@ckeditor/ckeditor5-ui 41.1.0 → 41.3.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.
Files changed (177) hide show
  1. package/ckeditor5-metadata.json +14 -0
  2. package/dist/content-index.css +4 -0
  3. package/dist/editor-index.css +451 -0
  4. package/dist/index.css +856 -0
  5. package/dist/index.css.map +1 -0
  6. package/dist/index.js +13857 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/types/arialiveannouncer.d.ts +98 -0
  9. package/dist/types/augmentation.d.ts +88 -0
  10. package/dist/types/autocomplete/autocompleteview.d.ts +81 -0
  11. package/dist/types/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
  12. package/dist/types/bindings/clickoutsidehandler.d.ts +28 -0
  13. package/dist/types/bindings/csstransitiondisablermixin.d.ts +40 -0
  14. package/dist/types/bindings/draggableviewmixin.d.ts +46 -0
  15. package/dist/types/bindings/injectcsstransitiondisabler.d.ts +59 -0
  16. package/dist/types/bindings/preventdefault.d.ts +33 -0
  17. package/dist/types/bindings/submithandler.d.ts +57 -0
  18. package/dist/types/button/button.d.ts +175 -0
  19. package/dist/types/button/buttonlabel.d.ts +34 -0
  20. package/dist/types/button/buttonlabelview.d.ts +31 -0
  21. package/dist/types/button/buttonview.d.ts +181 -0
  22. package/dist/types/button/switchbuttonview.d.ts +45 -0
  23. package/dist/types/collapsible/collapsibleview.d.ts +70 -0
  24. package/dist/types/colorgrid/colorgridview.d.ts +132 -0
  25. package/dist/types/colorgrid/colortileview.d.ts +28 -0
  26. package/dist/types/colorgrid/utils.d.ts +47 -0
  27. package/dist/types/colorpicker/colorpickerview.d.ts +142 -0
  28. package/dist/types/colorpicker/utils.d.ts +48 -0
  29. package/dist/types/colorselector/colorgridsfragmentview.d.ts +195 -0
  30. package/dist/types/colorselector/colorpickerfragmentview.d.ts +129 -0
  31. package/dist/types/colorselector/colorselectorview.d.ts +242 -0
  32. package/dist/types/colorselector/documentcolorcollection.d.ts +70 -0
  33. package/dist/types/componentfactory.d.ts +81 -0
  34. package/dist/types/dialog/dialog.d.ts +273 -0
  35. package/dist/types/dialog/dialogactionsview.d.ts +69 -0
  36. package/dist/types/dialog/dialogcontentview.d.ts +27 -0
  37. package/dist/types/dialog/dialogview.d.ts +256 -0
  38. package/dist/types/dropdown/button/dropdownbutton.d.ts +25 -0
  39. package/dist/types/dropdown/button/dropdownbuttonview.d.ts +48 -0
  40. package/dist/types/dropdown/button/splitbuttonview.d.ts +162 -0
  41. package/dist/types/dropdown/dropdownpanelfocusable.d.ts +21 -0
  42. package/dist/types/dropdown/dropdownpanelview.d.ts +62 -0
  43. package/dist/types/dropdown/dropdownview.d.ts +315 -0
  44. package/dist/types/dropdown/utils.d.ts +235 -0
  45. package/dist/types/editableui/editableuiview.d.ts +72 -0
  46. package/dist/types/editableui/inline/inlineeditableuiview.d.ts +40 -0
  47. package/dist/types/editorui/accessibilityhelp/accessibilityhelp.d.ts +47 -0
  48. package/dist/types/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +35 -0
  49. package/dist/types/editorui/bodycollection.d.ts +55 -0
  50. package/dist/types/editorui/boxed/boxededitoruiview.d.ts +40 -0
  51. package/dist/types/editorui/editorui.d.ts +288 -0
  52. package/dist/types/editorui/editoruiview.d.ts +39 -0
  53. package/dist/types/editorui/poweredby.d.ts +71 -0
  54. package/dist/types/focuscycler.d.ts +245 -0
  55. package/dist/types/formheader/formheaderview.d.ts +59 -0
  56. package/dist/types/highlightedtext/highlightedtextview.d.ts +38 -0
  57. package/dist/types/icon/iconview.d.ts +88 -0
  58. package/dist/types/iframe/iframeview.d.ts +50 -0
  59. package/dist/types/index.d.ts +74 -0
  60. package/dist/types/input/inputbase.d.ts +107 -0
  61. package/dist/types/input/inputview.d.ts +36 -0
  62. package/dist/types/inputnumber/inputnumberview.d.ts +49 -0
  63. package/dist/types/inputtext/inputtextview.d.ts +18 -0
  64. package/dist/types/label/labelview.d.ts +36 -0
  65. package/dist/types/labeledfield/labeledfieldview.d.ts +187 -0
  66. package/dist/types/labeledfield/utils.d.ts +123 -0
  67. package/dist/types/labeledinput/labeledinputview.d.ts +125 -0
  68. package/dist/types/list/listitemgroupview.d.ts +59 -0
  69. package/dist/types/list/listitemview.d.ts +36 -0
  70. package/dist/types/list/listseparatorview.d.ts +18 -0
  71. package/dist/types/list/listview.d.ts +124 -0
  72. package/dist/types/model.d.ts +22 -0
  73. package/dist/types/notification/notification.d.ts +211 -0
  74. package/dist/types/panel/balloon/balloonpanelview.d.ts +685 -0
  75. package/dist/types/panel/balloon/contextualballoon.d.ts +299 -0
  76. package/dist/types/panel/sticky/stickypanelview.d.ts +156 -0
  77. package/dist/types/search/filteredview.d.ts +31 -0
  78. package/dist/types/search/searchinfoview.d.ts +45 -0
  79. package/dist/types/search/searchresultsview.d.ts +54 -0
  80. package/dist/types/search/text/searchtextqueryview.d.ts +76 -0
  81. package/dist/types/search/text/searchtextview.d.ts +219 -0
  82. package/dist/types/spinner/spinnerview.d.ts +25 -0
  83. package/dist/types/template.d.ts +942 -0
  84. package/dist/types/textarea/textareaview.d.ts +104 -0
  85. package/dist/types/toolbar/balloon/balloontoolbar.d.ts +117 -0
  86. package/dist/types/toolbar/block/blockbuttonview.d.ts +35 -0
  87. package/dist/types/toolbar/block/blocktoolbar.d.ts +153 -0
  88. package/dist/types/toolbar/normalizetoolbarconfig.d.ts +40 -0
  89. package/dist/types/toolbar/toolbarlinebreakview.d.ts +18 -0
  90. package/dist/types/toolbar/toolbarseparatorview.d.ts +18 -0
  91. package/dist/types/toolbar/toolbarview.d.ts +267 -0
  92. package/dist/types/tooltipmanager.d.ts +184 -0
  93. package/dist/types/view.d.ts +422 -0
  94. package/dist/types/viewcollection.d.ts +139 -0
  95. package/lang/contexts.json +7 -1
  96. package/lang/translations/ar.po +24 -0
  97. package/lang/translations/ast.po +24 -0
  98. package/lang/translations/az.po +24 -0
  99. package/lang/translations/bg.po +24 -0
  100. package/lang/translations/bn.po +24 -0
  101. package/lang/translations/ca.po +24 -0
  102. package/lang/translations/cs.po +24 -0
  103. package/lang/translations/da.po +24 -0
  104. package/lang/translations/de-ch.po +24 -0
  105. package/lang/translations/de.po +24 -0
  106. package/lang/translations/el.po +24 -0
  107. package/lang/translations/en-au.po +24 -0
  108. package/lang/translations/en-gb.po +24 -0
  109. package/lang/translations/en.po +24 -0
  110. package/lang/translations/eo.po +24 -0
  111. package/lang/translations/es.po +24 -0
  112. package/lang/translations/et.po +24 -0
  113. package/lang/translations/eu.po +24 -0
  114. package/lang/translations/fa.po +24 -0
  115. package/lang/translations/fi.po +24 -0
  116. package/lang/translations/fr.po +24 -0
  117. package/lang/translations/gl.po +24 -0
  118. package/lang/translations/he.po +25 -1
  119. package/lang/translations/hi.po +24 -0
  120. package/lang/translations/hr.po +24 -0
  121. package/lang/translations/hu.po +24 -0
  122. package/lang/translations/id.po +24 -0
  123. package/lang/translations/it.po +24 -0
  124. package/lang/translations/ja.po +24 -0
  125. package/lang/translations/km.po +24 -0
  126. package/lang/translations/kn.po +24 -0
  127. package/lang/translations/ko.po +24 -0
  128. package/lang/translations/ku.po +24 -0
  129. package/lang/translations/lt.po +24 -0
  130. package/lang/translations/lv.po +24 -0
  131. package/lang/translations/ms.po +24 -0
  132. package/lang/translations/nb.po +24 -0
  133. package/lang/translations/ne.po +24 -0
  134. package/lang/translations/nl.po +24 -0
  135. package/lang/translations/no.po +24 -0
  136. package/lang/translations/pl.po +24 -0
  137. package/lang/translations/pt-br.po +24 -0
  138. package/lang/translations/pt.po +25 -1
  139. package/lang/translations/ro.po +24 -0
  140. package/lang/translations/ru.po +24 -0
  141. package/lang/translations/sk.po +24 -0
  142. package/lang/translations/sl.po +24 -0
  143. package/lang/translations/sq.po +24 -0
  144. package/lang/translations/sr-latn.po +24 -0
  145. package/lang/translations/sr.po +24 -0
  146. package/lang/translations/sv.po +24 -0
  147. package/lang/translations/th.po +24 -0
  148. package/lang/translations/tk.po +24 -0
  149. package/lang/translations/tr.po +24 -0
  150. package/lang/translations/tt.po +24 -0
  151. package/lang/translations/ug.po +24 -0
  152. package/lang/translations/uk.po +24 -0
  153. package/lang/translations/ur.po +24 -0
  154. package/lang/translations/uz.po +24 -0
  155. package/lang/translations/vi.po +24 -0
  156. package/lang/translations/zh-cn.po +24 -0
  157. package/lang/translations/zh.po +24 -0
  158. package/package.json +4 -3
  159. package/src/augmentation.d.ts +2 -1
  160. package/src/colorpicker/colorpickerview.js +0 -1
  161. package/src/dialog/dialog.js +10 -0
  162. package/src/editorui/accessibilityhelp/accessibilityhelp.d.ts +47 -0
  163. package/src/editorui/accessibilityhelp/accessibilityhelp.js +111 -0
  164. package/src/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +35 -0
  165. package/src/editorui/accessibilityhelp/accessibilityhelpcontentview.js +112 -0
  166. package/src/formheader/formheaderview.js +2 -1
  167. package/src/index.d.ts +3 -2
  168. package/src/index.js +3 -1
  169. package/src/toolbar/balloon/balloontoolbar.d.ts +0 -5
  170. package/src/toolbar/balloon/balloontoolbar.js +5 -8
  171. package/src/toolbar/block/blocktoolbar.d.ts +0 -8
  172. package/src/toolbar/block/blocktoolbar.js +9 -14
  173. package/src/toolbar/toolbarview.js +2 -3
  174. package/src/tooltipmanager.d.ts +5 -1
  175. package/src/tooltipmanager.js +32 -4
  176. package/theme/components/editorui/accessibilityhelp.css +10 -0
  177. package/theme/icons/accessibility.svg +1 -0
