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