@vonage/vivid 5.0.0 → 5.2.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/{shared/definition2.cjs → accordion/definition.cjs} +20 -20
- package/{shared/definition2.js → accordion/definition.js} +5 -7
- package/accordion/index.cjs +5 -5
- package/accordion/index.js +129 -3
- package/accordion-item/definition.cjs +145 -0
- package/accordion-item/definition.js +139 -0
- package/accordion-item/index.cjs +1 -5
- package/accordion-item/index.js +2 -3
- package/{shared/definition3.cjs → action-group/definition.cjs} +12 -9
- package/{shared/definition3.js → action-group/definition.js} +5 -4
- package/action-group/index.cjs +6 -5
- package/action-group/index.js +49 -3
- package/{shared/definition4.cjs → alert/definition.cjs} +33 -31
- package/{shared/definition4.js → alert/definition.js} +11 -11
- package/alert/index.cjs +30 -5
- package/alert/index.js +158 -3
- package/{shared/definition5.cjs → audio-player/definition.cjs} +95 -61
- package/{shared/definition5.js → audio-player/definition.js} +48 -16
- package/audio-player/index.cjs +68 -4
- package/audio-player/index.js +333 -2
- package/{shared/definition6.cjs → avatar/definition.cjs} +28 -26
- package/{shared/definition6.js → avatar/definition.js} +7 -7
- package/avatar/index.cjs +18 -5
- package/avatar/index.js +93 -3
- package/{shared/definition7.cjs → badge/definition.cjs} +18 -16
- package/{shared/definition7.js → badge/definition.js} +6 -6
- package/badge/index.cjs +4 -5
- package/badge/index.js +66 -3
- package/{shared/definition8.cjs → banner/definition.cjs} +26 -25
- package/{shared/definition8.js → banner/definition.js} +10 -11
- package/banner/index.cjs +29 -4
- package/banner/index.js +128 -2
- package/{shared/definition10.cjs → breadcrumb/definition.cjs} +11 -9
- package/{shared/definition10.js → breadcrumb/definition.js} +5 -5
- package/breadcrumb/index.cjs +12 -5
- package/breadcrumb/index.js +69 -3
- package/{shared/definition9.cjs → breadcrumb-item/definition.cjs} +18 -15
- package/{shared/definition9.js → breadcrumb-item/definition.js} +7 -7
- package/breadcrumb-item/index.cjs +5 -5
- package/breadcrumb-item/index.js +33 -3
- package/bundled/_has.cjs +1 -0
- package/bundled/_has.js +34 -0
- package/bundled/affix.cjs +13 -0
- package/bundled/affix.js +63 -0
- package/bundled/anchored.cjs +4 -0
- package/bundled/anchored.js +67 -0
- package/bundled/aria.cjs +1 -0
- package/bundled/aria.js +7 -0
- package/bundled/attribute-binding-behaviour.cjs +1 -0
- package/bundled/attribute-binding-behaviour.js +27 -0
- package/bundled/base-progress.cjs +1 -0
- package/bundled/base-progress.js +57 -0
- package/bundled/breadcrumb-item.cjs +1 -0
- package/bundled/breadcrumb-item.js +21 -0
- package/bundled/button.cjs +1 -0
- package/bundled/button.js +106 -0
- package/bundled/calendar-event.cjs +1 -0
- package/bundled/calendar-event.js +34 -0
- package/bundled/calendar-picker.template.cjs +148 -0
- package/bundled/calendar-picker.template.js +3371 -0
- package/bundled/char-count.cjs +13 -0
- package/bundled/char-count.js +54 -0
- package/bundled/children.cjs +1 -0
- package/bundled/children.js +38 -0
- package/bundled/class-names.cjs +1 -0
- package/bundled/class-names.js +9 -0
- package/bundled/definition.cjs +39 -0
- package/bundled/definition.js +122 -0
- package/bundled/definition10.cjs +19 -0
- package/bundled/definition10.js +73 -0
- package/bundled/definition11.cjs +10 -0
- package/bundled/definition11.js +44 -0
- package/bundled/definition12.cjs +1 -0
- package/bundled/definition12.js +20 -0
- package/bundled/definition13.cjs +73 -0
- package/bundled/definition13.js +359 -0
- package/bundled/definition14.cjs +5 -0
- package/bundled/definition14.js +29 -0
- package/bundled/definition15.cjs +30 -0
- package/bundled/definition15.js +80 -0
- package/bundled/definition16.cjs +19 -0
- package/bundled/definition16.js +103 -0
- package/bundled/definition17.cjs +13 -0
- package/bundled/definition17.js +137 -0
- package/bundled/definition18.cjs +12 -0
- package/bundled/definition18.js +94 -0
- package/bundled/definition19.cjs +70 -0
- package/bundled/definition19.js +674 -0
- package/bundled/definition2.cjs +20 -0
- package/bundled/definition2.js +180 -0
- package/bundled/definition20.cjs +20 -0
- package/bundled/definition20.js +106 -0
- package/bundled/definition21.cjs +5 -0
- package/bundled/definition21.js +19 -0
- package/bundled/definition22.cjs +24 -0
- package/bundled/definition22.js +151 -0
- package/bundled/definition3.cjs +29 -0
- package/bundled/definition3.js +195 -0
- package/bundled/definition4.cjs +6 -0
- package/bundled/definition4.js +42 -0
- package/bundled/definition5.cjs +1 -0
- package/bundled/definition5.js +345 -0
- package/bundled/definition6.cjs +31 -0
- package/bundled/definition6.js +268 -0
- package/bundled/definition7.cjs +30 -0
- package/bundled/definition7.js +288 -0
- package/bundled/definition8.cjs +19 -0
- package/bundled/definition8.js +145 -0
- package/bundled/definition9.cjs +14 -0
- package/bundled/definition9.js +1406 -0
- package/bundled/delegates-aria.cjs +1 -0
- package/bundled/delegates-aria.js +77 -0
- package/bundled/divider.cjs +1 -0
- package/bundled/divider.js +34 -0
- package/bundled/dom.cjs +1 -0
- package/bundled/dom.js +6 -0
- package/bundled/enums.cjs +1 -0
- package/bundled/enums.js +9 -0
- package/bundled/form-associated.cjs +1 -0
- package/bundled/form-associated.js +320 -0
- package/bundled/form-element.cjs +1 -0
- package/bundled/form-element.js +56 -0
- package/bundled/host-semantics.cjs +1 -0
- package/bundled/host-semantics.js +57 -0
- package/bundled/index.cjs +1 -0
- package/bundled/index.js +6 -0
- package/bundled/key-codes.cjs +1 -0
- package/bundled/key-codes.js +16 -0
- package/bundled/linkable.cjs +15 -0
- package/bundled/linkable.js +49 -0
- package/bundled/listbox.cjs +1 -0
- package/bundled/listbox.js +345 -0
- package/bundled/localized.cjs +1 -0
- package/bundled/localized.js +460 -0
- package/bundled/mixins.cjs +33 -0
- package/bundled/mixins.js +226 -0
- package/bundled/numbers.cjs +1 -0
- package/bundled/numbers.js +14 -0
- package/bundled/option.cjs +1 -0
- package/bundled/option.js +158 -0
- package/bundled/picker-field.template.cjs +67 -0
- package/bundled/picker-field.template.js +242 -0
- package/bundled/playbackRates.cjs +1 -0
- package/bundled/playbackRates.js +11 -0
- package/bundled/ref.cjs +1 -0
- package/bundled/ref.js +32 -0
- package/bundled/repeat.cjs +1 -0
- package/bundled/repeat.js +341 -0
- package/bundled/scrollIntoView.cjs +1 -0
- package/bundled/scrollIntoView.js +33 -0
- package/bundled/single-date-picker.cjs +1 -0
- package/bundled/single-date-picker.js +39 -0
- package/bundled/single-value-picker.cjs +1 -0
- package/bundled/single-value-picker.js +87 -0
- package/bundled/slider.template.cjs +41 -0
- package/bundled/slider.template.js +100 -0
- package/bundled/slotted.cjs +1 -0
- package/bundled/slotted.js +81 -0
- package/bundled/strings.cjs +1 -0
- package/bundled/strings.js +7 -0
- package/bundled/text-field.cjs +1 -0
- package/bundled/text-field.js +4 -0
- package/bundled/time-selection-picker.template.cjs +46 -0
- package/bundled/time-selection-picker.template.js +575 -0
- package/bundled/vivid-element.cjs +1 -0
- package/bundled/vivid-element.js +1761 -0
- package/bundled/when.cjs +1 -0
- package/bundled/when.js +11 -0
- package/bundled/with-contextual-help.cjs +1 -0
- package/bundled/with-contextual-help.js +32 -0
- package/bundled/with-error-text.cjs +1 -0
- package/bundled/with-error-text.js +39 -0
- package/bundled/with-success-text.cjs +1 -0
- package/bundled/with-success-text.js +16 -0
- package/button/definition.cjs +14 -0
- package/button/definition.js +4 -0
- package/button/index.cjs +1 -5
- package/button/index.js +2 -3
- package/{shared/definition13.cjs → calendar/definition.cjs} +27 -449
- package/{shared/definition13.js → calendar/definition.js} +7 -431
- package/calendar/index.cjs +53 -5
- package/calendar/index.js +431 -3
- package/{shared/definition12.cjs → calendar-event/definition.cjs} +12 -9
- package/{shared/definition12.js → calendar-event/definition.js} +6 -6
- package/calendar-event/index.cjs +9 -5
- package/calendar-event/index.js +43 -3
- package/card/definition.cjs +186 -0
- package/{shared/definition14.js → card/definition.js} +10 -11
- package/card/index.cjs +47 -5
- package/card/index.js +163 -3
- package/{shared/definition15.cjs → checkbox/definition.cjs} +30 -29
- package/{shared/definition15.js → checkbox/definition.js} +12 -13
- package/checkbox/index.cjs +1 -5
- package/checkbox/index.js +2 -3
- package/{shared/definition16.cjs → combobox/definition.cjs} +61 -56
- package/{shared/definition16.js → combobox/definition.js} +30 -27
- package/combobox/index.cjs +69 -5
- package/combobox/index.js +519 -3
- package/contextual-help/definition.cjs +62 -0
- package/contextual-help/definition.js +57 -0
- package/contextual-help/index.cjs +1 -0
- package/contextual-help/index.js +2 -0
- package/custom-elements.json +2504 -335
- package/{shared/definition17.cjs → data-grid/definition.cjs} +111 -121
- package/{shared/definition17.js → data-grid/definition.js} +11 -23
- package/data-grid/index.cjs +81 -5
- package/data-grid/index.js +1011 -3
- package/{shared/definition18.cjs → date-picker/definition.cjs} +20 -17
- package/{shared/definition18.js → date-picker/definition.js} +12 -11
- package/date-picker/index.cjs +1 -5
- package/date-picker/index.js +115 -3
- package/{shared/definition19.cjs → date-range-picker/definition.cjs} +26 -23
- package/{shared/definition19.js → date-range-picker/definition.js} +10 -9
- package/date-range-picker/index.cjs +1 -5
- package/date-range-picker/index.js +335 -3
- package/{shared/definition20.cjs → date-time-picker/definition.cjs} +27 -24
- package/{shared/definition20.js → date-time-picker/definition.js} +13 -12
- package/date-time-picker/index.cjs +8 -5
- package/date-time-picker/index.js +216 -3
- package/{shared/definition21.cjs → dial-pad/definition.cjs} +89 -40
- package/{shared/definition21.js → dial-pad/definition.js} +60 -13
- package/dial-pad/index.cjs +57 -5
- package/dial-pad/index.js +245 -3
- package/{shared/definition22.cjs → dialog/definition.cjs} +48 -47
- package/{shared/definition22.js → dialog/definition.js} +10 -11
- package/dialog/index.cjs +44 -5
- package/dialog/index.js +257 -3
- package/{shared/definition23.cjs → divider/definition.cjs} +10 -6
- package/{shared/definition23.js → divider/definition.js} +6 -5
- package/divider/index.cjs +1 -5
- package/divider/index.js +2 -3
- package/elevation/definition.cjs +11 -0
- package/elevation/definition.js +2 -0
- package/elevation/index.cjs +1 -5
- package/elevation/index.js +2 -3
- package/empty-state/definition.cjs +81 -0
- package/empty-state/definition.js +75 -0
- package/empty-state/index.cjs +14 -5
- package/empty-state/index.js +64 -3
- package/fab/definition.cjs +105 -0
- package/fab/definition.js +99 -0
- package/fab/index.cjs +20 -5
- package/fab/index.js +86 -3
- package/file-picker/definition.cjs +519 -0
- package/file-picker/definition.js +513 -0
- package/file-picker/index.cjs +61 -5
- package/file-picker/index.js +391 -3
- package/{shared/definition27.cjs → header/definition.cjs} +14 -11
- package/{shared/definition27.js → header/definition.js} +6 -5
- package/header/index.cjs +19 -5
- package/header/index.js +57 -3
- package/{shared/definition28.cjs → icon/definition.cjs} +25 -149
- package/{shared/definition28.js → icon/definition.js} +6 -132
- package/icon/index.cjs +1 -5
- package/icon/index.js +2 -3
- package/index.cjs +268 -264
- package/index.js +72 -71
- package/{shared/definition29.cjs → layout/definition.cjs} +13 -10
- package/{shared/definition29.js → layout/definition.js} +4 -3
- package/layout/index.cjs +3 -5
- package/layout/index.js +52 -3
- package/lib/accordion-item/accordion-item.d.ts +0 -1
- package/lib/action-group/action-group.d.ts +0 -1
- package/lib/alert/alert.d.ts +0 -2
- package/lib/audio-player/audio-player.d.ts +4 -1
- package/lib/avatar/avatar.d.ts +0 -1
- package/lib/badge/badge.d.ts +0 -1
- package/lib/banner/banner.d.ts +0 -3
- package/lib/breadcrumb/breadcrumb.d.ts +0 -1
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +0 -1
- package/lib/button/button.d.ts +1 -3
- package/lib/calendar-event/calendar-event.d.ts +0 -1
- package/lib/card/card.d.ts +0 -1
- package/lib/checkbox/checkbox.d.ts +0 -6
- package/lib/combobox/combobox.d.ts +483 -72
- package/lib/components.d.ts +1 -0
- package/lib/contextual-help/contextual-help.d.ts +5 -0
- package/lib/contextual-help/contextual-help.template.d.ts +3 -0
- package/lib/contextual-help/definition.d.ts +1 -0
- package/lib/data-grid/data-grid-cell.d.ts +0 -2
- package/lib/data-grid/data-grid-row.d.ts +0 -1
- package/lib/date-picker/date-picker.d.ts +892 -888
- package/lib/date-range-picker/date-range-picker.d.ts +590 -588
- package/lib/date-time-picker/date-time-picker.d.ts +893 -889
- package/lib/dial-pad/dial-pad.d.ts +0 -1
- package/lib/dial-pad/dial-pad.template.d.ts +1 -1
- package/lib/dial-pad/locale.d.ts +1 -0
- package/lib/dialog/dialog.d.ts +0 -2
- package/lib/divider/divider.d.ts +0 -1
- package/lib/fab/fab.d.ts +1 -1
- package/lib/file-picker/accept.d.ts +1 -0
- package/lib/file-picker/data-transfer.d.ts +1 -0
- package/lib/file-picker/file-picker.d.ts +490 -91
- package/lib/header/header.d.ts +0 -1
- package/lib/menu/menu.d.ts +1 -2
- package/lib/menu-item/menu-item.d.ts +0 -2
- package/lib/nav/nav.d.ts +0 -1
- package/lib/nav-disclosure/nav-disclosure.d.ts +0 -2
- package/lib/nav-item/nav-item.d.ts +0 -2
- package/lib/note/note.d.ts +0 -1
- package/lib/number-field/number-field.d.ts +505 -96
- package/lib/option/option.d.ts +1 -2
- package/lib/pagination/pagination.d.ts +0 -1
- package/lib/progress/progress.d.ts +0 -1
- package/lib/progress-ring/progress-ring.d.ts +0 -1
- package/lib/radio/radio.d.ts +0 -3
- package/lib/radio-group/radio-group.d.ts +0 -1
- package/lib/range-slider/range-slider.d.ts +0 -3
- package/lib/rich-text-editor/menubar/menubar.d.ts +0 -1
- package/lib/rich-text-editor/rich-text-editor.d.ts +0 -1
- package/lib/searchable-select/option-tag.d.ts +0 -1
- package/lib/searchable-select/searchable-select.d.ts +505 -96
- package/lib/select/select.d.ts +470 -60
- package/lib/selectable-box/selectable-box.d.ts +0 -1
- package/lib/simple-color-picker/definition.d.ts +4 -0
- package/lib/simple-color-picker/locale.d.ts +4 -0
- package/lib/simple-color-picker/simple-color-picker.d.ts +1600 -0
- package/lib/simple-color-picker/simple-color-picker.template.d.ts +3 -0
- package/lib/slider/slider.d.ts +0 -3
- package/lib/split-button/split-button.d.ts +2 -3
- package/lib/switch/switch.d.ts +0 -2
- package/lib/tab/tab.d.ts +0 -3
- package/lib/tab-panel/tab-panel.d.ts +0 -1
- package/lib/tag/tag.d.ts +0 -3
- package/lib/tag-group/tag-group.d.ts +0 -1
- package/lib/tag-name-map.d.ts +2 -1
- package/lib/text-area/text-area.d.ts +494 -84
- package/lib/text-field/text-field.d.ts +505 -96
- package/lib/time-picker/time-picker.d.ts +571 -569
- package/lib/toggletip/toggletip.d.ts +0 -2
- package/lib/tooltip/tooltip.d.ts +0 -1
- package/lib/tree-item/tree-item.d.ts +0 -2
- package/lib/tree-view/tree-view.d.ts +0 -1
- package/lib/video-player/video-player.d.ts +0 -1
- package/locales/de-DE.cjs +13 -1
- package/locales/de-DE.js +13 -1
- package/locales/en-GB.cjs +13 -1
- package/locales/en-GB.js +13 -1
- package/locales/en-US.cjs +13 -1
- package/locales/en-US.js +13 -1
- package/locales/ja-JP.cjs +13 -1
- package/locales/ja-JP.js +13 -1
- package/locales/zh-CN.cjs +13 -1
- package/locales/zh-CN.js +13 -1
- package/{shared/definition31.cjs → menu/definition.cjs} +46 -42
- package/{shared/definition31.js → menu/definition.js} +16 -14
- package/menu/index.cjs +1 -5
- package/menu/index.js +2 -3
- package/menu-item/definition.cjs +14 -0
- package/menu-item/definition.js +3 -0
- package/menu-item/index.cjs +1 -5
- package/menu-item/index.js +2 -3
- package/{shared/definition34.cjs → nav/definition.cjs} +7 -4
- package/{shared/definition34.js → nav/definition.js} +4 -3
- package/nav/index.cjs +5 -5
- package/nav/index.js +13 -3
- package/nav-disclosure/definition.cjs +122 -0
- package/nav-disclosure/definition.js +116 -0
- package/nav-disclosure/index.cjs +16 -5
- package/nav-disclosure/index.js +96 -3
- package/{shared/definition33.cjs → nav-item/definition.cjs} +19 -16
- package/{shared/definition33.js → nav-item/definition.js} +9 -8
- package/nav-item/index.cjs +2 -5
- package/nav-item/index.js +59 -3
- package/{shared/definition35.cjs → note/definition.cjs} +15 -13
- package/{shared/definition35.js → note/definition.js} +6 -6
- package/note/index.cjs +9 -5
- package/note/index.js +44 -3
- package/{shared/definition36.cjs → number-field/definition.cjs} +66 -60
- package/{shared/definition36.js → number-field/definition.js} +31 -27
- package/number-field/index.cjs +60 -5
- package/number-field/index.js +370 -3
- package/option/definition.cjs +84 -0
- package/option/definition.js +78 -0
- package/option/index.cjs +1 -5
- package/option/index.js +2 -3
- package/package.json +15 -4
- package/{shared/definition38.cjs → pagination/definition.cjs} +31 -33
- package/{shared/definition38.js → pagination/definition.js} +7 -11
- package/pagination/index.cjs +43 -5
- package/pagination/index.js +194 -3
- package/popup/definition.cjs +13 -0
- package/popup/definition.js +4 -0
- package/popup/index.cjs +1 -5
- package/popup/index.js +2 -3
- package/{shared/definition40.cjs → progress/definition.cjs} +17 -15
- package/{shared/definition40.js → progress/definition.js} +6 -6
- package/progress/index.cjs +17 -5
- package/progress/index.js +69 -3
- package/{shared/definition39.cjs → progress-ring/definition.cjs} +17 -15
- package/{shared/definition39.js → progress-ring/definition.js} +7 -7
- package/progress-ring/index.cjs +1 -5
- package/progress-ring/index.js +2 -3
- package/{shared/definition42.cjs → radio/definition.cjs} +20 -19
- package/{shared/definition42.js → radio/definition.js} +8 -9
- package/radio/index.cjs +1 -5
- package/radio/index.js +2 -3
- package/{shared/definition41.cjs → radio-group/definition.cjs} +31 -30
- package/{shared/definition41.js → radio-group/definition.js} +8 -9
- package/radio-group/index.cjs +23 -5
- package/radio-group/index.js +255 -3
- package/{shared/definition43.cjs → range-slider/definition.cjs} +62 -61
- package/{shared/definition43.js → range-slider/definition.js} +13 -14
- package/range-slider/index.cjs +68 -5
- package/range-slider/index.js +456 -3
- package/rich-text-editor/definition.cjs +1206 -0
- package/rich-text-editor/definition.js +1200 -0
- package/rich-text-editor/index.cjs +133 -4
- package/rich-text-editor/index.js +10386 -2
- package/{shared/definition45.cjs → searchable-select/definition.cjs} +142 -130
- package/{shared/definition45.js → searchable-select/definition.js} +51 -41
- package/searchable-select/index.cjs +167 -5
- package/searchable-select/index.js +1034 -3
- package/{shared/definition46.cjs → select/definition.cjs} +92 -87
- package/{shared/definition46.js → select/definition.js} +32 -29
- package/select/index.cjs +1 -5
- package/select/index.js +2 -3
- package/{shared/definition47.cjs → selectable-box/definition.cjs} +26 -24
- package/{shared/definition47.js → selectable-box/definition.js} +9 -9
- package/selectable-box/index.cjs +28 -5
- package/selectable-box/index.js +136 -3
- package/shared/aria/aria-mixin.d.ts +0 -1
- package/shared/aria/delegates-aria.d.ts +0 -1
- package/shared/aria/host-semantics.d.ts +0 -1
- package/shared/color-picker/index.d.ts +2 -0
- package/shared/color-picker/types.d.ts +4 -0
- package/shared/color-picker/utils.d.ts +3 -0
- package/shared/feedback/feedback-message.d.ts +0 -1
- package/shared/feedback/mixins.d.ts +0 -2
- package/shared/foundation/button/button.d.ts +0 -2
- package/shared/foundation/form-associated/form-associated.d.ts +0 -2
- package/shared/foundation/vivid-element/vivid-element.d.ts +0 -1
- package/shared/localization/Locale.d.ts +2 -0
- package/shared/patterns/affix.d.ts +0 -2
- package/shared/patterns/anchored.d.ts +0 -2
- package/shared/patterns/char-count/char-count.d.ts +0 -1
- package/shared/patterns/form-elements/form-element.d.ts +0 -2
- package/shared/patterns/form-elements/index.d.ts +1 -0
- package/shared/patterns/form-elements/with-contextual-help.d.ts +1239 -0
- package/shared/patterns/form-elements/with-error-text.d.ts +0 -3
- package/shared/patterns/form-elements/with-success-text.d.ts +0 -1
- package/shared/patterns/linkable.d.ts +0 -1
- package/shared/patterns/localized.d.ts +0 -1
- package/shared/patterns/trapped-focus.d.ts +0 -1
- package/shared/picker-field/mixins/calendar-picker.d.ts +452 -451
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +452 -451
- package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +0 -1
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +594 -592
- package/shared/picker-field/mixins/single-date-picker.d.ts +734 -731
- package/shared/picker-field/mixins/single-value-picker.d.ts +449 -448
- package/shared/picker-field/mixins/time-selection-picker.d.ts +571 -569
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +571 -569
- package/shared/picker-field/picker-field.d.ts +483 -72
- package/{shared/definition48.cjs → side-drawer/definition.cjs} +16 -14
- package/{shared/definition48.js → side-drawer/definition.js} +5 -5
- package/side-drawer/index.cjs +17 -3
- package/side-drawer/index.js +100 -2
- package/simple-color-picker/definition.cjs +398 -0
- package/simple-color-picker/definition.js +392 -0
- package/simple-color-picker/index.cjs +31 -0
- package/simple-color-picker/index.js +250 -0
- package/{shared/definition49.cjs → slider/definition.cjs} +46 -53
- package/{shared/definition49.js → slider/definition.js} +11 -20
- package/slider/index.cjs +1 -5
- package/slider/index.js +2 -3
- package/split-button/definition.cjs +176 -0
- package/split-button/definition.js +170 -0
- package/split-button/index.cjs +26 -5
- package/split-button/index.js +149 -3
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/{shared/definition51.cjs → switch/definition.cjs} +20 -19
- package/{shared/definition51.js → switch/definition.js} +8 -9
- package/switch/index.cjs +16 -5
- package/switch/index.js +102 -3
- package/tab/definition.cjs +127 -0
- package/tab/definition.js +121 -0
- package/tab/index.cjs +1 -5
- package/tab/index.js +2 -3
- package/{shared/definition52.cjs → tab-panel/definition.cjs} +7 -4
- package/{shared/definition52.js → tab-panel/definition.js} +4 -3
- package/tab-panel/index.cjs +1 -5
- package/tab-panel/index.js +2 -3
- package/{shared/definition54.cjs → tabs/definition.cjs} +46 -39
- package/{shared/definition54.js → tabs/definition.js} +18 -13
- package/tabs/index.cjs +31 -5
- package/tabs/index.js +321 -3
- package/tag/definition.cjs +156 -0
- package/tag/definition.js +150 -0
- package/tag/index.cjs +19 -5
- package/tag/index.js +118 -3
- package/{shared/definition55.cjs → tag-group/definition.cjs} +9 -6
- package/{shared/definition55.js → tag-group/definition.js} +5 -4
- package/tag-group/index.cjs +8 -5
- package/tag-group/index.js +26 -3
- package/{shared/definition57.cjs → text-area/definition.cjs} +62 -42
- package/{shared/definition57.js → text-area/definition.js} +38 -20
- package/text-area/index.cjs +41 -5
- package/text-area/index.js +293 -3
- package/{shared/definition58.cjs → text-field/definition.cjs} +70 -52
- package/{shared/definition58.js → text-field/definition.js} +40 -24
- package/text-field/index.cjs +1 -5
- package/text-field/index.js +2 -3
- package/time-picker/definition.cjs +43 -0
- package/{shared/definition59.js → time-picker/definition.js} +9 -8
- package/time-picker/index.cjs +1 -5
- package/time-picker/index.js +29 -3
- package/{shared/definition60.cjs → toggletip/definition.cjs} +20 -18
- package/{shared/definition60.js → toggletip/definition.js} +8 -8
- package/toggletip/index.cjs +1 -5
- package/toggletip/index.js +2 -3
- package/{shared/definition61.cjs → tooltip/definition.cjs} +16 -13
- package/{shared/definition61.js → tooltip/definition.js} +7 -6
- package/tooltip/index.cjs +1 -5
- package/tooltip/index.js +2 -3
- package/tree-item/definition.cjs +13 -0
- package/tree-item/definition.js +3 -0
- package/tree-item/index.cjs +1 -5
- package/tree-item/index.js +2 -3
- package/{shared/definition63.cjs → tree-view/definition.cjs} +41 -42
- package/{shared/definition63.js → tree-view/definition.js} +6 -9
- package/tree-view/index.cjs +13 -5
- package/tree-view/index.js +171 -3
- package/{shared → unbundled}/affix.cjs +10 -11
- package/{shared → unbundled}/affix.js +2 -3
- package/{shared → unbundled}/anchored.cjs +7 -8
- package/{shared → unbundled}/anchored.js +1 -2
- package/{shared → unbundled}/attribute-binding-behaviour.cjs +3 -3
- package/{shared → unbundled}/attribute-binding-behaviour.js +1 -1
- package/{shared → unbundled}/base-progress.cjs +6 -5
- package/{shared → unbundled}/base-progress.js +2 -1
- package/{shared → unbundled}/breadcrumb-item.cjs +3 -2
- package/{shared → unbundled}/breadcrumb-item.js +2 -1
- package/{shared → unbundled}/button.cjs +10 -9
- package/{shared → unbundled}/button.js +2 -1
- package/{shared → unbundled}/calendar-event.cjs +8 -7
- package/{shared → unbundled}/calendar-event.js +2 -1
- package/unbundled/calendar-picker.template.cjs +917 -0
- package/unbundled/calendar-picker.template.js +906 -0
- package/{shared → unbundled}/char-count.cjs +6 -7
- package/{shared → unbundled}/char-count.js +2 -3
- package/unbundled/definition.cjs +225 -0
- package/unbundled/definition.js +220 -0
- package/{shared/definition30.cjs → unbundled/definition2.cjs} +41 -42
- package/{shared/definition30.js → unbundled/definition2.js} +6 -7
- package/unbundled/definition3.cjs +207 -0
- package/{shared/definition62.js → unbundled/definition3.js} +5 -9
- package/unbundled/definition4.cjs +298 -0
- package/unbundled/definition4.js +293 -0
- package/{shared/definition65.cjs → unbundled/definition5.cjs} +7 -6
- package/{shared/definition65.js → unbundled/definition5.js} +3 -2
- package/{shared → unbundled}/delegates-aria.cjs +4 -3
- package/{shared → unbundled}/delegates-aria.js +2 -1
- package/{shared → unbundled}/divider.cjs +5 -4
- package/{shared → unbundled}/divider.js +3 -2
- package/{shared → unbundled}/form-associated.cjs +13 -13
- package/{shared → unbundled}/form-associated.js +2 -2
- package/{shared → unbundled}/form-element.cjs +3 -3
- package/{shared → unbundled}/form-element.js +1 -1
- package/{shared → unbundled}/host-semantics.cjs +2 -1
- package/{shared → unbundled}/host-semantics.js +2 -1
- package/unbundled/key-codes.cjs +10 -0
- package/unbundled/key-codes.js +7 -0
- package/{shared → unbundled}/linkable.cjs +11 -12
- package/{shared → unbundled}/linkable.js +1 -2
- package/{shared → unbundled}/listbox.cjs +21 -37
- package/{shared → unbundled}/listbox.js +3 -19
- package/{shared → unbundled}/localized.cjs +2 -2
- package/{shared → unbundled}/localized.js +1 -1
- package/{shared → unbundled}/mixins.cjs +27 -83
- package/{shared → unbundled}/mixins.js +6 -62
- package/{shared → unbundled}/option.cjs +29 -17
- package/{shared → unbundled}/option.js +14 -2
- package/{shared → unbundled}/picker-field.template.cjs +32 -24
- package/{shared → unbundled}/picker-field.template.js +18 -10
- package/{shared → unbundled}/slider.template.cjs +15 -19
- package/{shared → unbundled}/slider.template.js +3 -7
- package/unbundled/text-field.cjs +5 -0
- package/unbundled/text-field.js +3 -0
- package/{shared → unbundled}/time-selection-picker.template.cjs +28 -30
- package/{shared → unbundled}/time-selection-picker.template.js +4 -6
- package/unbundled/vivid-element.cjs +283 -0
- package/unbundled/vivid-element.js +274 -0
- package/unbundled/with-contextual-help.cjs +40 -0
- package/unbundled/with-contextual-help.js +38 -0
- package/{shared → unbundled}/with-error-text.cjs +2 -2
- package/{shared → unbundled}/with-error-text.js +1 -1
- package/{shared → unbundled}/with-success-text.cjs +2 -2
- package/{shared → unbundled}/with-success-text.js +1 -1
- package/video-player/definition.cjs +536 -0
- package/video-player/definition.js +530 -0
- package/video-player/index.cjs +536 -3
- package/video-player/index.js +35912 -2
- package/{shared/definition66.cjs → visually-hidden/definition.cjs} +6 -3
- package/{shared/definition66.js → visually-hidden/definition.js} +3 -2
- package/visually-hidden/index.cjs +1 -5
- package/visually-hidden/index.js +2 -3
- package/vivid.api.json +722 -799
- package/shared/_has.cjs +0 -58
- package/shared/_has.js +0 -54
- package/shared/aria.cjs +0 -11
- package/shared/aria.js +0 -9
- package/shared/calendar-picker.template.cjs +0 -6377
- package/shared/calendar-picker.template.js +0 -6366
- package/shared/children.cjs +0 -61
- package/shared/children.js +0 -59
- package/shared/class-names.cjs +0 -17
- package/shared/class-names.js +0 -15
- package/shared/definition.cjs +0 -145
- package/shared/definition.js +0 -141
- package/shared/definition11.cjs +0 -220
- package/shared/definition11.js +0 -215
- package/shared/definition14.cjs +0 -185
- package/shared/definition24.cjs +0 -80
- package/shared/definition24.js +0 -76
- package/shared/definition25.cjs +0 -90
- package/shared/definition25.js +0 -86
- package/shared/definition26.cjs +0 -2549
- package/shared/definition26.js +0 -2545
- package/shared/definition32.cjs +0 -120
- package/shared/definition32.js +0 -116
- package/shared/definition37.cjs +0 -71
- package/shared/definition37.js +0 -68
- package/shared/definition44.cjs +0 -14666
- package/shared/definition44.js +0 -14662
- package/shared/definition50.cjs +0 -148
- package/shared/definition50.js +0 -144
- package/shared/definition53.cjs +0 -124
- package/shared/definition53.js +0 -120
- package/shared/definition56.cjs +0 -154
- package/shared/definition56.js +0 -150
- package/shared/definition59.cjs +0 -39
- package/shared/definition62.cjs +0 -211
- package/shared/definition64.cjs +0 -69579
- package/shared/definition64.js +0 -69575
- package/shared/definition67.cjs +0 -2227
- package/shared/definition67.js +0 -2222
- package/shared/dom.cjs +0 -10
- package/shared/dom.js +0 -8
- package/shared/key-codes.cjs +0 -32
- package/shared/key-codes.js +0 -18
- package/shared/numbers.cjs +0 -38
- package/shared/numbers.js +0 -34
- package/shared/ref.cjs +0 -43
- package/shared/ref.js +0 -41
- package/shared/repeat.cjs +0 -767
- package/shared/repeat.js +0 -764
- package/shared/slotted.cjs +0 -123
- package/shared/slotted.js +0 -119
- package/shared/strings.cjs +0 -11
- package/shared/strings.js +0 -9
- package/shared/text-field.cjs +0 -5
- package/shared/text-field.js +0 -3
- package/shared/vivid-element.cjs +0 -2822
- package/shared/vivid-element.js +0 -2799
- package/shared/when.cjs +0 -31
- package/shared/when.js +0 -29
- /package/{shared → unbundled}/enums.cjs +0 -0
- /package/{shared → unbundled}/enums.js +0 -0
- /package/{shared → unbundled}/index.cjs +0 -0
- /package/{shared → unbundled}/index.js +0 -0
- /package/{shared → unbundled}/playbackRates.cjs +0 -0
- /package/{shared → unbundled}/playbackRates.js +0 -0
- /package/{shared → unbundled}/scrollIntoView.cjs +0 -0
- /package/{shared → unbundled}/scrollIntoView.js +0 -0
- /package/{shared → unbundled}/single-date-picker.cjs +0 -0
- /package/{shared → unbundled}/single-date-picker.js +0 -0
- /package/{shared → unbundled}/single-value-picker.cjs +0 -0
- /package/{shared → unbundled}/single-value-picker.js +0 -0
|
@@ -0,0 +1,1200 @@
|
|
|
1
|
+
import { V as VividElement, d as defineVividComponent, c as createRegisterFunction } from '../unbundled/vivid-element.js';
|
|
2
|
+
import { B as Button, b as buttonDefinition } from '../unbundled/definition.js';
|
|
3
|
+
import { dividerDefinition } from '../divider/definition.js';
|
|
4
|
+
import { listboxOptionDefinition } from '../option/definition.js';
|
|
5
|
+
import { VwcTooltipElement as Tooltip, tooltipDefinition } from '../tooltip/definition.js';
|
|
6
|
+
import { VwcMenuElement as Menu, menuDefinition } from '../menu/definition.js';
|
|
7
|
+
import { M as MenuItem, m as menuItemDefinition } from '../unbundled/definition2.js';
|
|
8
|
+
import { VwcSelectElement as Select, selectDefinition } from '../select/definition.js';
|
|
9
|
+
import { html, repeat, attr, DOM, nullableNumberConverter, when } from '@microsoft/fast-element';
|
|
10
|
+
import { classNames } from '@microsoft/fast-web-utilities';
|
|
11
|
+
import { D as Divider } from '../unbundled/divider.js';
|
|
12
|
+
import { L as ListboxOption } from '../unbundled/option.js';
|
|
13
|
+
import { L as Localized } from '../unbundled/localized.js';
|
|
14
|
+
import { EditorState, PluginKey, TextSelection, Plugin } from 'prosemirror-state';
|
|
15
|
+
import { Schema, DOMParser } from 'prosemirror-model';
|
|
16
|
+
import { EditorView, Decoration, DecorationSet } from 'prosemirror-view';
|
|
17
|
+
import { keymap } from 'prosemirror-keymap';
|
|
18
|
+
import { baseKeymap, toggleMark } from 'prosemirror-commands';
|
|
19
|
+
import { schema } from 'prosemirror-schema-basic';
|
|
20
|
+
import { VwcIconElement as Icon, iconDefinition } from '../icon/definition.js';
|
|
21
|
+
|
|
22
|
+
const styles$2 = "@charset \"UTF-8\";.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:\"\";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-menu{margin:0 -4px;line-height:1}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.ProseMirror-menuitem{margin-right:3px;display:inline-block}.ProseMirror-menuseparator{border-right:1px solid #ddd;margin-right:3px}.ProseMirror-menu-dropdown,.ProseMirror-menu-dropdown-menu{font-size:90%;white-space:nowrap}.ProseMirror-menu-dropdown{vertical-align:1px;cursor:pointer;position:relative;padding-right:15px}.ProseMirror-menu-dropdown-wrap{padding:1px 0 1px 4px;display:inline-block;position:relative}.ProseMirror-menu-dropdown:after{content:\"\";border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 2px)}.ProseMirror-menu-dropdown-menu,.ProseMirror-menu-submenu{position:absolute;background:#fff;color:#666;border:1px solid #aaa;padding:2px}.ProseMirror-menu-dropdown-menu{z-index:15;min-width:6em}.ProseMirror-menu-dropdown-item{cursor:pointer;padding:2px 8px 2px 4px}@media (hover: hover){.ProseMirror-menu-dropdown-item:hover{background:#f2f2f2}}.ProseMirror-menu-submenu-wrap{position:relative;margin-right:-4px}.ProseMirror-menu-submenu-label:after{content:\"\";border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 4px)}.ProseMirror-menu-submenu{display:none;min-width:4em;left:100%;top:-3px}.ProseMirror-menu-active{background:#eee;border-radius:4px}.ProseMirror-menu-disabled{opacity:.3}.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu,.ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu{display:block}.ProseMirror-menubar{border-top-left-radius:inherit;border-top-right-radius:inherit;position:relative;min-height:1em;color:#666;padding:1px 6px;top:0;left:0;right:0;border-bottom:1px solid silver;background:#fff;z-index:10;-moz-box-sizing:border-box;box-sizing:border-box;overflow:visible}.ProseMirror-icon{display:inline-block;line-height:.8;vertical-align:-2px;padding:2px 8px;cursor:pointer}.ProseMirror-menu-disabled.ProseMirror-icon{cursor:default}.ProseMirror-icon svg{fill:currentColor;height:1em}.ProseMirror-icon span{vertical-align:text-top}.ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}.ProseMirror-gapcursor:after{content:\"\";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid black;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}.ProseMirror-focused .ProseMirror-gapcursor{display:block}.ProseMirror-example-setup-style hr{padding:2px 10px;border:none;margin:1em 0}.ProseMirror-example-setup-style hr:after{content:\"\";display:block;height:1px;background-color:silver;line-height:2px}.ProseMirror ul,.ProseMirror ol{padding-left:30px}.ProseMirror blockquote{padding-left:1em;border-left:3px solid #eee;margin-left:0;margin-right:0}.ProseMirror-example-setup-style img{cursor:default}.ProseMirror-prompt{background:#fff;padding:5px 10px 5px 15px;border:1px solid silver;position:fixed;border-radius:3px;z-index:11;box-shadow:-.5px 2px 5px #0003}.ProseMirror-prompt h5{margin:0;font-weight:400;font-size:100%;color:#444}.ProseMirror-prompt input[type=text],.ProseMirror-prompt textarea{background:#eee;border:none;outline:none}.ProseMirror-prompt input[type=text]{padding:0 4px}.ProseMirror-prompt-close{position:absolute;left:2px;top:1px;color:#666;border:none;background:transparent;padding:0}.ProseMirror-prompt-close:after{content:\"✕\";font-size:12px}.ProseMirror-invalid{background:#ffc;border:1px solid #cc7;border-radius:4px;padding:5px 10px;position:absolute;min-width:10em}.ProseMirror-prompt-buttons{margin-top:5px;display:none}.placeholder:before{position:absolute;color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font:var(--vvd-typography-base);pointer-events:none}.editor{box-sizing:border-box;background:var(--vvd-color-canvas);background-clip:padding-box;color:var(--vvd-color-canvas-text)}.ProseMirror{position:relative;box-sizing:border-box;padding:10px 16px;block-size:120px;font:var(--vvd-typography-base);font-feature-settings:\"liga\" 0;font-variant-ligatures:none;line-height:1.2;outline:none;overflow-y:auto;white-space:break-spaces;word-wrap:break-word}.ProseMirror pre{white-space:pre-wrap}.ProseMirror p{margin-bottom:1em}.ProseMirror p:first-child,.ProseMirror h1:first-child,.ProseMirror h2:first-child,.ProseMirror h3:first-child,.ProseMirror h4:first-child,.ProseMirror h5:first-child,.ProseMirror h6:first-child{margin-top:10px}h2{font:var(--vvd-typography-heading-4)}h3{font:var(--vvd-typography-base-extended)}p{font:var(--vvd-typography-base)}:host{display:block}#editor{--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}#editor{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}#editor ::-webkit-scrollbar{width:4px}#editor ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}#editor ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}#editor{position:relative;display:flex;flex-direction:column;block-size:100%;overflow-y:auto}[contenteditable=true]{overflow:unset;block-size:unset}#attachments-wrapper{order:1}#attachments-wrapper .divider{padding:0 12px}.hidden{display:none}.drag-overlay{position:absolute;z-index:10;display:none;align-items:center;justify-content:center;border:1px dashed var(--vvd-color-cta-400);border-radius:8px;background:var(--vvd-color-cta-100);font:var(--vvd-typography-base);inset:0;opacity:.8;pointer-events:none;transition:opacity .2s}.drag-over .drag-overlay{display:flex}";
|
|
23
|
+
|
|
24
|
+
function notifyMenubarChange(menubar, eventName, payload) {
|
|
25
|
+
menubar.$emit(eventName, payload, { bubbles: false, composed: false });
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const TEXT_DECORATION_ITEMS = [
|
|
29
|
+
{
|
|
30
|
+
text: "Bold",
|
|
31
|
+
icon: "bold-line",
|
|
32
|
+
value: "bold"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
text: "Italic",
|
|
36
|
+
icon: "italic-line",
|
|
37
|
+
value: "italics"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
text: "Underline",
|
|
41
|
+
icon: "underline-line",
|
|
42
|
+
value: "underline"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
text: "Strikethrough",
|
|
46
|
+
icon: "strikethrough-line",
|
|
47
|
+
value: "strikethrough"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
text: "Monospace",
|
|
51
|
+
icon: "monospace-line",
|
|
52
|
+
value: "monospace"
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
const TEXT_SIZES = [
|
|
56
|
+
{
|
|
57
|
+
text: "Extra Large",
|
|
58
|
+
value: "extra-large"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
text: "Large",
|
|
62
|
+
value: "large"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
text: "Normal",
|
|
66
|
+
value: "normal"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
text: "Small",
|
|
70
|
+
value: "small"
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
const textBlockEventHandler = (event) => {
|
|
74
|
+
const customEvent = event;
|
|
75
|
+
if (!customEvent || !customEvent.detail || customEvent.detail.textBlockType === void 0) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const menu = customEvent.target;
|
|
79
|
+
menu.shadowRoot.querySelector("#text-block").setAttribute("current-value", customEvent.detail.textBlockType);
|
|
80
|
+
};
|
|
81
|
+
const textDecorationEventHandler = (event) => {
|
|
82
|
+
const customEvent = event;
|
|
83
|
+
if (!customEvent || !customEvent.detail) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const menu = customEvent.target;
|
|
87
|
+
const selectionButtons = menu.shadowRoot.querySelectorAll(
|
|
88
|
+
"#text-decoration .selection-button"
|
|
89
|
+
);
|
|
90
|
+
selectionButtons.forEach((button) => button.removeAttribute("active"));
|
|
91
|
+
customEvent.detail.textDecoration !== void 0 && TEXT_DECORATION_ITEMS.forEach((menuItemConfig, index) => {
|
|
92
|
+
if (customEvent.detail.textDecoration.indexOf(menuItemConfig.value) >= 0) {
|
|
93
|
+
selectionButtons[index].toggleAttribute("active", true);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const textSizeEventHandler = (event) => {
|
|
98
|
+
const customEvent = event;
|
|
99
|
+
if (!customEvent || !customEvent.detail) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const menu = customEvent.target;
|
|
103
|
+
const selectionTextSize = customEvent.detail.textSize ?? "normal";
|
|
104
|
+
const textSizeElements = menu.shadowRoot.querySelectorAll(
|
|
105
|
+
".menubar-selector-menuitem"
|
|
106
|
+
);
|
|
107
|
+
textSizeElements.forEach((textSizeElement) => {
|
|
108
|
+
textSizeElement.toggleAttribute(
|
|
109
|
+
"checked",
|
|
110
|
+
textSizeElement.getAttribute("value") === selectionTextSize
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const MENU_BAR_ITEMS = {
|
|
115
|
+
textBlock: {
|
|
116
|
+
registerStateProperty: function(menubar) {
|
|
117
|
+
menubar.addEventListener("text-styles-changed", textBlockEventHandler);
|
|
118
|
+
},
|
|
119
|
+
render: function(context) {
|
|
120
|
+
const selectTag = context.tagFor(Select);
|
|
121
|
+
const optionTag = context.tagFor(ListboxOption);
|
|
122
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
123
|
+
return html`
|
|
124
|
+
<${tooltipTag} text="${(_, { parent }) => parent.locale.richTextEditor.textBlockType}" placement="top">
|
|
125
|
+
<${selectTag}
|
|
126
|
+
scale="condensed"
|
|
127
|
+
shape="rounded"
|
|
128
|
+
appearance="ghost"
|
|
129
|
+
slot="anchor"
|
|
130
|
+
trigger="auto"
|
|
131
|
+
id="text-block"
|
|
132
|
+
aria-label="Text Block"
|
|
133
|
+
placement="bottom-end"
|
|
134
|
+
value="${(_, { parent }) => parent.textBlockType}"
|
|
135
|
+
@change="${(_, { parent, event }) => notifyMenubarChange(
|
|
136
|
+
parent,
|
|
137
|
+
"text-block-selected",
|
|
138
|
+
event.target.value
|
|
139
|
+
)}"
|
|
140
|
+
>
|
|
141
|
+
<${optionTag}
|
|
142
|
+
text="Title"
|
|
143
|
+
value="title"
|
|
144
|
+
internal-part
|
|
145
|
+
class="title"
|
|
146
|
+
connotation="cta"
|
|
147
|
+
></${optionTag}>
|
|
148
|
+
<${optionTag}
|
|
149
|
+
text="Subtitle"
|
|
150
|
+
value="subtitle"
|
|
151
|
+
internal-part
|
|
152
|
+
class="subtitle"
|
|
153
|
+
connotation="cta"
|
|
154
|
+
></${optionTag}>
|
|
155
|
+
<${optionTag}
|
|
156
|
+
text="Body"
|
|
157
|
+
value="body"
|
|
158
|
+
internal-part
|
|
159
|
+
class="body"
|
|
160
|
+
connotation="cta"
|
|
161
|
+
></${optionTag}>
|
|
162
|
+
</${selectTag}>
|
|
163
|
+
</${tooltipTag}>
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
textDecoration: {
|
|
168
|
+
registerStateProperty: function(menubar) {
|
|
169
|
+
menubar.addEventListener(
|
|
170
|
+
"text-styles-changed",
|
|
171
|
+
textDecorationEventHandler
|
|
172
|
+
);
|
|
173
|
+
},
|
|
174
|
+
render: function(context) {
|
|
175
|
+
const buttonTag = context.tagFor(Button);
|
|
176
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
177
|
+
return html`
|
|
178
|
+
<span id="text-decoration">
|
|
179
|
+
${repeat(
|
|
180
|
+
(_) => TEXT_DECORATION_ITEMS,
|
|
181
|
+
html`
|
|
182
|
+
<${tooltipTag} text="${(x, { parentContext: { parent } }) => parent.locale.richTextEditor[x.value]}" placement="top">
|
|
183
|
+
<${buttonTag}
|
|
184
|
+
class="selection-button"
|
|
185
|
+
slot="anchor"
|
|
186
|
+
aria-label="${(x, { parentContext: { parent } }) => parent.locale.richTextEditor[x.value]}"
|
|
187
|
+
size="super-condensed"
|
|
188
|
+
appearance="ghost-light"
|
|
189
|
+
shape="rounded"
|
|
190
|
+
icon="${(x) => x.icon}"
|
|
191
|
+
@click="${(x, c) => notifyMenubarChange(
|
|
192
|
+
c.parentContext.parent,
|
|
193
|
+
"text-decoration-selected",
|
|
194
|
+
x.value
|
|
195
|
+
)}"')}"
|
|
196
|
+
></${buttonTag}>
|
|
197
|
+
</${tooltipTag}>
|
|
198
|
+
`
|
|
199
|
+
)}
|
|
200
|
+
</span>
|
|
201
|
+
`;
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
textSize: {
|
|
205
|
+
registerStateProperty: function(menubar) {
|
|
206
|
+
menubar.addEventListener("text-styles-changed", textSizeEventHandler);
|
|
207
|
+
},
|
|
208
|
+
render: function(context) {
|
|
209
|
+
const menuTag = context.tagFor(Menu);
|
|
210
|
+
const buttonTag = context.tagFor(Button);
|
|
211
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
212
|
+
const menuItemTag = context.tagFor(MenuItem);
|
|
213
|
+
return html`
|
|
214
|
+
<${menuTag}
|
|
215
|
+
auto-dismiss
|
|
216
|
+
trigger="auto"
|
|
217
|
+
id="text-size"
|
|
218
|
+
aria-label="Text Size"
|
|
219
|
+
placement="bottom-end"
|
|
220
|
+
>
|
|
221
|
+
<${tooltipTag} slot="anchor" text="${(_, { parent }) => parent.locale.richTextEditor.textSize}" placement="top">
|
|
222
|
+
<${buttonTag}
|
|
223
|
+
slot="anchor"
|
|
224
|
+
aria-label="Open text size menu"
|
|
225
|
+
size="super-condensed"
|
|
226
|
+
appearance="ghost-light"
|
|
227
|
+
shape="pill"
|
|
228
|
+
icon="text-size-line"
|
|
229
|
+
></${buttonTag}>
|
|
230
|
+
</${tooltipTag}>
|
|
231
|
+
${repeat(
|
|
232
|
+
(_) => TEXT_SIZES,
|
|
233
|
+
html`
|
|
234
|
+
<${menuItemTag}
|
|
235
|
+
check-appearance="tick-only"
|
|
236
|
+
control-type="checkbox"
|
|
237
|
+
text="${(x) => x.text}"
|
|
238
|
+
value="${(x) => x.value}"
|
|
239
|
+
internal-part
|
|
240
|
+
class="menubar-selector-menuitem"
|
|
241
|
+
connotation="cta"
|
|
242
|
+
@click="${(x, c) => notifyMenubarChange(
|
|
243
|
+
c.parentContext.parent,
|
|
244
|
+
"text-size-selected",
|
|
245
|
+
x.value
|
|
246
|
+
)}"
|
|
247
|
+
></${menuItemTag}>
|
|
248
|
+
`
|
|
249
|
+
)}
|
|
250
|
+
</${menuTag}>
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
divider: {
|
|
255
|
+
render: function(context) {
|
|
256
|
+
const dividerTag = context.tagFor(Divider);
|
|
257
|
+
return html`
|
|
258
|
+
<${dividerTag} class="divider" orientation="vertical"></${dividerTag}>
|
|
259
|
+
`;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
var __defProp$2 = Object.defineProperty;
|
|
265
|
+
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
266
|
+
var result = void 0 ;
|
|
267
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
268
|
+
if (decorator = decorators[i])
|
|
269
|
+
result = (decorator(target, key, result) ) || result;
|
|
270
|
+
if (result) __defProp$2(target, key, result);
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
class Menubar extends Localized(VividElement) {
|
|
274
|
+
get #textEditorElement() {
|
|
275
|
+
return this.parentElement;
|
|
276
|
+
}
|
|
277
|
+
#updateTextStyleState = () => {
|
|
278
|
+
this.dispatchEvent(
|
|
279
|
+
new CustomEvent("text-styles-changed", {
|
|
280
|
+
detail: this.#textEditorElement?.selectionStyles
|
|
281
|
+
})
|
|
282
|
+
);
|
|
283
|
+
};
|
|
284
|
+
connectedCallback() {
|
|
285
|
+
super.connectedCallback();
|
|
286
|
+
this.#textEditorElement.addEventListener(
|
|
287
|
+
"selection-changed",
|
|
288
|
+
this.#updateTextStyleState
|
|
289
|
+
);
|
|
290
|
+
this.#textEditorElement.addEventListener(
|
|
291
|
+
"change",
|
|
292
|
+
this.#updateTextStyleState
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
disconnectedCallback() {
|
|
296
|
+
super.disconnectedCallback();
|
|
297
|
+
this.#textEditorElement?.removeEventListener(
|
|
298
|
+
"selection-changed",
|
|
299
|
+
this.#updateTextStyleState
|
|
300
|
+
);
|
|
301
|
+
this.#textEditorElement?.removeEventListener(
|
|
302
|
+
"change",
|
|
303
|
+
this.#updateTextStyleState
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
__decorateClass$2([
|
|
308
|
+
attr({ attribute: "menu-items" })
|
|
309
|
+
], Menubar.prototype, "menuItems");
|
|
310
|
+
|
|
311
|
+
const getClasses$2 = (menubar) => classNames("control", [
|
|
312
|
+
"hide-menubar",
|
|
313
|
+
getValidMenuItems(menubar).length === 0
|
|
314
|
+
]);
|
|
315
|
+
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
316
|
+
function getPropertyStateRgistrationFunction(item) {
|
|
317
|
+
return MENU_BAR_ITEMS[item].registerStateProperty;
|
|
318
|
+
}
|
|
319
|
+
function createMenuItem(item) {
|
|
320
|
+
return MENU_BAR_ITEMS[item].render;
|
|
321
|
+
}
|
|
322
|
+
function getValidMenuItems({ menuItems }) {
|
|
323
|
+
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
324
|
+
}
|
|
325
|
+
function renderMenuItems(context) {
|
|
326
|
+
return () => html`${repeat(
|
|
327
|
+
getValidMenuItems,
|
|
328
|
+
html`${(menuItemName, { parent }) => {
|
|
329
|
+
getPropertyStateRgistrationFunction(menuItemName)?.(parent);
|
|
330
|
+
return createMenuItem(menuItemName)(context);
|
|
331
|
+
}}`
|
|
332
|
+
)}`;
|
|
333
|
+
}
|
|
334
|
+
const MenubarTemplate = (context) => {
|
|
335
|
+
return html`<template class="${getClasses$2}">
|
|
336
|
+
${renderMenuItems(context)}
|
|
337
|
+
</template>`;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const styles$1 = ":host{display:flex;align-items:center;background-color:var(--vvd-color-neutral-50);gap:4px}:host .hide-menubar{display:none}.title{--_text-primary-custom-size: var(--vvd-typography-heading-4)}.subtitle{--_text-primary-custom-size: var(--vvd-typography-base-extended)}.body{--_text-primary-custom-size: var(--vvd-typography-base)}.divider{height:28px}#text-block{width:104px}";
|
|
341
|
+
|
|
342
|
+
const menubarDefinition = defineVividComponent(
|
|
343
|
+
"menubar",
|
|
344
|
+
Menubar,
|
|
345
|
+
MenubarTemplate,
|
|
346
|
+
[
|
|
347
|
+
buttonDefinition,
|
|
348
|
+
selectDefinition,
|
|
349
|
+
listboxOptionDefinition,
|
|
350
|
+
dividerDefinition,
|
|
351
|
+
tooltipDefinition,
|
|
352
|
+
menuDefinition,
|
|
353
|
+
menuItemDefinition
|
|
354
|
+
],
|
|
355
|
+
{
|
|
356
|
+
styles: styles$1,
|
|
357
|
+
shadowOptions: {
|
|
358
|
+
delegatesFocus: true
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
const TEXT_SIZES_CSS_VARIABLES = {
|
|
364
|
+
"extra-large": "var(--vvd-typography-heading-4)",
|
|
365
|
+
large: "var(--vvd-typography-base-extended)",
|
|
366
|
+
normal: "var(--vvd-typography-base)",
|
|
367
|
+
small: "var(--vvd-typography-base-condensed)"
|
|
368
|
+
};
|
|
369
|
+
const CSS_VARIABLES_TO_SIZES = Object.fromEntries(
|
|
370
|
+
Object.entries(TEXT_SIZES_CSS_VARIABLES).map(([key, value]) => [value, key])
|
|
371
|
+
);
|
|
372
|
+
const customMarks = {
|
|
373
|
+
u: {
|
|
374
|
+
parseDOM: [{ tag: "u" }],
|
|
375
|
+
toDOM() {
|
|
376
|
+
return ["u", 0];
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
s: {
|
|
380
|
+
parseDOM: [{ tag: "s" }, { tag: "del" }],
|
|
381
|
+
toDOM() {
|
|
382
|
+
return ["s", 0];
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
tt: {
|
|
386
|
+
parseDOM: [{ tag: "tt" }, { tag: "code" }],
|
|
387
|
+
toDOM() {
|
|
388
|
+
return ["tt", 0];
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
textSize: {
|
|
392
|
+
attrs: { size: { default: "normal" } },
|
|
393
|
+
parseDOM: [
|
|
394
|
+
{
|
|
395
|
+
tag: "span[style*='font']",
|
|
396
|
+
getAttrs: (node) => {
|
|
397
|
+
const style = node.getAttribute("style");
|
|
398
|
+
const fontSize = style.match(/font:\s*([^;]+)/)?.[1]?.trim();
|
|
399
|
+
const size = CSS_VARIABLES_TO_SIZES[fontSize];
|
|
400
|
+
if (size) return { size };
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
toDOM(mark) {
|
|
406
|
+
const size = mark.attrs.size;
|
|
407
|
+
const fontSize = TEXT_SIZES_CSS_VARIABLES[size] || TEXT_SIZES_CSS_VARIABLES.normal;
|
|
408
|
+
return ["span", { style: `font: ${fontSize};` }, 0];
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
const dynamicSchema = (prefix = "vwc") => new Schema({
|
|
413
|
+
nodes: {
|
|
414
|
+
...schema.spec.nodes.toObject(),
|
|
415
|
+
imageError: {
|
|
416
|
+
inline: true,
|
|
417
|
+
group: "inline",
|
|
418
|
+
atom: true,
|
|
419
|
+
attrs: {
|
|
420
|
+
alt: { default: "" },
|
|
421
|
+
icon: { default: "" },
|
|
422
|
+
errorMessage: { default: "Failed to attach" },
|
|
423
|
+
fileName: { default: "" }
|
|
424
|
+
},
|
|
425
|
+
toDOM(node) {
|
|
426
|
+
return [
|
|
427
|
+
`${prefix}-text-editor-image-placeholder`,
|
|
428
|
+
{
|
|
429
|
+
alt: node.attrs.alt,
|
|
430
|
+
icon: node.attrs.icon,
|
|
431
|
+
"error-message": node.attrs.errorMessage,
|
|
432
|
+
"file-name": node.attrs.fileName
|
|
433
|
+
}
|
|
434
|
+
];
|
|
435
|
+
},
|
|
436
|
+
parseDOM: [
|
|
437
|
+
{
|
|
438
|
+
tag: `${prefix}-text-editor-image-placeholder`,
|
|
439
|
+
getAttrs(dom) {
|
|
440
|
+
return {
|
|
441
|
+
alt: dom.getAttribute("alt"),
|
|
442
|
+
icon: dom.getAttribute("icon"),
|
|
443
|
+
errorMessage: dom.getAttribute("error-message"),
|
|
444
|
+
fileName: dom.getAttribute("file-name")
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
]
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
marks: {
|
|
452
|
+
...schema.spec.marks.toObject(),
|
|
453
|
+
...customMarks
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
dynamicSchema();
|
|
457
|
+
|
|
458
|
+
const NEGATIVE_SELECTION = {
|
|
459
|
+
start: -1,
|
|
460
|
+
end: -1
|
|
461
|
+
};
|
|
462
|
+
class TagToSchemaMap {
|
|
463
|
+
static get h2() {
|
|
464
|
+
return {
|
|
465
|
+
type: "heading",
|
|
466
|
+
attrs: { level: 2 }
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
static get h3() {
|
|
470
|
+
return {
|
|
471
|
+
type: "heading",
|
|
472
|
+
attrs: { level: 3 }
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
static get p() {
|
|
476
|
+
return {
|
|
477
|
+
type: "paragraph",
|
|
478
|
+
attrs: {}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function setTextBlockType(styles, type) {
|
|
483
|
+
if (styles.textBlockType && styles.textBlockType !== type || styles.textBlockType === "") {
|
|
484
|
+
styles.textBlockType = "";
|
|
485
|
+
} else {
|
|
486
|
+
styles.textBlockType = type;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function createEnterKeymapPlugin() {
|
|
490
|
+
return keymap({
|
|
491
|
+
["Shift-Enter"]: (state, dispatch) => {
|
|
492
|
+
const { schema } = state;
|
|
493
|
+
const br = schema.nodes.hard_break;
|
|
494
|
+
const { $from, $to } = state.selection;
|
|
495
|
+
if ($from.sameParent($to)) {
|
|
496
|
+
dispatch && dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView());
|
|
497
|
+
} else {
|
|
498
|
+
if (dispatch) {
|
|
499
|
+
const tr = state.tr;
|
|
500
|
+
const lastSelectionBlock = state.doc.resolve($to.end());
|
|
501
|
+
tr.delete(lastSelectionBlock.start(), $to.pos);
|
|
502
|
+
tr.delete($from.pos, lastSelectionBlock.start() - 1);
|
|
503
|
+
tr.insert($from.pos, br.create());
|
|
504
|
+
const newSelection = TextSelection.create(tr.doc, $from.pos + 1);
|
|
505
|
+
tr.setSelection(newSelection);
|
|
506
|
+
dispatch(tr.scrollIntoView());
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return true;
|
|
510
|
+
},
|
|
511
|
+
Enter: (state, dispatch) => {
|
|
512
|
+
const { schema } = state;
|
|
513
|
+
const paragraph = schema.nodes.paragraph;
|
|
514
|
+
const { $from, empty } = state.selection;
|
|
515
|
+
if (!empty || $from.parent.type !== paragraph) {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
const tr = state.tr;
|
|
519
|
+
const marks = $from.marks();
|
|
520
|
+
tr.split($from.pos);
|
|
521
|
+
if (marks.length > 0) {
|
|
522
|
+
const newParaStart = $from.pos + 1;
|
|
523
|
+
const zeroWidthSpace = "";
|
|
524
|
+
const content = schema.text(zeroWidthSpace, marks);
|
|
525
|
+
tr.insert(newParaStart, content);
|
|
526
|
+
tr.setSelection(TextSelection.create(tr.doc, newParaStart + 1));
|
|
527
|
+
}
|
|
528
|
+
dispatch && dispatch(tr.scrollIntoView());
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
function createSelectionChangePlugin(onSelectionChange) {
|
|
534
|
+
return new Plugin({
|
|
535
|
+
view: () => ({
|
|
536
|
+
update: (view, prevState) => {
|
|
537
|
+
const { from, to } = view.state.selection;
|
|
538
|
+
const { from: prevFrom, to: prevTo } = prevState.selection;
|
|
539
|
+
if (from !== prevFrom || to !== prevTo) {
|
|
540
|
+
onSelectionChange({ start: from, end: to });
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
})
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
function convertSelectionToVividFormat({
|
|
547
|
+
to,
|
|
548
|
+
from
|
|
549
|
+
}) {
|
|
550
|
+
return {
|
|
551
|
+
start: from,
|
|
552
|
+
end: to
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function getImageErrorNode(schema, file, errorMessage = "Image loading failed") {
|
|
556
|
+
const nodeType = schema.nodes.imageError;
|
|
557
|
+
const imageErrorNode = nodeType.create({
|
|
558
|
+
alt: `inline image from file ${file.name}`,
|
|
559
|
+
fileName: file.name,
|
|
560
|
+
icon: file.type.split("/")[1],
|
|
561
|
+
errorMessage
|
|
562
|
+
});
|
|
563
|
+
return imageErrorNode;
|
|
564
|
+
}
|
|
565
|
+
const isEmptyParagraph = (node) => {
|
|
566
|
+
return node.type.name === "paragraph" && node.nodeSize === 2;
|
|
567
|
+
};
|
|
568
|
+
const DEFAULT_TEXT_EDITOR_PLACEHOLDER = "Start typing...";
|
|
569
|
+
const placeholderPluginKey = new PluginKey("placeholderPlugin");
|
|
570
|
+
const createPlaceholderPlugin = (placeholder = DEFAULT_TEXT_EDITOR_PLACEHOLDER) => {
|
|
571
|
+
return new Plugin({
|
|
572
|
+
key: placeholderPluginKey,
|
|
573
|
+
props: {
|
|
574
|
+
decorations(state) {
|
|
575
|
+
const { $from } = state.selection;
|
|
576
|
+
const decorations = [];
|
|
577
|
+
if (state.doc.childCount === 1 && isEmptyParagraph($from.parent)) {
|
|
578
|
+
const decoration = Decoration.node($from.before(), $from.after(), {
|
|
579
|
+
"data-placeholder": placeholder,
|
|
580
|
+
class: "placeholder"
|
|
581
|
+
});
|
|
582
|
+
decorations.push(decoration);
|
|
583
|
+
}
|
|
584
|
+
return DecorationSet.create(state.doc, decorations);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
class ProseMirrorFacade {
|
|
590
|
+
#userContentChange = false;
|
|
591
|
+
#view;
|
|
592
|
+
#verifyViewInitiation() {
|
|
593
|
+
if (!this.#view) {
|
|
594
|
+
throw new Error(
|
|
595
|
+
"ProseMirror was not initiated. Please use the `init` method first."
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
#onSelectionChange = () => {
|
|
600
|
+
this.#dispatchEvent("selection-changed");
|
|
601
|
+
};
|
|
602
|
+
#handleInputEvent = (e) => {
|
|
603
|
+
e.stopPropagation();
|
|
604
|
+
this.#userContentChange = true;
|
|
605
|
+
this.#dispatchEvent("input");
|
|
606
|
+
};
|
|
607
|
+
#handleChangeEvent = () => {
|
|
608
|
+
if (!this.#userContentChange) {
|
|
609
|
+
this.#userContentChange = false;
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
this.#dispatchEvent("change");
|
|
613
|
+
};
|
|
614
|
+
#vwcPrefix = "vwc";
|
|
615
|
+
init(element, vwcPrefix = "vwc") {
|
|
616
|
+
this.#vwcPrefix = vwcPrefix;
|
|
617
|
+
if (!(element instanceof HTMLElement)) {
|
|
618
|
+
throw new Error(
|
|
619
|
+
"ProseMirror Facade init accepts a valid HTMLElement as its first parameter"
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
const plugins = [
|
|
623
|
+
createPlaceholderPlugin(),
|
|
624
|
+
createSelectionChangePlugin(this.#onSelectionChange),
|
|
625
|
+
createEnterKeymapPlugin(),
|
|
626
|
+
keymap(baseKeymap)
|
|
627
|
+
];
|
|
628
|
+
const state = EditorState.create({
|
|
629
|
+
schema: dynamicSchema(this.#vwcPrefix),
|
|
630
|
+
plugins
|
|
631
|
+
});
|
|
632
|
+
this.#view = new EditorView(element, { state });
|
|
633
|
+
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
634
|
+
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
635
|
+
}
|
|
636
|
+
updatePlaceholder(placeholderText) {
|
|
637
|
+
this.#verifyViewInitiation();
|
|
638
|
+
const { state } = this.#view;
|
|
639
|
+
const plugins = state.plugins.filter(
|
|
640
|
+
(plugin) => plugin !== placeholderPluginKey.get(state)
|
|
641
|
+
);
|
|
642
|
+
const newPlaceholderPlugin = createPlaceholderPlugin(placeholderText);
|
|
643
|
+
const newState = state.reconfigure({
|
|
644
|
+
plugins: [...plugins, newPlaceholderPlugin]
|
|
645
|
+
});
|
|
646
|
+
this.#view.updateState(newState);
|
|
647
|
+
}
|
|
648
|
+
replaceContent(content) {
|
|
649
|
+
this.#verifyViewInitiation();
|
|
650
|
+
const parser = DOMParser.fromSchema(this.#view.state.schema);
|
|
651
|
+
const doc = parser.parse(
|
|
652
|
+
new window.DOMParser().parseFromString(content, "text/html").body
|
|
653
|
+
);
|
|
654
|
+
const transaction = this.#view.state.tr.replaceWith(
|
|
655
|
+
0,
|
|
656
|
+
this.#view.state.doc.content.size,
|
|
657
|
+
doc.content
|
|
658
|
+
);
|
|
659
|
+
this.#view.dispatch(transaction);
|
|
660
|
+
}
|
|
661
|
+
selection(position) {
|
|
662
|
+
if (this.#view && position) {
|
|
663
|
+
const transaction = this.#view.state.tr.setSelection(
|
|
664
|
+
TextSelection.create(this.#view.state.doc, position.start, position.end)
|
|
665
|
+
);
|
|
666
|
+
this.#view.dispatch(transaction);
|
|
667
|
+
}
|
|
668
|
+
return !this.#view ? NEGATIVE_SELECTION : convertSelectionToVividFormat(this.#view.state.selection);
|
|
669
|
+
}
|
|
670
|
+
#eventHandler = document.createElement("div");
|
|
671
|
+
addEventListener(eventName, callback) {
|
|
672
|
+
this.#eventHandler.addEventListener(eventName, callback);
|
|
673
|
+
}
|
|
674
|
+
#dispatchEvent = (eventName, detail) => {
|
|
675
|
+
this.#eventHandler.dispatchEvent(new CustomEvent(eventName, { detail }));
|
|
676
|
+
};
|
|
677
|
+
setSelectionTag(tag) {
|
|
678
|
+
this.#verifyViewInitiation();
|
|
679
|
+
const nodeDefinitions = TagToSchemaMap[tag] ?? {
|
|
680
|
+
type: tag
|
|
681
|
+
};
|
|
682
|
+
const { state, dispatch } = this.#view;
|
|
683
|
+
const { from, to } = state.selection;
|
|
684
|
+
const tr = state.tr;
|
|
685
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
686
|
+
const nodeType = state.schema.nodes[nodeDefinitions.type];
|
|
687
|
+
if (!nodeType) {
|
|
688
|
+
throw new Error("Node type tag does not exist in the schema");
|
|
689
|
+
}
|
|
690
|
+
if (node.type === nodeType) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
tr.setBlockType(from, to, nodeType, nodeDefinitions.attrs);
|
|
694
|
+
});
|
|
695
|
+
dispatch(tr);
|
|
696
|
+
}
|
|
697
|
+
setSelectionDecoration(decoration) {
|
|
698
|
+
this.#verifyViewInitiation();
|
|
699
|
+
const SUPPORTED_DECORATIONS = {
|
|
700
|
+
bold: "strong",
|
|
701
|
+
italics: "em",
|
|
702
|
+
underline: "u",
|
|
703
|
+
strikethrough: "s",
|
|
704
|
+
monospace: "tt"
|
|
705
|
+
};
|
|
706
|
+
const { state, dispatch } = this.#view;
|
|
707
|
+
const decorationKey = decoration;
|
|
708
|
+
const markType = state.schema.marks[SUPPORTED_DECORATIONS[decorationKey]];
|
|
709
|
+
if (!markType) {
|
|
710
|
+
throw new Error(`${decoration} is not a supported decoration`);
|
|
711
|
+
}
|
|
712
|
+
toggleMark(markType)(state, dispatch);
|
|
713
|
+
this.#userContentChange = true;
|
|
714
|
+
this.#handleChangeEvent();
|
|
715
|
+
}
|
|
716
|
+
#getSelectionBlockType() {
|
|
717
|
+
const { state } = this.#view;
|
|
718
|
+
const { from, to } = state.selection;
|
|
719
|
+
const styles = {};
|
|
720
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
721
|
+
if (node.type.name === "heading" && node.attrs.level === 2) {
|
|
722
|
+
setTextBlockType(styles, "title");
|
|
723
|
+
} else if (node.type.name === "heading" && node.attrs.level === 3) {
|
|
724
|
+
setTextBlockType(styles, "subtitle");
|
|
725
|
+
} else if (node.type.name === "paragraph") {
|
|
726
|
+
setTextBlockType(styles, "body");
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
return styles.textBlockType;
|
|
730
|
+
}
|
|
731
|
+
#getSelectionTextDecoration() {
|
|
732
|
+
const { state } = this.#view;
|
|
733
|
+
const { from, to, empty } = state.selection;
|
|
734
|
+
const decorations = [];
|
|
735
|
+
if (empty) {
|
|
736
|
+
const marks = state.doc.resolve(from).marks();
|
|
737
|
+
if (state.schema.marks.strong && marks.some((mark) => mark.type === state.schema.marks.strong)) {
|
|
738
|
+
decorations.push("bold");
|
|
739
|
+
}
|
|
740
|
+
if (state.schema.marks.em && marks.some((mark) => mark.type === state.schema.marks.em)) {
|
|
741
|
+
decorations.push("italics");
|
|
742
|
+
}
|
|
743
|
+
if (state.schema.marks.u && marks.some((mark) => mark.type === state.schema.marks.u)) {
|
|
744
|
+
decorations.push("underline");
|
|
745
|
+
}
|
|
746
|
+
if (state.schema.marks.s && marks.some((mark) => mark.type === state.schema.marks.s)) {
|
|
747
|
+
decorations.push("strikethrough");
|
|
748
|
+
}
|
|
749
|
+
if (state.schema.marks.tt && marks.some((mark) => mark.type === state.schema.marks.tt)) {
|
|
750
|
+
decorations.push("monospace");
|
|
751
|
+
}
|
|
752
|
+
} else {
|
|
753
|
+
if (state.schema.marks.strong && state.doc.rangeHasMark(from, to, state.schema.marks.strong)) {
|
|
754
|
+
decorations.push("bold");
|
|
755
|
+
}
|
|
756
|
+
if (state.schema.marks.em && state.doc.rangeHasMark(from, to, state.schema.marks.em)) {
|
|
757
|
+
decorations.push("italics");
|
|
758
|
+
}
|
|
759
|
+
if (state.schema.marks.u && state.doc.rangeHasMark(from, to, state.schema.marks.u)) {
|
|
760
|
+
decorations.push("underline");
|
|
761
|
+
}
|
|
762
|
+
if (state.schema.marks.s && state.doc.rangeHasMark(from, to, state.schema.marks.s)) {
|
|
763
|
+
decorations.push("strikethrough");
|
|
764
|
+
}
|
|
765
|
+
if (state.schema.marks.tt && state.doc.rangeHasMark(from, to, state.schema.marks.tt)) {
|
|
766
|
+
decorations.push("monospace");
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return decorations.length ? decorations : void 0;
|
|
770
|
+
}
|
|
771
|
+
#getSelectionTextSize() {
|
|
772
|
+
const { state } = this.#view;
|
|
773
|
+
const { from, to, empty } = state.selection;
|
|
774
|
+
const defaultSize = "normal";
|
|
775
|
+
if (empty) {
|
|
776
|
+
const marks = state.doc.resolve(from).marks();
|
|
777
|
+
const textSizeMark = marks.find(
|
|
778
|
+
(mark) => mark.type === state.schema.marks.textSize
|
|
779
|
+
);
|
|
780
|
+
return textSizeMark ? textSizeMark.attrs.size : defaultSize;
|
|
781
|
+
} else {
|
|
782
|
+
let textSize = null;
|
|
783
|
+
let foundMixedSizes = false;
|
|
784
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
785
|
+
if (node.isText) {
|
|
786
|
+
const mark = node.marks.find(
|
|
787
|
+
(mark2) => mark2.type === state.schema.marks.textSize
|
|
788
|
+
);
|
|
789
|
+
if (mark) {
|
|
790
|
+
if (textSize === null) {
|
|
791
|
+
textSize = mark.attrs.size;
|
|
792
|
+
} else if (textSize !== mark.attrs.size) {
|
|
793
|
+
foundMixedSizes = true;
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
} else if (textSize !== null) {
|
|
797
|
+
foundMixedSizes = true;
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
return true;
|
|
802
|
+
});
|
|
803
|
+
if (foundMixedSizes) {
|
|
804
|
+
return "";
|
|
805
|
+
}
|
|
806
|
+
return textSize !== null ? textSize : defaultSize;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
getSelectionStyles() {
|
|
810
|
+
this.#verifyViewInitiation();
|
|
811
|
+
const styles = {};
|
|
812
|
+
styles.textBlockType = this.#getSelectionBlockType();
|
|
813
|
+
styles.textDecoration = this.#getSelectionTextDecoration();
|
|
814
|
+
styles.textSize = this.#getSelectionTextSize();
|
|
815
|
+
return styles;
|
|
816
|
+
}
|
|
817
|
+
setTextSize(size = "normal") {
|
|
818
|
+
this.#verifyViewInitiation();
|
|
819
|
+
const { state, dispatch } = this.#view;
|
|
820
|
+
const { schema, selection, tr } = state;
|
|
821
|
+
const { from, to } = selection;
|
|
822
|
+
const textSizeMark = schema.marks.textSize;
|
|
823
|
+
tr.removeMark(from, to, textSizeMark);
|
|
824
|
+
tr.addMark(from, to, textSizeMark.create({ size }));
|
|
825
|
+
dispatch(tr.scrollIntoView());
|
|
826
|
+
this.#userContentChange = true;
|
|
827
|
+
this.#handleChangeEvent();
|
|
828
|
+
}
|
|
829
|
+
getValue() {
|
|
830
|
+
return this.#view.dom.innerHTML;
|
|
831
|
+
}
|
|
832
|
+
async addInlineImage({
|
|
833
|
+
file,
|
|
834
|
+
position,
|
|
835
|
+
alt,
|
|
836
|
+
error
|
|
837
|
+
}) {
|
|
838
|
+
this.#verifyViewInitiation();
|
|
839
|
+
const reader = new FileReader();
|
|
840
|
+
const src = await new Promise((resolve, reject) => {
|
|
841
|
+
reader.onload = () => resolve(reader.result);
|
|
842
|
+
reader.onerror = reject;
|
|
843
|
+
reader.readAsDataURL(file);
|
|
844
|
+
});
|
|
845
|
+
const { state, dispatch } = this.#view;
|
|
846
|
+
const { schema } = state;
|
|
847
|
+
const imageAlt = alt ?? `inline image from file ${file.name}`;
|
|
848
|
+
const imageNode = error ? getImageErrorNode(schema, file, error) : schema.nodes.image.create({ src, alt: imageAlt });
|
|
849
|
+
let insertPos = position;
|
|
850
|
+
if (typeof insertPos !== "number") {
|
|
851
|
+
insertPos = state.selection.from;
|
|
852
|
+
}
|
|
853
|
+
const tr = state.tr.insert(insertPos, imageNode);
|
|
854
|
+
dispatch(tr.scrollIntoView());
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
var __defProp$1 = Object.defineProperty;
|
|
859
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
860
|
+
var result = void 0 ;
|
|
861
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
862
|
+
if (decorator = decorators[i])
|
|
863
|
+
result = (decorator(target, key, result) ) || result;
|
|
864
|
+
if (result) __defProp$1(target, key, result);
|
|
865
|
+
return result;
|
|
866
|
+
};
|
|
867
|
+
const RichTextEditorTextBlocks = {
|
|
868
|
+
title: "h2",
|
|
869
|
+
subtitle: "h3",
|
|
870
|
+
body: "p"
|
|
871
|
+
};
|
|
872
|
+
class RichTextEditor extends Localized(VividElement) {
|
|
873
|
+
constructor() {
|
|
874
|
+
super();
|
|
875
|
+
this.selectionStart = null;
|
|
876
|
+
this.#updateEditorSelection = () => {
|
|
877
|
+
try {
|
|
878
|
+
this.#editor?.selection({
|
|
879
|
+
start: this.selectionStart,
|
|
880
|
+
end: this.selectionEnd ? this.selectionEnd : this.selectionStart
|
|
881
|
+
});
|
|
882
|
+
} catch (e) {
|
|
883
|
+
console.warn(e.message);
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
this.selectionEnd = null;
|
|
887
|
+
this.#handleSelectionChange = () => {
|
|
888
|
+
if (!this.#editor.selection()) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
const { start, end } = this.#editor.selection();
|
|
892
|
+
this.selectionStart = start;
|
|
893
|
+
this.selectionEnd = end;
|
|
894
|
+
this.$emit("selection-changed");
|
|
895
|
+
};
|
|
896
|
+
this.#handleChange = () => {
|
|
897
|
+
this.$emit("change");
|
|
898
|
+
};
|
|
899
|
+
this.#handleInput = () => {
|
|
900
|
+
this.$emit("input");
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Indicates the rich text editor's value.
|
|
905
|
+
*
|
|
906
|
+
* @public
|
|
907
|
+
* @remarks
|
|
908
|
+
* HTML Attribute: value
|
|
909
|
+
*/
|
|
910
|
+
get value() {
|
|
911
|
+
return this.#editor?.getValue();
|
|
912
|
+
}
|
|
913
|
+
set value(content) {
|
|
914
|
+
if (this.#editor) {
|
|
915
|
+
this.#editor.replaceContent(content);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
#editor;
|
|
919
|
+
get #editorWrapperElement() {
|
|
920
|
+
return this.shadowRoot.querySelector("#editor");
|
|
921
|
+
}
|
|
922
|
+
selectionStartChanged() {
|
|
923
|
+
if (!this.selectionStart || this.selectionEnd && this.selectionStart > this.selectionEnd) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
this.#updateEditorSelection();
|
|
927
|
+
}
|
|
928
|
+
#updateEditorSelection;
|
|
929
|
+
selectionEndChanged() {
|
|
930
|
+
if (this.selectionEnd && !this.selectionStart) {
|
|
931
|
+
this.selectionStart = 1;
|
|
932
|
+
}
|
|
933
|
+
this.#updateEditorSelection();
|
|
934
|
+
}
|
|
935
|
+
placeholderChanged() {
|
|
936
|
+
this.#editor?.updatePlaceholder(this.placeholder);
|
|
937
|
+
}
|
|
938
|
+
#handleSelectionChange;
|
|
939
|
+
#handleChange;
|
|
940
|
+
#handleInput;
|
|
941
|
+
connectedCallback() {
|
|
942
|
+
super.connectedCallback();
|
|
943
|
+
if (!this.#editor) {
|
|
944
|
+
this.#editor = new ProseMirrorFacade();
|
|
945
|
+
this.#editor.init(this.#editorWrapperElement);
|
|
946
|
+
this.#editor.addEventListener(
|
|
947
|
+
"selection-changed",
|
|
948
|
+
this.#handleSelectionChange
|
|
949
|
+
);
|
|
950
|
+
this.#editor.addEventListener("change", this.#handleChange);
|
|
951
|
+
this.#editor.addEventListener("input", this.#handleInput);
|
|
952
|
+
}
|
|
953
|
+
this.placeholderChanged();
|
|
954
|
+
}
|
|
955
|
+
setTextBlock(blockType) {
|
|
956
|
+
try {
|
|
957
|
+
this.#editor?.setSelectionTag(RichTextEditorTextBlocks[blockType]);
|
|
958
|
+
} catch (e) {
|
|
959
|
+
console.warn(`Invalid text block: ${blockType}`);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
setSelectionDecoration(decoration) {
|
|
963
|
+
try {
|
|
964
|
+
this.#editor?.setSelectionDecoration(decoration);
|
|
965
|
+
} catch (e) {
|
|
966
|
+
console.warn(`Invalid decoration: ${decoration}`);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
setSelectionTextSize(textSize) {
|
|
970
|
+
this.#editor?.setTextSize(textSize);
|
|
971
|
+
}
|
|
972
|
+
get selectionStyles() {
|
|
973
|
+
if (!this.#editor) {
|
|
974
|
+
return {};
|
|
975
|
+
}
|
|
976
|
+
return this.#editor.getSelectionStyles();
|
|
977
|
+
}
|
|
978
|
+
focus() {
|
|
979
|
+
super.focus();
|
|
980
|
+
setTimeout(() => {
|
|
981
|
+
this.#editableAreaElement.focus();
|
|
982
|
+
}, 0);
|
|
983
|
+
}
|
|
984
|
+
get #editableAreaElement() {
|
|
985
|
+
return this.#editorWrapperElement.querySelector(
|
|
986
|
+
'[contenteditable="true"]'
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
scrollToAttachments(additionalPixels = 0) {
|
|
990
|
+
DOM.queueUpdate(() => {
|
|
991
|
+
this.#editorWrapperElement.scrollTop = this.#editableAreaElement.getBoundingClientRect().height - this.#editorWrapperElement.getBoundingClientRect().height + additionalPixels;
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
async addInlineImage(imageProps) {
|
|
995
|
+
try {
|
|
996
|
+
await this.#editor.addInlineImage(imageProps);
|
|
997
|
+
} catch (e) {
|
|
998
|
+
console.warn(e.message);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
__decorateClass$1([
|
|
1003
|
+
attr({ converter: nullableNumberConverter, attribute: "selection-start" })
|
|
1004
|
+
], RichTextEditor.prototype, "selectionStart");
|
|
1005
|
+
__decorateClass$1([
|
|
1006
|
+
attr({ converter: nullableNumberConverter, attribute: "selection-end" })
|
|
1007
|
+
], RichTextEditor.prototype, "selectionEnd");
|
|
1008
|
+
__decorateClass$1([
|
|
1009
|
+
attr
|
|
1010
|
+
], RichTextEditor.prototype, "placeholder");
|
|
1011
|
+
|
|
1012
|
+
const getClasses$1 = (_) => classNames("control");
|
|
1013
|
+
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
1014
|
+
const menuParent = (target) => target.parentElement;
|
|
1015
|
+
function textBlockSelectedHandler(event) {
|
|
1016
|
+
menuParent(event.target).setTextBlock(
|
|
1017
|
+
event.detail
|
|
1018
|
+
);
|
|
1019
|
+
menuParent(event.target).focus();
|
|
1020
|
+
}
|
|
1021
|
+
function selectionDecorationSelectedHandler(event) {
|
|
1022
|
+
menuParent(event.target).setSelectionDecoration(
|
|
1023
|
+
event.detail
|
|
1024
|
+
);
|
|
1025
|
+
menuParent(event.target).focus();
|
|
1026
|
+
}
|
|
1027
|
+
function textSizeSelectedHandler(event) {
|
|
1028
|
+
menuParent(event.target).setSelectionTextSize(
|
|
1029
|
+
event.detail
|
|
1030
|
+
);
|
|
1031
|
+
menuParent(event.target).focus();
|
|
1032
|
+
}
|
|
1033
|
+
function handleAttachmentsSlotChange(_, { event }) {
|
|
1034
|
+
const slotElement = event.target;
|
|
1035
|
+
slotElement.parentElement?.classList.toggle(
|
|
1036
|
+
"hidden",
|
|
1037
|
+
slotElement.assignedElements().length < 1
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
function handleMenubarSlotChange(_, { event }) {
|
|
1041
|
+
const slot = event.target;
|
|
1042
|
+
const assignedElements = slot.assignedElements({ flatten: true });
|
|
1043
|
+
const menubar = assignedElements.find(
|
|
1044
|
+
(element) => element.tagName.toLowerCase().endsWith(VALID_MENU_ELEMEMENT_SUFFIX)
|
|
1045
|
+
);
|
|
1046
|
+
assignedElements.forEach((element) => {
|
|
1047
|
+
if (element === menubar) {
|
|
1048
|
+
element.style.removeProperty("display");
|
|
1049
|
+
} else {
|
|
1050
|
+
element.style.display = "none";
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
if (menubar) {
|
|
1054
|
+
menubar.addEventListener(
|
|
1055
|
+
"text-block-selected",
|
|
1056
|
+
textBlockSelectedHandler
|
|
1057
|
+
);
|
|
1058
|
+
menubar.addEventListener(
|
|
1059
|
+
"text-decoration-selected",
|
|
1060
|
+
selectionDecorationSelectedHandler
|
|
1061
|
+
);
|
|
1062
|
+
menubar.addEventListener(
|
|
1063
|
+
"text-size-selected",
|
|
1064
|
+
textSizeSelectedHandler
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
function handleFileDrop(x, { event }) {
|
|
1069
|
+
x.dispatchEvent(
|
|
1070
|
+
new CustomEvent("file-drop", { detail: event.dataTransfer.files })
|
|
1071
|
+
);
|
|
1072
|
+
handleDragLeave(x, { event });
|
|
1073
|
+
}
|
|
1074
|
+
function handleDragEnter(_, { event }) {
|
|
1075
|
+
const editorWrapperElement = event.currentTarget;
|
|
1076
|
+
editorWrapperElement.classList.toggle("drag-over", true);
|
|
1077
|
+
}
|
|
1078
|
+
function handleDragLeave(_, { event }) {
|
|
1079
|
+
const editorWrapperElement = event.currentTarget;
|
|
1080
|
+
if (!editorWrapperElement.contains(event.relatedTarget)) {
|
|
1081
|
+
editorWrapperElement.classList.remove("drag-over");
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
const RichTextEditorTemplate = (context) => {
|
|
1085
|
+
const dividerTag = context.tagFor(Divider);
|
|
1086
|
+
return html`<template class="${getClasses$1}">
|
|
1087
|
+
<div id="editor"
|
|
1088
|
+
class="editor"
|
|
1089
|
+
@drop="${handleFileDrop}"
|
|
1090
|
+
@dragenter="${handleDragEnter}"
|
|
1091
|
+
@dragleave="${handleDragLeave}"
|
|
1092
|
+
>
|
|
1093
|
+
<div class="drag-overlay">
|
|
1094
|
+
${(x) => x.locale.richTextEditor.dragAndDropFilesHere}
|
|
1095
|
+
</div>
|
|
1096
|
+
<div id="attachments-wrapper" class="hidden">
|
|
1097
|
+
<${dividerTag} class="divider"></${dividerTag}>
|
|
1098
|
+
<slot name="attachments"
|
|
1099
|
+
@slotchange="${handleAttachmentsSlotChange}">
|
|
1100
|
+
</slot>
|
|
1101
|
+
</div>
|
|
1102
|
+
</div>
|
|
1103
|
+
<slot name="menu-bar"
|
|
1104
|
+
@slotchange="${handleMenubarSlotChange}"></slot>
|
|
1105
|
+
</template>`;
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
const styles = ":host{white-space:normal}.image-placeholder{display:flex;width:250px;height:64px;box-sizing:border-box;align-items:center;padding:16px;border:1px solid var(--vvd-color-neutral-200);border-radius:12px;background-color:var(--vvd-color-canvas);gap:16px}.icon{display:flex;width:40px;height:40px;box-sizing:border-box;flex-shrink:0;align-items:center;justify-content:center;border-radius:8px;background-color:color-mix(in srgb,var(--vvd-color-neutral-950),transparent 90%);color:var(--vvd-color-neutral-600)}.info{display:flex;flex-direction:column;min-inline-size:0}.filename{display:flex;overflow:hidden;width:100%;max-width:220px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-condensed-bold);white-space:nowrap}.name{overflow:hidden;flex:1 1 auto;text-overflow:ellipsis}.suffix{flex:0 0 auto;margin-left:4px}.error{display:flex;align-items:center;color:var(--vvd-color-alert-600);font:var(--vvd-typography-base-condensed);gap:6px}";
|
|
1109
|
+
|
|
1110
|
+
var __defProp = Object.defineProperty;
|
|
1111
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
1112
|
+
var result = void 0 ;
|
|
1113
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1114
|
+
if (decorator = decorators[i])
|
|
1115
|
+
result = (decorator(target, key, result) ) || result;
|
|
1116
|
+
if (result) __defProp(target, key, result);
|
|
1117
|
+
return result;
|
|
1118
|
+
};
|
|
1119
|
+
class ImagePlaceholder extends VividElement {
|
|
1120
|
+
}
|
|
1121
|
+
__decorateClass([
|
|
1122
|
+
attr({ attribute: "file-name" })
|
|
1123
|
+
], ImagePlaceholder.prototype, "fileName");
|
|
1124
|
+
__decorateClass([
|
|
1125
|
+
attr({ attribute: "size" })
|
|
1126
|
+
], ImagePlaceholder.prototype, "size");
|
|
1127
|
+
__decorateClass([
|
|
1128
|
+
attr({ attribute: "error-message" })
|
|
1129
|
+
], ImagePlaceholder.prototype, "errorMessage");
|
|
1130
|
+
__decorateClass([
|
|
1131
|
+
attr({ attribute: "icon" })
|
|
1132
|
+
], ImagePlaceholder.prototype, "icon");
|
|
1133
|
+
|
|
1134
|
+
const getClasses = (_) => classNames("base");
|
|
1135
|
+
const getIconName = ({ icon }) => {
|
|
1136
|
+
if (!icon) {
|
|
1137
|
+
return "clear-file-solid";
|
|
1138
|
+
}
|
|
1139
|
+
return `file-${icon}-solid`;
|
|
1140
|
+
};
|
|
1141
|
+
const getFileSuffix = (x) => {
|
|
1142
|
+
return x.fileName?.split(".").pop() || "";
|
|
1143
|
+
};
|
|
1144
|
+
const getFileName = (x) => {
|
|
1145
|
+
return x.fileName?.replace(/\.[^/.]+$/, "") || "";
|
|
1146
|
+
};
|
|
1147
|
+
const ImagePlaceholderTemplate = (context) => {
|
|
1148
|
+
const iconTag = context.tagFor(Icon);
|
|
1149
|
+
return html`<template class="${getClasses}">
|
|
1150
|
+
<div class="image-placeholder">
|
|
1151
|
+
<div class="icon">
|
|
1152
|
+
<${iconTag} name="${getIconName}" size="-5"></${iconTag}>
|
|
1153
|
+
</div>
|
|
1154
|
+
<div class="info">
|
|
1155
|
+
<div class="filename" title="${(x) => x.fileName}">
|
|
1156
|
+
<div class="name">${getFileName}</div>
|
|
1157
|
+
<div class="suffix">${getFileSuffix}</div>
|
|
1158
|
+
</div>
|
|
1159
|
+
${when(
|
|
1160
|
+
(x) => x.errorMessage,
|
|
1161
|
+
html`<div class="error">
|
|
1162
|
+
<span class="error-icon"><${iconTag} name="error-solid" size="-6"></${iconTag}></span>
|
|
1163
|
+
<span class="error-text">${(x) => x.errorMessage}</span>
|
|
1164
|
+
</div>`
|
|
1165
|
+
)}
|
|
1166
|
+
</div>
|
|
1167
|
+
</div>
|
|
1168
|
+
</template>`;
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
const imagePlaceholderDefinition = defineVividComponent(
|
|
1172
|
+
"text-editor-image-placeholder",
|
|
1173
|
+
ImagePlaceholder,
|
|
1174
|
+
ImagePlaceholderTemplate,
|
|
1175
|
+
[iconDefinition],
|
|
1176
|
+
{
|
|
1177
|
+
styles,
|
|
1178
|
+
shadowOptions: {
|
|
1179
|
+
delegatesFocus: true
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1183
|
+
|
|
1184
|
+
const richTextEditorDefinition = defineVividComponent(
|
|
1185
|
+
"rich-text-editor",
|
|
1186
|
+
RichTextEditor,
|
|
1187
|
+
RichTextEditorTemplate,
|
|
1188
|
+
[menubarDefinition, dividerDefinition, imagePlaceholderDefinition],
|
|
1189
|
+
{
|
|
1190
|
+
styles: styles$2,
|
|
1191
|
+
shadowOptions: {
|
|
1192
|
+
delegatesFocus: true
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
);
|
|
1196
|
+
const registerRichTextEditor = createRegisterFunction(
|
|
1197
|
+
richTextEditorDefinition
|
|
1198
|
+
);
|
|
1199
|
+
|
|
1200
|
+
export { RichTextEditor as VwcRichTextEditorElement, registerRichTextEditor, richTextEditorDefinition };
|