@vonage/vivid 4.21.1 → 4.23.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/custom-elements.json +2055 -640
- package/index.cjs +1 -1
- package/index.js +2 -2
- package/lib/accordion-item/accordion-item.d.ts +11 -5
- package/lib/action-group/action-group.d.ts +8 -6
- package/lib/alert/alert.d.ts +21 -9
- package/lib/audio-player/audio-player.d.ts +13 -6
- package/lib/badge/badge.d.ts +11 -5
- package/lib/banner/banner.d.ts +26 -12
- package/lib/breadcrumb/breadcrumb.d.ts +333 -1
- package/lib/breadcrumb/breadcrumb.template.d.ts +2 -3
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +8 -6
- package/lib/button/button.d.ts +11 -5
- package/lib/calendar/calendar.d.ts +3 -1
- package/lib/calendar-event/calendar-event.d.ts +333 -1
- package/lib/checkbox/checkbox.d.ts +8 -6
- package/lib/combobox/combobox.d.ts +11 -5
- package/lib/date-picker/date-picker.d.ts +74 -50
- package/lib/date-range-picker/date-range-picker.d.ts +38 -26
- package/lib/date-time-picker/date-time-picker.d.ts +76 -52
- package/lib/dial-pad/dial-pad.d.ts +11 -5
- package/lib/dialog/dialog.d.ts +16 -8
- package/lib/divider/divider.d.ts +8 -6
- package/lib/enums.d.ts +0 -4
- package/lib/fab/fab.d.ts +11 -5
- package/lib/file-picker/file-picker.d.ts +338 -1
- package/lib/header/header.d.ts +333 -1
- package/lib/menu/menu.d.ts +16 -8
- package/lib/menu-item/menu-item.d.ts +338 -2
- package/lib/nav/nav.d.ts +333 -1
- package/lib/nav-disclosure/nav-disclosure.d.ts +16 -8
- package/lib/nav-item/nav-item.d.ts +11 -5
- package/lib/note/note.d.ts +11 -5
- package/lib/number-field/number-field.d.ts +26 -12
- package/lib/option/option.d.ts +341 -3
- package/lib/progress/progress.d.ts +8 -6
- package/lib/progress-ring/progress-ring.d.ts +8 -6
- package/lib/radio-group/radio-group.d.ts +333 -1
- package/lib/range-slider/range-slider.d.ts +11 -5
- package/lib/rich-text-editor/facades/prose-mirror-vivid.schema.d.ts +1 -1
- package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +7 -1
- package/lib/rich-text-editor/menubar/consts.d.ts +18 -0
- package/lib/rich-text-editor/menubar/menubar.d.ts +3 -0
- package/lib/rich-text-editor/rich-text-editor.d.ts +14 -3
- package/lib/searchable-select/option-tag.d.ts +14 -6
- package/lib/searchable-select/searchable-select.d.ts +349 -7
- package/lib/select/select.d.ts +339 -3
- package/lib/selectable-box/selectable-box.d.ts +8 -6
- package/lib/slider/slider.d.ts +16 -8
- package/lib/split-button/split-button.d.ts +26 -12
- package/lib/switch/switch.d.ts +8 -6
- package/lib/tab/tab.d.ts +349 -7
- package/lib/tab-panel/tab-panel.d.ts +333 -1
- package/lib/tabs/definition.d.ts +1 -0
- package/lib/tabs/tabs.d.ts +6 -1
- package/lib/tag/tag.d.ts +338 -2
- package/lib/tag-group/tag-group.d.ts +8 -6
- package/lib/text-anchor/text-anchor.d.ts +16 -8
- package/lib/text-area/text-area.d.ts +8 -6
- package/lib/text-field/text-field.d.ts +16 -8
- package/lib/time-picker/time-picker.d.ts +38 -26
- package/lib/toggletip/toggletip.d.ts +9 -3
- package/lib/tooltip/tooltip.d.ts +9 -3
- package/lib/tree-item/tree-item.d.ts +338 -2
- package/lib/tree-view/tree-view.d.ts +333 -1
- package/lib/video-player/video-player.d.ts +14 -6
- package/package.json +1 -1
- package/shared/affix.js +1 -1
- package/shared/aria/aria-change-subscription.d.ts +6 -0
- package/shared/aria/aria-mixin.d.ts +338 -0
- package/shared/aria/delegate-aria-behavior.d.ts +31 -0
- package/shared/aria/delegates-aria.d.ts +14 -9
- package/shared/aria/host-semantics-behavior.d.ts +22 -0
- package/shared/aria/host-semantics.d.ts +337 -0
- package/shared/attribute-binding-behaviour.cjs +41 -0
- package/shared/attribute-binding-behaviour.js +39 -0
- package/shared/calendar-event.cjs +2 -1
- package/shared/calendar-event.js +2 -1
- package/shared/definition.js +1 -1
- package/shared/definition10.cjs +8 -2
- package/shared/definition10.js +9 -3
- package/shared/definition11.cjs +4 -28
- package/shared/definition11.js +5 -29
- package/shared/definition12.cjs +4 -1
- package/shared/definition12.js +5 -2
- package/shared/definition13.js +1 -1
- package/shared/definition14.js +1 -1
- package/shared/definition15.cjs +9 -8
- package/shared/definition15.js +11 -10
- package/shared/definition16.cjs +1 -1
- package/shared/definition16.js +2 -2
- package/shared/definition17.js +1 -1
- package/shared/definition18.js +1 -1
- package/shared/definition19.cjs +3 -0
- package/shared/definition19.js +4 -1
- package/shared/definition2.js +1 -1
- package/shared/definition20.js +1 -1
- package/shared/definition21.js +1 -1
- package/shared/definition22.cjs +3 -2
- package/shared/definition22.js +5 -4
- package/shared/definition23.cjs +4 -2
- package/shared/definition23.js +6 -4
- package/shared/definition24.js +1 -1
- package/shared/definition25.cjs +2 -14
- package/shared/definition25.js +3 -15
- package/shared/definition26.cjs +15 -2
- package/shared/definition26.js +16 -3
- package/shared/definition27.cjs +3 -2
- package/shared/definition27.js +4 -3
- package/shared/definition28.cjs +1 -1
- package/shared/definition28.js +2 -2
- package/shared/definition29.js +1 -1
- package/shared/definition3.cjs +4 -3
- package/shared/definition3.js +6 -5
- package/shared/definition30.cjs +34 -34
- package/shared/definition30.js +36 -36
- package/shared/definition31.cjs +6 -4
- package/shared/definition31.js +8 -6
- package/shared/definition32.js +1 -1
- package/shared/definition33.cjs +7 -2
- package/shared/definition33.js +8 -3
- package/shared/definition34.js +1 -1
- package/shared/definition35.cjs +3 -14
- package/shared/definition35.js +5 -16
- package/shared/definition36.cjs +8 -5
- package/shared/definition36.js +9 -6
- package/shared/definition37.js +1 -1
- package/shared/definition38.cjs +7 -8
- package/shared/definition38.js +9 -10
- package/shared/definition39.cjs +7 -8
- package/shared/definition39.js +9 -10
- package/shared/definition4.cjs +1 -1
- package/shared/definition4.js +2 -2
- package/shared/definition40.cjs +8 -5
- package/shared/definition40.js +9 -6
- package/shared/definition41.cjs +1 -1
- package/shared/definition41.js +2 -2
- package/shared/definition42.js +1 -1
- package/shared/definition43.cjs +506 -93
- package/shared/definition43.js +502 -89
- package/shared/definition44.cjs +27 -10
- package/shared/definition44.js +28 -11
- package/shared/definition45.cjs +12 -6
- package/shared/definition45.js +13 -7
- package/shared/definition46.cjs +18 -6
- package/shared/definition46.js +20 -8
- package/shared/definition47.js +1 -1
- package/shared/definition48.js +1 -1
- package/shared/definition49.cjs +10 -3
- package/shared/definition49.js +12 -5
- package/shared/definition5.cjs +7 -2
- package/shared/definition5.js +8 -3
- package/shared/definition50.cjs +8 -7
- package/shared/definition50.js +10 -9
- package/shared/definition51.cjs +3 -2
- package/shared/definition51.js +4 -3
- package/shared/definition52.cjs +8 -4
- package/shared/definition52.js +9 -5
- package/shared/definition53.cjs +5 -0
- package/shared/definition53.js +6 -2
- package/shared/definition54.cjs +4 -3
- package/shared/definition54.js +6 -5
- package/shared/definition55.cjs +7 -4
- package/shared/definition55.js +8 -5
- package/shared/definition56.cjs +69 -15
- package/shared/definition56.js +70 -16
- package/shared/definition57.cjs +163 -112
- package/shared/definition57.js +165 -114
- package/shared/definition58.js +1 -1
- package/shared/definition59.js +1 -1
- package/shared/definition6.js +1 -1
- package/shared/definition60.js +1 -1
- package/shared/definition61.cjs +8 -5
- package/shared/definition61.js +9 -6
- package/shared/definition62.cjs +5 -2
- package/shared/definition62.js +6 -3
- package/shared/definition63.js +1 -1
- package/shared/definition64.js +1 -1
- package/shared/definition65.js +1 -1
- package/shared/definition7.js +1 -1
- package/shared/definition8.cjs +4 -2
- package/shared/definition8.js +6 -4
- package/shared/definition9.js +1 -1
- package/shared/delegates-aria.cjs +106 -56
- package/shared/delegates-aria.js +107 -58
- package/shared/enums.cjs +0 -6
- package/shared/enums.js +1 -6
- package/shared/foundation/button/button.d.ts +8 -6
- package/shared/foundation/vivid-element/vivid-element.d.ts +339 -1
- package/shared/host-semantics.cjs +65 -0
- package/shared/host-semantics.js +62 -0
- package/shared/option.cjs +7 -1
- package/shared/option.js +7 -1
- package/shared/patterns/affix.d.ts +22 -10
- package/shared/patterns/anchored.d.ts +18 -6
- package/shared/patterns/localized.d.ts +11 -5
- package/shared/patterns/trapped-focus.d.ts +11 -5
- package/shared/picker-field/mixins/calendar-picker.d.ts +19 -13
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +19 -13
- package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +11 -5
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +38 -26
- package/shared/picker-field/mixins/single-date-picker.d.ts +55 -37
- package/shared/picker-field/mixins/single-value-picker.d.ts +17 -11
- package/shared/picker-field/mixins/time-selection-picker.d.ts +38 -26
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +38 -26
- package/shared/picker-field/picker-field.d.ts +21 -9
- package/shared/picker-field.template.js +1 -1
- package/shared/repeat.js +1 -1
- package/shared/single-value-picker.cjs +3 -0
- package/shared/single-value-picker.js +3 -0
- package/shared/slider.template.cjs +10 -9
- package/shared/slider.template.js +10 -9
- package/shared/templating/attribute-binding-behaviour.d.ts +15 -0
- package/shared/templating/render-in-light-dom.d.ts +22 -0
- package/shared/text-anchor.template.cjs +2 -13
- package/shared/text-anchor.template.js +2 -13
- package/shared/text-field.cjs +1 -1
- package/shared/text-field.js +1 -1
- package/shared/time-selection-picker.template.js +1 -1
- package/shared/vivid-element.cjs +96 -2
- package/shared/vivid-element.js +93 -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/text-anchor/index.js +1 -1
- package/vivid.api.json +316 -70
- package/shared/Reflector.cjs +0 -71
- package/shared/Reflector.js +0 -69
package/shared/definition43.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { V as VividElement, a as attr, h as html,
|
|
1
|
+
import { V as VividElement, a as attr, h as html, i as defineVividComponent, n as nullableNumberConverter, g as createRegisterFunction } from './vivid-element.js';
|
|
2
2
|
import { B as Button, b as buttonDefinition } from './definition11.js';
|
|
3
|
-
import { e as Menu, M as MenuItem, c as menuDefinition, m as menuItemDefinition } from './definition30.js';
|
|
4
3
|
import { D as Divider, d as dividerDefinition } from './definition23.js';
|
|
5
4
|
import { T as Tooltip, t as tooltipDefinition } from './definition60.js';
|
|
6
|
-
import {
|
|
5
|
+
import { S as Select, s as selectDefinition } from './definition45.js';
|
|
6
|
+
import { L as ListboxOption } from './option.js';
|
|
7
|
+
import { e as Menu, M as MenuItem, c as menuDefinition, m as menuItemDefinition } from './definition30.js';
|
|
7
8
|
import { r as repeat } from './repeat.js';
|
|
9
|
+
import { c as classNames } from './class-names.js';
|
|
10
|
+
import { l as listboxOptionDefinition } from './definition36.js';
|
|
8
11
|
|
|
9
|
-
const styles$1 = "@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}.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}.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)}";
|
|
12
|
+
const styles$1 = "@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}.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)}";
|
|
10
13
|
|
|
11
|
-
const styles = ":host{display:flex;align-items:center;
|
|
14
|
+
const styles = ":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}";
|
|
12
15
|
|
|
13
16
|
var __defProp$1 = Object.defineProperty;
|
|
14
17
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
@@ -20,6 +23,38 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
20
23
|
return result;
|
|
21
24
|
};
|
|
22
25
|
class MenuBar extends VividElement {
|
|
26
|
+
get #textEditorElement() {
|
|
27
|
+
return this.parentElement;
|
|
28
|
+
}
|
|
29
|
+
#updateTextStyleState = () => {
|
|
30
|
+
this.dispatchEvent(
|
|
31
|
+
new CustomEvent("text-styles-changed", {
|
|
32
|
+
detail: this.#textEditorElement?.selectionStyles
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
super.connectedCallback();
|
|
38
|
+
this.#textEditorElement.addEventListener(
|
|
39
|
+
"selection-changed",
|
|
40
|
+
this.#updateTextStyleState
|
|
41
|
+
);
|
|
42
|
+
this.#textEditorElement.addEventListener(
|
|
43
|
+
"change",
|
|
44
|
+
this.#updateTextStyleState
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
this.#textEditorElement?.removeEventListener(
|
|
50
|
+
"selection-changed",
|
|
51
|
+
this.#updateTextStyleState
|
|
52
|
+
);
|
|
53
|
+
this.#textEditorElement?.removeEventListener(
|
|
54
|
+
"change",
|
|
55
|
+
this.#updateTextStyleState
|
|
56
|
+
);
|
|
57
|
+
}
|
|
23
58
|
}
|
|
24
59
|
__decorateClass$1([
|
|
25
60
|
attr({ attribute: "menu-items" })
|
|
@@ -56,93 +91,225 @@ const TEXT_DECORATION_ITEMS = [
|
|
|
56
91
|
value: "monospace"
|
|
57
92
|
}
|
|
58
93
|
];
|
|
94
|
+
const TEXT_SIZES = [
|
|
95
|
+
{
|
|
96
|
+
text: "Extra Large",
|
|
97
|
+
value: "extra-large"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
text: "Large",
|
|
101
|
+
value: "large"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
text: "Normal",
|
|
105
|
+
value: "normal"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
text: "Small",
|
|
109
|
+
value: "small"
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
const textBlockEventHandler = (event) => {
|
|
113
|
+
const customEvent = event;
|
|
114
|
+
if (!customEvent || !customEvent.detail || customEvent.detail.textBlockType === void 0) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const menu = customEvent.target;
|
|
118
|
+
menu.shadowRoot.querySelector("#text-block").setAttribute("current-value", customEvent.detail.textBlockType);
|
|
119
|
+
};
|
|
120
|
+
const textDecorationEventHandler = (event) => {
|
|
121
|
+
const customEvent = event;
|
|
122
|
+
if (!customEvent || !customEvent.detail) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const menu = customEvent.target;
|
|
126
|
+
const selectionButtons = menu.shadowRoot.querySelectorAll(
|
|
127
|
+
"#text-decoration .selection-button"
|
|
128
|
+
);
|
|
129
|
+
selectionButtons.forEach((button) => button.removeAttribute("active"));
|
|
130
|
+
customEvent.detail.textDecoration !== void 0 && TEXT_DECORATION_ITEMS.forEach((menuItemConfig, index) => {
|
|
131
|
+
if (customEvent.detail.textDecoration.indexOf(menuItemConfig.value) >= 0) {
|
|
132
|
+
selectionButtons[index].toggleAttribute("active", true);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
const textSizeEventHandler = (event) => {
|
|
137
|
+
const customEvent = event;
|
|
138
|
+
if (!customEvent || !customEvent.detail) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const menu = customEvent.target;
|
|
142
|
+
const selectionTextSize = customEvent.detail.textSize ?? "normal";
|
|
143
|
+
const textSizeElements = menu.shadowRoot.querySelectorAll(
|
|
144
|
+
".menubar-selector-menuitem"
|
|
145
|
+
);
|
|
146
|
+
textSizeElements.forEach((textSizeElement) => {
|
|
147
|
+
textSizeElement.toggleAttribute(
|
|
148
|
+
"checked",
|
|
149
|
+
textSizeElement.getAttribute("value") === selectionTextSize
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
};
|
|
59
153
|
const MENU_BAR_ITEMS = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
154
|
+
textBlock: {
|
|
155
|
+
registerStateProperty: function(menuBar) {
|
|
156
|
+
menuBar.addEventListener("text-styles-changed", textBlockEventHandler);
|
|
157
|
+
},
|
|
158
|
+
render: function(context) {
|
|
159
|
+
const selectTag = context.tagFor(Select);
|
|
160
|
+
const optionTag = context.tagFor(ListboxOption);
|
|
161
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
162
|
+
return html`
|
|
163
|
+
<${tooltipTag} text="Text Block Type" placement="top">
|
|
164
|
+
<${selectTag}
|
|
165
|
+
scale="condensed"
|
|
166
|
+
shape="rounded"
|
|
167
|
+
appearance="ghost"
|
|
168
|
+
slot="anchor"
|
|
67
169
|
trigger="auto"
|
|
68
|
-
id="text-
|
|
69
|
-
aria-label="Text
|
|
170
|
+
id="text-block"
|
|
171
|
+
aria-label="Text Block"
|
|
70
172
|
placement="bottom-end"
|
|
173
|
+
value="${(_, { parent }) => parent.textBlockType}"
|
|
174
|
+
@change="${(_, { parent, event }) => notifyMenuBarChange(
|
|
175
|
+
parent,
|
|
176
|
+
"text-block-selected",
|
|
177
|
+
event.target.value
|
|
178
|
+
)}"
|
|
71
179
|
>
|
|
72
|
-
<${
|
|
73
|
-
<${buttonTag}
|
|
74
|
-
slot="anchor"
|
|
75
|
-
aria-label="Open text size menu"
|
|
76
|
-
size="super-condensed"
|
|
77
|
-
appearance="ghost-light"
|
|
78
|
-
shape="pill"
|
|
79
|
-
icon="text-size-line"
|
|
80
|
-
></${buttonTag}>
|
|
81
|
-
</${tooltipTag}>
|
|
82
|
-
<${menuItemTag}
|
|
180
|
+
<${optionTag}
|
|
83
181
|
text="Title"
|
|
84
182
|
value="title"
|
|
85
183
|
internal-part
|
|
86
184
|
class="title"
|
|
87
185
|
connotation="cta"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<${menuItemTag}
|
|
186
|
+
></${optionTag}>
|
|
187
|
+
<${optionTag}
|
|
91
188
|
text="Subtitle"
|
|
92
189
|
value="subtitle"
|
|
93
190
|
internal-part
|
|
94
191
|
class="subtitle"
|
|
95
192
|
connotation="cta"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<${menuItemTag}
|
|
193
|
+
></${optionTag}>
|
|
194
|
+
<${optionTag}
|
|
99
195
|
text="Body"
|
|
100
196
|
value="body"
|
|
101
197
|
internal-part
|
|
102
198
|
class="body"
|
|
103
199
|
connotation="cta"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
200
|
+
></${optionTag}>
|
|
201
|
+
</${selectTag}>
|
|
202
|
+
</${tooltipTag}>
|
|
107
203
|
`;
|
|
204
|
+
}
|
|
108
205
|
},
|
|
109
|
-
textDecoration:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
206
|
+
textDecoration: {
|
|
207
|
+
registerStateProperty: function(menuBar) {
|
|
208
|
+
menuBar.addEventListener(
|
|
209
|
+
"text-styles-changed",
|
|
210
|
+
textDecorationEventHandler
|
|
211
|
+
);
|
|
212
|
+
},
|
|
213
|
+
render: function(context) {
|
|
214
|
+
const buttonTag = context.tagFor(Button);
|
|
215
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
216
|
+
return html`
|
|
217
|
+
<span id="text-decoration">
|
|
218
|
+
${repeat(
|
|
219
|
+
(_) => TEXT_DECORATION_ITEMS,
|
|
220
|
+
html`
|
|
221
|
+
<${tooltipTag} text="${(x) => x.text}" placement="top">
|
|
222
|
+
<${buttonTag}
|
|
223
|
+
class="selection-button"
|
|
224
|
+
slot="anchor"
|
|
225
|
+
aria-label="${(x) => x.text}"
|
|
226
|
+
size="super-condensed"
|
|
227
|
+
appearance="ghost-light"
|
|
228
|
+
shape="rounded"
|
|
229
|
+
icon="${(x) => x.icon}"
|
|
230
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
231
|
+
c.parentContext.parent,
|
|
232
|
+
"text-decoration-selected",
|
|
233
|
+
x.value
|
|
234
|
+
)}"')}"
|
|
235
|
+
></${buttonTag}>
|
|
236
|
+
</${tooltipTag}>
|
|
133
237
|
`
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
238
|
+
)}
|
|
239
|
+
</span>
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
textSize: {
|
|
244
|
+
registerStateProperty: function(menuBar) {
|
|
245
|
+
menuBar.addEventListener("text-styles-changed", textSizeEventHandler);
|
|
246
|
+
},
|
|
247
|
+
render: function(context) {
|
|
248
|
+
const menuTag = context.tagFor(Menu);
|
|
249
|
+
const buttonTag = context.tagFor(Button);
|
|
250
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
251
|
+
const menuItemTag = context.tagFor(MenuItem);
|
|
252
|
+
return html`
|
|
253
|
+
<${menuTag}
|
|
254
|
+
auto-dismiss
|
|
255
|
+
trigger="auto"
|
|
256
|
+
id="text-size"
|
|
257
|
+
aria-label="Text Size"
|
|
258
|
+
placement="bottom-end"
|
|
259
|
+
>
|
|
260
|
+
<${tooltipTag} slot="anchor" text="Text Size" placement="top">
|
|
261
|
+
<${buttonTag}
|
|
262
|
+
slot="anchor"
|
|
263
|
+
aria-label="Open text size menu"
|
|
264
|
+
size="super-condensed"
|
|
265
|
+
appearance="ghost-light"
|
|
266
|
+
shape="pill"
|
|
267
|
+
icon="text-size-line"
|
|
268
|
+
></${buttonTag}>
|
|
269
|
+
</${tooltipTag}>
|
|
270
|
+
${repeat(
|
|
271
|
+
(_) => TEXT_SIZES,
|
|
272
|
+
html`
|
|
273
|
+
<${menuItemTag}
|
|
274
|
+
check-appearance="tick-only"
|
|
275
|
+
role="menuitemcheckbox"
|
|
276
|
+
text="${(x) => x.text}"
|
|
277
|
+
value="${(x) => x.value}"
|
|
278
|
+
internal-part
|
|
279
|
+
class="menubar-selector-menuitem"
|
|
280
|
+
connotation="cta"
|
|
281
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
282
|
+
c.parentContext.parent,
|
|
283
|
+
"text-size-selected",
|
|
284
|
+
x.value
|
|
285
|
+
)}"
|
|
286
|
+
></${menuItemTag}>
|
|
287
|
+
`
|
|
288
|
+
)}
|
|
289
|
+
</${menuTag}>
|
|
290
|
+
`;
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
divider: {
|
|
294
|
+
render: function(context) {
|
|
295
|
+
const dividerTag = context.tagFor(Divider);
|
|
296
|
+
return html`
|
|
297
|
+
<${dividerTag} class="divider" orientation="vertical"></${dividerTag}>
|
|
298
|
+
`;
|
|
299
|
+
}
|
|
137
300
|
}
|
|
138
301
|
};
|
|
302
|
+
|
|
139
303
|
const getClasses$1 = (menuBar) => classNames("control", [
|
|
140
304
|
"hide-menubar",
|
|
141
305
|
getValidMenuItems(menuBar).length === 0
|
|
142
306
|
]);
|
|
143
|
-
const validItems = ["
|
|
307
|
+
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
308
|
+
function getPropertyStateRgistrationFunction(item) {
|
|
309
|
+
return MENU_BAR_ITEMS[item].registerStateProperty;
|
|
310
|
+
}
|
|
144
311
|
function createMenuItem(item) {
|
|
145
|
-
return MENU_BAR_ITEMS[item];
|
|
312
|
+
return MENU_BAR_ITEMS[item].render;
|
|
146
313
|
}
|
|
147
314
|
function getValidMenuItems({ menuItems }) {
|
|
148
315
|
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
@@ -150,7 +317,10 @@ function getValidMenuItems({ menuItems }) {
|
|
|
150
317
|
function renderMenuItems(context) {
|
|
151
318
|
return () => html`${repeat(
|
|
152
319
|
getValidMenuItems,
|
|
153
|
-
html`${(menuItemName) =>
|
|
320
|
+
html`${(menuItemName, { parent }) => {
|
|
321
|
+
getPropertyStateRgistrationFunction(menuItemName)?.(parent);
|
|
322
|
+
return createMenuItem(menuItemName)(context);
|
|
323
|
+
}}`
|
|
154
324
|
)}`;
|
|
155
325
|
}
|
|
156
326
|
const MenuBarTemplate = (context) => {
|
|
@@ -165,10 +335,12 @@ const menuBarDefinition = defineVividComponent(
|
|
|
165
335
|
MenuBarTemplate,
|
|
166
336
|
[
|
|
167
337
|
buttonDefinition,
|
|
168
|
-
|
|
169
|
-
|
|
338
|
+
selectDefinition,
|
|
339
|
+
listboxOptionDefinition,
|
|
170
340
|
dividerDefinition,
|
|
171
|
-
tooltipDefinition
|
|
341
|
+
tooltipDefinition,
|
|
342
|
+
menuDefinition,
|
|
343
|
+
menuItemDefinition
|
|
172
344
|
],
|
|
173
345
|
{
|
|
174
346
|
styles,
|
|
@@ -6825,6 +6997,27 @@ function createKey(name) {
|
|
|
6825
6997
|
keys[name] = 0;
|
|
6826
6998
|
return name + "$";
|
|
6827
6999
|
}
|
|
7000
|
+
/**
|
|
7001
|
+
A key is used to [tag](https://prosemirror.net/docs/ref/#state.PluginSpec.key) plugins in a way
|
|
7002
|
+
that makes it possible to find them, given an editor state.
|
|
7003
|
+
Assigning a key does mean only one plugin of that type can be
|
|
7004
|
+
active in a state.
|
|
7005
|
+
*/
|
|
7006
|
+
class PluginKey {
|
|
7007
|
+
/**
|
|
7008
|
+
Create a plugin key.
|
|
7009
|
+
*/
|
|
7010
|
+
constructor(name = "key") { this.key = createKey(name); }
|
|
7011
|
+
/**
|
|
7012
|
+
Get the active plugin with this key, if any, from an editor
|
|
7013
|
+
state.
|
|
7014
|
+
*/
|
|
7015
|
+
get(state) { return state.config.pluginsByKey[this.key]; }
|
|
7016
|
+
/**
|
|
7017
|
+
Get the plugin's state from an editor state.
|
|
7018
|
+
*/
|
|
7019
|
+
getState(state) { return state[this.key]; }
|
|
7020
|
+
}
|
|
6828
7021
|
|
|
6829
7022
|
const domIndex = function (node) {
|
|
6830
7023
|
for (var index = 0;; index++) {
|
|
@@ -13606,6 +13799,15 @@ To reuse elements from this schema, extend or read from its
|
|
|
13606
13799
|
*/
|
|
13607
13800
|
const schema = new Schema({ nodes, marks });
|
|
13608
13801
|
|
|
13802
|
+
const TEXT_SIZES_CSS_VARIABLES = {
|
|
13803
|
+
"extra-large": "var(--vvd-typography-heading-4)",
|
|
13804
|
+
large: "var(--vvd-typography-base-extended)",
|
|
13805
|
+
normal: "var(--vvd-typography-base)",
|
|
13806
|
+
small: "var(--vvd-typography-base-condensed)"
|
|
13807
|
+
};
|
|
13808
|
+
const CSS_VARIABLES_TO_SIZES = Object.fromEntries(
|
|
13809
|
+
Object.entries(TEXT_SIZES_CSS_VARIABLES).map(([key, value]) => [value, key])
|
|
13810
|
+
);
|
|
13609
13811
|
const customMarks = {
|
|
13610
13812
|
u: {
|
|
13611
13813
|
parseDOM: [{ tag: "u" }],
|
|
@@ -13624,6 +13826,26 @@ const customMarks = {
|
|
|
13624
13826
|
toDOM() {
|
|
13625
13827
|
return ["tt", 0];
|
|
13626
13828
|
}
|
|
13829
|
+
},
|
|
13830
|
+
textSize: {
|
|
13831
|
+
attrs: { size: { default: "normal" } },
|
|
13832
|
+
parseDOM: [
|
|
13833
|
+
{
|
|
13834
|
+
tag: "span[style*='font']",
|
|
13835
|
+
getAttrs: (node) => {
|
|
13836
|
+
const style = node.getAttribute("style");
|
|
13837
|
+
const fontSize = style.match(/font:\s*([^;]+)/)?.[1]?.trim();
|
|
13838
|
+
const size = CSS_VARIABLES_TO_SIZES[fontSize];
|
|
13839
|
+
if (size) return { size };
|
|
13840
|
+
return false;
|
|
13841
|
+
}
|
|
13842
|
+
}
|
|
13843
|
+
],
|
|
13844
|
+
toDOM(mark) {
|
|
13845
|
+
const size = mark.attrs.size;
|
|
13846
|
+
const fontSize = TEXT_SIZES_CSS_VARIABLES[size] || TEXT_SIZES_CSS_VARIABLES.normal;
|
|
13847
|
+
return ["span", { style: `font: ${fontSize};` }, 0];
|
|
13848
|
+
}
|
|
13627
13849
|
}
|
|
13628
13850
|
};
|
|
13629
13851
|
const extendedSchema = new Schema({
|
|
@@ -13658,6 +13880,13 @@ class TagToSchemaMap {
|
|
|
13658
13880
|
};
|
|
13659
13881
|
}
|
|
13660
13882
|
}
|
|
13883
|
+
function setTextBlockType(styles, type) {
|
|
13884
|
+
if (styles.textBlockType && styles.textBlockType !== type || styles.textBlockType === "") {
|
|
13885
|
+
styles.textBlockType = "";
|
|
13886
|
+
} else {
|
|
13887
|
+
styles.textBlockType = type;
|
|
13888
|
+
}
|
|
13889
|
+
}
|
|
13661
13890
|
function createSelectionChangePlugin(onSelectionChange) {
|
|
13662
13891
|
return new Plugin({
|
|
13663
13892
|
view: () => ({
|
|
@@ -13680,6 +13909,30 @@ function convertSelectionToVividFormat({
|
|
|
13680
13909
|
end: to
|
|
13681
13910
|
};
|
|
13682
13911
|
}
|
|
13912
|
+
const isEmptyParagraph = (node) => {
|
|
13913
|
+
return node.type.name === "paragraph" && node.nodeSize === 2;
|
|
13914
|
+
};
|
|
13915
|
+
const DEFAULT_TEXT_EDITOR_PLACEHOLDER = "Start typing...";
|
|
13916
|
+
const placeholderPluginKey = new PluginKey("placeholderPlugin");
|
|
13917
|
+
const createPlaceholderPlugin = (placeholder = DEFAULT_TEXT_EDITOR_PLACEHOLDER) => {
|
|
13918
|
+
return new Plugin({
|
|
13919
|
+
key: placeholderPluginKey,
|
|
13920
|
+
props: {
|
|
13921
|
+
decorations(state) {
|
|
13922
|
+
const { $from } = state.selection;
|
|
13923
|
+
const decorations = [];
|
|
13924
|
+
if (state.doc.childCount === 1 && isEmptyParagraph($from.parent)) {
|
|
13925
|
+
const decoration = Decoration.node($from.before(), $from.after(), {
|
|
13926
|
+
"data-placeholder": placeholder,
|
|
13927
|
+
class: "placeholder"
|
|
13928
|
+
});
|
|
13929
|
+
decorations.push(decoration);
|
|
13930
|
+
}
|
|
13931
|
+
return DecorationSet.create(state.doc, decorations);
|
|
13932
|
+
}
|
|
13933
|
+
}
|
|
13934
|
+
});
|
|
13935
|
+
};
|
|
13683
13936
|
class ProseMirrorFacade {
|
|
13684
13937
|
#userContentChange = false;
|
|
13685
13938
|
#view;
|
|
@@ -13700,6 +13953,7 @@ class ProseMirrorFacade {
|
|
|
13700
13953
|
};
|
|
13701
13954
|
#handleChangeEvent = () => {
|
|
13702
13955
|
if (!this.#userContentChange) {
|
|
13956
|
+
this.#userContentChange = false;
|
|
13703
13957
|
return;
|
|
13704
13958
|
}
|
|
13705
13959
|
this.#dispatchEvent("change");
|
|
@@ -13711,6 +13965,7 @@ class ProseMirrorFacade {
|
|
|
13711
13965
|
);
|
|
13712
13966
|
}
|
|
13713
13967
|
const plugins = [
|
|
13968
|
+
createPlaceholderPlugin(),
|
|
13714
13969
|
createSelectionChangePlugin(this.#onSelectionChange),
|
|
13715
13970
|
keymap(baseKeymap)
|
|
13716
13971
|
];
|
|
@@ -13722,6 +13977,18 @@ class ProseMirrorFacade {
|
|
|
13722
13977
|
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
13723
13978
|
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
13724
13979
|
}
|
|
13980
|
+
updatePlaceholder(placeholderText) {
|
|
13981
|
+
this.#verifyViewInitiation();
|
|
13982
|
+
const { state } = this.#view;
|
|
13983
|
+
const plugins = state.plugins.filter(
|
|
13984
|
+
(plugin) => plugin !== placeholderPluginKey.get(state)
|
|
13985
|
+
);
|
|
13986
|
+
const newPlaceholderPlugin = createPlaceholderPlugin(placeholderText);
|
|
13987
|
+
const newState = state.reconfigure({
|
|
13988
|
+
plugins: [...plugins, newPlaceholderPlugin]
|
|
13989
|
+
});
|
|
13990
|
+
this.#view.updateState(newState);
|
|
13991
|
+
}
|
|
13725
13992
|
replaceContent(content) {
|
|
13726
13993
|
this.#verifyViewInitiation();
|
|
13727
13994
|
const parser = DOMParser.fromSchema(extendedSchema);
|
|
@@ -13772,6 +14039,7 @@ class ProseMirrorFacade {
|
|
|
13772
14039
|
dispatch(tr);
|
|
13773
14040
|
}
|
|
13774
14041
|
setSelectionDecoration(decoration) {
|
|
14042
|
+
this.#verifyViewInitiation();
|
|
13775
14043
|
const SUPPORTED_DECORATIONS = {
|
|
13776
14044
|
bold: "strong",
|
|
13777
14045
|
italics: "em",
|
|
@@ -13779,7 +14047,6 @@ class ProseMirrorFacade {
|
|
|
13779
14047
|
strikethrough: "s",
|
|
13780
14048
|
monospace: "tt"
|
|
13781
14049
|
};
|
|
13782
|
-
this.#verifyViewInitiation();
|
|
13783
14050
|
const { state, dispatch } = this.#view;
|
|
13784
14051
|
const decorationKey = decoration;
|
|
13785
14052
|
const markType = state.schema.marks[SUPPORTED_DECORATIONS[decorationKey]];
|
|
@@ -13787,6 +14054,121 @@ class ProseMirrorFacade {
|
|
|
13787
14054
|
throw new Error(`${decoration} is not a supported decoration`);
|
|
13788
14055
|
}
|
|
13789
14056
|
toggleMark(markType)(state, dispatch);
|
|
14057
|
+
this.#userContentChange = true;
|
|
14058
|
+
this.#handleChangeEvent();
|
|
14059
|
+
}
|
|
14060
|
+
#getSelectionBlockType() {
|
|
14061
|
+
const { state } = this.#view;
|
|
14062
|
+
const { from, to } = state.selection;
|
|
14063
|
+
const styles = {};
|
|
14064
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14065
|
+
if (node.type.name === "heading" && node.attrs.level === 2) {
|
|
14066
|
+
setTextBlockType(styles, "title");
|
|
14067
|
+
} else if (node.type.name === "heading" && node.attrs.level === 3) {
|
|
14068
|
+
setTextBlockType(styles, "subtitle");
|
|
14069
|
+
} else if (node.type.name === "paragraph") {
|
|
14070
|
+
setTextBlockType(styles, "body");
|
|
14071
|
+
}
|
|
14072
|
+
});
|
|
14073
|
+
return styles.textBlockType;
|
|
14074
|
+
}
|
|
14075
|
+
#getSelectionTextDecoration() {
|
|
14076
|
+
const { state } = this.#view;
|
|
14077
|
+
const { from, to, empty } = state.selection;
|
|
14078
|
+
const decorations = [];
|
|
14079
|
+
if (empty) {
|
|
14080
|
+
const marks = state.doc.resolve(from).marks();
|
|
14081
|
+
if (state.schema.marks.strong && marks.some((mark) => mark.type === state.schema.marks.strong)) {
|
|
14082
|
+
decorations.push("bold");
|
|
14083
|
+
}
|
|
14084
|
+
if (state.schema.marks.em && marks.some((mark) => mark.type === state.schema.marks.em)) {
|
|
14085
|
+
decorations.push("italics");
|
|
14086
|
+
}
|
|
14087
|
+
if (state.schema.marks.u && marks.some((mark) => mark.type === state.schema.marks.u)) {
|
|
14088
|
+
decorations.push("underline");
|
|
14089
|
+
}
|
|
14090
|
+
if (state.schema.marks.s && marks.some((mark) => mark.type === state.schema.marks.s)) {
|
|
14091
|
+
decorations.push("strikethrough");
|
|
14092
|
+
}
|
|
14093
|
+
if (state.schema.marks.tt && marks.some((mark) => mark.type === state.schema.marks.tt)) {
|
|
14094
|
+
decorations.push("monospace");
|
|
14095
|
+
}
|
|
14096
|
+
} else {
|
|
14097
|
+
if (state.schema.marks.strong && state.doc.rangeHasMark(from, to, state.schema.marks.strong)) {
|
|
14098
|
+
decorations.push("bold");
|
|
14099
|
+
}
|
|
14100
|
+
if (state.schema.marks.em && state.doc.rangeHasMark(from, to, state.schema.marks.em)) {
|
|
14101
|
+
decorations.push("italics");
|
|
14102
|
+
}
|
|
14103
|
+
if (state.schema.marks.u && state.doc.rangeHasMark(from, to, state.schema.marks.u)) {
|
|
14104
|
+
decorations.push("underline");
|
|
14105
|
+
}
|
|
14106
|
+
if (state.schema.marks.s && state.doc.rangeHasMark(from, to, state.schema.marks.s)) {
|
|
14107
|
+
decorations.push("strikethrough");
|
|
14108
|
+
}
|
|
14109
|
+
if (state.schema.marks.tt && state.doc.rangeHasMark(from, to, state.schema.marks.tt)) {
|
|
14110
|
+
decorations.push("monospace");
|
|
14111
|
+
}
|
|
14112
|
+
}
|
|
14113
|
+
return decorations.length ? decorations : void 0;
|
|
14114
|
+
}
|
|
14115
|
+
#getSelectionTextSize() {
|
|
14116
|
+
const { state } = this.#view;
|
|
14117
|
+
const { from, to, empty } = state.selection;
|
|
14118
|
+
const defaultSize = "normal";
|
|
14119
|
+
if (empty) {
|
|
14120
|
+
const marks = state.doc.resolve(from).marks();
|
|
14121
|
+
const textSizeMark = marks.find(
|
|
14122
|
+
(mark) => mark.type === state.schema.marks.textSize
|
|
14123
|
+
);
|
|
14124
|
+
return textSizeMark ? textSizeMark.attrs.size : defaultSize;
|
|
14125
|
+
} else {
|
|
14126
|
+
let textSize = null;
|
|
14127
|
+
let foundMixedSizes = false;
|
|
14128
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14129
|
+
if (node.isText) {
|
|
14130
|
+
const mark = node.marks.find(
|
|
14131
|
+
(mark2) => mark2.type === state.schema.marks.textSize
|
|
14132
|
+
);
|
|
14133
|
+
if (mark) {
|
|
14134
|
+
if (textSize === null) {
|
|
14135
|
+
textSize = mark.attrs.size;
|
|
14136
|
+
} else if (textSize !== mark.attrs.size) {
|
|
14137
|
+
foundMixedSizes = true;
|
|
14138
|
+
return false;
|
|
14139
|
+
}
|
|
14140
|
+
} else if (textSize !== null) {
|
|
14141
|
+
foundMixedSizes = true;
|
|
14142
|
+
return false;
|
|
14143
|
+
}
|
|
14144
|
+
}
|
|
14145
|
+
return true;
|
|
14146
|
+
});
|
|
14147
|
+
if (foundMixedSizes) {
|
|
14148
|
+
return "";
|
|
14149
|
+
}
|
|
14150
|
+
return textSize !== null ? textSize : defaultSize;
|
|
14151
|
+
}
|
|
14152
|
+
}
|
|
14153
|
+
getSelectionStyles() {
|
|
14154
|
+
this.#verifyViewInitiation();
|
|
14155
|
+
const styles = {};
|
|
14156
|
+
styles.textBlockType = this.#getSelectionBlockType();
|
|
14157
|
+
styles.textDecoration = this.#getSelectionTextDecoration();
|
|
14158
|
+
styles.textSize = this.#getSelectionTextSize();
|
|
14159
|
+
return styles;
|
|
14160
|
+
}
|
|
14161
|
+
setTextSize(size = "normal") {
|
|
14162
|
+
this.#verifyViewInitiation();
|
|
14163
|
+
const { state, dispatch } = this.#view;
|
|
14164
|
+
const { schema, selection, tr } = state;
|
|
14165
|
+
const { from, to } = selection;
|
|
14166
|
+
const textSizeMark = schema.marks.textSize;
|
|
14167
|
+
tr.removeMark(from, to, textSizeMark);
|
|
14168
|
+
tr.addMark(from, to, textSizeMark.create({ size }));
|
|
14169
|
+
dispatch(tr.scrollIntoView());
|
|
14170
|
+
this.#userContentChange = true;
|
|
14171
|
+
this.#handleChangeEvent();
|
|
13790
14172
|
}
|
|
13791
14173
|
}
|
|
13792
14174
|
|
|
@@ -13799,7 +14181,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
13799
14181
|
if (result) __defProp(target, key, result);
|
|
13800
14182
|
return result;
|
|
13801
14183
|
};
|
|
13802
|
-
const
|
|
14184
|
+
const RichTextEditorTextBlocks = {
|
|
13803
14185
|
title: "h2",
|
|
13804
14186
|
subtitle: "h3",
|
|
13805
14187
|
body: "p"
|
|
@@ -13819,13 +14201,11 @@ class RichTextEditor extends VividElement {
|
|
|
13819
14201
|
}
|
|
13820
14202
|
};
|
|
13821
14203
|
this.selectionEnd = null;
|
|
13822
|
-
this.#selectionChangedByUser = false;
|
|
13823
14204
|
this.#handleSelectionChange = () => {
|
|
13824
14205
|
if (!this.#editor.selection()) {
|
|
13825
14206
|
return;
|
|
13826
14207
|
}
|
|
13827
14208
|
const { start, end } = this.#editor.selection();
|
|
13828
|
-
this.#selectionChangedByUser = true;
|
|
13829
14209
|
this.selectionStart = start;
|
|
13830
14210
|
this.selectionEnd = end;
|
|
13831
14211
|
this.$emit("selection-changed");
|
|
@@ -13857,9 +14237,6 @@ class RichTextEditor extends VividElement {
|
|
|
13857
14237
|
return this.shadowRoot.querySelector("#editor");
|
|
13858
14238
|
}
|
|
13859
14239
|
selectionStartChanged() {
|
|
13860
|
-
if (this.#selectionChangedByUser) {
|
|
13861
|
-
return;
|
|
13862
|
-
}
|
|
13863
14240
|
if (!this.selectionStart || this.selectionEnd && this.selectionStart > this.selectionEnd) {
|
|
13864
14241
|
return;
|
|
13865
14242
|
}
|
|
@@ -13867,16 +14244,14 @@ class RichTextEditor extends VividElement {
|
|
|
13867
14244
|
}
|
|
13868
14245
|
#updateEditorSelection;
|
|
13869
14246
|
selectionEndChanged() {
|
|
13870
|
-
if (this.#selectionChangedByUser) {
|
|
13871
|
-
this.#selectionChangedByUser = false;
|
|
13872
|
-
return;
|
|
13873
|
-
}
|
|
13874
14247
|
if (this.selectionEnd && !this.selectionStart) {
|
|
13875
14248
|
this.selectionStart = 1;
|
|
13876
14249
|
}
|
|
13877
14250
|
this.#updateEditorSelection();
|
|
13878
14251
|
}
|
|
13879
|
-
|
|
14252
|
+
placeholderChanged() {
|
|
14253
|
+
this.#editor?.updatePlaceholder(this.placeholder);
|
|
14254
|
+
}
|
|
13880
14255
|
#handleSelectionChange;
|
|
13881
14256
|
#handleChange;
|
|
13882
14257
|
#handleInput;
|
|
@@ -13892,12 +14267,13 @@ class RichTextEditor extends VividElement {
|
|
|
13892
14267
|
this.#editor.addEventListener("change", this.#handleChange);
|
|
13893
14268
|
this.#editor.addEventListener("input", this.#handleInput);
|
|
13894
14269
|
}
|
|
14270
|
+
this.placeholderChanged();
|
|
13895
14271
|
}
|
|
13896
|
-
|
|
14272
|
+
setTextBlock(blockType) {
|
|
13897
14273
|
try {
|
|
13898
|
-
this.#editor?.setSelectionTag(
|
|
14274
|
+
this.#editor?.setSelectionTag(RichTextEditorTextBlocks[blockType]);
|
|
13899
14275
|
} catch (e) {
|
|
13900
|
-
console.warn(`Invalid text
|
|
14276
|
+
console.warn(`Invalid text block: ${blockType}`);
|
|
13901
14277
|
}
|
|
13902
14278
|
}
|
|
13903
14279
|
setSelectionDecoration(decoration) {
|
|
@@ -13907,6 +14283,23 @@ class RichTextEditor extends VividElement {
|
|
|
13907
14283
|
console.warn(`Invalid decoration: ${decoration}`);
|
|
13908
14284
|
}
|
|
13909
14285
|
}
|
|
14286
|
+
setSelectionTextSize(textSize) {
|
|
14287
|
+
this.#editor?.setTextSize(textSize);
|
|
14288
|
+
}
|
|
14289
|
+
get selectionStyles() {
|
|
14290
|
+
if (!this.#editor) {
|
|
14291
|
+
return {};
|
|
14292
|
+
}
|
|
14293
|
+
return this.#editor.getSelectionStyles();
|
|
14294
|
+
}
|
|
14295
|
+
focus() {
|
|
14296
|
+
super.focus();
|
|
14297
|
+
setTimeout(() => {
|
|
14298
|
+
this.#editorWrapperElement.querySelector(
|
|
14299
|
+
'[contenteditable="true"]'
|
|
14300
|
+
).focus();
|
|
14301
|
+
}, 0);
|
|
14302
|
+
}
|
|
13910
14303
|
}
|
|
13911
14304
|
__decorateClass([
|
|
13912
14305
|
attr({ converter: nullableNumberConverter, attribute: "selection-start" })
|
|
@@ -13914,16 +14307,32 @@ __decorateClass([
|
|
|
13914
14307
|
__decorateClass([
|
|
13915
14308
|
attr({ converter: nullableNumberConverter, attribute: "selection-end" })
|
|
13916
14309
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14310
|
+
__decorateClass([
|
|
14311
|
+
attr
|
|
14312
|
+
], RichTextEditor.prototype, "placeholder");
|
|
13917
14313
|
|
|
13918
14314
|
const getClasses = (_) => classNames("control");
|
|
13919
14315
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
13920
|
-
|
|
13921
|
-
|
|
14316
|
+
const menuParent = (target) => target.parentElement;
|
|
14317
|
+
function textBlockSelectedHandler(event) {
|
|
14318
|
+
menuParent(event.target).setTextBlock(
|
|
14319
|
+
event.detail
|
|
14320
|
+
);
|
|
14321
|
+
menuParent(event.target).focus();
|
|
13922
14322
|
}
|
|
13923
14323
|
function selectionDecorationSelectedHandler(event) {
|
|
13924
|
-
|
|
14324
|
+
menuParent(event.target).setSelectionDecoration(
|
|
14325
|
+
event.detail
|
|
14326
|
+
);
|
|
14327
|
+
menuParent(event.target).focus();
|
|
14328
|
+
}
|
|
14329
|
+
function textSizeSelectedHandler(event) {
|
|
14330
|
+
menuParent(event.target).setSelectionTextSize(
|
|
14331
|
+
event.detail
|
|
14332
|
+
);
|
|
14333
|
+
menuParent(event.target).focus();
|
|
13925
14334
|
}
|
|
13926
|
-
function handleMenuBarSlotChange(
|
|
14335
|
+
function handleMenuBarSlotChange(_, { event }) {
|
|
13927
14336
|
const slot = event.target;
|
|
13928
14337
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
13929
14338
|
const menuBar = assignedElements.find(
|
|
@@ -13938,12 +14347,16 @@ function handleMenuBarSlotChange(richTextEditor, { event }) {
|
|
|
13938
14347
|
});
|
|
13939
14348
|
if (menuBar) {
|
|
13940
14349
|
menuBar.addEventListener(
|
|
13941
|
-
"text-
|
|
13942
|
-
|
|
14350
|
+
"text-block-selected",
|
|
14351
|
+
textBlockSelectedHandler
|
|
13943
14352
|
);
|
|
13944
14353
|
menuBar.addEventListener(
|
|
13945
14354
|
"text-decoration-selected",
|
|
13946
|
-
selectionDecorationSelectedHandler
|
|
14355
|
+
selectionDecorationSelectedHandler
|
|
14356
|
+
);
|
|
14357
|
+
menuBar.addEventListener(
|
|
14358
|
+
"text-size-selected",
|
|
14359
|
+
textSizeSelectedHandler
|
|
13947
14360
|
);
|
|
13948
14361
|
}
|
|
13949
14362
|
}
|