@ckeditor/ckeditor5-ui 36.0.1 → 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
|
@@ -13,6 +13,7 @@ import BalloonPanelView from '../../panel/balloon/balloonpanelview';
|
|
|
13
13
|
import ToolbarView from '../toolbarview';
|
|
14
14
|
import clickOutsideHandler from '../../bindings/clickoutsidehandler';
|
|
15
15
|
import normalizeToolbarConfig from '../normalizetoolbarconfig';
|
|
16
|
+
import '../../uiconfig';
|
|
16
17
|
const toPx = toUnit('px');
|
|
17
18
|
const { pilcrow } = icons;
|
|
18
19
|
/**
|
|
@@ -28,33 +29,39 @@ const { pilcrow } = icons;
|
|
|
28
29
|
* By default, the button is attached so its right boundary is touching the
|
|
29
30
|
* {@link module:engine/view/editableelement~EditableElement}:
|
|
30
31
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* ```
|
|
33
|
+
* __ |
|
|
34
|
+
* | || This is a block of content that the
|
|
35
|
+
* ¯¯ | button is attached to. This is a
|
|
36
|
+
* | block of content that the button is
|
|
37
|
+
* | attached to.
|
|
38
|
+
* ```
|
|
36
39
|
*
|
|
37
40
|
* The position of the button can be adjusted using the CSS `transform` property:
|
|
38
41
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
+
* ```css
|
|
43
|
+
* .ck-block-toolbar-button {
|
|
44
|
+
* transform: translateX( -10px );
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
42
47
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
+
* ```
|
|
49
|
+
* __ |
|
|
50
|
+
* | | | This is a block of content that the
|
|
51
|
+
* ¯¯ | button is attached to. This is a
|
|
52
|
+
* | block of content that the button is
|
|
53
|
+
* | attached to.
|
|
54
|
+
* ```
|
|
48
55
|
*
|
|
49
56
|
* **Note**: If you plan to run the editor in a right–to–left (RTL) language, keep in mind the button
|
|
50
57
|
* will be attached to the **right** boundary of the editable area. In that case, make sure the
|
|
51
58
|
* CSS position adjustment works properly by adding the following styles:
|
|
52
59
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
60
|
+
* ```css
|
|
61
|
+
* .ck[dir="rtl"] .ck-block-toolbar-button {
|
|
62
|
+
* transform: translateX( 10px );
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
58
65
|
*/
|
|
59
66
|
export default class BlockToolbar extends Plugin {
|
|
60
67
|
/**
|
|
@@ -68,31 +75,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
68
75
|
*/
|
|
69
76
|
constructor(editor) {
|
|
70
77
|
super(editor);
|
|
71
|
-
/**
|
|
72
|
-
* A cached and normalized `config.blockToolbar` object.
|
|
73
|
-
*
|
|
74
|
-
* @type {module:core/editor/editorconfig~EditorConfig#blockToolbar}
|
|
75
|
-
* @private
|
|
76
|
-
*/
|
|
77
|
-
this._blockToolbarConfig = normalizeToolbarConfig(this.editor.config.get('blockToolbar'));
|
|
78
|
-
/**
|
|
79
|
-
* The toolbar view.
|
|
80
|
-
*
|
|
81
|
-
* @type {module:ui/toolbar/toolbarview~ToolbarView}
|
|
82
|
-
*/
|
|
83
|
-
this.toolbarView = this._createToolbarView();
|
|
84
|
-
/**
|
|
85
|
-
* The balloon panel view, containing the {@link #toolbarView}.
|
|
86
|
-
*
|
|
87
|
-
* @type {module:ui/panel/balloon/balloonpanelview~BalloonPanelView}
|
|
88
|
-
*/
|
|
89
|
-
this.panelView = this._createPanelView();
|
|
90
|
-
/**
|
|
91
|
-
* The button view that opens the {@link #toolbarView}.
|
|
92
|
-
*
|
|
93
|
-
* @type {module:ui/toolbar/block/blockbuttonview~BlockButtonView}
|
|
94
|
-
*/
|
|
95
|
-
this.buttonView = this._createButtonView();
|
|
96
78
|
/**
|
|
97
79
|
* An instance of the resize observer that allows to respond to changes in editable's geometry
|
|
98
80
|
* so the toolbar can stay within its boundaries (and group toolbar items that do not fit).
|
|
@@ -101,11 +83,12 @@ export default class BlockToolbar extends Plugin {
|
|
|
101
83
|
* {@link module:core/editor/editorconfig~EditorConfig#blockToolbar configuration}.
|
|
102
84
|
*
|
|
103
85
|
* **Note:** Created in {@link #afterInit}.
|
|
104
|
-
*
|
|
105
|
-
* @protected
|
|
106
|
-
* @member {module:utils/dom/resizeobserver~ResizeObserver}
|
|
107
86
|
*/
|
|
108
87
|
this._resizeObserver = null;
|
|
88
|
+
this._blockToolbarConfig = normalizeToolbarConfig(this.editor.config.get('blockToolbar'));
|
|
89
|
+
this.toolbarView = this._createToolbarView();
|
|
90
|
+
this.panelView = this._createPanelView();
|
|
91
|
+
this.buttonView = this._createButtonView();
|
|
109
92
|
// Close the #panelView upon clicking outside of the plugin UI.
|
|
110
93
|
clickOutsideHandler({
|
|
111
94
|
emitter: this.panelView,
|
|
@@ -152,8 +135,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
152
135
|
* Fills the toolbar with its items based on the configuration.
|
|
153
136
|
*
|
|
154
137
|
* **Note:** This needs to be done after all plugins are ready.
|
|
155
|
-
*
|
|
156
|
-
* @inheritDoc
|
|
157
138
|
*/
|
|
158
139
|
afterInit() {
|
|
159
140
|
const factory = this.editor.ui.componentFactory;
|
|
@@ -188,9 +169,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
188
169
|
}
|
|
189
170
|
/**
|
|
190
171
|
* Creates the {@link #toolbarView}.
|
|
191
|
-
*
|
|
192
|
-
* @private
|
|
193
|
-
* @returns {module:ui/toolbar/toolbarview~ToolbarView}
|
|
194
172
|
*/
|
|
195
173
|
_createToolbarView() {
|
|
196
174
|
const t = this.editor.locale.t;
|
|
@@ -210,9 +188,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
210
188
|
}
|
|
211
189
|
/**
|
|
212
190
|
* Creates the {@link #panelView}.
|
|
213
|
-
*
|
|
214
|
-
* @private
|
|
215
|
-
* @returns {module:ui/panel/balloon/balloonpanelview~BalloonPanelView}
|
|
216
191
|
*/
|
|
217
192
|
_createPanelView() {
|
|
218
193
|
const editor = this.editor;
|
|
@@ -230,9 +205,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
230
205
|
}
|
|
231
206
|
/**
|
|
232
207
|
* Creates the {@link #buttonView}.
|
|
233
|
-
*
|
|
234
|
-
* @private
|
|
235
|
-
* @returns {module:ui/toolbar/block/blockbuttonview~BlockButtonView}
|
|
236
208
|
*/
|
|
237
209
|
_createButtonView() {
|
|
238
210
|
const editor = this.editor;
|
|
@@ -278,8 +250,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
278
250
|
/**
|
|
279
251
|
* Shows or hides the button.
|
|
280
252
|
* When all the conditions for displaying the button are matched, it shows the button. Hides otherwise.
|
|
281
|
-
*
|
|
282
|
-
* @private
|
|
283
253
|
*/
|
|
284
254
|
_updateButton() {
|
|
285
255
|
const editor = this.editor;
|
|
@@ -315,8 +285,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
315
285
|
}
|
|
316
286
|
/**
|
|
317
287
|
* Hides the button.
|
|
318
|
-
*
|
|
319
|
-
* @private
|
|
320
288
|
*/
|
|
321
289
|
_hideButton() {
|
|
322
290
|
this.buttonView.isVisible = false;
|
|
@@ -324,8 +292,6 @@ export default class BlockToolbar extends Plugin {
|
|
|
324
292
|
/**
|
|
325
293
|
* Shows the {@link #toolbarView} attached to the {@link #buttonView}.
|
|
326
294
|
* If the toolbar is already visible, then it simply repositions it.
|
|
327
|
-
*
|
|
328
|
-
* @private
|
|
329
295
|
*/
|
|
330
296
|
_showPanel() {
|
|
331
297
|
// Usually, the only way to show the toolbar is by pressing the block button. It makes it impossible for
|
|
@@ -372,8 +338,7 @@ export default class BlockToolbar extends Plugin {
|
|
|
372
338
|
/**
|
|
373
339
|
* Hides the {@link #toolbarView}.
|
|
374
340
|
*
|
|
375
|
-
* @
|
|
376
|
-
* @param {Boolean} [focusEditable=false] When `true`, the editable will be focused after hiding the panel.
|
|
341
|
+
* @param focusEditable When `true`, the editable will be focused after hiding the panel.
|
|
377
342
|
*/
|
|
378
343
|
_hidePanel(focusEditable) {
|
|
379
344
|
this.panelView.isVisible = false;
|
|
@@ -384,8 +349,7 @@ export default class BlockToolbar extends Plugin {
|
|
|
384
349
|
/**
|
|
385
350
|
* Attaches the {@link #buttonView} to the target block of content.
|
|
386
351
|
*
|
|
387
|
-
* @
|
|
388
|
-
* @param {HTMLElement} targetElement Target element.
|
|
352
|
+
* @param targetElement Target element.
|
|
389
353
|
*/
|
|
390
354
|
_attachButtonToElement(targetElement) {
|
|
391
355
|
const contentStyles = window.getComputedStyle(targetElement);
|
|
@@ -420,8 +384,7 @@ export default class BlockToolbar extends Plugin {
|
|
|
420
384
|
* Gets the {@link #toolbarView} max-width, based on
|
|
421
385
|
* editable width plus distance between farthest edge of the {@link #buttonView} and the editable.
|
|
422
386
|
*
|
|
423
|
-
* @
|
|
424
|
-
* @returns {String} maxWidth A maximum width that toolbar can have, in pixels.
|
|
387
|
+
* @returns A maximum width that toolbar can have, in pixels.
|
|
425
388
|
*/
|
|
426
389
|
_getToolbarMaxWidth() {
|
|
427
390
|
const editableElement = this.editor.ui.view.editable.element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolbarConfig, ToolbarConfigItem } from '@ckeditor/ckeditor5-core';
|
|
6
|
+
/**
|
|
7
|
+
* @module ui/toolbar/normalizetoolbarconfig
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes the toolbar configuration (`config.toolbar`), which:
|
|
11
|
+
*
|
|
12
|
+
* * may be defined as an `Array`:
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* toolbar: [ 'heading', 'bold', 'italic', 'link', ... ]
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* * or an `Object`:
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
* toolbar: {
|
|
22
|
+
* items: [ 'heading', 'bold', 'italic', 'link', ... ],
|
|
23
|
+
* removeItems: [ 'bold' ],
|
|
24
|
+
* ...
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* * or may not be defined at all (`undefined`)
|
|
29
|
+
*
|
|
30
|
+
* and returns it in the object form.
|
|
31
|
+
*
|
|
32
|
+
* @param config The value of `config.toolbar`.
|
|
33
|
+
* @returns A normalized toolbar config object.
|
|
34
|
+
*/
|
|
35
|
+
export default function normalizeToolbarConfig(config: ToolbarConfig | undefined): {
|
|
36
|
+
items: Array<ToolbarConfigItem>;
|
|
37
|
+
removeItems: Array<string>;
|
|
38
|
+
shouldNotGroupWhenFull?: boolean;
|
|
39
|
+
};
|
|
@@ -10,22 +10,26 @@
|
|
|
10
10
|
*
|
|
11
11
|
* * may be defined as an `Array`:
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* ```
|
|
14
|
+
* toolbar: [ 'heading', 'bold', 'italic', 'link', ... ]
|
|
15
|
+
* ```
|
|
14
16
|
*
|
|
15
17
|
* * or an `Object`:
|
|
16
18
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* ```
|
|
20
|
+
* toolbar: {
|
|
21
|
+
* items: [ 'heading', 'bold', 'italic', 'link', ... ],
|
|
22
|
+
* removeItems: [ 'bold' ],
|
|
23
|
+
* ...
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
22
26
|
*
|
|
23
27
|
* * or may not be defined at all (`undefined`)
|
|
24
28
|
*
|
|
25
29
|
* and returns it in the object form.
|
|
26
30
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
31
|
+
* @param config The value of `config.toolbar`.
|
|
32
|
+
* @returns A normalized toolbar config object.
|
|
29
33
|
*/
|
|
30
34
|
export default function normalizeToolbarConfig(config) {
|
|
31
35
|
if (Array.isArray(config)) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/toolbar/toolbarlinebreakview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
10
|
+
/**
|
|
11
|
+
* The toolbar line break view class.
|
|
12
|
+
*/
|
|
13
|
+
export default class ToolbarLineBreakView extends View {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
constructor(locale?: Locale);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/toolbar/toolbarseparatorview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
10
|
+
/**
|
|
11
|
+
* The toolbar separator view class.
|
|
12
|
+
*/
|
|
13
|
+
export default class ToolbarSeparatorView extends View {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
constructor(locale?: Locale);
|
|
18
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/toolbar/toolbarview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import type ComponentFactory from '../componentfactory';
|
|
10
|
+
import type ViewCollection from '../viewcollection';
|
|
11
|
+
import type DropdownPanelFocusable from '../dropdown/dropdownpanelfocusable';
|
|
12
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from '@ckeditor/ckeditor5-utils';
|
|
13
|
+
import { type ToolbarConfig } from '@ckeditor/ckeditor5-core';
|
|
14
|
+
import '../../theme/components/toolbar/toolbar.css';
|
|
15
|
+
/**
|
|
16
|
+
* The toolbar view class.
|
|
17
|
+
*/
|
|
18
|
+
export default class ToolbarView extends View implements DropdownPanelFocusable {
|
|
19
|
+
/**
|
|
20
|
+
* A reference to the options object passed to the constructor.
|
|
21
|
+
*/
|
|
22
|
+
readonly options: ToolbarOptions;
|
|
23
|
+
/**
|
|
24
|
+
* A collection of toolbar items (buttons, dropdowns, etc.).
|
|
25
|
+
*/
|
|
26
|
+
readonly items: ViewCollection;
|
|
27
|
+
/**
|
|
28
|
+
* Tracks information about the DOM focus in the toolbar.
|
|
29
|
+
*/
|
|
30
|
+
readonly focusTracker: FocusTracker;
|
|
31
|
+
/**
|
|
32
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}
|
|
33
|
+
* to handle keyboard navigation in the toolbar.
|
|
34
|
+
*/
|
|
35
|
+
readonly keystrokes: KeystrokeHandler;
|
|
36
|
+
/**
|
|
37
|
+
* A (child) view containing {@link #items toolbar items}.
|
|
38
|
+
*/
|
|
39
|
+
readonly itemsView: ItemsView;
|
|
40
|
+
/**
|
|
41
|
+
* A top–level collection aggregating building blocks of the toolbar.
|
|
42
|
+
*
|
|
43
|
+
* ┌───────────────── ToolbarView ─────────────────┐
|
|
44
|
+
* | ┌──────────────── #children ────────────────┐ |
|
|
45
|
+
* | | ┌──────────── #itemsView ───────────┐ | |
|
|
46
|
+
* | | | [ item1 ] [ item2 ] ... [ itemN ] | | |
|
|
47
|
+
* | | └──────────────────────────────────-┘ | |
|
|
48
|
+
* | └───────────────────────────────────────────┘ |
|
|
49
|
+
* └───────────────────────────────────────────────┘
|
|
50
|
+
*
|
|
51
|
+
* By default, it contains the {@link #itemsView} but it can be extended with additional
|
|
52
|
+
* UI elements when necessary.
|
|
53
|
+
*/
|
|
54
|
+
readonly children: ViewCollection;
|
|
55
|
+
/**
|
|
56
|
+
* A collection of {@link #items} that take part in the focus cycling
|
|
57
|
+
* (i.e. navigation using the keyboard). Usually, it contains a subset of {@link #items} with
|
|
58
|
+
* some optional UI elements that also belong to the toolbar and should be focusable
|
|
59
|
+
* by the user.
|
|
60
|
+
*/
|
|
61
|
+
readonly focusables: ViewCollection;
|
|
62
|
+
locale: Locale;
|
|
63
|
+
/**
|
|
64
|
+
* Label used by assistive technologies to describe this toolbar element.
|
|
65
|
+
*
|
|
66
|
+
* @observable
|
|
67
|
+
* @default 'Editor toolbar'
|
|
68
|
+
*/
|
|
69
|
+
ariaLabel: string;
|
|
70
|
+
/**
|
|
71
|
+
* The maximum width of the toolbar element.
|
|
72
|
+
*
|
|
73
|
+
* **Note**: When set to a specific value (e.g. `'200px'`), the value will affect the behavior of the
|
|
74
|
+
* {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull}
|
|
75
|
+
* option by changing the number of {@link #items} that will be displayed in the toolbar at a time.
|
|
76
|
+
*
|
|
77
|
+
* @observable
|
|
78
|
+
* @default 'auto'
|
|
79
|
+
*/
|
|
80
|
+
maxWidth: string;
|
|
81
|
+
/**
|
|
82
|
+
* An additional CSS class added to the {@link #element}.
|
|
83
|
+
*
|
|
84
|
+
* @observable
|
|
85
|
+
* @member {String} #class
|
|
86
|
+
*/
|
|
87
|
+
class: string | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* When set true, makes the toolbar look compact with {@link #element}.
|
|
90
|
+
*
|
|
91
|
+
* @observable
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
isCompact: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Controls the orientation of toolbar items. Only available when
|
|
97
|
+
* {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull dynamic items grouping}
|
|
98
|
+
* is **disabled**.
|
|
99
|
+
*
|
|
100
|
+
* @observable
|
|
101
|
+
*/
|
|
102
|
+
isVertical: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Helps cycling over {@link #focusables focusable items} in the toolbar.
|
|
105
|
+
*/
|
|
106
|
+
private readonly _focusCycler;
|
|
107
|
+
/**
|
|
108
|
+
* An instance of the active toolbar behavior that shapes its look and functionality.
|
|
109
|
+
*
|
|
110
|
+
* See {@link module:ui/toolbar/toolbarview~ToolbarBehavior} to learn more.
|
|
111
|
+
*/
|
|
112
|
+
private readonly _behavior;
|
|
113
|
+
/**
|
|
114
|
+
* Creates an instance of the {@link module:ui/toolbar/toolbarview~ToolbarView} class.
|
|
115
|
+
*
|
|
116
|
+
* Also see {@link #render}.
|
|
117
|
+
*
|
|
118
|
+
* @param locale The localization services instance.
|
|
119
|
+
* @param options Configuration options of the toolbar.
|
|
120
|
+
*/
|
|
121
|
+
constructor(locale: Locale, options?: ToolbarOptions);
|
|
122
|
+
/**
|
|
123
|
+
* @inheritDoc
|
|
124
|
+
*/
|
|
125
|
+
render(): void;
|
|
126
|
+
/**
|
|
127
|
+
* @inheritDoc
|
|
128
|
+
*/
|
|
129
|
+
destroy(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Focuses the first focusable in {@link #focusables}.
|
|
132
|
+
*/
|
|
133
|
+
focus(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Focuses the last focusable in {@link #focusables}.
|
|
136
|
+
*/
|
|
137
|
+
focusLast(): void;
|
|
138
|
+
/**
|
|
139
|
+
* A utility that expands the plain toolbar configuration into
|
|
140
|
+
* {@link module:ui/toolbar/toolbarview~ToolbarView#items} using a given component factory.
|
|
141
|
+
*
|
|
142
|
+
* @param itemsOrConfig The toolbar items or the entire toolbar configuration object.
|
|
143
|
+
* @param factory A factory producing toolbar items.
|
|
144
|
+
* @param removeItems An array of items names to be removed from the configuration. When present, applies
|
|
145
|
+
* to this toolbar and all nested ones as well.
|
|
146
|
+
*/
|
|
147
|
+
fillFromConfig(itemsOrConfig: ToolbarConfig | undefined, factory: ComponentFactory, removeItems?: Array<string>): void;
|
|
148
|
+
/**
|
|
149
|
+
* A utility that expands the plain toolbar configuration into a list of view items using a given component factory.
|
|
150
|
+
*
|
|
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
|
|
154
|
+
* to this toolbar and all nested ones as well.
|
|
155
|
+
*/
|
|
156
|
+
private _buildItemsFromConfig;
|
|
157
|
+
/**
|
|
158
|
+
* Cleans up the {@link module:ui/toolbar/toolbarview~ToolbarView#items} of the toolbar by removing unwanted items and
|
|
159
|
+
* duplicated (obsolete) separators or line breaks.
|
|
160
|
+
*
|
|
161
|
+
* @param items The toolbar items configuration.
|
|
162
|
+
* @param factory A factory producing toolbar items.
|
|
163
|
+
* @param removeItems An array of items names to be removed from the configuration.
|
|
164
|
+
* @returns Items after the clean-up.
|
|
165
|
+
*/
|
|
166
|
+
private _cleanItemsConfiguration;
|
|
167
|
+
/**
|
|
168
|
+
* Remove leading, trailing, and duplicated separators (`-` and `|`).
|
|
169
|
+
*
|
|
170
|
+
* @returns Toolbar items after the separator and line break clean-up.
|
|
171
|
+
*/
|
|
172
|
+
private _cleanSeparatorsAndLineBreaks;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a user-defined dropdown containing a toolbar with items.
|
|
175
|
+
*
|
|
176
|
+
* @param definition A definition of the nested toolbar dropdown.
|
|
177
|
+
* @param definition.label A label of the dropdown.
|
|
178
|
+
* @param definition.icon An icon of the drop-down. One of 'bold', 'plus', 'text', 'importExport', 'alignLeft',
|
|
179
|
+
* 'paragraph' or an SVG string. When `false` is passed, no icon will be used.
|
|
180
|
+
* @param definition.withText When set `true`, the label of the dropdown will be visible. See
|
|
181
|
+
* {@link module:ui/button/buttonview~ButtonView#withText} to learn more.
|
|
182
|
+
* @param definition.tooltip A tooltip of the dropdown button. See
|
|
183
|
+
* {@link module:ui/button/buttonview~ButtonView#tooltip} to learn more. Defaults to `true`.
|
|
184
|
+
* @param componentFactory Component factory used to create items
|
|
185
|
+
* of the nested toolbar.
|
|
186
|
+
*/
|
|
187
|
+
private _createNestedToolbarDropdown;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Fired when some toolbar {@link #items} were grouped or ungrouped as a result of some change
|
|
191
|
+
* in the toolbar geometry.
|
|
192
|
+
*
|
|
193
|
+
* **Note**: This event is always fired **once** regardless of the number of items that were be
|
|
194
|
+
* grouped or ungrouped at a time.
|
|
195
|
+
*
|
|
196
|
+
* **Note**: This event is fired only if the items grouping functionality was enabled in
|
|
197
|
+
* the first place (see {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull}).
|
|
198
|
+
*
|
|
199
|
+
* @eventName groupedItemsUpdate
|
|
200
|
+
*/
|
|
201
|
+
export type ToolbarViewGroupedItemsUpdateEvent = {
|
|
202
|
+
name: 'groupedItemsUpdate';
|
|
203
|
+
args: [];
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* An inner block of the {@link module:ui/toolbar/toolbarview~ToolbarView} hosting its
|
|
207
|
+
* {@link module:ui/toolbar/toolbarview~ToolbarView#items}.
|
|
208
|
+
*/
|
|
209
|
+
declare class ItemsView extends View {
|
|
210
|
+
/**
|
|
211
|
+
* A collection of items (buttons, dropdowns, etc.).
|
|
212
|
+
*/
|
|
213
|
+
readonly children: ViewCollection;
|
|
214
|
+
/**
|
|
215
|
+
* @inheritDoc
|
|
216
|
+
*/
|
|
217
|
+
constructor(locale?: Locale);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Options passed to the {@link module:ui/toolbar/toolbarview~ToolbarView#constructor} of the toolbar.
|
|
221
|
+
*/
|
|
222
|
+
export interface ToolbarOptions {
|
|
223
|
+
/**
|
|
224
|
+
* When set to `true`, the toolbar will automatically group {@link module:ui/toolbar/toolbarview~ToolbarView#items} that
|
|
225
|
+
* would normally wrap to the next line when there is not enough space to display them in a single row, for
|
|
226
|
+
* instance, if the parent container of the toolbar is narrow. For toolbars in absolutely positioned containers
|
|
227
|
+
* without width restrictions also the {@link module:ui/toolbar/toolbarview~ToolbarOptions#isFloating} option is required to be `true`.
|
|
228
|
+
*
|
|
229
|
+
* See also: {@link module:ui/toolbar/toolbarview~ToolbarView#maxWidth}.
|
|
230
|
+
*/
|
|
231
|
+
shouldGroupWhenFull?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* This option should be enabled for toolbars in absolutely positioned containers without width restrictions
|
|
234
|
+
* to enable automatic {@link module:ui/toolbar/toolbarview~ToolbarView#items} grouping.
|
|
235
|
+
* When this option is set to `true`, the items will stop wrapping to the next line
|
|
236
|
+
* and together with {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull},
|
|
237
|
+
* this will allow grouping them when there is not enough space in a single row.
|
|
238
|
+
*/
|
|
239
|
+
isFloating?: boolean;
|
|
240
|
+
}
|
|
241
|
+
export {};
|