8
0
فهرست منبع

Passed the editable element as a limiter to StickyToolbarView constructor.

Aleksander Nowodzinski 9 سال پیش
والد
کامیت
a13b7a1d06
2فایلهای تغییر یافته به همراه29 افزوده شده و 13 حذف شده
  1. 12 8
      packages/ckeditor5-editor-classic/src/classiceditorui.js
  2. 17 5
      packages/ckeditor5-editor-classic/tests/classiceditorui.js

+ 12 - 8
packages/ckeditor5-editor-classic/src/classiceditorui.js

@@ -29,20 +29,24 @@ export default class ClassicEditorUI extends BoxedEditorUI {
 		super( editor );
 		super( editor );
 
 
 		/**
 		/**
-		 * Toolbar controller.
+		 * Editable UI controller.
 		 *
 		 *
 		 * @readonly
 		 * @readonly
-		 * @member {ui.toolbar.Toolbar} editor-classic.ClassicEditorUI#toolbar
+		 * @member {ui.editableUI.EditableUI} editor-classic.ClassicEditorUI#editable
 		 */
 		 */
-		this.toolbar = this._createToolbar();
+		this.editable = this._createEditableUI();
+	}
 
 
+	init() {
 		/**
 		/**
-		 * Editable UI controller.
+		 * Toolbar controller.
 		 *
 		 *
 		 * @readonly
 		 * @readonly
-		 * @member {ui.editableUI.EditableUI} editor-classic.ClassicEditorUI#editable
+		 * @member {ui.toolbar.Toolbar} editor-classic.ClassicEditorUI#toolbar
 		 */
 		 */
-		this.editable = this._createEditableUI();
+		this.toolbar = this._createToolbar( this.editor.ui.view.element );
+
+		return super.init();
 	}
 	}
 
 
 	/**
 	/**
@@ -61,7 +65,7 @@ export default class ClassicEditorUI extends BoxedEditorUI {
 	 * @protected
 	 * @protected
 	 * @returns {ui.toolbar.Toolbar}
 	 * @returns {ui.toolbar.Toolbar}
 	 */
 	 */
-	_createToolbar() {
+	_createToolbar( editorUiElement ) {
 		const editor = this.editor;
 		const editor = this.editor;
 		const model = new Model( {
 		const model = new Model( {
 			config: this.editor.config.get( 'toolbar' )
 			config: this.editor.config.get( 'toolbar' )
@@ -69,7 +73,7 @@ export default class ClassicEditorUI extends BoxedEditorUI {
 
 
 		model.bind( 'isActive' ).to( editor.editing.view.getRoot(), 'isFocused' );
 		model.bind( 'isActive' ).to( editor.editing.view.getRoot(), 'isFocused' );
 
 
-		const toolbar = new StickyToolbar( model, new StickyToolbarView( editor.locale ), editor );
+		const toolbar = new StickyToolbar( model, new StickyToolbarView( editor.locale, editorUiElement ), editor );
 		this.add( 'top', toolbar );
 		this.add( 'top', toolbar );
 
 
 		return toolbar;
 		return toolbar;

+ 17 - 5
packages/ckeditor5-editor-classic/tests/classiceditorui.js

@@ -40,11 +40,6 @@ describe( 'ClassicEditorUI', () => {
 	} );
 	} );
 
 
 	describe( 'constructor', () => {
 	describe( 'constructor', () => {
-		it( 'creates toolbar', () => {
-			expect( editorUI.toolbar ).to.be.instanceof( Toolbar );
-			expect( editorUI.toolbar.view ).to.be.instanceof( StickyToolbarView );
-		} );
-
 		it( 'creates editable', () => {
 		it( 'creates editable', () => {
 			expect( editorUI.editable ).to.be.instanceof( EditableUI );
 			expect( editorUI.editable ).to.be.instanceof( EditableUI );
 			expect( editorUI.editable.view ).to.be.instanceof( InlineEditableUIView );
 			expect( editorUI.editable.view ).to.be.instanceof( InlineEditableUIView );
@@ -68,11 +63,28 @@ describe( 'ClassicEditorUI', () => {
 
 
 			expect( editorUI.init() ).to.be.instanceof( Promise );
 			expect( editorUI.init() ).to.be.instanceof( Promise );
 		} );
 		} );
+
+		it( 'creates toolbar', ( done ) => {
+			return editorUI.init().then( () => {
+				expect( editorUI.toolbar ).to.be.instanceof( Toolbar );
+				expect( editorUI.toolbar.view ).to.be.instanceof( StickyToolbarView );
+
+				done();
+			} );
+		} );
 	} );
 	} );
 
 
 	describe( '_createToolbar', () => {
 	describe( '_createToolbar', () => {
+		beforeEach( () => {
+			return editorUI.init();
+		} );
+
 		it( 'passes toolbar config to the model', () => {
 		it( 'passes toolbar config to the model', () => {
 			expect( editorUI.toolbar.model.config ).to.have.members( [ 'foo', 'bar' ] );
 			expect( editorUI.toolbar.model.config ).to.have.members( [ 'foo', 'bar' ] );
 		} );
 		} );
+
+		it( 'passes the limiter element to the view constructor', () => {
+			expect( editorUI.toolbar.view.limiterElement ).to.equal( editorUI.view.element );
+		} );
 	} );
 	} );
 } );
 } );