@vonage/vivid 5.24.0 → 5.27.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 (777) hide show
  1. package/README.md +1 -1
  2. package/accordion/index.cjs +1 -1
  3. package/accordion/index.js +8 -8
  4. package/accordion-item/index.cjs +1 -1
  5. package/action-group/index.cjs +3 -3
  6. package/action-group/index.js +10 -5
  7. package/alert/index.cjs +7 -7
  8. package/alert/index.js +47 -35
  9. package/audio-player/index.cjs +18 -18
  10. package/audio-player/index.js +15 -11
  11. package/avatar/index.cjs +10 -10
  12. package/avatar/index.js +29 -19
  13. package/badge/index.cjs +1 -1
  14. package/banner/index.cjs +5 -5
  15. package/banner/index.js +33 -27
  16. package/breadcrumb/index.cjs +1 -1
  17. package/breadcrumb/index.js +5 -1
  18. package/breadcrumb-item/index.cjs +9 -5
  19. package/breadcrumb-item/index.js +15 -10
  20. package/bundled/affix.cjs +3 -3
  21. package/bundled/affix.js +2 -2
  22. package/bundled/anchored.cjs +2 -2
  23. package/bundled/anchored.js +13 -1
  24. package/bundled/aria-binding-directive.cjs +1 -1
  25. package/bundled/aria-binding-directive.js +2 -2
  26. package/bundled/aria.cjs +1 -1
  27. package/bundled/base-color-picker.cjs +2 -2
  28. package/bundled/base-color-picker.js +1 -1
  29. package/bundled/base-progress.cjs +1 -1
  30. package/bundled/breadcrumb-item.cjs +1 -1
  31. package/bundled/button.cjs +1 -1
  32. package/bundled/calendar-event.cjs +1 -1
  33. package/bundled/calendar-event.js +17 -4
  34. package/bundled/calendar-picker.template.cjs +5 -5
  35. package/bundled/calendar-picker.template.js +53 -55
  36. package/bundled/char-count.cjs +2 -2
  37. package/bundled/children.cjs +1 -1
  38. package/bundled/children.js +1 -1
  39. package/bundled/class-names.cjs +1 -1
  40. package/bundled/component-enum.cjs +1 -0
  41. package/bundled/component-enum.js +9 -0
  42. package/bundled/data-grid.options.cjs +1 -1
  43. package/bundled/data-grid.options.js +7 -6
  44. package/bundled/decorate.cjs +1 -1
  45. package/bundled/decorate.js +1 -1
  46. package/bundled/definition.cjs +1 -1
  47. package/bundled/definition10.cjs +10 -19
  48. package/bundled/definition10.js +23 -71
  49. package/bundled/definition11.cjs +74 -10
  50. package/bundled/definition11.js +194 -23
  51. package/bundled/definition12.cjs +18 -70
  52. package/bundled/definition12.js +48 -185
  53. package/bundled/definition13.cjs +5 -22
  54. package/bundled/definition13.js +9 -58
  55. package/bundled/definition14.cjs +1 -5
  56. package/bundled/definition14.js +9 -9
  57. package/bundled/definition15.cjs +6 -6
  58. package/bundled/definition15.js +19 -18
  59. package/bundled/definition16.cjs +3 -3
  60. package/bundled/definition16.js +23 -17
  61. package/bundled/definition17.cjs +7 -7
  62. package/bundled/definition17.js +22 -109
  63. package/bundled/definition18.cjs +3 -3
  64. package/bundled/definition18.js +9 -31
  65. package/bundled/definition19.cjs +21 -21
  66. package/bundled/definition19.js +68 -62
  67. package/bundled/definition2.cjs +13 -1
  68. package/bundled/definition2.js +22 -185
  69. package/bundled/definition20.cjs +3 -3
  70. package/bundled/definition20.js +6 -7
  71. package/bundled/definition21.cjs +9 -9
  72. package/bundled/definition21.js +25 -25
  73. package/bundled/definition22.cjs +5 -5
  74. package/bundled/definition22.js +27 -27
  75. package/bundled/definition23.cjs +3 -3
  76. package/bundled/definition23.js +26 -8
  77. package/bundled/definition24.cjs +4 -4
  78. package/bundled/definition24.js +4 -3
  79. package/bundled/definition25.cjs +7 -7
  80. package/bundled/definition25.js +37 -28
  81. package/bundled/definition3.cjs +25 -12
  82. package/bundled/definition3.js +83 -44
  83. package/bundled/definition4.cjs +29 -25
  84. package/bundled/definition4.js +50 -88
  85. package/bundled/definition5.cjs +28 -29
  86. package/bundled/definition5.js +143 -45
  87. package/bundled/definition6.cjs +6 -29
  88. package/bundled/definition6.js +20 -129
  89. package/bundled/definition7.cjs +14 -6
  90. package/bundled/definition7.js +159 -20
  91. package/bundled/definition8.cjs +22 -14
  92. package/bundled/definition8.js +88 -144
  93. package/bundled/definition9.cjs +20 -16
  94. package/bundled/definition9.js +59 -62
  95. package/bundled/delegates-aria.cjs +1 -1
  96. package/bundled/delegates-aria.js +3 -2
  97. package/bundled/dialog.cjs +1 -1
  98. package/bundled/dialog.js +1 -1
  99. package/bundled/divider.cjs +1 -1
  100. package/bundled/divider.js +9 -9
  101. package/bundled/dom.cjs +1 -1
  102. package/bundled/enums.cjs +1 -1
  103. package/bundled/extractOptions.cjs +1 -1
  104. package/bundled/extractOptions.js +2 -2
  105. package/bundled/feedback-message.cjs +8 -0
  106. package/bundled/feedback-message.js +41 -0
  107. package/bundled/floating-ui.dom.cjs +1 -1
  108. package/bundled/floating-ui.dom.js +163 -197
  109. package/bundled/form-associated.cjs +1 -1
  110. package/bundled/form-associated.js +3 -4
  111. package/bundled/form-element.cjs +1 -1
  112. package/bundled/host-semantics.cjs +1 -1
  113. package/bundled/icon.cjs +1 -0
  114. package/bundled/icon.js +34 -0
  115. package/bundled/kbd-shortcut.cjs +1 -1
  116. package/bundled/key-codes.cjs +1 -1
  117. package/bundled/linkable.cjs +2 -2
  118. package/bundled/listbox.cjs +1 -1
  119. package/bundled/listbox.js +8 -7
  120. package/bundled/localized.cjs +1 -1
  121. package/bundled/localized.js +33 -32
  122. package/bundled/mixins.cjs +9 -16
  123. package/bundled/mixins.js +23 -56
  124. package/bundled/numberConverter.cjs +2 -2
  125. package/bundled/numberConverter.js +1 -1
  126. package/bundled/numbers.cjs +1 -1
  127. package/bundled/optgroup.cjs +1 -0
  128. package/bundled/optgroup.js +27 -0
  129. package/bundled/option.cjs +1 -0
  130. package/bundled/option.js +95 -0
  131. package/bundled/picker-field.template.cjs +2 -2
  132. package/bundled/picker-field.template.js +8 -8
  133. package/bundled/platform.cjs +1 -1
  134. package/bundled/playbackRates.cjs +1 -1
  135. package/bundled/ref.cjs +1 -1
  136. package/bundled/ref.js +1 -1
  137. package/bundled/render-in-light-dom.cjs +1 -1
  138. package/bundled/render-in-light-dom.js +1 -1
  139. package/bundled/repeat.cjs +1 -1
  140. package/bundled/repeat.js +16 -15
  141. package/bundled/scrollIntoView.cjs +1 -1
  142. package/bundled/scrollIntoView.js +1 -3
  143. package/bundled/single-date-picker.cjs +1 -1
  144. package/bundled/single-value-picker.cjs +1 -1
  145. package/bundled/single-value-picker.js +1 -1
  146. package/bundled/slider.template.cjs +12 -12
  147. package/bundled/slider.template.js +209 -32
  148. package/bundled/slottable-request.cjs +3 -3
  149. package/bundled/slottable-request.js +26 -17
  150. package/bundled/slotted.cjs +1 -1
  151. package/bundled/slotted.js +1 -1
  152. package/bundled/text-field.cjs +1 -1
  153. package/bundled/text-field.js +1 -1
  154. package/bundled/time-selection-picker.template.cjs +4 -4
  155. package/bundled/time-selection-picker.template.js +10 -7
  156. package/bundled/trapped-focus.cjs +1 -1
  157. package/bundled/utils.cjs +1 -1
  158. package/bundled/vivid-element.cjs +3 -3
  159. package/bundled/vivid-element.js +397 -358
  160. package/bundled/when.cjs +1 -1
  161. package/bundled/when.js +1 -1
  162. package/bundled/with-contextual-help.cjs +1 -1
  163. package/bundled/with-contextual-help.js +1 -1
  164. package/bundled/with-error-text.cjs +1 -1
  165. package/bundled/with-success-text.cjs +1 -1
  166. package/button/index.cjs +1 -1
  167. package/button/index.js +1 -1
  168. package/calendar/index.cjs +1 -1
  169. package/calendar/index.js +7 -7
  170. package/calendar-event/index.cjs +2 -2
  171. package/calendar-event/index.js +10 -8
  172. package/card/index.cjs +24 -22
  173. package/card/index.js +14 -8
  174. package/checkbox/index.cjs +1 -1
  175. package/color-picker/index.cjs +13 -13
  176. package/color-picker/index.js +22 -19
  177. package/combobox/index.cjs +9 -9
  178. package/combobox/index.js +46 -42
  179. package/contextual-help/index.cjs +1 -1
  180. package/contextual-help/index.js +1 -1
  181. package/country/index.cjs +1 -1
  182. package/country-group/index.cjs +1 -1
  183. package/country-group/index.js +8 -4
  184. package/custom-elements.json +4208 -3828
  185. package/data-grid/index.cjs +28 -28
  186. package/data-grid/index.js +92 -98
  187. package/date-picker/index.cjs +1 -1
  188. package/date-picker/index.js +10 -6
  189. package/date-range-picker/index.cjs +1 -1
  190. package/date-range-picker/index.js +13 -9
  191. package/date-time-picker/index.cjs +1 -1
  192. package/date-time-picker/index.js +11 -7
  193. package/dial-pad/index.cjs +24 -23
  194. package/dial-pad/index.js +17 -11
  195. package/dialog/index.cjs +14 -14
  196. package/dialog/index.js +12 -8
  197. package/divider/index.cjs +1 -1
  198. package/elevation/definition.cjs +1 -0
  199. package/elevation/definition.js +2 -2
  200. package/elevation/index.cjs +1 -1
  201. package/elevation/index.js +1 -1
  202. package/empty-state/index.cjs +4 -4
  203. package/empty-state/index.js +20 -7
  204. package/fab/index.cjs +3 -3
  205. package/fab/index.js +14 -6
  206. package/file-picker/index.cjs +11 -13
  207. package/file-picker/index.js +28 -24
  208. package/flag/index.cjs +1 -1
  209. package/flag/index.js +7 -3
  210. package/form-field/definition.cjs +5 -0
  211. package/form-field/definition.js +2 -0
  212. package/form-field/index.cjs +29 -0
  213. package/form-field/index.js +57 -0
  214. package/header/definition.cjs +1 -1
  215. package/header/definition.js +1 -1
  216. package/header/index.cjs +1 -1
  217. package/header/index.js +9 -5
  218. package/icon/definition.cjs +2 -1
  219. package/icon/definition.js +2 -1
  220. package/icon/index.cjs +1 -1
  221. package/icon/index.js +1 -1
  222. package/index.cjs +166 -154
  223. package/index.js +48 -42
  224. package/kbd-key/definition.cjs +1 -1
  225. package/kbd-key/definition.js +1 -1
  226. package/kbd-key/index.cjs +3 -3
  227. package/kbd-key/index.js +22 -13
  228. package/kbd-shortcut/definition.cjs +1 -1
  229. package/kbd-shortcut/definition.js +1 -1
  230. package/kbd-shortcut/index.cjs +1 -1
  231. package/kbd-shortcut/index.js +6 -6
  232. package/layout/definition.cjs +1 -1
  233. package/layout/definition.js +1 -1
  234. package/layout/index.cjs +1 -1
  235. package/layout/index.js +7 -3
  236. package/lib/accordion-item/accordion-item.d.ts +12 -6
  237. package/lib/action-group/action-group.d.ts +10 -5
  238. package/lib/alert/alert.d.ts +15 -18
  239. package/lib/avatar/avatar.d.ts +16 -7
  240. package/lib/badge/badge.d.ts +17 -7
  241. package/lib/banner/banner.d.ts +18 -20
  242. package/lib/button/button.d.ts +25 -16
  243. package/lib/calendar-event/calendar-event.d.ts +14 -7
  244. package/lib/checkbox/checkbox.d.ts +31 -28
  245. package/lib/combobox/combobox.d.ts +38 -33
  246. package/lib/components.d.ts +2 -0
  247. package/lib/data-grid/data-grid.options.d.ts +6 -1
  248. package/lib/dial-pad/dial-pad.d.ts +0 -1
  249. package/lib/dial-pad/locale.d.ts +1 -0
  250. package/lib/divider/divider.d.ts +9 -6
  251. package/lib/elevation/definition.d.ts +2 -0
  252. package/lib/empty-state/empty-state.d.ts +7 -2
  253. package/lib/fab/fab.d.ts +3 -2
  254. package/lib/form-field/definition.d.ts +4 -0
  255. package/lib/form-field/form-field.d.ts +6 -0
  256. package/lib/form-field/form-field.template.d.ts +3 -0
  257. package/lib/kbd-key/kbd-key.d.ts +7 -2
  258. package/lib/listbox/definition.d.ts +3 -0
  259. package/lib/listbox/listbox.d.ts +1303 -0
  260. package/lib/listbox/listbox.template.d.ts +3 -0
  261. package/lib/menu/menu.d.ts +0 -1
  262. package/lib/menu-item/menu-item.d.ts +17 -14
  263. package/lib/nav-disclosure/nav-disclosure.d.ts +18 -11
  264. package/lib/nav-item/nav-item.d.ts +19 -12
  265. package/lib/note/note.d.ts +10 -6
  266. package/lib/number-field/number-field.d.ts +45 -41
  267. package/lib/option/option.d.ts +13 -10
  268. package/lib/popup/definition.d.ts +2 -0
  269. package/lib/progress/progress.d.ts +10 -5
  270. package/lib/progress-ring/progress-ring.d.ts +9 -5
  271. package/lib/radio/radio.d.ts +18 -15
  272. package/lib/range-slider/range-slider.d.ts +19 -15
  273. package/lib/rich-text-editor/rich-text-editor.d.ts +9 -5
  274. package/lib/rich-text-editor/rte/features/base.d.ts +1 -0
  275. package/lib/rich-text-editor/rte/utils/default-textblock.d.ts +2 -2
  276. package/lib/rich-text-editor/rte/utils/ui.d.ts +2 -1
  277. package/lib/searchable-select/option-tag.d.ts +12 -7
  278. package/lib/searchable-select/searchable-select.d.ts +7 -2
  279. package/lib/select/select.d.ts +45 -40
  280. package/lib/selectable-box/selectable-box.d.ts +9 -5
  281. package/lib/slider/slider.d.ts +18 -14
  282. package/lib/split-button/split-button.d.ts +24 -15
  283. package/lib/status/status.d.ts +10 -7
  284. package/lib/switch/switch.d.ts +13 -9
  285. package/lib/tab/tab.d.ts +19 -14
  286. package/lib/tabs/tabs.d.ts +6 -3
  287. package/lib/tag/tag.d.ts +24 -15
  288. package/lib/tag-name-map.d.ts +3 -1
  289. package/lib/text-field/text-field.d.ts +47 -41
  290. package/lib/toggletip/toggletip.d.ts +1 -0
  291. package/lib/tooltip/tooltip.d.ts +1 -0
  292. package/lib/video-player/__tests__/video-fixtures.d.ts +3 -0
  293. package/listbox/definition.cjs +5 -0
  294. package/listbox/definition.js +2 -0
  295. package/listbox/index.cjs +13 -0
  296. package/listbox/index.js +554 -0
  297. package/locales/de-DE.cjs +34 -33
  298. package/locales/de-DE.js +34 -33
  299. package/locales/en-GB.cjs +34 -33
  300. package/locales/en-GB.js +34 -33
  301. package/locales/ja-JP.cjs +35 -33
  302. package/locales/ja-JP.js +35 -33
  303. package/locales/zh-CN.cjs +34 -33
  304. package/locales/zh-CN.js +34 -33
  305. package/menu/index.cjs +1 -1
  306. package/menu-item/index.cjs +1 -1
  307. package/nav/definition.cjs +1 -1
  308. package/nav/definition.js +1 -1
  309. package/nav/index.cjs +1 -1
  310. package/nav/index.js +6 -4
  311. package/nav-disclosure/definition.cjs +1 -1
  312. package/nav-disclosure/definition.js +1 -1
  313. package/nav-disclosure/index.cjs +5 -5
  314. package/nav-disclosure/index.js +15 -9
  315. package/nav-item/definition.cjs +1 -1
  316. package/nav-item/definition.js +1 -1
  317. package/nav-item/index.cjs +2 -2
  318. package/nav-item/index.js +15 -10
  319. package/note/definition.cjs +1 -1
  320. package/note/definition.js +1 -1
  321. package/note/index.cjs +6 -4
  322. package/note/index.js +22 -9
  323. package/number-field/definition.cjs +1 -1
  324. package/number-field/definition.js +1 -1
  325. package/number-field/index.cjs +11 -11
  326. package/number-field/index.js +41 -36
  327. package/optgroup/definition.cjs +2 -1
  328. package/optgroup/definition.js +2 -1
  329. package/optgroup/index.cjs +1 -1
  330. package/option/definition.cjs +2 -1
  331. package/option/definition.js +2 -1
  332. package/option/index.cjs +1 -1
  333. package/package.json +32 -38
  334. package/pagination/definition.cjs +1 -1
  335. package/pagination/definition.js +1 -1
  336. package/pagination/index.cjs +1 -1
  337. package/pagination/index.js +9 -9
  338. package/platform-switch/definition.cjs +1 -1
  339. package/platform-switch/definition.js +1 -1
  340. package/platform-switch/index.cjs +1 -1
  341. package/platform-switch/index.js +6 -2
  342. package/popover/definition.cjs +1 -1
  343. package/popover/definition.js +1 -1
  344. package/popover/index.cjs +5 -5
  345. package/popover/index.js +46 -37
  346. package/popup/definition.cjs +1 -0
  347. package/popup/definition.js +2 -2
  348. package/popup/index.cjs +1 -1
  349. package/popup/index.js +1 -1
  350. package/progress/definition.cjs +1 -1
  351. package/progress/definition.js +1 -1
  352. package/progress/index.cjs +7 -7
  353. package/progress/index.js +21 -11
  354. package/progress-ring/index.cjs +1 -1
  355. package/progress-ring/index.js +1 -1
  356. package/radio/definition.cjs +1 -1
  357. package/radio/definition.js +1 -1
  358. package/radio/index.cjs +1 -1
  359. package/radio-group/definition.cjs +1 -1
  360. package/radio-group/definition.js +1 -1
  361. package/radio-group/index.cjs +2 -2
  362. package/radio-group/index.js +14 -9
  363. package/range-slider/definition.cjs +1 -1
  364. package/range-slider/definition.js +1 -1
  365. package/range-slider/index.cjs +8 -8
  366. package/range-slider/index.js +31 -32
  367. package/rich-text-editor/definition.cjs +1 -1
  368. package/rich-text-editor/definition.js +1 -1
  369. package/rich-text-editor/index.cjs +17 -14
  370. package/rich-text-editor/index.js +1955 -1721
  371. package/rich-text-view/definition.cjs +1 -1
  372. package/rich-text-view/definition.js +1 -1
  373. package/rich-text-view/index.cjs +1 -1
  374. package/rich-text-view/index.js +6 -4
  375. package/searchable-select/definition.cjs +1 -1
  376. package/searchable-select/definition.js +1 -1
  377. package/searchable-select/index.cjs +26 -26
  378. package/searchable-select/index.js +97 -90
  379. package/select/definition.cjs +1 -1
  380. package/select/definition.js +1 -1
  381. package/select/index.cjs +1 -1
  382. package/selectable-box/definition.cjs +1 -1
  383. package/selectable-box/definition.js +1 -1
  384. package/selectable-box/index.cjs +8 -8
  385. package/selectable-box/index.js +24 -20
  386. package/shared/listbox/commands.d.ts +17 -0
  387. package/shared/listbox/move.d.ts +6 -0
  388. package/shared/listbox/options.d.ts +12 -0
  389. package/shared/listbox/selection.d.ts +28 -0
  390. package/shared/listbox/state.d.ts +26 -0
  391. package/shared/listbox/typeahead.d.ts +8 -0
  392. package/shared/listbox/with-options-filter.d.ts +440 -0
  393. package/shared/listbox/with-options.d.ts +862 -0
  394. package/shared/patterns/anchored.d.ts +2 -0
  395. package/shared/styles/appearance.d.ts +2 -0
  396. package/shared/styles/connotation.d.ts +2 -0
  397. package/shared/styles/connotationOverrides.d.ts +1 -0
  398. package/shared/utils/component-enum.d.ts +7 -0
  399. package/side-drawer/definition.cjs +1 -1
  400. package/side-drawer/definition.js +1 -1
  401. package/side-drawer/index.cjs +1 -1
  402. package/side-drawer/index.js +10 -7
  403. package/simple-color-picker/definition.cjs +1 -1
  404. package/simple-color-picker/definition.js +1 -1
  405. package/simple-color-picker/index.cjs +6 -6
  406. package/simple-color-picker/index.js +22 -21
  407. package/slider/definition.cjs +2 -1
  408. package/slider/definition.js +2 -1
  409. package/slider/index.cjs +1 -1
  410. package/slider/index.js +1 -1
  411. package/split-button/definition.cjs +1 -1
  412. package/split-button/definition.js +1 -1
  413. package/split-button/index.cjs +9 -7
  414. package/split-button/index.js +58 -37
  415. package/status/definition.cjs +1 -1
  416. package/status/definition.js +1 -1
  417. package/status/index.cjs +5 -5
  418. package/status/index.js +22 -13
  419. package/switch/definition.cjs +1 -1
  420. package/switch/definition.js +1 -1
  421. package/switch/index.cjs +3 -3
  422. package/switch/index.js +22 -11
  423. package/tab/definition.cjs +1 -1
  424. package/tab/definition.js +1 -1
  425. package/tab/index.cjs +1 -1
  426. package/tab/index.js +1 -1
  427. package/tab-panel/definition.cjs +1 -1
  428. package/tab-panel/definition.js +1 -1
  429. package/tab-panel/index.cjs +1 -1
  430. package/tab-panel/index.js +1 -1
  431. package/table/definition.cjs +1 -1
  432. package/table/definition.js +1 -1
  433. package/table/index.cjs +16 -14
  434. package/table/index.js +14 -11
  435. package/tabs/definition.cjs +1 -1
  436. package/tabs/definition.js +1 -1
  437. package/tabs/index.cjs +4 -4
  438. package/tabs/index.js +32 -30
  439. package/tag/definition.cjs +1 -1
  440. package/tag/definition.js +1 -1
  441. package/tag/index.cjs +11 -11
  442. package/tag/index.js +31 -14
  443. package/tag-group/definition.cjs +1 -1
  444. package/tag-group/definition.js +1 -1
  445. package/tag-group/index.cjs +1 -1
  446. package/tag-group/index.js +6 -4
  447. package/text-area/definition.cjs +1 -1
  448. package/text-area/definition.js +1 -1
  449. package/text-area/index.cjs +5 -5
  450. package/text-area/index.js +18 -15
  451. package/text-field/index.cjs +1 -1
  452. package/text-field/index.js +1 -1
  453. package/time-picker/definition.cjs +1 -1
  454. package/time-picker/definition.js +1 -1
  455. package/time-picker/index.cjs +1 -1
  456. package/time-picker/index.js +9 -6
  457. package/toggletip/index.cjs +1 -1
  458. package/toggletip/index.js +1 -1
  459. package/tooltip/index.cjs +1 -1
  460. package/tooltip/index.js +1 -1
  461. package/tree-item/definition.cjs +1 -1
  462. package/tree-item/definition.js +1 -1
  463. package/tree-item/index.cjs +1 -1
  464. package/tree-item/index.js +1 -1
  465. package/tree-view/definition.cjs +1 -1
  466. package/tree-view/definition.js +1 -1
  467. package/tree-view/index.cjs +1 -1
  468. package/tree-view/index.js +7 -5
  469. package/unbundled/affix.cjs +2 -3
  470. package/unbundled/affix.js +1 -1
  471. package/unbundled/anchored.cjs +39 -1
  472. package/unbundled/anchored.js +28 -1
  473. package/unbundled/aria-binding-directive.cjs +2 -2
  474. package/unbundled/aria-binding-directive.js +2 -1
  475. package/unbundled/base-color-picker.cjs +0 -1
  476. package/unbundled/base-progress.cjs +1 -2
  477. package/unbundled/base-progress.js +1 -1
  478. package/unbundled/breadcrumb-item.cjs +0 -1
  479. package/unbundled/button.cjs +2 -3
  480. package/unbundled/button.js +2 -2
  481. package/unbundled/calendar-event.cjs +29 -1
  482. package/unbundled/calendar-event.js +18 -1
  483. package/unbundled/calendar-picker.template.cjs +109 -91
  484. package/unbundled/calendar-picker.template.js +109 -90
  485. package/unbundled/char-count.cjs +0 -1
  486. package/unbundled/component-enum.cjs +18 -0
  487. package/unbundled/component-enum.js +13 -0
  488. package/unbundled/data-grid.options.cjs +8 -0
  489. package/unbundled/data-grid.options.js +3 -1
  490. package/unbundled/decorate.cjs +1 -1
  491. package/unbundled/decorate.js +1 -1
  492. package/unbundled/definition.cjs +3 -67
  493. package/unbundled/definition.js +5 -62
  494. package/unbundled/definition10.cjs +2 -343
  495. package/unbundled/definition10.js +4 -338
  496. package/unbundled/definition11.cjs +10 -10
  497. package/unbundled/definition11.js +9 -8
  498. package/unbundled/definition12.cjs +7 -6
  499. package/unbundled/definition12.js +8 -6
  500. package/unbundled/definition13.cjs +2 -2
  501. package/unbundled/definition13.js +2 -1
  502. package/unbundled/definition14.cjs +13 -4
  503. package/unbundled/definition14.js +13 -3
  504. package/unbundled/definition15.cjs +26 -5
  505. package/unbundled/definition15.js +26 -4
  506. package/unbundled/definition16.cjs +20 -14
  507. package/unbundled/definition16.js +20 -13
  508. package/unbundled/definition17.cjs +9 -5
  509. package/unbundled/definition17.js +9 -4
  510. package/unbundled/definition18.cjs +4 -3
  511. package/unbundled/definition18.js +4 -2
  512. package/unbundled/definition19.cjs +2 -3
  513. package/unbundled/definition19.js +9 -8
  514. package/unbundled/definition2.cjs +15 -5
  515. package/unbundled/definition2.js +16 -5
  516. package/unbundled/definition20.cjs +1 -2
  517. package/unbundled/definition20.js +7 -6
  518. package/unbundled/definition21.cjs +6 -4
  519. package/unbundled/definition21.js +6 -3
  520. package/unbundled/definition22.cjs +0 -1
  521. package/unbundled/definition23.cjs +14 -7
  522. package/unbundled/definition23.js +13 -5
  523. package/unbundled/definition24.cjs +10 -8
  524. package/unbundled/definition24.js +11 -8
  525. package/unbundled/definition25.cjs +4 -4
  526. package/unbundled/definition25.js +4 -3
  527. package/unbundled/definition26.cjs +13 -8
  528. package/unbundled/definition26.js +12 -6
  529. package/unbundled/definition27.cjs +41 -7
  530. package/unbundled/definition27.js +42 -7
  531. package/unbundled/definition28.cjs +7 -6
  532. package/unbundled/definition28.js +6 -4
  533. package/unbundled/definition29.cjs +5 -169
  534. package/unbundled/definition29.js +11 -162
  535. package/unbundled/definition3.cjs +5 -6
  536. package/unbundled/definition3.js +5 -5
  537. package/unbundled/definition30.cjs +2 -64
  538. package/unbundled/definition30.js +5 -54
  539. package/unbundled/definition31.cjs +20 -16
  540. package/unbundled/definition31.js +19 -14
  541. package/unbundled/definition32.cjs +2 -2
  542. package/unbundled/definition32.js +2 -1
  543. package/unbundled/definition33.cjs +0 -1
  544. package/unbundled/definition34.cjs +0 -1
  545. package/unbundled/definition35.cjs +41 -52
  546. package/unbundled/definition35.js +42 -52
  547. package/unbundled/definition36.cjs +2 -3
  548. package/unbundled/definition36.js +9 -8
  549. package/unbundled/definition37.cjs +1 -2
  550. package/unbundled/definition37.js +1 -1
  551. package/unbundled/definition38.cjs +0 -1
  552. package/unbundled/definition39.cjs +1 -2
  553. package/unbundled/definition39.js +1 -1
  554. package/unbundled/definition4.cjs +4 -3
  555. package/unbundled/definition4.js +11 -6
  556. package/unbundled/definition40.cjs +9 -6
  557. package/unbundled/definition40.js +9 -5
  558. package/unbundled/definition41.cjs +11 -7
  559. package/unbundled/definition41.js +11 -6
  560. package/unbundled/definition42.cjs +16 -7
  561. package/unbundled/definition42.js +16 -6
  562. package/unbundled/definition43.cjs +7 -3
  563. package/unbundled/definition43.js +7 -2
  564. package/unbundled/definition44.cjs +15 -13
  565. package/unbundled/definition44.js +14 -11
  566. package/unbundled/definition45.cjs +73 -52
  567. package/unbundled/definition45.js +69 -47
  568. package/unbundled/definition46.cjs +53 -46
  569. package/unbundled/definition46.js +49 -41
  570. package/unbundled/definition47.cjs +40 -165
  571. package/unbundled/definition47.js +36 -160
  572. package/unbundled/definition48.cjs +177 -32
  573. package/unbundled/definition48.js +174 -22
  574. package/unbundled/definition49.cjs +30 -90
  575. package/unbundled/definition49.js +27 -86
  576. package/unbundled/definition5.cjs +9 -3
  577. package/unbundled/definition5.js +15 -7
  578. package/unbundled/definition50.cjs +617 -48
  579. package/unbundled/definition50.js +615 -47
  580. package/unbundled/definition51.cjs +93 -22
  581. package/unbundled/definition51.js +91 -16
  582. package/unbundled/definition52.cjs +52 -33
  583. package/unbundled/definition52.js +49 -29
  584. package/unbundled/definition53.cjs +22 -324
  585. package/unbundled/definition53.js +18 -319
  586. package/unbundled/definition54.cjs +44 -213
  587. package/unbundled/definition54.js +40 -208
  588. package/unbundled/definition55.cjs +321 -42
  589. package/unbundled/definition55.js +317 -37
  590. package/unbundled/definition56.cjs +199 -254
  591. package/unbundled/definition56.js +193 -247
  592. package/unbundled/definition57.cjs +45 -54
  593. package/unbundled/definition57.js +42 -49
  594. package/unbundled/definition58.cjs +271 -134
  595. package/unbundled/definition58.js +269 -128
  596. package/unbundled/definition59.cjs +59 -246
  597. package/unbundled/definition59.js +58 -244
  598. package/unbundled/definition6.cjs +22 -7
  599. package/unbundled/definition6.js +22 -6
  600. package/unbundled/definition60.cjs +129 -445
  601. package/unbundled/definition60.js +127 -442
  602. package/unbundled/definition61.cjs +230 -3746
  603. package/unbundled/definition61.js +224 -3576
  604. package/unbundled/definition62.cjs +428 -742
  605. package/unbundled/definition62.js +426 -739
  606. package/unbundled/definition63.cjs +3776 -103
  607. package/unbundled/definition63.js +3607 -97
  608. package/unbundled/definition64.cjs +693 -906
  609. package/unbundled/definition64.js +685 -894
  610. package/unbundled/definition65.cjs +104 -109
  611. package/unbundled/definition65.js +100 -104
  612. package/unbundled/definition66.cjs +1004 -66
  613. package/unbundled/definition66.js +1003 -58
  614. package/unbundled/definition67.cjs +107 -156
  615. package/unbundled/definition67.js +103 -151
  616. package/unbundled/definition68.cjs +71 -123
  617. package/unbundled/definition68.js +67 -118
  618. package/unbundled/definition69.cjs +163 -52
  619. package/unbundled/definition69.js +159 -47
  620. package/unbundled/definition7.cjs +0 -1
  621. package/unbundled/definition7.js +10 -4
  622. package/unbundled/definition70.cjs +146 -76
  623. package/unbundled/definition70.js +145 -71
  624. package/unbundled/definition71.cjs +66 -22
  625. package/unbundled/definition71.js +63 -15
  626. package/unbundled/definition72.cjs +88 -76
  627. package/unbundled/definition72.js +85 -72
  628. package/unbundled/definition73.cjs +20 -306
  629. package/unbundled/definition73.js +16 -229
  630. package/unbundled/definition74.cjs +77 -316
  631. package/unbundled/definition74.js +76 -307
  632. package/unbundled/definition75.cjs +310 -31
  633. package/unbundled/definition75.js +233 -24
  634. package/unbundled/definition76.cjs +316 -110
  635. package/unbundled/definition76.js +307 -106
  636. package/unbundled/definition77.cjs +26 -251
  637. package/unbundled/definition77.js +22 -246
  638. package/unbundled/definition78.cjs +147 -27
  639. package/unbundled/definition78.js +139 -25
  640. package/unbundled/definition79.cjs +230 -117
  641. package/unbundled/definition79.js +227 -107
  642. package/unbundled/definition8.cjs +17 -10
  643. package/unbundled/definition8.js +17 -9
  644. package/unbundled/definition80.cjs +28 -203
  645. package/unbundled/definition80.js +26 -193
  646. package/unbundled/definition81.cjs +125 -477
  647. package/unbundled/definition81.js +118 -473
  648. package/unbundled/definition82.cjs +220 -0
  649. package/unbundled/definition82.js +203 -0
  650. package/unbundled/definition83.cjs +517 -0
  651. package/unbundled/definition83.js +498 -0
  652. package/unbundled/definition9.cjs +4 -3
  653. package/unbundled/definition9.js +4 -2
  654. package/unbundled/delegates-aria.cjs +4 -2
  655. package/unbundled/delegates-aria.js +4 -2
  656. package/unbundled/divider.cjs +8 -3
  657. package/unbundled/divider.js +3 -3
  658. package/unbundled/en-US.cjs +34 -33
  659. package/unbundled/en-US.js +34 -33
  660. package/unbundled/extractOptions.cjs +5 -5
  661. package/unbundled/extractOptions.js +2 -2
  662. package/unbundled/feedback-message.cjs +59 -0
  663. package/unbundled/feedback-message.js +48 -0
  664. package/unbundled/form-associated.cjs +1 -4
  665. package/unbundled/form-associated.js +1 -3
  666. package/unbundled/form-element.cjs +0 -1
  667. package/unbundled/icon.cjs +66 -0
  668. package/unbundled/icon.js +61 -0
  669. package/unbundled/kbd-shortcut.cjs +0 -1
  670. package/unbundled/linkable.cjs +1 -2
  671. package/unbundled/linkable.js +1 -1
  672. package/unbundled/listbox.cjs +8 -5
  673. package/unbundled/listbox.js +7 -3
  674. package/unbundled/localized.cjs +0 -1
  675. package/unbundled/mixins.cjs +3 -53
  676. package/unbundled/mixins.js +3 -46
  677. package/unbundled/numberConverter.cjs +8 -3
  678. package/unbundled/numberConverter.js +8 -3
  679. package/unbundled/optgroup.cjs +65 -0
  680. package/unbundled/optgroup.js +54 -0
  681. package/unbundled/option.cjs +183 -0
  682. package/unbundled/option.js +166 -0
  683. package/unbundled/picker-field.template.cjs +1 -2
  684. package/unbundled/picker-field.template.js +1 -1
  685. package/unbundled/randomId.cjs +0 -1
  686. package/unbundled/{chunk.cjs → rolldown-runtime.cjs} +1 -1
  687. package/unbundled/scrollIntoView.cjs +0 -1
  688. package/unbundled/scrollIntoView.js +0 -1
  689. package/unbundled/slider.template.cjs +340 -2
  690. package/unbundled/slider.template.js +338 -5
  691. package/unbundled/text-field.cjs +1 -1
  692. package/unbundled/text-field.js +1 -1
  693. package/unbundled/time-selection-picker.template.cjs +3 -4
  694. package/unbundled/time-selection-picker.template.js +3 -3
  695. package/unbundled/vivid-element.cjs +63 -4
  696. package/unbundled/vivid-element.js +63 -3
  697. package/unbundled/with-contextual-help.cjs +0 -1
  698. package/unbundled/with-error-text.cjs +0 -1
  699. package/unbundled/with-success-text.cjs +0 -1
  700. package/video-player/definition.cjs +1 -1
  701. package/video-player/definition.js +1 -1
  702. package/video-player/index.cjs +31 -31
  703. package/video-player/index.js +2094 -2085
  704. package/visually-hidden/index.cjs +1 -1
  705. package/vivid.api.json +807 -1341
  706. package/lib/action-group/variations.browser-spec.d.ts +0 -1
  707. package/lib/alert/variations.browser-spec.d.ts +0 -1
  708. package/lib/audio-player/variations.browser-spec.d.ts +0 -1
  709. package/lib/avatar/variations.browser-spec.d.ts +0 -1
  710. package/lib/badge/variations.browser-spec.d.ts +0 -1
  711. package/lib/banner/variations.browser-spec.d.ts +0 -1
  712. package/lib/breadcrumb-item/variations.browser-spec.d.ts +0 -1
  713. package/lib/button/variations.browser-spec.d.ts +0 -1
  714. package/lib/calendar/variations.browser-spec.d.ts +0 -1
  715. package/lib/calendar-event/variations.browser-spec.d.ts +0 -1
  716. package/lib/card/variations.browser-spec.d.ts +0 -1
  717. package/lib/checkbox/variations.browser-spec.d.ts +0 -1
  718. package/lib/color-picker/variations.browser-spec.d.ts +0 -1
  719. package/lib/combobox/variations.browser-spec.d.ts +0 -1
  720. package/lib/contextual-help/variations.browser-spec.d.ts +0 -1
  721. package/lib/country/variations.browser-spec.d.ts +0 -1
  722. package/lib/data-grid/variations.browser-spec.d.ts +0 -1
  723. package/lib/date-picker/variations.browser-spec.d.ts +0 -1
  724. package/lib/date-range-picker/variations.browser-spec.d.ts +0 -1
  725. package/lib/date-time-picker/variations.browser-spec.d.ts +0 -1
  726. package/lib/dial-pad/variations.browser-spec.d.ts +0 -1
  727. package/lib/dialog/variations.browser-spec.d.ts +0 -1
  728. package/lib/divider/variations.browser-spec.d.ts +0 -1
  729. package/lib/empty-state/variations.browser-spec.d.ts +0 -1
  730. package/lib/fab/variations.browser-spec.d.ts +0 -1
  731. package/lib/file-picker/variations.browser-spec.d.ts +0 -1
  732. package/lib/flag/variations.browser-spec.d.ts +0 -1
  733. package/lib/header/variations.browser-spec.d.ts +0 -1
  734. package/lib/icon/variations.browser-spec.d.ts +0 -1
  735. package/lib/kbd-key/variations.browser-spec.d.ts +0 -1
  736. package/lib/kbd-shortcut/variations.browser-spec.d.ts +0 -1
  737. package/lib/layout/variations.browser-spec.d.ts +0 -1
  738. package/lib/menu/variations.browser-spec.d.ts +0 -1
  739. package/lib/menu-item/variations.browser-spec.d.ts +0 -1
  740. package/lib/nav/variations.browser-spec.d.ts +0 -1
  741. package/lib/nav-disclosure/variations.browser-spec.d.ts +0 -1
  742. package/lib/nav-item/variations.browser-spec.d.ts +0 -1
  743. package/lib/note/variations.browser-spec.d.ts +0 -1
  744. package/lib/number-field/variations.browser-spec.d.ts +0 -1
  745. package/lib/optgroup/variations.browser-spec.d.ts +0 -1
  746. package/lib/option/variations.browser-spec.d.ts +0 -1
  747. package/lib/pagination/variations.browser-spec.d.ts +0 -1
  748. package/lib/popover/variations.browser-spec.d.ts +0 -1
  749. package/lib/progress/variations.browser-spec.d.ts +0 -1
  750. package/lib/progress-ring/variations.browser-spec.d.ts +0 -1
  751. package/lib/radio/variations.browser-spec.d.ts +0 -1
  752. package/lib/radio-group/variations.browser-spec.d.ts +0 -1
  753. package/lib/range-slider/variations.browser-spec.d.ts +0 -1
  754. package/lib/rich-text-editor/variations.browser-spec.d.ts +0 -1
  755. package/lib/rich-text-view/variations.browser-spec.d.ts +0 -1
  756. package/lib/searchable-select/variations.browser-spec.d.ts +0 -1
  757. package/lib/select/variations.browser-spec.d.ts +0 -1
  758. package/lib/selectable-box/variations.browser-spec.d.ts +0 -1
  759. package/lib/side-drawer/variations.browser-spec.d.ts +0 -1
  760. package/lib/simple-color-picker/variations.browser-spec.d.ts +0 -1
  761. package/lib/slider/variations.browser-spec.d.ts +0 -1
  762. package/lib/split-button/variations.browser-spec.d.ts +0 -1
  763. package/lib/status/variations.browser-spec.d.ts +0 -1
  764. package/lib/switch/variations.browser-spec.d.ts +0 -1
  765. package/lib/table/variations.browser-spec.d.ts +0 -1
  766. package/lib/tabs/variations.browser-spec.d.ts +0 -1
  767. package/lib/tag/variations.browser-spec.d.ts +0 -1
  768. package/lib/text-area/variations.browser-spec.d.ts +0 -1
  769. package/lib/text-field/variations.browser-spec.d.ts +0 -1
  770. package/lib/time-picker/variations.browser-spec.d.ts +0 -1
  771. package/lib/toggletip/variations.browser-spec.d.ts +0 -1
  772. package/lib/tooltip/variations.browser-spec.d.ts +0 -1
  773. package/lib/tree-item/variations.browser-spec.d.ts +0 -1
  774. package/lib/video-player/variations.browser-spec.d.ts +0 -1
  775. /package/lib/{accordion-item/variations.browser-spec.d.ts → form-field/index.d.ts} +0 -0
  776. /package/lib/{accordion/variations.browser-spec.d.ts → listbox/index.d.ts} +0 -0
  777. /package/unbundled/{chunk.js → rolldown-runtime.js} +0 -0
