Kaynağa Gözat

Code refactorin in the editor-inline package.

Internal: Aligned the UI to the latest API of the framework (see ckeditor/ckeditor5-ui#262).
Aleksander Nowodzinski 8 yıl önce
ebeveyn
işleme
ae14d4c308

+ 2 - 4
packages/ckeditor5-editor-inline/src/inlineeditorui.js

@@ -66,7 +66,7 @@ export default class InlineEditorUI {
 		// Set–up the view#panel.
 		view.panel.bind( 'isVisible' ).to( this.focusTracker, 'isFocused' );
 
-		if ( this._toolbarConfig && this._toolbarConfig.viewportTopOffset ) {
+		if ( this._toolbarConfig.viewportTopOffset ) {
 			view.viewportTopOffset = this._toolbarConfig.viewportTopOffset;
 		}
 
@@ -93,9 +93,7 @@ export default class InlineEditorUI {
 
 		this.focusTracker.add( view.editableElement );
 
-		if ( this._toolbarConfig ) {
-			view.toolbar.fillFromConfig( this._toolbarConfig.items, this.componentFactory );
-		}
+		view.toolbar.fillFromConfig( this._toolbarConfig.items, this.componentFactory );
 
 		enableToolbarKeyboardFocus( {
 			origin: editor.editing.view,

+ 16 - 34
packages/ckeditor5-editor-inline/tests/inlineeditorui.js

@@ -23,24 +23,24 @@ testUtils.createSinonSandbox();
 describe( 'InlineEditorUI', () => {
 	let editor, view, ui;
 
-	describe( 'constructor()', () => {
-		beforeEach( () => {
-			return VirtualInlineTestEditor
-				.create( {
-					toolbar: [ 'foo', 'bar' ],
-				} )
-				.then( newEditor => {
-					editor = newEditor;
-
-					ui = editor.ui;
-					view = ui.view;
-				} );
-		} );
+	beforeEach( () => {
+		return VirtualInlineTestEditor
+			.create( {
+				toolbar: [ 'foo', 'bar' ],
+			} )
+			.then( newEditor => {
+				editor = newEditor;
+
+				ui = editor.ui;
+				view = ui.view;
+			} );
+	} );
 
-		afterEach( () => {
-			editor.destroy();
-		} );
+	afterEach( () => {
+		editor.destroy();
+	} );
 
+	describe( 'constructor()', () => {
 		it( 'sets #editor', () => {
 			expect( ui.editor ).to.equal( editor );
 		} );
@@ -150,24 +150,6 @@ describe( 'InlineEditorUI', () => {
 	} );
 
 	describe( 'init()', () => {
-		beforeEach( () => {
-			return VirtualInlineTestEditor
-				.create( {
-					toolbar: [ 'foo', 'bar' ],
-				} )
-				.then( newEditor => {
-					editor = newEditor;
-
-					ui = editor.ui;
-					view = ui.view;
-				} );
-		} );
-
-		afterEach( () => {
-			ui.destroy();
-			editor.destroy();
-		} );
-
 		it( 'renders the #view', () => {
 			expect( view.isRendered ).to.be.true;
 		} );