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