@ckeditor/ckeditor5-ui 35.2.1 → 35.3.1
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 +31 -23
- package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
- package/src/bindings/clickoutsidehandler.js +15 -21
- package/src/bindings/injectcsstransitiondisabler.js +16 -20
- package/src/bindings/preventdefault.js +6 -8
- package/src/bindings/submithandler.js +5 -7
- package/src/button/button.js +5 -0
- package/src/button/buttonview.js +220 -259
- package/src/button/switchbuttonview.js +56 -71
- package/src/colorgrid/colorgridview.js +135 -197
- package/src/colorgrid/colortileview.js +37 -47
- package/src/colorgrid/utils.js +57 -66
- package/src/componentfactory.js +79 -93
- package/src/dropdown/button/dropdownbutton.js +5 -0
- package/src/dropdown/button/dropdownbuttonview.js +44 -57
- package/src/dropdown/button/splitbuttonview.js +159 -207
- package/src/dropdown/dropdownpanelfocusable.js +5 -0
- package/src/dropdown/dropdownpanelview.js +101 -112
- package/src/dropdown/dropdownview.js +396 -438
- package/src/dropdown/utils.js +164 -213
- package/src/editableui/editableuiview.js +125 -141
- package/src/editableui/inline/inlineeditableuiview.js +44 -54
- package/src/editorui/bodycollection.js +61 -75
- package/src/editorui/boxed/boxededitoruiview.js +91 -104
- package/src/editorui/editoruiview.js +30 -39
- package/src/focuscycler.js +214 -245
- package/src/formheader/formheaderview.js +58 -70
- package/src/icon/iconview.js +145 -111
- package/src/iframe/iframeview.js +37 -49
- package/src/index.js +0 -17
- package/src/input/inputview.js +170 -198
- package/src/inputnumber/inputnumberview.js +48 -56
- package/src/inputtext/inputtextview.js +14 -18
- package/src/label/labelview.js +44 -53
- package/src/labeledfield/labeledfieldview.js +212 -235
- package/src/labeledfield/utils.js +39 -57
- package/src/labeledinput/labeledinputview.js +190 -221
- package/src/list/listitemview.js +40 -50
- package/src/list/listseparatorview.js +15 -19
- package/src/list/listview.js +94 -115
- package/src/model.js +19 -25
- package/src/notification/notification.js +151 -202
- package/src/panel/balloon/balloonpanelview.js +535 -628
- package/src/panel/balloon/contextualballoon.js +611 -732
- package/src/panel/sticky/stickypanelview.js +238 -270
- package/src/template.js +1049 -1479
- package/src/toolbar/balloon/balloontoolbar.js +337 -424
- package/src/toolbar/block/blockbuttonview.js +32 -42
- package/src/toolbar/block/blocktoolbar.js +375 -477
- package/src/toolbar/normalizetoolbarconfig.js +17 -21
- package/src/toolbar/toolbarlinebreakview.js +15 -19
- package/src/toolbar/toolbarseparatorview.js +15 -19
- package/src/toolbar/toolbarview.js +866 -1053
- package/src/tooltipmanager.js +324 -353
- package/src/view.js +389 -430
- package/src/viewcollection.js +147 -178
- package/src/button/button.jsdoc +0 -165
- package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
- package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
|
@@ -2,19 +2,14 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module ui/dropdown/dropdownview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
|
|
12
10
|
import { FocusTracker } from '@ckeditor/ckeditor5-utils';
|
|
13
|
-
|
|
14
|
-
import '../../theme/components/dropdown/dropdown.css';
|
|
15
|
-
|
|
16
11
|
import { getOptimalPosition } from '@ckeditor/ckeditor5-utils/src/dom/position';
|
|
17
|
-
|
|
12
|
+
import '../../theme/components/dropdown/dropdown.css';
|
|
18
13
|
/**
|
|
19
14
|
* The dropdown view class. It manages the dropdown button and dropdown panel.
|
|
20
15
|
*
|
|
@@ -66,291 +61,255 @@ import { getOptimalPosition } from '@ckeditor/ckeditor5-utils/src/dom/position';
|
|
|
66
61
|
* @extends module:ui/view~View
|
|
67
62
|
*/
|
|
68
63
|
export default class DropdownView extends View {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
* Focuses the {@link #buttonView}.
|
|
318
|
-
*/
|
|
319
|
-
focus() {
|
|
320
|
-
this.buttonView.focus();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Returns {@link #panelView panel} positions to be used by the
|
|
325
|
-
* {@link module:utils/dom/position~getOptimalPosition `getOptimalPosition()`}
|
|
326
|
-
* utility considering the direction of the language the UI of the editor is displayed in.
|
|
327
|
-
*
|
|
328
|
-
* @type {module:utils/dom/position~Options#positions}
|
|
329
|
-
* @private
|
|
330
|
-
*/
|
|
331
|
-
get _panelPositions() {
|
|
332
|
-
const {
|
|
333
|
-
south, north,
|
|
334
|
-
southEast, southWest,
|
|
335
|
-
northEast, northWest,
|
|
336
|
-
southMiddleEast, southMiddleWest,
|
|
337
|
-
northMiddleEast, northMiddleWest
|
|
338
|
-
} = DropdownView.defaultPanelPositions;
|
|
339
|
-
|
|
340
|
-
if ( this.locale.uiLanguageDirection !== 'rtl' ) {
|
|
341
|
-
return [
|
|
342
|
-
southEast, southWest, southMiddleEast, southMiddleWest, south,
|
|
343
|
-
northEast, northWest, northMiddleEast, northMiddleWest, north
|
|
344
|
-
];
|
|
345
|
-
} else {
|
|
346
|
-
return [
|
|
347
|
-
southWest, southEast, southMiddleWest, southMiddleEast, south,
|
|
348
|
-
northWest, northEast, northMiddleWest, northMiddleEast, north
|
|
349
|
-
];
|
|
350
|
-
}
|
|
351
|
-
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates an instance of the dropdown.
|
|
66
|
+
*
|
|
67
|
+
* Also see {@link #render}.
|
|
68
|
+
*
|
|
69
|
+
* @param {module:utils/locale~Locale} [locale] The localization services instance.
|
|
70
|
+
* @param {module:ui/dropdown/button/dropdownbutton~DropdownButton} buttonView
|
|
71
|
+
* @param {module:ui/dropdown/dropdownpanelview~DropdownPanelView} panelView
|
|
72
|
+
*/
|
|
73
|
+
constructor(locale, buttonView, panelView) {
|
|
74
|
+
super(locale);
|
|
75
|
+
const bind = this.bindTemplate;
|
|
76
|
+
/**
|
|
77
|
+
* Button of the dropdown view. Clicking the button opens the {@link #panelView}.
|
|
78
|
+
*
|
|
79
|
+
* @readonly
|
|
80
|
+
* @member {module:ui/button/buttonview~ButtonView} #buttonView
|
|
81
|
+
*/
|
|
82
|
+
this.buttonView = buttonView;
|
|
83
|
+
/**
|
|
84
|
+
* Panel of the dropdown. It opens when the {@link #buttonView} is
|
|
85
|
+
* {@link module:ui/button/buttonview~ButtonView#event:execute executed} (i.e. clicked).
|
|
86
|
+
*
|
|
87
|
+
* Child views can be added to the panel's `children` collection:
|
|
88
|
+
*
|
|
89
|
+
* dropdown.panelView.children.add( childView );
|
|
90
|
+
*
|
|
91
|
+
* See {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView#children} and
|
|
92
|
+
* {@link module:ui/viewcollection~ViewCollection#add}.
|
|
93
|
+
*
|
|
94
|
+
* @readonly
|
|
95
|
+
* @member {module:ui/dropdown/dropdownpanelview~DropdownPanelView} #panelView
|
|
96
|
+
*/
|
|
97
|
+
this.panelView = panelView;
|
|
98
|
+
/**
|
|
99
|
+
* Controls whether the dropdown view is open, i.e. shows or hides the {@link #panelView panel}.
|
|
100
|
+
*
|
|
101
|
+
* **Note**: When the dropdown gets open, it will attempt to call `focus()` on the first child of its {@link #panelView}.
|
|
102
|
+
* See {@link module:ui/dropdown/utils~addToolbarToDropdown}, {@link module:ui/dropdown/utils~addListToDropdown}, and
|
|
103
|
+
* {@link module:ui/dropdown/utils~focusChildOnDropdownOpen} to learn more about focus management in dropdowns.
|
|
104
|
+
*
|
|
105
|
+
* @observable
|
|
106
|
+
* @member {Boolean} #isOpen
|
|
107
|
+
*/
|
|
108
|
+
this.set('isOpen', false);
|
|
109
|
+
/**
|
|
110
|
+
* Controls whether the dropdown is enabled, i.e. it can be clicked and execute an action.
|
|
111
|
+
*
|
|
112
|
+
* See {@link module:ui/button/buttonview~ButtonView#isEnabled}.
|
|
113
|
+
*
|
|
114
|
+
* @observable
|
|
115
|
+
* @member {Boolean} #isEnabled
|
|
116
|
+
*/
|
|
117
|
+
this.set('isEnabled', true);
|
|
118
|
+
/**
|
|
119
|
+
* (Optional) The additional CSS class set on the dropdown {@link #element}.
|
|
120
|
+
*
|
|
121
|
+
* @observable
|
|
122
|
+
* @member {String} #class
|
|
123
|
+
*/
|
|
124
|
+
this.set('class', undefined);
|
|
125
|
+
/**
|
|
126
|
+
* (Optional) The `id` attribute of the dropdown (i.e. to pair with a `<label>` element).
|
|
127
|
+
*
|
|
128
|
+
* @observable
|
|
129
|
+
* @member {String} #id
|
|
130
|
+
*/
|
|
131
|
+
this.set('id', undefined);
|
|
132
|
+
/**
|
|
133
|
+
* The position of the panel, relative to the dropdown.
|
|
134
|
+
*
|
|
135
|
+
* **Note**: When `'auto'`, the panel will use one of the remaining positions to stay
|
|
136
|
+
* in the viewport, visible to the user. The positions correspond directly to
|
|
137
|
+
* {@link module:ui/dropdown/dropdownview~DropdownView.defaultPanelPositions default panel positions}.
|
|
138
|
+
*
|
|
139
|
+
* **Note**: This value has an impact on the
|
|
140
|
+
* {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView#position} property
|
|
141
|
+
* each time the panel becomes {@link #isOpen open}.
|
|
142
|
+
*
|
|
143
|
+
* @observable
|
|
144
|
+
* @default 'auto'
|
|
145
|
+
* @member {'auto'|'s'|'se'|'sw'|'sme'|'smw'|'n'|'ne'|'nw'|'nme'|'nmw'} #panelPosition
|
|
146
|
+
*/
|
|
147
|
+
this.set('panelPosition', 'auto');
|
|
148
|
+
/**
|
|
149
|
+
* Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}. It manages
|
|
150
|
+
* keystrokes of the dropdown:
|
|
151
|
+
*
|
|
152
|
+
* * <kbd>▼</kbd> opens the dropdown,
|
|
153
|
+
* * <kbd>◀</kbd> and <kbd>Esc</kbd> closes the dropdown.
|
|
154
|
+
*
|
|
155
|
+
* @readonly
|
|
156
|
+
* @member {module:utils/keystrokehandler~KeystrokeHandler}
|
|
157
|
+
*/
|
|
158
|
+
this.keystrokes = new KeystrokeHandler();
|
|
159
|
+
/**
|
|
160
|
+
* Tracks information about the DOM focus in the dropdown.
|
|
161
|
+
*
|
|
162
|
+
* @readonly
|
|
163
|
+
* @member {module:utils/focustracker~FocusTracker}
|
|
164
|
+
*/
|
|
165
|
+
this.focusTracker = new FocusTracker();
|
|
166
|
+
this.setTemplate({
|
|
167
|
+
tag: 'div',
|
|
168
|
+
attributes: {
|
|
169
|
+
class: [
|
|
170
|
+
'ck',
|
|
171
|
+
'ck-dropdown',
|
|
172
|
+
bind.to('class'),
|
|
173
|
+
bind.if('isEnabled', 'ck-disabled', value => !value)
|
|
174
|
+
],
|
|
175
|
+
id: bind.to('id'),
|
|
176
|
+
'aria-describedby': bind.to('ariaDescribedById')
|
|
177
|
+
},
|
|
178
|
+
children: [
|
|
179
|
+
buttonView,
|
|
180
|
+
panelView
|
|
181
|
+
]
|
|
182
|
+
});
|
|
183
|
+
buttonView.extendTemplate({
|
|
184
|
+
attributes: {
|
|
185
|
+
class: [
|
|
186
|
+
'ck-dropdown__button'
|
|
187
|
+
],
|
|
188
|
+
'data-cke-tooltip-disabled': bind.to('isOpen')
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
/**
|
|
192
|
+
* A child {@link module:ui/list/listview~ListView list view} of the dropdown located
|
|
193
|
+
* in its {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
|
|
194
|
+
*
|
|
195
|
+
* **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addListToDropdown}.
|
|
196
|
+
*
|
|
197
|
+
* @readonly
|
|
198
|
+
* @member {module:ui/list/listview~ListView} #listView
|
|
199
|
+
*/
|
|
200
|
+
/**
|
|
201
|
+
* A child toolbar of the dropdown located in the
|
|
202
|
+
* {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
|
|
203
|
+
*
|
|
204
|
+
* **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addToolbarToDropdown}.
|
|
205
|
+
*
|
|
206
|
+
* @readonly
|
|
207
|
+
* @member {module:ui/toolbar/toolbarview~ToolbarView} #toolbarView
|
|
208
|
+
*/
|
|
209
|
+
/**
|
|
210
|
+
* Fired when the toolbar button or list item is executed.
|
|
211
|
+
*
|
|
212
|
+
* For {@link #listView} It fires when a child of some {@link module:ui/list/listitemview~ListItemView}
|
|
213
|
+
* fired `execute`.
|
|
214
|
+
*
|
|
215
|
+
* For {@link #toolbarView} It fires when one of the buttons has been
|
|
216
|
+
* {@link module:ui/button/buttonview~ButtonView#event:execute executed}.
|
|
217
|
+
*
|
|
218
|
+
* **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addListToDropdown}
|
|
219
|
+
* or {@link module:ui/dropdown/utils~addToolbarToDropdown}.
|
|
220
|
+
*
|
|
221
|
+
* @event execute
|
|
222
|
+
*/
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @inheritDoc
|
|
226
|
+
*/
|
|
227
|
+
render() {
|
|
228
|
+
super.render();
|
|
229
|
+
this.focusTracker.add(this.buttonView.element);
|
|
230
|
+
this.focusTracker.add(this.panelView.element);
|
|
231
|
+
// Toggle the dropdown when its button has been clicked.
|
|
232
|
+
this.listenTo(this.buttonView, 'open', () => {
|
|
233
|
+
this.isOpen = !this.isOpen;
|
|
234
|
+
});
|
|
235
|
+
// Toggle the visibility of the panel when the dropdown becomes open.
|
|
236
|
+
this.panelView.bind('isVisible').to(this, 'isOpen');
|
|
237
|
+
// Let the dropdown control the position of the panel. The position must
|
|
238
|
+
// be updated every time the dropdown is open.
|
|
239
|
+
this.on('change:isOpen', (evt, name, isOpen) => {
|
|
240
|
+
if (!isOpen) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// If "auto", find the best position of the panel to fit into the viewport.
|
|
244
|
+
// Otherwise, simply assign the static position.
|
|
245
|
+
if (this.panelPosition === 'auto') {
|
|
246
|
+
this.panelView.position = DropdownView._getOptimalPosition({
|
|
247
|
+
element: this.panelView.element,
|
|
248
|
+
target: this.buttonView.element,
|
|
249
|
+
fitInViewport: true,
|
|
250
|
+
positions: this._panelPositions
|
|
251
|
+
}).name;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
this.panelView.position = this.panelPosition;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// Listen for keystrokes coming from within #element.
|
|
258
|
+
this.keystrokes.listenTo(this.element);
|
|
259
|
+
const closeDropdown = (data, cancel) => {
|
|
260
|
+
if (this.isOpen) {
|
|
261
|
+
this.isOpen = false;
|
|
262
|
+
cancel();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
// Open the dropdown panel using the arrow down key, just like with return or space.
|
|
266
|
+
this.keystrokes.set('arrowdown', (data, cancel) => {
|
|
267
|
+
// Don't open if the dropdown is disabled or already open.
|
|
268
|
+
if (this.buttonView.isEnabled && !this.isOpen) {
|
|
269
|
+
this.isOpen = true;
|
|
270
|
+
cancel();
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
// Block the right arrow key (until nested dropdowns are implemented).
|
|
274
|
+
this.keystrokes.set('arrowright', (data, cancel) => {
|
|
275
|
+
if (this.isOpen) {
|
|
276
|
+
cancel();
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
// Close the dropdown using the arrow left/escape key.
|
|
280
|
+
this.keystrokes.set('arrowleft', closeDropdown);
|
|
281
|
+
this.keystrokes.set('esc', closeDropdown);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Focuses the {@link #buttonView}.
|
|
285
|
+
*/
|
|
286
|
+
focus() {
|
|
287
|
+
this.buttonView.focus();
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Returns {@link #panelView panel} positions to be used by the
|
|
291
|
+
* {@link module:utils/dom/position~getOptimalPosition `getOptimalPosition()`}
|
|
292
|
+
* utility considering the direction of the language the UI of the editor is displayed in.
|
|
293
|
+
*
|
|
294
|
+
* @type {module:utils/dom/position~Options#positions}
|
|
295
|
+
* @private
|
|
296
|
+
*/
|
|
297
|
+
get _panelPositions() {
|
|
298
|
+
const { south, north, southEast, southWest, northEast, northWest, southMiddleEast, southMiddleWest, northMiddleEast, northMiddleWest } = DropdownView.defaultPanelPositions;
|
|
299
|
+
if (this.locale.uiLanguageDirection !== 'rtl') {
|
|
300
|
+
return [
|
|
301
|
+
southEast, southWest, southMiddleEast, southMiddleWest, south,
|
|
302
|
+
northEast, northWest, northMiddleEast, northMiddleWest, north
|
|
303
|
+
];
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
return [
|
|
307
|
+
southWest, southEast, southMiddleWest, southMiddleEast, south,
|
|
308
|
+
northWest, northEast, northMiddleWest, northMiddleEast, north
|
|
309
|
+
];
|
|
310
|
+
}
|
|
311
|
+
}
|
|
352
312
|
}
|
|
353
|
-
|
|
354
313
|
/**
|
|
355
314
|
* A set of positioning functions used by the dropdown view to determine
|
|
356
315
|
* the optimal position (i.e. fitting into the browser viewport) of its
|
|
@@ -364,156 +323,155 @@ export default class DropdownView extends View {
|
|
|
364
323
|
* * `south`
|
|
365
324
|
*
|
|
366
325
|
* [ Button ]
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
326
|
+
* +-----------------+
|
|
327
|
+
* | Panel |
|
|
328
|
+
* +-----------------+
|
|
329
|
+
*
|
|
330
|
+
* * `southEast`
|
|
331
|
+
*
|
|
332
|
+
* [ Button ]
|
|
333
|
+
* +-----------------+
|
|
334
|
+
* | Panel |
|
|
335
|
+
* +-----------------+
|
|
336
|
+
*
|
|
337
|
+
* * `southWest`
|
|
338
|
+
*
|
|
339
|
+
* [ Button ]
|
|
340
|
+
* +-----------------+
|
|
341
|
+
* | Panel |
|
|
342
|
+
* +-----------------+
|
|
343
|
+
*
|
|
344
|
+
* * `southMiddleEast`
|
|
345
|
+
*
|
|
346
|
+
* [ Button ]
|
|
347
|
+
* +-----------------+
|
|
348
|
+
* | Panel |
|
|
349
|
+
* +-----------------+
|
|
350
|
+
*
|
|
351
|
+
* * `southMiddleWest`
|
|
352
|
+
*
|
|
353
|
+
* [ Button ]
|
|
354
|
+
* +-----------------+
|
|
355
|
+
* | Panel |
|
|
356
|
+
* +-----------------+
|
|
357
|
+
*
|
|
358
|
+
* **North**
|
|
359
|
+
*
|
|
360
|
+
* * `north`
|
|
361
|
+
*
|
|
362
|
+
* +-----------------+
|
|
363
|
+
* | Panel |
|
|
364
|
+
* +-----------------+
|
|
365
|
+
* [ Button ]
|
|
366
|
+
*
|
|
367
|
+
* * `northEast`
|
|
368
|
+
*
|
|
369
|
+
* +-----------------+
|
|
370
|
+
* | Panel |
|
|
371
|
+
* +-----------------+
|
|
372
|
+
* [ Button ]
|
|
373
|
+
*
|
|
374
|
+
* * `northWest`
|
|
375
|
+
*
|
|
376
|
+
* +-----------------+
|
|
377
|
+
* | Panel |
|
|
378
|
+
* +-----------------+
|
|
379
|
+
* [ Button ]
|
|
380
|
+
*
|
|
381
|
+
* * `northMiddleEast`
|
|
382
|
+
*
|
|
383
|
+
* +-----------------+
|
|
384
|
+
* | Panel |
|
|
385
|
+
* +-----------------+
|
|
386
|
+
* [ Button ]
|
|
387
|
+
*
|
|
388
|
+
* * `northMiddleWest`
|
|
389
|
+
*
|
|
390
|
+
* +-----------------+
|
|
391
|
+
* | Panel |
|
|
392
|
+
* +-----------------+
|
|
393
|
+
* [ Button ]
|
|
394
|
+
*
|
|
395
|
+
* Positioning functions are compatible with {@link module:utils/dom/position~Position}.
|
|
396
|
+
*
|
|
397
|
+
* The name that position function returns will be reflected in dropdown panel's class that
|
|
398
|
+
* controls its placement. See {@link module:ui/dropdown/dropdownview~DropdownView#panelPosition}
|
|
399
|
+
* to learn more.
|
|
400
|
+
*
|
|
401
|
+
* @member {Object} module:ui/dropdown/dropdownview~DropdownView.defaultPanelPositions
|
|
402
|
+
*/
|
|
444
403
|
DropdownView.defaultPanelPositions = {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
404
|
+
south: (buttonRect, panelRect) => {
|
|
405
|
+
return {
|
|
406
|
+
top: buttonRect.bottom,
|
|
407
|
+
left: buttonRect.left - (panelRect.width - buttonRect.width) / 2,
|
|
408
|
+
name: 's'
|
|
409
|
+
};
|
|
410
|
+
},
|
|
411
|
+
southEast: buttonRect => {
|
|
412
|
+
return {
|
|
413
|
+
top: buttonRect.bottom,
|
|
414
|
+
left: buttonRect.left,
|
|
415
|
+
name: 'se'
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
southWest: (buttonRect, panelRect) => {
|
|
419
|
+
return {
|
|
420
|
+
top: buttonRect.bottom,
|
|
421
|
+
left: buttonRect.left - panelRect.width + buttonRect.width,
|
|
422
|
+
name: 'sw'
|
|
423
|
+
};
|
|
424
|
+
},
|
|
425
|
+
southMiddleEast: (buttonRect, panelRect) => {
|
|
426
|
+
return {
|
|
427
|
+
top: buttonRect.bottom,
|
|
428
|
+
left: buttonRect.left - (panelRect.width - buttonRect.width) / 4,
|
|
429
|
+
name: 'sme'
|
|
430
|
+
};
|
|
431
|
+
},
|
|
432
|
+
southMiddleWest: (buttonRect, panelRect) => {
|
|
433
|
+
return {
|
|
434
|
+
top: buttonRect.bottom,
|
|
435
|
+
left: buttonRect.left - (panelRect.width - buttonRect.width) * 3 / 4,
|
|
436
|
+
name: 'smw'
|
|
437
|
+
};
|
|
438
|
+
},
|
|
439
|
+
north: (buttonRect, panelRect) => {
|
|
440
|
+
return {
|
|
441
|
+
top: buttonRect.top - panelRect.height,
|
|
442
|
+
left: buttonRect.left - (panelRect.width - buttonRect.width) / 2,
|
|
443
|
+
name: 'n'
|
|
444
|
+
};
|
|
445
|
+
},
|
|
446
|
+
northEast: (buttonRect, panelRect) => {
|
|
447
|
+
return {
|
|
448
|
+
top: buttonRect.top - panelRect.height,
|
|
449
|
+
left: buttonRect.left,
|
|
450
|
+
name: 'ne'
|
|
451
|
+
};
|
|
452
|
+
},
|
|
453
|
+
northWest: (buttonRect, panelRect) => {
|
|
454
|
+
return {
|
|
455
|
+
top: buttonRect.top - panelRect.height,
|
|
456
|
+
left: buttonRect.left - panelRect.width + buttonRect.width,
|
|
457
|
+
name: 'nw'
|
|
458
|
+
};
|
|
459
|
+
},
|
|
460
|
+
northMiddleEast: (buttonRect, panelRect) => {
|
|
461
|
+
return {
|
|
462
|
+
top: buttonRect.top - panelRect.height,
|
|
463
|
+
left: buttonRect.left - (panelRect.width - buttonRect.width) / 4,
|
|
464
|
+
name: 'nme'
|
|
465
|
+
};
|
|
466
|
+
},
|
|
467
|
+
northMiddleWest: (buttonRect, panelRect) => {
|
|
468
|
+
return {
|
|
469
|
+
top: buttonRect.top - panelRect.height,
|
|
470
|
+
left: buttonRect.left - (panelRect.width - buttonRect.width) * 3 / 4,
|
|
471
|
+
name: 'nmw'
|
|
472
|
+
};
|
|
473
|
+
}
|
|
515
474
|
};
|
|
516
|
-
|
|
517
475
|
/**
|
|
518
476
|
* A function used to calculate the optimal position for the dropdown panel.
|
|
519
477
|
*
|