浏览代码

Add config option for inline toolbar to set if shouldn't group items

panr 5 年之前
父节点
当前提交
201f94e6f5

+ 3 - 1
packages/ckeditor5-editor-inline/src/inlineeditor.js

@@ -73,7 +73,9 @@ export default class InlineEditor extends Editor {
 			secureSourceElement( this );
 		}
 
-		const view = new InlineEditorUIView( this.locale, this.editing.view, this.sourceElement );
+		const shouldToolbarGroupWhenFull = !this.config.get( 'toolbar.shouldNotGroupWhenFull' );
+
+		const view = new InlineEditorUIView( this.locale, this.editing.view, this.sourceElement, { shouldToolbarGroupWhenFull } );
 		this.ui = new InlineEditorUI( this, view );
 
 		attachToForm( this );

+ 8 - 5
packages/ckeditor5-editor-inline/src/inlineeditorui.js

@@ -159,12 +159,15 @@ export default class InlineEditorUI extends EditorUI {
 			toolbar
 		} );
 
-		// Set toolbar's max-width on the initialization and update it on the editable resize.
-		const widthObserver = getResizeObserver( ( [ entry ] ) => {
-			this._setToolbarMaxWidth( entry.contentRect.width );
-		} );
+		// Set toolbar's max-width on the initialization and update it on the editable resize,
+		// if 'shouldToolbarGroupWhenFull' in config is set to 'true'.
+		if ( !this._toolbarConfig.shouldNotGroupWhenFull ) {
+			const widthObserver = getResizeObserver( ( [ entry ] ) => {
+				this._setToolbarMaxWidth( entry.contentRect.width );
+			} );
 
-		widthObserver.observe( editableElement );
+			widthObserver.observe( editableElement );
+		}
 	}
 
 	/**

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

@@ -26,7 +26,7 @@ export default class InlineEditorUIView extends EditorUIView {
 	 * @param {HTMLElement} [editableElement] The editable element. If not specified, it will be automatically created by
 	 * {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
 	 */
-	constructor( locale, editingView, editableElement ) {
+	constructor( locale, editingView, editableElement, options = {} ) {
 		super( locale );
 
 		/**
@@ -35,7 +35,7 @@ export default class InlineEditorUIView extends EditorUIView {
 		 * @readonly
 		 * @member {module:ui/toolbar/toolbarview~ToolbarView}
 		 */
-		this.toolbar = new ToolbarView( locale, { shouldGroupWhenFull: true } );
+		this.toolbar = new ToolbarView( locale, { shouldGroupWhenFull: options.shouldToolbarGroupWhenFull } );
 
 		/**
 		 * The offset from the top edge of the web browser's viewport which makes the