@ckeditor/ckeditor5-ui 43.0.0 → 43.1.0-alpha.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.
Files changed (274) hide show
  1. package/dist/bindings/clickoutsidehandler.d.ts +5 -3
  2. package/dist/dropdown/dropdownview.d.ts +21 -8
  3. package/dist/dropdown/menu/dropdownmenubehaviors.d.ts +48 -0
  4. package/dist/dropdown/menu/dropdownmenubuttonview.d.ts +40 -0
  5. package/dist/dropdown/menu/dropdownmenulistitembuttonview.d.ts +21 -0
  6. package/dist/dropdown/menu/dropdownmenulistitemview.d.ts +26 -0
  7. package/dist/dropdown/menu/dropdownmenulistview.d.ts +28 -0
  8. package/dist/dropdown/menu/dropdownmenunestedmenupanelview.d.ts +38 -0
  9. package/dist/dropdown/menu/dropdownmenunestedmenuview.d.ts +135 -0
  10. package/dist/dropdown/menu/dropdownmenurootlistview.d.ts +144 -0
  11. package/dist/dropdown/menu/utils.d.ts +128 -0
  12. package/dist/dropdown/utils.d.ts +58 -0
  13. package/dist/editableui/editableuiview.d.ts +1 -1
  14. package/dist/editableui/inline/inlineeditableuiview.d.ts +13 -9
  15. package/dist/editorui/editorui.d.ts +4 -0
  16. package/dist/index-editor.css +16 -0
  17. package/dist/index.css +31 -0
  18. package/dist/index.css.map +1 -1
  19. package/dist/index.d.ts +7 -1
  20. package/dist/index.js +4717 -3869
  21. package/dist/index.js.map +1 -1
  22. package/dist/menubar/utils.d.ts +5 -5
  23. package/dist/panel/balloon/contextualballoon.d.ts +12 -6
  24. package/dist/toolbar/balloon/balloontoolbar.d.ts +5 -0
  25. package/dist/translations/af.js +1 -1
  26. package/dist/translations/af.umd.js +1 -1
  27. package/dist/translations/ar.js +1 -1
  28. package/dist/translations/ar.umd.js +1 -1
  29. package/dist/translations/ast.js +1 -1
  30. package/dist/translations/ast.umd.js +1 -1
  31. package/dist/translations/az.js +1 -1
  32. package/dist/translations/az.umd.js +1 -1
  33. package/dist/translations/bg.js +1 -1
  34. package/dist/translations/bg.umd.js +1 -1
  35. package/dist/translations/bn.js +1 -1
  36. package/dist/translations/bn.umd.js +1 -1
  37. package/dist/translations/bs.js +1 -1
  38. package/dist/translations/bs.umd.js +1 -1
  39. package/dist/translations/ca.js +1 -1
  40. package/dist/translations/ca.umd.js +1 -1
  41. package/dist/translations/cs.js +1 -1
  42. package/dist/translations/cs.umd.js +1 -1
  43. package/dist/translations/da.js +1 -1
  44. package/dist/translations/da.umd.js +1 -1
  45. package/dist/translations/de-ch.js +1 -1
  46. package/dist/translations/de-ch.umd.js +1 -1
  47. package/dist/translations/de.js +1 -1
  48. package/dist/translations/de.umd.js +1 -1
  49. package/dist/translations/el.js +1 -1
  50. package/dist/translations/el.umd.js +1 -1
  51. package/dist/translations/en-au.js +1 -1
  52. package/dist/translations/en-au.umd.js +1 -1
  53. package/dist/translations/en-gb.js +1 -1
  54. package/dist/translations/en-gb.umd.js +1 -1
  55. package/dist/translations/en.js +1 -1
  56. package/dist/translations/en.umd.js +1 -1
  57. package/dist/translations/eo.js +1 -1
  58. package/dist/translations/eo.umd.js +1 -1
  59. package/dist/translations/es-co.js +1 -1
  60. package/dist/translations/es-co.umd.js +1 -1
  61. package/dist/translations/es.js +1 -1
  62. package/dist/translations/es.umd.js +1 -1
  63. package/dist/translations/et.js +1 -1
  64. package/dist/translations/et.umd.js +1 -1
  65. package/dist/translations/eu.js +1 -1
  66. package/dist/translations/eu.umd.js +1 -1
  67. package/dist/translations/fa.js +1 -1
  68. package/dist/translations/fa.umd.js +1 -1
  69. package/dist/translations/fi.js +1 -1
  70. package/dist/translations/fi.umd.js +1 -1
  71. package/dist/translations/fr.js +1 -1
  72. package/dist/translations/fr.umd.js +1 -1
  73. package/dist/translations/gl.js +1 -1
  74. package/dist/translations/gl.umd.js +1 -1
  75. package/dist/translations/he.js +1 -1
  76. package/dist/translations/he.umd.js +1 -1
  77. package/dist/translations/hi.js +1 -1
  78. package/dist/translations/hi.umd.js +1 -1
  79. package/dist/translations/hr.js +1 -1
  80. package/dist/translations/hr.umd.js +1 -1
  81. package/dist/translations/hu.js +1 -1
  82. package/dist/translations/hu.umd.js +1 -1
  83. package/dist/translations/id.js +1 -1
  84. package/dist/translations/id.umd.js +1 -1
  85. package/dist/translations/it.js +1 -1
  86. package/dist/translations/it.umd.js +1 -1
  87. package/dist/translations/ja.js +1 -1
  88. package/dist/translations/ja.umd.js +1 -1
  89. package/dist/translations/jv.js +1 -1
  90. package/dist/translations/jv.umd.js +1 -1
  91. package/dist/translations/km.js +1 -1
  92. package/dist/translations/km.umd.js +1 -1
  93. package/dist/translations/kn.js +1 -1
  94. package/dist/translations/kn.umd.js +1 -1
  95. package/dist/translations/ko.js +1 -1
  96. package/dist/translations/ko.umd.js +1 -1
  97. package/dist/translations/ku.js +1 -1
  98. package/dist/translations/ku.umd.js +1 -1
  99. package/dist/translations/lt.js +1 -1
  100. package/dist/translations/lt.umd.js +1 -1
  101. package/dist/translations/lv.js +1 -1
  102. package/dist/translations/lv.umd.js +1 -1
  103. package/dist/translations/ms.js +1 -1
  104. package/dist/translations/ms.umd.js +1 -1
  105. package/dist/translations/nb.js +1 -1
  106. package/dist/translations/nb.umd.js +1 -1
  107. package/dist/translations/ne.js +1 -1
  108. package/dist/translations/ne.umd.js +1 -1
  109. package/dist/translations/nl.js +1 -1
  110. package/dist/translations/nl.umd.js +1 -1
  111. package/dist/translations/no.js +1 -1
  112. package/dist/translations/no.umd.js +1 -1
  113. package/dist/translations/pl.js +1 -1
  114. package/dist/translations/pl.umd.js +1 -1
  115. package/dist/translations/pt-br.js +1 -1
  116. package/dist/translations/pt-br.umd.js +1 -1
  117. package/dist/translations/pt.js +1 -1
  118. package/dist/translations/pt.umd.js +1 -1
  119. package/dist/translations/ro.js +1 -1
  120. package/dist/translations/ro.umd.js +1 -1
  121. package/dist/translations/ru.js +1 -1
  122. package/dist/translations/ru.umd.js +1 -1
  123. package/dist/translations/sk.js +1 -1
  124. package/dist/translations/sk.umd.js +1 -1
  125. package/dist/translations/sl.js +1 -1
  126. package/dist/translations/sl.umd.js +1 -1
  127. package/dist/translations/sq.js +1 -1
  128. package/dist/translations/sq.umd.js +1 -1
  129. package/dist/translations/sr-latn.js +1 -1
  130. package/dist/translations/sr-latn.umd.js +1 -1
  131. package/dist/translations/sr.js +1 -1
  132. package/dist/translations/sr.umd.js +1 -1
  133. package/dist/translations/sv.js +1 -1
  134. package/dist/translations/sv.umd.js +1 -1
  135. package/dist/translations/th.js +1 -1
  136. package/dist/translations/th.umd.js +1 -1
  137. package/dist/translations/ti.js +1 -1
  138. package/dist/translations/ti.umd.js +1 -1
  139. package/dist/translations/tk.js +1 -1
  140. package/dist/translations/tk.umd.js +1 -1
  141. package/dist/translations/tr.js +1 -1
  142. package/dist/translations/tr.umd.js +1 -1
  143. package/dist/translations/tt.js +1 -1
  144. package/dist/translations/tt.umd.js +1 -1
  145. package/dist/translations/ug.js +1 -1
  146. package/dist/translations/ug.umd.js +1 -1
  147. package/dist/translations/uk.js +1 -1
  148. package/dist/translations/uk.umd.js +1 -1
  149. package/dist/translations/ur.js +1 -1
  150. package/dist/translations/ur.umd.js +1 -1
  151. package/dist/translations/uz.js +1 -1
  152. package/dist/translations/uz.umd.js +1 -1
  153. package/dist/translations/vi.js +1 -1
  154. package/dist/translations/vi.umd.js +1 -1
  155. package/dist/translations/zh-cn.js +1 -1
  156. package/dist/translations/zh-cn.umd.js +1 -1
  157. package/dist/translations/zh.js +1 -1
  158. package/dist/translations/zh.umd.js +1 -1
  159. package/lang/contexts.json +1 -1
  160. package/lang/translations/af.po +4 -4
  161. package/lang/translations/ar.po +4 -4
  162. package/lang/translations/ast.po +4 -4
  163. package/lang/translations/az.po +4 -4
  164. package/lang/translations/bg.po +4 -4
  165. package/lang/translations/bn.po +4 -4
  166. package/lang/translations/bs.po +4 -4
  167. package/lang/translations/ca.po +4 -4
  168. package/lang/translations/cs.po +4 -4
  169. package/lang/translations/da.po +4 -4
  170. package/lang/translations/de-ch.po +4 -4
  171. package/lang/translations/de.po +4 -4
  172. package/lang/translations/el.po +4 -4
  173. package/lang/translations/en-au.po +4 -4
  174. package/lang/translations/en-gb.po +4 -4
  175. package/lang/translations/en.po +4 -4
  176. package/lang/translations/eo.po +4 -4
  177. package/lang/translations/es-co.po +4 -4
  178. package/lang/translations/es.po +4 -4
  179. package/lang/translations/et.po +4 -4
  180. package/lang/translations/eu.po +4 -4
  181. package/lang/translations/fa.po +4 -4
  182. package/lang/translations/fi.po +4 -4
  183. package/lang/translations/fr.po +4 -4
  184. package/lang/translations/gl.po +4 -4
  185. package/lang/translations/he.po +4 -4
  186. package/lang/translations/hi.po +4 -4
  187. package/lang/translations/hr.po +4 -4
  188. package/lang/translations/hu.po +4 -4
  189. package/lang/translations/id.po +4 -4
  190. package/lang/translations/it.po +4 -4
  191. package/lang/translations/ja.po +4 -4
  192. package/lang/translations/jv.po +4 -4
  193. package/lang/translations/km.po +4 -4
  194. package/lang/translations/kn.po +4 -4
  195. package/lang/translations/ko.po +4 -4
  196. package/lang/translations/ku.po +4 -4
  197. package/lang/translations/lt.po +4 -4
  198. package/lang/translations/lv.po +4 -4
  199. package/lang/translations/ms.po +4 -4
  200. package/lang/translations/nb.po +4 -4
  201. package/lang/translations/ne.po +4 -4
  202. package/lang/translations/nl.po +4 -4
  203. package/lang/translations/no.po +4 -4
  204. package/lang/translations/pl.po +4 -4
  205. package/lang/translations/pt-br.po +4 -4
  206. package/lang/translations/pt.po +4 -4
  207. package/lang/translations/ro.po +4 -4
  208. package/lang/translations/ru.po +4 -4
  209. package/lang/translations/sk.po +4 -4
  210. package/lang/translations/sl.po +4 -4
  211. package/lang/translations/sq.po +4 -4
  212. package/lang/translations/sr-latn.po +4 -4
  213. package/lang/translations/sr.po +4 -4
  214. package/lang/translations/sv.po +4 -4
  215. package/lang/translations/th.po +4 -4
  216. package/lang/translations/ti.po +4 -4
  217. package/lang/translations/tk.po +4 -4
  218. package/lang/translations/tr.po +4 -4
  219. package/lang/translations/tt.po +4 -4
  220. package/lang/translations/ug.po +4 -4
  221. package/lang/translations/uk.po +4 -4
  222. package/lang/translations/ur.po +4 -4
  223. package/lang/translations/uz.po +4 -4
  224. package/lang/translations/vi.po +4 -4
  225. package/lang/translations/zh-cn.po +4 -4
  226. package/lang/translations/zh.po +4 -4
  227. package/package.json +4 -3
  228. package/src/bindings/clickoutsidehandler.d.ts +5 -3
  229. package/src/bindings/clickoutsidehandler.js +3 -2
  230. package/src/dialog/dialog.js +0 -1
  231. package/src/dropdown/dropdownview.d.ts +21 -8
  232. package/src/dropdown/menu/dropdownmenubehaviors.d.ts +44 -0
  233. package/src/dropdown/menu/dropdownmenubehaviors.js +119 -0
  234. package/src/dropdown/menu/dropdownmenubuttonview.d.ts +36 -0
  235. package/src/dropdown/menu/dropdownmenubuttonview.js +65 -0
  236. package/src/dropdown/menu/dropdownmenulistitembuttonview.d.ts +17 -0
  237. package/src/dropdown/menu/dropdownmenulistitembuttonview.js +29 -0
  238. package/src/dropdown/menu/dropdownmenulistitemview.d.ts +22 -0
  239. package/src/dropdown/menu/dropdownmenulistitemview.js +34 -0
  240. package/src/dropdown/menu/dropdownmenulistview.d.ts +24 -0
  241. package/src/dropdown/menu/dropdownmenulistview.js +29 -0
  242. package/src/dropdown/menu/dropdownmenunestedmenupanelview.d.ts +34 -0
  243. package/src/dropdown/menu/dropdownmenunestedmenupanelview.js +63 -0
  244. package/src/dropdown/menu/dropdownmenunestedmenuview.d.ts +131 -0
  245. package/src/dropdown/menu/dropdownmenunestedmenuview.js +191 -0
  246. package/src/dropdown/menu/dropdownmenurootlistview.d.ts +140 -0
  247. package/src/dropdown/menu/dropdownmenurootlistview.js +160 -0
  248. package/src/dropdown/menu/utils.d.ts +124 -0
  249. package/src/dropdown/menu/utils.js +61 -0
  250. package/src/dropdown/utils.d.ts +58 -0
  251. package/src/dropdown/utils.js +101 -18
  252. package/src/editableui/editableuiview.d.ts +1 -1
  253. package/src/editableui/inline/inlineeditableuiview.d.ts +13 -9
  254. package/src/editableui/inline/inlineeditableuiview.js +29 -6
  255. package/src/editorui/accessibilityhelp/accessibilityhelp.js +3 -1
  256. package/src/editorui/editorui.d.ts +4 -0
  257. package/src/editorui/editorui.js +16 -1
  258. package/src/editorui/poweredby.js +0 -1
  259. package/src/index.d.ts +7 -1
  260. package/src/index.js +6 -0
  261. package/src/menubar/menubarmenuview.js +1 -0
  262. package/src/menubar/utils.d.ts +5 -5
  263. package/src/menubar/utils.js +21 -12
  264. package/src/panel/balloon/balloonpanelview.js +19 -12
  265. package/src/panel/balloon/contextualballoon.d.ts +12 -6
  266. package/src/panel/balloon/contextualballoon.js +24 -24
  267. package/src/toolbar/balloon/balloontoolbar.d.ts +5 -0
  268. package/src/toolbar/balloon/balloontoolbar.js +26 -5
  269. package/src/toolbar/block/blocktoolbar.js +0 -2
  270. package/theme/components/dropdown/menu/dropdownmenu.css +8 -0
  271. package/theme/components/dropdown/menu/dropdownmenubutton.css +9 -0
  272. package/theme/components/dropdown/menu/dropdownmenulistitem.css +10 -0
  273. package/theme/components/dropdown/menu/dropdownmenulistitembutton.css +10 -0
  274. package/theme/components/dropdown/menu/dropdownmenupanel.css +11 -0
