@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.cjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vividElement = require('./vivid-element.cjs');
|
|
4
|
-
const definition = require('./definition11.cjs');
|
|
5
|
-
const definition
|
|
6
|
-
const definition$
|
|
7
|
-
const definition$
|
|
4
|
+
const definition$2 = require('./definition11.cjs');
|
|
5
|
+
const definition = require('./definition23.cjs');
|
|
6
|
+
const definition$3 = require('./definition60.cjs');
|
|
7
|
+
const definition$4 = require('./definition45.cjs');
|
|
8
8
|
const option = require('./option.cjs');
|
|
9
|
-
const
|
|
9
|
+
const definition$1 = require('./definition30.cjs');
|
|
10
10
|
const repeat = require('./repeat.cjs');
|
|
11
|
-
const
|
|
11
|
+
const classNames = require('./class-names.cjs');
|
|
12
|
+
const definition$5 = require('./definition36.cjs');
|
|
12
13
|
|
|
13
|
-
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)}";
|
|
14
|
+
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)}";
|
|
14
15
|
|
|
15
|
-
const styles = ":host{display:flex;align-items:center;
|
|
16
|
+
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}";
|
|
16
17
|
|
|
17
18
|
var __defProp$1 = Object.defineProperty;
|
|
18
19
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
@@ -24,6 +25,38 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
24
25
|
return result;
|
|
25
26
|
};
|
|
26
27
|
class MenuBar extends vividElement.VividElement {
|
|
28
|
+
get #textEditorElement() {
|
|
29
|
+
return this.parentElement;
|
|
30
|
+
}
|
|
31
|
+
#updateTextStyleState = () => {
|
|
32
|
+
this.dispatchEvent(
|
|
33
|
+
new CustomEvent("text-styles-changed", {
|
|
34
|
+
detail: this.#textEditorElement?.selectionStyles
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
super.connectedCallback();
|
|
40
|
+
this.#textEditorElement.addEventListener(
|
|
41
|
+
"selection-changed",
|
|
42
|
+
this.#updateTextStyleState
|
|
43
|
+
);
|
|
44
|
+
this.#textEditorElement.addEventListener(
|
|
45
|
+
"change",
|
|
46
|
+
this.#updateTextStyleState
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
super.disconnectedCallback();
|
|
51
|
+
this.#textEditorElement?.removeEventListener(
|
|
52
|
+
"selection-changed",
|
|
53
|
+
this.#updateTextStyleState
|
|
54
|
+
);
|
|
55
|
+
this.#textEditorElement?.removeEventListener(
|
|
56
|
+
"change",
|
|
57
|
+
this.#updateTextStyleState
|
|
58
|
+
);
|
|
59
|
+
}
|
|
27
60
|
}
|
|
28
61
|
__decorateClass$1([
|
|
29
62
|
vividElement.attr({ attribute: "menu-items" })
|
|
@@ -60,76 +93,91 @@ const TEXT_DECORATION_ITEMS = [
|
|
|
60
93
|
value: "monospace"
|
|
61
94
|
}
|
|
62
95
|
];
|
|
96
|
+
const TEXT_SIZES = [
|
|
97
|
+
{
|
|
98
|
+
text: "Extra Large",
|
|
99
|
+
value: "extra-large"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
text: "Large",
|
|
103
|
+
value: "large"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
text: "Normal",
|
|
107
|
+
value: "normal"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
text: "Small",
|
|
111
|
+
value: "small"
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
const textBlockEventHandler = (event) => {
|
|
115
|
+
const customEvent = event;
|
|
116
|
+
if (!customEvent || !customEvent.detail || customEvent.detail.textBlockType === void 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const menu = customEvent.target;
|
|
120
|
+
menu.shadowRoot.querySelector("#text-block").setAttribute("current-value", customEvent.detail.textBlockType);
|
|
121
|
+
};
|
|
122
|
+
const textDecorationEventHandler = (event) => {
|
|
123
|
+
const customEvent = event;
|
|
124
|
+
if (!customEvent || !customEvent.detail) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const menu = customEvent.target;
|
|
128
|
+
const selectionButtons = menu.shadowRoot.querySelectorAll(
|
|
129
|
+
"#text-decoration .selection-button"
|
|
130
|
+
);
|
|
131
|
+
selectionButtons.forEach((button) => button.removeAttribute("active"));
|
|
132
|
+
customEvent.detail.textDecoration !== void 0 && TEXT_DECORATION_ITEMS.forEach((menuItemConfig, index) => {
|
|
133
|
+
if (customEvent.detail.textDecoration.indexOf(menuItemConfig.value) >= 0) {
|
|
134
|
+
selectionButtons[index].toggleAttribute("active", true);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const textSizeEventHandler = (event) => {
|
|
139
|
+
const customEvent = event;
|
|
140
|
+
if (!customEvent || !customEvent.detail) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const menu = customEvent.target;
|
|
144
|
+
const selectionTextSize = customEvent.detail.textSize ?? "normal";
|
|
145
|
+
const textSizeElements = menu.shadowRoot.querySelectorAll(
|
|
146
|
+
".menubar-selector-menuitem"
|
|
147
|
+
);
|
|
148
|
+
textSizeElements.forEach((textSizeElement) => {
|
|
149
|
+
textSizeElement.toggleAttribute(
|
|
150
|
+
"checked",
|
|
151
|
+
textSizeElement.getAttribute("value") === selectionTextSize
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
};
|
|
63
155
|
const MENU_BAR_ITEMS = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
aria-label="Text Block"
|
|
74
|
-
placement="bottom-end"
|
|
75
|
-
>
|
|
76
|
-
<${tooltipTag} slot="anchor" text="Text Block Type" placement="top">
|
|
77
|
-
<${buttonTag}
|
|
78
|
-
slot="anchor"
|
|
79
|
-
aria-label="Open text block menu"
|
|
80
|
-
size="super-condensed"
|
|
81
|
-
appearance="ghost-light"
|
|
82
|
-
shape="pill"
|
|
83
|
-
icon="text-size-line"
|
|
84
|
-
></${buttonTag}>
|
|
85
|
-
</${tooltipTag}>
|
|
86
|
-
<${menuItemTag}
|
|
87
|
-
text="Title"
|
|
88
|
-
value="title"
|
|
89
|
-
internal-part
|
|
90
|
-
class="title"
|
|
91
|
-
connotation="cta"
|
|
92
|
-
@click="${(_, { parent }) =>
|
|
93
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'title')}"
|
|
94
|
-
></${menuItemTag}>
|
|
95
|
-
<${menuItemTag}
|
|
96
|
-
text="Subtitle"
|
|
97
|
-
value="subtitle"
|
|
98
|
-
internal-part
|
|
99
|
-
class="subtitle"
|
|
100
|
-
connotation="cta"
|
|
101
|
-
@click="${(_, { parent }) =>
|
|
102
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'subtitle')}"
|
|
103
|
-
></${menuItemTag}>
|
|
104
|
-
<${menuItemTag}
|
|
105
|
-
text="Body"
|
|
106
|
-
value="body"
|
|
107
|
-
internal-part
|
|
108
|
-
class="body"
|
|
109
|
-
connotation="cta"
|
|
110
|
-
@click="${(_, { parent }) =>
|
|
111
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'body')}"
|
|
112
|
-
></${menuItemTag}>
|
|
113
|
-
</${menuTag}>
|
|
114
|
-
`;
|
|
115
|
-
},*/
|
|
116
|
-
textBlock: function(context) {
|
|
117
|
-
const selectTag = context.tagFor(definition$3.Select);
|
|
118
|
-
const optionTag = context.tagFor(option.ListboxOption);
|
|
119
|
-
const tooltipTag = context.tagFor(definition$2.Tooltip);
|
|
120
|
-
return vividElement.html`
|
|
156
|
+
textBlock: {
|
|
157
|
+
registerStateProperty: function(menuBar) {
|
|
158
|
+
menuBar.addEventListener("text-styles-changed", textBlockEventHandler);
|
|
159
|
+
},
|
|
160
|
+
render: function(context) {
|
|
161
|
+
const selectTag = context.tagFor(definition$4.Select);
|
|
162
|
+
const optionTag = context.tagFor(option.ListboxOption);
|
|
163
|
+
const tooltipTag = context.tagFor(definition$3.Tooltip);
|
|
164
|
+
return vividElement.html`
|
|
121
165
|
<${tooltipTag} text="Text Block Type" placement="top">
|
|
122
166
|
<${selectTag}
|
|
167
|
+
scale="condensed"
|
|
168
|
+
shape="rounded"
|
|
169
|
+
appearance="ghost"
|
|
123
170
|
slot="anchor"
|
|
124
171
|
trigger="auto"
|
|
125
172
|
id="text-block"
|
|
126
173
|
aria-label="Text Block"
|
|
127
174
|
placement="bottom-end"
|
|
175
|
+
value="${(_, { parent }) => parent.textBlockType}"
|
|
128
176
|
@change="${(_, { parent, event }) => notifyMenuBarChange(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
177
|
+
parent,
|
|
178
|
+
"text-block-selected",
|
|
179
|
+
event.target.value
|
|
180
|
+
)}"
|
|
133
181
|
>
|
|
134
182
|
<${optionTag}
|
|
135
183
|
text="Title"
|
|
@@ -155,44 +203,115 @@ const MENU_BAR_ITEMS = {
|
|
|
155
203
|
</${selectTag}>
|
|
156
204
|
</${tooltipTag}>
|
|
157
205
|
`;
|
|
206
|
+
}
|
|
158
207
|
},
|
|
159
|
-
textDecoration:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
208
|
+
textDecoration: {
|
|
209
|
+
registerStateProperty: function(menuBar) {
|
|
210
|
+
menuBar.addEventListener(
|
|
211
|
+
"text-styles-changed",
|
|
212
|
+
textDecorationEventHandler
|
|
213
|
+
);
|
|
214
|
+
},
|
|
215
|
+
render: function(context) {
|
|
216
|
+
const buttonTag = context.tagFor(definition$2.Button);
|
|
217
|
+
const tooltipTag = context.tagFor(definition$3.Tooltip);
|
|
218
|
+
return vividElement.html`
|
|
219
|
+
<span id="text-decoration">
|
|
220
|
+
${repeat.repeat(
|
|
221
|
+
(_) => TEXT_DECORATION_ITEMS,
|
|
222
|
+
vividElement.html`
|
|
223
|
+
<${tooltipTag} text="${(x) => x.text}" placement="top">
|
|
224
|
+
<${buttonTag}
|
|
225
|
+
class="selection-button"
|
|
226
|
+
slot="anchor"
|
|
227
|
+
aria-label="${(x) => x.text}"
|
|
228
|
+
size="super-condensed"
|
|
229
|
+
appearance="ghost-light"
|
|
230
|
+
shape="rounded"
|
|
231
|
+
icon="${(x) => x.icon}"
|
|
232
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
233
|
+
c.parentContext.parent,
|
|
234
|
+
"text-decoration-selected",
|
|
235
|
+
x.value
|
|
236
|
+
)}"')}"
|
|
237
|
+
></${buttonTag}>
|
|
238
|
+
</${tooltipTag}>
|
|
183
239
|
`
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
240
|
+
)}
|
|
241
|
+
</span>
|
|
242
|
+
`;
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
textSize: {
|
|
246
|
+
registerStateProperty: function(menuBar) {
|
|
247
|
+
menuBar.addEventListener("text-styles-changed", textSizeEventHandler);
|
|
248
|
+
},
|
|
249
|
+
render: function(context) {
|
|
250
|
+
const menuTag = context.tagFor(definition$1.Menu);
|
|
251
|
+
const buttonTag = context.tagFor(definition$2.Button);
|
|
252
|
+
const tooltipTag = context.tagFor(definition$3.Tooltip);
|
|
253
|
+
const menuItemTag = context.tagFor(definition$1.MenuItem);
|
|
254
|
+
return vividElement.html`
|
|
255
|
+
<${menuTag}
|
|
256
|
+
auto-dismiss
|
|
257
|
+
trigger="auto"
|
|
258
|
+
id="text-size"
|
|
259
|
+
aria-label="Text Size"
|
|
260
|
+
placement="bottom-end"
|
|
261
|
+
>
|
|
262
|
+
<${tooltipTag} slot="anchor" text="Text Size" placement="top">
|
|
263
|
+
<${buttonTag}
|
|
264
|
+
slot="anchor"
|
|
265
|
+
aria-label="Open text size menu"
|
|
266
|
+
size="super-condensed"
|
|
267
|
+
appearance="ghost-light"
|
|
268
|
+
shape="pill"
|
|
269
|
+
icon="text-size-line"
|
|
270
|
+
></${buttonTag}>
|
|
271
|
+
</${tooltipTag}>
|
|
272
|
+
${repeat.repeat(
|
|
273
|
+
(_) => TEXT_SIZES,
|
|
274
|
+
vividElement.html`
|
|
275
|
+
<${menuItemTag}
|
|
276
|
+
check-appearance="tick-only"
|
|
277
|
+
role="menuitemcheckbox"
|
|
278
|
+
text="${(x) => x.text}"
|
|
279
|
+
value="${(x) => x.value}"
|
|
280
|
+
internal-part
|
|
281
|
+
class="menubar-selector-menuitem"
|
|
282
|
+
connotation="cta"
|
|
283
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
284
|
+
c.parentContext.parent,
|
|
285
|
+
"text-size-selected",
|
|
286
|
+
x.value
|
|
287
|
+
)}"
|
|
288
|
+
></${menuItemTag}>
|
|
289
|
+
`
|
|
290
|
+
)}
|
|
291
|
+
</${menuTag}>
|
|
292
|
+
`;
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
divider: {
|
|
296
|
+
render: function(context) {
|
|
297
|
+
const dividerTag = context.tagFor(definition.Divider);
|
|
298
|
+
return vividElement.html`
|
|
299
|
+
<${dividerTag} class="divider" orientation="vertical"></${dividerTag}>
|
|
300
|
+
`;
|
|
301
|
+
}
|
|
187
302
|
}
|
|
188
303
|
};
|
|
304
|
+
|
|
189
305
|
const getClasses$1 = (menuBar) => classNames.classNames("control", [
|
|
190
306
|
"hide-menubar",
|
|
191
307
|
getValidMenuItems(menuBar).length === 0
|
|
192
308
|
]);
|
|
193
|
-
const validItems = ["textBlock", "textDecoration"];
|
|
309
|
+
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
310
|
+
function getPropertyStateRgistrationFunction(item) {
|
|
311
|
+
return MENU_BAR_ITEMS[item].registerStateProperty;
|
|
312
|
+
}
|
|
194
313
|
function createMenuItem(item) {
|
|
195
|
-
return MENU_BAR_ITEMS[item];
|
|
314
|
+
return MENU_BAR_ITEMS[item].render;
|
|
196
315
|
}
|
|
197
316
|
function getValidMenuItems({ menuItems }) {
|
|
198
317
|
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
@@ -200,7 +319,10 @@ function getValidMenuItems({ menuItems }) {
|
|
|
200
319
|
function renderMenuItems(context) {
|
|
201
320
|
return () => vividElement.html`${repeat.repeat(
|
|
202
321
|
getValidMenuItems,
|
|
203
|
-
vividElement.html`${(menuItemName) =>
|
|
322
|
+
vividElement.html`${(menuItemName, { parent }) => {
|
|
323
|
+
getPropertyStateRgistrationFunction(menuItemName)?.(parent);
|
|
324
|
+
return createMenuItem(menuItemName)(context);
|
|
325
|
+
}}`
|
|
204
326
|
)}`;
|
|
205
327
|
}
|
|
206
328
|
const MenuBarTemplate = (context) => {
|
|
@@ -214,11 +336,13 @@ const menuBarDefinition = vividElement.defineVividComponent(
|
|
|
214
336
|
MenuBar,
|
|
215
337
|
MenuBarTemplate,
|
|
216
338
|
[
|
|
217
|
-
definition.buttonDefinition,
|
|
218
|
-
definition$
|
|
219
|
-
definition$
|
|
220
|
-
definition
|
|
221
|
-
definition$
|
|
339
|
+
definition$2.buttonDefinition,
|
|
340
|
+
definition$4.selectDefinition,
|
|
341
|
+
definition$5.listboxOptionDefinition,
|
|
342
|
+
definition.dividerDefinition,
|
|
343
|
+
definition$3.tooltipDefinition,
|
|
344
|
+
definition$1.menuDefinition,
|
|
345
|
+
definition$1.menuItemDefinition
|
|
222
346
|
],
|
|
223
347
|
{
|
|
224
348
|
styles,
|
|
@@ -6875,6 +6999,27 @@ function createKey(name) {
|
|
|
6875
6999
|
keys[name] = 0;
|
|
6876
7000
|
return name + "$";
|
|
6877
7001
|
}
|
|
7002
|
+
/**
|
|
7003
|
+
A key is used to [tag](https://prosemirror.net/docs/ref/#state.PluginSpec.key) plugins in a way
|
|
7004
|
+
that makes it possible to find them, given an editor state.
|
|
7005
|
+
Assigning a key does mean only one plugin of that type can be
|
|
7006
|
+
active in a state.
|
|
7007
|
+
*/
|
|
7008
|
+
class PluginKey {
|
|
7009
|
+
/**
|
|
7010
|
+
Create a plugin key.
|
|
7011
|
+
*/
|
|
7012
|
+
constructor(name = "key") { this.key = createKey(name); }
|
|
7013
|
+
/**
|
|
7014
|
+
Get the active plugin with this key, if any, from an editor
|
|
7015
|
+
state.
|
|
7016
|
+
*/
|
|
7017
|
+
get(state) { return state.config.pluginsByKey[this.key]; }
|
|
7018
|
+
/**
|
|
7019
|
+
Get the plugin's state from an editor state.
|
|
7020
|
+
*/
|
|
7021
|
+
getState(state) { return state[this.key]; }
|
|
7022
|
+
}
|
|
6878
7023
|
|
|
6879
7024
|
const domIndex = function (node) {
|
|
6880
7025
|
for (var index = 0;; index++) {
|
|
@@ -13656,6 +13801,15 @@ To reuse elements from this schema, extend or read from its
|
|
|
13656
13801
|
*/
|
|
13657
13802
|
const schema = new Schema({ nodes, marks });
|
|
13658
13803
|
|
|
13804
|
+
const TEXT_SIZES_CSS_VARIABLES = {
|
|
13805
|
+
"extra-large": "var(--vvd-typography-heading-4)",
|
|
13806
|
+
large: "var(--vvd-typography-base-extended)",
|
|
13807
|
+
normal: "var(--vvd-typography-base)",
|
|
13808
|
+
small: "var(--vvd-typography-base-condensed)"
|
|
13809
|
+
};
|
|
13810
|
+
const CSS_VARIABLES_TO_SIZES = Object.fromEntries(
|
|
13811
|
+
Object.entries(TEXT_SIZES_CSS_VARIABLES).map(([key, value]) => [value, key])
|
|
13812
|
+
);
|
|
13659
13813
|
const customMarks = {
|
|
13660
13814
|
u: {
|
|
13661
13815
|
parseDOM: [{ tag: "u" }],
|
|
@@ -13674,6 +13828,26 @@ const customMarks = {
|
|
|
13674
13828
|
toDOM() {
|
|
13675
13829
|
return ["tt", 0];
|
|
13676
13830
|
}
|
|
13831
|
+
},
|
|
13832
|
+
textSize: {
|
|
13833
|
+
attrs: { size: { default: "normal" } },
|
|
13834
|
+
parseDOM: [
|
|
13835
|
+
{
|
|
13836
|
+
tag: "span[style*='font']",
|
|
13837
|
+
getAttrs: (node) => {
|
|
13838
|
+
const style = node.getAttribute("style");
|
|
13839
|
+
const fontSize = style.match(/font:\s*([^;]+)/)?.[1]?.trim();
|
|
13840
|
+
const size = CSS_VARIABLES_TO_SIZES[fontSize];
|
|
13841
|
+
if (size) return { size };
|
|
13842
|
+
return false;
|
|
13843
|
+
}
|
|
13844
|
+
}
|
|
13845
|
+
],
|
|
13846
|
+
toDOM(mark) {
|
|
13847
|
+
const size = mark.attrs.size;
|
|
13848
|
+
const fontSize = TEXT_SIZES_CSS_VARIABLES[size] || TEXT_SIZES_CSS_VARIABLES.normal;
|
|
13849
|
+
return ["span", { style: `font: ${fontSize};` }, 0];
|
|
13850
|
+
}
|
|
13677
13851
|
}
|
|
13678
13852
|
};
|
|
13679
13853
|
const extendedSchema = new Schema({
|
|
@@ -13708,6 +13882,13 @@ class TagToSchemaMap {
|
|
|
13708
13882
|
};
|
|
13709
13883
|
}
|
|
13710
13884
|
}
|
|
13885
|
+
function setTextBlockType(styles, type) {
|
|
13886
|
+
if (styles.textBlockType && styles.textBlockType !== type || styles.textBlockType === "") {
|
|
13887
|
+
styles.textBlockType = "";
|
|
13888
|
+
} else {
|
|
13889
|
+
styles.textBlockType = type;
|
|
13890
|
+
}
|
|
13891
|
+
}
|
|
13711
13892
|
function createSelectionChangePlugin(onSelectionChange) {
|
|
13712
13893
|
return new Plugin({
|
|
13713
13894
|
view: () => ({
|
|
@@ -13730,6 +13911,30 @@ function convertSelectionToVividFormat({
|
|
|
13730
13911
|
end: to
|
|
13731
13912
|
};
|
|
13732
13913
|
}
|
|
13914
|
+
const isEmptyParagraph = (node) => {
|
|
13915
|
+
return node.type.name === "paragraph" && node.nodeSize === 2;
|
|
13916
|
+
};
|
|
13917
|
+
const DEFAULT_TEXT_EDITOR_PLACEHOLDER = "Start typing...";
|
|
13918
|
+
const placeholderPluginKey = new PluginKey("placeholderPlugin");
|
|
13919
|
+
const createPlaceholderPlugin = (placeholder = DEFAULT_TEXT_EDITOR_PLACEHOLDER) => {
|
|
13920
|
+
return new Plugin({
|
|
13921
|
+
key: placeholderPluginKey,
|
|
13922
|
+
props: {
|
|
13923
|
+
decorations(state) {
|
|
13924
|
+
const { $from } = state.selection;
|
|
13925
|
+
const decorations = [];
|
|
13926
|
+
if (state.doc.childCount === 1 && isEmptyParagraph($from.parent)) {
|
|
13927
|
+
const decoration = Decoration.node($from.before(), $from.after(), {
|
|
13928
|
+
"data-placeholder": placeholder,
|
|
13929
|
+
class: "placeholder"
|
|
13930
|
+
});
|
|
13931
|
+
decorations.push(decoration);
|
|
13932
|
+
}
|
|
13933
|
+
return DecorationSet.create(state.doc, decorations);
|
|
13934
|
+
}
|
|
13935
|
+
}
|
|
13936
|
+
});
|
|
13937
|
+
};
|
|
13733
13938
|
class ProseMirrorFacade {
|
|
13734
13939
|
#userContentChange = false;
|
|
13735
13940
|
#view;
|
|
@@ -13750,6 +13955,7 @@ class ProseMirrorFacade {
|
|
|
13750
13955
|
};
|
|
13751
13956
|
#handleChangeEvent = () => {
|
|
13752
13957
|
if (!this.#userContentChange) {
|
|
13958
|
+
this.#userContentChange = false;
|
|
13753
13959
|
return;
|
|
13754
13960
|
}
|
|
13755
13961
|
this.#dispatchEvent("change");
|
|
@@ -13761,6 +13967,7 @@ class ProseMirrorFacade {
|
|
|
13761
13967
|
);
|
|
13762
13968
|
}
|
|
13763
13969
|
const plugins = [
|
|
13970
|
+
createPlaceholderPlugin(),
|
|
13764
13971
|
createSelectionChangePlugin(this.#onSelectionChange),
|
|
13765
13972
|
keymap(baseKeymap)
|
|
13766
13973
|
];
|
|
@@ -13772,6 +13979,18 @@ class ProseMirrorFacade {
|
|
|
13772
13979
|
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
13773
13980
|
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
13774
13981
|
}
|
|
13982
|
+
updatePlaceholder(placeholderText) {
|
|
13983
|
+
this.#verifyViewInitiation();
|
|
13984
|
+
const { state } = this.#view;
|
|
13985
|
+
const plugins = state.plugins.filter(
|
|
13986
|
+
(plugin) => plugin !== placeholderPluginKey.get(state)
|
|
13987
|
+
);
|
|
13988
|
+
const newPlaceholderPlugin = createPlaceholderPlugin(placeholderText);
|
|
13989
|
+
const newState = state.reconfigure({
|
|
13990
|
+
plugins: [...plugins, newPlaceholderPlugin]
|
|
13991
|
+
});
|
|
13992
|
+
this.#view.updateState(newState);
|
|
13993
|
+
}
|
|
13775
13994
|
replaceContent(content) {
|
|
13776
13995
|
this.#verifyViewInitiation();
|
|
13777
13996
|
const parser = DOMParser.fromSchema(extendedSchema);
|
|
@@ -13822,6 +14041,7 @@ class ProseMirrorFacade {
|
|
|
13822
14041
|
dispatch(tr);
|
|
13823
14042
|
}
|
|
13824
14043
|
setSelectionDecoration(decoration) {
|
|
14044
|
+
this.#verifyViewInitiation();
|
|
13825
14045
|
const SUPPORTED_DECORATIONS = {
|
|
13826
14046
|
bold: "strong",
|
|
13827
14047
|
italics: "em",
|
|
@@ -13829,7 +14049,6 @@ class ProseMirrorFacade {
|
|
|
13829
14049
|
strikethrough: "s",
|
|
13830
14050
|
monospace: "tt"
|
|
13831
14051
|
};
|
|
13832
|
-
this.#verifyViewInitiation();
|
|
13833
14052
|
const { state, dispatch } = this.#view;
|
|
13834
14053
|
const decorationKey = decoration;
|
|
13835
14054
|
const markType = state.schema.marks[SUPPORTED_DECORATIONS[decorationKey]];
|
|
@@ -13837,6 +14056,121 @@ class ProseMirrorFacade {
|
|
|
13837
14056
|
throw new Error(`${decoration} is not a supported decoration`);
|
|
13838
14057
|
}
|
|
13839
14058
|
toggleMark(markType)(state, dispatch);
|
|
14059
|
+
this.#userContentChange = true;
|
|
14060
|
+
this.#handleChangeEvent();
|
|
14061
|
+
}
|
|
14062
|
+
#getSelectionBlockType() {
|
|
14063
|
+
const { state } = this.#view;
|
|
14064
|
+
const { from, to } = state.selection;
|
|
14065
|
+
const styles = {};
|
|
14066
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14067
|
+
if (node.type.name === "heading" && node.attrs.level === 2) {
|
|
14068
|
+
setTextBlockType(styles, "title");
|
|
14069
|
+
} else if (node.type.name === "heading" && node.attrs.level === 3) {
|
|
14070
|
+
setTextBlockType(styles, "subtitle");
|
|
14071
|
+
} else if (node.type.name === "paragraph") {
|
|
14072
|
+
setTextBlockType(styles, "body");
|
|
14073
|
+
}
|
|
14074
|
+
});
|
|
14075
|
+
return styles.textBlockType;
|
|
14076
|
+
}
|
|
14077
|
+
#getSelectionTextDecoration() {
|
|
14078
|
+
const { state } = this.#view;
|
|
14079
|
+
const { from, to, empty } = state.selection;
|
|
14080
|
+
const decorations = [];
|
|
14081
|
+
if (empty) {
|
|
14082
|
+
const marks = state.doc.resolve(from).marks();
|
|
14083
|
+
if (state.schema.marks.strong && marks.some((mark) => mark.type === state.schema.marks.strong)) {
|
|
14084
|
+
decorations.push("bold");
|
|
14085
|
+
}
|
|
14086
|
+
if (state.schema.marks.em && marks.some((mark) => mark.type === state.schema.marks.em)) {
|
|
14087
|
+
decorations.push("italics");
|
|
14088
|
+
}
|
|
14089
|
+
if (state.schema.marks.u && marks.some((mark) => mark.type === state.schema.marks.u)) {
|
|
14090
|
+
decorations.push("underline");
|
|
14091
|
+
}
|
|
14092
|
+
if (state.schema.marks.s && marks.some((mark) => mark.type === state.schema.marks.s)) {
|
|
14093
|
+
decorations.push("strikethrough");
|
|
14094
|
+
}
|
|
14095
|
+
if (state.schema.marks.tt && marks.some((mark) => mark.type === state.schema.marks.tt)) {
|
|
14096
|
+
decorations.push("monospace");
|
|
14097
|
+
}
|
|
14098
|
+
} else {
|
|
14099
|
+
if (state.schema.marks.strong && state.doc.rangeHasMark(from, to, state.schema.marks.strong)) {
|
|
14100
|
+
decorations.push("bold");
|
|
14101
|
+
}
|
|
14102
|
+
if (state.schema.marks.em && state.doc.rangeHasMark(from, to, state.schema.marks.em)) {
|
|
14103
|
+
decorations.push("italics");
|
|
14104
|
+
}
|
|
14105
|
+
if (state.schema.marks.u && state.doc.rangeHasMark(from, to, state.schema.marks.u)) {
|
|
14106
|
+
decorations.push("underline");
|
|
14107
|
+
}
|
|
14108
|
+
if (state.schema.marks.s && state.doc.rangeHasMark(from, to, state.schema.marks.s)) {
|
|
14109
|
+
decorations.push("strikethrough");
|
|
14110
|
+
}
|
|
14111
|
+
if (state.schema.marks.tt && state.doc.rangeHasMark(from, to, state.schema.marks.tt)) {
|
|
14112
|
+
decorations.push("monospace");
|
|
14113
|
+
}
|
|
14114
|
+
}
|
|
14115
|
+
return decorations.length ? decorations : void 0;
|
|
14116
|
+
}
|
|
14117
|
+
#getSelectionTextSize() {
|
|
14118
|
+
const { state } = this.#view;
|
|
14119
|
+
const { from, to, empty } = state.selection;
|
|
14120
|
+
const defaultSize = "normal";
|
|
14121
|
+
if (empty) {
|
|
14122
|
+
const marks = state.doc.resolve(from).marks();
|
|
14123
|
+
const textSizeMark = marks.find(
|
|
14124
|
+
(mark) => mark.type === state.schema.marks.textSize
|
|
14125
|
+
);
|
|
14126
|
+
return textSizeMark ? textSizeMark.attrs.size : defaultSize;
|
|
14127
|
+
} else {
|
|
14128
|
+
let textSize = null;
|
|
14129
|
+
let foundMixedSizes = false;
|
|
14130
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14131
|
+
if (node.isText) {
|
|
14132
|
+
const mark = node.marks.find(
|
|
14133
|
+
(mark2) => mark2.type === state.schema.marks.textSize
|
|
14134
|
+
);
|
|
14135
|
+
if (mark) {
|
|
14136
|
+
if (textSize === null) {
|
|
14137
|
+
textSize = mark.attrs.size;
|
|
14138
|
+
} else if (textSize !== mark.attrs.size) {
|
|
14139
|
+
foundMixedSizes = true;
|
|
14140
|
+
return false;
|
|
14141
|
+
}
|
|
14142
|
+
} else if (textSize !== null) {
|
|
14143
|
+
foundMixedSizes = true;
|
|
14144
|
+
return false;
|
|
14145
|
+
}
|
|
14146
|
+
}
|
|
14147
|
+
return true;
|
|
14148
|
+
});
|
|
14149
|
+
if (foundMixedSizes) {
|
|
14150
|
+
return "";
|
|
14151
|
+
}
|
|
14152
|
+
return textSize !== null ? textSize : defaultSize;
|
|
14153
|
+
}
|
|
14154
|
+
}
|
|
14155
|
+
getSelectionStyles() {
|
|
14156
|
+
this.#verifyViewInitiation();
|
|
14157
|
+
const styles = {};
|
|
14158
|
+
styles.textBlockType = this.#getSelectionBlockType();
|
|
14159
|
+
styles.textDecoration = this.#getSelectionTextDecoration();
|
|
14160
|
+
styles.textSize = this.#getSelectionTextSize();
|
|
14161
|
+
return styles;
|
|
14162
|
+
}
|
|
14163
|
+
setTextSize(size = "normal") {
|
|
14164
|
+
this.#verifyViewInitiation();
|
|
14165
|
+
const { state, dispatch } = this.#view;
|
|
14166
|
+
const { schema, selection, tr } = state;
|
|
14167
|
+
const { from, to } = selection;
|
|
14168
|
+
const textSizeMark = schema.marks.textSize;
|
|
14169
|
+
tr.removeMark(from, to, textSizeMark);
|
|
14170
|
+
tr.addMark(from, to, textSizeMark.create({ size }));
|
|
14171
|
+
dispatch(tr.scrollIntoView());
|
|
14172
|
+
this.#userContentChange = true;
|
|
14173
|
+
this.#handleChangeEvent();
|
|
13840
14174
|
}
|
|
13841
14175
|
}
|
|
13842
14176
|
|
|
@@ -13917,6 +14251,9 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13917
14251
|
}
|
|
13918
14252
|
this.#updateEditorSelection();
|
|
13919
14253
|
}
|
|
14254
|
+
placeholderChanged() {
|
|
14255
|
+
this.#editor?.updatePlaceholder(this.placeholder);
|
|
14256
|
+
}
|
|
13920
14257
|
#handleSelectionChange;
|
|
13921
14258
|
#handleChange;
|
|
13922
14259
|
#handleInput;
|
|
@@ -13932,6 +14269,7 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13932
14269
|
this.#editor.addEventListener("change", this.#handleChange);
|
|
13933
14270
|
this.#editor.addEventListener("input", this.#handleInput);
|
|
13934
14271
|
}
|
|
14272
|
+
this.placeholderChanged();
|
|
13935
14273
|
}
|
|
13936
14274
|
setTextBlock(blockType) {
|
|
13937
14275
|
try {
|
|
@@ -13947,6 +14285,15 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13947
14285
|
console.warn(`Invalid decoration: ${decoration}`);
|
|
13948
14286
|
}
|
|
13949
14287
|
}
|
|
14288
|
+
setSelectionTextSize(textSize) {
|
|
14289
|
+
this.#editor?.setTextSize(textSize);
|
|
14290
|
+
}
|
|
14291
|
+
get selectionStyles() {
|
|
14292
|
+
if (!this.#editor) {
|
|
14293
|
+
return {};
|
|
14294
|
+
}
|
|
14295
|
+
return this.#editor.getSelectionStyles();
|
|
14296
|
+
}
|
|
13950
14297
|
focus() {
|
|
13951
14298
|
super.focus();
|
|
13952
14299
|
setTimeout(() => {
|
|
@@ -13962,6 +14309,9 @@ __decorateClass([
|
|
|
13962
14309
|
__decorateClass([
|
|
13963
14310
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-end" })
|
|
13964
14311
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14312
|
+
__decorateClass([
|
|
14313
|
+
vividElement.attr
|
|
14314
|
+
], RichTextEditor.prototype, "placeholder");
|
|
13965
14315
|
|
|
13966
14316
|
const getClasses = (_) => classNames.classNames("control");
|
|
13967
14317
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
@@ -13978,6 +14328,12 @@ function selectionDecorationSelectedHandler(event) {
|
|
|
13978
14328
|
);
|
|
13979
14329
|
menuParent(event.target).focus();
|
|
13980
14330
|
}
|
|
14331
|
+
function textSizeSelectedHandler(event) {
|
|
14332
|
+
menuParent(event.target).setSelectionTextSize(
|
|
14333
|
+
event.detail
|
|
14334
|
+
);
|
|
14335
|
+
menuParent(event.target).focus();
|
|
14336
|
+
}
|
|
13981
14337
|
function handleMenuBarSlotChange(_, { event }) {
|
|
13982
14338
|
const slot = event.target;
|
|
13983
14339
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
@@ -14000,6 +14356,10 @@ function handleMenuBarSlotChange(_, { event }) {
|
|
|
14000
14356
|
"text-decoration-selected",
|
|
14001
14357
|
selectionDecorationSelectedHandler
|
|
14002
14358
|
);
|
|
14359
|
+
menuBar.addEventListener(
|
|
14360
|
+
"text-size-selected",
|
|
14361
|
+
textSizeSelectedHandler
|
|
14362
|
+
);
|
|
14003
14363
|
}
|
|
14004
14364
|
}
|
|
14005
14365
|
const RichTextEditorTemplate = (_) => {
|