@vonage/vivid 5.23.1 → 5.24.0

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