@ckeditor/ckeditor5-ui 36.0.0 → 37.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +23 -22
- package/src/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
- package/src/bindings/addkeyboardhandlingforgrid.js +42 -34
- package/src/bindings/clickoutsidehandler.d.ts +28 -0
- package/src/bindings/clickoutsidehandler.js +5 -6
- package/src/bindings/csstransitiondisablermixin.d.ts +40 -0
- package/src/bindings/csstransitiondisablermixin.js +55 -0
- package/src/bindings/injectcsstransitiondisabler.d.ts +59 -0
- package/src/bindings/injectcsstransitiondisabler.js +23 -20
- package/src/bindings/preventdefault.d.ts +33 -0
- package/src/bindings/preventdefault.js +13 -15
- package/src/bindings/submithandler.d.ts +57 -0
- package/src/bindings/submithandler.js +22 -23
- package/src/button/button.d.ts +154 -0
- package/src/button/buttonview.d.ts +155 -0
- package/src/button/buttonview.js +16 -60
- package/src/button/switchbuttonview.d.ts +45 -0
- package/src/button/switchbuttonview.js +9 -18
- package/src/colorgrid/colorgridview.d.ts +132 -0
- package/src/colorgrid/colorgridview.js +8 -40
- package/src/colorgrid/colortileview.d.ts +28 -0
- package/src/colorgrid/colortileview.js +0 -13
- package/src/colorgrid/utils.d.ts +47 -0
- package/src/colorgrid/utils.js +7 -13
- package/src/componentfactory.d.ts +81 -0
- package/src/componentfactory.js +21 -35
- package/src/dropdown/button/dropdownbutton.d.ts +25 -0
- package/src/dropdown/button/dropdownbuttonview.d.ts +48 -0
- package/src/dropdown/button/dropdownbuttonview.js +11 -21
- package/src/dropdown/button/splitbuttonview.d.ts +145 -0
- package/src/dropdown/button/splitbuttonview.js +10 -51
- package/src/dropdown/dropdownpanelfocusable.d.ts +21 -0
- package/src/dropdown/dropdownpanelview.d.ts +62 -0
- package/src/dropdown/dropdownpanelview.js +2 -30
- package/src/dropdown/dropdownview.d.ts +315 -0
- package/src/dropdown/dropdownview.js +121 -222
- package/src/dropdown/utils.d.ts +219 -0
- package/src/dropdown/utils.js +112 -106
- package/src/editableui/editableuiview.d.ts +71 -0
- package/src/editableui/editableuiview.js +14 -43
- package/src/editableui/inline/inlineeditableuiview.d.ts +40 -0
- package/src/editableui/inline/inlineeditableuiview.js +5 -15
- package/src/editorui/bodycollection.d.ts +51 -0
- package/src/editorui/bodycollection.js +2 -16
- package/src/editorui/boxed/boxededitoruiview.d.ts +40 -0
- package/src/editorui/boxed/boxededitoruiview.js +1 -27
- package/src/editorui/editorui.d.ts +264 -0
- package/src/editorui/editorui.js +21 -128
- package/src/editorui/editoruiview.d.ts +39 -0
- package/src/editorui/editoruiview.js +1 -10
- package/src/focuscycler.d.ts +183 -0
- package/src/focuscycler.js +34 -90
- package/src/formheader/formheaderview.d.ts +53 -0
- package/src/formheader/formheaderview.js +3 -24
- package/src/icon/iconview.d.ts +78 -0
- package/src/icon/iconview.js +0 -50
- package/src/iframe/iframeview.d.ts +50 -0
- package/src/iframe/iframeview.js +2 -2
- package/src/index.d.ts +54 -0
- package/src/index.js +1 -0
- package/src/input/inputview.d.ts +121 -0
- package/src/input/inputview.js +0 -82
- package/src/inputnumber/inputnumberview.d.ts +49 -0
- package/src/inputnumber/inputnumberview.js +5 -28
- package/src/inputtext/inputtextview.d.ts +18 -0
- package/src/inputtext/inputtextview.js +0 -2
- package/src/label/labelview.d.ts +36 -0
- package/src/label/labelview.js +0 -20
- package/src/labeledfield/labeledfieldview.d.ts +182 -0
- package/src/labeledfield/labeledfieldview.js +20 -126
- package/src/labeledfield/utils.d.ts +93 -0
- package/src/labeledfield/utils.js +24 -18
- package/src/labeledinput/labeledinputview.d.ts +125 -0
- package/src/labeledinput/labeledinputview.js +7 -90
- package/src/list/listitemview.d.ts +35 -0
- package/src/list/listitemview.js +0 -16
- package/src/list/listseparatorview.d.ts +18 -0
- package/src/list/listseparatorview.js +0 -2
- package/src/list/listview.d.ts +59 -0
- package/src/list/listview.js +0 -33
- package/src/model.d.ts +22 -0
- package/src/model.js +2 -4
- package/src/notification/notification.d.ts +216 -0
- package/src/notification/notification.js +64 -51
- package/src/panel/balloon/balloonpanelview.d.ts +685 -0
- package/src/panel/balloon/balloonpanelview.js +146 -168
- package/src/panel/balloon/contextualballoon.d.ts +240 -0
- package/src/panel/balloon/contextualballoon.js +41 -171
- package/src/panel/sticky/stickypanelview.d.ts +132 -0
- package/src/panel/sticky/stickypanelview.js +0 -115
- package/src/template.d.ts +940 -0
- package/src/template.js +396 -460
- package/src/toolbar/balloon/balloontoolbar.d.ts +124 -0
- package/src/toolbar/balloon/balloontoolbar.js +15 -81
- package/src/toolbar/block/blockbuttonview.d.ts +35 -0
- package/src/toolbar/block/blockbuttonview.js +1 -13
- package/src/toolbar/block/blocktoolbar.d.ts +159 -0
- package/src/toolbar/block/blocktoolbar.js +32 -69
- package/src/toolbar/normalizetoolbarconfig.d.ts +39 -0
- package/src/toolbar/normalizetoolbarconfig.js +12 -8
- package/src/toolbar/toolbarlinebreakview.d.ts +18 -0
- package/src/toolbar/toolbarlinebreakview.js +0 -2
- package/src/toolbar/toolbarseparatorview.d.ts +18 -0
- package/src/toolbar/toolbarseparatorview.js +0 -2
- package/src/toolbar/toolbarview.d.ts +241 -0
- package/src/toolbar/toolbarview.js +54 -305
- package/src/tooltipmanager.d.ts +180 -0
- package/src/tooltipmanager.js +47 -94
- package/src/uiconfig.d.ts +82 -0
- package/src/uiconfig.js +5 -0
- package/src/view.d.ts +422 -0
- package/src/view.js +182 -251
- package/src/viewcollection.d.ts +139 -0
- package/src/viewcollection.js +62 -56
|
@@ -28,9 +28,6 @@ const NESTED_TOOLBAR_ICONS = {
|
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* The toolbar view class.
|
|
31
|
-
*
|
|
32
|
-
* @extends module:ui/view~View
|
|
33
|
-
* @implements module:ui/dropdown/dropdownpanelfocusable~DropdownPanelFocusable
|
|
34
31
|
*/
|
|
35
32
|
export default class ToolbarView extends View {
|
|
36
33
|
/**
|
|
@@ -38,127 +35,25 @@ export default class ToolbarView extends View {
|
|
|
38
35
|
*
|
|
39
36
|
* Also see {@link #render}.
|
|
40
37
|
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
38
|
+
* @param locale The localization services instance.
|
|
39
|
+
* @param options Configuration options of the toolbar.
|
|
43
40
|
*/
|
|
44
41
|
constructor(locale, options) {
|
|
45
42
|
super(locale);
|
|
46
43
|
const bind = this.bindTemplate;
|
|
47
44
|
const t = this.t;
|
|
48
|
-
/**
|
|
49
|
-
* A reference to the options object passed to the constructor.
|
|
50
|
-
*
|
|
51
|
-
* @readonly
|
|
52
|
-
* @member {module:ui/toolbar/toolbarview~ToolbarOptions}
|
|
53
|
-
*/
|
|
54
45
|
this.options = options || {};
|
|
55
|
-
/**
|
|
56
|
-
* Label used by assistive technologies to describe this toolbar element.
|
|
57
|
-
*
|
|
58
|
-
* @default 'Editor toolbar'
|
|
59
|
-
* @member {String} #ariaLabel
|
|
60
|
-
*/
|
|
61
46
|
this.set('ariaLabel', t('Editor toolbar'));
|
|
62
|
-
/**
|
|
63
|
-
* The maximum width of the toolbar element.
|
|
64
|
-
*
|
|
65
|
-
* **Note**: When set to a specific value (e.g. `'200px'`), the value will affect the behavior of the
|
|
66
|
-
* {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull}
|
|
67
|
-
* option by changing the number of {@link #items} that will be displayed in the toolbar at a time.
|
|
68
|
-
*
|
|
69
|
-
* @observable
|
|
70
|
-
* @default 'auto'
|
|
71
|
-
* @member {String} #maxWidth
|
|
72
|
-
*/
|
|
73
47
|
this.set('maxWidth', 'auto');
|
|
74
|
-
/**
|
|
75
|
-
* A collection of toolbar items (buttons, dropdowns, etc.).
|
|
76
|
-
*
|
|
77
|
-
* @readonly
|
|
78
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
79
|
-
*/
|
|
80
48
|
this.items = this.createCollection();
|
|
81
|
-
/**
|
|
82
|
-
* Tracks information about the DOM focus in the toolbar.
|
|
83
|
-
*
|
|
84
|
-
* @readonly
|
|
85
|
-
* @member {module:utils/focustracker~FocusTracker}
|
|
86
|
-
*/
|
|
87
49
|
this.focusTracker = new FocusTracker();
|
|
88
|
-
/**
|
|
89
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}
|
|
90
|
-
* to handle keyboard navigation in the toolbar.
|
|
91
|
-
*
|
|
92
|
-
* @readonly
|
|
93
|
-
* @member {module:utils/keystrokehandler~KeystrokeHandler}
|
|
94
|
-
*/
|
|
95
50
|
this.keystrokes = new KeystrokeHandler();
|
|
96
|
-
/**
|
|
97
|
-
* An additional CSS class added to the {@link #element}.
|
|
98
|
-
*
|
|
99
|
-
* @observable
|
|
100
|
-
* @member {String} #class
|
|
101
|
-
*/
|
|
102
51
|
this.set('class', undefined);
|
|
103
|
-
/**
|
|
104
|
-
* When set true, makes the toolbar look compact with {@link #element}.
|
|
105
|
-
*
|
|
106
|
-
* @observable
|
|
107
|
-
* @default false
|
|
108
|
-
* @member {String} #isCompact
|
|
109
|
-
*/
|
|
110
52
|
this.set('isCompact', false);
|
|
111
|
-
/**
|
|
112
|
-
* A (child) view containing {@link #items toolbar items}.
|
|
113
|
-
*
|
|
114
|
-
* @readonly
|
|
115
|
-
* @member {module:ui/toolbar/toolbarview~ItemsView}
|
|
116
|
-
*/
|
|
117
53
|
this.itemsView = new ItemsView(locale);
|
|
118
|
-
/**
|
|
119
|
-
* A top–level collection aggregating building blocks of the toolbar.
|
|
120
|
-
*
|
|
121
|
-
* ┌───────────────── ToolbarView ─────────────────┐
|
|
122
|
-
* | ┌──────────────── #children ────────────────┐ |
|
|
123
|
-
* | | ┌──────────── #itemsView ───────────┐ | |
|
|
124
|
-
* | | | [ item1 ] [ item2 ] ... [ itemN ] | | |
|
|
125
|
-
* | | └──────────────────────────────────-┘ | |
|
|
126
|
-
* | └───────────────────────────────────────────┘ |
|
|
127
|
-
* └───────────────────────────────────────────────┘
|
|
128
|
-
*
|
|
129
|
-
* By default, it contains the {@link #itemsView} but it can be extended with additional
|
|
130
|
-
* UI elements when necessary.
|
|
131
|
-
*
|
|
132
|
-
* @readonly
|
|
133
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
134
|
-
*/
|
|
135
54
|
this.children = this.createCollection();
|
|
136
55
|
this.children.add(this.itemsView);
|
|
137
|
-
/**
|
|
138
|
-
* A collection of {@link #items} that take part in the focus cycling
|
|
139
|
-
* (i.e. navigation using the keyboard). Usually, it contains a subset of {@link #items} with
|
|
140
|
-
* some optional UI elements that also belong to the toolbar and should be focusable
|
|
141
|
-
* by the user.
|
|
142
|
-
*
|
|
143
|
-
* @readonly
|
|
144
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
145
|
-
*/
|
|
146
56
|
this.focusables = this.createCollection();
|
|
147
|
-
/**
|
|
148
|
-
* Controls the orientation of toolbar items. Only available when
|
|
149
|
-
* {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull dynamic items grouping}
|
|
150
|
-
* is **disabled**.
|
|
151
|
-
*
|
|
152
|
-
* @observable
|
|
153
|
-
* @member {Boolean} #isVertical
|
|
154
|
-
*/
|
|
155
|
-
/**
|
|
156
|
-
* Helps cycling over {@link #focusables focusable items} in the toolbar.
|
|
157
|
-
*
|
|
158
|
-
* @readonly
|
|
159
|
-
* @protected
|
|
160
|
-
* @member {module:ui/focuscycler~FocusCycler}
|
|
161
|
-
*/
|
|
162
57
|
const isRtl = locale.uiLanguageDirection === 'rtl';
|
|
163
58
|
this._focusCycler = new FocusCycler({
|
|
164
59
|
focusables: this.focusables,
|
|
@@ -196,15 +91,6 @@ export default class ToolbarView extends View {
|
|
|
196
91
|
mousedown: preventDefault(this)
|
|
197
92
|
}
|
|
198
93
|
});
|
|
199
|
-
/**
|
|
200
|
-
* An instance of the active toolbar behavior that shapes its look and functionality.
|
|
201
|
-
*
|
|
202
|
-
* See {@link module:ui/toolbar/toolbarview~ToolbarBehavior} to learn more.
|
|
203
|
-
*
|
|
204
|
-
* @protected
|
|
205
|
-
* @readonly
|
|
206
|
-
* @member {module:ui/toolbar/toolbarview~ToolbarBehavior}
|
|
207
|
-
*/
|
|
208
94
|
this._behavior = this.options.shouldGroupWhenFull ? new DynamicGrouping(this) : new StaticLayout(this);
|
|
209
95
|
}
|
|
210
96
|
/**
|
|
@@ -251,9 +137,9 @@ export default class ToolbarView extends View {
|
|
|
251
137
|
* A utility that expands the plain toolbar configuration into
|
|
252
138
|
* {@link module:ui/toolbar/toolbarview~ToolbarView#items} using a given component factory.
|
|
253
139
|
*
|
|
254
|
-
* @param
|
|
255
|
-
* @param
|
|
256
|
-
* @param
|
|
140
|
+
* @param itemsOrConfig The toolbar items or the entire toolbar configuration object.
|
|
141
|
+
* @param factory A factory producing toolbar items.
|
|
142
|
+
* @param removeItems An array of items names to be removed from the configuration. When present, applies
|
|
257
143
|
* to this toolbar and all nested ones as well.
|
|
258
144
|
*/
|
|
259
145
|
fillFromConfig(itemsOrConfig, factory, removeItems) {
|
|
@@ -262,9 +148,9 @@ export default class ToolbarView extends View {
|
|
|
262
148
|
/**
|
|
263
149
|
* A utility that expands the plain toolbar configuration into a list of view items using a given component factory.
|
|
264
150
|
*
|
|
265
|
-
* @param
|
|
266
|
-
* @param
|
|
267
|
-
* @param
|
|
151
|
+
* @param itemsOrConfig The toolbar items or the entire toolbar configuration object.
|
|
152
|
+
* @param factory A factory producing toolbar items.
|
|
153
|
+
* @param removeItems An array of items names to be removed from the configuration. When present, applies
|
|
268
154
|
* to this toolbar and all nested ones as well.
|
|
269
155
|
*/
|
|
270
156
|
_buildItemsFromConfig(itemsOrConfig, factory, removeItems) {
|
|
@@ -290,11 +176,10 @@ export default class ToolbarView extends View {
|
|
|
290
176
|
* Cleans up the {@link module:ui/toolbar/toolbarview~ToolbarView#items} of the toolbar by removing unwanted items and
|
|
291
177
|
* duplicated (obsolete) separators or line breaks.
|
|
292
178
|
*
|
|
293
|
-
* @
|
|
294
|
-
* @param
|
|
295
|
-
* @param
|
|
296
|
-
* @
|
|
297
|
-
* @returns {Array.<String>} Items after the clean-up.
|
|
179
|
+
* @param items The toolbar items configuration.
|
|
180
|
+
* @param factory A factory producing toolbar items.
|
|
181
|
+
* @param removeItems An array of items names to be removed from the configuration.
|
|
182
|
+
* @returns Items after the clean-up.
|
|
298
183
|
*/
|
|
299
184
|
_cleanItemsConfiguration(items, factory, removeItems) {
|
|
300
185
|
const filteredItems = items
|
|
@@ -315,12 +200,14 @@ export default class ToolbarView extends View {
|
|
|
315
200
|
* is disabled in the toolbar configuration.
|
|
316
201
|
* To do this, set the `shouldNotGroupWhenFull` option to `true` in the editor configuration:
|
|
317
202
|
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* const config = {
|
|
205
|
+
* toolbar: {
|
|
206
|
+
* items: [ ... ],
|
|
207
|
+
* shouldNotGroupWhenFull: true
|
|
208
|
+
* }
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
324
211
|
*
|
|
325
212
|
* Learn more about {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar configuration}.
|
|
326
213
|
*
|
|
@@ -345,10 +232,12 @@ export default class ToolbarView extends View {
|
|
|
345
232
|
*
|
|
346
233
|
* You can use the following snippet to retrieve all available toolbar items:
|
|
347
234
|
*
|
|
348
|
-
*
|
|
235
|
+
* ```ts
|
|
236
|
+
* Array.from( editor.ui.componentFactory.names() );
|
|
237
|
+
* ```
|
|
349
238
|
*
|
|
350
239
|
* @error toolbarview-item-unavailable
|
|
351
|
-
* @param
|
|
240
|
+
* @param item The name of the component or nested toolbar definition.
|
|
352
241
|
*/
|
|
353
242
|
logWarning('toolbarview-item-unavailable', { item });
|
|
354
243
|
return false;
|
|
@@ -360,9 +249,7 @@ export default class ToolbarView extends View {
|
|
|
360
249
|
/**
|
|
361
250
|
* Remove leading, trailing, and duplicated separators (`-` and `|`).
|
|
362
251
|
*
|
|
363
|
-
* @
|
|
364
|
-
* @param {Array.<String>} items
|
|
365
|
-
* @returns {Array.<String>} Toolbar items after the separator and line break clean-up.
|
|
252
|
+
* @returns Toolbar items after the separator and line break clean-up.
|
|
366
253
|
*/
|
|
367
254
|
_cleanSeparatorsAndLineBreaks(items) {
|
|
368
255
|
const nonSeparatorPredicate = (item) => (item !== '-' && item !== '|');
|
|
@@ -394,18 +281,16 @@ export default class ToolbarView extends View {
|
|
|
394
281
|
/**
|
|
395
282
|
* Creates a user-defined dropdown containing a toolbar with items.
|
|
396
283
|
*
|
|
397
|
-
* @
|
|
398
|
-
* @param
|
|
399
|
-
* @param
|
|
400
|
-
* @param {String|Boolean} [definition.icon] An icon of the drop-down. One of 'bold', 'plus', 'text', 'importExport', 'alignLeft',
|
|
284
|
+
* @param definition A definition of the nested toolbar dropdown.
|
|
285
|
+
* @param definition.label A label of the dropdown.
|
|
286
|
+
* @param definition.icon An icon of the drop-down. One of 'bold', 'plus', 'text', 'importExport', 'alignLeft',
|
|
401
287
|
* 'paragraph' or an SVG string. When `false` is passed, no icon will be used.
|
|
402
|
-
* @param
|
|
288
|
+
* @param definition.withText When set `true`, the label of the dropdown will be visible. See
|
|
403
289
|
* {@link module:ui/button/buttonview~ButtonView#withText} to learn more.
|
|
404
|
-
* @param
|
|
405
|
-
* {@link module:ui/button/buttonview~ButtonView#tooltip} to learn more.
|
|
406
|
-
* @param
|
|
290
|
+
* @param definition.tooltip A tooltip of the dropdown button. See
|
|
291
|
+
* {@link module:ui/button/buttonview~ButtonView#tooltip} to learn more. Defaults to `true`.
|
|
292
|
+
* @param componentFactory Component factory used to create items
|
|
407
293
|
* of the nested toolbar.
|
|
408
|
-
* @returns {module:ui/dropdown/dropdownview~DropdownView}
|
|
409
294
|
*/
|
|
410
295
|
_createNestedToolbarDropdown(definition, componentFactory, removeItems) {
|
|
411
296
|
let { label, icon, items, tooltip = true, withText = false } = definition;
|
|
@@ -423,11 +308,13 @@ export default class ToolbarView extends View {
|
|
|
423
308
|
* Without a label, the dropdown becomes inaccessible to users relying on assistive technologies.
|
|
424
309
|
* Make sure the `label` property is set in your drop-down configuration:
|
|
425
310
|
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
311
|
+
* ```json
|
|
312
|
+
* {
|
|
313
|
+
* label: 'A human-readable label',
|
|
314
|
+
* icon: '...',
|
|
315
|
+
* items: [ ... ]
|
|
316
|
+
* },
|
|
317
|
+
* ```
|
|
431
318
|
*
|
|
432
319
|
* Learn more about {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar configuration}.
|
|
433
320
|
*
|
|
@@ -457,9 +344,6 @@ export default class ToolbarView extends View {
|
|
|
457
344
|
/**
|
|
458
345
|
* An inner block of the {@link module:ui/toolbar/toolbarview~ToolbarView} hosting its
|
|
459
346
|
* {@link module:ui/toolbar/toolbarview~ToolbarView#items}.
|
|
460
|
-
*
|
|
461
|
-
* @private
|
|
462
|
-
* @extends module:ui/view~View
|
|
463
347
|
*/
|
|
464
348
|
class ItemsView extends View {
|
|
465
349
|
/**
|
|
@@ -467,12 +351,6 @@ class ItemsView extends View {
|
|
|
467
351
|
*/
|
|
468
352
|
constructor(locale) {
|
|
469
353
|
super(locale);
|
|
470
|
-
/**
|
|
471
|
-
* A collection of items (buttons, dropdowns, etc.).
|
|
472
|
-
*
|
|
473
|
-
* @readonly
|
|
474
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
475
|
-
*/
|
|
476
354
|
this.children = this.createCollection();
|
|
477
355
|
this.setTemplate({
|
|
478
356
|
tag: 'div',
|
|
@@ -490,17 +368,13 @@ class ItemsView extends View {
|
|
|
490
368
|
* A toolbar behavior that makes it static and unresponsive to the changes of the environment.
|
|
491
369
|
* At the same time, it also makes it possible to display a toolbar with a vertical layout
|
|
492
370
|
* using the {@link module:ui/toolbar/toolbarview~ToolbarView#isVertical} property.
|
|
493
|
-
*
|
|
494
|
-
* @private
|
|
495
|
-
* @implements module:ui/toolbar/toolbarview~ToolbarBehavior
|
|
496
371
|
*/
|
|
497
372
|
class StaticLayout {
|
|
498
373
|
/**
|
|
499
374
|
* Creates an instance of the {@link module:ui/toolbar/toolbarview~StaticLayout} toolbar
|
|
500
375
|
* behavior.
|
|
501
376
|
*
|
|
502
|
-
* @param
|
|
503
|
-
* is added to.
|
|
377
|
+
* @param view An instance of the toolbar that this behavior is added to.
|
|
504
378
|
*/
|
|
505
379
|
constructor(view) {
|
|
506
380
|
const bind = view.bindTemplate;
|
|
@@ -535,110 +409,25 @@ class StaticLayout {
|
|
|
535
409
|
* that do not fit visually into a single row of the toolbar (due to limited space).
|
|
536
410
|
* Items that do not fit are aggregated in a dropdown displayed at the end of the toolbar.
|
|
537
411
|
*
|
|
412
|
+
* ```
|
|
538
413
|
* ┌──────────────────────────────────────── ToolbarView ──────────────────────────────────────────┐
|
|
539
414
|
* | ┌─────────────────────────────────────── #children ─────────────────────────────────────────┐ |
|
|
540
415
|
* | | ┌─────── #itemsView ────────┐ ┌──────────────────────┐ ┌── #groupedItemsDropdown ───┐ | |
|
|
541
416
|
* | | | #ungroupedItems | | ToolbarSeparatorView | | #groupedItems | | |
|
|
542
417
|
* | | └──────────────────────────-┘ └──────────────────────┘ └────────────────────────────┘ | |
|
|
543
|
-
* | | \---------- only when toolbar items overflow
|
|
418
|
+
* | | \---------- only when toolbar items overflow -------/ | |
|
|
544
419
|
* | └───────────────────────────────────────────────────────────────────────────────────────────┘ |
|
|
545
420
|
* └───────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
546
|
-
*
|
|
547
|
-
* @private
|
|
548
|
-
* @implements module:ui/toolbar/toolbarview~ToolbarBehavior
|
|
421
|
+
* ```
|
|
549
422
|
*/
|
|
550
423
|
class DynamicGrouping {
|
|
551
424
|
/**
|
|
552
425
|
* Creates an instance of the {@link module:ui/toolbar/toolbarview~DynamicGrouping} toolbar
|
|
553
426
|
* behavior.
|
|
554
427
|
*
|
|
555
|
-
* @param
|
|
556
|
-
* is added to.
|
|
428
|
+
* @param view An instance of the toolbar that this behavior is added to.
|
|
557
429
|
*/
|
|
558
430
|
constructor(view) {
|
|
559
|
-
/**
|
|
560
|
-
* A toolbar view this behavior belongs to.
|
|
561
|
-
*
|
|
562
|
-
* @readonly
|
|
563
|
-
* @member {module:ui/toolbar~ToolbarView}
|
|
564
|
-
*/
|
|
565
|
-
this.view = view;
|
|
566
|
-
/**
|
|
567
|
-
* A collection of toolbar children.
|
|
568
|
-
*
|
|
569
|
-
* @readonly
|
|
570
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
571
|
-
*/
|
|
572
|
-
this.viewChildren = view.children;
|
|
573
|
-
/**
|
|
574
|
-
* A collection of focusable toolbar elements.
|
|
575
|
-
*
|
|
576
|
-
* @readonly
|
|
577
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
578
|
-
*/
|
|
579
|
-
this.viewFocusables = view.focusables;
|
|
580
|
-
/**
|
|
581
|
-
* A view containing toolbar items.
|
|
582
|
-
*
|
|
583
|
-
* @readonly
|
|
584
|
-
* @member {module:ui/toolbar/toolbarview~ItemsView}
|
|
585
|
-
*/
|
|
586
|
-
this.viewItemsView = view.itemsView;
|
|
587
|
-
/**
|
|
588
|
-
* Toolbar focus tracker.
|
|
589
|
-
*
|
|
590
|
-
* @readonly
|
|
591
|
-
* @member {module:utils/focustracker~FocusTracker}
|
|
592
|
-
*/
|
|
593
|
-
this.viewFocusTracker = view.focusTracker;
|
|
594
|
-
/**
|
|
595
|
-
* Toolbar locale.
|
|
596
|
-
*
|
|
597
|
-
* @readonly
|
|
598
|
-
* @member {module:utils/locale~Locale}
|
|
599
|
-
*/
|
|
600
|
-
this.viewLocale = view.locale;
|
|
601
|
-
/**
|
|
602
|
-
* Toolbar element.
|
|
603
|
-
*
|
|
604
|
-
* @readonly
|
|
605
|
-
* @member {HTMLElement} #viewElement
|
|
606
|
-
*/
|
|
607
|
-
/**
|
|
608
|
-
* A subset of toolbar {@link module:ui/toolbar/toolbarview~ToolbarView#items}.
|
|
609
|
-
* Aggregates items that fit into a single row of the toolbar and were not {@link #groupedItems grouped}
|
|
610
|
-
* into a {@link #groupedItemsDropdown dropdown}. Items of this collection are displayed in the
|
|
611
|
-
* {@link module:ui/toolbar/toolbarview~ToolbarView#itemsView}.
|
|
612
|
-
*
|
|
613
|
-
* When none of the {@link module:ui/toolbar/toolbarview~ToolbarView#items} were grouped, it
|
|
614
|
-
* matches the {@link module:ui/toolbar/toolbarview~ToolbarView#items} collection in size and order.
|
|
615
|
-
*
|
|
616
|
-
* @readonly
|
|
617
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
618
|
-
*/
|
|
619
|
-
this.ungroupedItems = view.createCollection();
|
|
620
|
-
/**
|
|
621
|
-
* A subset of toolbar {@link module:ui/toolbar/toolbarview~ToolbarView#items}.
|
|
622
|
-
* A collection of the toolbar items that do not fit into a single row of the toolbar.
|
|
623
|
-
* Grouped items are displayed in a dedicated {@link #groupedItemsDropdown dropdown}.
|
|
624
|
-
*
|
|
625
|
-
* When none of the {@link module:ui/toolbar/toolbarview~ToolbarView#items} were grouped,
|
|
626
|
-
* this collection is empty.
|
|
627
|
-
*
|
|
628
|
-
* @readonly
|
|
629
|
-
* @member {module:ui/viewcollection~ViewCollection}
|
|
630
|
-
*/
|
|
631
|
-
this.groupedItems = view.createCollection();
|
|
632
|
-
/**
|
|
633
|
-
* The dropdown that aggregates {@link #groupedItems grouped items} that do not fit into a single
|
|
634
|
-
* row of the toolbar. It is displayed on demand as the last of
|
|
635
|
-
* {@link module:ui/toolbar/toolbarview~ToolbarView#children toolbar children} and offers another
|
|
636
|
-
* (nested) toolbar which displays items that would normally overflow.
|
|
637
|
-
*
|
|
638
|
-
* @readonly
|
|
639
|
-
* @member {module:ui/dropdown/dropdownview~DropdownView}
|
|
640
|
-
*/
|
|
641
|
-
this.groupedItemsDropdown = this._createGroupedItemsDropdown();
|
|
642
431
|
/**
|
|
643
432
|
* An instance of the resize observer that helps dynamically determine the geometry of the toolbar
|
|
644
433
|
* and manage items that do not fit into a single row.
|
|
@@ -646,7 +435,6 @@ class DynamicGrouping {
|
|
|
646
435
|
* **Note:** Created in {@link #_enableGroupingOnResize}.
|
|
647
436
|
*
|
|
648
437
|
* @readonly
|
|
649
|
-
* @member {module:utils/dom/resizeobserver~ResizeObserver}
|
|
650
438
|
*/
|
|
651
439
|
this.resizeObserver = null;
|
|
652
440
|
/**
|
|
@@ -656,7 +444,6 @@ class DynamicGrouping {
|
|
|
656
444
|
* the padding will change and re–using `Window.getComputedStyle()` is expensive.
|
|
657
445
|
*
|
|
658
446
|
* @readonly
|
|
659
|
-
* @member {Number}
|
|
660
447
|
*/
|
|
661
448
|
this.cachedPadding = null;
|
|
662
449
|
/**
|
|
@@ -664,9 +451,17 @@ class DynamicGrouping {
|
|
|
664
451
|
* and should be executed immediately the next time the toolbar shows up.
|
|
665
452
|
*
|
|
666
453
|
* @readonly
|
|
667
|
-
* @member {Boolean}
|
|
668
454
|
*/
|
|
669
455
|
this.shouldUpdateGroupingOnNextResize = false;
|
|
456
|
+
this.view = view;
|
|
457
|
+
this.viewChildren = view.children;
|
|
458
|
+
this.viewFocusables = view.focusables;
|
|
459
|
+
this.viewItemsView = view.itemsView;
|
|
460
|
+
this.viewFocusTracker = view.focusTracker;
|
|
461
|
+
this.viewLocale = view.locale;
|
|
462
|
+
this.ungroupedItems = view.createCollection();
|
|
463
|
+
this.groupedItems = view.createCollection();
|
|
464
|
+
this.groupedItemsDropdown = this._createGroupedItemsDropdown();
|
|
670
465
|
// Only those items that were not grouped are visible to the user.
|
|
671
466
|
view.itemsView.children.bindTo(this.ungroupedItems).using(item => item);
|
|
672
467
|
// Make sure all #items visible in the main space of the toolbar are "focuscycleable".
|
|
@@ -717,8 +512,7 @@ class DynamicGrouping {
|
|
|
717
512
|
/**
|
|
718
513
|
* Enables dynamic items grouping based on the dimensions of the toolbar.
|
|
719
514
|
*
|
|
720
|
-
* @param
|
|
721
|
-
* is added to.
|
|
515
|
+
* @param view An instance of the toolbar that this behavior is added to.
|
|
722
516
|
*/
|
|
723
517
|
render(view) {
|
|
724
518
|
this.viewElement = view.element;
|
|
@@ -741,8 +535,6 @@ class DynamicGrouping {
|
|
|
741
535
|
* At the same time, it will also check if there is enough space in the toolbar for the first of the
|
|
742
536
|
* {@link #groupedItems} to be returned back to {@link #ungroupedItems} and still fit into a single row
|
|
743
537
|
* without the toolbar wrapping.
|
|
744
|
-
*
|
|
745
|
-
* @protected
|
|
746
538
|
*/
|
|
747
539
|
_updateGrouping() {
|
|
748
540
|
// Do no grouping–related geometry analysis when the toolbar is detached from visible DOM,
|
|
@@ -796,9 +588,6 @@ class DynamicGrouping {
|
|
|
796
588
|
/**
|
|
797
589
|
* Returns `true` when {@link module:ui/toolbar/toolbarview~ToolbarView#element} children visually overflow,
|
|
798
590
|
* for instance if the toolbar is narrower than its members. Returns `false` otherwise.
|
|
799
|
-
*
|
|
800
|
-
* @private
|
|
801
|
-
* @type {Boolean}
|
|
802
591
|
*/
|
|
803
592
|
get _areItemsOverflowing() {
|
|
804
593
|
// An empty toolbar cannot overflow.
|
|
@@ -833,8 +622,6 @@ class DynamicGrouping {
|
|
|
833
622
|
* them in the dropdown if necessary. It will also observe the browser window for size changes in
|
|
834
623
|
* the future and respond to them by grouping more items or reverting already grouped back, depending
|
|
835
624
|
* on the visual space available.
|
|
836
|
-
*
|
|
837
|
-
* @private
|
|
838
625
|
*/
|
|
839
626
|
_enableGroupingOnResize() {
|
|
840
627
|
let previousWidth;
|
|
@@ -851,8 +638,6 @@ class DynamicGrouping {
|
|
|
851
638
|
/**
|
|
852
639
|
* Enables the grouping functionality, just like {@link #_enableGroupingOnResize} but the difference is that
|
|
853
640
|
* it listens to the changes of {@link module:ui/toolbar/toolbarview~ToolbarView#maxWidth} instead.
|
|
854
|
-
*
|
|
855
|
-
* @private
|
|
856
641
|
*/
|
|
857
642
|
_enableGroupingOnMaxWidthChange(view) {
|
|
858
643
|
view.on('change:maxWidth', () => {
|
|
@@ -864,8 +649,6 @@ class DynamicGrouping {
|
|
|
864
649
|
* to the {@link #groupedItems} collection.
|
|
865
650
|
*
|
|
866
651
|
* The opposite of {@link #_ungroupFirstItem}.
|
|
867
|
-
*
|
|
868
|
-
* @private
|
|
869
652
|
*/
|
|
870
653
|
_groupLastItem() {
|
|
871
654
|
if (!this.groupedItems.length) {
|
|
@@ -880,8 +663,6 @@ class DynamicGrouping {
|
|
|
880
663
|
* to the {@link #ungroupedItems} collection.
|
|
881
664
|
*
|
|
882
665
|
* The opposite of {@link #_groupLastItem}.
|
|
883
|
-
*
|
|
884
|
-
* @private
|
|
885
666
|
*/
|
|
886
667
|
_ungroupFirstItem() {
|
|
887
668
|
this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first));
|
|
@@ -894,9 +675,6 @@ class DynamicGrouping {
|
|
|
894
675
|
/**
|
|
895
676
|
* Creates the {@link #groupedItemsDropdown} that hosts the members of the {@link #groupedItems}
|
|
896
677
|
* collection when there is not enough space in the toolbar to display all items in a single row.
|
|
897
|
-
*
|
|
898
|
-
* @private
|
|
899
|
-
* @returns {module:ui/dropdown/dropdownview~DropdownView}
|
|
900
678
|
*/
|
|
901
679
|
_createGroupedItemsDropdown() {
|
|
902
680
|
const locale = this.viewLocale;
|
|
@@ -924,8 +702,6 @@ class DynamicGrouping {
|
|
|
924
702
|
*
|
|
925
703
|
* See the {@link module:ui/toolbar/toolbarview~ToolbarView#focusables collection} documentation
|
|
926
704
|
* to learn more about the purpose of this method.
|
|
927
|
-
*
|
|
928
|
-
* @private
|
|
929
705
|
*/
|
|
930
706
|
_updateFocusCycleableItems() {
|
|
931
707
|
this.viewFocusables.clear();
|
|
@@ -937,30 +713,3 @@ class DynamicGrouping {
|
|
|
937
713
|
}
|
|
938
714
|
}
|
|
939
715
|
}
|
|
940
|
-
/**
|
|
941
|
-
* Creates a new toolbar behavior instance.
|
|
942
|
-
*
|
|
943
|
-
* The instance is created in the {@link module:ui/toolbar/toolbarview~ToolbarView#constructor} of the toolbar.
|
|
944
|
-
* This is the right place to extend the {@link module:ui/toolbar/toolbarview~ToolbarView#template} of
|
|
945
|
-
* the toolbar, define extra toolbar properties, etc.
|
|
946
|
-
*
|
|
947
|
-
* @method #constructor
|
|
948
|
-
* @param {module:ui/toolbar/toolbarview~ToolbarView} view An instance of the toolbar that this behavior is added to.
|
|
949
|
-
*/
|
|
950
|
-
/**
|
|
951
|
-
* A method called after the toolbar has been {@link module:ui/toolbar/toolbarview~ToolbarView#render rendered}.
|
|
952
|
-
* It can be used to, for example, customize the behavior of the toolbar when its {@link module:ui/toolbar/toolbarview~ToolbarView#element}
|
|
953
|
-
* is available.
|
|
954
|
-
*
|
|
955
|
-
* @readonly
|
|
956
|
-
* @member {Function} #render
|
|
957
|
-
* @param {module:ui/toolbar/toolbarview~ToolbarView} view An instance of the toolbar being rendered.
|
|
958
|
-
*/
|
|
959
|
-
/**
|
|
960
|
-
* A method called after the toolbar has been {@link module:ui/toolbar/toolbarview~ToolbarView#destroy destroyed}.
|
|
961
|
-
* It allows cleaning up after the toolbar behavior, for instance, this is the right place to detach
|
|
962
|
-
* event listeners, free up references, etc.
|
|
963
|
-
*
|
|
964
|
-
* @readonly
|
|
965
|
-
* @member {Function} #destroy
|
|
966
|
-
*/
|