Răsfoiți Sursa

Added additional class to the ToolbarView in BlockToolbar.

Oskar Wróbel 7 ani în urmă
părinte
comite
f0c8f7658d

+ 22 - 1
packages/ckeditor5-ui/src/toolbar/block/blocktoolbar.js

@@ -79,7 +79,7 @@ export default class BlockToolbar extends Plugin {
 		 *
 		 * @type {module:ui/toolbar/toolbarview~ToolbarView}
 		 */
-		this.toolbarView = new ToolbarView( editor.locale );
+		this.toolbarView = this._createToolbarView();
 
 		/**
 		 * Panel view.
@@ -134,6 +134,27 @@ export default class BlockToolbar extends Plugin {
 		}
 	}
 
+	/**
+	 * Creates toolbar view.
+	 *
+	 * @private
+	 * @returns {module:ui/toolbar/toolbarview~ToolbarView}
+	 */
+	_createToolbarView() {
+		const toolbarView = new ToolbarView( this.editor.locale );
+
+		toolbarView.extendTemplate( {
+			attributes: {
+				class: [
+					// https://github.com/ckeditor/ckeditor5-editor-inline/issues/11
+					'ck-toolbar_floating'
+				]
+			}
+		} );
+
+		return toolbarView;
+	}
+
 	/**
 	 * Creates panel view.
 	 *

+ 4 - 0
packages/ckeditor5-ui/tests/toolbar/block/blocktoolbar.js

@@ -116,6 +116,10 @@ describe( 'BlockToolbar', () => {
 				expect( blockToolbar.toolbarView ).to.instanceof( ToolbarView );
 			} );
 
+			it( 'should add additional class to toolbar element', () => {
+				expect( blockToolbar.toolbarView.element.classList.contains( 'ck-toolbar_floating' ) ).to.true;
+			} );
+
 			it( 'should be added to panelView#content collection', () => {
 				expect( Array.from( blockToolbar.panelView.content ) ).to.include( blockToolbar.toolbarView );
 			} );