@@ -1,123 +1,3633 @@
1
1
  import { d as createRegisterFunction, t as VividElement, u as defineVividComponent } from "./vivid-element.js";
2
2
  import { t as __decorate } from "./decorate.js";
3
- import { c as impl, n as removeSymbol, s as sortedContributions, t as dispatchSlottableRequest } from "./slottable-request.js";
4
- import { ElementStyles, html, observable, ref } from "@microsoft/fast-element";
5
- import { DOMSerializer, Mark, Node } from "prosemirror-model";
6
- //#region src/lib/rich-text-view/rich-text-view.scss?inline
7
- var rich_text_view_default = ":host{display:contents}.content{overflow-wrap:break-word;white-space:break-spaces;display:contents}";
3
+ import { r as ProgressRing, t as progressRingDefinition } from "./definition5.js";
4
+ import { n as WithObservableLocale } from "./localized.js";
5
+ import { i as Button, t as buttonDefinition } from "./definition6.js";
6
+ import { i as Popup, r as PlacementStrategy, t as popupDefinition } from "./definition9.js";
7
+ import { i as MenuItem, t as menuItemDefinition } from "./definition11.js";
8
+ import { r as Menu, t as menuDefinition } from "./definition12.js";
9
+ import { t as Divider } from "./divider.js";
10
+ import { t as generateRandomId } from "./randomId.js";
11
+ import { n as textFieldDefinition, r as TextField } from "./definition26.js";
12
+ import { n as tooltipDefinition, r as Tooltip } from "./definition27.js";
13
+ import { t as ListboxOption } from "./option.js";
14
+ import { t as listboxOptionDefinition } from "./definition29.js";
15
+ import { t as dividerDefinition } from "./definition36.js";
16
+ import { a as featureFacade, c as impl, i as contributionPriority, n as removeSymbol, o as getFeatureImpl, r as RteFeatureImpl, s as sortedContributions, t as dispatchSlottableRequest } from "./slottable-request.js";
17
+ import { n as selectDefinition, r as Select } from "./definition64.js";
18
+ import { ElementStyles, attr, html, observable, ref, volatile } from "@microsoft/fast-element";
19
+ import { classNames } from "@microsoft/fast-web-utilities";
20
+ import { DOMParser, DOMSerializer, Fragment, NodeRange, Schema, Slice } from "prosemirror-model";
21
+ import { AllSelection, EditorState, NodeSelection, Plugin, PluginKey, TextSelection } from "prosemirror-state";
22
+ import { Decoration, DecorationSet, EditorView } from "prosemirror-view";
23
+ import { keymap } from "prosemirror-keymap";
24
+ import { autoJoin, baseKeymap, chainCommands, createParagraphNear, liftEmptyBlock, newlineInCode, splitBlockAs, toggleMark } from "prosemirror-commands";
25
+ import { dropCursor } from "prosemirror-dropcursor";
26
+ import { gapCursor } from "prosemirror-gapcursor";
27
+ import DOMPurify from "dompurify";
28
+ import { closeHistory, history, redo, undo } from "prosemirror-history";
29
+ import { InputRule, inputRules, undoInputRule } from "prosemirror-inputrules";
30
+ import { RemoveMarkStep, ReplaceAroundStep, dropPoint } from "prosemirror-transform";
31
+ import { marks } from "prosemirror-schema-basic";
32
+ //#region src/lib/rich-text-editor/rich-text-editor.scss?inline
33
+ var rich_text_editor_default = ":host{display:block}.rte{--editor-padding-inline:var(--rich-text-editor-padding-inline,16px);--editor-padding-block:var(--rich-text-editor-padding-block,calc(8px + var(--_border-width,0px)));block-size:100%;max-block-size:inherit;min-block-size:inherit;flex-direction:column;display:flex}.rte.appearance-fieldset{--_border-width:1px;border:var(--_border-width) solid var(--_appearance-color-outline);background-color:var(--_appearance-color-fill);border-radius:8px;transition:border-color .2s}.rte.appearance-fieldset:focus-within{--focus-stroke-gap-color:transparent;box-shadow:0 0 0 4px color-mix(in sRGB, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px))}.rte.appearance-fieldset .editor-viewport{border-start-start-radius:inherit;border-start-end-radius:inherit}.rte.appearance-fieldset .editor-scroll-area{background:0 0}.rte.appearance-fieldset .toolbar{border-end-end-radius:inherit;border-end-start-radius:inherit}.editor{display:contents}.editor-viewport{contain:layout;flex-direction:column;flex:1;min-block-size:0;display:flex;position:relative;overflow:hidden}.editor-scroll-area{background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);--scrollbar-track-color:transparent;--scrollbar-thumb-color:color-mix(in sRGB, var(--vvd-color-neutral-950), transparent 70%);scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin;flex-direction:column;flex:1;min-block-size:0;display:flex;overflow-y:auto}.editor-scroll-area ::-webkit-scrollbar{width:4px}.editor-scroll-area ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.editor-scroll-area ::-webkit-scrollbar-thumb{background-color:var(--scrollbar-fallback-track-color,var(--scrollbar-thumb-color));border:0;border-radius:4px}.popovers--disabled>*{display:none!important}";
8
34
  //#endregion
9
- //#region src/lib/rich-text-view/rich-text-view.ts
35
+ //#region src/lib/rich-text-editor/rich-text-editor.ts
10
36
  /**
11
37
  * @public
12
- * @component rich-text-view
13
- * @dynamicSlot `@vonage/vivid#RteChildSlotProps` child - Used for custom rendered children.
38
+ * @component rich-text-editor
39
+ * @slot editor-before - Displayed before the scrollable editor area.
40
+ * @slot editor-start - Displayed at the start of the scrollable editor area.
41
+ * @slot editor-end - Displayed at the end of the scrollable editor area.
42
+ * @slot editor-after - Displayed after the scrollable editor area.
43
+ * @slot status - Displayed between the editor viewport and the toolbar.
44
+ * @slot text-color-picker - Color picker for the RteTextColorFeature.
45
+ * @dynamicSlot `{ url: string }` inline-image-placeholder - Placeholder content for inline images.
46
+ * @dynamicSlot `{ id: string }` suggestions-empty - Empty state if no suggestions are found.
14
47
  */
15
- var RichTextView = class extends VividElement {
48
+ var RichTextEditor = class extends WithObservableLocale(VividElement) {
49
+ /** @internal */
50
+ instanceChanged(prevInstance) {
51
+ prevInstance?.[impl].destroyViewIfNeeded();
52
+ this._initViewIfNeeded();
53
+ prevInstance?.[impl].styles.removeStylesFrom(this.shadowRoot);
54
+ this.instance?.[impl].styles.addStylesTo(this.shadowRoot);
55
+ }
56
+ _initViewIfNeeded() {
57
+ const instance = this.instance?.[impl];
58
+ if (instance && this.$fastController.isConnected && !instance.view) {
59
+ this._syncStateIfNeeded();
60
+ instance.createView(this._editorEl);
61
+ }
62
+ }
63
+ _destroyViewIfNeeded() {
64
+ this.instance?.[impl].destroyViewIfNeeded();
65
+ }
66
+ connectedCallback() {
67
+ super.connectedCallback();
68
+ this._initViewIfNeeded();
69
+ }
70
+ disconnectedCallback() {
71
+ super.disconnectedCallback();
72
+ this._destroyViewIfNeeded();
73
+ }
74
+ /** @internal */
75
+ localeChanged() {
76
+ this._syncStateIfNeeded();
77
+ }
78
+ _syncStateIfNeeded() {
79
+ this.instance?.[impl].updateHostState({
80
+ locale: this.locale,
81
+ ctx: this._ctx
82
+ });
83
+ }
84
+ };
85
+ __decorate([observable], RichTextEditor.prototype, "instance", void 0);
86
+ __decorate([attr], RichTextEditor.prototype, "appearance", void 0);
87
+ //#endregion
88
+ //#region src/lib/rich-text-editor/rich-text-editor.template.ts
89
+ var RichTextEditorTemplate = (ctx) => {
90
+ return html`<template :_ctx="${() => ctx}">
91
+ <div
92
+ class="${(x) => classNames("rte", `connotation-accent`, "with-idle", "with-hover", [`appearance-${x.appearance}`, Boolean(x.appearance)])}"
93
+ >
94
+ <slot name="editor-before"></slot>
95
+ <div class="editor-viewport" ${ref("editorViewportElement")}>
96
+ <div class="editor-scroll-area" part="editor-scrollable-area">
97
+ <slot name="editor-start"></slot>
98
+ <div class="editor rich-text" ${ref("_editorEl")}></div>
99
+ <div class="popovers"></div>
100
+ <slot name="editor-end"></slot>
101
+ </div>
102
+ </div>
103
+ <slot name="editor-after"></slot>
104
+ <slot name="status"></slot>
105
+ <div class="toolbar"></div>
106
+ </div>
107
+ </template>`;
108
+ };
109
+ //#endregion
110
+ //#region src/lib/rich-text-editor/popover.ts
111
+ var Kind = {
112
+ default: {
113
+ placement: void 0,
114
+ placementStrategy: PlacementStrategy.AutoPlacementHorizontal,
115
+ shiftCrossAxis: false,
116
+ strategy: "fixed"
117
+ },
118
+ autocomplete: {
119
+ placement: "bottom-start",
120
+ placementStrategy: PlacementStrategy.Flip,
121
+ shiftCrossAxis: false,
122
+ strategy: "fixed"
123
+ },
124
+ imageOptions: {
125
+ placement: "bottom",
126
+ placementStrategy: PlacementStrategy.Flip,
127
+ shiftCrossAxis: true,
128
+ strategy: "absolute"
129
+ }
130
+ };
131
+ var popoverTemplate = (context) => {
132
+ const popup = context.tagFor(Popup);
133
+ return html`<${popup}
134
+ :anchor="${(x) => x.anchorEl}"
135
+ :placement="${(x) => Kind[x.kind].placement}"
136
+ :placementStrategy="${(x) => Kind[x.kind].placementStrategy}"
137
+ :shiftCrossAxis="${(x) => Kind[x.kind].shiftCrossAxis}"
138
+ :open="${(x) => x.open}"
139
+ :offset="${(x) => x.offset}"
140
+ :strategy="${(x) => Kind[x.kind].strategy}"
141
+ exportparts="vvd-theme-alternate"
142
+ >
143
+ <slot></slot>
144
+ </${popup}>`;
145
+ };
146
+ var Popover = class extends VividElement {
16
147
  constructor(..._args) {
17
148
  super(..._args);
18
- this._slotCounter = 0;
19
- this._slottedChildren = /* @__PURE__ */ new Set();
20
- this._slotRequests = /* @__PURE__ */ new Set();
21
- this._contentElement = null;
149
+ this.kind = "default";
150
+ this.anchorBlocksPopover = false;
151
+ this.onAnchorBlockPopoverChanged = () => {
152
+ this.anchorBlocksPopover = this.anchorEl?.dataset.blockPopover === "true" || false;
153
+ };
154
+ this.requestedOpenState = false;
22
155
  }
23
- /** @internal */
24
- viewChanged(oldView, newView) {
25
- if (oldView) this._removeStyles();
26
- if (newView) this._addStyles(newView);
27
- this._updateView();
28
- }
29
- _addStyles(view) {
30
- const config = view[impl].config[impl];
31
- this._styles = new ElementStyles(sortedContributions(config.features.flatMap((f) => f.getStyles())));
32
- this._styles.addStylesTo(this.shadowRoot);
33
- }
34
- _removeStyles() {
35
- if (this._styles) {
36
- this._styles.removeStylesFrom(this.shadowRoot);
37
- this._styles = void 0;
38
- }
39
- }
40
- _cleanupLightDom() {
41
- for (const el of this._slottedChildren) this.removeChild(el);
42
- for (const slotName of this._slotRequests) dispatchSlottableRequest(this, "child", slotName, removeSymbol);
43
- this._slottedChildren.clear();
44
- this._slotRequests.clear();
45
- this._slotCounter = 0;
46
- }
47
- _updateView() {
48
- if (!this._contentElement) return;
49
- this._contentElement.innerHTML = "";
50
- this._cleanupLightDom();
51
- if (this.view) this._contentElement.appendChild(this._renderView(this.view));
52
- }
53
- _renderView(rteView) {
54
- const ctx = rteView[impl];
55
- if (rteView.type === "node" && rteView.node.type === "doc") rteView = rteView.children;
56
- if (rteView.type === "fragment") {
57
- const frag = document.createDocumentFragment();
58
- for (const child of rteView.content) frag.appendChild(this._renderView(child));
59
- return frag;
60
- }
61
- const customRenderedView = ctx.options.renderChildView?.(rteView) ?? false;
62
- if (customRenderedView) return this._handleCustomRender(rteView, customRenderedView);
63
- else return this._renderDefault(rteView);
64
- }
65
- _handleCustomRender(rteView, customResult) {
66
- const slotName = `child-view-${this._slotCounter++}`;
67
- const slot = document.createElement("slot");
68
- slot.setAttribute("name", slotName);
69
- if (customResult === true) {
70
- this._slotRequests.add(slotName);
71
- dispatchSlottableRequest(this, "child", slotName, { view: rteView });
72
- } else {
73
- const { dom, contentDom = dom } = customResult;
74
- const nestedView = document.createElement(this.tagName);
75
- nestedView.view = rteView.children;
76
- contentDom.appendChild(nestedView);
77
- dom.setAttribute("slot", slotName);
78
- this.appendChild(dom);
79
- this._slottedChildren.add(dom);
80
- }
81
- return slot;
82
- }
83
- _renderDefault(view) {
84
- const schema = view[impl].config[impl].schema;
85
- if (view.type === "node" && view.node.type === "text") return document.createTextNode(view.node.text);
86
- const item = view.type === "node" ? view.node : view.mark;
87
- const pmItem = view.type === "node" ? Node.fromJSON(schema, item) : Mark.fromJSON(schema, item);
88
- const spec = pmItem instanceof Node ? pmItem.type.spec.toDOM(pmItem) : pmItem.type.spec.toDOM(pmItem, true);
89
- const { dom, contentDOM = dom } = DOMSerializer.renderSpec(document, spec);
90
- const childrenRendered = this._renderView(view.children);
91
- contentDOM.appendChild(childrenRendered);
92
- return dom;
156
+ static setBlockPopover(onElement, block) {
157
+ onElement.dataset.blockPopover = block ? "true" : "false";
158
+ const event = new CustomEvent("block-popover-changed", {
159
+ bubbles: false,
160
+ composed: false
161
+ });
162
+ onElement.dispatchEvent(event);
93
163
  }
94
- /** @internal */
164
+ /** Closes the popover. It reopens when anchorEl changes to a new element that does not block it. */
165
+ dismiss() {
166
+ this.anchorBlocksPopover = true;
167
+ }
168
+ anchorElChanged(prev, next) {
169
+ prev?.removeEventListener("block-popover-changed", this.onAnchorBlockPopoverChanged);
170
+ next?.addEventListener("block-popover-changed", this.onAnchorBlockPopoverChanged);
171
+ this.onAnchorBlockPopoverChanged();
172
+ }
173
+ anchorIdChanged() {
174
+ this.updateAnchor();
175
+ }
176
+ updateAnchor() {
177
+ if (this.anchorId && this.isConnected) this.anchorEl = this.getRootNode().getElementById(this.anchorId) || void 0;
178
+ else this.anchorEl = void 0;
179
+ }
180
+ requestOpenState(open) {
181
+ this.requestedOpenState = open;
182
+ }
183
+ get open() {
184
+ return this.requestedOpenState && !!this.anchorEl && !this.anchorBlocksPopover;
185
+ }
186
+ #observer;
95
187
  connectedCallback() {
96
188
  super.connectedCallback();
97
- this._updateView();
189
+ this.updateAnchor();
190
+ this.#observer = new MutationObserver((records) => {
191
+ if (records.some((r) => Array.from(r.addedNodes).some((n) => n instanceof HTMLElement && n.id === this.anchorId))) this.updateAnchor();
192
+ });
193
+ this.#observer.observe(this.getRootNode(), {
194
+ childList: true,
195
+ subtree: true
196
+ });
98
197
  }
