@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
package/src/dropdown/utils.js
CHANGED
|
@@ -30,57 +30,63 @@ import '../../theme/components/dropdown/listdropdown.css';
|
|
|
30
30
|
* By default, the default {@link module:ui/dropdown/button/dropdownbuttonview~DropdownButtonView} class is used as
|
|
31
31
|
* definition of the button:
|
|
32
32
|
*
|
|
33
|
-
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const dropdown = createDropdown( model );
|
|
34
35
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
* // Configure dropdown's button properties:
|
|
37
|
+
* dropdown.buttonView.set( {
|
|
38
|
+
* label: 'A dropdown',
|
|
39
|
+
* withText: true
|
|
40
|
+
* } );
|
|
40
41
|
*
|
|
41
|
-
*
|
|
42
|
+
* dropdown.render();
|
|
42
43
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
44
|
+
* // Will render a dropdown labeled "A dropdown" with an empty panel.
|
|
45
|
+
* document.body.appendChild( dropdown.element );
|
|
46
|
+
* ```
|
|
45
47
|
*
|
|
46
48
|
* You can also provide other button views (they need to implement the
|
|
47
49
|
* {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface). For instance, you can use
|
|
48
50
|
* {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} to create a dropdown with a split button.
|
|
49
51
|
*
|
|
50
|
-
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* const dropdown = createDropdown( locale, SplitButtonView );
|
|
51
54
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* // Configure dropdown's button properties:
|
|
56
|
+
* dropdown.buttonView.set( {
|
|
57
|
+
* label: 'A dropdown',
|
|
58
|
+
* withText: true
|
|
59
|
+
* } );
|
|
57
60
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
61
|
+
* dropdown.buttonView.on( 'execute', () => {
|
|
62
|
+
* // Add the behavior of the "action part" of the split button.
|
|
63
|
+
* // Split button consists of the "action part" and "arrow part".
|
|
64
|
+
* // The arrow opens the dropdown while the action part can have some other behavior.
|
|
65
|
+
* } );
|
|
63
66
|
*
|
|
64
|
-
*
|
|
67
|
+
* dropdown.render();
|
|
65
68
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
69
|
+
* // Will render a dropdown labeled "A dropdown" with an empty panel.
|
|
70
|
+
* document.body.appendChild( dropdown.element );
|
|
71
|
+
* ```
|
|
68
72
|
*
|
|
69
73
|
* # Adding content to the dropdown's panel
|
|
70
74
|
*
|
|
71
75
|
* The content of the panel can be inserted directly into the `dropdown.panelView.element`:
|
|
72
76
|
*
|
|
73
|
-
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* dropdown.panelView.element.textContent = 'Content of the panel';
|
|
79
|
+
* ```
|
|
74
80
|
*
|
|
75
81
|
* However, most of the time you will want to add there either a {@link module:ui/list/listview~ListView list of options}
|
|
76
82
|
* or a list of buttons (i.e. a {@link module:ui/toolbar/toolbarview~ToolbarView toolbar}).
|
|
77
83
|
* To simplify the task, you can use, respectively, {@link module:ui/dropdown/utils~addListToDropdown} or
|
|
78
84
|
* {@link module:ui/dropdown/utils~addToolbarToDropdown} utils.
|
|
79
85
|
*
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
86
|
+
* @param locale The locale instance.
|
|
87
|
+
* @param ButtonClass The dropdown button view class. Needs to implement the
|
|
82
88
|
* {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface.
|
|
83
|
-
* @returns
|
|
89
|
+
* @returns The dropdown view instance.
|
|
84
90
|
*/
|
|
85
91
|
export function createDropdown(locale, ButtonClass = DropdownButtonView) {
|
|
86
92
|
const buttonView = new ButtonClass(locale);
|
|
@@ -99,23 +105,25 @@ export function createDropdown(locale, ButtonClass = DropdownButtonView) {
|
|
|
99
105
|
/**
|
|
100
106
|
* Adds an instance of {@link module:ui/toolbar/toolbarview~ToolbarView} to a dropdown.
|
|
101
107
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
108
|
+
* ```ts
|
|
109
|
+
* const buttonsCreator = () => {
|
|
110
|
+
* const buttons = [];
|
|
104
111
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
112
|
+
* // Either create a new ButtonView instance or create existing.
|
|
113
|
+
* buttons.push( new ButtonView() );
|
|
114
|
+
* buttons.push( editor.ui.componentFactory.create( 'someButton' ) );
|
|
115
|
+
* };
|
|
109
116
|
*
|
|
110
|
-
*
|
|
117
|
+
* const dropdown = createDropdown( locale );
|
|
111
118
|
*
|
|
112
|
-
*
|
|
119
|
+
* addToolbarToDropdown( dropdown, buttonsCreator, { isVertical: true } );
|
|
113
120
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
121
|
+
* // Will render a vertical button dropdown labeled "A button dropdown"
|
|
122
|
+
* // with a button group in the panel containing two buttons.
|
|
123
|
+
* // Buttons inside the dropdown will be created on first dropdown panel open.
|
|
124
|
+
* dropdown.render()
|
|
125
|
+
* document.body.appendChild( dropdown.element );
|
|
126
|
+
* ```
|
|
119
127
|
*
|
|
120
128
|
* **Note:** To improve the accessibility, you can tell the dropdown to focus the first active button of the toolbar when the dropdown
|
|
121
129
|
* {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}. See the documentation of `options` to learn more.
|
|
@@ -124,21 +132,19 @@ export function createDropdown(locale, ButtonClass = DropdownButtonView) {
|
|
|
124
132
|
*
|
|
125
133
|
* See {@link module:ui/dropdown/utils~createDropdown} and {@link module:ui/toolbar/toolbarview~ToolbarView}.
|
|
126
134
|
*
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @param {Object} [options]
|
|
130
|
-
* @param {Boolean} [options.enableActiveItemFocusOnDropdownOpen=false] When set `true`, the focus will automatically move to the first
|
|
135
|
+
* @param dropdownView A dropdown instance to which `ToolbarView` will be added.
|
|
136
|
+
* @param options.enableActiveItemFocusOnDropdownOpen When set `true`, the focus will automatically move to the first
|
|
131
137
|
* active {@link module:ui/toolbar/toolbarview~ToolbarView#items item} of the toolbar upon
|
|
132
138
|
* {@link module:ui/dropdown/dropdownview~DropdownView#isOpen opening} the dropdown. Active items are those with the `isOn` property set
|
|
133
139
|
* `true` (for instance {@link module:ui/button/buttonview~ButtonView buttons}). If no active items is found, the toolbar will be focused
|
|
134
140
|
* as a whole resulting in the focus moving to its first focusable item (default behavior of
|
|
135
141
|
* {@link module:ui/dropdown/dropdownview~DropdownView}).
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
142
|
+
* @param options.ariaLabel Label used by assistive technologies to describe toolbar element.
|
|
143
|
+
* @param options.maxWidth The maximum width of the toolbar element.
|
|
138
144
|
* Details: {@link module:ui/toolbar/toolbarview~ToolbarView#maxWidth}.
|
|
139
|
-
* @param
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
145
|
+
* @param options.class An additional CSS class added to the toolbar element.
|
|
146
|
+
* @param options.isCompact When set true, makes the toolbar look compact with toolbar element.
|
|
147
|
+
* @param options.isVertical Controls the orientation of toolbar items.
|
|
142
148
|
*/
|
|
143
149
|
export function addToolbarToDropdown(dropdownView, buttonsOrCallback, options = {}) {
|
|
144
150
|
dropdownView.extendTemplate({
|
|
@@ -190,34 +196,36 @@ function addToolbarToOpenDropdown(dropdownView, buttonsOrCallback, options) {
|
|
|
190
196
|
/**
|
|
191
197
|
* Adds an instance of {@link module:ui/list/listview~ListView} to a dropdown.
|
|
192
198
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
199
|
+
* ```ts
|
|
200
|
+
* const items = new Collection();
|
|
201
|
+
*
|
|
202
|
+
* items.add( {
|
|
203
|
+
* type: 'button',
|
|
204
|
+
* model: new Model( {
|
|
205
|
+
* withText: true,
|
|
206
|
+
* label: 'First item',
|
|
207
|
+
* labelStyle: 'color: red'
|
|
208
|
+
* } )
|
|
209
|
+
* } );
|
|
210
|
+
*
|
|
211
|
+
* items.add( {
|
|
212
|
+
* type: 'button',
|
|
213
|
+
* model: new Model( {
|
|
214
|
+
* withText: true,
|
|
215
|
+
* label: 'Second item',
|
|
216
|
+
* labelStyle: 'color: green',
|
|
217
|
+
* class: 'foo'
|
|
218
|
+
* } )
|
|
219
|
+
* } );
|
|
220
|
+
*
|
|
221
|
+
* const dropdown = createDropdown( locale );
|
|
222
|
+
*
|
|
223
|
+
* addListToDropdown( dropdown, items );
|
|
224
|
+
*
|
|
225
|
+
* // Will render a dropdown with a list in the panel containing two items.
|
|
226
|
+
* dropdown.render()
|
|
227
|
+
* document.body.appendChild( dropdown.element );
|
|
228
|
+
* ```
|
|
221
229
|
*
|
|
222
230
|
* The `items` collection passed to this methods controls the presence and attributes of respective
|
|
223
231
|
* {@link module:ui/list/listitemview~ListItemView list items}.
|
|
@@ -230,11 +238,9 @@ function addToolbarToOpenDropdown(dropdownView, buttonsOrCallback, options) {
|
|
|
230
238
|
*
|
|
231
239
|
* See {@link module:ui/dropdown/utils~createDropdown} and {@link module:list/list~List}.
|
|
232
240
|
*
|
|
233
|
-
* @param
|
|
234
|
-
* @param
|
|
235
|
-
*
|
|
236
|
-
* @param {Object} [options]
|
|
237
|
-
* @param {String} [options.ariaLabel] Label used by assistive technologies to describe list element.
|
|
241
|
+
* @param dropdownView A dropdown instance to which `ListVIew` will be added.
|
|
242
|
+
* @param itemsOrCallback A collection of the list item definitions or a callback returning a list item definitions to populate the list.
|
|
243
|
+
* @param options.ariaLabel Label used by assistive technologies to describe list element.
|
|
238
244
|
*/
|
|
239
245
|
export function addListToDropdown(dropdownView, itemsOrCallback, options = {}) {
|
|
240
246
|
if (dropdownView.isOpen) {
|
|
@@ -287,8 +293,8 @@ function addListToOpenDropdown(dropdownView, itemsOrCallback, options) {
|
|
|
287
293
|
* A helper to be used on an existing {@link module:ui/dropdown/dropdownview~DropdownView} that focuses
|
|
288
294
|
* a specific child in DOM when the dropdown {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}.
|
|
289
295
|
*
|
|
290
|
-
* @param
|
|
291
|
-
* @param
|
|
296
|
+
* @param dropdownView A dropdown instance to which the focus behavior will be added.
|
|
297
|
+
* @param childSelectorCallback A callback executed when the dropdown gets open. It should return a {@link module:ui/view~View}
|
|
292
298
|
* instance (child of {@link module:ui/dropdown/dropdownview~DropdownView#panelView}) that will get focused or a falsy value.
|
|
293
299
|
* If falsy value is returned, a default behavior of the dropdown will engage focusing the first focusable child in
|
|
294
300
|
* the {@link module:ui/dropdown/dropdownview~DropdownView#panelView}.
|
|
@@ -323,9 +329,9 @@ export function focusChildOnDropdownOpen(dropdownView, childSelectorCallback) {
|
|
|
323
329
|
// * Execute after focusDropdownPanelOnOpen(). See focusDropdownPanelOnOpen() to learn more.
|
|
324
330
|
}, { priority: priorities.low - 10 });
|
|
325
331
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
332
|
+
/**
|
|
333
|
+
* Add a set of default behaviors to dropdown view.
|
|
334
|
+
*/
|
|
329
335
|
function addDefaultBehavior(dropdownView) {
|
|
330
336
|
closeDropdownOnClickOutside(dropdownView);
|
|
331
337
|
closeDropdownOnExecute(dropdownView);
|
|
@@ -334,9 +340,9 @@ function addDefaultBehavior(dropdownView) {
|
|
|
334
340
|
focusDropdownButtonOnClose(dropdownView);
|
|
335
341
|
focusDropdownPanelOnOpen(dropdownView);
|
|
336
342
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
343
|
+
/**
|
|
344
|
+
* Adds a behavior to a dropdownView that closes opened dropdown when user clicks outside the dropdown.
|
|
345
|
+
*/
|
|
340
346
|
function closeDropdownOnClickOutside(dropdownView) {
|
|
341
347
|
dropdownView.on('render', () => {
|
|
342
348
|
clickOutsideHandler({
|
|
@@ -349,9 +355,9 @@ function closeDropdownOnClickOutside(dropdownView) {
|
|
|
349
355
|
});
|
|
350
356
|
});
|
|
351
357
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Adds a behavior to a dropdownView that closes the dropdown view on "execute" event.
|
|
360
|
+
*/
|
|
355
361
|
function closeDropdownOnExecute(dropdownView) {
|
|
356
362
|
// Close the dropdown when one of the list items has been executed.
|
|
357
363
|
dropdownView.on('execute', evt => {
|
|
@@ -362,9 +368,9 @@ function closeDropdownOnExecute(dropdownView) {
|
|
|
362
368
|
dropdownView.isOpen = false;
|
|
363
369
|
});
|
|
364
370
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
371
|
+
/**
|
|
372
|
+
* Adds a behavior to a dropdown view that closes opened dropdown when it loses focus.
|
|
373
|
+
*/
|
|
368
374
|
function closeDropdownOnBlur(dropdownView) {
|
|
369
375
|
dropdownView.focusTracker.on('change:isFocused', (evt, name, isFocused) => {
|
|
370
376
|
if (dropdownView.isOpen && !isFocused) {
|
|
@@ -372,9 +378,9 @@ function closeDropdownOnBlur(dropdownView) {
|
|
|
372
378
|
}
|
|
373
379
|
});
|
|
374
380
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
381
|
+
/**
|
|
382
|
+
* Adds a behavior to a dropdownView that focuses the dropdown's panel view contents on keystrokes.
|
|
383
|
+
*/
|
|
378
384
|
function focusDropdownContentsOnArrows(dropdownView) {
|
|
379
385
|
// If the dropdown panel is already open, the arrow down key should focus the first child of the #panelView.
|
|
380
386
|
dropdownView.keystrokes.set('arrowdown', (data, cancel) => {
|
|
@@ -391,10 +397,10 @@ function focusDropdownContentsOnArrows(dropdownView) {
|
|
|
391
397
|
}
|
|
392
398
|
});
|
|
393
399
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Adds a behavior that focuses the #buttonView when the dropdown was closed but focus was within the #panelView element.
|
|
402
|
+
* This makes sure the focus is never lost.
|
|
403
|
+
*/
|
|
398
404
|
function focusDropdownButtonOnClose(dropdownView) {
|
|
399
405
|
dropdownView.on('change:isOpen', (evt, name, isOpen) => {
|
|
400
406
|
if (isOpen) {
|
|
@@ -409,9 +415,9 @@ function focusDropdownButtonOnClose(dropdownView) {
|
|
|
409
415
|
}
|
|
410
416
|
});
|
|
411
417
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
418
|
+
/**
|
|
419
|
+
* Adds a behavior that focuses the #panelView when dropdown gets open (accessibility).
|
|
420
|
+
*/
|
|
415
421
|
function focusDropdownPanelOnOpen(dropdownView) {
|
|
416
422
|
dropdownView.on('change:isOpen', (evt, name, isOpen) => {
|
|
417
423
|
if (!isOpen) {
|
|
@@ -0,0 +1,71 @@
|
|
|
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/editableui/editableuiview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view';
|
|
9
|
+
import type { View as EditingView } from '@ckeditor/ckeditor5-engine';
|
|
10
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
11
|
+
/**
|
|
12
|
+
* The editable UI view class.
|
|
13
|
+
*/
|
|
14
|
+
export default class EditableUIView extends View {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the editable UI view.
|
|
17
|
+
*/
|
|
18
|
+
name: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Controls whether the editable is focused, i.e. the user is typing in it.
|
|
21
|
+
*
|
|
22
|
+
* @observable
|
|
23
|
+
*/
|
|
24
|
+
isFocused: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The editing view instance the editable is related to. Editable uses the editing
|
|
27
|
+
* view to dynamically modify its certain DOM attributes after {@link #render rendering}.
|
|
28
|
+
*
|
|
29
|
+
* **Note**: The DOM attributes are performed by the editing view and not UI
|
|
30
|
+
* {@link module:ui/view~View#bindTemplate template bindings} because once rendered,
|
|
31
|
+
* the editable DOM element must remain under the full control of the engine to work properly.
|
|
32
|
+
*/
|
|
33
|
+
protected _editingView: EditingView;
|
|
34
|
+
/**
|
|
35
|
+
* The element which is the main editable element (usually the one with `contentEditable="true"`).
|
|
36
|
+
*/
|
|
37
|
+
private _editableElement;
|
|
38
|
+
/**
|
|
39
|
+
* Whether an external {@link #_editableElement} was passed into the constructor, which also means
|
|
40
|
+
* the view will not render its {@link #template}.
|
|
41
|
+
*/
|
|
42
|
+
private _hasExternalElement;
|
|
43
|
+
/**
|
|
44
|
+
* Creates an instance of EditableUIView class.
|
|
45
|
+
*
|
|
46
|
+
* @param locale The locale instance.
|
|
47
|
+
* @param editingView The editing view instance the editable is related to.
|
|
48
|
+
* @param editableElement The editable element. If not specified, this view
|
|
49
|
+
* should create it. Otherwise, the existing element should be used.
|
|
50
|
+
*/
|
|
51
|
+
constructor(locale: Locale, editingView: EditingView, editableElement?: HTMLElement);
|
|
52
|
+
/**
|
|
53
|
+
* Renders the view by either applying the {@link #template} to the existing
|
|
54
|
+
* {@link #_editableElement} or assigning {@link #element} as {@link #_editableElement}.
|
|
55
|
+
*/
|
|
56
|
+
render(): void;
|
|
57
|
+
/**
|
|
58
|
+
* @inheritDoc
|
|
59
|
+
*/
|
|
60
|
+
destroy(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Whether an external {@link #_editableElement} was passed into the constructor, which also means
|
|
63
|
+
* the view will not render its {@link #template}.
|
|
64
|
+
*/
|
|
65
|
+
get hasExternalElement(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Updates the `ck-focused` and `ck-blurred` CSS classes on the {@link #element} according to
|
|
68
|
+
* the {@link #isFocused} property value using the {@link #_editingView editing view} API.
|
|
69
|
+
*/
|
|
70
|
+
private _updateIsFocusedClasses;
|
|
71
|
+
}
|
|
@@ -8,20 +8,22 @@
|
|
|
8
8
|
import View from '../view';
|
|
9
9
|
/**
|
|
10
10
|
* The editable UI view class.
|
|
11
|
-
*
|
|
12
|
-
* @extends module:ui/view~View
|
|
13
11
|
*/
|
|
14
12
|
export default class EditableUIView extends View {
|
|
15
13
|
/**
|
|
16
14
|
* Creates an instance of EditableUIView class.
|
|
17
15
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
16
|
+
* @param locale The locale instance.
|
|
17
|
+
* @param editingView The editing view instance the editable is related to.
|
|
18
|
+
* @param editableElement The editable element. If not specified, this view
|
|
21
19
|
* should create it. Otherwise, the existing element should be used.
|
|
22
20
|
*/
|
|
23
21
|
constructor(locale, editingView, editableElement) {
|
|
24
22
|
super(locale);
|
|
23
|
+
/**
|
|
24
|
+
* The name of the editable UI view.
|
|
25
|
+
*/
|
|
26
|
+
this.name = null;
|
|
25
27
|
this.setTemplate({
|
|
26
28
|
tag: 'div',
|
|
27
29
|
attributes: {
|
|
@@ -35,45 +37,9 @@ export default class EditableUIView extends View {
|
|
|
35
37
|
dir: locale.contentLanguageDirection
|
|
36
38
|
}
|
|
37
39
|
});
|
|
38
|
-
/**
|
|
39
|
-
* The name of the editable UI view.
|
|
40
|
-
*
|
|
41
|
-
* @member {String} #name
|
|
42
|
-
*/
|
|
43
|
-
this.name = null;
|
|
44
|
-
/**
|
|
45
|
-
* Controls whether the editable is focused, i.e. the user is typing in it.
|
|
46
|
-
*
|
|
47
|
-
* @observable
|
|
48
|
-
* @member {Boolean} #isFocused
|
|
49
|
-
*/
|
|
50
40
|
this.set('isFocused', false);
|
|
51
|
-
/**
|
|
52
|
-
* The element which is the main editable element (usually the one with `contentEditable="true"`).
|
|
53
|
-
*
|
|
54
|
-
* @private
|
|
55
|
-
* @type {HTMLElement}
|
|
56
|
-
*/
|
|
57
41
|
this._editableElement = editableElement;
|
|
58
|
-
/**
|
|
59
|
-
* Whether an external {@link #_editableElement} was passed into the constructor, which also means
|
|
60
|
-
* the view will not render its {@link #template}.
|
|
61
|
-
*
|
|
62
|
-
* @private
|
|
63
|
-
* @type {Boolean}
|
|
64
|
-
*/
|
|
65
42
|
this._hasExternalElement = !!this._editableElement;
|
|
66
|
-
/**
|
|
67
|
-
* The editing view instance the editable is related to. Editable uses the editing
|
|
68
|
-
* view to dynamically modify its certain DOM attributes after {@link #render rendering}.
|
|
69
|
-
*
|
|
70
|
-
* **Note**: The DOM attributes are performed by the editing view and not UI
|
|
71
|
-
* {@link module:ui/view~View#bindTemplate template bindings} because once rendered,
|
|
72
|
-
* the editable DOM element must remain under the full control of the engine to work properly.
|
|
73
|
-
*
|
|
74
|
-
* @protected
|
|
75
|
-
* @type {module:engine/view/view~View}
|
|
76
|
-
*/
|
|
77
43
|
this._editingView = editingView;
|
|
78
44
|
}
|
|
79
45
|
/**
|
|
@@ -100,11 +66,16 @@ export default class EditableUIView extends View {
|
|
|
100
66
|
}
|
|
101
67
|
super.destroy();
|
|
102
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Whether an external {@link #_editableElement} was passed into the constructor, which also means
|
|
71
|
+
* the view will not render its {@link #template}.
|
|
72
|
+
*/
|
|
73
|
+
get hasExternalElement() {
|
|
74
|
+
return this._hasExternalElement;
|
|
75
|
+
}
|
|
103
76
|
/**
|
|
104
77
|
* Updates the `ck-focused` and `ck-blurred` CSS classes on the {@link #element} according to
|
|
105
78
|
* the {@link #isFocused} property value using the {@link #_editingView editing view} API.
|
|
106
|
-
*
|
|
107
|
-
* @private
|
|
108
79
|
*/
|
|
109
80
|
_updateIsFocusedClasses() {
|
|
110
81
|
const editingView = this._editingView;
|
|
@@ -0,0 +1,40 @@
|
|
|
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/editableui/inline/inlineeditableuiview
|
|
7
|
+
*/
|
|
8
|
+
import EditableUIView from '../editableuiview';
|
|
9
|
+
import type { View } from '@ckeditor/ckeditor5-engine';
|
|
10
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
11
|
+
/**
|
|
12
|
+
* The inline editable UI class implementing an inline {@link module:ui/editableui/editableuiview~EditableUIView}.
|
|
13
|
+
*/
|
|
14
|
+
export default class InlineEditableUIView extends EditableUIView {
|
|
15
|
+
/**
|
|
16
|
+
* A function that gets called with the instance of this view as an argument and should return a string that
|
|
17
|
+
* represents the label of the editable for assistive technologies.
|
|
18
|
+
*/
|
|
19
|
+
private readonly _generateLabel;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of the InlineEditableUIView class.
|
|
22
|
+
*
|
|
23
|
+
* @param locale The locale instance.
|
|
24
|
+
* @param editingView The editing view instance the editable is related to.
|
|
25
|
+
* @param editableElement The editable element. If not specified, the
|
|
26
|
+
* {@link module:ui/editableui/editableuiview~EditableUIView}
|
|
27
|
+
* will create it. Otherwise, the existing element will be used.
|
|
28
|
+
* @param options Additional configuration of the view.
|
|
29
|
+
* @param options.label A function that gets called with the instance of this view as an argument
|
|
30
|
+
* and should return a string that represents the label of the editable for assistive technologies. If not provided,
|
|
31
|
+
* a default label generator is used.
|
|
32
|
+
*/
|
|
33
|
+
constructor(locale: Locale, editingView: View, editableElement?: HTMLElement, options?: {
|
|
34
|
+
label?: (view: InlineEditableUIView) => string;
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
render(): void;
|
|
40
|
+
}
|
|
@@ -8,20 +8,18 @@
|
|
|
8
8
|
import EditableUIView from '../editableuiview';
|
|
9
9
|
/**
|
|
10
10
|
* The inline editable UI class implementing an inline {@link module:ui/editableui/editableuiview~EditableUIView}.
|
|
11
|
-
*
|
|
12
|
-
* @extends module:ui/editableui/editableuiview~EditableUIView
|
|
13
11
|
*/
|
|
14
12
|
export default class InlineEditableUIView extends EditableUIView {
|
|
15
13
|
/**
|
|
16
14
|
* Creates an instance of the InlineEditableUIView class.
|
|
17
15
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
16
|
+
* @param locale The locale instance.
|
|
17
|
+
* @param editingView The editing view instance the editable is related to.
|
|
18
|
+
* @param editableElement The editable element. If not specified, the
|
|
21
19
|
* {@link module:ui/editableui/editableuiview~EditableUIView}
|
|
22
20
|
* will create it. Otherwise, the existing element will be used.
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
21
|
+
* @param options Additional configuration of the view.
|
|
22
|
+
* @param options.label A function that gets called with the instance of this view as an argument
|
|
25
23
|
* and should return a string that represents the label of the editable for assistive technologies. If not provided,
|
|
26
24
|
* a default label generator is used.
|
|
27
25
|
*/
|
|
@@ -34,14 +32,6 @@ export default class InlineEditableUIView extends EditableUIView {
|
|
|
34
32
|
class: 'ck-editor__editable_inline'
|
|
35
33
|
}
|
|
36
34
|
});
|
|
37
|
-
/**
|
|
38
|
-
* A function that gets called with the instance of this view as an argument and should return a string that
|
|
39
|
-
* represents the label of the editable for assistive technologies.
|
|
40
|
-
*
|
|
41
|
-
* @private
|
|
42
|
-
* @readonly
|
|
43
|
-
* @param {Function}
|
|
44
|
-
*/
|
|
45
35
|
this._generateLabel = options.label || (() => t('Editor editing area: %0', this.name));
|
|
46
36
|
}
|
|
47
37
|
/**
|
|
@@ -0,0 +1,51 @@
|
|
|
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 ViewCollection from '../viewcollection';
|
|
6
|
+
import type View from '../view';
|
|
7
|
+
import { type Locale } from '@ckeditor/ckeditor5-utils';
|
|
8
|
+
/**
|
|
9
|
+
* This is a special {@link module:ui/viewcollection~ViewCollection} dedicated to elements that are detached
|
|
10
|
+
* from the DOM structure of the editor, like panels, icons, etc.
|
|
11
|
+
*
|
|
12
|
+
* The body collection is available in the {@link module:ui/editorui/editoruiview~EditorUIView#body `editor.ui.view.body`} property.
|
|
13
|
+
* Any plugin can add a {@link module:ui/view~View view} to this collection.
|
|
14
|
+
* These views will render in a container placed directly in the `<body>` element.
|
|
15
|
+
* The editor will detach and destroy this collection when the editor will be {@link module:core/editor/editor~Editor#destroy destroyed}.
|
|
16
|
+
*
|
|
17
|
+
* If you need to control the life cycle of the body collection on your own, you can create your own instance of this class.
|
|
18
|
+
*
|
|
19
|
+
* A body collection will render itself automatically in the DOM body element as soon as you call {@link ~BodyCollection#attachToDom}.
|
|
20
|
+
* If you create multiple body collections, this class will create a special wrapper element in the DOM to limit the number of
|
|
21
|
+
* elements created directly in the body and remove it when the last body collection will be
|
|
22
|
+
* {@link ~BodyCollection#detachFromDom detached}.
|
|
23
|
+
*/
|
|
24
|
+
export default class BodyCollection extends ViewCollection {
|
|
25
|
+
/**
|
|
26
|
+
* The {@link module:core/editor/editor~Editor#locale editor's locale} instance.
|
|
27
|
+
* See the view {@link module:ui/view~View#locale locale} property.
|
|
28
|
+
*/
|
|
29
|
+
readonly locale: Locale;
|
|
30
|
+
/**
|
|
31
|
+
* The element holding elements of the body region.
|
|
32
|
+
*/
|
|
33
|
+
private _bodyCollectionContainer?;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new instance of the {@link module:ui/editorui/bodycollection~BodyCollection}.
|
|
36
|
+
*
|
|
37
|
+
* @param locale The {@link module:core/editor/editor~Editor editor's locale} instance.
|
|
38
|
+
* @param initialItems The initial items of the collection.
|
|
39
|
+
*/
|
|
40
|
+
constructor(locale: Locale, initialItems?: Iterable<View>);
|
|
41
|
+
/**
|
|
42
|
+
* Attaches the body collection to the DOM body element. You need to execute this method to render the content of
|
|
43
|
+
* the body collection.
|
|
44
|
+
*/
|
|
45
|
+
attachToDom(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Detaches the collection from the DOM structure. Use this method when you do not need to use the body collection
|
|
48
|
+
* anymore to clean-up the DOM structure.
|
|
49
|
+
*/
|
|
50
|
+
detachFromDom(): void;
|
|
51
|
+
}
|