@ckeditor/ckeditor5-ui 47.6.1 → 48.0.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 (367) hide show
  1. package/LICENSE.md +1 -1
  2. package/ckeditor5-metadata.json +3 -3
  3. package/{src → dist}/colorselector/documentcolorcollection.d.ts +4 -4
  4. package/{src → dist}/dialog/dialog.d.ts +1 -1
  5. package/dist/index-editor.css +2728 -587
  6. package/dist/index.css +2673 -850
  7. package/dist/index.css.map +1 -1
  8. package/dist/index.js +11 -1
  9. package/dist/index.js.map +1 -1
  10. package/{src → dist}/menubar/menubarmenuview.d.ts +4 -0
  11. package/{src → dist}/view.d.ts +1 -1
  12. package/package.json +25 -47
  13. package/lang/contexts.json +0 -51
  14. package/lang/translations/af.po +0 -208
  15. package/lang/translations/ar.po +0 -208
  16. package/lang/translations/ast.po +0 -208
  17. package/lang/translations/az.po +0 -208
  18. package/lang/translations/be.po +0 -208
  19. package/lang/translations/bg.po +0 -208
  20. package/lang/translations/bn.po +0 -208
  21. package/lang/translations/bs.po +0 -208
  22. package/lang/translations/ca.po +0 -208
  23. package/lang/translations/cs.po +0 -208
  24. package/lang/translations/da.po +0 -208
  25. package/lang/translations/de-ch.po +0 -208
  26. package/lang/translations/de.po +0 -208
  27. package/lang/translations/el.po +0 -208
  28. package/lang/translations/en-au.po +0 -208
  29. package/lang/translations/en-gb.po +0 -208
  30. package/lang/translations/en.po +0 -208
  31. package/lang/translations/eo.po +0 -208
  32. package/lang/translations/es-co.po +0 -208
  33. package/lang/translations/es.po +0 -208
  34. package/lang/translations/et.po +0 -208
  35. package/lang/translations/eu.po +0 -208
  36. package/lang/translations/fa.po +0 -208
  37. package/lang/translations/fi.po +0 -208
  38. package/lang/translations/fr.po +0 -208
  39. package/lang/translations/gl.po +0 -208
  40. package/lang/translations/gu.po +0 -208
  41. package/lang/translations/he.po +0 -208
  42. package/lang/translations/hi.po +0 -208
  43. package/lang/translations/hr.po +0 -208
  44. package/lang/translations/hu.po +0 -208
  45. package/lang/translations/hy.po +0 -208
  46. package/lang/translations/id.po +0 -208
  47. package/lang/translations/it.po +0 -208
  48. package/lang/translations/ja.po +0 -208
  49. package/lang/translations/jv.po +0 -208
  50. package/lang/translations/kk.po +0 -208
  51. package/lang/translations/km.po +0 -208
  52. package/lang/translations/kn.po +0 -208
  53. package/lang/translations/ko.po +0 -208
  54. package/lang/translations/ku.po +0 -208
  55. package/lang/translations/lt.po +0 -208
  56. package/lang/translations/lv.po +0 -208
  57. package/lang/translations/ms.po +0 -208
  58. package/lang/translations/nb.po +0 -208
  59. package/lang/translations/ne.po +0 -208
  60. package/lang/translations/nl.po +0 -208
  61. package/lang/translations/no.po +0 -208
  62. package/lang/translations/oc.po +0 -208
  63. package/lang/translations/pl.po +0 -208
  64. package/lang/translations/pt-br.po +0 -208
  65. package/lang/translations/pt.po +0 -208
  66. package/lang/translations/ro.po +0 -208
  67. package/lang/translations/ru.po +0 -208
  68. package/lang/translations/si.po +0 -208
  69. package/lang/translations/sk.po +0 -208
  70. package/lang/translations/sl.po +0 -208
  71. package/lang/translations/sq.po +0 -208
  72. package/lang/translations/sr-latn.po +0 -208
  73. package/lang/translations/sr.po +0 -208
  74. package/lang/translations/sv.po +0 -208
  75. package/lang/translations/th.po +0 -208
  76. package/lang/translations/ti.po +0 -208
  77. package/lang/translations/tk.po +0 -208
  78. package/lang/translations/tr.po +0 -208
  79. package/lang/translations/tt.po +0 -208
  80. package/lang/translations/ug.po +0 -208
  81. package/lang/translations/uk.po +0 -208
  82. package/lang/translations/ur.po +0 -208
  83. package/lang/translations/uz.po +0 -208
  84. package/lang/translations/vi.po +0 -208
  85. package/lang/translations/zh-cn.po +0 -208
  86. package/lang/translations/zh.po +0 -208
  87. package/src/arialiveannouncer.js +0 -189
  88. package/src/augmentation.js +0 -5
  89. package/src/autocomplete/autocompleteview.js +0 -157
  90. package/src/badge/badge.js +0 -226
  91. package/src/bindings/addkeyboardhandlingforgrid.js +0 -107
  92. package/src/bindings/clickoutsidehandler.js +0 -36
  93. package/src/bindings/csstransitiondisablermixin.js +0 -58
  94. package/src/bindings/draggableviewmixin.js +0 -144
  95. package/src/bindings/preventdefault.js +0 -35
  96. package/src/bindings/submithandler.js +0 -47
  97. package/src/button/button.js +0 -5
  98. package/src/button/buttonlabel.js +0 -5
  99. package/src/button/buttonlabelview.js +0 -42
  100. package/src/button/buttonview.js +0 -278
  101. package/src/button/filedialogbuttonview.js +0 -147
  102. package/src/button/listitembuttonview.js +0 -136
  103. package/src/button/switchbuttonview.js +0 -79
  104. package/src/collapsible/collapsibleview.js +0 -106
  105. package/src/colorgrid/colorgridview.js +0 -140
  106. package/src/colorgrid/colortileview.js +0 -42
  107. package/src/colorgrid/utils.js +0 -84
  108. package/src/colorpicker/colorpickerview.js +0 -356
  109. package/src/colorpicker/utils.js +0 -108
  110. package/src/colorselector/colorgridsfragmentview.js +0 -368
  111. package/src/colorselector/colorpickerfragmentview.js +0 -254
  112. package/src/colorselector/colorselectorview.js +0 -294
  113. package/src/colorselector/documentcolorcollection.js +0 -42
  114. package/src/componentfactory.js +0 -108
  115. package/src/dialog/dialog.js +0 -325
  116. package/src/dialog/dialogactionsview.js +0 -118
  117. package/src/dialog/dialogcontentview.js +0 -39
  118. package/src/dialog/dialogview.js +0 -507
  119. package/src/dropdown/button/dropdownbutton.js +0 -5
  120. package/src/dropdown/button/dropdownbuttonview.js +0 -70
  121. package/src/dropdown/button/splitbuttonview.js +0 -178
  122. package/src/dropdown/dropdownpanelfocusable.js +0 -5
  123. package/src/dropdown/dropdownpanelview.js +0 -106
  124. package/src/dropdown/dropdownview.js +0 -438
  125. package/src/dropdown/menu/dropdownmenubehaviors.js +0 -125
  126. package/src/dropdown/menu/dropdownmenubuttonview.js +0 -69
  127. package/src/dropdown/menu/dropdownmenulistitembuttonview.js +0 -30
  128. package/src/dropdown/menu/dropdownmenulistitemview.js +0 -38
  129. package/src/dropdown/menu/dropdownmenulistview.js +0 -29
  130. package/src/dropdown/menu/dropdownmenunestedmenupanelview.js +0 -63
  131. package/src/dropdown/menu/dropdownmenunestedmenuview.js +0 -214
  132. package/src/dropdown/menu/dropdownmenurootlistview.js +0 -168
  133. package/src/dropdown/menu/utils.js +0 -61
  134. package/src/dropdown/utils.js +0 -654
  135. package/src/editableui/editableuiview.js +0 -130
  136. package/src/editableui/inline/inlineeditableuiview.js +0 -75
  137. package/src/editorui/accessibilityhelp/accessibilityhelp.js +0 -142
  138. package/src/editorui/accessibilityhelp/accessibilityhelpcontentview.js +0 -112
  139. package/src/editorui/bodycollection.js +0 -128
  140. package/src/editorui/boxed/boxededitoruiview.js +0 -95
  141. package/src/editorui/editorui.js +0 -586
  142. package/src/editorui/editoruiview.js +0 -60
  143. package/src/editorui/evaluationbadge.js +0 -99
  144. package/src/editorui/poweredby.js +0 -120
  145. package/src/focuscycler.js +0 -383
  146. package/src/formheader/formheaderview.js +0 -77
  147. package/src/formrow/formrowview.js +0 -56
  148. package/src/highlightedtext/buttonlabelwithhighlightview.js +0 -31
  149. package/src/highlightedtext/highlightedtextview.js +0 -102
  150. package/src/highlightedtext/labelwithhighlightview.js +0 -37
  151. package/src/icon/iconview.js +0 -123
  152. package/src/iframe/iframeview.js +0 -63
  153. package/src/index.js +0 -132
  154. package/src/input/inputbase.js +0 -119
  155. package/src/input/inputview.js +0 -24
  156. package/src/inputnumber/inputnumberview.js +0 -40
  157. package/src/inputtext/inputtextview.js +0 -27
  158. package/src/label/labelview.js +0 -46
  159. package/src/labeledfield/labeledfieldview.js +0 -177
  160. package/src/labeledfield/utils.js +0 -176
  161. package/src/labeledinput/labeledinputview.js +0 -138
  162. package/src/legacyerrors.js +0 -20
  163. package/src/list/listitemgroupview.js +0 -82
  164. package/src/list/listitemview.js +0 -46
  165. package/src/list/listseparatorview.js +0 -28
  166. package/src/list/listview.js +0 -210
  167. package/src/menubar/menubarmenubuttonview.js +0 -68
  168. package/src/menubar/menubarmenulistitembuttonview.js +0 -30
  169. package/src/menubar/menubarmenulistitemfiledialogbuttonview.js +0 -32
  170. package/src/menubar/menubarmenulistitemview.js +0 -34
  171. package/src/menubar/menubarmenulistview.js +0 -72
  172. package/src/menubar/menubarmenupanelview.js +0 -64
  173. package/src/menubar/menubarmenuview.js +0 -198
  174. package/src/menubar/menubarview.js +0 -281
  175. package/src/menubar/utils.js +0 -1432
  176. package/src/model.js +0 -31
  177. package/src/notification/notification.js +0 -192
  178. package/src/panel/balloon/balloonpanelview.js +0 -1077
  179. package/src/panel/balloon/contextualballoon.js +0 -616
  180. package/src/panel/sticky/stickypanelview.js +0 -246
  181. package/src/search/filteredview.js +0 -5
  182. package/src/search/filtergroupanditemnames.js +0 -38
  183. package/src/search/searchinfoview.js +0 -59
  184. package/src/search/searchresultsview.js +0 -83
  185. package/src/search/text/searchtextqueryview.js +0 -87
  186. package/src/search/text/searchtextview.js +0 -242
  187. package/src/spinner/spinnerview.js +0 -38
  188. package/src/template.js +0 -1396
  189. package/src/textarea/textareaview.js +0 -189
  190. package/src/toolbar/balloon/balloontoolbar.js +0 -358
  191. package/src/toolbar/block/blockbuttonview.js +0 -41
  192. package/src/toolbar/block/blocktoolbar.js +0 -507
  193. package/src/toolbar/normalizetoolbarconfig.js +0 -52
  194. package/src/toolbar/toolbarlinebreakview.js +0 -28
  195. package/src/toolbar/toolbarseparatorview.js +0 -28
  196. package/src/toolbar/toolbarview.js +0 -873
  197. package/src/tooltipmanager.js +0 -454
  198. package/src/view.js +0 -471
  199. package/src/viewcollection.js +0 -210
  200. package/theme/components/arialiveannouncer/arialiveannouncer.css +0 -14
  201. package/theme/components/autocomplete/autocomplete.css +0 -22
  202. package/theme/components/button/button.css +0 -39
  203. package/theme/components/button/listitembutton.css +0 -48
  204. package/theme/components/button/switchbutton.css +0 -14
  205. package/theme/components/collapsible/collapsible.css +0 -10
  206. package/theme/components/colorgrid/colorgrid.css +0 -8
  207. package/theme/components/colorpicker/colorpicker.css +0 -34
  208. package/theme/components/colorselector/colorselector.css +0 -35
  209. package/theme/components/dialog/dialog.css +0 -42
  210. package/theme/components/dialog/dialogactions.css +0 -11
  211. package/theme/components/dropdown/dropdown.css +0 -95
  212. package/theme/components/dropdown/listdropdown.css +0 -10
  213. package/theme/components/dropdown/menu/dropdownmenu.css +0 -8
  214. package/theme/components/dropdown/menu/dropdownmenubutton.css +0 -9
  215. package/theme/components/dropdown/menu/dropdownmenulistitem.css +0 -10
  216. package/theme/components/dropdown/menu/dropdownmenulistitembutton.css +0 -10
  217. package/theme/components/dropdown/menu/dropdownmenupanel.css +0 -11
  218. package/theme/components/dropdown/splitbutton.css +0 -14
  219. package/theme/components/dropdown/toolbardropdown.css +0 -20
  220. package/theme/components/editorui/accessibilityhelp.css +0 -10
  221. package/theme/components/editorui/editorui.css +0 -10
  222. package/theme/components/form/form.css +0 -87
  223. package/theme/components/formheader/formheader.css +0 -18
  224. package/theme/components/formrow/formrow.css +0 -32
  225. package/theme/components/highlightedtext/highlightedtext.css +0 -12
  226. package/theme/components/icon/icon.css +0 -8
  227. package/theme/components/input/input.css +0 -10
  228. package/theme/components/label/label.css +0 -12
  229. package/theme/components/labeledfield/labeledfieldview.css +0 -16
  230. package/theme/components/labeledinput/labeledinput.css +0 -10
  231. package/theme/components/list/list.css +0 -26
  232. package/theme/components/menubar/menubar.css +0 -10
  233. package/theme/components/menubar/menubarmenu.css +0 -9
  234. package/theme/components/menubar/menubarmenubutton.css +0 -11
  235. package/theme/components/menubar/menubarmenulistitem.css +0 -10
  236. package/theme/components/menubar/menubarmenulistitembutton.css +0 -10
  237. package/theme/components/menubar/menubarmenupanel.css +0 -62
  238. package/theme/components/panel/balloonpanel.css +0 -56
  239. package/theme/components/panel/balloonrotator.css +0 -17
  240. package/theme/components/panel/fakepanel.css +0 -23
  241. package/theme/components/panel/stickypanel.css +0 -17
  242. package/theme/components/responsive-form/responsiveform.css +0 -42
  243. package/theme/components/search/search.css +0 -43
  244. package/theme/components/spinner/spinner.css +0 -23
  245. package/theme/components/textarea/textarea.css +0 -10
  246. package/theme/components/toolbar/blocktoolbar.css +0 -9
  247. package/theme/components/toolbar/toolbar.css +0 -58
  248. package/theme/components/tooltip/tooltip.css +0 -12
  249. package/theme/globals/_evaluationbadge.css +0 -54
  250. package/theme/globals/_hidden.css +0 -13
  251. package/theme/globals/_poweredby.css +0 -84
  252. package/theme/globals/_transition.css +0 -12
  253. package/theme/globals/_zindex.css +0 -10
  254. package/theme/globals/globals.css +0 -10
  255. package/theme/mixins/_dir.css +0 -10
  256. package/theme/mixins/_mediacolors.css +0 -20
  257. package/theme/mixins/_rwd.css +0 -10
  258. package/theme/mixins/_unselectable.css +0 -14
  259. /package/{src → dist}/arialiveannouncer.d.ts +0 -0
  260. /package/{src → dist}/augmentation.d.ts +0 -0
  261. /package/{src → dist}/autocomplete/autocompleteview.d.ts +0 -0
  262. /package/{src → dist}/badge/badge.d.ts +0 -0
  263. /package/{src → dist}/bindings/addkeyboardhandlingforgrid.d.ts +0 -0
  264. /package/{src → dist}/bindings/clickoutsidehandler.d.ts +0 -0
  265. /package/{src → dist}/bindings/csstransitiondisablermixin.d.ts +0 -0
  266. /package/{src → dist}/bindings/draggableviewmixin.d.ts +0 -0
  267. /package/{src → dist}/bindings/preventdefault.d.ts +0 -0
  268. /package/{src → dist}/bindings/submithandler.d.ts +0 -0
  269. /package/{src → dist}/button/button.d.ts +0 -0
  270. /package/{src → dist}/button/buttonlabel.d.ts +0 -0
  271. /package/{src → dist}/button/buttonlabelview.d.ts +0 -0
  272. /package/{src → dist}/button/buttonview.d.ts +0 -0
  273. /package/{src → dist}/button/filedialogbuttonview.d.ts +0 -0
  274. /package/{src → dist}/button/listitembuttonview.d.ts +0 -0
  275. /package/{src → dist}/button/switchbuttonview.d.ts +0 -0
  276. /package/{src → dist}/collapsible/collapsibleview.d.ts +0 -0
  277. /package/{src → dist}/colorgrid/colorgridview.d.ts +0 -0
  278. /package/{src → dist}/colorgrid/colortileview.d.ts +0 -0
  279. /package/{src → dist}/colorgrid/utils.d.ts +0 -0
  280. /package/{src → dist}/colorpicker/colorpickerview.d.ts +0 -0
  281. /package/{src → dist}/colorpicker/utils.d.ts +0 -0
  282. /package/{src → dist}/colorselector/colorgridsfragmentview.d.ts +0 -0
  283. /package/{src → dist}/colorselector/colorpickerfragmentview.d.ts +0 -0
  284. /package/{src → dist}/colorselector/colorselectorview.d.ts +0 -0
  285. /package/{src → dist}/componentfactory.d.ts +0 -0
  286. /package/{src → dist}/dialog/dialogactionsview.d.ts +0 -0
  287. /package/{src → dist}/dialog/dialogcontentview.d.ts +0 -0
  288. /package/{src → dist}/dialog/dialogview.d.ts +0 -0
  289. /package/{src → dist}/dropdown/button/dropdownbutton.d.ts +0 -0
  290. /package/{src → dist}/dropdown/button/dropdownbuttonview.d.ts +0 -0
  291. /package/{src → dist}/dropdown/button/splitbuttonview.d.ts +0 -0
  292. /package/{src → dist}/dropdown/dropdownpanelfocusable.d.ts +0 -0
  293. /package/{src → dist}/dropdown/dropdownpanelview.d.ts +0 -0
  294. /package/{src → dist}/dropdown/dropdownview.d.ts +0 -0
  295. /package/{src → dist}/dropdown/menu/dropdownmenubehaviors.d.ts +0 -0
  296. /package/{src → dist}/dropdown/menu/dropdownmenubuttonview.d.ts +0 -0
  297. /package/{src → dist}/dropdown/menu/dropdownmenulistitembuttonview.d.ts +0 -0
  298. /package/{src → dist}/dropdown/menu/dropdownmenulistitemview.d.ts +0 -0
  299. /package/{src → dist}/dropdown/menu/dropdownmenulistview.d.ts +0 -0
  300. /package/{src → dist}/dropdown/menu/dropdownmenunestedmenupanelview.d.ts +0 -0
  301. /package/{src → dist}/dropdown/menu/dropdownmenunestedmenuview.d.ts +0 -0
  302. /package/{src → dist}/dropdown/menu/dropdownmenurootlistview.d.ts +0 -0
  303. /package/{src → dist}/dropdown/menu/utils.d.ts +0 -0
  304. /package/{src → dist}/dropdown/utils.d.ts +0 -0
  305. /package/{src → dist}/editableui/editableuiview.d.ts +0 -0
  306. /package/{src → dist}/editableui/inline/inlineeditableuiview.d.ts +0 -0
  307. /package/{src → dist}/editorui/accessibilityhelp/accessibilityhelp.d.ts +0 -0
  308. /package/{src → dist}/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +0 -0
  309. /package/{src → dist}/editorui/bodycollection.d.ts +0 -0
  310. /package/{src → dist}/editorui/boxed/boxededitoruiview.d.ts +0 -0
  311. /package/{src → dist}/editorui/editorui.d.ts +0 -0
  312. /package/{src → dist}/editorui/editoruiview.d.ts +0 -0
  313. /package/{src → dist}/editorui/evaluationbadge.d.ts +0 -0
  314. /package/{src → dist}/editorui/poweredby.d.ts +0 -0
  315. /package/{src → dist}/focuscycler.d.ts +0 -0
  316. /package/{src → dist}/formheader/formheaderview.d.ts +0 -0
  317. /package/{src → dist}/formrow/formrowview.d.ts +0 -0
  318. /package/{src → dist}/highlightedtext/buttonlabelwithhighlightview.d.ts +0 -0
  319. /package/{src → dist}/highlightedtext/highlightedtextview.d.ts +0 -0
  320. /package/{src → dist}/highlightedtext/labelwithhighlightview.d.ts +0 -0
  321. /package/{src → dist}/icon/iconview.d.ts +0 -0
  322. /package/{src → dist}/iframe/iframeview.d.ts +0 -0
  323. /package/{src → dist}/index.d.ts +0 -0
  324. /package/{src → dist}/input/inputbase.d.ts +0 -0
  325. /package/{src → dist}/input/inputview.d.ts +0 -0
  326. /package/{src → dist}/inputnumber/inputnumberview.d.ts +0 -0
  327. /package/{src → dist}/inputtext/inputtextview.d.ts +0 -0
  328. /package/{src → dist}/label/labelview.d.ts +0 -0
  329. /package/{src → dist}/labeledfield/labeledfieldview.d.ts +0 -0
  330. /package/{src → dist}/labeledfield/utils.d.ts +0 -0
  331. /package/{src → dist}/labeledinput/labeledinputview.d.ts +0 -0
  332. /package/{src → dist}/legacyerrors.d.ts +0 -0
  333. /package/{src → dist}/list/listitemgroupview.d.ts +0 -0
  334. /package/{src → dist}/list/listitemview.d.ts +0 -0
  335. /package/{src → dist}/list/listseparatorview.d.ts +0 -0
  336. /package/{src → dist}/list/listview.d.ts +0 -0
  337. /package/{src → dist}/menubar/menubarmenubuttonview.d.ts +0 -0
  338. /package/{src → dist}/menubar/menubarmenulistitembuttonview.d.ts +0 -0
  339. /package/{src → dist}/menubar/menubarmenulistitemfiledialogbuttonview.d.ts +0 -0
  340. /package/{src → dist}/menubar/menubarmenulistitemview.d.ts +0 -0
  341. /package/{src → dist}/menubar/menubarmenulistview.d.ts +0 -0
  342. /package/{src → dist}/menubar/menubarmenupanelview.d.ts +0 -0
  343. /package/{src → dist}/menubar/menubarview.d.ts +0 -0
  344. /package/{src → dist}/menubar/utils.d.ts +0 -0
  345. /package/{src → dist}/model.d.ts +0 -0
  346. /package/{src → dist}/notification/notification.d.ts +0 -0
  347. /package/{src → dist}/panel/balloon/balloonpanelview.d.ts +0 -0
  348. /package/{src → dist}/panel/balloon/contextualballoon.d.ts +0 -0
  349. /package/{src → dist}/panel/sticky/stickypanelview.d.ts +0 -0
  350. /package/{src → dist}/search/filteredview.d.ts +0 -0
  351. /package/{src → dist}/search/filtergroupanditemnames.d.ts +0 -0
  352. /package/{src → dist}/search/searchinfoview.d.ts +0 -0
  353. /package/{src → dist}/search/searchresultsview.d.ts +0 -0
  354. /package/{src → dist}/search/text/searchtextqueryview.d.ts +0 -0
  355. /package/{src → dist}/search/text/searchtextview.d.ts +0 -0
  356. /package/{src → dist}/spinner/spinnerview.d.ts +0 -0
  357. /package/{src → dist}/template.d.ts +0 -0
  358. /package/{src → dist}/textarea/textareaview.d.ts +0 -0
  359. /package/{src → dist}/toolbar/balloon/balloontoolbar.d.ts +0 -0
  360. /package/{src → dist}/toolbar/block/blockbuttonview.d.ts +0 -0
  361. /package/{src → dist}/toolbar/block/blocktoolbar.d.ts +0 -0
  362. /package/{src → dist}/toolbar/normalizetoolbarconfig.d.ts +0 -0
  363. /package/{src → dist}/toolbar/toolbarlinebreakview.d.ts +0 -0
  364. /package/{src → dist}/toolbar/toolbarseparatorview.d.ts +0 -0
  365. /package/{src → dist}/toolbar/toolbarview.d.ts +0 -0
  366. /package/{src → dist}/tooltipmanager.d.ts +0 -0
  367. /package/{src → dist}/viewcollection.d.ts +0 -0