99
- /** @internal */
100
198
  disconnectedCallback() {
101
199
  super.disconnectedCallback();
102
- this._removeStyles();
103
- this._cleanupLightDom();
200
+ this.#observer.disconnect();
201
+ }
202
+ };
203
+ __decorate([observable], Popover.prototype, "kind", void 0);
204
+ __decorate([observable], Popover.prototype, "offset", void 0);
205
+ __decorate([observable], Popover.prototype, "anchorBlocksPopover", void 0);
206
+ __decorate([observable], Popover.prototype, "anchorEl", void 0);
207
+ __decorate([observable], Popover.prototype, "anchorId", void 0);
208
+ __decorate([observable], Popover.prototype, "requestedOpenState", void 0);
209
+ __decorate([volatile], Popover.prototype, "open", null);
210
+ var popoverDefinition = defineVividComponent("rich-text-editor-popover", Popover, popoverTemplate, [popupDefinition], {});
211
+ //#endregion
212
+ //#region ../../node_modules/.pnpm/prosemirror-view@1.41.8/node_modules/prosemirror-view/style/prosemirror.css?inline
213
+ var prosemirror_default = ".ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:\"liga\" 0;position:relative}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection{caret-color:#0000}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:\"\";pointer-events:none;border:2px solid #8cf;position:absolute;inset:-2px -2px -2px -32px}img.ProseMirror-separator{border:none!important;margin:0!important;display:inline!important}";
214
+ //#endregion
215
+ //#region src/lib/rich-text-editor/rte/utils/default-textblock.ts
216
+ function defaultTextblockForMatch(match) {
217
+ for (let i = 0; i < match.edgeCount; i++) {
218
+ const { type } = match.edge(i);
219
+ /* v8 ignore if -- @preserve It's currently not possible to exercise this code in our RTE */
220
+ if (type.isTextblock && !type.hasRequiredAttrs()) return type;
221
+ }
222
+ }
223
+ //#endregion
224
+ //#region src/lib/rich-text-editor/rte/utils/ui.style.scss?inline
225
+ var ui_style_default = "[data-class=ui-select]{min-inline-size:120px;margin-block:-4px}.ui-divider{block-size:20px}.ui-button-group{gap:4px;display:flex}.ui-tooltip,.ui-menu{--_popup-display:contents;display:contents}.ui-tooltip-wrapper{display:contents}";
226
+ //#endregion
227
+ //#region src/lib/rich-text-editor/rte/utils/feature-state.ts
228
+ var FeatureState = class {
229
+ constructor(initialValue) {
230
+ this.plugin = new Plugin({ state: {
231
+ init: () => initialValue,
232
+ apply: (tr, value) => {
233
+ const meta = tr.getMeta(this.plugin);
234
+ return meta !== void 0 ? meta : value;
235
+ }
236
+ } });
237
+ }
238
+ getValue(rte) {
239
+ return this.plugin.getState(rte.state);
240
+ }
241
+ setValue(rte, newValue) {
242
+ rte.dispatchTransaction(rte.tr.setMeta(this.plugin, newValue));
243
+ }
244
+ };
245
+ //#endregion
246
+ //#region src/lib/rich-text-editor/rte/features/internal/core.style.scss?inline
247
+ var core_style_default = ".ProseMirror{box-sizing:border-box;padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none;flex:1 0 0}.ProseMirror-selectednode{--focus-stroke-gap-color:transparent;--focus-border-radius:2px;outline:none;position:relative}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in sRGB, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px));border-radius:var(--focus-border-radius,inherit);block-size:calc(100% + var(--focus-block-size-addition,4px));content:\"\";inline-size:calc(100% + var(--focus-block-size-addition,4px));display:block;position:absolute;inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}.editor--disabled .ProseMirror{color:var(--vvd-color-neutral-300);cursor:not-allowed}";
248
+ //#endregion
249
+ //#region src/lib/rich-text-editor/rte/features/internal/foreign-html.ts
250
+ var RteForeignHtmlFeatureImpl = class extends RteFeatureImpl {
251
+ constructor(..._args) {
252
+ super(..._args);
253
+ this.name = "RteForeignHtmlFeature";
254
+ }
255
+ getPlugins(rte) {
256
+ return [this.contribution(new Plugin({ props: {
257
+ transformPastedHTML: (html) => rte.foreignHtmlParser[impl].transform(html),
258
+ clipboardParser: rte.foreignHtmlParser[impl].parser,
259
+ clipboardSerializer: rte.foreignHtmlSerializer[impl].serializer
260
+ } }))];
261
+ }
262
+ };
263
+ //#endregion
264
+ //#region src/lib/rich-text-editor/rte/features/internal/cursor-fix.ts
265
+ /**
266
+ * When the cursor is positioned after an inline atom node at the end of a line,
267
+ * browsers may display the cursor inside the atom.
268
+ */
269
+ var atomCursorFix = ($cursor) => {
270
+ if (!($cursor.parentOffset === $cursor.parent.content.size)) return null;
271
+ const nodeBefore = $cursor.nodeBefore;
272
+ if (nodeBefore && nodeBefore.isInline && nodeBefore.isAtom && !nodeBefore.isText) return {};
273
+ return null;
274
+ };
275
+ /**
276
+ * When the cursor is positioned directly before an inline atom node (e.g. an image)
277
+ * that wraps to the next line, browsers may display the cursor on the next line even
278
+ * though typing inserts text on the previous line. A ZWSP between cursor and atom will be
279
+ * layouted to the previous line and therefore fix the cursor position.
280
+ */
281
+ var beforeAtomCursorFix = ($cursor) => {
282
+ const nodeAfter = $cursor.nodeAfter;
283
+ if (nodeAfter && nodeAfter.isInline && nodeAfter.isAtom && !nodeAfter.isText) return { afterCursor: true };
284
+ return null;
285
+ };
286
+ function createZwspWidget(style) {
287
+ const span = document.createElement("span");
288
+ span.textContent = "​";
289
+ for (const [prop, value] of Object.entries(style)) span.style.setProperty(prop, value);
290
+ return span;
291
+ }
292
+ var RteCursorFixFeatureImpl = class extends RteFeatureImpl {
293
+ constructor(..._args) {
294
+ super(..._args);
295
+ this.name = "RteCursorFix";
296
+ }
297
+ getPlugins(rte) {
298
+ const cursorFixes = [atomCursorFix, beforeAtomCursorFix];
299
+ for (const markType of Object.values(rte.schema.marks)) {
300
+ const spec = markType.spec;
301
+ if (spec.cursorFix) cursorFixes.push(spec.cursorFix);
302
+ }
303
+ return [this.contribution(new Plugin({ props: { decorations: (state) => {
304
+ const { $cursor } = state.selection;
305
+ if (!$cursor) return null;
306
+ const decorations = [];
307
+ const cursorFixStyles = {};
308
+ let before = false;
309
+ let after = false;
310
+ for (const fn of cursorFixes) {
311
+ const result = fn($cursor, state);
312
+ if (!result) continue;
313
+ if (result.style) Object.assign(cursorFixStyles, result.style);
314
+ if (result.afterCursor) after = true;
315
+ else before = true;
316
+ }
317
+ if (before) decorations.push(Decoration.widget($cursor.pos, () => createZwspWidget(cursorFixStyles), { side: -1 }));
318
+ if (after) decorations.push(Decoration.widget($cursor.pos, () => createZwspWidget(cursorFixStyles), { side: 1 }));
319
+ if (decorations.length === 0) return null;
320
+ return DecorationSet.create(state.doc, decorations);
321
+ } } }))];
322
+ }
323
+ };
324
+ featureFacade(RteCursorFixFeatureImpl);
325
+ //#endregion
326
+ //#region src/lib/rich-text-editor/rte/features/internal/core.ts
327
+ /** Plugin to bring state from the host web component into ProseMirror. */
328
+ var hostBridgePlugin = new Plugin({ state: {
329
+ init() {
330
+ return null;
331
+ },
332
+ apply(tr, value) {
333
+ const meta = tr.getMeta(hostBridgePlugin);
334
+ if (meta) return meta;
335
+ else return value;
336
+ }
337
+ } });
338
+ var RteCoreImpl = class extends RteFeatureImpl {
339
+ constructor(..._args) {
340
+ super(..._args);
341
+ this.name = "RteCore";
342
+ this.disabled = new FeatureState(false);
343
+ this.scrollThreshold = void 0;
344
+ this.scrollMargin = void 0;
345
+ }
346
+ getStyles() {
347
+ return [
348
+ this.contribution(prosemirror_default),
349
+ this.contribution(core_style_default),
350
+ this.contribution(ui_style_default)
351
+ ];
352
+ }
353
+ getPlugins(rte) {
354
+ const splitFn = splitBlockAs((node, atEnd, $from) => {
355
+ if (!atEnd) return {
356
+ type: node.type,
357
+ attrs: node.attrs
358
+ };
359
+ const defaultTextblock = defaultTextblockForMatch($from.node($from.depth - 1).contentMatchAt($from.indexAfter($from.depth - 1)));
360
+ if (!defaultTextblock) return null;
361
+ return {
362
+ type: defaultTextblock,
363
+ attrs: rte.textblockAttrs.extractFromNode(node)
364
+ };
365
+ });
366
+ const splitFnKeepMarks = (state, dispatch) => splitFn(state, dispatch && ((tr) => {
367
+ const marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();
368
+ if (marks) tr.ensureMarks(marks);
369
+ dispatch(tr);
370
+ }));
371
+ const enterKeyChainCommands = chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitFnKeepMarks);
372
+ return [
373
+ this.contribution(this.disabled.plugin),
374
+ this.contribution(new Plugin({
375
+ props: {
376
+ editable: () => !this.disabled.getValue(rte),
377
+ handleDOMEvents: { click: (_view, event) => {
378
+ if (this.disabled.getValue(rte)) {
379
+ event.preventDefault();
380
+ return true;
381
+ }
382
+ return false;
383
+ } }
384
+ },
385
+ view: (view) => {
386
+ const popovers = view.dom.getRootNode().querySelector(".popovers");
387
+ const updateDisabled = () => {
388
+ const disabled = this.disabled.getValue(rte);
389
+ popovers.classList.toggle("popovers--disabled", disabled);
390
+ view.dom.parentElement.classList.toggle("editor--disabled", disabled);
391
+ };
392
+ updateDisabled();
393
+ return { update: () => {
394
+ updateDisabled();
395
+ } };
396
+ }
397
+ })),
398
+ this.contribution(keymap({
399
+ ...baseKeymap,
400
+ Enter: enterKeyChainCommands,
401
+ "Shift-Enter": enterKeyChainCommands
402
+ })),
403
+ this.contribution(dropCursor()),
404
+ this.contribution(gapCursor()),
405
+ this.contribution(hostBridgePlugin)
406
+ ];
407
+ }
408
+ getFeatures() {
409
+ return [
410
+ this,
411
+ new RteForeignHtmlFeatureImpl(),
412
+ new RteCursorFixFeatureImpl()
413
+ ];
414
+ }
415
+ };
416
+ featureFacade(RteCoreImpl);
417
+ //#endregion
418
+ //#region src/lib/rich-text-editor/rte/utils/sanitization.ts
419
+ var DEFAULT_ALLOWED_URI_REGEXP = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i;
420
+ var ALLOWED_URI_REGEXP_WITH_BLOB = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i;
421
+ var ATTR_WHITESPACE = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;
422
+ var domPurifyConfig = { ALLOWED_URI_REGEXP: ALLOWED_URI_REGEXP_WITH_BLOB };
423
+ /**
424
+ * Sanitize potentially dangerous URLs, like "javascript:", in anchor href attributes.
425
+ * Returns empty string if the URL is unsafe.
426
+ */
427
+ var sanitizeLinkHref = (url) => {
428
+ if (!DEFAULT_ALLOWED_URI_REGEXP.test(url.replace(ATTR_WHITESPACE, ""))) return "";
429
+ const anchor = document.createElement("a");
430
+ anchor.setAttribute("href", url);
431
+ /* v8 ignore next -- since href is already validated it's probably always present @preserve */
432
+ return DOMPurify.sanitize(anchor, {
433
+ RETURN_DOM: true,
434
+ ...domPurifyConfig
435
+ }).querySelector("a").getAttribute("href") ?? "";
436
+ };
437
+ /**
438
+ * Sanitize potentially dangerous URLs, like "javascript:", in image src attributes.
439
+ * Returns empty string if the URL is unsafe.
440
+ */
441
+ var sanitizeImageSrc = (url) => {
442
+ const img = document.createElement("img");
443
+ img.setAttribute("src", url);
444
+ return DOMPurify.sanitize(img, {
445
+ RETURN_DOM: true,
446
+ ...domPurifyConfig
447
+ }).querySelector("img").getAttribute("src") ?? "";
448
+ };
449
+ /**
450
+ * Escapes a CSS value for insertion into style attribute.
451
+ * E.g. "15px; background: red" => "15px"
452
+ */
453
+ var escapeCssProperty = (value) => value.replace(/[;!].*/, "");
454
+ //#endregion
455
+ //#region src/lib/rich-text-editor/rte/html-parser.ts
456
+ var copy = (obj) => ({ ...obj });
457
+ var parseRulesFromSchema = (schema) => ({
458
+ nodes: Object.fromEntries(Object.keys(schema.nodes).map((name) => [name, (schema.nodes[name].spec.parseDOM ?? []).map(copy)])),
459
+ marks: Object.fromEntries(Object.keys(schema.marks).map((name) => [name, (schema.marks[name].spec.parseDOM ?? []).map(copy)]))
460
+ });
461
+ var RteHtmlParser = class {
462
+ constructor(config, options) {
463
+ this[impl] = new RteHtmlParserImpl(config[impl], options);
464
+ }
465
+ /** Converts an HTML string to an RteDocument. */
466
+ parseDocument(html, options) {
467
+ return this[impl].parser.parse(this.parseHtml(html, options), { preserveWhitespace: true }).toJSON();
468
+ }
469
+ /** Converts an HTML string to an RteFragment. */
470
+ parseFragment(html, options) {
471
+ return this[impl].parser.parseSlice(this.parseHtml(html, options), { preserveWhitespace: true }).content.toJSON() ?? [];
472
+ }
473
+ parseHtml(html, options) {
474
+ const dom = DOMPurify.sanitize(html, {
475
+ RETURN_DOM: true,
476
+ ...domPurifyConfig
477
+ });
478
+ const container = document.createDocumentFragment();
479
+ container.appendChild(dom);
480
+ options?.modifyDom?.(container);
481
+ return container;
482
+ }
483
+ };
484
+ var RteHtmlParserImpl = class {
485
+ constructor(config, options) {
486
+ const rules = parseRulesFromSchema(config.schema);
487
+ options?.modifyParseRules?.(rules);
488
+ this.parser = buildDomParser(config.schema, rules);
489
+ }
490
+ /** Used by the editor when foreign HTML is pasted or dropped */
491
+ transform(html) {
492
+ return DOMPurify.sanitize(html);
493
+ }
494
+ };
495
+ var buildDomParser = (schema, { marks, nodes }) => {
496
+ const parserRules = [];
497
+ const priority = (rule) => rule.priority ?? 50;
498
+ function insert(rule) {
499
+ let i = 0;
500
+ for (; i < parserRules.length; i++) {
501
+ const next = parserRules[i];
502
+ if (priority(next) < priority(rule)) break;
503
+ }
504
+ parserRules.splice(i, 0, rule);
505
+ }
506
+ for (const name in marks) marks[name]?.forEach((rule) => {
507
+ insert(rule = copy(rule));
508
+ if (!(rule.mark || rule.ignore || rule.clearMark)) rule.mark = name;
509
+ });
510
+ for (const name in nodes) nodes[name]?.forEach((rule) => {
511
+ insert(rule = copy(rule));
512
+ if (!(rule.node || rule.ignore || rule.mark)) rule.node = name;
513
+ });
514
+ parserRules.push({
515
+ tag: "br",
516
+ closeParent: true
517
+ });
518
+ return new DOMParser(schema, parserRules);
519
+ };
520
+ //#endregion
521
+ //#region src/lib/rich-text-editor/rte/html-serializer.ts
522
+ var RteHtmlSerializer = class {
523
+ constructor(config, options) {
524
+ this[impl] = new RteHtmlSerializerImpl(config[impl], options);
525
+ }
526
+ /** Converts an RteDocument to an HTML string. */
527
+ serializeDocument(doc, options) {
528
+ return this[impl].serializeFragment(doc.content, options);
529
+ }
530
+ /** Converts an RteFragment to an HTML string. */
531
+ serializeFragment(fragment, options) {
532
+ return this[impl].serializeFragment(fragment, options);
533
+ }
534
+ };
535
+ var RteHtmlSerializerImpl = class RteHtmlSerializerImpl {
536
+ constructor(config, options) {
537
+ this.config = config;
538
+ const serializers = RteHtmlSerializerImpl.domSerializersFromSchema(config.schema);
539
+ Object.assign(serializers.nodes, options?.serializers?.nodes ?? {});
540
+ Object.assign(serializers.marks, options?.serializers?.marks ?? {});
541
+ this.serializer = new DOMSerializer(serializers.nodes, serializers.marks);
542
+ }
543
+ static domSerializersFromSchema(schema) {
544
+ const result = {
545
+ nodes: {},
546
+ marks: {}
547
+ };
548
+ for (const name in schema.marks) {
549
+ const toDOM = schema.marks[name].spec.toDOM;
550
+ if (toDOM) result.marks[name] = toDOM;
551
+ }
552
+ for (const name in schema.nodes) {
553
+ const toDOM = schema.nodes[name].spec.serializeToDOM ?? schema.nodes[name].spec.toDOM;
554
+ if (toDOM) result.nodes[name] = toDOM;
555
+ }
556
+ result.nodes.text = (node) => document.createTextNode(node.text);
557
+ return result;
558
+ }
559
+ serializeFragment(fragment, options) {
560
+ const parsedFragment = Fragment.fromJSON(this.config.schema, fragment);
561
+ const serializedFragment = this.serializer.serializeFragment(parsedFragment);
562
+ const container = document.createDocumentFragment();
563
+ container.appendChild(serializedFragment);
564
+ options?.modifyDom?.(container);
565
+ const output = document.createElement("div");
566
+ output.appendChild(container);
567
+ return output.innerHTML;
568
+ }
569
+ };
570
+ //#endregion
571
+ //#region src/lib/rich-text-editor/rte/instance.ts
572
+ var parseDocument = (schema, doc) => {
573
+ const node = schema.topNodeType.createAndFill(null, doc ? Fragment.fromJSON(schema, doc.content) : null);
574
+ if (!node) throw new Error("Document could not be parsed");
575
+ node.check();
576
+ return node;
577
+ };
578
+ var RteInstance = class {
579
+ constructor(config, options) {
580
+ this.options = options;
581
+ this.feature = (Feature, featureId) => {
582
+ return this[impl].getPublicInterface(Feature, featureId);
583
+ };
584
+ this[impl] = new RteInstanceImpl(this, config, options);
585
+ }
586
+ /** Returns the current document state. */
587
+ getDocument() {
588
+ return this[impl].state.doc.toJSON();
589
+ }
590
+ /** Reset the editor to its initial state. Optionally, an initial document can be provided. */
591
+ reset(initialDocument) {
592
+ this[impl].reset(initialDocument);
593
+ }
594
+ /**
595
+ * Replaces the current selection with the given content.
596
+ * If no text is selected, this inserts the content at the cursor position.
597
+ */
598
+ replaceSelection(content, options) {
599
+ const { state, tr, schema, dispatchTransaction } = this[impl];
600
+ tr.replaceSelection(new Slice(Fragment.fromJSON(schema, content), 0, 0));
601
+ tr.doc.check();
602
+ const $from = tr.doc.resolve(tr.mapping.map(state.selection.from));
603
+ const $to = tr.doc.resolve(tr.selection.to);
604
+ const [$head, $anchor] = options?.cursorPlacement === "start" ? [$from, $to] : [$to, $from];
605
+ if (options?.selectContent) tr.setSelection(state.selection instanceof AllSelection ? new AllSelection(tr.doc) : TextSelection.between($anchor, $head));
606
+ else tr.setSelection(TextSelection.between($head, $head));
607
+ dispatchTransaction(tr);
608
+ }
609
+ /**
610
+ * Replaces the entire document with the given new document.
611
+ * Unlike reset, this preserves the rest of the editor state. The undo history is preserved, so the user can undo the replacement.
612
+ */
613
+ replaceDocument(newDocument, options) {
614
+ const { state, tr, schema, dispatchTransaction } = this[impl];
615
+ tr.replaceWith(0, state.doc.content.size, parseDocument(schema, newDocument));
616
+ if (options?.selectContent) tr.setSelection(new AllSelection(tr.doc));
617
+ else if (options?.cursorPlacement === "end") tr.setSelection(TextSelection.atEnd(tr.doc));
618
+ else tr.setSelection(TextSelection.atStart(tr.doc));
619
+ dispatchTransaction(tr);
620
+ }
621
+ /**
622
+ * Scrolls the cursor into view.
623
+ * Has no effect if the editor is not currently mounted.
624
+ */
625
+ scrollIntoView() {
626
+ const instance = this[impl];
627
+ if (!instance.view) return;
628
+ instance.dispatchTransaction(instance.tr.scrollIntoView());
629
+ }
630
+ };
631
+ var RteInstanceImpl = class {
632
+ getFeature(name) {
633
+ const f = this.config.featureMap.get(name);
634
+ if (!f) throw new Error(`Feature not found: ${name}`);
635
+ return f;
636
+ }
637
+ getPublicInterface(Feature, featureId) {
638
+ const instances = this.config.featureFacadesMap.get(Feature);
639
+ if (!instances || instances.length === 0) throw new Error(`Feature not found`);
640
+ if (instances[0].featureId !== void 0) {
641
+ if (featureId === void 0) throw new Error(`No featureId provided for multi-instance feature.`);
642
+ const instance = instances.find((f) => f.featureId === featureId);
643
+ if (!instance) throw new Error(`Feature with id "${featureId}" not found`);
644
+ return instance.getPublicInterface(this);
645
+ }
646
+ if (featureId !== void 0) throw new Error(`Feature does not support featureId`);
647
+ return instances[0].getPublicInterface(this);
648
+ }
649
+ constructor(instanceFacade, configFacade, options) {
650
+ this.options = options;
651
+ this.view = null;
652
+ this.dispatchTransaction = (tr) => {
653
+ const prevState = this.state;
654
+ this.state = this.state.apply(tr);
655
+ this.view?.updateState(this.state);
656
+ if (prevState.doc !== this.state.doc) this.options?.onChange?.();
657
+ return this.state;
658
+ };
659
+ this.facade = instanceFacade;
660
+ const config = configFacade[impl];
661
+ this.config = config;
662
+ this.schema = config.schema;
663
+ this.textblockAttrs = config.textblockAttrs;
664
+ this.features = config.features;
665
+ this.foreignHtmlParser = options?.foreignHtmlParser ?? new RteHtmlParser(configFacade);
666
+ this.foreignHtmlSerializer = options?.foreignHtmlSerializer ?? new RteHtmlSerializer(configFacade);
667
+ this.styles = new ElementStyles(sortedContributions(config.features.flatMap((f) => f.getStyles())));
668
+ this.initState(options?.initialDocument);
669
+ }
670
+ initState(initialDoc) {
671
+ this.state = EditorState.create({
672
+ doc: parseDocument(this.schema, initialDoc),
673
+ schema: this.config.schema,
674
+ plugins: sortedContributions(this.config.features.flatMap((feature) => feature.getPlugins(this)))
675
+ });
676
+ }
677
+ reset(initialDocument) {
678
+ const currentHostState = hostBridgePlugin.getState(this.state);
679
+ this.initState(initialDocument);
680
+ this.updateHostState(currentHostState);
681
+ this.view?.updateState(this.state);
682
+ }
683
+ createView(target) {
684
+ const core = this.config.featureMap.get("RteCore");
685
+ this.view = new EditorView((editor) => {
686
+ editor.part = "editor";
687
+ target.appendChild(editor);
688
+ }, {
689
+ state: this.state,
690
+ dispatchTransaction: this.dispatchTransaction,
691
+ ...core?.scrollThreshold !== void 0 && { scrollThreshold: core.scrollThreshold },
692
+ ...core?.scrollMargin !== void 0 && { scrollMargin: core.scrollMargin }
693
+ });
694
+ }
695
+ destroyViewIfNeeded() {
696
+ if (this.view) {
697
+ this.view.destroy();
698
+ this.view = null;
699
+ }
700
+ }
701
+ createComponent(type) {
702
+ return document.createElement(this.hostState().ctx.tagFor(type, true));
703
+ }
704
+ getLocale() {
705
+ return this.hostState().locale;
706
+ }
707
+ get tr() {
708
+ return this.state.tr;
709
+ }
710
+ hostState() {
711
+ const state = hostBridgePlugin.getState(this.state);
712
+ if (!state) throw new Error("No host state available");
713
+ return state;
714
+ }
715
+ updateHostState(hostState) {
716
+ this.dispatchTransaction(this.tr.setMeta(hostBridgePlugin, hostState));
104
717
  }
105
718
  };
