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