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