@@ -9,7 +9,7 @@
9
9
  /**
10
10
  * @module ui/bindings/clickoutsidehandler
11
11
  */
12
- import type { DomEmitter } from '@ckeditor/ckeditor5-utils';
12
+ import type { CallbackOptions, DomEmitter } from '@ckeditor/ckeditor5-utils';
13
13
  /**
14
14
  * Handles clicking **outside** of a specified set of elements, then fires an action.
15
15
  *
@@ -23,10 +23,12 @@ import type { DomEmitter } from '@ckeditor/ckeditor5-utils';
23
23
  * @param options.contextElements Array of HTML elements or a callback returning an array of HTML elements
24
24
  * that determine the scope of the handler. Clicking any of them or their descendants will **not** fire the callback.
25
25
  * @param options.callback An action executed by the handler.
26
+ * @param options.listenerOptions Additional options for the listener (like priority).
26
27
  */
27
- export default function clickOutsideHandler({ emitter, activator, callback, contextElements }: {
28
+ export default function clickOutsideHandler({ emitter, activator, callback, contextElements, listenerOptions }: {
28
29
  emitter: DomEmitter;
29
30
  activator: () => boolean;
30
- contextElements: Array<HTMLElement> | (() => Array<HTMLElement>);
31
+ contextElements: Array<Element> | (() => Array<Element>);
31
32
  callback: () => void;
33
+ listenerOptions?: CallbackOptions;
32
34
  }): void;
@@ -15,6 +15,7 @@ import type { default as DropdownPanelView, PanelPosition } from './dropdownpane
15
15
  import type { FocusableView } from '../focuscycler.js';
16
16
  import type ListView from '../list/listview.js';
17
17
  import type ToolbarView from '../toolbar/toolbarview.js';
18
+ import type DropdownMenuRootListView from './menu/dropdownmenurootlistview.js';
18
19
  import { KeystrokeHandler, FocusTracker, type Locale, type PositioningFunction } from '@ckeditor/ckeditor5-utils';
19
20
  import '../../theme/components/dropdown/dropdown.css';
20
21
  /**
@@ -111,9 +112,16 @@ export default class DropdownView extends View<HTMLDivElement> {
111
112
  * A child toolbar of the dropdown located in the
112
113
  * {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
113
114
  *
114
- * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addToolbarToDropdown}.
115
+ * **Note**: Only supported when dropdown has a toolbar added using {@link module:ui/dropdown/utils~addToolbarToDropdown}.
115
116
  */
116
117
  toolbarView?: ToolbarView;
118
+ /**
119
+ * A child menu component of the dropdown located
120
+ * in its {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
121
+ *
122
+ * **Note**: Only supported when dropdown has a menu added using {@link module:ui/dropdown/utils~addMenuToDropdown}.
123
+ */
124
+ menuView?: DropdownMenuRootListView;
117
125
  /**
118
126
  * Controls whether the dropdown view is open, i.e. shows or hides the {@link #panelView panel}.
119
127
  *
@@ -300,16 +308,21 @@ export default class DropdownView extends View<HTMLDivElement> {
300
308
  private static _getOptimalPosition;
301
309
  }
302
310
  /**
303
- * Fired when the toolbar button or list item is executed.
311
+ * Fired when an item inside the dropdown is executed.
312
+ *
313
+ * **Note**: Only supported when dropdown was integrated with its child view using one of the helper functions:
314
+ * {@link module:ui/dropdown/utils~addListToDropdown}, {@link module:ui/dropdown/utils~addToolbarToDropdown}, or
315
+ * {@link module:ui/dropdown/utils~addMenuToDropdown}.
316
+ *
317
+ * When integrated with a list, it fires when a child of one of {@link module:ui/list/listitemview~ListItemView}s
318
+ * fired `execute` event.
304
319
  *
305
- * For {@link ~DropdownView#listView} It fires when a child of some {@link module:ui/list/listitemview~ListItemView}
306
- * fired `execute`.
320
+ * When integrated with a toolbar, it fires when one of the buttons has been {@link module:ui/button/button~Button#event:execute executed}.
307
321
  *
308
- * For {@link ~DropdownView#toolbarView} It fires when one of the buttons has been
309
- * {@link module:ui/button/button~Button#event:execute executed}.
322
+ * When integrated with a nested menu, it fires when one of the menu buttons has been executed.
310
323
  *
311
- * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addListToDropdown}
312
- * or {@link module:ui/dropdown/utils~addToolbarToDropdown}.
324
+ * In each case, the event is delegated from the component which fired it. It does not have additional parameters and `event.source` is the
325
+ * original component.
313
326
  *
314
327
  * @eventName ~DropdownView#execute
315
328
  */
@@ -0,0 +1,48 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import type DropdownMenuNestedMenuView from './dropdownmenunestedmenuview.js';
10
+ import type DropdownMenuRootListView from './dropdownmenurootlistview.js';
11
+ export declare const DropdownRootMenuBehaviors: {
12
+ /**
13
+ * Move focus to a menu item on mouse hover. If it is a button to open a nested menu, open that menu.
14
+ */
15
+ toggleMenusAndFocusItemsOnHover(rootList: DropdownMenuRootListView): void;
16
+ /**
17
+ * Handles the following case:
18
+ *
19
+ * 1. Hover to open a sub-menu (A). The button has focus.
20
+ * 2. Press arrow up/down to move focus to another sub-menu (B) button.
21
+ * 3. Press arrow right to open the sub-menu (B).
22
+ * 4. The sub-menu (A) should close (if not, there are two open menus).
23
+ */
24
+ closeMenuWhenAnotherOnTheSameLevelOpens(rootList: DropdownMenuRootListView): void;
25
+ };
26
+ export declare const DropdownMenuBehaviors: {
27
+ /**
28
+ * Open the menu on the right arrow key press (left, in RTL mode). This allows for navigating to sub-menus using the keyboard.
29
+ */
30
+ openOnArrowRightKey(menuView: DropdownMenuNestedMenuView): void;
31
+ /**
32
+ * Opens the menu on its button click as well as enter and space keys press (if the button is focused).
33
+ */
34
+ openOnButtonClick(menuView: DropdownMenuNestedMenuView): void;
35
+ /**
36
+ * Opens the menu and focuses the panel content upon pressing the Enter key.
37
+ */
38
+ openAndFocusOnEnterKeyPress(menuView: DropdownMenuNestedMenuView): void;
39
+ /**
40
+ * Closes the menu on the left key press (right, in RTL mode). This allows for navigating to sub-menus using the keyboard.
41
+ */
42
+ closeOnArrowLeftKey(menuView: DropdownMenuNestedMenuView): void;
43
+ closeOnEscKey(menuView: DropdownMenuNestedMenuView): void;
44
+ /**
45
+ * Closes the menu when its parent menu closes. This prevents from leaving orphaned open menus.
46
+ */
47
+ closeOnParentClose(menuView: DropdownMenuNestedMenuView, parentMenuView: DropdownMenuNestedMenuView): void;
48
+ };
@@ -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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module ui/dropdown/menu/dropdownmenubuttonview
11
+ */
12
+ import IconView from '../../icon/iconview.js';
13
+ import ListItemButtonView from '../../button/listitembuttonview.js';
14
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
15
+ import '../../../theme/components/dropdown/menu/dropdownmenubutton.css';
16
+ /**
17
+ * Represents a view for a dropdown menu button.
18
+ */
19
+ export default class DropdownMenuButtonView extends ListItemButtonView {
20
+ /**
21
+ * An icon that displays an arrow to indicate a direction of the menu.
22
+ */
23
+ readonly arrowView: IconView;
24
+ /**
25
+ * Creates an instance of the dropdown menu button view.
26
+ *
27
+ * @param locale The localization services instance.
28
+ */
29
+ constructor(locale: Locale);
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ render(): void;
34
+ /**
35
+ * Creates the arrow view instance.
36
+ *
37
+ * @private
38
+ */
39
+ private _createArrowView;
40
+ }
@@ -0,0 +1,21 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module ui/dropdown/menu/dropdownmenulistitembuttonview
11
+ */
12
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
13
+ import ButtonView from '../../button/buttonview.js';
14
+ import '../../../theme/components/dropdown/menu/dropdownmenulistitembutton.css';
15
+ /**
16
+ * Represents a view for a button in a dropdown menu list item.
17
+ */
18
+ export default class DropdownMenuListItemButtonView extends ButtonView {
19
+ readonly id: string;
20
+ constructor(locale: Locale, id: string, label: string);
21
+ }
@@ -0,0 +1,26 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module ui/dropdown/menu/dropdownmenulistitemview
11
+ */
12
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
13
+ import type DropdownMenuNestedMenuView from './dropdownmenunestedmenuview.js';
14
+ import ListItemView from '../../list/listitemview.js';
15
+ import DropdownMenuListItemButtonView from './dropdownmenulistitembuttonview.js';
16
+ import '../../../theme/components/dropdown/menu/dropdownmenulistitem.css';
17
+ /**
18
+ * Represents a view for a single item in a dropdown menu list.
19
+ */
20
+ export default class DropdownMenuListItemView extends ListItemView {
21
+ /**
22
+ * The view representing either a flat item or a nested menu in a dropdown menu list item.
23
+ */
24
+ readonly childView: DropdownMenuNestedMenuView | DropdownMenuListItemButtonView;
25
+ constructor(locale: Locale, parentMenuView: DropdownMenuNestedMenuView | null, childView: DropdownMenuNestedMenuView | DropdownMenuListItemButtonView);
26
+ }
@@ -0,0 +1,28 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module ui/dropdown/menu/dropdownmenulistview
11
+ */
12
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
13
+ import ListView from '../../list/listview.js';
14
+ /**
15
+ * Represents a dropdown menu list view.
16
+ */
17
+ export default class DropdownMenuListView extends ListView {
18
+ /**
19
+ * Represents whether the dropdown menu list view is visible or not.
20
+ */
21
+ isVisible: boolean;
22
+ /**
23
+ * Creates an instance of the dropdown menu list view.
24
+ *
25
+ * @param locale The localization services instance.
26
+ */
27
+ constructor(locale: Locale);
28
+ }
@@ -0,0 +1,38 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module ui/dropdown/menu/dropdownmenunestedmenupanelview
11
+ */
12
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
13
+ import type { FocusableView } from '../../focuscycler.js';
14
+ import BalloonPanelView from '../../panel/balloon/balloonpanelview.js';
15
+ import '../../../theme/components/dropdown/menu/dropdownmenupanel.css';
16
+ /**
17
+ * Represents the view for the dropdown menu panel.
18
+ */
19
+ export default class DropdownMenuNestedMenuPanelView extends BalloonPanelView implements FocusableView {
20
+ /**
21
+ * Creates an instance of the menu panel view.
22
+ *
23
+ * @param locale The localization services instance.
24
+ */
25
+ constructor(locale?: Locale);
26
+ /**
27
+ * Focuses the first child of the panel (default) or the last one if the `direction` is `-1`.
28
+ *
29
+ * @param direction The direction to focus. Default is `1`.
30
+ */
31
+ focus(direction?: -1 | 1): void;
32
+ }
33
+ /**
34
+ * The names of the positions of the {@link module:ui/dropdown/menu/dropdownmenunestedmenupanelview~DropdownMenuNestedMenuPanelView}.
35
+ *
36
+ * They are reflected as CSS class suffixes on the panel view element.
37
+ */
38
+ export type DropdownMenuNestedMenuPanelPosition = 'es' | 'ws' | 'en' | 'wn' | 'w' | 'e';
@@ -0,0 +1,135 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module ui/dropdown/menu/dropdownmenunestedmenuview
11
+ */
12
+ import { FocusTracker, KeystrokeHandler, type PositioningFunction, type Locale } from '@ckeditor/ckeditor5-utils';
13
+ import type { FocusableView } from '../../focuscycler.js';
14
+ import type BodyCollection from '../../editorui/bodycollection.js';
15
+ import DropdownMenuButtonView from './dropdownmenubuttonview.js';
16
+ import DropdownMenuListView from './dropdownmenulistview.js';
17
+ import View from '../../view.js';
18
+ import DropdownMenuNestedMenuPanelView, { type DropdownMenuNestedMenuPanelPosition } from './dropdownmenunestedmenupanelview.js';
19
+ import '../../../theme/components/dropdown/menu/dropdownmenu.css';
20
+ /**
21
+ * Represents a nested menu view.
22
+ */
23
+ export default class DropdownMenuNestedMenuView extends View implements FocusableView {
24
+ /**
25
+ * An array of delegated events for the dropdown menu definition controller.
26
+ * These events are delegated to the dropdown menu element.
27
+ */
28
+ static readonly DELEGATED_EVENTS: readonly ["mouseenter", "execute", "change:isOpen"];
29
+ readonly id: string;
30
+ /**
31
+ * Button of the menu view.
32
+ */
33
+ readonly buttonView: DropdownMenuButtonView;
34
+ /**
35
+ * Panel of the menu. It hosts children of the menu.
36
+ */
37
+ readonly panelView: DropdownMenuNestedMenuPanelView;
38
+ /**
39
+ * List of nested menu entries.
40
+ */
41
+ readonly listView: DropdownMenuListView;
42
+ /**
43
+ * Tracks information about the DOM focus in the menu.
44
+ */
45
+ readonly focusTracker: FocusTracker;
46
+ /**
47
+ * Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}. It manages
48
+ * keystrokes of the menu.
49
+ */
50
+ readonly keystrokes: KeystrokeHandler;
51
+ /**
52
+ * Controls whether the menu is open, i.e. shows or hides the {@link #panelView panel}.
53
+ *
54
+ * @observable
55
+ */
56
+ isOpen: boolean;
57
+ /**
58
+ * Controls whether the menu is enabled, i.e. its {@link #buttonView} can be clicked.
59
+ *
60
+ * @observable
61
+ */
62
+ isEnabled: boolean;
63
+ /**
64
+ * (Optional) The additional CSS class set on the menu {@link #element}.
65
+ *
66
+ * @observable
67
+ */
68
+ class: string | undefined;
69
+ /**
70
+ * The name of the position of the {@link #panelView}, relative to the menu.
71
+ *
72
+ * **Note**: The value is updated each time the panel gets {@link #isOpen open}.
73
+ *
74
+ * @observable
75
+ * @default 'w'
76
+ */
77
+ panelPosition: DropdownMenuNestedMenuPanelPosition;
78
+ /**
79
+ * The parent menu view of the menu. It is `null` for top-level menus.
80
+ *
81
+ * @observable
82
+ * @default null
83
+ */
84
+ readonly parentMenuView: DropdownMenuNestedMenuView | null;
85
+ private _bodyCollection;
86
+ /**
87
+ * Creates a new instance of the DropdownMenuView class.
88
+ *
89
+ * @param locale
90
+ * @param bodyCollection
91
+ * @param id
92
+ * @param label The label for the dropdown menu button.
93
+ * @param parentMenuView The parent dropdown menu view, if any.
94
+ */
95
+ constructor(locale: Locale, bodyCollection: BodyCollection, id: string, label: string, parentMenuView: DropdownMenuNestedMenuView | null);
96
+ /**
97
+ * An array of positioning functions used to determine the position of the dropdown menu panel.
98
+ * The order of the functions in the array determines the priority of the positions to be tried.
99
+ * The first function that returns a valid position will be used.
100
+ *
101
+ * @returns {Array<PositioningFunction>} An array of positioning functions.
102
+ * @internal
103
+ */
104
+ get _panelPositions(): Array<PositioningFunction>;
105
+ /**
106
+ * @inheritDoc
107
+ */
108
+ render(): void;
109
+ /**
110
+ * @inheritDoc
111
+ */
112
+ destroy(): void;
113
+ /**
114
+ * @inheritDoc
115
+ */
116
+ focus(): void;
117
+ private _handleParentMenuView;
118
+ /**
119
+ * Attach all keyboard behaviors for the menu view.
120
+ */
121
+ private _attachBehaviors;
122
+ /**
123
+ * Mounts the portal view in the body when the menu is open and removes it when the menu is closed.
124
+ * Binds keystrokes to the portal view when the menu is open.
125
+ */
126
+ private _mountPanelOnOpen;
127
+ /**
128
+ * Removes the panel view from the editor's body and removes it from the focus tracker.
129
+ */
130
+ private _removePanelFromBody;
131
+ /**
132
+ * Adds the panel view to the editor's body and sets up event listeners.
133
+ */
134
+ private _addPanelToBody;
135
+ }
@@ -0,0 +1,144 @@
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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module ui/dropdown/menu/dropdownmenurootlistview
11
+ */
12
+ import DropdownMenuListItemButtonView from './dropdownmenulistitembuttonview.js';
13
+ import DropdownMenuNestedMenuView from './dropdownmenunestedmenuview.js';
14
+ import DropdownMenuListView from './dropdownmenulistview.js';
15
+ import type BodyCollection from '../../editorui/bodycollection.js';
16
+ import type { DropdownMenuDefinition } from './utils.js';
17
+ import type { Locale, BaseEvent } from '@ckeditor/ckeditor5-utils';
18
+ /**
19
+ * Creates and manages a multi-level menu UI structure, suitable to be used inside dropdown components.
20
+ *
21
+ * This class creates a menu structure based on {@link module:ui/dropdown/menu/utils~DropdownMenuDefinition declarative definition}
22
+ * passed in the constructor.
23
+ *
24
+ * Below is an example of a simple definition, that describes a menu with two sub-menus (Menu 1, Menu 2) and four buttons in total (Item A,
25
+ * Item B, Item C, Item D):
26
+ *
27
+ * ```js
28
+ * [
29
+ * {
30
+ * id: 'menu_1',
31
+ * menu: 'Menu 1',
32
+ * children: [
33
+ * { id: 'menu_1_a', label: 'Item A' },
34
+ * { id: 'menu_1_b', label: 'Item B' }
35
+ * ]
36
+ * },
37
+ * {
38
+ * id: 'menu_2',
39
+ * menu: 'Menu 2',
40
+ * children: [
41
+ * { id: 'menu_2_c', label: 'Item C' },
42
+ * ]
43
+ * },
44
+ * { id: 'item_d', label: 'Item D' }
45
+ * ]
46
+ * ```
47
+ *
48
+ * The menu is build using multiple view classes. The most important are:
49
+ *
50
+ * * {@link module:ui/dropdown/menu/dropdownmenunestedmenuview~DropdownMenuNestedMenuView `DropdownMenuNestedMenuView`} - "menu" - provides
51
+ * a panel with a nested menu, and a button which opens the panel,
52
+ * * {@link module:ui/dropdown/menu/dropdownmenulistitembuttonview~DropdownMenuListItemButtonView `DropdownMenuListItemButtonView`} -
53
+ * "button" or "leaf button" (as opposed to buttons provided by `DropdownMenuNestedMenuView`) - should trigger some action when pressed.
54
+ *
55
+ * Instances of these two classes are created based on the data provided in definitions. They are assigned proper IDs and labels.
56
+ * Other view classes build a proper DOM structure around menus and buttons.
57
+ *
58
+ * The `DropdownMenuNestedMenuView` instances provides panels, which may include further menus or buttons. These panels are added to
59
+ * a `BodyCollection` view, which means they are appended outside the DOM editor and UI structure.
60
+ *
61
+ * When "leaf button" is pressed, it fires `execute` event which is delegated to `DropdownMenuRootListView` as `menu:execute` event. You
62
+ * can listen to this event to perform an action:
63
+ *
64
+ * ```js
65
+ * rootListView.on( 'menu:execute', evt => {
66
+ * console.log( evt.source.id ); // E.g. will print 'menu_1_a' when 'Item A' is pressed.
67
+ * } );
68
+ * ```
69
+ *
70
+ * All menus and "leaf" buttons created from the definition can be easily accessed through {@link ~DropdownMenuRootListView#menus `menus`}
71
+ * and {@link ~DropdownMenuRootListView#buttons `buttons`} properties.
72
+ *
73
+ * For performance reasons, the whole menu structure is created only when `DropdownMenuRootListView` is rendered for the first time.
74
+ *
75
+ * It is recommended to use this class together with {@link module:ui/dropdown/utils~addMenuToDropdown `addMenuToDropdown()` helper}.
76
+ */
77
+ export default class DropdownMenuRootListView extends DropdownMenuListView {
78
+ /**
79
+ * The CSS class to be applied to nested menu panels in this dropdown menu.
80
+ *
81
+ * It is necessary, as the panels are created in body collection, outside editor and UI structure.
82
+ */
83
+ menuPanelClass: string | undefined;
84
+ /**
85
+ * The definitions object used to create the whole menu structure.
86
+ */
87
+ private readonly _definition;
88
+ /**
89
+ * Cached array of all menus in the dropdown menu (including nested menus).
90
+ */
91
+ private _cachedMenus;
92
+ /**
93
+ * Cached array of all buttons in the dropdown menu (including buttons in nested menus).
94
+ */
95
+ private _cachedButtons;
96
+ /**
97
+ * Editor body collection into which nested menus panels will be appended.
98
+ */
99
+ private _bodyCollection;
100
+ /**
101
+ * Creates an instance of the DropdownMenuRootListView class.
102
+ *
103
+ * @param locale
104
+ * @param bodyCollection
105
+ * @param definition The definition object used to create the menu structure.
106
+ */
107
+ constructor(locale: Locale, bodyCollection: BodyCollection, definition: DropdownMenuDefinition);
108
+ /**
109
+ * Returns the array of all menus in the dropdown menu (including nested menus).
110
+ */
111
+ get menus(): Array<DropdownMenuNestedMenuView>;
112
+ /**
113
+ * Returns the array of all buttons in the dropdown menu (including buttons in nested menus).
114
+ *
115
+ * Note, that this includes only "leaf" buttons, as specified in the definition passed in constructor. Buttons created as a part of
116
+ * the nested menus, that open nested menus when hovered or pressed, are not included.
117
+ */
118
+ get buttons(): Array<DropdownMenuListItemButtonView>;
119
+ /**
120
+ * @inheritDoc
121
+ */
122
+ render(): void;
123
+ /**
124
+ * Closes all nested menus.
125
+ */
126
+ closeMenus(): void;
127
+ /**
128
+ * Recursively creates the whole view tree structure for the dropdown menu, according to the passed `definitions`.
129
+ *
130
+ * @private
131
+ */
132
+ private _createStructure;
133
+ }
134
+ /**
135
+ * Fired when one of the menu buttons is executed (through mouse click or keyboard).
136
+ *
137
+ * This event is a delegated `execute` event fired by the pressed button. The `event.source` is the button which was executed.
138
+ *
139
+ * @eventName ~DropdownMenuRootListView#menu:execute
140
+ */
141
+ export interface DropdownMenuRootListViewExecuteEvent extends BaseEvent {
142
+ name: 'menu:execute';
143
+ args: [];
144
+ }