@vonage/vivid 4.21.1 → 4.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +2055 -640
- package/index.cjs +1 -1
- package/index.js +2 -2
- package/lib/accordion-item/accordion-item.d.ts +11 -5
- package/lib/action-group/action-group.d.ts +8 -6
- package/lib/alert/alert.d.ts +21 -9
- package/lib/audio-player/audio-player.d.ts +13 -6
- package/lib/badge/badge.d.ts +11 -5
- package/lib/banner/banner.d.ts +26 -12
- package/lib/breadcrumb/breadcrumb.d.ts +333 -1
- package/lib/breadcrumb/breadcrumb.template.d.ts +2 -3
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +8 -6
- package/lib/button/button.d.ts +11 -5
- package/lib/calendar/calendar.d.ts +3 -1
- package/lib/calendar-event/calendar-event.d.ts +333 -1
- package/lib/checkbox/checkbox.d.ts +8 -6
- package/lib/combobox/combobox.d.ts +11 -5
- package/lib/date-picker/date-picker.d.ts +74 -50
- package/lib/date-range-picker/date-range-picker.d.ts +38 -26
- package/lib/date-time-picker/date-time-picker.d.ts +76 -52
- package/lib/dial-pad/dial-pad.d.ts +11 -5
- package/lib/dialog/dialog.d.ts +16 -8
- package/lib/divider/divider.d.ts +8 -6
- package/lib/enums.d.ts +0 -4
- package/lib/fab/fab.d.ts +11 -5
- package/lib/file-picker/file-picker.d.ts +338 -1
- package/lib/header/header.d.ts +333 -1
- package/lib/menu/menu.d.ts +16 -8
- package/lib/menu-item/menu-item.d.ts +338 -2
- package/lib/nav/nav.d.ts +333 -1
- package/lib/nav-disclosure/nav-disclosure.d.ts +16 -8
- package/lib/nav-item/nav-item.d.ts +11 -5
- package/lib/note/note.d.ts +11 -5
- package/lib/number-field/number-field.d.ts +26 -12
- package/lib/option/option.d.ts +341 -3
- package/lib/progress/progress.d.ts +8 -6
- package/lib/progress-ring/progress-ring.d.ts +8 -6
- package/lib/radio-group/radio-group.d.ts +333 -1
- package/lib/range-slider/range-slider.d.ts +11 -5
- package/lib/rich-text-editor/facades/prose-mirror-vivid.schema.d.ts +1 -1
- package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +7 -1
- package/lib/rich-text-editor/menubar/consts.d.ts +18 -0
- package/lib/rich-text-editor/menubar/menubar.d.ts +3 -0
- package/lib/rich-text-editor/rich-text-editor.d.ts +14 -3
- package/lib/searchable-select/option-tag.d.ts +14 -6
- package/lib/searchable-select/searchable-select.d.ts +349 -7
- package/lib/select/select.d.ts +339 -3
- package/lib/selectable-box/selectable-box.d.ts +8 -6
- package/lib/slider/slider.d.ts +16 -8
- package/lib/split-button/split-button.d.ts +26 -12
- package/lib/switch/switch.d.ts +8 -6
- package/lib/tab/tab.d.ts +349 -7
- package/lib/tab-panel/tab-panel.d.ts +333 -1
- package/lib/tabs/definition.d.ts +1 -0
- package/lib/tabs/tabs.d.ts +6 -1
- package/lib/tag/tag.d.ts +338 -2
- package/lib/tag-group/tag-group.d.ts +8 -6
- package/lib/text-anchor/text-anchor.d.ts +16 -8
- package/lib/text-area/text-area.d.ts +8 -6
- package/lib/text-field/text-field.d.ts +16 -8
- package/lib/time-picker/time-picker.d.ts +38 -26
- package/lib/toggletip/toggletip.d.ts +9 -3
- package/lib/tooltip/tooltip.d.ts +9 -3
- package/lib/tree-item/tree-item.d.ts +338 -2
- package/lib/tree-view/tree-view.d.ts +333 -1
- package/lib/video-player/video-player.d.ts +14 -6
- package/package.json +1 -1
- package/shared/affix.js +1 -1
- package/shared/aria/aria-change-subscription.d.ts +6 -0
- package/shared/aria/aria-mixin.d.ts +338 -0
- package/shared/aria/delegate-aria-behavior.d.ts +31 -0
- package/shared/aria/delegates-aria.d.ts +14 -9
- package/shared/aria/host-semantics-behavior.d.ts +22 -0
- package/shared/aria/host-semantics.d.ts +337 -0
- package/shared/attribute-binding-behaviour.cjs +41 -0
- package/shared/attribute-binding-behaviour.js +39 -0
- package/shared/calendar-event.cjs +2 -1
- package/shared/calendar-event.js +2 -1
- package/shared/definition.js +1 -1
- package/shared/definition10.cjs +8 -2
- package/shared/definition10.js +9 -3
- package/shared/definition11.cjs +4 -28
- package/shared/definition11.js +5 -29
- package/shared/definition12.cjs +4 -1
- package/shared/definition12.js +5 -2
- package/shared/definition13.js +1 -1
- package/shared/definition14.js +1 -1
- package/shared/definition15.cjs +9 -8
- package/shared/definition15.js +11 -10
- package/shared/definition16.cjs +1 -1
- package/shared/definition16.js +2 -2
- package/shared/definition17.js +1 -1
- package/shared/definition18.js +1 -1
- package/shared/definition19.cjs +3 -0
- package/shared/definition19.js +4 -1
- package/shared/definition2.js +1 -1
- package/shared/definition20.js +1 -1
- package/shared/definition21.js +1 -1
- package/shared/definition22.cjs +3 -2
- package/shared/definition22.js +5 -4
- package/shared/definition23.cjs +4 -2
- package/shared/definition23.js +6 -4
- package/shared/definition24.js +1 -1
- package/shared/definition25.cjs +2 -14
- package/shared/definition25.js +3 -15
- package/shared/definition26.cjs +15 -2
- package/shared/definition26.js +16 -3
- package/shared/definition27.cjs +3 -2
- package/shared/definition27.js +4 -3
- package/shared/definition28.cjs +1 -1
- package/shared/definition28.js +2 -2
- package/shared/definition29.js +1 -1
- package/shared/definition3.cjs +4 -3
- package/shared/definition3.js +6 -5
- package/shared/definition30.cjs +34 -34
- package/shared/definition30.js +36 -36
- package/shared/definition31.cjs +6 -4
- package/shared/definition31.js +8 -6
- package/shared/definition32.js +1 -1
- package/shared/definition33.cjs +7 -2
- package/shared/definition33.js +8 -3
- package/shared/definition34.js +1 -1
- package/shared/definition35.cjs +3 -14
- package/shared/definition35.js +5 -16
- package/shared/definition36.cjs +8 -5
- package/shared/definition36.js +9 -6
- package/shared/definition37.js +1 -1
- package/shared/definition38.cjs +7 -8
- package/shared/definition38.js +9 -10
- package/shared/definition39.cjs +7 -8
- package/shared/definition39.js +9 -10
- package/shared/definition4.cjs +1 -1
- package/shared/definition4.js +2 -2
- package/shared/definition40.cjs +8 -5
- package/shared/definition40.js +9 -6
- package/shared/definition41.cjs +1 -1
- package/shared/definition41.js +2 -2
- package/shared/definition42.js +1 -1
- package/shared/definition43.cjs +506 -93
- package/shared/definition43.js +502 -89
- package/shared/definition44.cjs +27 -10
- package/shared/definition44.js +28 -11
- package/shared/definition45.cjs +12 -6
- package/shared/definition45.js +13 -7
- package/shared/definition46.cjs +18 -6
- package/shared/definition46.js +20 -8
- package/shared/definition47.js +1 -1
- package/shared/definition48.js +1 -1
- package/shared/definition49.cjs +10 -3
- package/shared/definition49.js +12 -5
- package/shared/definition5.cjs +7 -2
- package/shared/definition5.js +8 -3
- package/shared/definition50.cjs +8 -7
- package/shared/definition50.js +10 -9
- package/shared/definition51.cjs +3 -2
- package/shared/definition51.js +4 -3
- package/shared/definition52.cjs +8 -4
- package/shared/definition52.js +9 -5
- package/shared/definition53.cjs +5 -0
- package/shared/definition53.js +6 -2
- package/shared/definition54.cjs +4 -3
- package/shared/definition54.js +6 -5
- package/shared/definition55.cjs +7 -4
- package/shared/definition55.js +8 -5
- package/shared/definition56.cjs +69 -15
- package/shared/definition56.js +70 -16
- package/shared/definition57.cjs +163 -112
- package/shared/definition57.js +165 -114
- package/shared/definition58.js +1 -1
- package/shared/definition59.js +1 -1
- package/shared/definition6.js +1 -1
- package/shared/definition60.js +1 -1
- package/shared/definition61.cjs +8 -5
- package/shared/definition61.js +9 -6
- package/shared/definition62.cjs +5 -2
- package/shared/definition62.js +6 -3
- package/shared/definition63.js +1 -1
- package/shared/definition64.js +1 -1
- package/shared/definition65.js +1 -1
- package/shared/definition7.js +1 -1
- package/shared/definition8.cjs +4 -2
- package/shared/definition8.js +6 -4
- package/shared/definition9.js +1 -1
- package/shared/delegates-aria.cjs +106 -56
- package/shared/delegates-aria.js +107 -58
- package/shared/enums.cjs +0 -6
- package/shared/enums.js +1 -6
- package/shared/foundation/button/button.d.ts +8 -6
- package/shared/foundation/vivid-element/vivid-element.d.ts +339 -1
- package/shared/host-semantics.cjs +65 -0
- package/shared/host-semantics.js +62 -0
- package/shared/option.cjs +7 -1
- package/shared/option.js +7 -1
- package/shared/patterns/affix.d.ts +22 -10
- package/shared/patterns/anchored.d.ts +18 -6
- package/shared/patterns/localized.d.ts +11 -5
- package/shared/patterns/trapped-focus.d.ts +11 -5
- package/shared/picker-field/mixins/calendar-picker.d.ts +19 -13
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +19 -13
- package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +11 -5
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +38 -26
- package/shared/picker-field/mixins/single-date-picker.d.ts +55 -37
- package/shared/picker-field/mixins/single-value-picker.d.ts +17 -11
- package/shared/picker-field/mixins/time-selection-picker.d.ts +38 -26
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +38 -26
- package/shared/picker-field/picker-field.d.ts +21 -9
- package/shared/picker-field.template.js +1 -1
- package/shared/repeat.js +1 -1
- package/shared/single-value-picker.cjs +3 -0
- package/shared/single-value-picker.js +3 -0
- package/shared/slider.template.cjs +10 -9
- package/shared/slider.template.js +10 -9
- package/shared/templating/attribute-binding-behaviour.d.ts +15 -0
- package/shared/templating/render-in-light-dom.d.ts +22 -0
- package/shared/text-anchor.template.cjs +2 -13
- package/shared/text-anchor.template.js +2 -13
- package/shared/text-field.cjs +1 -1
- package/shared/text-field.js +1 -1
- package/shared/time-selection-picker.template.js +1 -1
- package/shared/vivid-element.cjs +96 -2
- package/shared/vivid-element.js +93 -3
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/text-anchor/index.js +1 -1
- package/vivid.api.json +316 -70
- package/shared/Reflector.cjs +0 -71
- package/shared/Reflector.js +0 -69
package/shared/definition43.cjs
CHANGED
|
@@ -1,16 +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$
|
|
8
|
-
const
|
|
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
|
+
const option = require('./option.cjs');
|
|
9
|
+
const definition$1 = require('./definition30.cjs');
|
|
9
10
|
const repeat = require('./repeat.cjs');
|
|
11
|
+
const classNames = require('./class-names.cjs');
|
|
12
|
+
const definition$5 = require('./definition36.cjs');
|
|
10
13
|
|
|
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)}";
|
|
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)}";
|
|
12
15
|
|
|
13
|
-
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}";
|
|
14
17
|
|
|
15
18
|
var __defProp$1 = Object.defineProperty;
|
|
16
19
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
@@ -22,6 +25,38 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
22
25
|
return result;
|
|
23
26
|
};
|
|
24
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
|
+
}
|
|
25
60
|
}
|
|
26
61
|
__decorateClass$1([
|
|
27
62
|
vividElement.attr({ attribute: "menu-items" })
|
|
@@ -58,93 +93,225 @@ const TEXT_DECORATION_ITEMS = [
|
|
|
58
93
|
value: "monospace"
|
|
59
94
|
}
|
|
60
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
|
+
};
|
|
61
155
|
const MENU_BAR_ITEMS = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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`
|
|
165
|
+
<${tooltipTag} text="Text Block Type" placement="top">
|
|
166
|
+
<${selectTag}
|
|
167
|
+
scale="condensed"
|
|
168
|
+
shape="rounded"
|
|
169
|
+
appearance="ghost"
|
|
170
|
+
slot="anchor"
|
|
69
171
|
trigger="auto"
|
|
70
|
-
id="text-
|
|
71
|
-
aria-label="Text
|
|
172
|
+
id="text-block"
|
|
173
|
+
aria-label="Text Block"
|
|
72
174
|
placement="bottom-end"
|
|
175
|
+
value="${(_, { parent }) => parent.textBlockType}"
|
|
176
|
+
@change="${(_, { parent, event }) => notifyMenuBarChange(
|
|
177
|
+
parent,
|
|
178
|
+
"text-block-selected",
|
|
179
|
+
event.target.value
|
|
180
|
+
)}"
|
|
73
181
|
>
|
|
74
|
-
<${
|
|
75
|
-
<${buttonTag}
|
|
76
|
-
slot="anchor"
|
|
77
|
-
aria-label="Open text size menu"
|
|
78
|
-
size="super-condensed"
|
|
79
|
-
appearance="ghost-light"
|
|
80
|
-
shape="pill"
|
|
81
|
-
icon="text-size-line"
|
|
82
|
-
></${buttonTag}>
|
|
83
|
-
</${tooltipTag}>
|
|
84
|
-
<${menuItemTag}
|
|
182
|
+
<${optionTag}
|
|
85
183
|
text="Title"
|
|
86
184
|
value="title"
|
|
87
185
|
internal-part
|
|
88
186
|
class="title"
|
|
89
187
|
connotation="cta"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
<${menuItemTag}
|
|
188
|
+
></${optionTag}>
|
|
189
|
+
<${optionTag}
|
|
93
190
|
text="Subtitle"
|
|
94
191
|
value="subtitle"
|
|
95
192
|
internal-part
|
|
96
193
|
class="subtitle"
|
|
97
194
|
connotation="cta"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<${menuItemTag}
|
|
195
|
+
></${optionTag}>
|
|
196
|
+
<${optionTag}
|
|
101
197
|
text="Body"
|
|
102
198
|
value="body"
|
|
103
199
|
internal-part
|
|
104
200
|
class="body"
|
|
105
201
|
connotation="cta"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
202
|
+
></${optionTag}>
|
|
203
|
+
</${selectTag}>
|
|
204
|
+
</${tooltipTag}>
|
|
109
205
|
`;
|
|
206
|
+
}
|
|
110
207
|
},
|
|
111
|
-
textDecoration:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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}>
|
|
135
239
|
`
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
}
|
|
139
302
|
}
|
|
140
303
|
};
|
|
304
|
+
|
|
141
305
|
const getClasses$1 = (menuBar) => classNames.classNames("control", [
|
|
142
306
|
"hide-menubar",
|
|
143
307
|
getValidMenuItems(menuBar).length === 0
|
|
144
308
|
]);
|
|
145
|
-
const validItems = ["
|
|
309
|
+
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
310
|
+
function getPropertyStateRgistrationFunction(item) {
|
|
311
|
+
return MENU_BAR_ITEMS[item].registerStateProperty;
|
|
312
|
+
}
|
|
146
313
|
function createMenuItem(item) {
|
|
147
|
-
return MENU_BAR_ITEMS[item];
|
|
314
|
+
return MENU_BAR_ITEMS[item].render;
|
|
148
315
|
}
|
|
149
316
|
function getValidMenuItems({ menuItems }) {
|
|
150
317
|
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
@@ -152,7 +319,10 @@ function getValidMenuItems({ menuItems }) {
|
|
|
152
319
|
function renderMenuItems(context) {
|
|
153
320
|
return () => vividElement.html`${repeat.repeat(
|
|
154
321
|
getValidMenuItems,
|
|
155
|
-
vividElement.html`${(menuItemName) =>
|
|
322
|
+
vividElement.html`${(menuItemName, { parent }) => {
|
|
323
|
+
getPropertyStateRgistrationFunction(menuItemName)?.(parent);
|
|
324
|
+
return createMenuItem(menuItemName)(context);
|
|
325
|
+
}}`
|
|
156
326
|
)}`;
|
|
157
327
|
}
|
|
158
328
|
const MenuBarTemplate = (context) => {
|
|
@@ -166,11 +336,13 @@ const menuBarDefinition = vividElement.defineVividComponent(
|
|
|
166
336
|
MenuBar,
|
|
167
337
|
MenuBarTemplate,
|
|
168
338
|
[
|
|
169
|
-
definition.buttonDefinition,
|
|
170
|
-
definition$
|
|
171
|
-
definition$
|
|
172
|
-
definition
|
|
173
|
-
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
|
|
174
346
|
],
|
|
175
347
|
{
|
|
176
348
|
styles,
|
|
@@ -6827,6 +6999,27 @@ function createKey(name) {
|
|
|
6827
6999
|
keys[name] = 0;
|
|
6828
7000
|
return name + "$";
|
|
6829
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
|
+
}
|
|
6830
7023
|
|
|
6831
7024
|
const domIndex = function (node) {
|
|
6832
7025
|
for (var index = 0;; index++) {
|
|
@@ -13608,6 +13801,15 @@ To reuse elements from this schema, extend or read from its
|
|
|
13608
13801
|
*/
|
|
13609
13802
|
const schema = new Schema({ nodes, marks });
|
|
13610
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
|
+
);
|
|
13611
13813
|
const customMarks = {
|
|
13612
13814
|
u: {
|
|
13613
13815
|
parseDOM: [{ tag: "u" }],
|
|
@@ -13626,6 +13828,26 @@ const customMarks = {
|
|
|
13626
13828
|
toDOM() {
|
|
13627
13829
|
return ["tt", 0];
|
|
13628
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
|
+
}
|
|
13629
13851
|
}
|
|
13630
13852
|
};
|
|
13631
13853
|
const extendedSchema = new Schema({
|
|
@@ -13660,6 +13882,13 @@ class TagToSchemaMap {
|
|
|
13660
13882
|
};
|
|
13661
13883
|
}
|
|
13662
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
|
+
}
|
|
13663
13892
|
function createSelectionChangePlugin(onSelectionChange) {
|
|
13664
13893
|
return new Plugin({
|
|
13665
13894
|
view: () => ({
|
|
@@ -13682,6 +13911,30 @@ function convertSelectionToVividFormat({
|
|
|
13682
13911
|
end: to
|
|
13683
13912
|
};
|
|
13684
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
|
+
};
|
|
13685
13938
|
class ProseMirrorFacade {
|
|
13686
13939
|
#userContentChange = false;
|
|
13687
13940
|
#view;
|
|
@@ -13702,6 +13955,7 @@ class ProseMirrorFacade {
|
|
|
13702
13955
|
};
|
|
13703
13956
|
#handleChangeEvent = () => {
|
|
13704
13957
|
if (!this.#userContentChange) {
|
|
13958
|
+
this.#userContentChange = false;
|
|
13705
13959
|
return;
|
|
13706
13960
|
}
|
|
13707
13961
|
this.#dispatchEvent("change");
|
|
@@ -13713,6 +13967,7 @@ class ProseMirrorFacade {
|
|
|
13713
13967
|
);
|
|
13714
13968
|
}
|
|
13715
13969
|
const plugins = [
|
|
13970
|
+
createPlaceholderPlugin(),
|
|
13716
13971
|
createSelectionChangePlugin(this.#onSelectionChange),
|
|
13717
13972
|
keymap(baseKeymap)
|
|
13718
13973
|
];
|
|
@@ -13724,6 +13979,18 @@ class ProseMirrorFacade {
|
|
|
13724
13979
|
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
13725
13980
|
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
13726
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
|
+
}
|
|
13727
13994
|
replaceContent(content) {
|
|
13728
13995
|
this.#verifyViewInitiation();
|
|
13729
13996
|
const parser = DOMParser.fromSchema(extendedSchema);
|
|
@@ -13774,6 +14041,7 @@ class ProseMirrorFacade {
|
|
|
13774
14041
|
dispatch(tr);
|
|
13775
14042
|
}
|
|
13776
14043
|
setSelectionDecoration(decoration) {
|
|
14044
|
+
this.#verifyViewInitiation();
|
|
13777
14045
|
const SUPPORTED_DECORATIONS = {
|
|
13778
14046
|
bold: "strong",
|
|
13779
14047
|
italics: "em",
|
|
@@ -13781,7 +14049,6 @@ class ProseMirrorFacade {
|
|
|
13781
14049
|
strikethrough: "s",
|
|
13782
14050
|
monospace: "tt"
|
|
13783
14051
|
};
|
|
13784
|
-
this.#verifyViewInitiation();
|
|
13785
14052
|
const { state, dispatch } = this.#view;
|
|
13786
14053
|
const decorationKey = decoration;
|
|
13787
14054
|
const markType = state.schema.marks[SUPPORTED_DECORATIONS[decorationKey]];
|
|
@@ -13789,6 +14056,121 @@ class ProseMirrorFacade {
|
|
|
13789
14056
|
throw new Error(`${decoration} is not a supported decoration`);
|
|
13790
14057
|
}
|
|
13791
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();
|
|
13792
14174
|
}
|
|
13793
14175
|
}
|
|
13794
14176
|
|
|
@@ -13801,7 +14183,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
13801
14183
|
if (result) __defProp(target, key, result);
|
|
13802
14184
|
return result;
|
|
13803
14185
|
};
|
|
13804
|
-
const
|
|
14186
|
+
const RichTextEditorTextBlocks = {
|
|
13805
14187
|
title: "h2",
|
|
13806
14188
|
subtitle: "h3",
|
|
13807
14189
|
body: "p"
|
|
@@ -13821,13 +14203,11 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13821
14203
|
}
|
|
13822
14204
|
};
|
|
13823
14205
|
this.selectionEnd = null;
|
|
13824
|
-
this.#selectionChangedByUser = false;
|
|
13825
14206
|
this.#handleSelectionChange = () => {
|
|
13826
14207
|
if (!this.#editor.selection()) {
|
|
13827
14208
|
return;
|
|
13828
14209
|
}
|
|
13829
14210
|
const { start, end } = this.#editor.selection();
|
|
13830
|
-
this.#selectionChangedByUser = true;
|
|
13831
14211
|
this.selectionStart = start;
|
|
13832
14212
|
this.selectionEnd = end;
|
|
13833
14213
|
this.$emit("selection-changed");
|
|
@@ -13859,9 +14239,6 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13859
14239
|
return this.shadowRoot.querySelector("#editor");
|
|
13860
14240
|
}
|
|
13861
14241
|
selectionStartChanged() {
|
|
13862
|
-
if (this.#selectionChangedByUser) {
|
|
13863
|
-
return;
|
|
13864
|
-
}
|
|
13865
14242
|
if (!this.selectionStart || this.selectionEnd && this.selectionStart > this.selectionEnd) {
|
|
13866
14243
|
return;
|
|
13867
14244
|
}
|
|
@@ -13869,16 +14246,14 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13869
14246
|
}
|
|
13870
14247
|
#updateEditorSelection;
|
|
13871
14248
|
selectionEndChanged() {
|
|
13872
|
-
if (this.#selectionChangedByUser) {
|
|
13873
|
-
this.#selectionChangedByUser = false;
|
|
13874
|
-
return;
|
|
13875
|
-
}
|
|
13876
14249
|
if (this.selectionEnd && !this.selectionStart) {
|
|
13877
14250
|
this.selectionStart = 1;
|
|
13878
14251
|
}
|
|
13879
14252
|
this.#updateEditorSelection();
|
|
13880
14253
|
}
|
|
13881
|
-
|
|
14254
|
+
placeholderChanged() {
|
|
14255
|
+
this.#editor?.updatePlaceholder(this.placeholder);
|
|
14256
|
+
}
|
|
13882
14257
|
#handleSelectionChange;
|
|
13883
14258
|
#handleChange;
|
|
13884
14259
|
#handleInput;
|
|
@@ -13894,12 +14269,13 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13894
14269
|
this.#editor.addEventListener("change", this.#handleChange);
|
|
13895
14270
|
this.#editor.addEventListener("input", this.#handleInput);
|
|
13896
14271
|
}
|
|
14272
|
+
this.placeholderChanged();
|
|
13897
14273
|
}
|
|
13898
|
-
|
|
14274
|
+
setTextBlock(blockType) {
|
|
13899
14275
|
try {
|
|
13900
|
-
this.#editor?.setSelectionTag(
|
|
14276
|
+
this.#editor?.setSelectionTag(RichTextEditorTextBlocks[blockType]);
|
|
13901
14277
|
} catch (e) {
|
|
13902
|
-
console.warn(`Invalid text
|
|
14278
|
+
console.warn(`Invalid text block: ${blockType}`);
|
|
13903
14279
|
}
|
|
13904
14280
|
}
|
|
13905
14281
|
setSelectionDecoration(decoration) {
|
|
@@ -13909,6 +14285,23 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13909
14285
|
console.warn(`Invalid decoration: ${decoration}`);
|
|
13910
14286
|
}
|
|
13911
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
|
+
}
|
|
14297
|
+
focus() {
|
|
14298
|
+
super.focus();
|
|
14299
|
+
setTimeout(() => {
|
|
14300
|
+
this.#editorWrapperElement.querySelector(
|
|
14301
|
+
'[contenteditable="true"]'
|
|
14302
|
+
).focus();
|
|
14303
|
+
}, 0);
|
|
14304
|
+
}
|
|
13912
14305
|
}
|
|
13913
14306
|
__decorateClass([
|
|
13914
14307
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-start" })
|
|
@@ -13916,16 +14309,32 @@ __decorateClass([
|
|
|
13916
14309
|
__decorateClass([
|
|
13917
14310
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-end" })
|
|
13918
14311
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14312
|
+
__decorateClass([
|
|
14313
|
+
vividElement.attr
|
|
14314
|
+
], RichTextEditor.prototype, "placeholder");
|
|
13919
14315
|
|
|
13920
14316
|
const getClasses = (_) => classNames.classNames("control");
|
|
13921
14317
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
13922
|
-
|
|
13923
|
-
|
|
14318
|
+
const menuParent = (target) => target.parentElement;
|
|
14319
|
+
function textBlockSelectedHandler(event) {
|
|
14320
|
+
menuParent(event.target).setTextBlock(
|
|
14321
|
+
event.detail
|
|
14322
|
+
);
|
|
14323
|
+
menuParent(event.target).focus();
|
|
13924
14324
|
}
|
|
13925
14325
|
function selectionDecorationSelectedHandler(event) {
|
|
13926
|
-
|
|
14326
|
+
menuParent(event.target).setSelectionDecoration(
|
|
14327
|
+
event.detail
|
|
14328
|
+
);
|
|
14329
|
+
menuParent(event.target).focus();
|
|
14330
|
+
}
|
|
14331
|
+
function textSizeSelectedHandler(event) {
|
|
14332
|
+
menuParent(event.target).setSelectionTextSize(
|
|
14333
|
+
event.detail
|
|
14334
|
+
);
|
|
14335
|
+
menuParent(event.target).focus();
|
|
13927
14336
|
}
|
|
13928
|
-
function handleMenuBarSlotChange(
|
|
14337
|
+
function handleMenuBarSlotChange(_, { event }) {
|
|
13929
14338
|
const slot = event.target;
|
|
13930
14339
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
13931
14340
|
const menuBar = assignedElements.find(
|
|
@@ -13940,12 +14349,16 @@ function handleMenuBarSlotChange(richTextEditor, { event }) {
|
|
|
13940
14349
|
});
|
|
13941
14350
|
if (menuBar) {
|
|
13942
14351
|
menuBar.addEventListener(
|
|
13943
|
-
"text-
|
|
13944
|
-
|
|
14352
|
+
"text-block-selected",
|
|
14353
|
+
textBlockSelectedHandler
|
|
13945
14354
|
);
|
|
13946
14355
|
menuBar.addEventListener(
|
|
13947
14356
|
"text-decoration-selected",
|
|
13948
|
-
selectionDecorationSelectedHandler
|
|
14357
|
+
selectionDecorationSelectedHandler
|
|
14358
|
+
);
|
|
14359
|
+
menuBar.addEventListener(
|
|
14360
|
+
"text-size-selected",
|
|
14361
|
+
textSizeSelectedHandler
|
|
13949
14362
|
);
|
|
13950
14363
|
}
|
|
13951
14364
|
}
|