106
- __decorate([observable], RichTextView.prototype, "view", void 0);
107
719
  //#endregion
108
- //#region src/lib/rich-text-view/rich-text-view.template.ts
109
- var RichTextViewTemplate = () => html`<div class="content rich-text" ${ref("_contentElement")}></div>`;
720
+ //#region src/lib/rich-text-editor/rte/utils/textblock-attrs.ts
721
+ var TextblockAttrs = class {
722
+ constructor(specs) {
723
+ this.specs = specs;
724
+ this.attrs = {};
725
+ for (const spec of specs) this.attrs[spec.name] = { default: spec.default };
726
+ }
727
+ fromDOM(dom) {
728
+ return Object.assign({}, ...this.specs.map((s) => ({ [s.name]: s.fromDOM(dom) })));
729
+ }
730
+ getStyle(node) {
731
+ return this.specs.flatMap((s) => s.toStyles(node)).join("; ");
732
+ }
733
+ getDOMAttrsProperties(node) {
734
+ if (!this.specs.length) return {};
735
+ return { style: this.getStyle(node) };
736
+ }
737
+ getDOMAttrs(node) {
738
+ if (!this.specs.length) return [];
739
+ return [this.getDOMAttrsProperties(node)];
740
+ }
741
+ extractFromNode(node) {
742
+ return Object.assign({}, ...Object.keys(this.attrs).map((attr) => ({ [attr]: node.attrs[attr] })));
743
+ }
744
+ };
745
+ //#endregion
746
+ //#region src/lib/rich-text-editor/rte/utils/textblock-marks.ts
747
+ var TextblockMarks = class {
748
+ constructor(specs) {
749
+ this.specs = specs;
750
+ }
751
+ getAllowedMarksForNode(nodeName) {
752
+ return this.specs.filter((spec) => !spec.onNodeName || spec.onNodeName === nodeName).map((spec) => spec.markName);
753
+ }
754
+ getReferencedNodeNames() {
755
+ return new Set(this.specs.map((spec) => spec.onNodeName).filter(Boolean));
756
+ }
757
+ };
758
+ //#endregion
759
+ //#region src/lib/rich-text-editor/rte/view.ts
760
+ /**
761
+ * Converts an RteDocument to an RteView tree for rendering outside the editor.
762
+ * The logic is adapted from ProseMirror's DOM serialization to ensure the resulting structure
763
+ * matches the editor's HTML structure.
764
+ */
765
+ var convertToView = (doc, ctx) => {
766
+ const schema = ctx.config[impl].schema;
767
+ const getMarkRank = (mark) => schema.marks[mark.type].rank;
768
+ const marksEqual = (a, b) => {
769
+ if (a.type !== b.type) return false;
770
+ const attrsA = a.attrs;
771
+ const attrsB = b.attrs;
772
+ if (attrsA === attrsB) return true;
773
+ /* v8 ignore next -- not currently reachable since all attrs are required @preserve */
774
+ if (!attrsA || !attrsB) return false;
775
+ const keysA = Object.keys(attrsA);
776
+ const keysB = Object.keys(attrsB);
777
+ /* v8 ignore next -- not currently reachable since all attrs are required @preserve */
778
+ if (keysA.length !== keysB.length) return false;
779
+ for (const key of keysA) if (attrsA[key] !== attrsB[key]) return false;
780
+ return true;
781
+ };
782
+ const convertFragment = (nodes) => {
783
+ const result = [];
784
+ const active = [];
785
+ const activeContents = [result];
786
+ for (const node of nodes) {
787
+ const nodeMarks = [...node.marks ?? []].sort((a, b) => getMarkRank(a) - getMarkRank(b));
788
+ let keep = 0;
789
+ let rendered = 0;
790
+ while (keep < active.length && rendered < nodeMarks.length) {
791
+ if (!marksEqual(active[keep], nodeMarks[rendered])) break;
792
+ keep++;
793
+ rendered++;
794
+ }
795
+ while (active.length > keep) {
796
+ active.pop();
797
+ activeContents.pop();
798
+ }
799
+ while (rendered < nodeMarks.length) {
800
+ const mark = nodeMarks[rendered];
801
+ const markContent = [];
802
+ activeContents[activeContents.length - 1].push({
803
+ type: "mark",
804
+ mark,
805
+ children: {
806
+ type: "fragment",
807
+ content: markContent,
808
+ [impl]: ctx
809
+ },
810
+ [impl]: ctx
811
+ });
812
+ active.push(mark);
813
+ activeContents.push(markContent);
814
+ rendered++;
815
+ }
816
+ activeContents[activeContents.length - 1].push({
817
+ type: "node",
818
+ node,
819
+ children: convertFragment(node.content ?? []),
820
+ [impl]: ctx
821
+ });
822
+ }
823
+ return {
824
+ type: "fragment",
825
+ content: result,
826
+ [impl]: ctx
827
+ };
828
+ };
829
+ return {
830
+ type: "node",
831
+ node: doc,
832
+ children: convertFragment(doc.content),
833
+ [impl]: ctx
834
+ };
835
+ };
836
+ //#endregion
837
+ //#region src/lib/rich-text-editor/rte/config.ts
838
+ var RteConfig = class {
839
+ constructor(features) {
840
+ this[impl] = new RteConfigImpl(features);
841
+ }
842
+ instantiateEditor(options) {
843
+ return new RteInstance(this, options);
844
+ }
845
+ instantiateView(document, options) {
846
+ return convertToView(document, {
847
+ config: this,
848
+ options: { ...options }
849
+ });
850
+ }
851
+ };
852
+ var RteConfigImpl = class {
853
+ constructor(featuresFacades) {
854
+ const resolveFeatures = (features) => features.flatMap((f) => f.getFeatures().flatMap((subFeature) => subFeature === f ? f : resolveFeatures([subFeature])));
855
+ this.features = resolveFeatures(featuresFacades.map(getFeatureImpl));
856
+ this.featureMap = /* @__PURE__ */ new Map();
857
+ for (const f of this.features) {
858
+ if (this.featureMap.has(f.name)) throw new Error(`Duplicate feature: ${f.name}`);
859
+ this.featureMap.set(f.name, f);
860
+ }
861
+ this.featureFacadesMap = /* @__PURE__ */ new Map();
862
+ for (const facade of featuresFacades) {
863
+ const FacadeClass = facade.constructor;
864
+ const feature = getFeatureImpl(facade);
865
+ const instances = this.featureFacadesMap.get(FacadeClass);
866
+ if (instances) instances.push(feature);
867
+ else this.featureFacadesMap.set(FacadeClass, [feature]);
868
+ }
869
+ if (!this.featureMap.has("RteBase")) throw new Error("RteBase feature is required");
870
+ if (this.featureMap.has("RteLinkFeature") && !this.featureMap.has("RteToolbarFeature")) throw new Error("RteToolbarFeature is required for RteLinkFeature");
871
+ this.textblockAttrs = new TextblockAttrs(sortedContributions(this.features.flatMap((f) => f.getTextblockAttrs())));
872
+ this.textblockMarks = new TextblockMarks(sortedContributions(this.features.flatMap((f) => f.getTextblockMarks())));
873
+ const schemaContributions = sortedContributions(this.features.flatMap((f) => f.getSchema(this.textblockAttrs, this.textblockMarks)));
874
+ const schemaSpec = {
875
+ nodes: {},
876
+ marks: {}
877
+ };
878
+ for (const schema of schemaContributions) {
879
+ Object.assign(schemaSpec.nodes, schema.nodes ?? {});
880
+ Object.assign(schemaSpec.marks, schema.marks ?? {});
881
+ }
882
+ for (const referencedNodeName of this.textblockMarks.getReferencedNodeNames()) if (!(referencedNodeName in schemaSpec.nodes)) throw new Error(`Unknown node "${referencedNodeName}"`);
883
+ this.schema = new Schema(schemaSpec);
884
+ }
885
+ };
886
+ //#endregion
887
+ //#region src/lib/rich-text-editor/rte/utils/ui.ts
888
+ var isPropBinding = (prop) => typeof prop === "function";
889
+ var on = (event, prop, handler) => [
890
+ event,
891
+ prop,
892
+ handler
893
+ ];
894
+ var UiCtx = class {
895
+ constructor(view, rte, props) {
896
+ this.view = view;
897
+ this.rte = rte;
898
+ this.props = props;
899
+ this.bindings = [];
900
+ }
901
+ /** Evaluates a prop, returning its current value. */
902
+ evalProp(prop) {
903
+ return isPropBinding(prop) ? prop(this) : prop;
904
+ }
905
+ /** On every state change, prop is re-evaluated and passed to bindFn. */
906
+ bindProp(prop, bindFn) {
907
+ if (prop === void 0) return;
908
+ else if (isPropBinding(prop)) {
909
+ const binding = () => bindFn(prop(this));
910
+ this.bindings.push(binding);
911
+ binding();
912
+ } else bindFn(prop);
913
+ }
914
+ /** To be called on each state update to refresh all bindings. */
915
+ updateBindings() {
916
+ for (const binding of this.bindings) binding();
917
+ }
918
+ /** Whether to return focus to the editor after a toolbar action */
919
+ shouldReturnFocusToEditor() {
920
+ return this.evalProp(this.props.shouldReturnFocusToEditor);
921
+ }
922
+ /** Utility to more conveniently bind props to elements */
923
+ bindToEl(target, props = {}, events = [], children = []) {
924
+ for (const name in props) this.bindProp(props[name], (value) => {
925
+ target[name] = value;
926
+ });
927
+ for (const [name, value, bindFn] of events) if (value) target.addEventListener(name, bindFn(value));
928
+ for (const child of children) target.appendChild(child);
929
+ }
930
+ };
931
+ var createDiv = (ctx, props) => {
932
+ const div = document.createElement("div");
933
+ ctx.bindToEl(div, {
934
+ className: props.className,
935
+ slot: props.slot
936
+ }, [], props.children);
937
+ return div;
938
+ };
939
+ var createAnchor = (ctx, props) => {
940
+ const anchor = document.createElement("a");
941
+ ctx.bindToEl(anchor, {
942
+ href: props.href,
943
+ target: props.target,
944
+ rel: props.rel,
945
+ className: props.className
946
+ }, [], props.children);
947
+ return anchor;
948
+ };
949
+ var wrapperTargets = /* @__PURE__ */ new WeakMap();
950
+ var createOptionalTooltip = (ctx, props) => {
951
+ const tooltip = ctx.rte.createComponent(Tooltip);
952
+ tooltip.setAttribute("exportparts", "vvd-theme-alternate");
953
+ ctx.bindToEl(tooltip, {
954
+ className: "ui-tooltip",
955
+ text: props.label,
956
+ placement: ctx.props.popupPlacement
957
+ });
958
+ ctx.bindProp(props.enabled, (enabled) => {
959
+ if (!enabled) tooltip.open = false;
960
+ tooltip.anchor = enabled ? props.anchor : void 0;
961
+ });
962
+ const wrapper = createDiv(ctx, {
963
+ className: "ui-tooltip-wrapper",
964
+ slot: props.slot,
965
+ children: [props.anchor, tooltip]
966
+ });
967
+ wrapperTargets.set(wrapper, props.anchor);
968
+ return wrapper;
969
+ };
970
+ var createButton = (ctx, props) => {
971
+ const variant = () => ctx.evalProp(props.variant) ?? "toolbar";
972
+ const size = () => variant() === "toolbar" ? "super-condensed" : "condensed";
973
+ const appearanceInactive = () => variant() === "popover-primary" ? "outlined" : "ghost-light";
974
+ const appearanceActive = () => variant() === "toolbar-menu" || variant() === "popover" ? "filled" : appearanceInactive();
975
+ const appearance = () => ctx.evalProp(props.active) ? appearanceActive() : appearanceInactive();
976
+ const connotation = () => ctx.evalProp(props.connotation) ?? (variant() === "toolbar-menu" && ctx.evalProp(props.active) ? "cta" : void 0);
977
+ const disabled = () => Boolean(ctx.evalProp(ctx.props.disabled) || ctx.evalProp(props.disabled));
978
+ const hasIcon = Boolean(props.icon ?? props.dynamicIcon);
979
+ const icon = () => {
980
+ const dynamicIcon = ctx.evalProp(props.dynamicIcon);
981
+ if (dynamicIcon !== void 0) return `${dynamicIcon}-${ctx.evalProp(props.active) ? "solid" : "line"}`;
982
+ return ctx.evalProp(props.icon);
983
+ };
984
+ const button = ctx.rte.createComponent(Button);
985
+ ctx.bindToEl(button, {
986
+ size,
987
+ appearance,
988
+ disabled,
989
+ icon,
990
+ autofocus: props.autofocus,
991
+ connotation,
992
+ [hasIcon ? "ariaLabel" : "label"]: props.label,
993
+ pressed: () => Boolean(ctx.evalProp(props.active)),
994
+ ariaPressed: props.active !== void 0 ? () => ctx.evalProp(props.active) ? "true" : "false" : void 0
995
+ }, [on("click", props.onClick, (onClick) => () => {
996
+ if (!onClick() && ctx.shouldReturnFocusToEditor()) ctx.view.focus();
997
+ })]);
998
+ return createOptionalTooltip(ctx, {
999
+ enabled: () => hasIcon && !ctx.evalProp(props.noTooltip) && !disabled(),
1000
+ label: props.label,
1001
+ anchor: button,
1002
+ slot: props.slot
1003
+ });
1004
+ };
1005
+ var createMenu = (ctx, props) => {
1006
+ const menu = ctx.rte.createComponent(Menu);
1007
+ ctx.bindToEl(menu, {
1008
+ className: "ui-menu",
1009
+ autoDismiss: true,
1010
+ ariaLabel: props.label,
1011
+ anchor: wrapperTargets.get(props.trigger) ?? props.trigger,
1012
+ placement: ctx.props.popupPlacement,
1013
+ offset: () => ctx.evalProp(ctx.props.menuOffset) ?? null
1014
+ }, [], props.children);
1015
+ const fragment = document.createDocumentFragment();
1016
+ fragment.appendChild(props.trigger);
1017
+ fragment.appendChild(menu);
1018
+ return fragment;
1019
+ };
1020
+ var createMenuItem = (ctx, props) => {
1021
+ const disabled = () => Boolean(ctx.evalProp(ctx.props.disabled) || ctx.evalProp(props.disabled));
1022
+ const item = ctx.rte.createComponent(MenuItem);
1023
+ ctx.bindToEl(item, {
1024
+ text: props.text,
1025
+ checked: props.checked,
1026
+ disabled,
1027
+ controlType: "radio",
1028
+ checkedAppearance: "tick-only"
1029
+ }, [on("change", props.onSelect, (onSelect) => () => {
1030
+ if (item.checked && !item.disabled) {
1031
+ if (ctx.evalProp(props.checked) !== item.checked) {
1032
+ onSelect();
1033
+ if (ctx.shouldReturnFocusToEditor()) ctx.view.focus();
1034
+ }
1035
+ }
1036
+ })]);
1037
+ return item;
1038
+ };
1039
+ var createButtonGroup = (ctx, props) => createDiv(ctx, {
1040
+ slot: props.slot,
1041
+ className: "ui-button-group",
1042
+ children: props.children
1043
+ });
1044
+ function markActive(state, type) {
1045
+ const { from, $from, to, empty } = state.selection;
1046
+ if (empty) return !!type.isInSet(state.storedMarks || $from.marks());
1047
+ else return state.doc.rangeHasMark(from, to, type);
1048
+ }
1049
+ var createMarkToggle = (ctx, props) => createButton(ctx, {
1050
+ label: props.label,
1051
+ dynamicIcon: props.dynamicIcon,
1052
+ active: () => markActive(ctx.view.state, props.markType),
1053
+ disabled: () => !toggleMark(props.markType)(ctx.view.state),
1054
+ onClick: () => {
1055
+ toggleMark(props.markType)(ctx.view.state, ctx.view.dispatch);
1056
+ }
1057
+ });
1058
+ var createOption = (ctx, props) => {
1059
+ const disabled = () => Boolean(ctx.evalProp(ctx.props.disabled) || ctx.evalProp(props.disabled));
1060
+ const option = ctx.rte.createComponent(ListboxOption);
1061
+ ctx.bindToEl(option, {
1062
+ value: props.value,
1063
+ text: props.text,
1064
+ disabled
1065
+ });
1066
+ return option;
1067
+ };
1068
+ var createSelect = (ctx, props) => {
1069
+ const disabled = () => Boolean(ctx.evalProp(ctx.props.disabled));
1070
+ const select = ctx.rte.createComponent(Select);
1071
+ select.setAttribute("data-class", "ui-select");
1072
+ ctx.bindToEl(select, {
1073
+ placeholder: " ",
1074
+ ariaLabel: props.label,
1075
+ appearance: "ghost",
1076
+ disabled
1077
+ }, [on("change", props.onSelect, (onSelect) => () => {
1078
+ const value = select.value;
1079
+ if (value) {
1080
+ onSelect(value);
1081
+ if (ctx.shouldReturnFocusToEditor()) ctx.view.focus();
1082
+ }
1083
+ })], props.children);
1084
+ queueMicrotask(() => {
1085
+ ctx.bindProp(props.value, (value) => select.value = value);
1086
+ });
1087
+ let hideTooltip = false;
1088
+ select.addEventListener("vwc-popup:open", () => {
1089
+ hideTooltip = true;
1090
+ ctx.updateBindings();
1091
+ });
1092
+ select.addEventListener("vwc-popup:close", () => {
1093
+ hideTooltip = false;
1094
+ ctx.updateBindings();
1095
+ });
1096
+ return createOptionalTooltip(ctx, {
1097
+ enabled: () => !hideTooltip && !disabled(),
1098
+ label: props.label,
1099
+ anchor: select
1100
+ });
1101
+ };
1102
+ var createDivider = (ctx) => {
1103
+ const divider = ctx.rte.createComponent(Divider);
1104
+ ctx.bindToEl(divider, {
1105
+ className: "ui-divider",
1106
+ orientation: "vertical"
1107
+ });
1108
+ return divider;
1109
+ };
1110
+ var createTextField = (ctx, props) => {
1111
+ const textField = ctx.rte.createComponent(TextField);
1112
+ ctx.bindToEl(textField, {
1113
+ label: props.label,
1114
+ value: props.value,
1115
+ placeholder: props.placeholder,
1116
+ slot: props.slot,
1117
+ autofocus: props.autofocus,
1118
+ type: props.type,
1119
+ helperText: props.helperText
1120
+ }, [on("input", props.onInput, (onInput) => () => {
1121
+ onInput(textField.value);
1122
+ })]);
1123
+ return textField;
1124
+ };
1125
+ var createText = (ctx, props) => {
1126
+ const textNode = document.createTextNode("");
1127
+ ctx.bindToEl(textNode, { textContent: props.text });
1128
+ return textNode;
1129
+ };
1130
+ var createSingleSlot = (ctx, props) => {
1131
+ const slot = document.createElement("slot");
1132
+ slot.name = props.name;
1133
+ let currentEl = null;
1134
+ const listeners = [];
1135
+ function cleanup() {
1136
+ for (const { el, type, handler } of listeners) el.removeEventListener(type, handler);
1137
+ listeners.length = 0;
1138
+ currentEl = null;
1139
+ }
1140
+ for (const [key, prop] of Object.entries(props.assignedProps)) ctx.bindProp(prop, (value) => {
1141
+ if (currentEl) currentEl[key] = value;
1142
+ });
1143
+ function applyPropsAndEvents(el) {
1144
+ for (const [key, prop] of Object.entries(props.assignedProps)) el[key] = ctx.evalProp(prop);
1145
+ for (const [type, handler] of Object.entries(props.assignedEvents)) {
1146
+ const listener = (e) => {
1147
+ handler(e);
1148
+ if (ctx.shouldReturnFocusToEditor()) ctx.view.focus();
1149
+ };
1150
+ el.addEventListener(type, listener);
1151
+ listeners.push({
1152
+ el,
1153
+ type,
1154
+ handler: listener
1155
+ });
1156
+ }
1157
+ }
1158
+ const processSlot = () => {
1159
+ const first = slot.assignedElements({ flatten: true })[0];
1160
+ if (first === currentEl) return;
1161
+ cleanup();
1162
+ if (first) {
1163
+ currentEl = first;
1164
+ applyPropsAndEvents(first);
1165
+ }
1166
+ };
1167
+ slot.addEventListener("slotchange", processSlot);
1168
+ queueMicrotask(processSlot);
1169
+ return slot;
1170
+ };
1171
+ //#endregion
1172
+ //#region src/lib/rich-text-editor/rte/features/internal/history.ts
1173
+ var RteHistoryFeatureImpl = class extends RteFeatureImpl {
1174
+ constructor(config) {
1175
+ super();
1176
+ this.config = config;
1177
+ this.name = "RteHistoryFeature";
1178
+ }
1179
+ getPlugins() {
1180
+ return [this.contribution(history()), this.contribution(keymap({
1181
+ "Mod-z": undo,
1182
+ "Ctrl-y": redo,
1183
+ "Cmd-Z": redo
1184
+ }))];
1185
+ }
1186
+ getToolbarItems() {
1187
+ if (!this.config.showToolbarButtons) return [];
1188
+ return [this.contribution({
1189
+ section: "history",
1190
+ render: (ctx) => createButton(ctx, {
1191
+ label: (ctx) => ctx.rte.getLocale().richTextEditor.undo,
1192
+ icon: "undo-line",
1193
+ disabled: (ctx) => !undo(ctx.view.state),
1194
+ onClick: () => {
1195
+ const { state, dispatch } = ctx.view;
1196
+ undo(state, dispatch);
1197
+ }
1198
+ })
1199
+ }, 1), this.contribution({
1200
+ section: "history",
1201
+ render: (ctx) => createButton(ctx, {
1202
+ label: (ctx) => ctx.rte.getLocale().richTextEditor.redo,
1203
+ icon: "redo-line",
1204
+ disabled: (ctx) => !redo(ctx.view.state),
1205
+ onClick: () => {
1206
+ const { state, dispatch } = ctx.view;
1207
+ redo(state, dispatch);
1208
+ }
1209
+ })
1210
+ }, 2)];
1211
+ }
1212
+ };
1213
+ //#endregion
1214
+ //#region src/lib/rich-text-editor/rte/features/internal/basic-text-blocks.style.scss?inline
1215
+ var basic_text_blocks_style_default = "h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:16px;line-height:20px}.heading-step-1{font:var(--vvd-typography-heading-4);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:28px}.heading-step-2{font:var(--vvd-typography-heading-3);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:36px}.heading-step-3{font:var(--vvd-typography-heading-2);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:32px 16px;line-height:42px}";
1216
+ //#endregion
1217
+ //#region src/lib/rich-text-editor/rte/features/internal/basic-text-blocks.ts
1218
+ var RteBasicTextBlocksImpl = class extends RteFeatureImpl {
1219
+ constructor(enabledBlocks) {
1220
+ super();
1221
+ this.enabledBlocks = enabledBlocks;
1222
+ this.name = "RteBasicTextBlocks";
1223
+ }
1224
+ getStyles() {
1225
+ return [this.contribution(basic_text_blocks_style_default)];
1226
+ }
1227
+ getSchema(textblockAttrs, textblockMarks) {
1228
+ const nodes = {};
1229
+ if (this.enabledBlocks.paragraph) nodes["paragraph"] = {
1230
+ group: "block",
1231
+ content: "inline*",
1232
+ attrs: { ...textblockAttrs.attrs },
1233
+ parseDOM: [{
1234
+ tag: "p",
1235
+ getAttrs: (dom) => textblockAttrs.fromDOM(dom)
1236
+ }],
1237
+ marks: textblockMarks.getAllowedMarksForNode("paragraph").join(" "),
1238
+ toDOM(node) {
1239
+ return [
1240
+ "p",
1241
+ {
1242
+ part: `node--paragraph`,
1243
+ ...textblockAttrs.getDOMAttrsProperties(node)
1244
+ },
1245
+ 0
1246
+ ];
1247
+ },
1248
+ serializeToDOM(node) {
1249
+ return [
1250
+ "p",
1251
+ ...textblockAttrs.getDOMAttrs(node),
1252
+ 0
1253
+ ];
1254
+ }
1255
+ };
1256
+ let headingCount = 0;
1257
+ for (const level of [
1258
+ 3,
1259
+ 2,
1260
+ 1
1261
+ ]) {
1262
+ const nodeName = `heading${level}`;
1263
+ const tag = `h${level}`;
1264
+ if (!this.enabledBlocks[nodeName]) continue;
1265
+ headingCount++;
1266
+ const visualLevel = headingCount;
1267
+ nodes[nodeName] = {
1268
+ group: "block",
1269
+ content: "inline*",
1270
+ attrs: { ...textblockAttrs.attrs },
1271
+ parseDOM: [{
1272
+ tag,
1273
+ getAttrs: (dom) => textblockAttrs.fromDOM(dom)
1274
+ }],
1275
+ marks: textblockMarks.getAllowedMarksForNode(nodeName).join(" "),
1276
+ defining: true,
1277
+ toDOM(node) {
1278
+ return [
1279
+ tag,
1280
+ {
1281
+ class: `heading-step-${visualLevel}`,
1282
+ part: `node--${nodeName}`,
1283
+ ...textblockAttrs.getDOMAttrsProperties(node)
1284
+ },
1285
+ 0
1286
+ ];
1287
+ },
1288
+ serializeToDOM(node) {
1289
+ return [
1290
+ tag,
1291
+ ...textblockAttrs.getDOMAttrs(node),
1292
+ 0
1293
+ ];
1294
+ }
1295
+ };
1296
+ }
1297
+ return [this.contribution({ nodes })];
1298
+ }
1299
+ getPlugins(rte) {
1300
+ const keyBindings = {};
1301
+ if (this.enabledBlocks.paragraph) keyBindings["Mod-Alt-0"] = this.setBlockType(rte, "paragraph");
1302
+ for (const level of [
1303
+ 1,
1304
+ 2,
1305
+ 3
1306
+ ]) {
1307
+ const nodeName = `heading${level}`;
1308
+ if (this.enabledBlocks[nodeName]) keyBindings[`Mod-Alt-${level}`] = this.setBlockType(rte, nodeName);
1309
+ }
1310
+ return [this.contribution(keymap(keyBindings))];
1311
+ }
1312
+ getCurrentBlockType(state) {
1313
+ const { $from, $to } = state.selection;
1314
+ const fromTopBlock = $from.depth === 0 ? state.doc.childAfter($from.pos).node : $from.node(1);
1315
+ if (fromTopBlock !== ($to.depth === 0 ? state.doc.childBefore($to.pos).node : $to.node(1))) return null;
1316
+ if (!(fromTopBlock.type.name in this.enabledBlocks)) return null;
1317
+ return fromTopBlock.type.name;
1318
+ }
1319
+ setBlockType(rte, name) {
1320
+ return (state, dispatch) => {
1321
+ const { from, to } = state.selection;
1322
+ const tr = state.tr;
1323
+ let supportedNodeFound = false;
1324
+ state.doc.nodesBetween(from, to, (node, pos) => {
1325
+ if (node.type.name in this.enabledBlocks) {
1326
+ supportedNodeFound = true;
1327
+ tr.setBlockType(pos, pos + node.nodeSize, state.schema.nodes[name], (oldNode) => rte.textblockAttrs.extractFromNode(oldNode));
1328
+ }
1329
+ return false;
1330
+ });
1331
+ if (!supportedNodeFound) return false;
1332
+ dispatch?.(tr);
1333
+ return true;
1334
+ };
1335
+ }
1336
+ };
1337
+ //#endregion
1338
+ //#region src/lib/rich-text-editor/rte/utils/text-before-cursor.ts
1339
+ /** Get the text content before the cursor position in the current text block. */
1340
+ var textBeforeCursor = ($cursor) => $cursor.parent.textBetween(0, $cursor.parentOffset, void 0, "");
1341
+ //#endregion
1342
+ //#region src/lib/rich-text-editor/rte/features/internal/input-rules.ts
1343
+ /** Aggregates all input rules from other features. */
1344
+ var RteInputRulesFeatureImpl = class extends RteFeatureImpl {
1345
+ constructor(..._args) {
1346
+ super(..._args);
1347
+ this.name = "RteInputRulesFeature";
1348
+ }
1349
+ getPlugins(rte) {
1350
+ const ruleSpecs = sortedContributions(rte.config.features.flatMap((f) => f.getInputRules(rte)));
1351
+ if (ruleSpecs.length === 0) return [];
1352
+ const plugins = [];
1353
+ const rules = ruleSpecs.map((spec) => spec.rule);
1354
+ plugins.push(this.contribution(inputRules({ rules })));
1355
+ plugins.push(this.contribution(keymap({ Backspace: undoInputRule }), contributionPriority.high));
1356
+ const enterHandlers = ruleSpecs.filter((spec) => spec.enterHandler).map((spec) => spec.enterHandler);
1357
+ if (enterHandlers.length > 0) plugins.push(this.contribution(keymap({ Enter: (state, dispatch) => {
1358
+ const { $cursor } = state.selection;
1359
+ if (!$cursor) return false;
1360
+ const textBefore = textBeforeCursor($cursor);
1361
+ for (const { regex, handler } of enterHandlers) {
1362
+ const match = regex.exec(textBefore);
1363
+ if (!match) continue;
1364
+ const matchStart = $cursor.pos - $cursor.parentOffset + match.index;
1365
+ const tr = handler(state, match, matchStart, matchStart + match[0].length);
1366
+ if (tr) dispatch?.(tr);
1367
+ break;
1368
+ }
1369
+ return false;
1370
+ } }), contributionPriority.highest));
1371
+ return plugins;
1372
+ }
1373
+ };
1374
+ //#endregion
1375
+ //#region src/lib/rich-text-editor/rte/features/base.ts
1376
+ var RteBaseImpl = class extends RteFeatureImpl {
1377
+ constructor(config) {
1378
+ super();
1379
+ this.config = config;
1380
+ this.name = "RteBase";
1381
+ }
1382
+ getSchema() {
1383
+ return [this.contribution({ nodes: {
1384
+ doc: { content: this.config?.singleBlock ? "block" : "block+" },
1385
+ text: { group: "inline" }
1386
+ } })];
1387
+ }
1388
+ getFeatures() {
1389
+ return [
1390
+ this,
1391
+ new RteCoreImpl(),
1392
+ new RteHistoryFeatureImpl({ showToolbarButtons: this.config?.historyToolbarButtons ?? true }),
1393
+ new RteBasicTextBlocksImpl({
1394
+ heading1: this.config?.heading1 ?? false,
1395
+ heading2: this.config?.heading2 ?? false,
1396
+ heading3: this.config?.heading3 ?? false,
1397
+ paragraph: this.config?.paragraph ?? true
1398
+ }),
1399
+ new RteInputRulesFeatureImpl()
1400
+ ];
1401
+ }
1402
+ getPublicInterface(rte) {
1403
+ const core = rte.getFeature("RteCore");
1404
+ return {
1405
+ get disabled() {
1406
+ return core.disabled.getValue(rte);
1407
+ },
1408
+ set disabled(value) {
1409
+ core.disabled.setValue(rte, value);
1410
+ },
1411
+ get scrollThreshold() {
1412
+ return core.scrollThreshold;
1413
+ },
1414
+ set scrollThreshold(value) {
1415
+ core.scrollThreshold = value;
1416
+ rte.view?.setProps({ scrollThreshold: value });
1417
+ },
1418
+ get scrollMargin() {
1419
+ return core.scrollMargin;
1420
+ },
1421
+ set scrollMargin(value) {
1422
+ core.scrollMargin = value;
1423
+ rte.view?.setProps({ scrollMargin: value });
1424
+ }
1425
+ };
1426
+ }
1427
+ };
1428
+ var RteBase = featureFacade(RteBaseImpl);
1429
+ //#endregion
1430
+ //#region src/lib/rich-text-editor/rte/features/text-block-picker.ts
1431
+ var RteTextBlockPickerFeatureImpl = class extends RteFeatureImpl {
1432
+ constructor(config) {
1433
+ super();
1434
+ this.config = config;
1435
+ this.name = "RteTextBlockPickerFeature";
1436
+ }
1437
+ getToolbarItems(rte) {
1438
+ const blocks = rte.getFeature("RteBasicTextBlocks");
1439
+ return [this.contribution({
1440
+ section: "font",
1441
+ render: (ctx) => {
1442
+ return createSelect(ctx, {
1443
+ label: () => ctx.rte.getLocale().richTextEditor.paragraphStyles,
1444
+ value: (ctx) => blocks.getCurrentBlockType(ctx.view.state) ?? "",
1445
+ onSelect: (value) => {
1446
+ const { state, dispatch } = ctx.view;
1447
+ blocks.setBlockType(rte, value)(state, dispatch);
1448
+ },
1449
+ children: this.config.options.map((opt) => createOption(ctx, {
1450
+ text: opt.label,
1451
+ value: opt.node,
1452
+ disabled: () => !blocks.setBlockType(rte, opt.node)(ctx.view.state)
1453
+ }))
1454
+ });
1455
+ }
1456
+ }, 1)];
1457
+ }
1458
+ };
1459
+ var RteTextBlockPickerFeature = featureFacade(RteTextBlockPickerFeatureImpl);
1460
+ //#endregion
1461
+ //#region src/lib/rich-text-editor/rte/features/toolbar.style.scss?inline
1462
+ var toolbar_style_default = ".toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}";
1463
+ //#endregion
1464
+ //#region src/lib/rich-text-editor/rte/features/toolbar.ts
1465
+ var RteToolbarFeatureImpl = class extends RteFeatureImpl {
1466
+ constructor(config) {
1467
+ super();
1468
+ this.config = config;
1469
+ this.name = "RteToolbarFeature";
1470
+ this.hidden = new FeatureState(false);
1471
+ }
1472
+ getStyles() {
1473
+ return [this.contribution(toolbar_style_default)];
1474
+ }
1475
+ getPlugins(rte) {
1476
+ const sections = [
1477
+ "history",
1478
+ "font",
1479
+ "text-style",
1480
+ "textblock",
1481
+ "insert"
1482
+ ];
1483
+ const itemsBySection = new Map(sections.map((section) => [section, []]));
1484
+ for (const toolbarItem of sortedContributions(rte.features.flatMap((f) => f.getToolbarItems(rte)))) itemsBySection.get(toolbarItem.section).push(toolbarItem);
1485
+ const core = rte.getFeature("RteCore");
1486
+ return [this.contribution(this.hidden.plugin), this.contribution(new Plugin({ view: (view) => {
1487
+ let focusCameFromEditorWithMouse = false;
1488
+ const ctx = new UiCtx(view, rte, {
1489
+ popupPlacement: this.config?.popupDirection === "outward" ? "bottom" : "top",
1490
+ menuOffset: 8,
1491
+ disabled: () => core.disabled.getValue(rte),
1492
+ shouldReturnFocusToEditor: () => focusCameFromEditorWithMouse
1493
+ });
1494
+ const toolbar = view.dom.getRootNode().querySelector(".toolbar");
1495
+ let mouseDownTime = -Infinity;
1496
+ const onMouseDown = () => {
1497
+ if (view.hasFocus()) focusCameFromEditorWithMouse = true;
1498
+ mouseDownTime = Date.now();
1499
+ };
1500
+ const onFocusIn = () => {
1501
+ if (Date.now() - mouseDownTime > 250) focusCameFromEditorWithMouse = false;
1502
+ };
1503
+ const onFocusOut = (e) => {
1504
+ if (!toolbar.contains(e.relatedTarget)) focusCameFromEditorWithMouse = false;
1505
+ };
1506
+ toolbar.addEventListener("mousedown", onMouseDown, { capture: true });
1507
+ toolbar.addEventListener("focusin", onFocusIn);
1508
+ toolbar.addEventListener("focusout", onFocusOut);
1509
+ ctx.bindProp(() => this.hidden.getValue(rte), (hidden) => {
1510
+ toolbar.classList.toggle("toolbar--hidden", hidden);
1511
+ });
1512
+ let openSection = false;
1513
+ for (const section of sections) {
1514
+ const items = itemsBySection.get(section);
1515
+ if (items.length && openSection) {
1516
+ toolbar.appendChild(createDivider(ctx));
1517
+ openSection = false;
1518
+ }
1519
+ for (const toolbarItemSpec of items) {
1520
+ toolbar.appendChild(toolbarItemSpec.render(ctx));
1521
+ openSection = true;
1522
+ }
1523
+ }
1524
+ return {
1525
+ update() {
1526
+ ctx.updateBindings();
1527
+ },
1528
+ destroy() {
1529
+ toolbar.innerHTML = "";
1530
+ toolbar.removeEventListener("mousedown", onMouseDown, { capture: true });
1531
+ toolbar.removeEventListener("focusin", onFocusIn);
1532
+ toolbar.removeEventListener("focusout", onFocusOut);
1533
+ focusCameFromEditorWithMouse = false;
1534
+ }
1535
+ };
1536
+ } }))];
1537
+ }
1538
+ getPublicInterface(rte) {
1539
+ const hidden = this.hidden;
1540
+ return {
1541
+ get hidden() {
1542
+ return hidden.getValue(rte);
1543
+ },
1544
+ set hidden(value) {
1545
+ hidden.setValue(rte, value);
1546
+ }
1547
+ };
1548
+ }
1549
+ };
1550
+ var RteToolbarFeature = featureFacade(RteToolbarFeatureImpl);
1551
+ //#endregion
1552
+ //#region src/lib/rich-text-editor/rte/features/placeholder.style.scss?inline
1553
+ var placeholder_style_default = ".placeholder{display:contents}.placeholder:before{color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size,inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none;position:absolute}.editor--disabled .placeholder:before{color:var(--vvd-color-neutral-300)}";
1554
+ //#endregion
1555
+ //#region src/lib/rich-text-editor/rte/features/placeholder.ts
1556
+ var RtePlaceholderFeatureImpl = class extends RteFeatureImpl {
1557
+ constructor(config) {
1558
+ super();
1559
+ this.config = config;
1560
+ this.name = "RtePlaceholderFeature";
1561
+ }
1562
+ getStyles() {
1563
+ return [this.contribution(placeholder_style_default)];
1564
+ }
1565
+ getPlugins() {
1566
+ const placeholderPlugin = new Plugin({ props: { decorations: (state) => {
1567
+ if (state.doc.nodeSize === 4) {
1568
+ const storedSize = state.schema.marks.fontSize?.isInSet(state.storedMarks ?? [])?.attrs.size;
1569
+ return DecorationSet.create(state.doc, [Decoration.widget(1, () => {
1570
+ const placeholder = document.createElement("span");
1571
+ placeholder.className = "placeholder";
1572
+ placeholder.dataset.placeholder = this.config.text;
1573
+ if (storedSize) placeholder.style.setProperty("--placeholder-font-size", storedSize);
1574
+ return placeholder;
1575
+ })]);
1576
+ }
1577
+ return null;
1578
+ } } });
1579
+ return [this.contribution(placeholderPlugin)];
1580
+ }
1581
+ };
1582
+ var RtePlaceholderFeature = featureFacade(RtePlaceholderFeatureImpl);
1583
+ //#endregion
1584
+ //#region src/lib/rich-text-editor/rte/features/hard-break.ts
1585
+ var RteHardBreakFeatureImpl = class extends RteFeatureImpl {
1586
+ constructor(..._args) {
1587
+ super(..._args);
1588
+ this.name = "RteHardBreakFeature";
1589
+ }
1590
+ getSchema() {
1591
+ return [this.contribution({ nodes: { hardBreak: {
1592
+ inline: true,
1593
+ group: "inline",
1594
+ selectable: false,
1595
+ parseDOM: [{ tag: "br" }],
1596
+ toDOM() {
1597
+ return ["br"];
1598
+ }
1599
+ } } })];
1600
+ }
1601
+ getPlugins(_rte) {
1602
+ const forceBreak = (state, dispatch) => {
1603
+ const marks = state.storedMarks || state.selection.$from.marks();
1604
+ const tr = state.tr.replaceSelectionWith(state.schema.nodes.hardBreak.create(), true).scrollIntoView();
1605
+ if (marks.length) tr.setStoredMarks(marks);
1606
+ dispatch?.(tr);
1607
+ return true;
1608
+ };
1609
+ const keyBindings = { "Shift-Enter": forceBreak };
1610
+ return [this.contribution(keymap(keyBindings), contributionPriority.high)];
1611
+ }
1612
+ };
1613
+ var RteHardBreakFeature = featureFacade(RteHardBreakFeatureImpl);
1614
+ //#endregion
1615
+ //#region src/lib/rich-text-editor/rte/features/font-size-picker.ts
1616
+ var mixedFontSize = Symbol("mixedFontSize");
1617
+ var RteFontSizePickerFeatureImpl = class extends RteFeatureImpl {
1618
+ constructor(config) {
1619
+ super();
1620
+ this.config = config;
1621
+ this.name = "RteFontSizePickerFeature";
1622
+ this.fontSizes = config.options;
1623
+ if (config.onBlocks) {
1624
+ this.defaultFontSizeForNode = {};
1625
+ for (const block of config.onBlocks) this.defaultFontSizeForNode[block.node] = block.defaultSize ?? null;
1626
+ }
1627
+ }
1628
+ getTextblockMarks() {
1629
+ if (this.config?.onBlocks) return this.config.onBlocks.map((block) => this.contribution({
1630
+ markName: "fontSize",
1631
+ onNodeName: block.node
1632
+ }));
1633
+ return [this.contribution({ markName: "fontSize" })];
1634
+ }
1635
+ getSchema() {
1636
+ return [this.contribution({ marks: { fontSize: {
1637
+ attrs: { size: { validate: "string" } },
1638
+ parseDOM: [{
1639
+ tag: "span[style*='font-size']",
1640
+ getAttrs: (node) => {
1641
+ const size = node.getAttribute("style").match(/font-size:\s*([^;]+)/)?.[1]?.trim();
1642
+ if (size) return { size };
1643
+ return false;
1644
+ }
1645
+ }],
1646
+ toDOM: (mark) => {
1647
+ return [
1648
+ "span",
1649
+ { style: `font-size: ${escapeCssProperty(mark.attrs.size)};` },
1650
+ 0
1651
+ ];
1652
+ },
1653
+ cursorFix: ($cursor, state) => {
1654
+ const storedMarks = state.storedMarks;
1655
+ if (!storedMarks) return null;
1656
+ const fontSizeMark = storedMarks.find((m) => m.type.name === "fontSize");
1657
+ if (fontSizeMark) return { style: { "font-size": fontSizeMark.attrs.size } };
1658
+ if (storedMarks.length === 0) {
1659
+ const defaultSize = this.defaultFontSizeForNode?.[$cursor.parent.type.name];
1660
+ if (defaultSize) return { style: { "font-size": defaultSize } };
1661
+ }
1662
+ return null;
1663
+ }
1664
+ } } })];
1665
+ }
1666
+ getPlugins() {
1667
+ return [this.contribution(keymap({
1668
+ "Mod-Shift-.": this.adjustFontSize(-1),
1669
+ "Mod-Shift-,": this.adjustFontSize(1)
1670
+ }))];
1671
+ }
1672
+ getToolbarItems(rte) {
1673
+ return [this.contribution({
1674
+ section: "font",
1675
+ render: (ctx) => createMenu(ctx, {
1676
+ label: () => rte.getLocale().richTextEditor.textSize,
1677
+ trigger: createButton(ctx, {
1678
+ label: () => rte.getLocale().richTextEditor.textSize,
1679
+ icon: "text-size-line"
1680
+ }),
1681
+ children: this.fontSizes.map((fs) => createMenuItem(ctx, {
1682
+ text: fs.label,
1683
+ checked: () => this.getFontSizeFromSelection(ctx.view.state) === fs.size,
1684
+ disabled: () => !this.setFontSize(fs.size)(ctx.view.state),
1685
+ onSelect: () => {
1686
+ const { state, dispatch } = ctx.view;
1687
+ this.setFontSize(fs.size)(state, dispatch);
1688
+ }
1689
+ }))
1690
+ })
1691
+ }, 2)];
1692
+ }
1693
+ getFontSizeFromSelection(state) {
1694
+ const { from, to, $from, empty } = state.selection;
1695
+ const { fontSize } = state.schema.marks;
1696
+ if (empty) {
1697
+ const defaultSize = this.defaultFontSizeForNode?.[$from.parent.type.name] ?? null;
1698
+ return fontSize.isInSet(state.storedMarks || $from.marks())?.attrs.size ?? defaultSize;
1699
+ }
1700
+ let size = null;
1701
+ const observeSize = (observedSize) => {
1702
+ if (size === null) size = observedSize ?? null;
1703
+ else if (observedSize !== size) size = mixedFontSize;
1704
+ };
1705
+ state.doc.nodesBetween(from, to, (node, _, parent) => {
1706
+ if (size === mixedFontSize) return false;
1707
+ if (!node.isLeaf) {
1708
+ if (node.type.allowsMarkType(fontSize) && node.childCount === 0) observeSize(this.defaultFontSizeForNode?.[node.type.name]);
1709
+ return true;
1710
+ }
1711
+ observeSize(fontSize.isInSet(node.marks)?.attrs.size ?? (parent && this.defaultFontSizeForNode?.[parent.type.name]));
1712
+ return true;
1713
+ });
1714
+ return size;
1715
+ }
1716
+ setFontSize(size) {
1717
+ return (state, dispatch) => {
1718
+ const { from, to, empty, $from } = state.selection;
1719
+ const { fontSize } = state.schema.marks;
1720
+ if (!toggleMark(fontSize, { size })(state)) return false;
1721
+ const tr = state.tr;
1722
+ if (empty) {
1723
+ const newStoredMarks = (state.storedMarks || []).filter((m) => m.type !== fontSize);
1724
+ if (size !== this.defaultFontSizeForNode?.[$from.parent.type.name]) newStoredMarks.push(fontSize.create({ size }));
1725
+ tr.setStoredMarks(newStoredMarks);
1726
+ } else {
1727
+ tr.addMark(from, to, fontSize.create({ size }));
1728
+ tr.doc.nodesBetween(from, to, (node, pos, parent) => {
1729
+ if (!node.isInline) return;
1730
+ const mark = fontSize.isInSet(node.marks);
1731
+ const defaultSize = this.defaultFontSizeForNode?.[parent.type.name];
1732
+ if (mark && mark.attrs.size === defaultSize) tr.step(new RemoveMarkStep(pos, pos + node.nodeSize, mark));
1733
+ });
1734
+ }
1735
+ dispatch?.(tr.scrollIntoView());
1736
+ return true;
1737
+ };
1738
+ }
1739
+ adjustFontSize(adjustment) {
1740
+ return (state, dispatch) => {
1741
+ const currentSize = this.getFontSizeFromSelection(state);
1742
+ if (currentSize === null || currentSize === mixedFontSize) return false;
1743
+ const nextIndex = this.fontSizes.findIndex((fs) => fs.size === currentSize) + adjustment;
1744
+ if (nextIndex < 0 || nextIndex >= this.fontSizes.length) return false;
1745
+ return this.setFontSize(this.fontSizes[nextIndex].size)(state, dispatch);
1746
+ };
1747
+ }
1748
+ };
1749
+ var RteFontSizePickerFeature = featureFacade(RteFontSizePickerFeatureImpl);
1750
+ //#endregion
1751
+ //#region src/lib/rich-text-editor/rte/features/internal/text-style.ts
1752
+ var RteTextStyleFeatureImpl = class extends RteFeatureImpl {
1753
+ constructor(config) {
1754
+ super();
1755
+ this.config = config;
1756
+ }
1757
+ getTextblockMarks() {
1758
+ if (this.config?.onBlocks) return this.config.onBlocks.map((block) => this.contribution({
1759
+ markName: this.markName,
1760
+ onNodeName: block.node
1761
+ }));
1762
+ return [this.contribution({ markName: this.markName })];
1763
+ }
1764
+ };
1765
+ //#endregion
1766
+ //#region src/lib/rich-text-editor/rte/features/bold.ts
1767
+ var RteBoldFeatureImpl = class extends RteTextStyleFeatureImpl {
1768
+ constructor(..._args) {
1769
+ super(..._args);
1770
+ this.name = "RteBoldFeature";
1771
+ this.markName = "bold";
1772
+ }
1773
+ getSchema() {
1774
+ return [this.contribution({ marks: { bold: marks.strong } })];
1775
+ }
1776
+ getPlugins(rte) {
1777
+ return [this.contribution(keymap({ "Mod-b": toggleMark(rte.schema.marks.bold) }))];
1778
+ }
1779
+ getToolbarItems(rte) {
1780
+ return [this.contribution({
1781
+ section: "text-style",
1782
+ render: (ctx) => createMarkToggle(ctx, {
1783
+ label: () => ctx.rte.getLocale().richTextEditor.bold,
1784
+ dynamicIcon: "bold",
1785
+ markType: rte.schema.marks.bold
1786
+ })
1787
+ }, 1)];
1788
+ }
1789
+ };
1790
+ var RteBoldFeature = featureFacade(RteBoldFeatureImpl);
1791
+ //#endregion
1792
+ //#region src/lib/rich-text-editor/rte/features/italic.ts
1793
+ var RteItalicFeatureImpl = class extends RteTextStyleFeatureImpl {
1794
+ constructor(..._args) {
1795
+ super(..._args);
1796
+ this.name = "RteItalicFeature";
1797
+ this.markName = "italic";
1798
+ }
1799
+ getSchema() {
1800
+ return [this.contribution({ marks: { italic: marks.em } })];
1801
+ }
1802
+ getPlugins(rte) {
1803
+ return [this.contribution(keymap({ "Mod-i": toggleMark(rte.schema.marks.italic) }))];
1804
+ }
1805
+ getToolbarItems(rte) {
1806
+ return [this.contribution({
1807
+ section: "text-style",
1808
+ render: (ctx) => createMarkToggle(ctx, {
1809
+ label: () => ctx.rte.getLocale().richTextEditor.italic,
1810
+ dynamicIcon: "italic",
1811
+ markType: rte.schema.marks.italic
1812
+ })
1813
+ }, 2)];
1814
+ }
1815
+ };
1816
+ var RteItalicFeature = featureFacade(RteItalicFeatureImpl);
1817
+ //#endregion
1818
+ //#region src/lib/rich-text-editor/rte/features/underline.ts
1819
+ var RteUnderlineFeatureImpl = class extends RteTextStyleFeatureImpl {
1820
+ constructor(..._args) {
1821
+ super(..._args);
1822
+ this.name = "RteUnderlineFeature";
1823
+ this.markName = "underline";
1824
+ }
1825
+ getSchema() {
1826
+ return [this.contribution({ marks: { underline: {
1827
+ parseDOM: [{ tag: "u" }],
1828
+ toDOM() {
1829
+ return ["u", 0];
1830
+ }
1831
+ } } })];
1832
+ }
1833
+ getPlugins(rte) {
1834
+ return [this.contribution(keymap({ "Mod-u": toggleMark(rte.schema.marks.underline) }))];
1835
+ }
1836
+ getToolbarItems(rte) {
1837
+ return [this.contribution({
1838
+ section: "text-style",
1839
+ render: (ctx) => createMarkToggle(ctx, {
1840
+ label: () => ctx.rte.getLocale().richTextEditor.underline,
1841
+ dynamicIcon: "underline",
1842
+ markType: rte.schema.marks.underline
1843
+ })
1844
+ }, 3)];
1845
+ }
1846
+ };
1847
+ var RteUnderlineFeature = featureFacade(RteUnderlineFeatureImpl);
1848
+ //#endregion
1849
+ //#region src/lib/rich-text-editor/rte/features/strikethrough.ts
1850
+ var RteStrikethroughFeatureImpl = class extends RteTextStyleFeatureImpl {
1851
+ constructor(..._args) {
1852
+ super(..._args);
1853
+ this.name = "RteStrikethroughFeature";
1854
+ this.markName = "strikethrough";
1855
+ }
1856
+ getSchema() {
1857
+ return [this.contribution({ marks: { strikethrough: {
1858
+ parseDOM: [{ tag: "s" }, { tag: "del" }],
1859
+ toDOM() {
1860
+ return ["s", 0];
1861
+ }
1862
+ } } })];
1863
+ }
1864
+ getPlugins(rte) {
1865
+ return [this.contribution(keymap({
1866
+ "Alt-Shift-5": toggleMark(rte.schema.marks.strikethrough),
1867
+ "Cmd-Shift-X": toggleMark(rte.schema.marks.strikethrough)
1868
+ }))];
1869
+ }
1870
+ getToolbarItems(rte) {
1871
+ return [this.contribution({
1872
+ section: "text-style",
1873
+ render: (ctx) => createMarkToggle(ctx, {
1874
+ label: () => ctx.rte.getLocale().richTextEditor.strikethrough,
1875
+ dynamicIcon: "strikethrough",
1876
+ markType: rte.schema.marks.strikethrough
1877
+ })
1878
+ }, 4)];
1879
+ }
1880
+ };
1881
+ var RteStrikethroughFeature = featureFacade(RteStrikethroughFeatureImpl);
1882
+ //#endregion
1883
+ //#region src/lib/rich-text-editor/rte/features/monospace.style.scss?inline
1884
+ var monospace_style_default = "tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}";
1885
+ //#endregion
1886
+ //#region src/lib/rich-text-editor/rte/features/monospace.ts
1887
+ var RteMonospaceFeatureImpl = class extends RteTextStyleFeatureImpl {
1888
+ constructor(..._args) {
1889
+ super(..._args);
1890
+ this.name = "RteMonospaceFeature";
1891
+ this.markName = "monospace";
1892
+ }
1893
+ getStyles() {
1894
+ return [this.contribution(monospace_style_default)];
1895
+ }
1896
+ getSchema() {
1897
+ return [this.contribution({ marks: { monospace: {
1898
+ parseDOM: [{ tag: "tt" }, { tag: "code" }],
1899
+ toDOM() {
1900
+ return ["tt", 0];
1901
+ }
1902
+ } } })];
1903
+ }
1904
+ getPlugins(rte) {
1905
+ return [this.contribution(keymap({ "Mod-M": toggleMark(rte.schema.marks.monospace) }))];
1906
+ }
1907
+ getToolbarItems(rte) {
1908
+ return [this.contribution({
1909
+ section: "text-style",
1910
+ render: (ctx) => createMarkToggle(ctx, {
1911
+ label: () => ctx.rte.getLocale().richTextEditor.monospace,
1912
+ dynamicIcon: "monospace",
1913
+ markType: rte.schema.marks.monospace
1914
+ })
1915
+ }, 5)];
1916
+ }
1917
+ };
1918
+ var RteMonospaceFeature = featureFacade(RteMonospaceFeatureImpl);
1919
+ //#endregion
1920
+ //#region src/lib/rich-text-editor/rte/features/text-color-picker.ts
1921
+ function markApplies(doc, ranges, type) {
1922
+ for (let i = 0; i < ranges.length; i++) {
1923
+ const { $from, $to } = ranges[i];
1924
+ let can = $from.depth == 0 ? doc.type.allowsMarkType(type) : false;
1925
+ doc.nodesBetween($from.pos, $to.pos, (node) => {
1926
+ if (can) return false;
1927
+ can = node.inlineContent && node.type.allowsMarkType(type);
1928
+ return true;
1929
+ });
1930
+ if (can) return true;
1931
+ }
1932
+ return false;
1933
+ }
1934
+ var mixedColor = Symbol("mixedColor");
1935
+ var RteTextColorPickerFeatureImpl = class extends RteFeatureImpl {
1936
+ constructor(config) {
1937
+ super();
1938
+ this.config = config;
1939
+ this.name = "RteTextColorPicker";
1940
+ if (config?.onBlocks) {
1941
+ this.defaultColorForNode = {};
1942
+ for (const block of config.onBlocks) this.defaultColorForNode[block.node] = block.defaultColor ?? null;
1943
+ }
1944
+ }
1945
+ getTextblockMarks() {
1946
+ if (this.config?.onBlocks) return this.config.onBlocks.map((block) => this.contribution({
1947
+ markName: "textColor",
1948
+ onNodeName: block.node
1949
+ }));
1950
+ return [this.contribution({ markName: "textColor" })];
1951
+ }
1952
+ getSchema() {
1953
+ return [this.contribution({ marks: { textColor: {
1954
+ attrs: { color: { validate: "string" } },
1955
+ parseDOM: [{
1956
+ tag: "span[data-text-color]",
1957
+ getAttrs: (dom) => {
1958
+ return { color: dom.getAttribute("data-text-color") };
1959
+ }
1960
+ }, {
1961
+ style: "color",
1962
+ getAttrs: (value) => {
1963
+ return { color: value };
1964
+ }
1965
+ }],
1966
+ toDOM(node) {
1967
+ const { color } = node.attrs;
1968
+ return [
1969
+ "span",
1970
+ {
1971
+ style: `color: ${escapeCssProperty(color)};`,
1972
+ "data-text-color": color
1973
+ },
1974
+ 0
1975
+ ];
1976
+ },
1977
+ inclusive: true
1978
+ } } })];
1979
+ }
1980
+ getToolbarItems() {
1981
+ return [this.contribution({
1982
+ section: "text-style",
1983
+ render: (ctx) => {
1984
+ const tooltipButton = createButton(ctx, {
1985
+ label: () => ctx.rte.getLocale().richTextEditor.textColor,
1986
+ disabled: () => !this.setColor("any")(ctx.view.state),
1987
+ icon: "textcolor-line"
1988
+ });
1989
+ const button = tooltipButton.firstElementChild;
1990
+ return createDiv(ctx, { children: [tooltipButton, createSingleSlot(ctx, {
1991
+ name: "text-color-picker",
1992
+ assignedProps: {
1993
+ anchor: button,
1994
+ value: () => this.getSelectionColor(ctx.view.state) || ""
1995
+ },
1996
+ assignedEvents: { change: (e) => {
1997
+ const value = e.currentTarget.value;
1998
+ this.setColor(value)(ctx.view.state, ctx.view.dispatch);
1999
+ } }
2000
+ })] });
2001
+ }
2002
+ }, 6)];
2003
+ }
2004
+ /** Determine the color of the current selection or null if colors are mixed */
2005
+ getSelectionColor(state) {
2006
+ const { selection } = state;
2007
+ const { textColor } = state.schema.marks;
2008
+ const { from, to, $from, empty } = selection;
2009
+ if (empty) {
2010
+ const defaultColor = this.defaultColorForNode?.[$from.parent.type.name] ?? null;
2011
+ return textColor.isInSet(state.storedMarks || $from.marks())?.attrs.color ?? defaultColor;
2012
+ }
2013
+ let selectionColor = null;
2014
+ const observeColor = (observedColor) => {
2015
+ if (selectionColor === null) selectionColor = observedColor ?? null;
2016
+ else if (observedColor !== selectionColor) selectionColor = mixedColor;
2017
+ };
2018
+ state.doc.nodesBetween(from, to, (node, _pos, parent) => {
2019
+ if (selectionColor === mixedColor) return false;
2020
+ if (!node.isLeaf) {
2021
+ if (node.type.allowsMarkType(textColor) && node.childCount === 0) observeColor(this.defaultColorForNode?.[node.type.name]);
2022
+ return true;
2023
+ }
2024
+ observeColor(textColor.isInSet(node.marks)?.attrs.color ?? (parent && this.defaultColorForNode?.[parent.type.name]));
2025
+ return true;
2026
+ });
2027
+ return selectionColor === mixedColor ? null : selectionColor;
2028
+ }
2029
+ setColor(color) {
2030
+ return (state, dispatch) => {
2031
+ const { textColor } = state.schema.marks;
2032
+ const { from, to, empty, $from } = state.selection;
2033
+ if (!markApplies(state.doc, state.selection.ranges, textColor)) return false;
2034
+ const tr = state.tr;
2035
+ if (empty) {
2036
+ const newStoredMarks = (state.storedMarks || []).filter((m) => m.type !== textColor);
2037
+ if (color !== this.defaultColorForNode?.[$from.parent.type.name]) newStoredMarks.push(textColor.create({ color }));
2038
+ tr.setStoredMarks(newStoredMarks);
2039
+ } else {
2040
+ tr.addMark(from, to, textColor.create({ color }));
2041
+ tr.doc.nodesBetween(from, to, (node, pos, parent) => {
2042
+ if (!node.isInline) return;
2043
+ const mark = textColor.isInSet(node.marks);
2044
+ const defaultColor = this.defaultColorForNode?.[parent.type.name];
2045
+ if (mark && mark.attrs.color === defaultColor) tr.step(new RemoveMarkStep(pos, pos + node.nodeSize, mark));
2046
+ });
2047
+ }
2048
+ dispatch?.(tr.scrollIntoView());
2049
+ return true;
2050
+ };
2051
+ }
2052
+ };
2053
+ var RteTextColorPickerFeature = featureFacade(RteTextColorPickerFeatureImpl);
2054
+ //#endregion
2055
+ //#region src/lib/rich-text-editor/rte/features/list.style.scss?inline
2056
+ var list_style_default = ".rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}";
2057
+ //#endregion
2058
+ //#region src/lib/rich-text-editor/rte/features/list.ts
2059
+ var atStartOfNode = ($cursor) => $cursor.parentOffset === 0;
2060
+ var isEmpty = (node) => node.nodeSize === 2;
2061
+ var listDepth = ($li) => $li.depth - 1;
2062
+ var outOfListDepth = ($li) => $li.depth - 2;
2063
+ var getLi = ($li) => $li.parent;
2064
+ var getList = ($li) => $li.node(listDepth($li));
2065
+ var isNested = ($li) => $li.depth > 2;
2066
+ var isFirstChild = ($pos, depth) => $pos.index(depth) === 0;
2067
+ var isLastChild = ($pos, depth) => $pos.index(depth) === $pos.node(depth).childCount - 1;
2068
+ var prevSibling = ($pos, depth) => {
2069
+ const parent = $pos.node(depth);
2070
+ const index = $pos.index(depth);
2071
+ return parent.maybeChild(index - 1);
2072
+ };
2073
+ var nextSibling = ($pos, depth) => {
2074
+ const parent = $pos.node(depth);
2075
+ const index = $pos.index(depth);
2076
+ return parent.maybeChild(index + 1);
2077
+ };
2078
+ var asTextSelection = (selection) => {
2079
+ let { $from, $to } = selection;
2080
+ if (selection instanceof AllSelection) {
2081
+ const textSelection = TextSelection.between(selection.$from, selection.$to);
2082
+ $from = textSelection.$from;
2083
+ $to = textSelection.$to;
2084
+ }
2085
+ return {
2086
+ $from,
2087
+ $to
2088
+ };
2089
+ };
2090
+ var getSharedAncestor = ($from, $to) => $from.sameParent($to) ? $from.node(-1) : $from.node($from.sharedDepth($to.pos));
2091
+ var cursorInListItem = (state) => {
2092
+ const { $cursor } = state.selection;
2093
+ if ($cursor?.parent.type === state.schema.nodes.listItem) return $cursor;
2094
+ return null;
2095
+ };
2096
+ var allListItemsAreOfType = (state, $from, $to, type) => {
2097
+ let currentListType;
2098
+ let allLisAreOurType = true;
2099
+ state.doc.nodesBetween($from.pos, $to.pos, (node) => {
2100
+ if (node.type.isInGroup("list")) currentListType = node.type;
2101
+ if (node.type === state.schema.nodes.listItem && currentListType !== type) allLisAreOurType = false;
2102
+ });
2103
+ return allLisAreOurType;
2104
+ };
2105
+ var lift = (rte, $li, tr) => {
2106
+ if (isNested($li)) {
2107
+ liftToOuterList($li, tr);
2108
+ return true;
2109
+ }
2110
+ return liftOutOfList(rte, $li, tr);
2111
+ };
2112
+ var liftToOuterList = ($li, tr) => {
2113
+ const liRange = new NodeRange($li.doc.resolve($li.before()), $li.doc.resolve($li.after()), $li.depth - 1);
2114
+ tr.lift(liRange, $li.depth - 2);
2115
+ };
2116
+ var liftOutOfList = (rte, $li, tr) => {
2117
+ const list = getList($li);
2118
+ const listIndex = $li.index(outOfListDepth($li));
2119
+ const defaultTextblock = defaultTextblockForMatch($li.node(outOfListDepth($li)).contentMatchAt(listIndex + 1));
2120
+ if (!defaultTextblock) return false;
2121
+ const atStart = isFirstChild($li, listDepth($li));
2122
+ const atEnd = isLastChild($li, listDepth($li));
2123
+ tr.step(new ReplaceAroundStep($li.before() - (atStart ? 1 : 0), $li.after() + (atEnd ? 1 : 0), $li.start(), $li.end(), new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(Fragment.from(defaultTextblock.create(rte.textblockAttrs.extractFromNode(getLi($li))))).append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), (atStart ? 0 : 1) + 1));
2124
+ return true;
2125
+ };
2126
+ var sink = (rte, listType, $node, tr) => {
2127
+ if ($node.parent.type === rte.schema.nodes.listItem) sinkLi(listType, $node, tr);
2128
+ else sinkNode(rte, listType, $node, tr);
2129
+ };
2130
+ var sinkLi = (listType, $li, tr) => {
2131
+ const canJoinWithPrev = prevSibling($li, listDepth($li))?.type === listType;
2132
+ const canJoinWithNext = nextSibling($li, listDepth($li))?.type === listType;
2133
+ const openStart = canJoinWithPrev ? 1 : 0;
2134
+ const openEnd = canJoinWithNext ? 1 : 0;
2135
+ tr.step(new ReplaceAroundStep($li.before() - (canJoinWithPrev ? 1 : 0), $li.after() + (canJoinWithNext ? 1 : 0), $li.before(), $li.after(), new Slice(Fragment.from(listType.create(null, [])), openStart, openEnd), 1 - openStart));
2136
+ };
2137
+ var sinkNode = (rte, listType, $node, tr) => {
2138
+ tr.step(new ReplaceAroundStep($node.before(), $node.after(), $node.start(), $node.end(), new Slice(Fragment.from(listType.create(null, [rte.schema.nodes.listItem.create(rte.textblockAttrs.extractFromNode($node.parent))])), 0, 0), 2));
2139
+ };
2140
+ var RteListFeatureImpl = class extends RteFeatureImpl {
2141
+ constructor(config) {
2142
+ super();
2143
+ this.config = config;
2144
+ this.name = "RteListFeature";
2145
+ if (!config.bulletList && !config.numberedList) throw new Error("RteListFeature requires at least one of bulletList or numberedList to be enabled");
2146
+ }
2147
+ getStyles() {
2148
+ return [this.contribution(list_style_default)];
2149
+ }
2150
+ getSchema(textblockAttrs) {
2151
+ return [this.contribution({ nodes: {
2152
+ listItem: {
2153
+ content: "inline*",
2154
+ attrs: textblockAttrs.attrs,
2155
+ defining: true,
2156
+ parseDOM: [{
2157
+ tag: "li",
2158
+ getAttrs: (dom) => textblockAttrs.fromDOM(dom)
2159
+ }],
2160
+ toDOM(node) {
2161
+ return [
2162
+ "li",
2163
+ ...textblockAttrs.getDOMAttrs(node),
2164
+ 0
2165
+ ];
2166
+ }
2167
+ },
2168
+ ...this.config.bulletList ? { bulletList: {
2169
+ group: "block list",
2170
+ content: "(listItem | list)+",
2171
+ parseDOM: [{ tag: "ul" }],
2172
+ toDOM() {
2173
+ return ["ul", 0];
2174
+ }
2175
+ } } : {},
2176
+ ...this.config.numberedList ? { numberedList: {
2177
+ group: "block list",
2178
+ content: "(listItem | list)+",
2179
+ parseDOM: [{ tag: "ol" }],
2180
+ toDOM() {
2181
+ return ["ol", 0];
2182
+ }
2183
+ } } : {}
2184
+ } })];
2185
+ }
2186
+ getPlugins(rte) {
2187
+ this.rte = rte;
2188
+ const tabCommand = (state, dispatch) => {
2189
+ const $liCursor = cursorInListItem(state);
2190
+ if ($liCursor && atStartOfNode($liCursor)) {
2191
+ const tr = state.tr;
2192
+ sinkLi(getList($liCursor).type, $liCursor, tr);
2193
+ dispatch?.(tr.scrollIntoView());
2194
+ return true;
2195
+ }
2196
+ return false;
2197
+ };
2198
+ const shiftTabCommand = (state, dispatch) => {
2199
+ const $liCursor = cursorInListItem(state);
2200
+ if ($liCursor && atStartOfNode($liCursor) && isNested($liCursor)) {
2201
+ const tr = state.tr;
2202
+ liftToOuterList($liCursor, tr);
2203
+ dispatch?.(tr.scrollIntoView());
2204
+ return true;
2205
+ }
2206
+ return false;
2207
+ };
2208
+ const enterCommand = (state, dispatch) => {
2209
+ const $liCursor = cursorInListItem(state);
2210
+ if ($liCursor && isEmpty(getLi($liCursor))) {
2211
+ const tr = state.tr;
2212
+ if (!lift(this.rte, $liCursor, tr)) return false;
2213
+ dispatch?.(tr.scrollIntoView());
2214
+ return true;
2215
+ }
2216
+ return false;
2217
+ };
2218
+ const backspaceCommand = (state, dispatch) => {
2219
+ const $liCursor = cursorInListItem(state);
2220
+ if ($liCursor && atStartOfNode($liCursor)) {
2221
+ if (isFirstChild($liCursor, listDepth($liCursor)) && prevSibling($liCursor, outOfListDepth($liCursor))?.type === getList($liCursor).type) return false;
2222
+ const tr = state.tr;
2223
+ if (!lift(this.rte, $liCursor, tr)) return false;
2224
+ dispatch?.(tr.scrollIntoView());
2225
+ return true;
2226
+ }
2227
+ return false;
2228
+ };
2229
+ return [this.contribution(keymap({
2230
+ Enter: enterCommand,
2231
+ Backspace: backspaceCommand,
2232
+ Tab: tabCommand,
2233
+ "Shift-Tab": shiftTabCommand,
2234
+ ...this.config.bulletList ? { "Mod-Shift-8": this.toggleList(rte.schema.nodes.bulletList) } : {},
2235
+ ...this.config.numberedList ? { "Mod-Shift-7": this.toggleList(rte.schema.nodes.numberedList) } : {}
2236
+ }), contributionPriority.high)];
2237
+ }
2238
+ getToolbarItems(rte) {
2239
+ const toolbarItems = [];
2240
+ if (this.config.bulletList) toolbarItems.push(this.contribution({
2241
+ section: "textblock",
2242
+ render: (ctx) => createButton(ctx, {
2243
+ label: () => ctx.rte.getLocale().richTextEditor.bulletList,
2244
+ dynamicIcon: "bullet-list-2",
2245
+ active: () => this.isSelectionInList(rte.schema.nodes.bulletList, ctx.rte.state),
2246
+ onClick: () => {
2247
+ const { state, dispatch } = ctx.view;
2248
+ this.toggleList(rte.schema.nodes.bulletList)(state, dispatch);
2249
+ }
2250
+ })
2251
+ }, 1));
2252
+ if (this.config.numberedList) toolbarItems.push(this.contribution({
2253
+ section: "textblock",
2254
+ render: (ctx) => createButton(ctx, {
2255
+ label: () => ctx.rte.getLocale().richTextEditor.numberedList,
2256
+ dynamicIcon: "list-numbered",
2257
+ active: () => this.isSelectionInList(rte.schema.nodes.numberedList, ctx.rte.state),
2258
+ onClick: () => {
2259
+ const { state, dispatch } = ctx.view;
2260
+ this.toggleList(rte.schema.nodes.numberedList)(state, dispatch);
2261
+ }
2262
+ })
2263
+ }, 2));
2264
+ return toolbarItems;
2265
+ }
2266
+ toggleList(type) {
2267
+ return autoJoin((state, dispatch) => {
2268
+ const { $from, $to } = asTextSelection(state.selection);
2269
+ if (getSharedAncestor($from, $to).type.isInGroup("list")) {
2270
+ if (allListItemsAreOfType(state, $from, $to, type)) {
2271
+ const tr = state.tr;
2272
+ state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
2273
+ if (node.type === state.schema.nodes.listItem) {
2274
+ const $li = tr.doc.resolve(tr.mapping.map(pos + 1));
2275
+ lift(this.rte, $li, tr);
2276
+ }
2277
+ });
2278
+ dispatch?.(tr.scrollIntoView());
2279
+ return true;
2280
+ } else {
2281
+ const tr = state.tr;
2282
+ state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
2283
+ if (node.type.isInGroup("list") && node.type !== type) tr.setNodeMarkup(pos, type, node.attrs);
2284
+ });
2285
+ dispatch?.(tr.scrollIntoView());
2286
+ return true;
2287
+ }
2288
+ } else {
2289
+ const tr = state.tr;
2290
+ state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
2291
+ if (!node.isTextblock) return;
2292
+ const $node = tr.doc.resolve(tr.mapping.map(pos + 1));
2293
+ sink(this.rte, type, $node, tr);
2294
+ });
2295
+ dispatch?.(tr.scrollIntoView());
2296
+ return true;
2297
+ }
2298
+ }, (before, after) => before.type === type && after.type === type);
2299
+ }
2300
+ isSelectionInList(type, state) {
2301
+ const { $from, $to } = asTextSelection(state.selection);
2302
+ if (getSharedAncestor($from, $to).type.isInGroup("list")) return allListItemsAreOfType(state, $from, $to, type);
2303
+ else return false;
2304
+ }
2305
+ };
2306
+ var RteListFeature = featureFacade(RteListFeatureImpl);
2307
+ //#endregion
2308
+ //#region src/lib/rich-text-editor/rte/features/alignment.ts
2309
+ var alignments = [
2310
+ {
2311
+ value: "left",
2312
+ icon: "align-left",
2313
+ label: "left"
2314
+ },
2315
+ {
2316
+ value: "center",
2317
+ icon: "align-center",
2318
+ label: "center"
2319
+ },
2320
+ {
2321
+ value: "right",
2322
+ icon: "align-right",
2323
+ label: "right"
2324
+ }
2325
+ ];
2326
+ var validTextAlign = (value) => alignments.find((a) => a.value === value)?.value ?? "left";
2327
+ var RteAlignmentFeatureImpl = class extends RteFeatureImpl {
2328
+ constructor(..._args) {
2329
+ super(..._args);
2330
+ this.name = "RteAlignmentFeature";
2331
+ }
2332
+ getTextblockAttrs() {
2333
+ return [this.contribution({
2334
+ name: "textAlign",
2335
+ default: "left",
2336
+ fromDOM(dom) {
2337
+ return validTextAlign(dom.style.textAlign);
2338
+ },
2339
+ toStyles(node) {
2340
+ return [`text-align: ${validTextAlign(node.attrs.textAlign)}`];
2341
+ }
2342
+ })];
2343
+ }
2344
+ getPlugins() {
2345
+ return [this.contribution(keymap({
2346
+ "Mod-L": this.setAlignment("left"),
2347
+ "Mod-E": this.setAlignment("center"),
2348
+ "Mod-R": this.setAlignment("right")
2349
+ }))];
2350
+ }
2351
+ getToolbarItems() {
2352
+ return [this.contribution({
2353
+ section: "textblock",
2354
+ render: (ctx) => createMenu(ctx, {
2355
+ label: () => ctx.rte.getLocale().richTextEditor.alignment,
2356
+ trigger: createButton(ctx, {
2357
+ label: () => ctx.rte.getLocale().richTextEditor.alignment,
2358
+ icon: () => {
2359
+ const currentAlign = this.getAlignmentFromSelection(ctx.view.state);
2360
+ return `${alignments.find((a) => a.value === currentAlign)?.icon ?? "align-left"}-line`;
2361
+ }
2362
+ }),
2363
+ children: [createButtonGroup(ctx, {
2364
+ slot: "header",
2365
+ children: alignments.map((align, index) => createButton(ctx, {
2366
+ dynamicIcon: align.icon,
2367
+ label: () => ctx.rte.getLocale().richTextEditor.alignments[align.label],
2368
+ noTooltip: true,
2369
+ variant: "toolbar-menu",
2370
+ autofocus: () => {
2371
+ const currentAlign = this.getAlignmentFromSelection(ctx.view.state);
2372
+ if ((currentAlign === "mixed" || currentAlign === null) && index === 0) return true;
2373
+ return align.value === currentAlign;
2374
+ },
2375
+ active: () => this.getAlignmentFromSelection(ctx.view.state) === align.value,
2376
+ disabled: () => this.getAlignmentFromSelection(ctx.view.state) === null,
2377
+ onClick: () => {
2378
+ const { state, dispatch } = ctx.view;
2379
+ this.setAlignment(align.value)(state, dispatch);
2380
+ }
2381
+ }))
2382
+ })]
2383
+ })
2384
+ }, 3)];
2385
+ }
2386
+ getAlignmentFromSelection(state) {
2387
+ const { selection } = state;
2388
+ const { from, to } = selection;
2389
+ let align = null;
2390
+ state.doc.nodesBetween(from, to, (node) => {
2391
+ if (align === "mixed") return;
2392
+ if (node.type.isTextblock) {
2393
+ if (!align) align = node.attrs.textAlign;
2394
+ else if (align !== node.attrs.textAlign) align = "mixed";
2395
+ }
2396
+ });
2397
+ return align;
2398
+ }
2399
+ setAlignment(align) {
2400
+ return (state, dispatch) => {
2401
+ const { tr, selection } = state;
2402
+ const { from, to } = selection;
2403
+ state.doc.nodesBetween(from, to, (node, pos) => {
2404
+ if (node.type.isTextblock) tr.setNodeMarkup(pos, node.type, {
2405
+ ...node.attrs,
2406
+ textAlign: align
2407
+ });
2408
+ });
2409
+ dispatch?.(tr.scrollIntoView());
2410
+ return true;
2411
+ };
2412
+ }
2413
+ };
2414
+ var RteAlignmentFeature = featureFacade(RteAlignmentFeatureImpl);
2415
+ //#endregion
2416
+ //#region src/lib/rich-text-editor/rte/features/link.style.scss?inline
2417
+ var link_style_default = ".link-popover{flex-direction:column;gap:8px;inline-size:450px;padding:16px;display:flex}.link-popover-header{justify-content:space-between;align-items:center;display:flex}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{flex-direction:column;gap:16px;display:flex}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{justify-content:end;gap:8px;display:flex}.link-toolbar-menu{flex-direction:column;gap:16px;inline-size:368px;padding:8px;display:flex}";
2418
+ //#endregion
2419
+ //#region src/lib/rich-text-editor/rte/features/link.ts
2420
+ var linkPattern = "(?:https?://|www\\.)[^\\s<]+";
2421
+ function convertToLink(state, matchedText, start, end) {
2422
+ if (state.doc.rangeHasMark(start, start + 1, state.schema.marks.link)) return null;
2423
+ const link = matchedText.replace(/[.,;:!?) ]+$/, "");
2424
+ const href = link.startsWith("www.") ? `https://${link}` : link;
2425
+ const linkMark = state.schema.marks.link.create({ href });
2426
+ const linkEnd = start + link.length;
2427
+ const trailingChars = matchedText.slice(link.length);
2428
+ const tr = state.tr.addMark(start, linkEnd, linkMark);
2429
+ if (trailingChars) tr.replaceWith(linkEnd, end, state.schema.text(trailingChars));
2430
+ return tr;
2431
+ }
2432
+ var RteLinkFeatureImpl = class extends RteFeatureImpl {
2433
+ constructor(..._args) {
2434
+ super(..._args);
2435
+ this.name = "RteLinkFeature";
2436
+ this.removeLink = (state, dispatch) => {
2437
+ const tr = state.tr;
2438
+ const existingLink = this.getCurrentLink(state);
2439
+ tr.removeMark(existingLink.start, existingLink.end, state.schema.marks.link);
2440
+ dispatch?.(tr.scrollIntoView());
2441
+ return true;
2442
+ };
2443
+ }
2444
+ getStyles() {
2445
+ return [this.contribution(link_style_default)];
2446
+ }
2447
+ getSchema() {
2448
+ return [this.contribution({ marks: { link: {
2449
+ attrs: { href: { validate: "string" } },
2450
+ inclusive: false,
2451
+ parseDOM: [{
2452
+ tag: "a[href]",
2453
+ getAttrs(dom) {
2454
+ return { href: dom.getAttribute("href") };
2455
+ }
2456
+ }],
2457
+ toDOM(node) {
2458
+ const { href } = node.attrs;
2459
+ return [
2460
+ "a",
2461
+ { href: sanitizeLinkHref(href) },
2462
+ 0
2463
+ ];
2464
+ }
2465
+ } } }, contributionPriority.high)];
2466
+ }
2467
+ getTextblockMarks() {
2468
+ return [this.contribution({ markName: "link" })];
2469
+ }
2470
+ getInputRules() {
2471
+ const linkRegex = new RegExp(`${linkPattern}$`);
2472
+ return [this.contribution({
2473
+ rule: new InputRule(new RegExp(`${linkPattern} $`), (state, match, start, end) => convertToLink(state, match[0], start, end)),
2474
+ enterHandler: {
2475
+ regex: linkRegex,
2476
+ handler: (state, match, start, end) => convertToLink(state, match[0], start, end)
2477
+ }
2478
+ })];
2479
+ }
2480
+ getPlugins(rte) {
2481
+ const insertLinkCommand = () => {
2482
+ this.toolbarMenu.open = true;
2483
+ return true;
2484
+ };
2485
+ let popup;
2486
+ return [this.contribution(new Plugin({
2487
+ props: { decorations: (state) => {
2488
+ const link = this.getCurrentLink(state);
2489
+ if (link) {
2490
+ const deco = Decoration.inline(link.start, link.end, { id: "current-link" });
2491
+ return DecorationSet.create(state.doc, [deco]);
2492
+ }
2493
+ return null;
2494
+ } },
2495
+ view: (view) => {
2496
+ const ctx = new UiCtx(view, rte, {
2497
+ popupPlacement: "bottom",
2498
+ shouldReturnFocusToEditor: true
2499
+ });
2500
+ popup = rte.createComponent(Popover);
2501
+ popup.anchorId = "current-link";
2502
+ const content = createDiv(ctx, {
2503
+ className: "link-popover",
2504
+ children: [createDiv(ctx, {
2505
+ className: "link-popover-header",
2506
+ children: [createDiv(ctx, {
2507
+ className: "link-popover-label",
2508
+ children: [createText(ctx, { text: () => this.getCurrentLink(ctx.view.state)?.text || "" })]
2509
+ }), createButton(ctx, {
2510
+ icon: "close-line",
2511
+ label: () => ctx.rte.getLocale().richTextEditor.close,
2512
+ noTooltip: true,
2513
+ onClick: () => {
2514
+ popup.dismiss();
2515
+ }
2516
+ })]
2517
+ }), createDiv(ctx, {
2518
+ className: "link-popover-content",
2519
+ children: [createAnchor(ctx, {
2520
+ className: "link",
2521
+ href: () => this.getCurrentLink(ctx.view.state)?.href || "",
2522
+ target: "_blank",
2523
+ rel: "noopener",
2524
+ children: [createText(ctx, { text: () => this.getCurrentLink(ctx.view.state)?.href || "" })]
2525
+ }), createDiv(ctx, {
2526
+ className: "link-action-bar",
2527
+ children: [createButton(ctx, {
2528
+ icon: "delete-line",
2529
+ label: () => ctx.rte.getLocale().richTextEditor.delete,
2530
+ connotation: "alert",
2531
+ variant: "popover",
2532
+ noTooltip: true,
2533
+ onClick: () => {
2534
+ const { state, dispatch } = ctx.view;
2535
+ this.removeLink(state, dispatch);
2536
+ }
2537
+ }), createButton(ctx, {
2538
+ icon: "edit-line",
2539
+ label: () => ctx.rte.getLocale().richTextEditor.edit,
2540
+ variant: "popover",
2541
+ noTooltip: true,
2542
+ onClick: () => {
2543
+ this.toolbarMenu.open = true;
2544
+ popup.requestOpenState(false);
2545
+ return true;
2546
+ }
2547
+ })]
2548
+ })]
2549
+ })]
2550
+ });
2551
+ popup.appendChild(content);
2552
+ view.dom.getRootNode().querySelector(".popovers").appendChild(popup);
2553
+ return {
2554
+ update: (view) => {
2555
+ const state = view.state;
2556
+ ctx.updateBindings();
2557
+ const link = this.getCurrentLink(state);
2558
+ popup.requestOpenState(Boolean(link));
2559
+ },
2560
+ destroy: () => {
2561
+ popup.remove();
2562
+ }
2563
+ };
2564
+ }
2565
+ })), this.contribution(keymap({
2566
+ Escape: (state) => {
2567
+ if (this.getCurrentLink(state)) {
2568
+ popup?.dismiss();
2569
+ return true;
2570
+ }
2571
+ return false;
2572
+ },
2573
+ "Mod-k": insertLinkCommand
2574
+ }))];
2575
+ }
2576
+ getToolbarItems(rte) {
2577
+ const getSelectionText = (state) => {
2578
+ const { from, to } = state.selection;
2579
+ if (from === to) return "";
2580
+ return state.doc.textBetween(from, to, " ");
2581
+ };
2582
+ const isValidUrl = (url) => {
2583
+ try {
2584
+ new URL(url);
2585
+ return true;
2586
+ } catch {
2587
+ return false;
2588
+ }
2589
+ };
2590
+ return [this.contribution({
2591
+ section: "insert",
2592
+ render: (ctx) => {
2593
+ const textField = createTextField(ctx, {
2594
+ label: () => ctx.rte.getLocale().richTextEditor.linkText,
2595
+ placeholder: () => ctx.rte.getLocale().richTextEditor.linkTextPlaceholder,
2596
+ slot: "header",
2597
+ autofocus: true,
2598
+ value: () => this.getCurrentLink(ctx.view.state)?.text || getSelectionText(ctx.view.state) || "",
2599
+ onInput: () => {
2600
+ updateValidation();
2601
+ }
2602
+ });
2603
+ const urlField = createTextField(ctx, {
2604
+ label: () => ctx.rte.getLocale().richTextEditor.linkUrl,
2605
+ type: "url",
2606
+ placeholder: () => ctx.rte.getLocale().richTextEditor.linkUrlPlaceholder,
2607
+ helperText: () => ctx.rte.getLocale().richTextEditor.linkUrlHelperText,
2608
+ slot: "header",
2609
+ value: () => this.getCurrentLink(ctx.view.state)?.href || "",
2610
+ onInput: () => {
2611
+ updateValidation();
2612
+ }
2613
+ });
2614
+ const applyButton = createButton(ctx, {
2615
+ label: () => ctx.rte.getLocale().richTextEditor.apply,
2616
+ variant: "popover-primary",
2617
+ disabled: () => {
2618
+ const link = this.getCurrentLink(ctx.view.state);
2619
+ return !(link && link.text.length && isValidUrl(link.href));
2620
+ },
2621
+ onClick: () => {
2622
+ const { state, dispatch } = ctx.view;
2623
+ this.insertLink(rte, urlField.value, textField.value)(state, dispatch);
2624
+ this.toolbarMenu.open = false;
2625
+ }
2626
+ });
2627
+ const updateValidation = () => {
2628
+ applyButton.querySelector("[data-vvd-component=\"button\"]").disabled = !(textField.value.length && isValidUrl(urlField.value));
2629
+ };
2630
+ const menu = createMenu(ctx, {
2631
+ label: () => ctx.rte.getLocale().richTextEditor.hyperlink,
2632
+ trigger: createButton(ctx, {
2633
+ label: () => ctx.rte.getLocale().richTextEditor.hyperlink,
2634
+ icon: "link-line"
2635
+ }),
2636
+ children: [createDiv(ctx, {
2637
+ className: "link-toolbar-menu",
2638
+ slot: "header",
2639
+ children: [
2640
+ textField,
2641
+ urlField,
2642
+ createDiv(ctx, {
2643
+ className: "link-action-bar",
2644
+ slot: "header",
2645
+ children: [createButton(ctx, {
2646
+ label: () => ctx.rte.getLocale().richTextEditor.cancel,
2647
+ variant: "popover",
2648
+ onClick: () => {
2649
+ this.toolbarMenu.open = false;
2650
+ }
2651
+ }), applyButton]
2652
+ })
2653
+ ]
2654
+ })]
2655
+ });
2656
+ this.toolbarMenu = menu.lastElementChild;
2657
+ return menu;
2658
+ }
2659
+ }, 1)];
2660
+ }
2661
+ getCurrentLink(state) {
2662
+ const selection = state.selection;
2663
+ if (!(selection instanceof TextSelection)) return null;
2664
+ const linkMark = state.schema.marks.link;
2665
+ const { $from, $to } = selection;
2666
+ const selectionStartMarks = state.selection.empty ? $from.marks() : $from.nodeAfter?.marks ?? [];
2667
+ const targetHref = linkMark.isInSet(selectionStartMarks)?.attrs.href;
2668
+ if (!targetHref) return null;
2669
+ const isTargetLink = (node) => linkMark.isInSet(node.marks)?.attrs.href === targetHref;
2670
+ let currentRun = null;
2671
+ const runs = [];
2672
+ state.doc.nodesBetween($from.start(), $to.end(), (node, pos) => {
2673
+ if (!node.isText) return true;
2674
+ const nodeEnd = pos + node.nodeSize;
2675
+ if (isTargetLink(node)) {
2676
+ if (!currentRun) {
2677
+ currentRun = {
2678
+ start: pos,
2679
+ end: nodeEnd
2680
+ };
2681
+ runs.push(currentRun);
2682
+ } else currentRun.end = nodeEnd;
2683
+ } else currentRun = null;
2684
+ return false;
2685
+ });
2686
+ const selectionRun = runs.find((run) => run.start <= selection.from && run.end >= selection.to);
2687
+ if (!selectionRun) return null;
2688
+ return {
2689
+ text: state.doc.textBetween(selectionRun.start, selectionRun.end, " "),
2690
+ href: targetHref,
2691
+ start: selectionRun.start,
2692
+ end: selectionRun.end
2693
+ };
2694
+ }
2695
+ insertLink(rte, href, text) {
2696
+ return (state, dispatch) => {
2697
+ let { from, to } = state.selection;
2698
+ const tr = state.tr;
2699
+ const existingLink = this.getCurrentLink(state);
2700
+ if (existingLink) {
2701
+ from = existingLink.start;
2702
+ to = existingLink.end;
2703
+ }
2704
+ tr.insertText(text, from, to);
2705
+ tr.addMark(from, from + text.length, rte.schema.marks.link.create({ href }));
2706
+ dispatch?.(tr.scrollIntoView());
2707
+ return true;
2708
+ };
2709
+ }
2710
+ };
2711
+ var RteLinkFeature = featureFacade(RteLinkFeatureImpl);
2712
+ //#endregion
2713
+ //#region src/lib/rich-text-editor/rte/features/inline-image.style.scss?inline
2714
+ var inline_image_style_default = ".inline-image-wrapper{vertical-align:text-bottom;display:inline-block}.inline-image{block-size:auto;display:block}.inline-image-popover{align-items:center;gap:4px;padding:8px;display:flex}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}";
2715
+ //#endregion
2716
+ //#region src/lib/rich-text-editor/rte/features/inline-image.ts
2717
+ var isGenerator$1 = (value) => value !== null && Boolean(value["next"]);
2718
+ var uniqueId$1 = 1;
2719
+ var generateUniqueId = () => uniqueId$1++;
2720
+ var InlineImageView = class {
2721
+ constructor(node, view, getPos, config) {
2722
+ this.view = view;
2723
+ this.getPos = getPos;
2724
+ this.config = config;
2725
+ this.content = null;
2726
+ this.dom = document.createElement("div");
2727
+ this.dom.className = "inline-image-wrapper";
2728
+ this.imageUrl = node.attrs.imageUrl;
2729
+ this.img = document.createElement("img");
2730
+ this.initializeImg(node);
2731
+ const resolveResult = this.config.resolveUrl ? this.config.resolveUrl(this.imageUrl) : this.imageUrl;
2732
+ const initialResolvedUrl = isGenerator$1(resolveResult) ? null : resolveResult;
2733
+ this.handleResolvedUrl(initialResolvedUrl);
2734
+ if (isGenerator$1(resolveResult)) this.handleResolvedUrlGenerator(resolveResult);
2735
+ }
2736
+ setContent(content, { onDestroy, allowPopover } = {}) {
2737
+ this.content?.remove();
2738
+ this.onContentDestroy?.();
2739
+ this.content = content;
2740
+ if (content) {
2741
+ this.onContentDestroy = onDestroy;
2742
+ this.dom.appendChild(content);
2743
+ }
2744
+ Popover.setBlockPopover(this.dom, !allowPopover);
2745
+ }
2746
+ async handleResolvedUrlGenerator(generator) {
2747
+ const iterator = generator[Symbol.asyncIterator]();
2748
+ let result;
2749
+ do {
2750
+ result = await iterator.next();
2751
+ this.handleResolvedUrl(result.value);
2752
+ } while (!result.done);
2753
+ }
2754
+ handleResolvedUrl(result) {
2755
+ if (typeof result === "string") this.renderImg(result);
2756
+ else if (result?.type === "placeholder") {
2757
+ const slotName = `inline-image-placeholder-${generateUniqueId()}`;
2758
+ const slot = document.createElement("slot");
2759
+ slot.className = "inline-image-placeholder";
2760
+ slot.name = slotName;
2761
+ const onDestroy = result.create?.(slotName);
2762
+ const host = this.view.dom.getRootNode().host;
2763
+ dispatchSlottableRequest(host, "inline-image-placeholder", slotName, { url: this.imageUrl });
2764
+ this.setContent(slot, { onDestroy: () => {
2765
+ dispatchSlottableRequest(host, "inline-image-placeholder", slotName, removeSymbol);
2766
+ onDestroy?.();
2767
+ } });
2768
+ } else this.setContent(null);
2769
+ }
2770
+ initializeImg(node) {
2771
+ this.img.className = "inline-image";
2772
+ this.update(node);
2773
+ this.img.addEventListener("load", () => {
2774
+ const pos = this.getPos();
2775
+ if (pos) {
2776
+ const { state, dispatch } = this.view;
2777
+ const currentNode = state.doc.nodeAt(pos);
2778
+ if (!currentNode || currentNode.attrs.naturalWidth === this.img.naturalWidth && currentNode.attrs.naturalHeight === this.img.naturalHeight) return;
2779
+ const tr = state.tr;
2780
+ tr.setNodeAttribute(pos, "naturalWidth", this.img.naturalWidth);
2781
+ tr.setNodeAttribute(pos, "naturalHeight", this.img.naturalHeight);
2782
+ tr.setMeta("addToHistory", false);
2783
+ dispatch(tr);
2784
+ }
2785
+ });
2786
+ }
2787
+ renderImg(src) {
2788
+ this.img.src = sanitizeImageSrc(src);
2789
+ this.setContent(this.img, { allowPopover: true });
2790
+ }
2791
+ update(node) {
2792
+ this.img.alt = node.attrs.alt;
2793
+ this.img.width = node.attrs.naturalWidth;
2794
+ this.img.height = node.attrs.naturalHeight;
2795
+ this.img.style.maxWidth = node.attrs.size;
2796
+ return true;
2797
+ }
2798
+ destroy() {
2799
+ this.setContent(null);
2800
+ }
2801
+ };
2802
+ var RteInlineImageFeatureImpl = class extends RteFeatureImpl {
2803
+ constructor(config = {}) {
2804
+ super();
2805
+ this.config = config;
2806
+ this.name = "RteInlineImageFeature";
2807
+ }
2808
+ getStyles() {
2809
+ return [this.contribution(inline_image_style_default)];
2810
+ }
2811
+ getSchema() {
2812
+ return [this.contribution({ nodes: { inlineImage: {
2813
+ inline: true,
2814
+ group: "inline",
2815
+ selectable: true,
2816
+ atom: true,
2817
+ attrs: {
2818
+ imageUrl: { validate: "string" },
2819
+ alt: {
2820
+ validate: "string",
2821
+ default: ""
2822
+ },
2823
+ size: {
2824
+ validate: "string|null",
2825
+ default: null
2826
+ },
2827
+ naturalWidth: {
2828
+ validate: "number|null",
2829
+ default: null
2830
+ },
2831
+ naturalHeight: {
2832
+ validate: "number|null",
2833
+ default: null
2834
+ }
2835
+ },
2836
+ parseDOM: [{
2837
+ tag: "img[src],img[data-src]",
2838
+ getAttrs: (dom) => {
2839
+ const parseDimension = (dim) => {
2840
+ const value = parseInt(dim ?? "", 10);
2841
+ return isNaN(value) ? null : value;
2842
+ };
2843
+ const srcAttr = dom.getAttribute("data-src") ?? dom.getAttribute("src");
2844
+ const imageUrl = this.config.parseUrlFromHtml ? this.config.parseUrlFromHtml(srcAttr) : srcAttr;
2845
+ if (imageUrl === null) return false;
2846
+ return {
2847
+ imageUrl,
2848
+ alt: dom.getAttribute("alt") || "",
2849
+ size: dom.style.maxWidth || null,
2850
+ naturalWidth: parseDimension(dom.getAttribute("width")),
2851
+ naturalHeight: parseDimension(dom.getAttribute("height"))
2852
+ };
2853
+ }
2854
+ }],
2855
+ /** Since we use a NodeView, this is only used for HTML serialization */
2856
+ toDOM: (node) => {
2857
+ const { imageUrl, alt, size, naturalWidth, naturalHeight } = node.attrs;
2858
+ const resolvedUrl = this.config.serializeUrlToHtml ? this.config.serializeUrlToHtml(imageUrl) : imageUrl;
2859
+ if (resolvedUrl === null) return document.createTextNode("");
2860
+ const attrs = {
2861
+ src: sanitizeImageSrc(resolvedUrl),
2862
+ "data-src": resolvedUrl,
2863
+ alt
2864
+ };
2865
+ if (size) attrs.style = `max-width: ${escapeCssProperty(size)}; height: auto;`;
2866
+ if (naturalWidth) attrs.width = naturalWidth;
2867
+ if (naturalHeight) attrs.height = naturalHeight;
2868
+ return ["img", attrs];
2869
+ }
2870
+ } } })];
2871
+ }
2872
+ getPlugins(rte) {
2873
+ let popover;
2874
+ return [this.contribution(new Plugin({
2875
+ props: { nodeViews: { inlineImage: (node, view, getPos) => new InlineImageView(node, view, getPos, this.config) } },
2876
+ view: (view) => {
2877
+ const ctx = new UiCtx(view, rte, {
2878
+ popupPlacement: "bottom",
2879
+ shouldReturnFocusToEditor: true
2880
+ });
2881
+ popover = rte.createComponent(Popover);
2882
+ popover.kind = "imageOptions";
2883
+ popover.offset = 4;
2884
+ const content = createDiv(ctx, {
2885
+ className: "inline-image-popover",
2886
+ children: [
2887
+ createButton(ctx, {
2888
+ label: () => ctx.rte.getLocale().richTextEditor.imageSizes.small,
2889
+ variant: "popover",
2890
+ active: () => this.getSelectedImageSize(ctx.view.state) === "small",
2891
+ onClick: () => {
2892
+ this.setSelectedImageSize("small")(ctx.view.state, ctx.view.dispatch);
2893
+ }
2894
+ }),
2895
+ createDivider(ctx),
2896
+ createButton(ctx, {
2897
+ label: () => ctx.rte.getLocale().richTextEditor.imageSizes.fit,
2898
+ variant: "popover",
2899
+ active: () => this.getSelectedImageSize(ctx.view.state) === "fit",
2900
+ onClick: () => {
2901
+ this.setSelectedImageSize("fit")(ctx.view.state, ctx.view.dispatch);
2902
+ }
2903
+ }),
2904
+ createDivider(ctx),
2905
+ createButton(ctx, {
2906
+ label: () => ctx.rte.getLocale().richTextEditor.imageSizes.original,
2907
+ variant: "popover",
2908
+ active: () => this.getSelectedImageSize(ctx.view.state) === "original",
2909
+ onClick: () => {
2910
+ this.setSelectedImageSize("original")(ctx.view.state, ctx.view.dispatch);
2911
+ }
2912
+ })
2913
+ ]
2914
+ });
2915
+ popover.appendChild(content);
2916
+ view.dom.getRootNode().querySelector(".popovers").appendChild(popover);
2917
+ return {
2918
+ update: (view) => {
2919
+ ctx.updateBindings();
2920
+ const selectedImage = this.getSelectedInlineImage(view.state);
2921
+ if (selectedImage) {
2922
+ popover.anchorEl = view.nodeDOM(selectedImage.pos);
2923
+ popover.requestOpenState(true);
2924
+ } else {
2925
+ popover.anchorEl = void 0;
2926
+ popover.requestOpenState(false);
2927
+ }
2928
+ },
2929
+ destroy: () => {
2930
+ popover.remove();
2931
+ }
2932
+ };
2933
+ }
2934
+ })), this.contribution(keymap({ Escape: (state) => {
2935
+ if (this.getSelectedInlineImage(state)) {
2936
+ popover?.dismiss();
2937
+ return true;
2938
+ }
2939
+ return false;
2940
+ } }))];
2941
+ }
2942
+ calculateSmallWidth(naturalWidth) {
2943
+ return `${Math.min(300, naturalWidth / 2)}px`;
2944
+ }
2945
+ getSelectedInlineImage(state) {
2946
+ const sel = state.selection;
2947
+ if (sel instanceof NodeSelection && sel.node.type === state.schema.nodes.inlineImage) return {
2948
+ pos: sel.from,
2949
+ node: sel.node
2950
+ };
2951
+ return null;
2952
+ }
2953
+ setSelectedImageSize(size) {
2954
+ return (state, dispatch) => {
2955
+ const selectedImage = this.getSelectedInlineImage(state);
2956
+ if (!selectedImage) return false;
2957
+ const { naturalWidth } = selectedImage.node.attrs;
2958
+ if (size === "small" && naturalWidth === null) return false;
2959
+ const tr = state.tr;
2960
+ tr.setNodeAttribute(selectedImage.pos, "size", size === "small" ? this.calculateSmallWidth(naturalWidth) : size === "fit" ? "100%" : null);
2961
+ dispatch?.(tr.scrollIntoView());
2962
+ return true;
2963
+ };
2964
+ }
2965
+ getSelectedImageSize(state) {
2966
+ const selectedImage = this.getSelectedInlineImage(state);
2967
+ if (!selectedImage) return null;
2968
+ const { size, naturalWidth } = selectedImage.node.attrs;
2969
+ if (naturalWidth !== null && size === this.calculateSmallWidth(naturalWidth)) return "small";
2970
+ if (size === "100%") return "fit";
2971
+ if (size === null) return "original";
2972
+ return null;
2973
+ }
2974
+ };
2975
+ var RteInlineImageFeature = featureFacade(RteInlineImageFeatureImpl);
2976
+ //#endregion
2977
+ //#region src/shared/utils/promise.ts
2978
+ var resolvePromise = async (promise) => {
2979
+ try {
2980
+ return {
2981
+ type: "ok",
2982
+ result: await promise
2983
+ };
2984
+ } catch (e) {
2985
+ return {
2986
+ type: "error",
2987
+ error: e
2988
+ };
2989
+ }
2990
+ };
2991
+ //#endregion
2992
+ //#region src/lib/rich-text-editor/rte/features/file-handler.ts
2993
+ var RteFileHandlerFeatureImpl = class extends RteFeatureImpl {
2994
+ constructor(config) {
2995
+ super();
2996
+ this.config = config;
2997
+ this.name = "RteFileHandlerFeature";
2998
+ }
2999
+ getPlugins(rte) {
3000
+ const insertPointPlaceholderPlugin = new Plugin({
3001
+ state: {
3002
+ init() {
3003
+ return DecorationSet.empty;
3004
+ },
3005
+ apply(tr, set) {
3006
+ set = set.map(tr.mapping, tr.doc);
3007
+ const action = tr.getMeta(insertPointPlaceholderPlugin);
3008
+ if (action && action.add) {
3009
+ const placeholder = document.createElement("placeholder");
3010
+ const deco = Decoration.widget(action.add.pos, placeholder, {
3011
+ id: action.add.id,
3012
+ relaxedSide: true
3013
+ });
3014
+ set = set.add(tr.doc, [deco]);
3015
+ } else if (action && action.remove) set = set.remove(set.find(void 0, void 0, (spec) => spec.id == action.remove.id));
3016
+ return set;
3017
+ }
3018
+ },
3019
+ props: { decorations(state) {
3020
+ return this.getState(state);
3021
+ } }
3022
+ });
3023
+ const createInsertPointPlaceholder = (tr, pos) => {
3024
+ const id = generateRandomId();
3025
+ tr.setMeta(insertPointPlaceholderPlugin, { add: {
3026
+ id,
3027
+ pos
3028
+ } });
3029
+ return {
3030
+ getPos: (state) => {
3031
+ const found = insertPointPlaceholderPlugin.getState(state).find(void 0, void 0, (spec) => spec.id == id);
3032
+ return found.length ? found[0].from : null;
3033
+ },
3034
+ remove: (tr) => {
3035
+ tr.setMeta(insertPointPlaceholderPlugin, { remove: { id } });
3036
+ }
3037
+ };
3038
+ };
3039
+ const insertFragment = (tr, fragment, insertPoint) => {
3040
+ if (insertPoint.type === "selection") {
3041
+ const parsed = Slice.fromJSON(rte.schema, { content: fragment });
3042
+ tr.replaceSelection(parsed);
3043
+ } else {
3044
+ const parsed = Fragment.fromJSON(rte.schema, fragment);
3045
+ tr.insert(insertPoint.pos, parsed);
3046
+ }
3047
+ };
3048
+ const handleFiles = (files, insertPoint) => {
3049
+ const result = this.config.handleFiles(files);
3050
+ if (result === null) return;
3051
+ else if (result instanceof Promise) handleAsyncResult(result, insertPoint);
3052
+ else handleSyncResult(result, insertPoint);
3053
+ };
3054
+ const handleSyncResult = (result, insertPoint) => {
3055
+ const tr = rte.state.tr;
3056
+ insertFragment(tr, result, insertPoint);
3057
+ rte.dispatchTransaction(tr);
3058
+ };
3059
+ const handleAsyncResult = async (promise, insertPoint) => {
3060
+ const tr = rte.state.tr;
3061
+ if (insertPoint.type === "selection" && !tr.selection.empty) tr.deleteSelection();
3062
+ const pos = insertPoint.type === "selection" ? tr.selection.from : insertPoint.pos;
3063
+ const placeholder = createInsertPointPlaceholder(tr, pos);
3064
+ rte.dispatchTransaction(tr);
3065
+ const resolved = await resolvePromise(promise);
3066
+ const updatedPos = placeholder.getPos(rte.state);
3067
+ const insertTr = rte.state.tr;
3068
+ placeholder.remove(insertTr);
3069
+ if (updatedPos !== null && resolved.type === "ok") insertFragment(insertTr, resolved.result, {
3070
+ type: "pos",
3071
+ pos: updatedPos
3072
+ });
3073
+ rte.dispatchTransaction(insertTr);
3074
+ if (resolved.type === "error") console.error("Error in handleFiles handler:", resolved.error);
3075
+ };
3076
+ return [this.contribution(insertPointPlaceholderPlugin), this.contribution(new Plugin({ props: {
3077
+ handlePaste: (_view, event) => {
3078
+ const files = Array.from(event.clipboardData.files);
3079
+ if (!files.length) return false;
3080
+ handleFiles(files, { type: "selection" });
3081
+ return true;
3082
+ },
3083
+ handleDrop: (view, event) => {
3084
+ const files = Array.from(event.dataTransfer.files);
3085
+ if (!files.length) return false;
3086
+ let target = view.posAtCoords({
3087
+ left: event.clientX,
3088
+ top: event.clientY
3089
+ }).pos;
3090
+ if (view.dragging && view.dragging.slice) {
3091
+ const point = dropPoint(view.state.doc, target, view.dragging.slice);
3092
+ if (point != null) target = point;
3093
+ }
3094
+ handleFiles(files, {
3095
+ type: "pos",
3096
+ pos: target
3097
+ });
3098
+ return true;
3099
+ }
3100
+ } }))];
3101
+ }
3102
+ };
3103
+ var RteFileHandlerFeature = featureFacade(RteFileHandlerFeatureImpl);
3104
+ //#endregion
3105
+ //#region src/lib/rich-text-editor/rte/features/drop-handler.ts
3106
+ var RteDropHandlerFeatureImpl = class extends RteFeatureImpl {
3107
+ constructor(config) {
3108
+ super();
3109
+ this.config = config;
3110
+ this.name = "RteDebugFeature";
3111
+ }
3112
+ getPlugins() {
3113
+ const dragOverResults = /* @__PURE__ */ new WeakMap();
3114
+ let lastResult = false;
3115
+ const onDragOver = (event) => {
3116
+ if (dragOverResults.get(event) !== void 0) return;
3117
+ lastResult = this.config.onViewportDragOver?.(event) ?? false;
3118
+ };
3119
+ const onDrop = (event) => {
3120
+ this.config.onViewportDrop?.(event);
3121
+ this.config.onViewportDragFinish?.();
3122
+ };
3123
+ const onDragEnd = () => {
3124
+ this.config.onViewportDragFinish?.();
3125
+ };
3126
+ let isEntering = false;
3127
+ const onDragEnter = () => {
3128
+ isEntering = true;
3129
+ window.setTimeout(() => isEntering = false, 0);
3130
+ };
3131
+ const onDragLeave = () => {
3132
+ if (isEntering) return;
3133
+ this.config.onViewportDragFinish?.();
3134
+ };
3135
+ return [this.contribution(new Plugin({ view: (view) => {
3136
+ const viewport = view.root.host.editorViewportElement;
3137
+ viewport.addEventListener("dragover", onDragOver);
3138
+ viewport.addEventListener("drop", onDrop);
3139
+ viewport.addEventListener("dragend", onDragEnd);
3140
+ viewport.addEventListener("dragenter", onDragEnter);
3141
+ viewport.addEventListener("dragleave", onDragLeave);
3142
+ return { destroy() {
3143
+ viewport.removeEventListener("dragover", onDragOver);
3144
+ viewport.removeEventListener("drop", onDrop);
3145
+ viewport.removeEventListener("dragend", onDragEnd);
3146
+ viewport.removeEventListener("dragenter", onDragEnter);
3147
+ viewport.removeEventListener("dragleave", onDragLeave);
3148
+ } };
3149
+ } })), this.contribution(new Plugin({ props: { handleDOMEvents: {
3150
+ dragover: (_view, event) => {
3151
+ const result = this.config.onViewportDragOver?.(event) ?? false;
3152
+ dragOverResults.set(event, result);
3153
+ lastResult = result;
3154
+ if (result) {
3155
+ event.stopImmediatePropagation();
3156
+ event.preventDefault();
3157
+ return true;
3158
+ }
3159
+ return false;
3160
+ },
3161
+ drop: () => {
3162
+ return lastResult;
3163
+ }
3164
+ } } }), contributionPriority.high)];
3165
+ }
3166
+ };
3167
+ var RteDropHandlerFeature = featureFacade(RteDropHandlerFeatureImpl);
3168
+ //#endregion
3169
+ //#region src/lib/rich-text-editor/rte/features/toolbar-button.ts
3170
+ var RteToolbarButtonFeatureImpl = class extends RteFeatureImpl {
3171
+ constructor(featureId, options) {
3172
+ super();
3173
+ this.featureId = featureId;
3174
+ this.options = options;
3175
+ this.name = `RteToolbarButtonFeature[${featureId}]`;
3176
+ }
3177
+ getToolbarItems() {
3178
+ return [this.contribution({
3179
+ section: "insert",
3180
+ render: (ctx) => createButton(ctx, {
3181
+ label: this.options.label,
3182
+ icon: this.options.icon,
3183
+ onClick: () => {
3184
+ this.executeAction(ctx);
3185
+ }
3186
+ })
3187
+ }, 2 + (this.options.order ?? 0) / Number.MAX_SAFE_INTEGER)];
3188
+ }
3189
+ executeAction(ctx) {
3190
+ const { action } = this.options;
3191
+ switch (action.type) {
3192
+ case "insert-text": {
3193
+ const { state, dispatch } = ctx.view;
3194
+ const { from, to } = state.selection;
3195
+ dispatch(state.tr.insertText(action.text, from, to));
3196
+ break;
3197
+ }
3198
+ }
3199
+ }
3200
+ };
3201
+ var RteToolbarButtonFeature = featureFacade(RteToolbarButtonFeatureImpl);
3202
+ //#endregion
3203
+ //#region src/lib/rich-text-editor/rte/features/atom.ts
3204
+ var isGenerator = (value) => value !== null && typeof value === "object" && "next" in value;
3205
+ var AtomView = class {
3206
+ constructor(node, config, atomName) {
3207
+ this.dom = document.createElement("span");
3208
+ this.dom.className = "atom-wrapper";
3209
+ this.dom.setAttribute("part", `node--${atomName}`);
3210
+ const result = config.resolveValue ? config.resolveValue(node.attrs.value) : node.attrs.value;
3211
+ if (isGenerator(result)) {
3212
+ this.dom.textContent = "";
3213
+ this.handleResolvedGenerator(result);
3214
+ } else this.dom.textContent = result ?? "";
3215
+ }
3216
+ async handleResolvedGenerator(generator) {
3217
+ const iterator = generator[Symbol.asyncIterator]();
3218
+ let result;
3219
+ do {
3220
+ result = await iterator.next();
3221
+ this.dom.textContent = result.value ?? "";
3222
+ } while (!result.done);
3223
+ }
3224
+ };
3225
+ var RteAtomFeatureImpl = class extends RteFeatureImpl {
3226
+ constructor(atomName, config = {}) {
3227
+ super();
3228
+ this.atomName = atomName;
3229
+ this.config = config;
3230
+ this.name = `RteAtomFeature[${atomName}]`;
3231
+ }
3232
+ getSchema() {
3233
+ const atomSpec = {
3234
+ inline: true,
3235
+ group: "inline",
3236
+ selectable: true,
3237
+ atom: true,
3238
+ attrs: { value: { validate: "string" } },
3239
+ parseDOM: [{
3240
+ tag: `span[data-atom-type="${this.atomName}"][data-value]`,
3241
+ getAttrs: (dom) => ({ value: dom.getAttribute("data-value") })
3242
+ }],
3243
+ /** Since we use a NodeView, toDOM is only used for Rich Text View */
3244
+ toDOM: (node) => {
3245
+ const serializedValue = this.config.serializeValueToHtml ? this.config.serializeValueToHtml(node.attrs.value) : node.attrs.value;
3246
+ if (serializedValue === null) return document.createDocumentFragment();
3247
+ return [
3248
+ "span",
3249
+ { part: `node--${this.atomName}` },
3250
+ serializedValue
3251
+ ];
3252
+ },
3253
+ serializeToDOM: (node) => {
3254
+ const serializedValue = this.config.serializeValueToHtml ? this.config.serializeValueToHtml(node.attrs.value) : node.attrs.value;
3255
+ if (serializedValue === null) return document.createTextNode("");
3256
+ return [
3257
+ "span",
3258
+ {
3259
+ "data-atom-type": this.atomName,
3260
+ "data-value": node.attrs.value
3261
+ },
3262
+ serializedValue
3263
+ ];
3264
+ }
3265
+ };
3266
+ return [this.contribution({ nodes: { [this.atomName]: atomSpec } })];
3267
+ }
3268
+ getPlugins(_rte) {
3269
+ return [this.contribution(new Plugin({ props: { nodeViews: { [this.atomName]: (node) => new AtomView(node, this.config, this.atomName) } } }))];
3270
+ }
3271
+ };
3272
+ var RteAtomFeature = featureFacade(RteAtomFeatureImpl);
3273
+ //#endregion
3274
+ //#region src/lib/rich-text-editor/rte/features/input-rule.ts
3275
+ var RteInputRuleFeatureImpl = class extends RteFeatureImpl {
3276
+ constructor(featureId, options) {
3277
+ super();
3278
+ this.featureId = featureId;
3279
+ this.options = options;
3280
+ this.name = `RteInputRuleFeature[${featureId}]`;
3281
+ }
3282
+ getInputRules(rte) {
3283
+ const basePattern = `(?:${this.options.pattern.source})`;
3284
+ const handler = (state, match, start, end) => {
3285
+ const fragment = this.options.handler(match);
3286
+ if (!fragment) return null;
3287
+ return state.tr.replaceWith(start, end, Fragment.fromJSON(rte.schema, fragment));
3288
+ };
3289
+ const regex = this.options.matchAfterWhitespace ? new RegExp(`${basePattern} $`) : new RegExp(`${basePattern}$`);
3290
+ const spec = { rule: new InputRule(regex, handler) };
3291
+ if (this.options.matchAfterWhitespace) spec.enterHandler = {
3292
+ regex: new RegExp(`${basePattern}$`),
3293
+ handler
3294
+ };
3295
+ return [this.contribution(spec)];
3296
+ }
3297
+ };
3298
+ var RteInputRuleFeature = featureFacade(RteInputRuleFeatureImpl);
3299
+ //#endregion
3300
+ //#region src/lib/rich-text-editor/rte/features/keyboard-shortcuts.ts
3301
+ function toCommand(handler, rteInstance) {
3302
+ return (_state, _dispatch) => handler(rteInstance);
3303
+ }
3304
+ var RteKeyboardShortcutsFeatureImpl = class extends RteFeatureImpl {
3305
+ constructor(featureId, options) {
3306
+ super();
3307
+ this.featureId = featureId;
3308
+ this.options = options;
3309
+ this.name = `RteKeyboardShortcutsFeature[${featureId}]`;
3310
+ }
3311
+ getPlugins(rte) {
3312
+ const bindings = {};
3313
+ for (const [key, handler] of Object.entries(this.options.shortcuts)) bindings[key] = toCommand(handler, rte.facade);
3314
+ return [this.contribution(keymap(bindings), contributionPriority.high)];
3315
+ }
3316
+ };
3317
+ var RteKeyboardShortcutsFeature = featureFacade(RteKeyboardShortcutsFeatureImpl);
3318
+ //#endregion
3319
+ //#region src/lib/rich-text-editor/rte/features/suggest.style.scss?inline
3320
+ var suggest_style_default = ".suggest-popover{flex-direction:column;gap:2px;max-block-size:408px;min-inline-size:128px;max-inline-size:248px;padding:4px;display:flex}.suggest-loading-widget{vertical-align:middle;white-space:normal;align-items:center;margin-inline-start:2px;display:inline-flex}.suggest-empty-message{color:var(--vvd-color-neutral-300);font:var(--vvd-typography-base);text-align:center;justify-content:center;align-items:center;min-block-size:40px;display:flex}";
3321
+ //#endregion
3322
+ //#region src/lib/rich-text-editor/rte/features/suggest.ts
3323
+ var isPopoverOpen = (state) => Boolean(state?.suggestions && !state.dismissed);
3324
+ var popoverShowsResults = (state) => isPopoverOpen(state) && state.suggestions.items.length > 0;
3325
+ function findMatch(state, regex) {
3326
+ const { $cursor } = state.selection;
3327
+ if (!$cursor) return null;
3328
+ const textBefore = textBeforeCursor($cursor);
3329
+ const match = regex.exec(textBefore);
3330
+ if (!match) return null;
3331
+ const blockStart = $cursor.pos - $cursor.parentOffset;
3332
+ return {
3333
+ text: match[0],
3334
+ groups: [...match],
3335
+ start: blockStart + match.index,
3336
+ end: blockStart + match.index + match[0].length
3337
+ };
3338
+ }
3339
+ var replaceMatch = (view, match, fragment) => {
3340
+ const { state } = view;
3341
+ view.dispatch(closeHistory(state.tr));
3342
+ const tr = view.state.tr;
3343
+ tr.replaceWith(match.start, match.end, Fragment.fromJSON(view.state.schema, fragment));
3344
+ const newPos = tr.mapping.map(match.end);
3345
+ tr.setSelection(TextSelection.create(tr.doc, newPos));
3346
+ view.dispatch(tr.scrollIntoView());
3347
+ };
3348
+ var RteSuggestFeatureImpl = class extends RteFeatureImpl {
3349
+ selectSuggestion(view, suggestState, suggestion) {
3350
+ const fragment = this.options.select(suggestion);
3351
+ replaceMatch(view, suggestState.match, fragment);
3352
+ view.focus();
3353
+ }
3354
+ async startLoadingSuggestions(match, dispatch) {
3355
+ const gen = ++this.loadGeneration;
3356
+ const suggestions = await this.options.load(match);
3357
+ if (gen !== this.loadGeneration) return;
3358
+ dispatch({
3359
+ type: "load",
3360
+ generation: gen,
3361
+ suggestions
3362
+ });
3363
+ }
3364
+ constructor(featureId, options) {
3365
+ super();
3366
+ this.featureId = featureId;
3367
+ this.options = options;
3368
+ this.pluginKey = new PluginKey("suggest");
3369
+ this.loadGeneration = 0;
3370
+ this.name = `RteSuggestFeature[${featureId}]`;
3371
+ }
3372
+ getStyles() {
3373
+ return [this.contribution(suggest_style_default)];
3374
+ }
3375
+ getPlugins(rte) {
3376
+ const createSuggestActionTr = (action) => rte.state.tr.setMeta(this.pluginKey, action);
3377
+ const dispatchSuggestAction = (action) => rte.dispatchTransaction(createSuggestActionTr(action));
3378
+ const suggestPlugin = new Plugin({
3379
+ key: this.pluginKey,
3380
+ state: {
3381
+ init: () => null,
3382
+ apply: (tr, prevState, _prevEditor, newEditor) => {
3383
+ const match = findMatch(newEditor, this.options.pattern);
3384
+ if (!match) return null;
3385
+ if (!prevState && !tr.docChanged) return null;
3386
+ if (prevState?.dismissed) return prevState;
3387
+ const loadingDecoration = (isLoading) => {
3388
+ if (!isLoading) return DecorationSet.empty;
3389
+ return Boolean(prevState?.loadingDecoration.find().length ?? 0) ? prevState.loadingDecoration.map(tr.mapping, tr.doc) : DecorationSet.create(tr.doc, [Decoration.widget(match.end, () => {
3390
+ const wrapper = document.createElement("span");
3391
+ wrapper.className = "suggest-loading-widget";
3392
+ const spinner = rte.createComponent(ProgressRing);
3393
+ spinner.size = -6;
3394
+ wrapper.appendChild(spinner);
3395
+ return wrapper;
3396
+ }, {
3397
+ ignoreSelection: true,
3398
+ side: 1
3399
+ })]);
3400
+ };
3401
+ const action = tr.getMeta(this.pluginKey);
3402
+ if (prevState && action) switch (action.type) {
3403
+ case "load": return {
3404
+ ...prevState,
3405
+ suggestions: {
3406
+ generation: action.generation,
3407
+ items: action.suggestions,
3408
+ selectedIndex: 0,
3409
+ visibleFocus: false
3410
+ },
3411
+ loadingDecoration: loadingDecoration(false)
3412
+ };
3413
+ case "navigate": {
3414
+ /* v8 ignore next 3 -- defensive: navigate is only dispatched after results are loaded @preserve */
3415
+ if (!prevState.suggestions?.items.length) return prevState;
3416
+ if (!prevState.suggestions.visibleFocus) return {
3417
+ ...prevState,
3418
+ suggestions: {
3419
+ ...prevState.suggestions,
3420
+ visibleFocus: true
3421
+ }
3422
+ };
3423
+ const newIndex = Math.max(0, Math.min(prevState.suggestions.items.length - 1, prevState.suggestions.selectedIndex + (action.action === "up" ? -1 : 1)));
3424
+ return {
3425
+ ...prevState,
3426
+ suggestions: {
3427
+ ...prevState.suggestions,
3428
+ selectedIndex: newIndex
3429
+ }
3430
+ };
3431
+ }
3432
+ case "dismiss": return {
3433
+ ...prevState,
3434
+ dismissed: true,
3435
+ loadingDecoration: DecorationSet.empty
3436
+ };
3437
+ }
3438
+ if (!prevState) {
3439
+ this.startLoadingSuggestions(match.groups, dispatchSuggestAction);
3440
+ return {
3441
+ match,
3442
+ loadingDecoration: loadingDecoration(true)
3443
+ };
3444
+ }
3445
+ const matchChanged = match.groups[0] !== prevState.match.groups[0];
3446
+ if (matchChanged) this.startLoadingSuggestions(match.groups, dispatchSuggestAction);
3447
+ return {
3448
+ ...prevState,
3449
+ match,
3450
+ suggestions: prevState.suggestions ? {
3451
+ ...prevState.suggestions,
3452
+ visibleFocus: false
3453
+ } : void 0,
3454
+ loadingDecoration: loadingDecoration(matchChanged)
3455
+ };
3456
+ }
3457
+ },
3458
+ props: { decorations: (state) => {
3459
+ const suggestState = this.pluginKey.getState(state);
3460
+ if (!suggestState) return null;
3461
+ return suggestState.loadingDecoration.add(state.doc, [Decoration.inline(suggestState.match.start, suggestState.match.end, { id: `suggest-anchor-${this.featureId}` })]);
3462
+ } },
3463
+ view: (view) => {
3464
+ const ctx = new UiCtx(view, rte, {
3465
+ popupPlacement: "bottom",
3466
+ shouldReturnFocusToEditor: true
3467
+ });
3468
+ const popover = rte.createComponent(Popover);
3469
+ popover.anchorId = `suggest-anchor-${this.featureId}`;
3470
+ popover.kind = "autocomplete";
3471
+ popover.offset = 4;
3472
+ const content = createDiv(ctx, {
3473
+ className: "suggest-popover",
3474
+ children: []
3475
+ });
3476
+ popover.appendChild(content);
3477
+ view.dom.getRootNode().querySelector(".popovers").appendChild(popover);
3478
+ const emptySlotName = `${this.featureId}-suggestions-empty`;
3479
+ const host = view.dom.getRootNode().host;
3480
+ let emptySlotShowing = false;
3481
+ const updateEmptySlotShowing = (showing) => {
3482
+ if (!emptySlotShowing && showing) dispatchSlottableRequest(host, "suggestions-empty-state", emptySlotName, { id: this.featureId });
3483
+ if (emptySlotShowing && !showing) dispatchSlottableRequest(host, "suggestions-empty-state", emptySlotName, removeSymbol);
3484
+ emptySlotShowing = showing;
3485
+ };
3486
+ const updatePopoverContent = (suggestState) => {
3487
+ content.innerHTML = "";
3488
+ const suggestions = suggestState.suggestions;
3489
+ const showEmptyState = suggestions.items.length === 0;
3490
+ updateEmptySlotShowing(showEmptyState);
3491
+ if (showEmptyState) {
3492
+ const emptySlot = document.createElement("slot");
3493
+ emptySlot.name = emptySlotName;
3494
+ emptySlot.textContent = rte.getLocale().richTextEditor.suggestNoResults;
3495
+ content.appendChild(createDiv(ctx, {
3496
+ className: "suggest-empty-message",
3497
+ children: [emptySlot]
3498
+ }));
3499
+ return;
3500
+ }
3501
+ for (const [index, suggestion] of suggestions.items.entries()) {
3502
+ const item = rte.createComponent(ListboxOption);
3503
+ item.text = suggestion.text;
3504
+ item.textSecondary = suggestion.textSecondary;
3505
+ if (index === suggestions.selectedIndex) {
3506
+ item.selected = true;
3507
+ if (suggestions.visibleFocus) item._highlighted = true;
3508
+ queueMicrotask(() => {
3509
+ item.scrollIntoView({ block: "nearest" });
3510
+ });
3511
+ }
3512
+ item.addEventListener("click", (e) => {
3513
+ e.preventDefault();
3514
+ e.stopPropagation();
3515
+ this.selectSuggestion(view, suggestState, suggestion);
3516
+ });
3517
+ content.appendChild(item);
3518
+ }
3519
+ };
3520
+ return {
3521
+ update: (view) => {
3522
+ ctx.updateBindings();
3523
+ const suggestState = this.pluginKey.getState(view.state);
3524
+ const showPopover = isPopoverOpen(suggestState);
3525
+ popover.requestOpenState(showPopover);
3526
+ if (showPopover) updatePopoverContent(suggestState);
3527
+ else updateEmptySlotShowing(false);
3528
+ },
3529
+ destroy: () => {
3530
+ updateEmptySlotShowing(false);
3531
+ popover.remove();
3532
+ }
3533
+ };
3534
+ }
3535
+ });
3536
+ return [this.contribution(suggestPlugin), this.contribution(keymap({
3537
+ ArrowUp: (state, dispatch) => {
3538
+ if (!popoverShowsResults(this.pluginKey.getState(state))) return false;
3539
+ dispatch?.(createSuggestActionTr({
3540
+ type: "navigate",
3541
+ action: "up"
3542
+ }));
3543
+ return true;
3544
+ },
3545
+ ArrowDown: (state, dispatch) => {
3546
+ if (!popoverShowsResults(this.pluginKey.getState(state))) return false;
3547
+ dispatch?.(createSuggestActionTr({
3548
+ type: "navigate",
3549
+ action: "down"
3550
+ }));
3551
+ return true;
3552
+ },
3553
+ Enter: (state, _dispatch, view) => {
3554
+ const suggestState = this.pluginKey.getState(state);
3555
+ if (!popoverShowsResults(suggestState)) return false;
3556
+ const suggestion = suggestState.suggestions.items[suggestState.suggestions.selectedIndex];
3557
+ /* v8 ignore next 3 -- defensive: view is always passed by keymap @preserve */
3558
+ if (view) this.selectSuggestion(view, suggestState, suggestion);
3559
+ return true;
3560
+ },
3561
+ Escape: (state, dispatch) => {
3562
+ if (!isPopoverOpen(this.pluginKey.getState(state))) return false;
3563
+ dispatch?.(createSuggestActionTr({ type: "dismiss" }));
3564
+ return true;
3565
+ }
3566
+ }), contributionPriority.high)];
3567
+ }
3568
+ };
3569
+ var RteSuggestFeature = featureFacade(RteSuggestFeatureImpl);
3570
+ //#endregion
3571
+ //#region src/lib/rich-text-editor/rte/features/character-count.ts
3572
+ var countCharacters = (doc) => doc.textBetween(0, doc.content.size, void 0, " ").length;
3573
+ var RteCharacterCountFeatureImpl = class extends RteFeatureImpl {
3574
+ constructor(config) {
3575
+ super();
3576
+ this.config = config;
3577
+ this.name = "RteCharacterCountFeature";
3578
+ }
3579
+ getPlugins() {
3580
+ const limit = this.config?.limit;
3581
+ if (limit === void 0) return [];
3582
+ return [this.contribution(new Plugin({ filterTransaction: (transaction, state) => {
3583
+ if (!transaction.docChanged) return true;
3584
+ const oldSize = countCharacters(state.doc);
3585
+ const newSize = countCharacters(transaction.doc);
3586
+ if (newSize <= limit) return true;
3587
+ if (oldSize > limit) return newSize <= oldSize;
3588
+ if (!transaction.getMeta("paste")) return false;
3589
+ const pos = transaction.selection.$head.pos;
3590
+ const from = pos - (newSize - limit);
3591
+ const to = pos;
3592
+ transaction.deleteRange(from, to);
3593
+ return countCharacters(transaction.doc) <= limit;
3594
+ } }))];
3595
+ }
3596
+ getPublicInterface(rte) {
3597
+ const limit = this.config?.limit;
3598
+ return {
3599
+ get characters() {
3600
+ return countCharacters(rte.state.doc);
3601
+ },
3602
+ get limit() {
3603
+ return limit;
3604
+ }
3605
+ };
3606
+ }
3607
+ };
3608
+ var RteCharacterCountFeature = featureFacade(RteCharacterCountFeatureImpl);
110
3609
  //#endregion
