@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.
- 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,21 +2,15 @@
|
|
|
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/button/splitbuttonview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../../view';
|
|
11
9
|
import ButtonView from '../../button/buttonview';
|
|
12
|
-
|
|
13
10
|
import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
|
|
14
11
|
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
|
|
15
|
-
|
|
16
12
|
import dropdownArrowIcon from '../../../theme/icons/dropdown-arrow.svg';
|
|
17
|
-
|
|
18
13
|
import '../../../theme/components/dropdown/splitbutton.css';
|
|
19
|
-
|
|
20
14
|
/**
|
|
21
15
|
* The split button view class.
|
|
22
16
|
*
|
|
@@ -38,205 +32,163 @@ import '../../../theme/components/dropdown/splitbutton.css';
|
|
|
38
32
|
* @extends module:ui/view~View
|
|
39
33
|
*/
|
|
40
34
|
export default class SplitButtonView extends View {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
attributes: {
|
|
201
|
-
class: 'ck-splitbutton__action'
|
|
202
|
-
}
|
|
203
|
-
} );
|
|
204
|
-
|
|
205
|
-
actionView.delegate( 'execute' ).to( this );
|
|
206
|
-
|
|
207
|
-
return actionView;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Creates a {@link module:ui/button/buttonview~ButtonView} instance as {@link #arrowView} and binds it with main split button
|
|
212
|
-
* attributes.
|
|
213
|
-
*
|
|
214
|
-
* @private
|
|
215
|
-
* @returns {module:ui/button/buttonview~ButtonView}
|
|
216
|
-
*/
|
|
217
|
-
_createArrowView() {
|
|
218
|
-
const arrowView = new ButtonView();
|
|
219
|
-
const bind = arrowView.bindTemplate;
|
|
220
|
-
|
|
221
|
-
arrowView.icon = dropdownArrowIcon;
|
|
222
|
-
|
|
223
|
-
arrowView.extendTemplate( {
|
|
224
|
-
attributes: {
|
|
225
|
-
class: [
|
|
226
|
-
'ck-splitbutton__arrow'
|
|
227
|
-
],
|
|
228
|
-
'data-cke-tooltip-disabled': bind.to( 'isOn' ),
|
|
229
|
-
'aria-haspopup': true,
|
|
230
|
-
'aria-expanded': bind.to( 'isOn', value => String( value ) )
|
|
231
|
-
}
|
|
232
|
-
} );
|
|
233
|
-
|
|
234
|
-
arrowView.bind( 'isEnabled' ).to( this );
|
|
235
|
-
arrowView.bind( 'label' ).to( this );
|
|
236
|
-
arrowView.bind( 'tooltip' ).to( this );
|
|
237
|
-
|
|
238
|
-
arrowView.delegate( 'execute' ).to( this, 'open' );
|
|
239
|
-
|
|
240
|
-
return arrowView;
|
|
241
|
-
}
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
constructor(locale) {
|
|
39
|
+
super(locale);
|
|
40
|
+
const bind = this.bindTemplate;
|
|
41
|
+
// Implement the Button interface.
|
|
42
|
+
this.set('class', undefined);
|
|
43
|
+
this.set('labelStyle', undefined);
|
|
44
|
+
this.set('icon', undefined);
|
|
45
|
+
this.set('isEnabled', true);
|
|
46
|
+
this.set('isOn', false);
|
|
47
|
+
this.set('isToggleable', false);
|
|
48
|
+
this.set('isVisible', true);
|
|
49
|
+
this.set('keystroke', undefined);
|
|
50
|
+
this.set('withKeystroke', false);
|
|
51
|
+
this.set('label', undefined);
|
|
52
|
+
this.set('tabindex', -1);
|
|
53
|
+
this.set('tooltip', false);
|
|
54
|
+
this.set('tooltipPosition', 's');
|
|
55
|
+
this.set('type', 'button');
|
|
56
|
+
this.set('withText', false);
|
|
57
|
+
/**
|
|
58
|
+
* Collection of the child views inside of the split button {@link #element}.
|
|
59
|
+
*
|
|
60
|
+
* @readonly
|
|
61
|
+
* @member {module:ui/viewcollection~ViewCollection}
|
|
62
|
+
*/
|
|
63
|
+
this.children = this.createCollection();
|
|
64
|
+
/**
|
|
65
|
+
* A main button of split button.
|
|
66
|
+
*
|
|
67
|
+
* @readonly
|
|
68
|
+
* @member {module:ui/button/buttonview~ButtonView}
|
|
69
|
+
*/
|
|
70
|
+
this.actionView = this._createActionView();
|
|
71
|
+
/**
|
|
72
|
+
* A secondary button of split button that opens dropdown.
|
|
73
|
+
*
|
|
74
|
+
* @readonly
|
|
75
|
+
* @member {module:ui/button/buttonview~ButtonView}
|
|
76
|
+
*/
|
|
77
|
+
this.arrowView = this._createArrowView();
|
|
78
|
+
/**
|
|
79
|
+
* Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}. It manages
|
|
80
|
+
* keystrokes of the split button:
|
|
81
|
+
*
|
|
82
|
+
* * <kbd>▶</kbd> moves focus to arrow view when action view is focused,
|
|
83
|
+
* * <kbd>◀</kbd> moves focus to action view when arrow view is focused.
|
|
84
|
+
*
|
|
85
|
+
* @readonly
|
|
86
|
+
* @member {module:utils/keystrokehandler~KeystrokeHandler}
|
|
87
|
+
*/
|
|
88
|
+
this.keystrokes = new KeystrokeHandler();
|
|
89
|
+
/**
|
|
90
|
+
* Tracks information about DOM focus in the dropdown.
|
|
91
|
+
*
|
|
92
|
+
* @readonly
|
|
93
|
+
* @member {module:utils/focustracker~FocusTracker}
|
|
94
|
+
*/
|
|
95
|
+
this.focusTracker = new FocusTracker();
|
|
96
|
+
this.setTemplate({
|
|
97
|
+
tag: 'div',
|
|
98
|
+
attributes: {
|
|
99
|
+
class: [
|
|
100
|
+
'ck',
|
|
101
|
+
'ck-splitbutton',
|
|
102
|
+
bind.to('class'),
|
|
103
|
+
bind.if('isVisible', 'ck-hidden', value => !value),
|
|
104
|
+
this.arrowView.bindTemplate.if('isOn', 'ck-splitbutton_open')
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
children: this.children
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @inheritDoc
|
|
112
|
+
*/
|
|
113
|
+
render() {
|
|
114
|
+
super.render();
|
|
115
|
+
this.children.add(this.actionView);
|
|
116
|
+
this.children.add(this.arrowView);
|
|
117
|
+
this.focusTracker.add(this.actionView.element);
|
|
118
|
+
this.focusTracker.add(this.arrowView.element);
|
|
119
|
+
this.keystrokes.listenTo(this.element);
|
|
120
|
+
// Overrides toolbar focus cycling behavior.
|
|
121
|
+
this.keystrokes.set('arrowright', (evt, cancel) => {
|
|
122
|
+
if (this.focusTracker.focusedElement === this.actionView.element) {
|
|
123
|
+
this.arrowView.focus();
|
|
124
|
+
cancel();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// Overrides toolbar focus cycling behavior.
|
|
128
|
+
this.keystrokes.set('arrowleft', (evt, cancel) => {
|
|
129
|
+
if (this.focusTracker.focusedElement === this.arrowView.element) {
|
|
130
|
+
this.actionView.focus();
|
|
131
|
+
cancel();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @inheritDoc
|
|
137
|
+
*/
|
|
138
|
+
destroy() {
|
|
139
|
+
super.destroy();
|
|
140
|
+
this.focusTracker.destroy();
|
|
141
|
+
this.keystrokes.destroy();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Focuses the {@link #actionView#element} of the action part of split button.
|
|
145
|
+
*/
|
|
146
|
+
focus() {
|
|
147
|
+
this.actionView.focus();
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Creates a {@link module:ui/button/buttonview~ButtonView} instance as {@link #actionView} and binds it with main split button
|
|
151
|
+
* attributes.
|
|
152
|
+
*
|
|
153
|
+
* @private
|
|
154
|
+
* @returns {module:ui/button/buttonview~ButtonView}
|
|
155
|
+
*/
|
|
156
|
+
_createActionView() {
|
|
157
|
+
const actionView = new ButtonView();
|
|
158
|
+
actionView.bind('icon', 'isEnabled', 'isOn', 'isToggleable', 'keystroke', 'label', 'tabindex', 'tooltip', 'tooltipPosition', 'type', 'withText').to(this);
|
|
159
|
+
actionView.extendTemplate({
|
|
160
|
+
attributes: {
|
|
161
|
+
class: 'ck-splitbutton__action'
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
actionView.delegate('execute').to(this);
|
|
165
|
+
return actionView;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Creates a {@link module:ui/button/buttonview~ButtonView} instance as {@link #arrowView} and binds it with main split button
|
|
169
|
+
* attributes.
|
|
170
|
+
*
|
|
171
|
+
* @private
|
|
172
|
+
* @returns {module:ui/button/buttonview~ButtonView}
|
|
173
|
+
*/
|
|
174
|
+
_createArrowView() {
|
|
175
|
+
const arrowView = new ButtonView();
|
|
176
|
+
const bind = arrowView.bindTemplate;
|
|
177
|
+
arrowView.icon = dropdownArrowIcon;
|
|
178
|
+
arrowView.extendTemplate({
|
|
179
|
+
attributes: {
|
|
180
|
+
class: [
|
|
181
|
+
'ck-splitbutton__arrow'
|
|
182
|
+
],
|
|
183
|
+
'data-cke-tooltip-disabled': bind.to('isOn'),
|
|
184
|
+
'aria-haspopup': true,
|
|
185
|
+
'aria-expanded': bind.to('isOn', value => String(value))
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
arrowView.bind('isEnabled').to(this);
|
|
189
|
+
arrowView.bind('label').to(this);
|
|
190
|
+
arrowView.bind('tooltip').to(this);
|
|
191
|
+
arrowView.delegate('execute').to(this, 'open');
|
|
192
|
+
return arrowView;
|
|
193
|
+
}
|
|
242
194
|
}
|
|
@@ -2,14 +2,11 @@
|
|
|
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/dropdownpanelview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import View from '../view';
|
|
11
9
|
import { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* The dropdown panel view class.
|
|
15
12
|
*
|
|
@@ -18,113 +15,105 @@ import { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
18
15
|
* @extends module:ui/view~View
|
|
19
16
|
*/
|
|
20
17
|
export default class DropdownPanelView extends View {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
if ( typeof lastChild.focusLast === 'function' ) {
|
|
124
|
-
lastChild.focusLast();
|
|
125
|
-
} else {
|
|
126
|
-
lastChild.focus();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
constructor(locale) {
|
|
22
|
+
super(locale);
|
|
23
|
+
const bind = this.bindTemplate;
|
|
24
|
+
/**
|
|
25
|
+
* Controls whether the panel is visible.
|
|
26
|
+
*
|
|
27
|
+
* @observable
|
|
28
|
+
* @member {Boolean} #isVisible
|
|
29
|
+
*/
|
|
30
|
+
this.set('isVisible', false);
|
|
31
|
+
/**
|
|
32
|
+
* The position of the panel, relative to the parent.
|
|
33
|
+
*
|
|
34
|
+
* This property is reflected in the CSS class set to {@link #element} that controls
|
|
35
|
+
* the position of the panel.
|
|
36
|
+
*
|
|
37
|
+
* @observable
|
|
38
|
+
* @default 'se'
|
|
39
|
+
* @member {'s'|'se'|'sw'|'sme'|'smw'|'n'|'ne'|'nw'|'nme'|'nmw'} #position
|
|
40
|
+
*/
|
|
41
|
+
this.set('position', 'se');
|
|
42
|
+
/**
|
|
43
|
+
* Collection of the child views in this panel.
|
|
44
|
+
*
|
|
45
|
+
* A common child type is the {@link module:ui/list/listview~ListView} and {@link module:ui/toolbar/toolbarview~ToolbarView}.
|
|
46
|
+
* See {@link module:ui/dropdown/utils~addListToDropdown} and
|
|
47
|
+
* {@link module:ui/dropdown/utils~addToolbarToDropdown} to learn more about child views of dropdowns.
|
|
48
|
+
*
|
|
49
|
+
* @readonly
|
|
50
|
+
* @member {module:ui/viewcollection~ViewCollection}
|
|
51
|
+
*/
|
|
52
|
+
this.children = this.createCollection();
|
|
53
|
+
this.setTemplate({
|
|
54
|
+
tag: 'div',
|
|
55
|
+
attributes: {
|
|
56
|
+
class: [
|
|
57
|
+
'ck',
|
|
58
|
+
'ck-reset',
|
|
59
|
+
'ck-dropdown__panel',
|
|
60
|
+
bind.to('position', value => `ck-dropdown__panel_${value}`),
|
|
61
|
+
bind.if('isVisible', 'ck-dropdown__panel-visible')
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
children: this.children,
|
|
65
|
+
on: {
|
|
66
|
+
// Drag and drop in the panel should not break the selection in the editor.
|
|
67
|
+
// https://github.com/ckeditor/ckeditor5-ui/issues/228
|
|
68
|
+
selectstart: bind.to(evt => evt.preventDefault())
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Focuses the first view in the {@link #children} collection.
|
|
74
|
+
*
|
|
75
|
+
* See also {@link module:ui/dropdown/dropdownpanelfocusable~DropdownPanelFocusable}.
|
|
76
|
+
*/
|
|
77
|
+
focus() {
|
|
78
|
+
if (this.children.length) {
|
|
79
|
+
const firstChild = this.children.first;
|
|
80
|
+
if (typeof firstChild.focus === 'function') {
|
|
81
|
+
firstChild.focus();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
/**
|
|
85
|
+
* The child view of a dropdown could not be focused because it is missing the `focus()` method.
|
|
86
|
+
*
|
|
87
|
+
* This warning appears when a dropdown {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open} and it
|
|
88
|
+
* attempts to focus the {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView#children first child} of its panel
|
|
89
|
+
* but the child does not implement the
|
|
90
|
+
* {@link module:ui/dropdown/dropdownpanelfocusable~DropdownPanelFocusable focusable interface}.
|
|
91
|
+
*
|
|
92
|
+
* Focusing the content of a dropdown on open greatly improves the accessibility. Please make sure the view instance
|
|
93
|
+
* provides the `focus()` method for the best user experience.
|
|
94
|
+
*
|
|
95
|
+
* @error ui-dropdown-panel-focus-child-missing-focus
|
|
96
|
+
* @param {module:ui/view~View} childView
|
|
97
|
+
* @param {module:ui/dropdown/dropdownpanelview~DropdownPanelView} dropdownPanel
|
|
98
|
+
*/
|
|
99
|
+
logWarning('ui-dropdown-panel-focus-child-missing-focus', { childView: this.children.first, dropdownPanel: this });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Focuses the view element or last item in view collection on opening dropdown's panel.
|
|
105
|
+
*
|
|
106
|
+
* See also {@link module:ui/dropdown/dropdownpanelfocusable~DropdownPanelFocusable}.
|
|
107
|
+
*/
|
|
108
|
+
focusLast() {
|
|
109
|
+
if (this.children.length) {
|
|
110
|
+
const lastChild = this.children.last;
|
|
111
|
+
if (typeof lastChild.focusLast === 'function') {
|
|
112
|
+
lastChild.focusLast();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
lastChild.focus();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
130
119
|
}
|