瀏覽代碼

Moved StickyToolbar collection binding to ClassicEditorUIView#init.

Aleksander Nowodziński 9 年之前
父節點
當前提交
a675b853c2

+ 4 - 2
packages/ckeditor5-editor-classic/src/classiceditoruiview.js

@@ -44,6 +44,10 @@ export default class ClassicEditorUIView extends BoxedEditorUIView {
 	 * @inheritDoc
 	 */
 	init() {
+		for ( let name of this.editor.config.get( 'toolbar' ) ) {
+			this.toolbar.items.add( this.featureComponents.create( name ) );
+		}
+
 		this.toolbar.limiterElement = this.element;
 
 		return super.init();
@@ -70,8 +74,6 @@ export default class ClassicEditorUIView extends BoxedEditorUIView {
 		const toolbar = new StickyToolbarView( editor.locale );
 
 		toolbar.bind( 'isActive' ).to( editor.focusTracker, 'isFocused' );
-		toolbar.config = this.editor.config.get( 'toolbar' );
-
 		this.top.add( toolbar );
 
 		return toolbar;

+ 6 - 8
packages/ckeditor5-editor-classic/tests/classiceditoruiview.js

@@ -29,8 +29,12 @@ describe( 'ClassicEditorUI', () => {
 		editable = editor.editing.view.createRoot( document.createElement( 'div' ) );
 		editor.ui = view = new ClassicEditorUIView( editor, editor.locale );
 
-		view.featureComponents.add( 'foo', ButtonView, () => {} );
-		view.featureComponents.add( 'bar', ButtonView, () => {} );
+		function createButton( locale ) {
+			return new ButtonView( locale );
+		}
+
+		view.featureComponents.add( 'foo', createButton );
+		view.featureComponents.add( 'bar', createButton );
 	} );
 
 	describe( 'constructor', () => {
@@ -117,10 +121,4 @@ describe( 'ClassicEditorUI', () => {
 			} );
 		} );
 	} );
-
-	describe( '_createToolbar', () => {
-		it( 'passes editor#config to view.toolbar#config', () => {
-			expect( view.toolbar.config ).to.have.members( [ 'foo', 'bar' ] );
-		} );
-	} );
 } );