111
- //#region src/lib/rich-text-view/definition.ts
112
- var richTextViewDefinition = defineVividComponent("rich-text-view", RichTextView, RichTextViewTemplate, [], {
113
- styles: rich_text_view_default,
3610
+ //#region src/lib/rich-text-editor/definition.ts
3611
+ var richTextEditorDefinition = defineVividComponent("rich-text-editor", RichTextEditor, RichTextEditorTemplate, [
3612
+ dividerDefinition,
3613
+ selectDefinition,
3614
+ listboxOptionDefinition,
3615
+ buttonDefinition,
3616
+ tooltipDefinition,
3617
+ menuDefinition,
3618
+ menuItemDefinition,
3619
+ textFieldDefinition,
3620
+ popoverDefinition,
3621
+ progressRingDefinition
3622
+ ], {
3623
+ styles: rich_text_editor_default,
114
3624
  shadowOptions: { delegatesFocus: true }
115
3625
  });
116
3626
  /**
117
- * Registers the rich-text-view element with the design system.
3627
+ * Registers the rich-text-editor element with the design system.
118
3628
  *
119
3629
  * @param prefix - the prefix to use for the component name
120
3630
  */
121
- var registerRichTextView = createRegisterFunction(richTextViewDefinition);
3631
+ var registerRichTextEditor = createRegisterFunction(richTextEditorDefinition);
122
3632
  //#endregion
123
- export { richTextViewDefinition as n, RichTextView as r, registerRichTextView as t };
3633
+ export { RichTextEditor as A, RtePlaceholderFeature as C, RteConfig as D, RteBase as E, RteHtmlSerializer as O, RteHardBreakFeature as S, RteTextBlockPickerFeature as T, RteStrikethroughFeature as _, RteKeyboardShortcutsFeature as a, RteBoldFeature as b, RteToolbarButtonFeature as c, RteInlineImageFeature as d, RteLinkFeature as f, RteMonospaceFeature as g, RteTextColorPickerFeature as h, RteSuggestFeature as i, RteHtmlParser as k, RteDropHandlerFeature as l, RteListFeature as m, richTextEditorDefinition as n, RteInputRuleFeature as o, RteAlignmentFeature as p, RteCharacterCountFeature as r, RteAtomFeature as s, registerRichTextEditor as t, RteFileHandlerFeature as u, RteUnderlineFeature as v, RteToolbarFeature as w, RteFontSizePickerFeature as x, RteItalicFeature as y };