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