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