@vonage/vivid 4.22.0 → 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 +1987 -631
- 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 +11 -5
- 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-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/fab/fab.d.ts +11 -5
- package/lib/file-picker/file-picker.d.ts +339 -3
- 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 +339 -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 +10 -0
- package/lib/searchable-select/option-tag.d.ts +11 -5
- 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/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 +11 -5
- 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 +8 -7
- package/shared/definition15.js +10 -9
- package/shared/definition16.js +1 -1
- package/shared/definition17.js +1 -1
- package/shared/definition18.js +1 -1
- package/shared/definition19.js +1 -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 +7 -2
- package/shared/definition26.js +8 -3
- package/shared/definition27.cjs +3 -2
- package/shared/definition27.js +4 -3
- package/shared/definition28.js +1 -1
- package/shared/definition29.js +1 -1
- package/shared/definition3.cjs +3 -2
- package/shared/definition3.js +5 -4
- package/shared/definition30.cjs +33 -34
- package/shared/definition30.js +35 -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 +2 -13
- package/shared/definition35.js +4 -15
- 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.js +1 -1
- package/shared/definition40.cjs +8 -5
- package/shared/definition40.js +9 -6
- package/shared/definition41.js +1 -1
- package/shared/definition42.js +1 -1
- package/shared/definition43.cjs +465 -105
- package/shared/definition43.js +457 -97
- package/shared/definition44.cjs +9 -6
- package/shared/definition44.js +10 -7
- package/shared/definition45.cjs +13 -7
- package/shared/definition45.js +14 -8
- 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 +7 -6
- package/shared/definition50.js +9 -8
- 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.js +1 -1
- 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 +68 -14
- package/shared/definition56.js +69 -15
- 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/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 +4 -1
- package/shared/option.js +4 -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/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/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 +155 -14
- package/shared/Reflector.cjs +0 -71
- package/shared/Reflector.js +0 -69
package/shared/definition43.js
CHANGED
|
@@ -1,16 +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
3
|
import { D as Divider, d as dividerDefinition } from './definition23.js';
|
|
4
4
|
import { T as Tooltip, t as tooltipDefinition } from './definition60.js';
|
|
5
5
|
import { S as Select, s as selectDefinition } from './definition45.js';
|
|
6
6
|
import { L as ListboxOption } from './option.js';
|
|
7
|
-
import { c as
|
|
7
|
+
import { e as Menu, M as MenuItem, c as menuDefinition, m as menuItemDefinition } from './definition30.js';
|
|
8
8
|
import { r as repeat } from './repeat.js';
|
|
9
|
+
import { c as classNames } from './class-names.js';
|
|
9
10
|
import { l as listboxOptionDefinition } from './definition36.js';
|
|
10
11
|
|
|
11
|
-
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)}";
|
|
12
13
|
|
|
13
|
-
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}";
|
|
14
15
|
|
|
15
16
|
var __defProp$1 = Object.defineProperty;
|
|
16
17
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
@@ -22,6 +23,38 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
22
23
|
return result;
|
|
23
24
|
};
|
|
24
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
|
+
}
|
|
25
58
|
}
|
|
26
59
|
__decorateClass$1([
|
|
27
60
|
attr({ attribute: "menu-items" })
|
|
@@ -58,76 +91,91 @@ const TEXT_DECORATION_ITEMS = [
|
|
|
58
91
|
value: "monospace"
|
|
59
92
|
}
|
|
60
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
|
+
};
|
|
61
153
|
const MENU_BAR_ITEMS = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
aria-label="Text Block"
|
|
72
|
-
placement="bottom-end"
|
|
73
|
-
>
|
|
74
|
-
<${tooltipTag} slot="anchor" text="Text Block Type" placement="top">
|
|
75
|
-
<${buttonTag}
|
|
76
|
-
slot="anchor"
|
|
77
|
-
aria-label="Open text block menu"
|
|
78
|
-
size="super-condensed"
|
|
79
|
-
appearance="ghost-light"
|
|
80
|
-
shape="pill"
|
|
81
|
-
icon="text-size-line"
|
|
82
|
-
></${buttonTag}>
|
|
83
|
-
</${tooltipTag}>
|
|
84
|
-
<${menuItemTag}
|
|
85
|
-
text="Title"
|
|
86
|
-
value="title"
|
|
87
|
-
internal-part
|
|
88
|
-
class="title"
|
|
89
|
-
connotation="cta"
|
|
90
|
-
@click="${(_, { parent }) =>
|
|
91
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'title')}"
|
|
92
|
-
></${menuItemTag}>
|
|
93
|
-
<${menuItemTag}
|
|
94
|
-
text="Subtitle"
|
|
95
|
-
value="subtitle"
|
|
96
|
-
internal-part
|
|
97
|
-
class="subtitle"
|
|
98
|
-
connotation="cta"
|
|
99
|
-
@click="${(_, { parent }) =>
|
|
100
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'subtitle')}"
|
|
101
|
-
></${menuItemTag}>
|
|
102
|
-
<${menuItemTag}
|
|
103
|
-
text="Body"
|
|
104
|
-
value="body"
|
|
105
|
-
internal-part
|
|
106
|
-
class="body"
|
|
107
|
-
connotation="cta"
|
|
108
|
-
@click="${(_, { parent }) =>
|
|
109
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'body')}"
|
|
110
|
-
></${menuItemTag}>
|
|
111
|
-
</${menuTag}>
|
|
112
|
-
`;
|
|
113
|
-
},*/
|
|
114
|
-
textBlock: function(context) {
|
|
115
|
-
const selectTag = context.tagFor(Select);
|
|
116
|
-
const optionTag = context.tagFor(ListboxOption);
|
|
117
|
-
const tooltipTag = context.tagFor(Tooltip);
|
|
118
|
-
return html`
|
|
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`
|
|
119
163
|
<${tooltipTag} text="Text Block Type" placement="top">
|
|
120
164
|
<${selectTag}
|
|
165
|
+
scale="condensed"
|
|
166
|
+
shape="rounded"
|
|
167
|
+
appearance="ghost"
|
|
121
168
|
slot="anchor"
|
|
122
169
|
trigger="auto"
|
|
123
170
|
id="text-block"
|
|
124
171
|
aria-label="Text Block"
|
|
125
172
|
placement="bottom-end"
|
|
173
|
+
value="${(_, { parent }) => parent.textBlockType}"
|
|
126
174
|
@change="${(_, { parent, event }) => notifyMenuBarChange(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
175
|
+
parent,
|
|
176
|
+
"text-block-selected",
|
|
177
|
+
event.target.value
|
|
178
|
+
)}"
|
|
131
179
|
>
|
|
132
180
|
<${optionTag}
|
|
133
181
|
text="Title"
|
|
@@ -153,44 +201,115 @@ const MENU_BAR_ITEMS = {
|
|
|
153
201
|
</${selectTag}>
|
|
154
202
|
</${tooltipTag}>
|
|
155
203
|
`;
|
|
204
|
+
}
|
|
156
205
|
},
|
|
157
|
-
textDecoration:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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}>
|
|
181
237
|
`
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
+
}
|
|
185
300
|
}
|
|
186
301
|
};
|
|
302
|
+
|
|
187
303
|
const getClasses$1 = (menuBar) => classNames("control", [
|
|
188
304
|
"hide-menubar",
|
|
189
305
|
getValidMenuItems(menuBar).length === 0
|
|
190
306
|
]);
|
|
191
|
-
const validItems = ["textBlock", "textDecoration"];
|
|
307
|
+
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
308
|
+
function getPropertyStateRgistrationFunction(item) {
|
|
309
|
+
return MENU_BAR_ITEMS[item].registerStateProperty;
|
|
310
|
+
}
|
|
192
311
|
function createMenuItem(item) {
|
|
193
|
-
return MENU_BAR_ITEMS[item];
|
|
312
|
+
return MENU_BAR_ITEMS[item].render;
|
|
194
313
|
}
|
|
195
314
|
function getValidMenuItems({ menuItems }) {
|
|
196
315
|
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
@@ -198,7 +317,10 @@ function getValidMenuItems({ menuItems }) {
|
|
|
198
317
|
function renderMenuItems(context) {
|
|
199
318
|
return () => html`${repeat(
|
|
200
319
|
getValidMenuItems,
|
|
201
|
-
html`${(menuItemName) =>
|
|
320
|
+
html`${(menuItemName, { parent }) => {
|
|
321
|
+
getPropertyStateRgistrationFunction(menuItemName)?.(parent);
|
|
322
|
+
return createMenuItem(menuItemName)(context);
|
|
323
|
+
}}`
|
|
202
324
|
)}`;
|
|
203
325
|
}
|
|
204
326
|
const MenuBarTemplate = (context) => {
|
|
@@ -216,7 +338,9 @@ const menuBarDefinition = defineVividComponent(
|
|
|
216
338
|
selectDefinition,
|
|
217
339
|
listboxOptionDefinition,
|
|
218
340
|
dividerDefinition,
|
|
219
|
-
tooltipDefinition
|
|
341
|
+
tooltipDefinition,
|
|
342
|
+
menuDefinition,
|
|
343
|
+
menuItemDefinition
|
|
220
344
|
],
|
|
221
345
|
{
|
|
222
346
|
styles,
|
|
@@ -6873,6 +6997,27 @@ function createKey(name) {
|
|
|
6873
6997
|
keys[name] = 0;
|
|
6874
6998
|
return name + "$";
|
|
6875
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
|
+
}
|
|
6876
7021
|
|
|
6877
7022
|
const domIndex = function (node) {
|
|
6878
7023
|
for (var index = 0;; index++) {
|
|
@@ -13654,6 +13799,15 @@ To reuse elements from this schema, extend or read from its
|
|
|
13654
13799
|
*/
|
|
13655
13800
|
const schema = new Schema({ nodes, marks });
|
|
13656
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
|
+
);
|
|
13657
13811
|
const customMarks = {
|
|
13658
13812
|
u: {
|
|
13659
13813
|
parseDOM: [{ tag: "u" }],
|
|
@@ -13672,6 +13826,26 @@ const customMarks = {
|
|
|
13672
13826
|
toDOM() {
|
|
13673
13827
|
return ["tt", 0];
|
|
13674
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
|
+
}
|
|
13675
13849
|
}
|
|
13676
13850
|
};
|
|
13677
13851
|
const extendedSchema = new Schema({
|
|
@@ -13706,6 +13880,13 @@ class TagToSchemaMap {
|
|
|
13706
13880
|
};
|
|
13707
13881
|
}
|
|
13708
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
|
+
}
|
|
13709
13890
|
function createSelectionChangePlugin(onSelectionChange) {
|
|
13710
13891
|
return new Plugin({
|
|
13711
13892
|
view: () => ({
|
|
@@ -13728,6 +13909,30 @@ function convertSelectionToVividFormat({
|
|
|
13728
13909
|
end: to
|
|
13729
13910
|
};
|
|
13730
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
|
+
};
|
|
13731
13936
|
class ProseMirrorFacade {
|
|
13732
13937
|
#userContentChange = false;
|
|
13733
13938
|
#view;
|
|
@@ -13748,6 +13953,7 @@ class ProseMirrorFacade {
|
|
|
13748
13953
|
};
|
|
13749
13954
|
#handleChangeEvent = () => {
|
|
13750
13955
|
if (!this.#userContentChange) {
|
|
13956
|
+
this.#userContentChange = false;
|
|
13751
13957
|
return;
|
|
13752
13958
|
}
|
|
13753
13959
|
this.#dispatchEvent("change");
|
|
@@ -13759,6 +13965,7 @@ class ProseMirrorFacade {
|
|
|
13759
13965
|
);
|
|
13760
13966
|
}
|
|
13761
13967
|
const plugins = [
|
|
13968
|
+
createPlaceholderPlugin(),
|
|
13762
13969
|
createSelectionChangePlugin(this.#onSelectionChange),
|
|
13763
13970
|
keymap(baseKeymap)
|
|
13764
13971
|
];
|
|
@@ -13770,6 +13977,18 @@ class ProseMirrorFacade {
|
|
|
13770
13977
|
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
13771
13978
|
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
13772
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
|
+
}
|
|
13773
13992
|
replaceContent(content) {
|
|
13774
13993
|
this.#verifyViewInitiation();
|
|
13775
13994
|
const parser = DOMParser.fromSchema(extendedSchema);
|
|
@@ -13820,6 +14039,7 @@ class ProseMirrorFacade {
|
|
|
13820
14039
|
dispatch(tr);
|
|
13821
14040
|
}
|
|
13822
14041
|
setSelectionDecoration(decoration) {
|
|
14042
|
+
this.#verifyViewInitiation();
|
|
13823
14043
|
const SUPPORTED_DECORATIONS = {
|
|
13824
14044
|
bold: "strong",
|
|
13825
14045
|
italics: "em",
|
|
@@ -13827,7 +14047,6 @@ class ProseMirrorFacade {
|
|
|
13827
14047
|
strikethrough: "s",
|
|
13828
14048
|
monospace: "tt"
|
|
13829
14049
|
};
|
|
13830
|
-
this.#verifyViewInitiation();
|
|
13831
14050
|
const { state, dispatch } = this.#view;
|
|
13832
14051
|
const decorationKey = decoration;
|
|
13833
14052
|
const markType = state.schema.marks[SUPPORTED_DECORATIONS[decorationKey]];
|
|
@@ -13835,6 +14054,121 @@ class ProseMirrorFacade {
|
|
|
13835
14054
|
throw new Error(`${decoration} is not a supported decoration`);
|
|
13836
14055
|
}
|
|
13837
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();
|
|
13838
14172
|
}
|
|
13839
14173
|
}
|
|
13840
14174
|
|
|
@@ -13915,6 +14249,9 @@ class RichTextEditor extends VividElement {
|
|
|
13915
14249
|
}
|
|
13916
14250
|
this.#updateEditorSelection();
|
|
13917
14251
|
}
|
|
14252
|
+
placeholderChanged() {
|
|
14253
|
+
this.#editor?.updatePlaceholder(this.placeholder);
|
|
14254
|
+
}
|
|
13918
14255
|
#handleSelectionChange;
|
|
13919
14256
|
#handleChange;
|
|
13920
14257
|
#handleInput;
|
|
@@ -13930,6 +14267,7 @@ class RichTextEditor extends VividElement {
|
|
|
13930
14267
|
this.#editor.addEventListener("change", this.#handleChange);
|
|
13931
14268
|
this.#editor.addEventListener("input", this.#handleInput);
|
|
13932
14269
|
}
|
|
14270
|
+
this.placeholderChanged();
|
|
13933
14271
|
}
|
|
13934
14272
|
setTextBlock(blockType) {
|
|
13935
14273
|
try {
|
|
@@ -13945,6 +14283,15 @@ class RichTextEditor extends VividElement {
|
|
|
13945
14283
|
console.warn(`Invalid decoration: ${decoration}`);
|
|
13946
14284
|
}
|
|
13947
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
|
+
}
|
|
13948
14295
|
focus() {
|
|
13949
14296
|
super.focus();
|
|
13950
14297
|
setTimeout(() => {
|
|
@@ -13960,6 +14307,9 @@ __decorateClass([
|
|
|
13960
14307
|
__decorateClass([
|
|
13961
14308
|
attr({ converter: nullableNumberConverter, attribute: "selection-end" })
|
|
13962
14309
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14310
|
+
__decorateClass([
|
|
14311
|
+
attr
|
|
14312
|
+
], RichTextEditor.prototype, "placeholder");
|
|
13963
14313
|
|
|
13964
14314
|
const getClasses = (_) => classNames("control");
|
|
13965
14315
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
@@ -13976,6 +14326,12 @@ function selectionDecorationSelectedHandler(event) {
|
|
|
13976
14326
|
);
|
|
13977
14327
|
menuParent(event.target).focus();
|
|
13978
14328
|
}
|
|
14329
|
+
function textSizeSelectedHandler(event) {
|
|
14330
|
+
menuParent(event.target).setSelectionTextSize(
|
|
14331
|
+
event.detail
|
|
14332
|
+
);
|
|
14333
|
+
menuParent(event.target).focus();
|
|
14334
|
+
}
|
|
13979
14335
|
function handleMenuBarSlotChange(_, { event }) {
|
|
13980
14336
|
const slot = event.target;
|
|
13981
14337
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
@@ -13998,6 +14354,10 @@ function handleMenuBarSlotChange(_, { event }) {
|
|
|
13998
14354
|
"text-decoration-selected",
|
|
13999
14355
|
selectionDecorationSelectedHandler
|
|
14000
14356
|
);
|
|
14357
|
+
menuBar.addEventListener(
|
|
14358
|
+
"text-size-selected",
|
|
14359
|
+
textSizeSelectedHandler
|
|
14360
|
+
);
|
|
14001
14361
|
}
|
|
14002
14362
|
}
|
|
14003
14363
|
const RichTextEditorTemplate = (_) => {
|