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