@vonage/vivid 5.23.1-preview.0 → 5.24.0

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