浏览代码

Aligned Editor Inline package to the synchronous UI API.

Aleksander Nowodzinski 8 年之前
父节点
当前提交
11d8b7f82f

+ 7 - 4
packages/ckeditor5-editor-inline/src/inlineeditor.js

@@ -47,8 +47,9 @@ export default class InlineEditor extends StandardEditor {
 		// It's safe to assume that the model->view conversion will not work after super.destroy().
 		const data = this.getData();
 
-		return this.ui.destroy()
-			.then( () => super.destroy() )
+		this.ui.destroy();
+
+		return super.destroy()
 			.then( () => setDataInElement( this.element, data ) );
 	}
 
@@ -77,8 +78,10 @@ export default class InlineEditor extends StandardEditor {
 
 			resolve(
 				editor.initPlugins()
-					.then( () => editor.ui.init() )
-					.then( () => editor.fire( 'uiReady' ) )
+					.then( () => {
+						editor.ui.init();
+						editor.fire( 'uiReady' );
+					} )
 					.then( () => editor.loadDataFromEditorElement() )
 					.then( () => {
 						editor.fire( 'dataReady' );

+ 10 - 17
packages/ckeditor5-editor-inline/src/inlineeditorui.js

@@ -73,32 +73,25 @@ export default class InlineEditorUI {
 
 	/**
 	 * Initializes the UI.
-	 *
-	 * @returns {Promise} A Promise resolved when the initialization process is finished.
 	 */
 	init() {
 		const editor = this.editor;
 
-		return this.view.init()
-			.then( () => {
-				return this.view.toolbar.fillFromConfig( editor.config.get( 'toolbar' ), this.componentFactory );
-			} )
-			.then( () => {
-				enableToolbarKeyboardFocus( {
-					origin: editor.editing.view,
-					originFocusTracker: this.focusTracker,
-					originKeystrokeHandler: editor.keystrokes,
-					toolbar: this.view.toolbar
-				} );
-			} );
+		this.view.init();
+		this.view.toolbar.fillFromConfig( editor.config.get( 'toolbar' ), this.componentFactory );
+
+		enableToolbarKeyboardFocus( {
+			origin: editor.editing.view,
+			originFocusTracker: this.focusTracker,
+			originKeystrokeHandler: editor.keystrokes,
+			toolbar: this.view.toolbar
+		} );
 	}
 
 	/**
 	 * Destroys the UI.
-	 *
-	 * @returns {Promise} A Promise resolved when the destruction process is finished.
 	 */
 	destroy() {
-		return this.view.destroy();
+		this.view.destroy();
 	}
 }

+ 3 - 2
packages/ckeditor5-editor-inline/src/inlineeditoruiview.js

@@ -100,8 +100,9 @@ export default class InlineEditorUIView extends EditorUIView {
 	 * @inheritDoc
 	 */
 	init() {
-		return super.init()
-			.then( () => this.panel.content.add( this.toolbar ) );
+		super.init();
+
+		this.panel.content.add( this.toolbar );
 	}
 
 	/**

+ 18 - 41
packages/ckeditor5-editor-inline/tests/inlineeditorui.js

@@ -123,71 +123,48 @@ describe( 'InlineEditorUI', () => {
 
 	describe( 'init()', () => {
 		afterEach( () => {
-			return ui.destroy();
-		} );
-
-		it( 'returns a promise', () => {
-			const promise = ui.init().then( () => {
-				expect( promise ).to.be.instanceof( Promise );
-			} );
-
-			return promise;
+			ui.destroy();
 		} );
 
 		it( 'initializes the #view', () => {
 			const spy = sinon.spy( view, 'init' );
 
-			return ui.init().then( () => {
-				sinon.assert.calledOnce( spy );
-			} );
+			ui.init();
+			sinon.assert.calledOnce( spy );
 		} );
 
 		it( 'fills view.toolbar#items with editor config', () => {
 			const spy = testUtils.sinon.spy( view.toolbar, 'fillFromConfig' );
 
-			return ui.init().then( () => {
-				sinon.assert.calledWithExactly( spy, editor.config.get( 'toolbar' ), ui.componentFactory );
-			} );
+			ui.init();
+			sinon.assert.calledWithExactly( spy, editor.config.get( 'toolbar' ), ui.componentFactory );
 		} );
 
 		it( 'initializes keyboard navigation between view#toolbar and view#editable', () => {
 			const spy = testUtils.sinon.spy( view.toolbar, 'focus' );
 
-			return ui.init().then( () => {
-				ui.focusTracker.isFocused = true;
-				ui.view.toolbar.focusTracker.isFocused = false;
-
-				editor.keystrokes.press( {
-					keyCode: keyCodes.f10,
-					altKey: true,
-					preventDefault: sinon.spy(),
-					stopPropagation: sinon.spy()
-				} );
+			ui.init();
+			ui.focusTracker.isFocused = true;
+			ui.view.toolbar.focusTracker.isFocused = false;
 
-				sinon.assert.calledOnce( spy );
+			editor.keystrokes.press( {
+				keyCode: keyCodes.f10,
+				altKey: true,
+				preventDefault: sinon.spy(),
+				stopPropagation: sinon.spy()
 			} );
+
+			sinon.assert.calledOnce( spy );
 		} );
 	} );
 
 	describe( 'destroy()', () => {
-		it( 'returns a promise', () => {
-			return ui.init().then( () => {
-				const promise = ui.destroy().then( () => {
-					expect( promise ).to.be.instanceof( Promise );
-				} );
-
-				return promise;
-			} );
-		} );
-
 		it( 'destroys the #view', () => {
 			const spy = sinon.spy( view, 'destroy' );
 
-			return ui.init()
-				.then( () => ui.destroy() )
-				.then( () => {
-					sinon.assert.calledOnce( spy );
-				} );
+			ui.init();
+			ui.destroy();
+			sinon.assert.calledOnce( spy );
 		} );
 	} );
 } );

+ 9 - 15
packages/ckeditor5-editor-inline/tests/inlineeditoruiview.js

@@ -67,11 +67,9 @@ describe( 'InlineEditorUIView', () => {
 			it( 'is registered as a child', () => {
 				const spy = sinon.spy( view.editable, 'destroy' );
 
-				return view.init()
-					.then( () => view.destroy() )
-					.then( () => {
-						sinon.assert.calledOnce( spy );
-					} );
+				view.init();
+				view.destroy();
+				sinon.assert.calledOnce( spy );
 			} );
 		} );
 	} );
@@ -80,21 +78,17 @@ describe( 'InlineEditorUIView', () => {
 		it( 'appends #toolbar to panel#content', () => {
 			expect( view.panel.content ).to.have.length( 0 );
 
-			return view.init()
-				.then( () => {
-					expect( view.panel.content.get( 0 ) ).to.equal( view.toolbar );
-				} )
-				.then( () => view.destroy() );
+			view.init();
+			expect( view.panel.content.get( 0 ) ).to.equal( view.toolbar );
+			view.destroy();
 		} );
 	} );
 
 	describe( 'editableElement', () => {
 		it( 'returns editable\'s view element', () => {
-			return view.init()
-				.then( () => {
-					expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
-				} )
-				.then( () => view.destroy() );
+			view.init();
+			expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
+			view.destroy();
 		} );
 	} );