This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +56
-5
lines changed
Expand file tree Collapse file tree 4 files changed +56
-5
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,12 @@ export default class ClassicEditor extends Editor {
7070
7171 this . model . document . createRoot ( ) ;
7272
73- this . ui = new ClassicEditorUI ( this , new ClassicEditorUIView ( this . locale , this . editing . view ) ) ;
73+ const shouldToolbarGroupWhenFull = ! this . config . get ( 'toolbar.shouldNotGroupWhenFull' ) ;
74+ const view = new ClassicEditorUIView ( this . locale , this . editing . view , {
75+ shouldToolbarGroupWhenFull
76+ } ) ;
77+
78+ this . ui = new ClassicEditorUI ( this , view ) ;
7479
7580 attachToForm ( this ) ;
7681 }
Original file line number Diff line number Diff line change @@ -26,8 +26,12 @@ export default class ClassicEditorUIView extends BoxedEditorUIView {
2626 *
2727 * @param {module:utils/locale~Locale } locale The {@link module:core/editor/editor~Editor#locale} instance.
2828 * @param {module:engine/view/view~View } editingView The editing view instance this view is related to.
29+ * @param {Object } [options={}] Configuration options fo the view instance.
30+ * @param {Boolean } [options.shouldToolbarGroupWhenFull] When set `true` enables automatic items grouping
31+ * in the main {@link module:editor-classic/classiceditoruiview~ClassicEditorUIView#toolbar toolbar}.
32+ * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
2933 */
30- constructor ( locale , editingView ) {
34+ constructor ( locale , editingView , options = { } ) {
3135 super ( locale ) ;
3236
3337 /**
@@ -46,7 +50,7 @@ export default class ClassicEditorUIView extends BoxedEditorUIView {
4650 * @member {module:ui/toolbar/toolbarview~ToolbarView}
4751 */
4852 this . toolbar = new ToolbarView ( locale , {
49- shouldGroupWhenFull : true
53+ shouldGroupWhenFull : options . shouldToolbarGroupWhenFull
5054 } ) ;
5155
5256 /**
Original file line number Diff line number Diff line change @@ -102,6 +102,30 @@ describe( 'ClassicEditor', () => {
102102 expect ( editor . ui ) . to . be . instanceof ( ClassicEditorUI ) ;
103103 expect ( editor . ui . view ) . to . be . instanceof ( ClassicEditorUIView ) ;
104104 } ) ;
105+
106+ describe ( 'automatic toolbar items groupping' , ( ) => {
107+ it ( 'should be on by default' , ( ) => {
108+ const editorElement = document . createElement ( 'div' ) ;
109+ const editor = new ClassicEditor ( editorElement ) ;
110+
111+ expect ( editor . ui . view . toolbar . options . shouldGroupWhenFull ) . to . be . true ;
112+
113+ editorElement . remove ( ) ;
114+ } ) ;
115+
116+ it ( 'can be disabled using config.toolbar.shouldNotGroupWhenFull' , ( ) => {
117+ const editorElement = document . createElement ( 'div' ) ;
118+ const editor = new ClassicEditor ( editorElement , {
119+ toolbar : {
120+ shouldNotGroupWhenFull : true
121+ }
122+ } ) ;
123+
124+ expect ( editor . ui . view . toolbar . options . shouldGroupWhenFull ) . to . be . false ;
125+
126+ editorElement . remove ( ) ;
127+ } ) ;
128+ } ) ;
105129 } ) ;
106130 } ) ;
107131
Original file line number Diff line number Diff line change @@ -59,8 +59,26 @@ describe( 'ClassicEditorUIView', () => {
5959 expect ( view . stickyPanel . content . get ( 0 ) ) . to . equal ( view . toolbar ) ;
6060 } ) ;
6161
62- it ( 'has automatic items grouping enabled' , ( ) => {
63- expect ( view . toolbar . options . shouldGroupWhenFull ) . to . be . true ;
62+ describe ( 'automatic items grouping' , ( ) => {
63+ it ( 'should be disabled by default' , ( ) => {
64+ expect ( view . toolbar . options . shouldGroupWhenFull ) . to . be . undefined ;
65+ } ) ;
66+
67+ it ( 'should be controlled via options.shouldToolbarGroupWhenFull' , ( ) => {
68+ const locale = new Locale ( ) ;
69+ const editingView = new EditingView ( ) ;
70+ const editingViewRoot = createRoot ( editingView . document ) ;
71+ const view = new ClassicEditorUIView ( locale , editingView , {
72+ shouldToolbarGroupWhenFull : true
73+ } ) ;
74+
75+ view . editable . name = editingViewRoot . rootName ;
76+ view . render ( ) ;
77+
78+ expect ( view . toolbar . options . shouldGroupWhenFull ) . to . be . true ;
79+
80+ return view . destroy ( ) ;
81+ } ) ;
6482 } ) ;
6583 } ) ;
6684
You can’t perform that action at this time.
0 commit comments