@@ -0,0 +1,315 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/dropdown/dropdownview
7
+ */
8
+ import View from '../view.js';
9
+ import type { default as DropdownButton } from './button/dropdownbutton.js';
10
+ import type { default as DropdownPanelView, PanelPosition } from './dropdownpanelview.js';
11
+ import type { FocusableView } from '../focuscycler.js';
12
+ import type ListView from '../list/listview.js';
13
+ import type ToolbarView from '../toolbar/toolbarview.js';
14
+ import { KeystrokeHandler, FocusTracker, type Locale, type PositioningFunction } from '@ckeditor/ckeditor5-utils';
15
+ import '../../theme/components/dropdown/dropdown.css';
16
+ /**
17
+ * The dropdown view class. It manages the dropdown button and dropdown panel.
18
+ *
19
+ * In most cases, the easiest way to create a dropdown is by using the {@link module:ui/dropdown/utils~createDropdown}
20
+ * util:
21
+ *
22
+ * ```ts
23
+ * const dropdown = createDropdown( locale );
24
+ *
25
+ * // Configure dropdown's button properties:
26
+ * dropdown.buttonView.set( {
27
+ * label: 'A dropdown',
28
+ * withText: true
29
+ * } );
30
+ *
31
+ * dropdown.render();
32
+ *
33
+ * dropdown.panelView.element.textContent = 'Content of the panel';
34
+ *
35
+ * // Will render a dropdown with a panel containing a "Content of the panel" text.
36
+ * document.body.appendChild( dropdown.element );
37
+ * ```
38
+ *
39
+ * If you want to add a richer content to the dropdown panel, you can use the {@link module:ui/dropdown/utils~addListToDropdown}
40
+ * and {@link module:ui/dropdown/utils~addToolbarToDropdown} helpers. See more examples in
41
+ * {@link module:ui/dropdown/utils~createDropdown} documentation.
42
+ *
43
+ * If you want to create a completely custom dropdown, then you can compose it manually:
44
+ *
45
+ * ```ts
46
+ * const button = new DropdownButtonView( locale );
47
+ * const panel = new DropdownPanelView( locale );
48
+ * const dropdown = new DropdownView( locale, button, panel );
49
+ *
50
+ * button.set( {
51
+ * label: 'A dropdown',
52
+ * withText: true
53
+ * } );
54
+ *
55
+ * dropdown.render();
56
+ *
57
+ * panel.element.textContent = 'Content of the panel';
58
+ *
59
+ * // Will render a dropdown with a panel containing a "Content of the panel" text.
60
+ * document.body.appendChild( dropdown.element );
61
+ * ```
62
+ *
63
+ * However, dropdown created this way will contain little behavior. You will need to implement handlers for actions
64
+ * such as {@link module:ui/bindings/clickoutsidehandler~clickOutsideHandler clicking outside an open dropdown}
65
+ * (which should close it) and support for arrow keys inside the panel. Therefore, unless you really know what
66
+ * you do and you really need to do it, it is recommended to use the {@link module:ui/dropdown/utils~createDropdown} helper.
67
+ */
68
+ export default class DropdownView extends View<HTMLDivElement> {
69
+ /**
70
+ * Button of the dropdown view. Clicking the button opens the {@link #panelView}.
71
+ */
72
+ readonly buttonView: DropdownButton & FocusableView;
73
+ /**
74
+ * Panel of the dropdown. It opens when the {@link #buttonView} is
75
+ * {@link module:ui/button/button~Button#event:execute executed} (i.e. clicked).
76
+ *
77
+ * Child views can be added to the panel's `children` collection:
78
+ *
79
+ * ```ts
80
+ * dropdown.panelView.children.add( childView );
81
+ * ```
82
+ *
83
+ * See {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView#children} and
84
+ * {@link module:ui/viewcollection~ViewCollection#add}.
85
+ */
86
+ readonly panelView: DropdownPanelView;
87
+ /**
88
+ * Tracks information about the DOM focus in the dropdown.
89
+ */
90
+ readonly focusTracker: FocusTracker;
91
+ /**
92
+ * Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}. It manages
93
+ * keystrokes of the dropdown:
94
+ *
95
+ * * <kbd>▼</kbd> opens the dropdown,
96
+ * * <kbd>◀</kbd> and <kbd>Esc</kbd> closes the dropdown.
97
+ */
98
+ readonly keystrokes: KeystrokeHandler;
99
+ /**
100
+ * A child {@link module:ui/list/listview~ListView list view} of the dropdown located
101
+ * in its {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
102
+ *
103
+ * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addListToDropdown}.
104
+ */
105
+ listView?: ListView;
106
+ /**
107
+ * A child toolbar of the dropdown located in the
108
+ * {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
109
+ *
110
+ * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addToolbarToDropdown}.
111
+ */
112
+ toolbarView?: ToolbarView;
113
+ /**
114
+ * Controls whether the dropdown view is open, i.e. shows or hides the {@link #panelView panel}.
115
+ *
116
+ * **Note**: When the dropdown gets open, it will attempt to call `focus()` on the first child of its {@link #panelView}.
117
+ * See {@link module:ui/dropdown/utils~addToolbarToDropdown}, {@link module:ui/dropdown/utils~addListToDropdown}, and
118
+ * {@link module:ui/dropdown/utils~focusChildOnDropdownOpen} to learn more about focus management in dropdowns.
119
+ *
120
+ * @observable
121
+ */
122
+ isOpen: boolean;
123
+ /**
124
+ * Controls whether the dropdown is enabled, i.e. it can be clicked and execute an action.
125
+ *
126
+ * See {@link module:ui/button/buttonview~ButtonView#isEnabled}.
127
+ *
128
+ * @observable
129
+ */
130
+ isEnabled: boolean;
131
+ /**
132
+ * (Optional) The additional CSS class set on the dropdown {@link #element}.
133
+ *
134
+ * @observable
135
+ */
136
+ class: string | undefined;
137
+ /**
138
+ * (Optional) The `id` attribute of the dropdown (i.e. to pair with a `<label>` element).
139
+ *
140
+ * @observable
141
+ */
142
+ id: string | undefined;
143
+ /**
144
+ * The position of the panel, relative to the dropdown.
145
+ *
146
+ * **Note**: When `'auto'`, the panel will use one of the remaining positions to stay
147
+ * in the viewport, visible to the user. The positions correspond directly to
148
+ * {@link module:ui/dropdown/dropdownview~DropdownView.defaultPanelPositions default panel positions}.
149
+ *
150
+ * **Note**: This value has an impact on the
151
+ * {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView#position} property
152
+ * each time the panel becomes {@link #isOpen open}.
153
+ *
154
+ * @observable
155
+ * @default 'auto'
156
+ */
157
+ panelPosition: PanelPosition | 'auto';
158
+ /**
159
+ * @observable
160
+ */
161
+ ariaDescribedById: string | undefined;
162
+ /**
163
+ * Creates an instance of the dropdown.
164
+ *
165
+ * Also see {@link #render}.
166
+ *
167
+ * @param locale The localization services instance.
168
+ */
169
+ constructor(locale: Locale | undefined, buttonView: DropdownButton & FocusableView, panelView: DropdownPanelView);
170
+ /**
171
+ * @inheritDoc
172
+ */
173
+ render(): void;
174
+ /**
175
+ * Focuses the {@link #buttonView}.
176
+ */
177
+ focus(): void;
178
+ /**
179
+ * Returns {@link #panelView panel} positions to be used by the
180
+ * {@link module:utils/dom/position~getOptimalPosition `getOptimalPosition()`}
181
+ * utility considering the direction of the language the UI of the editor is displayed in.
182
+ */
183
+ private get _panelPositions();
184
+ /**
185
+ * A set of positioning functions used by the dropdown view to determine
186
+ * the optimal position (i.e. fitting into the browser viewport) of its
187
+ * {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel} when
188
+ * {@link module:ui/dropdown/dropdownview~DropdownView#panelPosition} is set to 'auto'`.
189
+ *
190
+ * The available positioning functions are as follow:
191
+ *
192
+ * **South**
193
+ *
194
+ * * `south`
195
+ *
196
+ * ```
197
+ * [ Button ]
198
+ * +-----------------+
199
+ * | Panel |
200
+ * +-----------------+
201
+ * ```
202
+ *
203
+ * * `southEast`
204
+ *
205
+ * ```
206
+ * [ Button ]
207
+ * +-----------------+
208
+ * | Panel |
209
+ * +-----------------+
210
+ * ```
211
+ *
212
+ * * `southWest`
213
+ *
214
+ * ```
215
+ * [ Button ]
216
+ * +-----------------+
217
+ * | Panel |
218
+ * +-----------------+
219
+ * ```
220
+ *
221
+ * * `southMiddleEast`
222
+ *
223
+ * ```
224
+ * [ Button ]
225
+ * +-----------------+
226
+ * | Panel |
227
+ * +-----------------+
228
+ * ```
229
+ *
230
+ * * `southMiddleWest`
231
+ *
232
+ * ```
233
+ * [ Button ]
234
+ * +-----------------+
235
+ * | Panel |
236
+ * +-----------------+
237
+ * ```
238
+ *
239
+ * **North**
240
+ *
241
+ * * `north`
242
+ *
243
+ * ```
244
+ * +-----------------+
245
+ * | Panel |
246
+ * +-----------------+
247
+ * [ Button ]
248
+ * ```
249
+ *
250
+ * * `northEast`
251
+ *
252
+ * ```
253
+ * +-----------------+
254
+ * | Panel |
255
+ * +-----------------+
256
+ * [ Button ]
257
+ * ```
258
+ *
259
+ * * `northWest`
260
+ *
261
+ * ```
262
+ * +-----------------+
263
+ * | Panel |
264
+ * +-----------------+
265
+ * [ Button ]
266
+ * ```
267
+ *
268
+ * * `northMiddleEast`
269
+ *
270
+ * ```
271
+ * +-----------------+
272
+ * | Panel |
273
+ * +-----------------+
274
+ * [ Button ]
275
+ * ```
276
+ *
277
+ * * `northMiddleWest`
278
+ *
279
+ * ```
280
+ * +-----------------+
281
+ * | Panel |
282
+ * +-----------------+
283
+ * [ Button ]
284
+ * ```
285
+ *
286
+ * Positioning functions are compatible with {@link module:utils/dom/position~DomPoint}.
287
+ *
288
+ * The name that position function returns will be reflected in dropdown panel's class that
289
+ * controls its placement. See {@link module:ui/dropdown/dropdownview~DropdownView#panelPosition}
290
+ * to learn more.
291
+ */
292
+ static defaultPanelPositions: Record<string, PositioningFunction>;
293
+ /**
294
+ * A function used to calculate the optimal position for the dropdown panel.
295
+ */
296
+ private static _getOptimalPosition;
297
+ }
298
+ /**
299
+ * Fired when the toolbar button or list item is executed.
300
+ *
301
+ * For {@link ~DropdownView#listView} It fires when a child of some {@link module:ui/list/listitemview~ListItemView}
302
+ * fired `execute`.
303
+ *
304
+ * For {@link ~DropdownView#toolbarView} It fires when one of the buttons has been
305
+ * {@link module:ui/button/button~Button#event:execute executed}.
306
+ *
307
+ * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addListToDropdown}
308
+ * or {@link module:ui/dropdown/utils~addToolbarToDropdown}.
309
+ *
310
+ * @eventName ~DropdownView#execute
311
+ */
312
+ export type DropdownViewEvent = {
313
+ name: 'execute';
314
+ args: [];
315
+ };
@@ -0,0 +1,235 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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 DropdownView from './dropdownview.js';
6
+ import ViewCollection from '../viewcollection.js';
7
+ import type { default as View } from '../view.js';
8
+ import type Model from '../model.js';
9
+ import type DropdownButton from './button/dropdownbutton.js';
10
+ import type { FocusableView } from '../focuscycler.js';
11
+ import type { FalsyValue } from '../template.js';
12
+ import { type Collection, type Locale } from '@ckeditor/ckeditor5-utils';
13
+ import '../../theme/components/dropdown/toolbardropdown.css';
14
+ import '../../theme/components/dropdown/listdropdown.css';
15
+ /**
16
+ * A helper for creating dropdowns. It creates an instance of a {@link module:ui/dropdown/dropdownview~DropdownView dropdown},
17
+ * with a {@link module:ui/dropdown/button/dropdownbutton~DropdownButton button},
18
+ * {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView panel} and all standard dropdown's behaviors.
19
+ *
20
+ * # Creating dropdowns
21
+ *
22
+ * By default, the default {@link module:ui/dropdown/button/dropdownbuttonview~DropdownButtonView} class is used as
23
+ * definition of the button:
24
+ *
25
+ * ```ts
26
+ * const dropdown = createDropdown( model );
27
+ *
28
+ * // Configure dropdown's button properties:
29
+ * dropdown.buttonView.set( {
30
+ * label: 'A dropdown',
31
+ * withText: true
32
+ * } );
33
+ *
34
+ * dropdown.render();
35
+ *
36
+ * // Will render a dropdown labeled "A dropdown" with an empty panel.
37
+ * document.body.appendChild( dropdown.element );
38
+ * ```
39
+ *
40
+ * You can also provide other button views (they need to implement the
41
+ * {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface). For instance, you can use
42
+ * {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} to create a dropdown with a split button.
43
+ *
44
+ * ```ts
45
+ * const dropdown = createDropdown( locale, SplitButtonView );
46
+ *
47
+ * // Configure dropdown's button properties:
48
+ * dropdown.buttonView.set( {
49
+ * label: 'A dropdown',
50
+ * withText: true
51
+ * } );
52
+ *
53
+ * dropdown.buttonView.on( 'execute', () => {
54
+ * // Add the behavior of the "action part" of the split button.
55
+ * // Split button consists of the "action part" and "arrow part".
56
+ * // The arrow opens the dropdown while the action part can have some other behavior.
57
+ * } );
58
+ *
59
+ * dropdown.render();
60
+ *
61
+ * // Will render a dropdown labeled "A dropdown" with an empty panel.
62
+ * document.body.appendChild( dropdown.element );
63
+ * ```
64
+ *
65
+ * # Adding content to the dropdown's panel
66
+ *
67
+ * The content of the panel can be inserted directly into the `dropdown.panelView.element`:
68
+ *
69
+ * ```ts
70
+ * dropdown.panelView.element.textContent = 'Content of the panel';
71
+ * ```
72
+ *
73
+ * However, most of the time you will want to add there either a {@link module:ui/list/listview~ListView list of options}
74
+ * or a list of buttons (i.e. a {@link module:ui/toolbar/toolbarview~ToolbarView toolbar}).
75
+ * To simplify the task, you can use, respectively, {@link module:ui/dropdown/utils~addListToDropdown} or
76
+ * {@link module:ui/dropdown/utils~addToolbarToDropdown} utils.
77
+ *
78
+ * @param locale The locale instance.
79
+ * @param ButtonClassOrInstance The dropdown button view class. Needs to implement the
80
+ * {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface.
81
+ * @returns The dropdown view instance.
82
+ */
83
+ export declare function createDropdown(locale: Locale | undefined, ButtonClassOrInstance?: (new (locale?: Locale) => DropdownButton & FocusableView) | (DropdownButton & FocusableView)): DropdownView;
84
+ /**
85
+ * Adds an instance of {@link module:ui/toolbar/toolbarview~ToolbarView} to a dropdown.
86
+ *
87
+ * ```ts
88
+ * const buttonsCreator = () => {
89
+ * const buttons = [];
90
+ *
91
+ * // Either create a new ButtonView instance or create existing.
92
+ * buttons.push( new ButtonView() );
93
+ * buttons.push( editor.ui.componentFactory.create( 'someButton' ) );
94
+ * };
95
+ *
96
+ * const dropdown = createDropdown( locale );
97
+ *
98
+ * addToolbarToDropdown( dropdown, buttonsCreator, { isVertical: true } );
99
+ *
100
+ * // Will render a vertical button dropdown labeled "A button dropdown"
101
+ * // with a button group in the panel containing two buttons.
102
+ * // Buttons inside the dropdown will be created on first dropdown panel open.
103
+ * dropdown.render()
104
+ * document.body.appendChild( dropdown.element );
105
+ * ```
106
+ *
107
+ * **Note:** To improve the accessibility, you can tell the dropdown to focus the first active button of the toolbar when the dropdown
108
+ * {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}. See the documentation of `options` to learn more.
109
+ *
110
+ * **Note:** Toolbar view will be created on first open of the dropdown.
111
+ *
112
+ * See {@link module:ui/dropdown/utils~createDropdown} and {@link module:ui/toolbar/toolbarview~ToolbarView}.
113
+ *
114
+ * @param dropdownView A dropdown instance to which `ToolbarView` will be added.
115
+ * @param options.enableActiveItemFocusOnDropdownOpen When set `true`, the focus will automatically move to the first
116
+ * active {@link module:ui/toolbar/toolbarview~ToolbarView#items item} of the toolbar upon
117
+ * {@link module:ui/dropdown/dropdownview~DropdownView#isOpen opening} the dropdown. Active items are those with the `isOn` property set
118
+ * `true` (for instance {@link module:ui/button/buttonview~ButtonView buttons}). If no active items is found, the toolbar will be focused
119
+ * as a whole resulting in the focus moving to its first focusable item (default behavior of
120
+ * {@link module:ui/dropdown/dropdownview~DropdownView}).
121
+ * @param options.ariaLabel Label used by assistive technologies to describe toolbar element.
122
+ * @param options.maxWidth The maximum width of the toolbar element.
123
+ * Details: {@link module:ui/toolbar/toolbarview~ToolbarView#maxWidth}.
124
+ * @param options.class An additional CSS class added to the toolbar element.
125
+ * @param options.isCompact When set true, makes the toolbar look compact with toolbar element.
126
+ * @param options.isVertical Controls the orientation of toolbar items.
127
+ */
128
+ export declare function addToolbarToDropdown(dropdownView: DropdownView, buttonsOrCallback: Array<View> | ViewCollection | (() => Array<View> | ViewCollection), options?: {
129
+ enableActiveItemFocusOnDropdownOpen?: boolean;
130
+ ariaLabel?: string;
131
+ maxWidth?: string;
132
+ class?: string;
133
+ isCompact?: boolean;
134
+ isVertical?: boolean;
135
+ }): void;
136
+ /**
137
+ * Adds an instance of {@link module:ui/list/listview~ListView} to a dropdown.
138
+ *
139
+ * ```ts
140
+ * const items = new Collection<ListDropdownItemDefinition>();
141
+ *
142
+ * items.add( {
143
+ * type: 'button',
144
+ * model: new Model( {
145
+ * withText: true,
146
+ * label: 'First item',
147
+ * labelStyle: 'color: red'
148
+ * } )
149
+ * } );
150
+ *
151
+ * items.add( {
152
+ * type: 'button',
153
+ * model: new Model( {
154
+ * withText: true,
155
+ * label: 'Second item',
156
+ * labelStyle: 'color: green',
157
+ * class: 'foo'
158
+ * } )
159
+ * } );
160
+ *
161
+ * const dropdown = createDropdown( locale );
162
+ *
163
+ * addListToDropdown( dropdown, items );
164
+ *
165
+ * // Will render a dropdown with a list in the panel containing two items.
166
+ * dropdown.render()
167
+ * document.body.appendChild( dropdown.element );
168
+ * ```
169
+ *
170
+ * The `items` collection passed to this methods controls the presence and attributes of respective
171
+ * {@link module:ui/list/listitemview~ListItemView list items}.
172
+ *
173
+ * **Note:** To improve the accessibility, when a list is added to the dropdown using this helper the dropdown will automatically attempt
174
+ * to focus the first active item (a host to a {@link module:ui/button/buttonview~ButtonView} with
175
+ * {@link module:ui/button/buttonview~ButtonView#isOn} set `true`) or the very first item when none are active.
176
+ *
177
+ * **Note:** List view will be created on first open of the dropdown.
178
+ *
179
+ * See {@link module:ui/dropdown/utils~createDropdown} and {@link module:list/list~List}.
180
+ *
181
+ * @param dropdownView A dropdown instance to which `ListVIew` will be added.
182
+ * @param itemsOrCallback A collection of the list item definitions or a callback returning a list item definitions to populate the list.
183
+ * @param options.ariaLabel Label used by assistive technologies to describe list element.
184
+ * @param options.role Will be reflected by the `role` DOM attribute in `ListVIew` and used by assistive technologies.
185
+ */
186
+ export declare function addListToDropdown(dropdownView: DropdownView, itemsOrCallback: Collection<ListDropdownItemDefinition> | (() => Collection<ListDropdownItemDefinition>), options?: {
187
+ ariaLabel?: string;
188
+ role?: string;
189
+ }): void;
190
+ /**
191
+ * A helper to be used on an existing {@link module:ui/dropdown/dropdownview~DropdownView} that focuses
192
+ * a specific child in DOM when the dropdown {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}.
193
+ *
194
+ * @param dropdownView A dropdown instance to which the focus behavior will be added.
195
+ * @param childSelectorCallback A callback executed when the dropdown gets open. It should return a {@link module:ui/view~View}
196
+ * instance (child of {@link module:ui/dropdown/dropdownview~DropdownView#panelView}) that will get focused or a falsy value.
197
+ * If falsy value is returned, a default behavior of the dropdown will engage focusing the first focusable child in
198
+ * the {@link module:ui/dropdown/dropdownview~DropdownView#panelView}.
199
+ */
200
+ export declare function focusChildOnDropdownOpen(dropdownView: DropdownView, childSelectorCallback: () => View | FalsyValue): void;
201
+ /**
202
+ * A definition of the list item used by the {@link module:ui/dropdown/utils~addListToDropdown}
203
+ * utility.
204
+ */
205
+ export type ListDropdownItemDefinition = ListDropdownSeparatorDefinition | ListDropdownButtonDefinition | ListDropdownGroupDefinition;
206
+ /**
207
+ * A definition of the 'separator' list item.
208
+ */
209
+ export type ListDropdownSeparatorDefinition = {
210
+ type: 'separator';
211
+ };
212
+ /**
213
+ * A definition of the 'button' or 'switchbutton' list item.
214
+ */
215
+ export type ListDropdownButtonDefinition = {
216
+ type: 'button' | 'switchbutton';
217
+ /**
218
+ * Model of the item. Its properties fuel the newly created list item (or its children, depending on the `type`).
219
+ */
220
+ model: Model;
221
+ };
222
+ /**
223
+ * A definition of the group inside the list. A group can contain one or more list items (buttons).
224
+ */
225
+ export type ListDropdownGroupDefinition = {
226
+ type: 'group';
227
+ /**
228
+ * The visible label of the group.
229
+ */
230
+ label: string;
231
+ /**
232
+ * The collection of the child list items inside this group.
233
+ */
234
+ items: Collection<ListDropdownButtonDefinition>;
235
+ };
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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.js';
9
+ import type { 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 module:ui/editableui/editableuiview~EditableUIView#_editableElement} or assigning {@link #element}
55
+ * as {@link module:ui/editableui/editableuiview~EditableUIView#_editableElement}.
56
+ */
57
+ render(): void;
58
+ /**
59
+ * @inheritDoc
60
+ */
61
+ destroy(): void;
62
+ /**
63
+ * Whether an external {@link #_editableElement} was passed into the constructor, which also means
64
+ * the view will not render its {@link #template}.
65
+ */
66
+ get hasExternalElement(): boolean;
67
+ /**
68
+ * Updates the `ck-focused` and `ck-blurred` CSS classes on the {@link #element} according to
69
+ * the {@link #isFocused} property value using the {@link #_editingView editing view} API.
70
+ */
71
+ private _updateIsFocusedClasses;
72
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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.js';
9
+ import type { EditingView } 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: EditingView, editableElement?: HTMLElement, options?: {
34
+ label?: (view: InlineEditableUIView) => string;
35
+ });
36
+ /**
37
+ * @inheritDoc
38
+ */
39
+ render(): void;
40
+ }