@@ -1,1432 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module ui/menubar/utils
7
- */
8
- import { MenuBarMenuListItemView } from './menubarmenulistitemview.js';
9
- import { clickOutsideHandler } from '../bindings/clickoutsidehandler.js';
10
- import { logWarning } from '@ckeditor/ckeditor5-utils';
11
- import { cloneDeep } from 'es-toolkit/compat';
12
- const NESTED_PANEL_HORIZONTAL_OFFSET = 5;
13
- /**
14
- * Behaviors of the {@link module:ui/menubar/menubarview~MenuBarView} component.
15
- * @internal
16
- */
17
- export const MenuBarBehaviors = {
18
- /**
19
- * When the bar is already open:
20
- * * Opens the menu when the user hovers over its button.
21
- * * Closes open menu when another menu's button gets hovered.
22
- */
23
- toggleMenusAndFocusItemsOnHover(menuBarView) {
24
- menuBarView.on('menu:mouseenter', evt => {
25
- // This behavior should be activated when one of condition is present:
26
- // 1. The user opened any submenu of menubar and hover over items in the menu bar.
27
- // 2. The user focused whole menubar using keyboard interaction and enabled focus borders and hover over items in the menu bar.
28
- if (!menuBarView.isFocusBorderEnabled && !menuBarView.isOpen) {
29
- return;
30
- }
31
- if (menuBarView.isOpen) {
32
- for (const menuView of menuBarView.menus) {
33
- // @if CK_DEBUG_MENU_BAR // const wasOpen = menuView.isOpen;
34
- const pathLeaf = evt.path[0];
35
- const isListItemContainingMenu = pathLeaf instanceof MenuBarMenuListItemView && pathLeaf.children.first === menuView;
36
- menuView.isOpen = (evt.path.includes(menuView) || isListItemContainingMenu) && menuView.isEnabled;
37
- // @if CK_DEBUG_MENU_BAR // if ( wasOpen !== menuView.isOpen ) {
38
- // @if CK_DEBUG_MENU_BAR // console.log( '[BEHAVIOR] toggleMenusAndFocusItemsOnHover(): Toggle',
39
- // @if CK_DEBUG_MENU_BAR // logMenu( menuView ), 'isOpen', menuView.isOpen
40
- // @if CK_DEBUG_MENU_BAR // );
41
- // @if CK_DEBUG_MENU_BAR // }
42
- }
43
- }
44
- evt.source.focus();
45
- });
46
- },
47
- /**
48
- * Moves between top-level menus using the arrow left and right keys.
49
- *
50
- * If the menubar has already been open, the arrow keys move focus between top-level menu buttons and open them.
51
- * If the menubar is closed, the arrow keys only move focus between top-level menu buttons.
52
- */
53
- focusCycleMenusOnArrows(menuBarView) {
54
- const isContentRTL = menuBarView.locale.uiLanguageDirection === 'rtl';
55
- menuBarView.on('menu:arrowright', evt => {
56
- cycleTopLevelMenus(evt.source, isContentRTL ? -1 : 1);
57
- });
58
- menuBarView.on('menu:arrowleft', evt => {
59
- cycleTopLevelMenus(evt.source, isContentRTL ? 1 : -1);
60
- });
61
- function cycleTopLevelMenus(currentMenuView, step) {
62
- const currentIndex = menuBarView.children.getIndex(currentMenuView);
63
- const isCurrentMenuViewOpen = currentMenuView.isOpen;
64
- const menusCount = menuBarView.children.length;
65
- const menuViewToOpen = menuBarView.children.get((currentIndex + menusCount + step) % menusCount);
66
- currentMenuView.isOpen = false;
67
- if (isCurrentMenuViewOpen) {
68
- menuViewToOpen.isOpen = true;
69
- }
70
- menuViewToOpen.buttonView.focus();
71
- }
72
- },
73
- /**
74
- * Closes the entire sub-menu structure when the bar is closed. This prevents sub-menus from being open if the user
75
- * closes the entire bar, and then re-opens some top-level menu.
76
- */
77
- closeMenusWhenTheBarCloses(menuBarView) {
78
- menuBarView.on('change:isOpen', () => {
79
- if (!menuBarView.isOpen) {
80
- menuBarView.menus.forEach(menuView => {
81
- menuView.isOpen = false;
82
- // @if CK_DEBUG_MENU_BAR // console.log( '[BEHAVIOR] closeMenusWhenTheBarCloses(): Closing', logMenu( menuView ) );
83
- });
84
- }
85
- });
86
- },
87
- /**
88
- * Handles the following case:
89
- * 1. Hover to open a sub-menu (A). The button has focus.
90
- * 2. Press arrow up/down to move focus to another sub-menu (B) button.
91
- * 3. Press arrow right to open the sub-menu (B).
92
- * 4. The sub-menu (A) should close as it would with `toggleMenusAndFocusItemsOnHover()`.
93
- */
94
- closeMenuWhenAnotherOnTheSameLevelOpens(menuBarView) {
95
- menuBarView.on('menu:change:isOpen', (evt, name, isOpen) => {
96
- if (isOpen) {
97
- menuBarView.menus
98
- .filter(menuView => {
99
- return evt.source.parentMenuView === menuView.parentMenuView &&
100
- evt.source !== menuView &&
101
- menuView.isOpen;
102
- }).forEach(menuView => {
103
- menuView.isOpen = false;
104
- // @if CK_DEBUG_MENU_BAR // console.log( '[BEHAVIOR] closeMenuWhenAnotherOpens(): Closing', logMenu( menuView ) );
105
- });
106
- }
107
- });
108
- },
109
- /**
110
- * Closes the bar when the user clicked outside of it (page body, editor root, etc.).
111
- */
112
- closeOnClickOutside(menuBarView) {
113
- clickOutsideHandler({
114
- emitter: menuBarView,
115
- activator: () => menuBarView.isOpen,
116
- callback: () => menuBarView.close(),
117
- contextElements: () => menuBarView.children.map(child => child.element)
118
- });
119
- },
120
- /**
121
- * Tracks the keyboard focus interaction on the menu bar view. It is used to determine if the nested items
122
- * of the menu bar should render focus rings after first interaction with the keyboard.
123
- */
124
- enableFocusHighlightOnInteraction(menuBarView) {
125
- let isKeyPressed = false;
126
- menuBarView.on('change:isOpen', (_, evt, isOpen) => {
127
- if (!isOpen) {
128
- // Keep the focus border if the menu bar was closed by a keyboard interaction (Esc key).
129
- // The user remains in the keyboard navigation mode and can traverse the main categories.
130
- // See https://github.com/ckeditor/ckeditor5/issues/16719.
131
- if (!isKeyPressed) {
132
- menuBarView.isFocusBorderEnabled = false;
133
- }
134
- // Reset the flag when the menu bar is closed, menu items tend to intercept `keyup` event
135
- // and sometimes, after pressing `enter` on focused item, `isKeyPressed` stuck in `true` state.
136
- isKeyPressed = false;
137
- }
138
- });
139
- menuBarView.listenTo(menuBarView.element, 'keydown', () => {
140
- isKeyPressed = true;
141
- }, { useCapture: true });
142
- menuBarView.listenTo(menuBarView.element, 'keyup', () => {
143
- isKeyPressed = false;
144
- }, { useCapture: true });
145
- menuBarView.listenTo(menuBarView.element, 'focus', () => {
146
- if (isKeyPressed) {
147
- menuBarView.isFocusBorderEnabled = true;
148
- }
149
- }, { useCapture: true });
150
- }
151
- };
152
- /**
153
- * Behaviors of the {@link module:ui/menubar/menubarmenuview~MenuBarMenuView} component.
154
- * @internal
155
- */
156
- export const MenuBarMenuBehaviors = {
157
- /**
158
- * If the button of the menu is focused, pressing the arrow down key should open the panel and focus it.
159
- * This is analogous to the {@link module:ui/dropdown/dropdownview~DropdownView}.
160
- */
161
- openAndFocusPanelOnArrowDownKey(menuView) {
162
- menuView.keystrokes.set('arrowdown', (data, cancel) => {
163
- if (menuView.isEnabled && menuView.focusTracker.focusedElement === menuView.buttonView.element) {
164
- if (!menuView.isOpen) {
165
- menuView.isOpen = true;
166
- }
167
- menuView.panelView.focus();
168
- cancel();
169
- }
170
- });
171
- },
172
- /**
173
- * Open the menu on the right arrow key press. This allows for navigating to sub-menus using the keyboard.
174
- */
175
- openOnArrowRightKey(menuView) {
176
- const keystroke = menuView.locale.uiLanguageDirection === 'rtl' ? 'arrowleft' : 'arrowright';
177
- menuView.keystrokes.set(keystroke, (data, cancel) => {
178
- if (menuView.focusTracker.focusedElement !== menuView.buttonView.element || !menuView.isEnabled) {
179
- return;
180
- }
181
- // @if CK_DEBUG_MENU_BAR // console.log( '[BEHAVIOR] openOnArrowRightKey(): Opening', logMenu( menuView ) );
182
- if (!menuView.isOpen) {
183
- menuView.isOpen = true;
184
- }
185
- menuView.panelView.focus();
186
- cancel();
187
- });
188
- },
189
- /**
190
- * Opens the menu on its button click. Note that this behavior only opens but never closes the menu (unlike
191
- * {@link module:ui/dropdown/dropdownview~DropdownView}).
192
- */
193
- openOnButtonClick(menuView) {
194
- menuView.buttonView.on('execute', () => {
195
- menuView.isOpen = true;
196
- });
197
- },
198
- /**
199
- * Toggles the menu on its button click. This behavior is analogous to {@link module:ui/dropdown/dropdownview~DropdownView}.
200
- */
201
- toggleOnButtonClick(menuView) {
202
- menuView.buttonView.on('execute', () => {
203
- menuView.isOpen = !menuView.isOpen;
204
- });
205
- },
206
- /**
207
- * Opens the menu and focuses the panel content upon pressing the Enter key.
208
- */
209
- openAndFocusOnEnterKeyPress(menuView) {
210
- menuView.keystrokes.set('enter', (data, cancel) => {
211
- // Engage only for Enter key press when the button is focused. The panel can contain
212
- // other UI components and features that rely on the Enter key press.
213
- if (menuView.focusTracker.focusedElement !== menuView.buttonView.element) {
214
- return;
215
- }
216
- menuView.isOpen = true;
217
- menuView.panelView.focus();
218
- cancel();
219
- });
220
- },
221
- /**
222
- * Closes the menu on the right left key press. This allows for navigating to sub-menus using the keyboard.
223
- */
224
- closeOnArrowLeftKey(menuView) {
225
- const keystroke = menuView.locale.uiLanguageDirection === 'rtl' ? 'arrowright' : 'arrowleft';
226
- menuView.keystrokes.set(keystroke, (data, cancel) => {
227
- if (menuView.isOpen) {
228
- menuView.isOpen = false;
229
- menuView.focus();
230
- cancel();
231
- }
232
- });
233
- },
234
- /**
235
- * Closes the menu on the esc key press. This allows for navigating to sub-menus using the keyboard.
236
- */
237
- closeOnEscKey(menuView) {
238
- menuView.keystrokes.set('esc', (data, cancel) => {
239
- if (menuView.isOpen) {
240
- menuView.isOpen = false;
241
- menuView.focus();
242
- cancel();
243
- }
244
- });
245
- },
246
- /**
247
- * Closes the menu when its parent menu also closed. This prevents from orphaned open menus when the parent menu re-opens.
248
- */
249
- closeOnParentClose(menuView) {
250
- menuView.parentMenuView.on('change:isOpen', (evt, name, isOpen) => {
251
- if (!isOpen && evt.source === menuView.parentMenuView) {
252
- // @if CK_DEBUG_MENU_BAR // console.log( '[BEHAVIOR] closeOnParentClose(): Closing', logMenu( menuView ) );
253
- menuView.isOpen = false;
254
- }
255
- });
256
- }
257
- };
258
- // @if CK_DEBUG_MENU_BAR // function logMenu( menuView: MenuBarMenuView ) {
259
- // @if CK_DEBUG_MENU_BAR // return `"${ menuView.buttonView.label }"`;
260
- // @if CK_DEBUG_MENU_BAR // }
261
- /**
262
- * Contains every positioning function used by {@link module:ui/menubar/menubarmenuview~MenuBarMenuView} that decides where the
263
- * {@link module:ui/menubar/menubarmenuview~MenuBarMenuView#panelView} should be placed.
264
- *
265
- * Top-level menu positioning functions:
266
- *
267
- * ┌──────┐
268
- * │ │
269
- * ├──────┴────────┐
270
- * │ │
271
- * │ │
272
- * │ │
273
- * │ SE │
274
- * └───────────────┘
275
- *
276
- * ┌──────┐
277
- * │ │
278
- * ┌────────┴──────┤
279
- * │ │
280
- * │ │
281
- * │ │
282
- * │ SW │
283
- * └───────────────┘
284
- *
285
- * ┌───────────────┐
286
- * │ NW │
287
- * │ │
288
- * │ │
289
- * │ │
290
- * └────────┬──────┤
291
- * │ │
292
- * └──────┘
293
- *
294
- * ┌───────────────┐
295
- * │ NE │
296
- * │ │
297
- * │ │
298
- * │ │
299
- * ├──────┬────────┘
300
- * │ │
301
- * └──────┘
302
- *
303
- * Sub-menu positioning functions:
304
- *
305
- * ┌──────┬───────────────┐
306
- * │ │ │
307
- * └──────┤ │
308
- * │ │
309
- * │ ES │
310
- * └───────────────┘
311
- *
312
- * ┌───────────────┬──────┐
313
- * │ │ │
314
- * │ ├──────┘
315
- * │ │
316
- * │ WS │
317
- * └───────────────┘
318
- *
319
- * ┌───────────────┐
320
- * │ EN │
321
- * │ │
322
- * ┌──────┤ │
323
- * │ │ │
324
- * └──────┴───────────────┘
325
- *
326
- * ┌───────────────┐
327
- * │ WN │
328
- * │ │
329
- * │ ├──────┐
330
- * │ │ │
331
- * └───────────────┴──────┘
332
- */
333
- /**
334
- * @internal
335
- */
336
- export const MenuBarMenuViewPanelPositioningFunctions = {
337
- southEast: buttonRect => {
338
- return {
339
- top: buttonRect.bottom,
340
- left: buttonRect.left,
341
- name: 'se'
342
- };
343
- },
344
- southWest: (buttonRect, panelRect) => {
345
- return {
346
- top: buttonRect.bottom,
347
- left: buttonRect.left - panelRect.width + buttonRect.width,
348
- name: 'sw'
349
- };
350
- },
351
- northEast: (buttonRect, panelRect) => {
352
- return {
353
- top: buttonRect.top - panelRect.height,
354
- left: buttonRect.left,
355
- name: 'ne'
356
- };
357
- },
358
- northWest: (buttonRect, panelRect) => {
359
- return {
360
- top: buttonRect.top - panelRect.height,
361
- left: buttonRect.left - panelRect.width + buttonRect.width,
362
- name: 'nw'
363
- };
364
- },
365
- eastSouth: buttonRect => {
366
- return {
367
- top: buttonRect.top,
368
- left: buttonRect.right - NESTED_PANEL_HORIZONTAL_OFFSET,
369
- name: 'es'
370
- };
371
- },
372
- eastNorth: (buttonRect, panelRect) => {
373
- return {
374
- top: buttonRect.top - panelRect.height,
375
- left: buttonRect.right - NESTED_PANEL_HORIZONTAL_OFFSET,
376
- name: 'en'
377
- };
378
- },
379
- westSouth: (buttonRect, panelRect) => {
380
- return {
381
- top: buttonRect.top,
382
- left: buttonRect.left - panelRect.width + NESTED_PANEL_HORIZONTAL_OFFSET,
383
- name: 'ws'
384
- };
385
- },
386
- westNorth: (buttonRect, panelRect) => {
387
- return {
388
- top: buttonRect.top - panelRect.height,
389
- left: buttonRect.left - panelRect.width + NESTED_PANEL_HORIZONTAL_OFFSET,
390
- name: 'wn'
391
- };
392
- }
393
- };
394
- /**
395
- * The default items {@link module:core/editor/editorconfig~EditorConfig#menuBar configuration} of the
396
- * {@link module:ui/menubar/menubarview~MenuBarView} component. It contains names of all menu bar components
397
- * registered in the {@link module:ui/componentfactory~ComponentFactory component factory} (available in the project).
398
- *
399
- * **Note**: Menu bar component names provided by core editor features are prefixed with `menuBar:` in order to distinguish
400
- * them from components referenced by the {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar configuration}, for instance,
401
- * `'menuBar:bold'` is a menu bar button but `'bold'` is a toolbar button.
402
- *
403
- * Below is the preset menu bar structure (the default value of `config.menuBar.items` property):
404
- *
405
- * ```ts
406
- * [
407
- * {
408
- * menuId: 'file',
409
- * label: 'File',
410
- * groups: [
411
- * {
412
- * groupId: 'export',
413
- * items: [
414
- * 'menuBar:exportPdf',
415
- * 'menuBar:exportWord'
416
- * ]
417
- * },
418
- * {
419
- * groupId: 'import',
420
- * items: [
421
- * 'menuBar:importWord'
422
- * ]
423
- * },
424
- * {
425
- * groupId: 'revisionHistory',
426
- * items: [
427
- * 'menuBar:revisionHistory'
428
- * ]
429
- * }
430
- * ]
431
- * },
432
- * {
433
- * menuId: 'edit',
434
- * label: 'Edit',
435
- * groups: [
436
- * {
437
- * groupId: 'undo',
438
- * items: [
439
- * 'menuBar:undo',
440
- * 'menuBar:redo'
441
- * ]
442
- * },
443
- * {
444
- * groupId: 'selectAll',
445
- * items: [
446
- * 'menuBar:selectAll'
447
- * ]
448
- * },
449
- * {
450
- * groupId: 'findAndReplace',
451
- * items: [
452
- * 'menuBar:findAndReplace'
453
- * ]
454
- * }
455
- * ]
456
- * },
457
- * {
458
- * menuId: 'view',
459
- * label: 'View',
460
- * groups: [
461
- * {
462
- * groupId: 'sourceEditingEnhanced',
463
- * items: [
464
- * 'menuBar:sourceEditingEnhanced'
465
- * ]
466
- * },
467
- * {
468
- * groupId: 'sourceEditing',
469
- * items: [
470
- * 'menuBar:sourceEditing'
471
- * ]
472
- * },
473
- * {
474
- * groupId: 'showBlocks',
475
- * items: [
476
- * 'menuBar:showBlocks'
477
- * ]
478
- * },
479
- * {
480
- * groupId: 'previewMergeFields',
481
- * items: [
482
- * 'menuBar:previewMergeFields'
483
- * ]
484
- * },
485
- * {
486
- * groupId: 'fullscreen',
487
- * items: [
488
- * 'menuBar:fullscreen'
489
- * ]
490
- * },
491
- * {
492
- * groupId: 'restrictedEditingException',
493
- * items: [
494
- * 'menuBar:restrictedEditingException'
495
- * ]
496
- * }
497
- * ]
498
- * },
499
- * {
500
- * menuId: 'insert',
501
- * label: 'Insert',
502
- * groups: [
503
- * {
504
- * groupId: 'insertMainWidgets',
505
- * items: [
506
- * 'menuBar:insertImage',
507
- * 'menuBar:ckbox',
508
- * 'menuBar:ckfinder',
509
- * 'menuBar:insertTable'
510
- * ]
511
- * },
512
- * {
513
- * groupId: 'insertInline',
514
- * items: [
515
- * 'menuBar:link',
516
- * 'menuBar:insertFootnote',
517
- * 'menuBar:bookmark',
518
- * 'menuBar:comment',
519
- * 'menuBar:insertMergeField',
520
- * 'menuBar:emoji'
521
- * ]
522
- * },
523
- * {
524
- * groupId: 'insertMinorWidgets',
525
- * items: [
526
- * 'menuBar:mediaEmbed',
527
- * 'menuBar:insertTemplate',
528
- * 'menuBar:blockQuote',
529
- * 'menuBar:codeBlock',
530
- * 'menuBar:htmlEmbed'
531
- * ]
532
- * },
533
- * {
534
- * groupId: 'insertStructureWidgets',
535
- * items: [
536
- * 'menuBar:horizontalLine',
537
- * 'menuBar:pageBreak',
538
- * 'menuBar:tableOfContents'
539
- * ]
540
- * },
541
- * {
542
- * groupId: 'restrictedEditing',
543
- * items: [
544
- * 'menuBar:restrictedEditing'
545
- * ]
546
- * }
547
- * ]
548
- * },
549
- * {
550
- * menuId: 'format',
551
- * label: 'Format',
552
- * groups: [
553
- * {
554
- * groupId: 'textAndFont',
555
- * items: [
556
- * {
557
- * menuId: 'text',
558
- * label: 'Text',
559
- * groups: [
560
- * {
561
- * groupId: 'basicStyles',
562
- * items: [
563
- * 'menuBar:bold',
564
- * 'menuBar:italic',
565
- * 'menuBar:underline',
566
- * 'menuBar:strikethrough',
567
- * 'menuBar:superscript',
568
- * 'menuBar:subscript',
569
- * 'menuBar:code'
570
- * ]
571
- * },
572
- * {
573
- * groupId: 'textPartLanguage',
574
- * items: [
575
- * 'menuBar:textPartLanguage'
576
- * ]
577
- * }
578
- * ]
579
- * },
580
- * {
581
- * menuId: 'font',
582
- * label: 'Font',
583
- * groups: [
584
- * {
585
- * groupId: 'fontProperties',
586
- * items: [
587
- * 'menuBar:fontSize',
588
- * 'menuBar:fontFamily'
589
- * ]
590
- * },
591
- * {
592
- * groupId: 'fontColors',
593
- * items: [
594
- * 'menuBar:fontColor',
595
- * 'menuBar:fontBackgroundColor'
596
- * ]
597
- * },
598
- * {
599
- * groupId: 'highlight',
600
- * items: [
601
- * 'menuBar:highlight'
602
- * ]
603
- * }
604
- * ]
605
- * },
606
- * 'menuBar:heading'
607
- * ]
608
- * },
609
- * {
610
- * groupId: 'list',
611
- * items: [
612
- * 'menuBar:bulletedList',
613
- * 'menuBar:numberedList',
614
- * 'menuBar:multiLevelList',
615
- * 'menuBar:todoList'
616
- * ]
617
- * },
618
- * {
619
- * groupId: 'indent',
620
- * items: [
621
- * 'menuBar:alignment',
622
- * 'menuBar:lineHeight',
623
- * 'menuBar:indent',
624
- * 'menuBar:outdent'
625
- * ]
626
- * },
627
- * {
628
- * groupId: 'caseChange',
629
- * items: [
630
- * 'menuBar:caseChange'
631
- * ]
632
- * },
633
- * {
634
- * groupId: 'removeFormat',
635
- * items: [
636
- * 'menuBar:removeFormat'
637
- * ]
638
- * }
639
- * ]
640
- * },
641
- * {
642
- * menuId: 'tools',
643
- * label: 'Tools',
644
- * groups: [
645
- * {
646
- * groupId: 'aiTools',
647
- * items: [
648
- * 'menuBar:aiAssistant',
649
- * 'menuBar:aiCommands',
650
- * 'menuBar:toggleAi',
651
- * 'menuBar:aiQuickActions'
652
- * ]
653
- * },
654
- * {
655
- * groupId: 'tools',
656
- * items: [
657
- * 'menuBar:trackChanges',
658
- * 'menuBar:commentsArchive'
659
- * ]
660
- * }
661
- * ]
662
- * },
663
- * {
664
- * menuId: 'help',
665
- * label: 'Help',
666
- * groups: [
667
- * {
668
- * groupId: 'help',
669
- * items: [
670
- * 'menuBar:accessibilityHelp'
671
- * ]
672
- * }
673
- * ]
674
- * }
675
- * ];
676
- * ```
677
- *
678
- * The menu bar can be customized using the `config.menuBar.removeItems` and `config.menuBar.addItems` properties.
679
- */
680
- // **NOTE: Whenever you make changes to this value, reflect it in the documentation above!**
681
- export const DefaultMenuBarItems = [
682
- {
683
- menuId: 'file',
684
- label: 'File',
685
- groups: [
686
- {
687
- groupId: 'export',
688
- items: [
689
- 'menuBar:exportPdf',
690
- 'menuBar:exportWord'
691
- ]
692
- },
693
- {
694
- groupId: 'import',
695
- items: [
696
- 'menuBar:importWord'
697
- ]
698
- },
699
- {
700
- groupId: 'revisionHistory',
701
- items: [
702
- 'menuBar:revisionHistory'
703
- ]
704
- }
705
- ]
706
- },
707
- {
708
- menuId: 'edit',
709
- label: 'Edit',
710
- groups: [
711
- {
712
- groupId: 'undo',
713
- items: [
714
- 'menuBar:undo',
715
- 'menuBar:redo'
716
- ]
717
- },
718
- {
719
- groupId: 'selectAll',
720
- items: [
721
- 'menuBar:selectAll'
722
- ]
723
- },
724
- {
725
- groupId: 'findAndReplace',
726
- items: [
727
- 'menuBar:findAndReplace'
728
- ]
729
- }
730
- ]
731
- },
732
- {
733
- menuId: 'view',
734
- label: 'View',
735
- groups: [
736
- {
737
- groupId: 'sourceEditingEnhanced',
738
- items: [
739
- 'menuBar:sourceEditingEnhanced'
740
- ]
741
- },
742
- {
743
- groupId: 'sourceEditing',
744
- items: [
745
- 'menuBar:sourceEditing'
746
- ]
747
- },
748
- {
749
- groupId: 'showBlocks',
750
- items: [
751
- 'menuBar:showBlocks'
752
- ]
753
- },
754
- {
755
- groupId: 'previewMergeFields',
756
- items: [
757
- 'menuBar:previewMergeFields'
758
- ]
759
- },
760
- {
761
- groupId: 'fullscreen',
762
- items: [
763
- 'menuBar:fullscreen'
764
- ]
765
- },
766
- {
767
- groupId: 'restrictedEditing',
768
- items: [
769
- 'menuBar:restrictedEditing'
770
- ]
771
- }
772
- ]
773
- },
774
- {
775
- menuId: 'insert',
776
- label: 'Insert',
777
- groups: [
778
- {
779
- groupId: 'insertMainWidgets',
780
- items: [
781
- 'menuBar:insertImage',
782
- 'menuBar:ckbox',
783
- 'menuBar:ckfinder',
784
- 'menuBar:insertTable',
785
- 'menuBar:insertTableLayout'
786
- ]
787
- },
788
- {
789
- groupId: 'insertInline',
790
- items: [
791
- 'menuBar:link',
792
- 'menuBar:insertFootnote',
793
- 'menuBar:bookmark',
794
- 'menuBar:comment',
795
- 'menuBar:insertMergeField',
796
- 'menuBar:emoji'
797
- ]
798
- },
799
- {
800
- groupId: 'insertMinorWidgets',
801
- items: [
802
- 'menuBar:mediaEmbed',
803
- 'menuBar:insertTemplate',
804
- 'menuBar:specialCharacters',
805
- 'menuBar:blockQuote',
806
- 'menuBar:codeBlock',
807
- 'menuBar:htmlEmbed'
808
- ]
809
- },
810
- {
811
- groupId: 'insertStructureWidgets',
812
- items: [
813
- 'menuBar:horizontalLine',
814
- 'menuBar:pageBreak',
815
- 'menuBar:tableOfContents'
816
- ]
817
- },
818
- {
819
- groupId: 'restrictedEditingException',
820
- items: [
821
- 'menuBar:restrictedEditingException:inline',
822
- 'menuBar:restrictedEditingException:block'
823
- ]
824
- }
825
- ]
826
- },
827
- {
828
- menuId: 'format',
829
- label: 'Format',
830
- groups: [
831
- {
832
- groupId: 'textAndFont',
833
- items: [
834
- {
835
- menuId: 'text',
836
- label: 'Text',
837
- groups: [
838
- {
839
- groupId: 'basicStyles',
840
- items: [
841
- 'menuBar:bold',
842
- 'menuBar:italic',
843
- 'menuBar:underline',
844
- 'menuBar:strikethrough',
845
- 'menuBar:superscript',
846
- 'menuBar:subscript',
847
- 'menuBar:code'
848
- ]
849
- },
850
- {
851
- groupId: 'textPartLanguage',
852
- items: [
853
- 'menuBar:textPartLanguage'
854
- ]
855
- }
856
- ]
857
- },
858
- {
859
- menuId: 'font',
860
- label: 'Font',
861
- groups: [
862
- {
863
- groupId: 'fontProperties',
864
- items: [
865
- 'menuBar:fontSize',
866
- 'menuBar:fontFamily'
867
- ]
868
- },
869
- {
870
- groupId: 'fontColors',
871
- items: [
872
- 'menuBar:fontColor',
873
- 'menuBar:fontBackgroundColor'
874
- ]
875
- },
876
- {
877
- groupId: 'highlight',
878
- items: [
879
- 'menuBar:highlight'
880
- ]
881
- }
882
- ]
883
- },
884
- 'menuBar:heading'
885
- ]
886
- },
887
- {
888
- groupId: 'list',
889
- items: [
890
- 'menuBar:bulletedList',
891
- 'menuBar:numberedList',
892
- 'menuBar:multiLevelList',
893
- 'menuBar:todoList'
894
- ]
895
- },
896
- {
897
- groupId: 'indent',
898
- items: [
899
- 'menuBar:alignment',
900
- 'menuBar:lineHeight',
901
- 'menuBar:indent',
902
- 'menuBar:outdent'
903
- ]
904
- },
905
- {
906
- groupId: 'caseChange',
907
- items: [
908
- 'menuBar:caseChange'
909
- ]
910
- },
911
- {
912
- groupId: 'removeFormat',
913
- items: [
914
- 'menuBar:removeFormat'
915
- ]
916
- }
917
- ]
918
- },
919
- {
920
- menuId: 'tools',
921
- label: 'Tools',
922
- groups: [
923
- {
924
- groupId: 'aiTools',
925
- items: [
926
- 'menuBar:aiAssistant',
927
- 'menuBar:aiCommands',
928
- 'menuBar:toggleAi',
929
- 'menuBar:aiQuickActions'
930
- ]
931
- },
932
- {
933
- groupId: 'tools',
934
- items: [
935
- 'menuBar:trackChanges',
936
- 'menuBar:commentsArchive'
937
- ]
938
- }
939
- ]
940
- },
941
- {
942
- menuId: 'help',
943
- label: 'Help',
944
- groups: [
945
- {
946
- groupId: 'help',
947
- items: [
948
- 'menuBar:accessibilityHelp'
949
- ]
950
- }
951
- ]
952
- }
953
- ];
954
- /**
955
- * Performs a cleanup and normalization of the menu bar configuration.
956
- */
957
- export function normalizeMenuBarConfig(config) {
958
- let configObject;
959
- // The integrator specified the config as an object but without items. Let's give them defaults but respect their
960
- // additions and removals.
961
- if (!('items' in config) || !config.items) {
962
- configObject = {
963
- items: cloneDeep(DefaultMenuBarItems),
964
- addItems: [],
965
- removeItems: [],
966
- isVisible: true,
967
- isUsingDefaultConfig: true,
968
- ...config
969
- };
970
- }
971
- // The integrator specified the config as an object and there are items there. Let's take it as it is.
972
- else {
973
- configObject = {
974
- items: config.items,
975
- removeItems: [],
976
- addItems: [],
977
- isVisible: true,
978
- isUsingDefaultConfig: false,
979
- ...config
980
- };
981
- }
982
- return configObject;
983
- }
984
- /**
985
- * Processes a normalized menu bar config and returns a config clone with the following modifications:
986
- *
987
- * * Removed components that are not available in the component factory,
988
- * * Removed obsolete separators,
989
- * * Purged empty menus,
990
- * * Localized top-level menu labels.
991
- * @internal
992
- */
993
- export function processMenuBarConfig({ normalizedConfig, locale, componentFactory, extraItems }) {
994
- const configClone = cloneDeep(normalizedConfig);
995
- handleAdditions(normalizedConfig, configClone, extraItems);
996
- handleRemovals(normalizedConfig, configClone);
997
- handleAdditions(normalizedConfig, configClone, configClone.addItems);
998
- purgeUnavailableComponents(normalizedConfig, configClone, componentFactory);
999
- purgeEmptyMenus(normalizedConfig, configClone);
1000
- localizeMenuLabels(configClone, locale);
1001
- return configClone;
1002
- }
1003
- /**
1004
- * Removes items from the menu bar config based on user `removeItems` configuration. Users can remove
1005
- * individual items, groups, or entire menus. For each removed item, a warning is logged if the item
1006
- * was not found in the configuration.
1007
- */
1008
- function handleRemovals(originalConfig, config) {
1009
- const itemsToBeRemoved = config.removeItems;
1010
- const successfullyRemovedItems = [];
1011
- // Remove top-level menus.
1012
- config.items = config.items.filter(({ menuId }) => {
1013
- if (itemsToBeRemoved.includes(menuId)) {
1014
- successfullyRemovedItems.push(menuId);
1015
- return false;
1016
- }
1017
- return true;
1018
- });
1019
- walkConfigMenus(config.items, menuDefinition => {
1020
- // Remove groups from menus.
1021
- menuDefinition.groups = menuDefinition.groups.filter(({ groupId }) => {
1022
- if (itemsToBeRemoved.includes(groupId)) {
1023
- successfullyRemovedItems.push(groupId);
1024
- return false;
1025
- }
1026
- return true;
1027
- });
1028
- // Remove sub-menus and items from groups.
1029
- for (const groupDefinition of menuDefinition.groups) {
1030
- groupDefinition.items = groupDefinition.items.filter(item => {
1031
- const itemId = getIdFromGroupItem(item);
1032
- if (itemsToBeRemoved.includes(itemId)) {
1033
- successfullyRemovedItems.push(itemId);
1034
- return false;
1035
- }
1036
- return true;
1037
- });
1038
- }
1039
- });
1040
- for (const itemName of itemsToBeRemoved) {
1041
- if (!successfullyRemovedItems.includes(itemName)) {
1042
- /**
1043
- * There was a problem processing the configuration of the menu bar. The item with the given
1044
- * name does could not be removed from the menu bar configuration.
1045
- *
1046
- * This warning usually shows up when the {@link module:core/plugin~Plugin} which is supposed
1047
- * to provide a menu bar item has not been loaded or there is a typo in the
1048
- * {@link module:core/editor/editorconfig~EditorConfig#menuBar menu bar configuration}.
1049
- *
1050
- * @error menu-bar-item-could-not-be-removed
1051
- * @param menuBarConfig The full configuration of the menu bar.
1052
- * @param itemName The name of the item that was not removed from the menu bar.
1053
- */
1054
- logWarning('menu-bar-item-could-not-be-removed', {
1055
- menuBarConfig: originalConfig,
1056
- itemName
1057
- });
1058
- }
1059
- }
1060
- }
1061
- /**
1062
- * Adds provided items to config. It allows for adding menus, groups, and items at arbitrary
1063
- * positions in the menu bar. If the position does not exist, a warning is logged.
1064
- */
1065
- function handleAdditions(originalConfig, config, items) {
1066
- const successFullyAddedItems = [];
1067
- if (items.length == 0) {
1068
- return;
1069
- }
1070
- for (const itemToAdd of items) {
1071
- const relation = getRelationFromPosition(itemToAdd.position);
1072
- const relativeId = getRelativeIdFromPosition(itemToAdd.position);
1073
- // Adding a menu.
1074
- if (isMenuBarMenuAddition(itemToAdd)) {
1075
- if (!relativeId) {
1076
- // Adding a top-level menu at the beginning of the menu bar.
1077
- if (relation === 'start') {
1078
- config.items.unshift(itemToAdd.menu);
1079
- successFullyAddedItems.push(itemToAdd);
1080
- }
1081
- // Adding a top-level menu at the end of the menu bar.
1082
- else if (relation === 'end') {
1083
- config.items.push(itemToAdd.menu);
1084
- successFullyAddedItems.push(itemToAdd);
1085
- }
1086
- }
1087
- else {
1088
- const topLevelMenuDefinitionIndex = config.items.findIndex(menuDefinition => menuDefinition.menuId === relativeId);
1089
- // Adding a top-level menu somewhere between existing menu bar menus.
1090
- if (topLevelMenuDefinitionIndex != -1) {
1091
- if (relation === 'before') {
1092
- config.items.splice(topLevelMenuDefinitionIndex, 0, itemToAdd.menu);
1093
- successFullyAddedItems.push(itemToAdd);
1094
- }
1095
- else if (relation === 'after') {
1096
- config.items.splice(topLevelMenuDefinitionIndex + 1, 0, itemToAdd.menu);
1097
- successFullyAddedItems.push(itemToAdd);
1098
- }
1099
- }
1100
- // Adding a sub-menu to an existing items group.
1101
- else {
1102
- const wasAdded = addMenuOrItemToGroup(config, itemToAdd.menu, relativeId, relation);
1103
- if (wasAdded) {
1104
- successFullyAddedItems.push(itemToAdd);
1105
- }
1106
- }
1107
- }
1108
- }
1109
- // Adding a group.
1110
- else if (isMenuBarMenuGroupAddition(itemToAdd)) {
1111
- walkConfigMenus(config.items, menuDefinition => {
1112
- if (menuDefinition.menuId === relativeId) {
1113
- // Add a group at the start of a menu.
1114
- if (relation === 'start') {
1115
- menuDefinition.groups.unshift(itemToAdd.group);
1116
- successFullyAddedItems.push(itemToAdd);
1117
- }
1118
- // Add a group at the end of a menu.
1119
- else if (relation === 'end') {
1120
- menuDefinition.groups.push(itemToAdd.group);
1121
- successFullyAddedItems.push(itemToAdd);
1122
- }
1123
- }
1124
- else {
1125
- const relativeGroupIndex = menuDefinition.groups.findIndex(group => group.groupId === relativeId);
1126
- if (relativeGroupIndex !== -1) {
1127
- // Add a group before an existing group in a menu.
1128
- if (relation === 'before') {
1129
- menuDefinition.groups.splice(relativeGroupIndex, 0, itemToAdd.group);
1130
- successFullyAddedItems.push(itemToAdd);
1131
- }
1132
- // Add a group after an existing group in a menu.
1133
- else if (relation === 'after') {
1134
- menuDefinition.groups.splice(relativeGroupIndex + 1, 0, itemToAdd.group);
1135
- successFullyAddedItems.push(itemToAdd);
1136
- }
1137
- }
1138
- }
1139
- });
1140
- }
1141
- // Adding an item to an existing items group.
1142
- else {
1143
- const wasAdded = addMenuOrItemToGroup(config, itemToAdd.item, relativeId, relation);
1144
- if (wasAdded) {
1145
- successFullyAddedItems.push(itemToAdd);
1146
- }
1147
- }
1148
- }
1149
- for (const addedItemConfig of items) {
1150
- if (!successFullyAddedItems.includes(addedItemConfig)) {
1151
- /**
1152
- * There was a problem processing the configuration of the menu bar. The configured item could not be added
1153
- * because the position it was supposed to be added to does not exist.
1154
- *
1155
- * This warning usually shows up when the {@link module:core/plugin~Plugin} which is supposed
1156
- * to provide a menu bar item has not been loaded or there is a typo in the
1157
- * {@link module:core/editor/editorconfig~EditorConfig#menuBar menu bar configuration}.
1158
- *
1159
- * @error menu-bar-item-could-not-be-removed
1160
- * @param {object} menuBarConfig The full configuration of the menu bar.
1161
- * @param {object} addedItemConfig The name of the item that was not removed from the menu bar.
1162
- */
1163
- logWarning('menu-bar-item-could-not-be-added', {
1164
- menuBarConfig: originalConfig,
1165
- addedItemConfig
1166
- });
1167
- }
1168
- }
1169
- }
1170
- /**
1171
- * Handles adding a sub-menu or an item into a group. The logic is the same for both cases.
1172
- */
1173
- function addMenuOrItemToGroup(config, itemOrMenuToAdd, relativeId, relation) {
1174
- let wasAdded = false;
1175
- walkConfigMenus(config.items, menuDefinition => {
1176
- for (const { groupId, items: groupItems } of menuDefinition.groups) {
1177
- // Avoid infinite loops.
1178
- if (wasAdded) {
1179
- return;
1180
- }
1181
- if (groupId === relativeId) {
1182
- // Adding an item/menu at the beginning of a group.
1183
- if (relation === 'start') {
1184
- groupItems.unshift(itemOrMenuToAdd);
1185
- wasAdded = true;
1186
- }
1187
- // Adding an item/menu at the end of a group.
1188
- else if (relation === 'end') {
1189
- groupItems.push(itemOrMenuToAdd);
1190
- wasAdded = true;
1191
- }
1192
- }
1193
- else {
1194
- // Adding an item/menu relative to an existing item/menu.
1195
- const relativeItemIndex = groupItems.findIndex(groupItem => {
1196
- return getIdFromGroupItem(groupItem) === relativeId;
1197
- });
1198
- if (relativeItemIndex !== -1) {
1199
- if (relation === 'before') {
1200
- groupItems.splice(relativeItemIndex, 0, itemOrMenuToAdd);
1201
- wasAdded = true;
1202
- }
1203
- else if (relation === 'after') {
1204
- groupItems.splice(relativeItemIndex + 1, 0, itemOrMenuToAdd);
1205
- wasAdded = true;
1206
- }
1207
- }
1208
- }
1209
- }
1210
- });
1211
- return wasAdded;
1212
- }
1213
- /**
1214
- * Removes components from the menu bar configuration that are not available in the factory and would
1215
- * not be instantiated. Warns about missing components if the menu bar configuration was specified by the user.
1216
- */
1217
- function purgeUnavailableComponents(originalConfig, config, componentFactory) {
1218
- walkConfigMenus(config.items, menuDefinition => {
1219
- for (const groupDefinition of menuDefinition.groups) {
1220
- groupDefinition.items = groupDefinition.items.filter(item => {
1221
- const isItemUnavailable = typeof item === 'string' && !componentFactory.has(item);
1222
- // The default configuration contains all possible editor features. But integrators' editors rarely load
1223
- // every possible feature. This is why we do not want to log warnings about unavailable items for the default config
1224
- // because they would show up in almost every integration. If the configuration has been provided by
1225
- // the integrator, on the other hand, then these warnings bring value.
1226
- if (isItemUnavailable && !config.isUsingDefaultConfig) {
1227
- /**
1228
- * There was a problem processing the configuration of the menu bar. The item with the given
1229
- * name does not exist so it was omitted when rendering the menu bar.
1230
- *
1231
- * This warning usually shows up when the {@link module:core/plugin~Plugin} which is supposed
1232
- * to provide a menu bar item has not been loaded or there is a typo in the
1233
- * {@link module:core/editor/editorconfig~EditorConfig#menuBar menu bar configuration}.
1234
- *
1235
- * Make sure the plugin responsible for this menu bar item is loaded and the menu bar configuration
1236
- * is correct, e.g. {@link module:basic-styles/bold/boldui~BoldUI} is loaded for the `'menuBar:bold'`
1237
- * menu bar item.
1238
- *
1239
- * @error menu-bar-item-unavailable
1240
- * @param {object} menuBarConfig The full configuration of the menu bar.
1241
- * @param {object} parentMenuConfig The config of the menu the unavailable component was defined in.
1242
- * @param {string} componentName The name of the unavailable component.
1243
- */
1244
- logWarning('menu-bar-item-unavailable', {
1245
- menuBarConfig: originalConfig,
1246
- parentMenuConfig: cloneDeep(menuDefinition),
1247
- componentName: item
1248
- });
1249
- }
1250
- return !isItemUnavailable;
1251
- });
1252
- }
1253
- });
1254
- }
1255
- /**
1256
- * Removes empty menus from the menu bar configuration to improve the visual UX. Such menus can occur
1257
- * when some plugins responsible for providing menu bar items have not been loaded and some part of
1258
- * the configuration populated menus using these components exclusively.
1259
- */
1260
- function purgeEmptyMenus(originalConfig, config) {
1261
- const isUsingDefaultConfig = config.isUsingDefaultConfig;
1262
- let wasSubMenuPurged = false;
1263
- // Purge top-level menus.
1264
- config.items = config.items.filter(menuDefinition => {
1265
- if (!menuDefinition.groups.length) {
1266
- warnAboutEmptyMenu(originalConfig, menuDefinition, isUsingDefaultConfig);
1267
- return false;
1268
- }
1269
- return true;
1270
- });
1271
- // Warn if there were no top-level menus left in the menu bar after purging.
1272
- if (!config.items.length) {
1273
- warnAboutEmptyMenu(originalConfig, originalConfig, isUsingDefaultConfig);
1274
- return;
1275
- }
1276
- // Purge sub-menus and groups.
1277
- walkConfigMenus(config.items, menuDefinition => {
1278
- // Get rid of empty groups.
1279
- menuDefinition.groups = menuDefinition.groups.filter(groupDefinition => {
1280
- if (!groupDefinition.items.length) {
1281
- wasSubMenuPurged = true;
1282
- return false;
1283
- }
1284
- return true;
1285
- });
1286
- // Get rid of empty sub-menus.
1287
- for (const groupDefinition of menuDefinition.groups) {
1288
- groupDefinition.items = groupDefinition.items.filter(item => {
1289
- // If no groups were left after removing empty ones.
1290
- if (isMenuDefinition(item) && !item.groups.length) {
1291
- warnAboutEmptyMenu(originalConfig, item, isUsingDefaultConfig);
1292
- wasSubMenuPurged = true;
1293
- return false;
1294
- }
1295
- return true;
1296
- });
1297
- }
1298
- });
1299
- if (wasSubMenuPurged) {
1300
- // The config is walked from the root to the leaves so if anything gets removed, we need to re-run the
1301
- // whole process because it could've affected parents.
1302
- purgeEmptyMenus(originalConfig, config);
1303
- }
1304
- }
1305
- function warnAboutEmptyMenu(originalConfig, emptyMenuConfig, isUsingDefaultConfig) {
1306
- if (isUsingDefaultConfig) {
1307
- return;
1308
- }
1309
- /**
1310
- * There was a problem processing the configuration of the menu bar. One of the menus
1311
- * is empty so it was omitted when rendering the menu bar.
1312
- *
1313
- * This warning usually shows up when some {@link module:core/plugin~Plugin plugins} responsible for
1314
- * providing menu bar items have not been loaded and the
1315
- * {@link module:core/editor/editorconfig~EditorConfig#menuBar menu bar configuration} was not updated.
1316
- *
1317
- * Make sure all necessary editor plugins are loaded and/or update the menu bar configuration
1318
- * to account for the missing menu items.
1319
- *
1320
- * @error menu-bar-menu-empty
1321
- * @param {object} menuBarConfig The full configuration of the menu bar.
1322
- * @param {object} emptyMenuConfig The definition of the menu that has no child items.
1323
- */
1324
- logWarning('menu-bar-menu-empty', {
1325
- menuBarConfig: originalConfig,
1326
- emptyMenuConfig
1327
- });
1328
- }
1329
- /**
1330
- * Localizes the user-config using pre-defined localized category labels.
1331
- */
1332
- function localizeMenuLabels(config, locale) {
1333
- const t = locale.t;
1334
- const localizedCategoryLabels = {
1335
- // Top-level categories.
1336
- 'File': t({
1337
- string: 'File',
1338
- id: 'MENU_BAR_MENU_FILE'
1339
- }),
1340
- 'Edit': t({
1341
- string: 'Edit',
1342
- id: 'MENU_BAR_MENU_EDIT'
1343
- }),
1344
- 'View': t({
1345
- string: 'View',
1346
- id: 'MENU_BAR_MENU_VIEW'
1347
- }),
1348
- 'Insert': t({
1349
- string: 'Insert',
1350
- id: 'MENU_BAR_MENU_INSERT'
1351
- }),
1352
- 'Format': t({
1353
- string: 'Format',
1354
- id: 'MENU_BAR_MENU_FORMAT'
1355
- }),
1356
- 'Tools': t({
1357
- string: 'Tools',
1358
- id: 'MENU_BAR_MENU_TOOLS'
1359
- }),
1360
- 'Help': t({
1361
- string: 'Help',
1362
- id: 'MENU_BAR_MENU_HELP'
1363
- }),
1364
- // Sub-menus.
1365
- 'Text': t({
1366
- string: 'Text',
1367
- id: 'MENU_BAR_MENU_TEXT'
1368
- }),
1369
- 'Font': t({
1370
- string: 'Font',
1371
- id: 'MENU_BAR_MENU_FONT'
1372
- })
1373
- };
1374
- walkConfigMenus(config.items, definition => {
1375
- if (definition.label in localizedCategoryLabels) {
1376
- definition.label = localizedCategoryLabels[definition.label];
1377
- }
1378
- });
1379
- }
1380
- /**
1381
- * Recursively visits all menu definitions in the config and calls the callback for each of them.
1382
- */
1383
- function walkConfigMenus(definition, callback) {
1384
- if (Array.isArray(definition)) {
1385
- for (const topLevelMenuDefinition of definition) {
1386
- walk(topLevelMenuDefinition);
1387
- }
1388
- }
1389
- function walk(menuDefinition) {
1390
- callback(menuDefinition);
1391
- for (const groupDefinition of menuDefinition.groups) {
1392
- for (const groupItem of groupDefinition.items) {
1393
- if (isMenuDefinition(groupItem)) {
1394
- walk(groupItem);
1395
- }
1396
- }
1397
- }
1398
- }
1399
- }
1400
- function isMenuBarMenuAddition(definition) {
1401
- return typeof definition === 'object' && 'menu' in definition;
1402
- }
1403
- function isMenuBarMenuGroupAddition(definition) {
1404
- return typeof definition === 'object' && 'group' in definition;
1405
- }
1406
- function getRelationFromPosition(position) {
1407
- if (position.startsWith('start')) {
1408
- return 'start';
1409
- }
1410
- else if (position.startsWith('end')) {
1411
- return 'end';
1412
- }
1413
- else if (position.startsWith('after')) {
1414
- return 'after';
1415
- }
1416
- else {
1417
- return 'before';
1418
- }
1419
- }
1420
- function getRelativeIdFromPosition(position) {
1421
- const match = position.match(/^[^:]+:(.+)/);
1422
- if (match) {
1423
- return match[1];
1424
- }
1425
- return null;
1426
- }
1427
- function getIdFromGroupItem(item) {
1428
- return typeof item === 'string' ? item : item.menuId;
1429
- }
1430
- function isMenuDefinition(definition) {
1431
- return typeof definition === 'object' && 'menuId' in definition;
1432
- }