@vonage/vivid 4.22.0 → 4.24.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 +1658 -370
- 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 +337 -1
- package/lib/file-picker/locale.d.ts +1 -0
- 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/locale.d.ts +9 -0
- package/lib/rich-text-editor/menubar/consts.d.ts +18 -0
- package/lib/rich-text-editor/menubar/menubar.d.ts +337 -1
- package/lib/rich-text-editor/rich-text-editor.d.ts +10 -0
- package/lib/searchable-select/locale.d.ts +1 -0
- package/lib/searchable-select/option-tag.d.ts +11 -5
- package/lib/searchable-select/searchable-select.d.ts +350 -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/tabs.d.ts +5 -21
- 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/locales/de-DE.cjs +15 -1
- package/locales/de-DE.js +15 -1
- package/locales/en-GB.cjs +15 -1
- package/locales/en-GB.js +15 -1
- package/locales/en-US.cjs +15 -1
- package/locales/en-US.js +15 -1
- package/locales/ja-JP.cjs +15 -1
- package/locales/ja-JP.js +15 -1
- package/locales/zh-CN.cjs +15 -1
- package/locales/zh-CN.js +15 -1
- 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/button.cjs +6 -3
- package/shared/button.js +6 -3
- 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 +5 -2
- package/shared/definition12.js +6 -3
- 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.cjs +4 -1
- package/shared/definition17.js +5 -2
- 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 +11 -4
- package/shared/definition22.js +13 -6
- 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 +19 -3
- package/shared/definition26.js +20 -4
- 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 +558 -134
- package/shared/definition43.js +550 -126
- package/shared/definition44.cjs +83 -10
- package/shared/definition44.js +84 -11
- package/shared/definition45.cjs +20 -8
- package/shared/definition45.js +21 -9
- 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 +219 -297
- package/shared/definition53.js +221 -299
- 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/localization/Locale.d.ts +2 -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 +188 -17
- package/shared/Reflector.cjs +0 -71
- package/shared/Reflector.js +0 -69
package/shared/definition43.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { V as VividElement, a as attr, h as html,
|
|
1
|
+
import { V as VividElement, a as attr, h as html, i as defineVividComponent, n as nullableNumberConverter, g as createRegisterFunction } from './vivid-element.js';
|
|
2
|
+
import { L as Localized } from './localized.js';
|
|
2
3
|
import { B as Button, b as buttonDefinition } from './definition11.js';
|
|
3
4
|
import { D as Divider, d as dividerDefinition } from './definition23.js';
|
|
4
5
|
import { T as Tooltip, t as tooltipDefinition } from './definition60.js';
|
|
5
6
|
import { S as Select, s as selectDefinition } from './definition45.js';
|
|
6
7
|
import { L as ListboxOption } from './option.js';
|
|
7
|
-
import { c as
|
|
8
|
+
import { e as Menu, M as MenuItem, c as menuDefinition, m as menuItemDefinition } from './definition30.js';
|
|
8
9
|
import { r as repeat } from './repeat.js';
|
|
10
|
+
import { c as classNames } from './class-names.js';
|
|
9
11
|
import { l as listboxOptionDefinition } from './definition36.js';
|
|
10
12
|
|
|
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)}";
|
|
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}.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
14
|
|
|
13
|
-
const styles = ":host{display:flex;align-items:center;
|
|
15
|
+
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
16
|
|
|
15
17
|
var __defProp$1 = Object.defineProperty;
|
|
16
18
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
@@ -21,7 +23,39 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
21
23
|
if (result) __defProp$1(target, key, result);
|
|
22
24
|
return result;
|
|
23
25
|
};
|
|
24
|
-
class MenuBar extends VividElement {
|
|
26
|
+
class MenuBar extends Localized(VividElement) {
|
|
27
|
+
get #textEditorElement() {
|
|
28
|
+
return this.parentElement;
|
|
29
|
+
}
|
|
30
|
+
#updateTextStyleState = () => {
|
|
31
|
+
this.dispatchEvent(
|
|
32
|
+
new CustomEvent("text-styles-changed", {
|
|
33
|
+
detail: this.#textEditorElement?.selectionStyles
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
this.#textEditorElement.addEventListener(
|
|
40
|
+
"selection-changed",
|
|
41
|
+
this.#updateTextStyleState
|
|
42
|
+
);
|
|
43
|
+
this.#textEditorElement.addEventListener(
|
|
44
|
+
"change",
|
|
45
|
+
this.#updateTextStyleState
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
disconnectedCallback() {
|
|
49
|
+
super.disconnectedCallback();
|
|
50
|
+
this.#textEditorElement?.removeEventListener(
|
|
51
|
+
"selection-changed",
|
|
52
|
+
this.#updateTextStyleState
|
|
53
|
+
);
|
|
54
|
+
this.#textEditorElement?.removeEventListener(
|
|
55
|
+
"change",
|
|
56
|
+
this.#updateTextStyleState
|
|
57
|
+
);
|
|
58
|
+
}
|
|
25
59
|
}
|
|
26
60
|
__decorateClass$1([
|
|
27
61
|
attr({ attribute: "menu-items" })
|
|
@@ -58,76 +92,91 @@ const TEXT_DECORATION_ITEMS = [
|
|
|
58
92
|
value: "monospace"
|
|
59
93
|
}
|
|
60
94
|
];
|
|
95
|
+
const TEXT_SIZES = [
|
|
96
|
+
{
|
|
97
|
+
text: "Extra Large",
|
|
98
|
+
value: "extra-large"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
text: "Large",
|
|
102
|
+
value: "large"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
text: "Normal",
|
|
106
|
+
value: "normal"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
text: "Small",
|
|
110
|
+
value: "small"
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
const textBlockEventHandler = (event) => {
|
|
114
|
+
const customEvent = event;
|
|
115
|
+
if (!customEvent || !customEvent.detail || customEvent.detail.textBlockType === void 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const menu = customEvent.target;
|
|
119
|
+
menu.shadowRoot.querySelector("#text-block").setAttribute("current-value", customEvent.detail.textBlockType);
|
|
120
|
+
};
|
|
121
|
+
const textDecorationEventHandler = (event) => {
|
|
122
|
+
const customEvent = event;
|
|
123
|
+
if (!customEvent || !customEvent.detail) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const menu = customEvent.target;
|
|
127
|
+
const selectionButtons = menu.shadowRoot.querySelectorAll(
|
|
128
|
+
"#text-decoration .selection-button"
|
|
129
|
+
);
|
|
130
|
+
selectionButtons.forEach((button) => button.removeAttribute("active"));
|
|
131
|
+
customEvent.detail.textDecoration !== void 0 && TEXT_DECORATION_ITEMS.forEach((menuItemConfig, index) => {
|
|
132
|
+
if (customEvent.detail.textDecoration.indexOf(menuItemConfig.value) >= 0) {
|
|
133
|
+
selectionButtons[index].toggleAttribute("active", true);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const textSizeEventHandler = (event) => {
|
|
138
|
+
const customEvent = event;
|
|
139
|
+
if (!customEvent || !customEvent.detail) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const menu = customEvent.target;
|
|
143
|
+
const selectionTextSize = customEvent.detail.textSize ?? "normal";
|
|
144
|
+
const textSizeElements = menu.shadowRoot.querySelectorAll(
|
|
145
|
+
".menubar-selector-menuitem"
|
|
146
|
+
);
|
|
147
|
+
textSizeElements.forEach((textSizeElement) => {
|
|
148
|
+
textSizeElement.toggleAttribute(
|
|
149
|
+
"checked",
|
|
150
|
+
textSizeElement.getAttribute("value") === selectionTextSize
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
};
|
|
61
154
|
const MENU_BAR_ITEMS = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
placement="bottom-end"
|
|
73
|
-
>
|
|
74
|
-
<${tooltipTag} slot="anchor" text="Text Block Type" placement="top">
|
|
75
|
-
<${buttonTag}
|
|
76
|
-
slot="anchor"
|
|
77
|
-
aria-label="Open text block menu"
|
|
78
|
-
size="super-condensed"
|
|
79
|
-
appearance="ghost-light"
|
|
80
|
-
shape="pill"
|
|
81
|
-
icon="text-size-line"
|
|
82
|
-
></${buttonTag}>
|
|
83
|
-
</${tooltipTag}>
|
|
84
|
-
<${menuItemTag}
|
|
85
|
-
text="Title"
|
|
86
|
-
value="title"
|
|
87
|
-
internal-part
|
|
88
|
-
class="title"
|
|
89
|
-
connotation="cta"
|
|
90
|
-
@click="${(_, { parent }) =>
|
|
91
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'title')}"
|
|
92
|
-
></${menuItemTag}>
|
|
93
|
-
<${menuItemTag}
|
|
94
|
-
text="Subtitle"
|
|
95
|
-
value="subtitle"
|
|
96
|
-
internal-part
|
|
97
|
-
class="subtitle"
|
|
98
|
-
connotation="cta"
|
|
99
|
-
@click="${(_, { parent }) =>
|
|
100
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'subtitle')}"
|
|
101
|
-
></${menuItemTag}>
|
|
102
|
-
<${menuItemTag}
|
|
103
|
-
text="Body"
|
|
104
|
-
value="body"
|
|
105
|
-
internal-part
|
|
106
|
-
class="body"
|
|
107
|
-
connotation="cta"
|
|
108
|
-
@click="${(_, { parent }) =>
|
|
109
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'body')}"
|
|
110
|
-
></${menuItemTag}>
|
|
111
|
-
</${menuTag}>
|
|
112
|
-
`;
|
|
113
|
-
},*/
|
|
114
|
-
textBlock: function(context) {
|
|
115
|
-
const selectTag = context.tagFor(Select);
|
|
116
|
-
const optionTag = context.tagFor(ListboxOption);
|
|
117
|
-
const tooltipTag = context.tagFor(Tooltip);
|
|
118
|
-
return html`
|
|
119
|
-
<${tooltipTag} text="Text Block Type" placement="top">
|
|
155
|
+
textBlock: {
|
|
156
|
+
registerStateProperty: function(menuBar) {
|
|
157
|
+
menuBar.addEventListener("text-styles-changed", textBlockEventHandler);
|
|
158
|
+
},
|
|
159
|
+
render: function(context) {
|
|
160
|
+
const selectTag = context.tagFor(Select);
|
|
161
|
+
const optionTag = context.tagFor(ListboxOption);
|
|
162
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
163
|
+
return html`
|
|
164
|
+
<${tooltipTag} text="${(_, { parent }) => parent.locale.richTextEditor.textBlockType}" placement="top">
|
|
120
165
|
<${selectTag}
|
|
166
|
+
scale="condensed"
|
|
167
|
+
shape="rounded"
|
|
168
|
+
appearance="ghost"
|
|
121
169
|
slot="anchor"
|
|
122
170
|
trigger="auto"
|
|
123
171
|
id="text-block"
|
|
124
172
|
aria-label="Text Block"
|
|
125
173
|
placement="bottom-end"
|
|
174
|
+
value="${(_, { parent }) => parent.textBlockType}"
|
|
126
175
|
@change="${(_, { parent, event }) => notifyMenuBarChange(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
176
|
+
parent,
|
|
177
|
+
"text-block-selected",
|
|
178
|
+
event.target.value
|
|
179
|
+
)}"
|
|
131
180
|
>
|
|
132
181
|
<${optionTag}
|
|
133
182
|
text="Title"
|
|
@@ -153,44 +202,115 @@ const MENU_BAR_ITEMS = {
|
|
|
153
202
|
</${selectTag}>
|
|
154
203
|
</${tooltipTag}>
|
|
155
204
|
`;
|
|
205
|
+
}
|
|
156
206
|
},
|
|
157
|
-
textDecoration:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
207
|
+
textDecoration: {
|
|
208
|
+
registerStateProperty: function(menuBar) {
|
|
209
|
+
menuBar.addEventListener(
|
|
210
|
+
"text-styles-changed",
|
|
211
|
+
textDecorationEventHandler
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
render: function(context) {
|
|
215
|
+
const buttonTag = context.tagFor(Button);
|
|
216
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
217
|
+
return html`
|
|
218
|
+
<span id="text-decoration">
|
|
219
|
+
${repeat(
|
|
220
|
+
(_) => TEXT_DECORATION_ITEMS,
|
|
221
|
+
html`
|
|
222
|
+
<${tooltipTag} text="${(x, { parentContext: { parent } }) => parent.locale.richTextEditor[x.value]}" placement="top">
|
|
223
|
+
<${buttonTag}
|
|
224
|
+
class="selection-button"
|
|
225
|
+
slot="anchor"
|
|
226
|
+
aria-label="${(x, { parentContext: { parent } }) => parent.locale.richTextEditor[x.value]}"
|
|
227
|
+
size="super-condensed"
|
|
228
|
+
appearance="ghost-light"
|
|
229
|
+
shape="rounded"
|
|
230
|
+
icon="${(x) => x.icon}"
|
|
231
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
232
|
+
c.parentContext.parent,
|
|
233
|
+
"text-decoration-selected",
|
|
234
|
+
x.value
|
|
235
|
+
)}"')}"
|
|
236
|
+
></${buttonTag}>
|
|
237
|
+
</${tooltipTag}>
|
|
181
238
|
`
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
239
|
+
)}
|
|
240
|
+
</span>
|
|
241
|
+
`;
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
textSize: {
|
|
245
|
+
registerStateProperty: function(menuBar) {
|
|
246
|
+
menuBar.addEventListener("text-styles-changed", textSizeEventHandler);
|
|
247
|
+
},
|
|
248
|
+
render: function(context) {
|
|
249
|
+
const menuTag = context.tagFor(Menu);
|
|
250
|
+
const buttonTag = context.tagFor(Button);
|
|
251
|
+
const tooltipTag = context.tagFor(Tooltip);
|
|
252
|
+
const menuItemTag = context.tagFor(MenuItem);
|
|
253
|
+
return html`
|
|
254
|
+
<${menuTag}
|
|
255
|
+
auto-dismiss
|
|
256
|
+
trigger="auto"
|
|
257
|
+
id="text-size"
|
|
258
|
+
aria-label="Text Size"
|
|
259
|
+
placement="bottom-end"
|
|
260
|
+
>
|
|
261
|
+
<${tooltipTag} slot="anchor" text="${(_, { parent }) => parent.locale.richTextEditor.textSize}" placement="top">
|
|
262
|
+
<${buttonTag}
|
|
263
|
+
slot="anchor"
|
|
264
|
+
aria-label="Open text size menu"
|
|
265
|
+
size="super-condensed"
|
|
266
|
+
appearance="ghost-light"
|
|
267
|
+
shape="pill"
|
|
268
|
+
icon="text-size-line"
|
|
269
|
+
></${buttonTag}>
|
|
270
|
+
</${tooltipTag}>
|
|
271
|
+
${repeat(
|
|
272
|
+
(_) => TEXT_SIZES,
|
|
273
|
+
html`
|
|
274
|
+
<${menuItemTag}
|
|
275
|
+
check-appearance="tick-only"
|
|
276
|
+
role="menuitemcheckbox"
|
|
277
|
+
text="${(x) => x.text}"
|
|
278
|
+
value="${(x) => x.value}"
|
|
279
|
+
internal-part
|
|
280
|
+
class="menubar-selector-menuitem"
|
|
281
|
+
connotation="cta"
|
|
282
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
283
|
+
c.parentContext.parent,
|
|
284
|
+
"text-size-selected",
|
|
285
|
+
x.value
|
|
286
|
+
)}"
|
|
287
|
+
></${menuItemTag}>
|
|
288
|
+
`
|
|
289
|
+
)}
|
|
290
|
+
</${menuTag}>
|
|
291
|
+
`;
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
divider: {
|
|
295
|
+
render: function(context) {
|
|
296
|
+
const dividerTag = context.tagFor(Divider);
|
|
297
|
+
return html`
|
|
298
|
+
<${dividerTag} class="divider" orientation="vertical"></${dividerTag}>
|
|
299
|
+
`;
|
|
300
|
+
}
|
|
185
301
|
}
|
|
186
302
|
};
|
|
303
|
+
|
|
187
304
|
const getClasses$1 = (menuBar) => classNames("control", [
|
|
188
305
|
"hide-menubar",
|
|
189
306
|
getValidMenuItems(menuBar).length === 0
|
|
190
307
|
]);
|
|
191
|
-
const validItems = ["textBlock", "textDecoration"];
|
|
308
|
+
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
309
|
+
function getPropertyStateRgistrationFunction(item) {
|
|
310
|
+
return MENU_BAR_ITEMS[item].registerStateProperty;
|
|
311
|
+
}
|
|
192
312
|
function createMenuItem(item) {
|
|
193
|
-
return MENU_BAR_ITEMS[item];
|
|
313
|
+
return MENU_BAR_ITEMS[item].render;
|
|
194
314
|
}
|
|
195
315
|
function getValidMenuItems({ menuItems }) {
|
|
196
316
|
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
@@ -198,7 +318,10 @@ function getValidMenuItems({ menuItems }) {
|
|
|
198
318
|
function renderMenuItems(context) {
|
|
199
319
|
return () => html`${repeat(
|
|
200
320
|
getValidMenuItems,
|
|
201
|
-
html`${(menuItemName) =>
|
|
321
|
+
html`${(menuItemName, { parent }) => {
|
|
322
|
+
getPropertyStateRgistrationFunction(menuItemName)?.(parent);
|
|
323
|
+
return createMenuItem(menuItemName)(context);
|
|
324
|
+
}}`
|
|
202
325
|
)}`;
|
|
203
326
|
}
|
|
204
327
|
const MenuBarTemplate = (context) => {
|
|
@@ -216,7 +339,9 @@ const menuBarDefinition = defineVividComponent(
|
|
|
216
339
|
selectDefinition,
|
|
217
340
|
listboxOptionDefinition,
|
|
218
341
|
dividerDefinition,
|
|
219
|
-
tooltipDefinition
|
|
342
|
+
tooltipDefinition,
|
|
343
|
+
menuDefinition,
|
|
344
|
+
menuItemDefinition
|
|
220
345
|
],
|
|
221
346
|
{
|
|
222
347
|
styles,
|
|
@@ -3193,7 +3318,7 @@ class ParseContext {
|
|
|
3193
3318
|
value = value.replace(/\r\n?/g, "\n");
|
|
3194
3319
|
}
|
|
3195
3320
|
if (value)
|
|
3196
|
-
this.insertNode(this.parser.schema.text(value), marks);
|
|
3321
|
+
this.insertNode(this.parser.schema.text(value), marks, !/\S/.test(value));
|
|
3197
3322
|
this.findInText(dom);
|
|
3198
3323
|
}
|
|
3199
3324
|
else {
|
|
@@ -3257,7 +3382,7 @@ class ParseContext {
|
|
|
3257
3382
|
ignoreFallback(dom, marks) {
|
|
3258
3383
|
// Ignored BR nodes should at least create an inline context
|
|
3259
3384
|
if (dom.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent))
|
|
3260
|
-
this.findPlace(this.parser.schema.text("-"), marks);
|
|
3385
|
+
this.findPlace(this.parser.schema.text("-"), marks, true);
|
|
3261
3386
|
}
|
|
3262
3387
|
// Run any style parser associated with the node's styles. Either
|
|
3263
3388
|
// return an updated array of marks, or null to indicate some of the
|
|
@@ -3305,7 +3430,7 @@ class ParseContext {
|
|
|
3305
3430
|
marks = inner;
|
|
3306
3431
|
}
|
|
3307
3432
|
}
|
|
3308
|
-
else if (!this.insertNode(nodeType.create(rule.attrs), marks)) {
|
|
3433
|
+
else if (!this.insertNode(nodeType.create(rule.attrs), marks, dom.nodeName == "BR")) {
|
|
3309
3434
|
this.leafFallback(dom, marks);
|
|
3310
3435
|
}
|
|
3311
3436
|
}
|
|
@@ -3322,7 +3447,7 @@ class ParseContext {
|
|
|
3322
3447
|
}
|
|
3323
3448
|
else if (rule.getContent) {
|
|
3324
3449
|
this.findInside(dom);
|
|
3325
|
-
rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node, marks));
|
|
3450
|
+
rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node, marks, false));
|
|
3326
3451
|
}
|
|
3327
3452
|
else {
|
|
3328
3453
|
let contentDOM = dom;
|
|
@@ -3353,19 +3478,22 @@ class ParseContext {
|
|
|
3353
3478
|
// Try to find a way to fit the given node type into the current
|
|
3354
3479
|
// context. May add intermediate wrappers and/or leave non-solid
|
|
3355
3480
|
// nodes that we're in.
|
|
3356
|
-
findPlace(node, marks) {
|
|
3481
|
+
findPlace(node, marks, cautious) {
|
|
3357
3482
|
let route, sync;
|
|
3358
|
-
for (let depth = this.open; depth >= 0; depth--) {
|
|
3483
|
+
for (let depth = this.open, penalty = 0; depth >= 0; depth--) {
|
|
3359
3484
|
let cx = this.nodes[depth];
|
|
3360
3485
|
let found = cx.findWrapping(node);
|
|
3361
|
-
if (found && (!route || route.length > found.length)) {
|
|
3486
|
+
if (found && (!route || route.length > found.length + penalty)) {
|
|
3362
3487
|
route = found;
|
|
3363
3488
|
sync = cx;
|
|
3364
3489
|
if (!found.length)
|
|
3365
3490
|
break;
|
|
3366
3491
|
}
|
|
3367
|
-
if (cx.solid)
|
|
3368
|
-
|
|
3492
|
+
if (cx.solid) {
|
|
3493
|
+
if (cautious)
|
|
3494
|
+
break;
|
|
3495
|
+
penalty += 2;
|
|
3496
|
+
}
|
|
3369
3497
|
}
|
|
3370
3498
|
if (!route)
|
|
3371
3499
|
return null;
|
|
@@ -3375,13 +3503,13 @@ class ParseContext {
|
|
|
3375
3503
|
return marks;
|
|
3376
3504
|
}
|
|
3377
3505
|
// Try to insert the given node, adjusting the context when needed.
|
|
3378
|
-
insertNode(node, marks) {
|
|
3506
|
+
insertNode(node, marks, cautious) {
|
|
3379
3507
|
if (node.isInline && this.needsBlock && !this.top.type) {
|
|
3380
3508
|
let block = this.textblockFromContext();
|
|
3381
3509
|
if (block)
|
|
3382
3510
|
marks = this.enterInner(block, null, marks);
|
|
3383
3511
|
}
|
|
3384
|
-
let innerMarks = this.findPlace(node, marks);
|
|
3512
|
+
let innerMarks = this.findPlace(node, marks, cautious);
|
|
3385
3513
|
if (innerMarks) {
|
|
3386
3514
|
this.closeExtra();
|
|
3387
3515
|
let top = this.top;
|
|
@@ -3399,7 +3527,7 @@ class ParseContext {
|
|
|
3399
3527
|
// Try to start a node of the given type, adjusting the context when
|
|
3400
3528
|
// necessary.
|
|
3401
3529
|
enter(type, attrs, marks, preserveWS) {
|
|
3402
|
-
let innerMarks = this.findPlace(type.create(attrs), marks);
|
|
3530
|
+
let innerMarks = this.findPlace(type.create(attrs), marks, false);
|
|
3403
3531
|
if (innerMarks)
|
|
3404
3532
|
innerMarks = this.enterInner(type, attrs, marks, true, preserveWS);
|
|
3405
3533
|
return innerMarks;
|
|
@@ -4533,7 +4661,7 @@ class ReplaceStep extends Step {
|
|
|
4533
4661
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
4534
4662
|
if (from.deletedAcross && to.deletedAcross)
|
|
4535
4663
|
return null;
|
|
4536
|
-
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
|
|
4664
|
+
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
|
|
4537
4665
|
}
|
|
4538
4666
|
merge(other) {
|
|
4539
4667
|
if (!(other instanceof ReplaceStep) || other.structure || this.structure)
|
|
@@ -5841,19 +5969,26 @@ class Transform {
|
|
|
5841
5969
|
return this;
|
|
5842
5970
|
}
|
|
5843
5971
|
/**
|
|
5844
|
-
Remove a mark (or
|
|
5972
|
+
Remove a mark (or all marks of the given type) from the node at
|
|
5845
5973
|
position `pos`.
|
|
5846
5974
|
*/
|
|
5847
5975
|
removeNodeMark(pos, mark) {
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5976
|
+
let node = this.doc.nodeAt(pos);
|
|
5977
|
+
if (!node)
|
|
5978
|
+
throw new RangeError("No node at position " + pos);
|
|
5979
|
+
if (mark instanceof Mark) {
|
|
5980
|
+
if (mark.isInSet(node.marks))
|
|
5981
|
+
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
5982
|
+
}
|
|
5983
|
+
else {
|
|
5984
|
+
let set = node.marks, found, steps = [];
|
|
5985
|
+
while (found = mark.isInSet(set)) {
|
|
5986
|
+
steps.push(new RemoveNodeMarkStep(pos, found));
|
|
5987
|
+
set = found.removeFromSet(set);
|
|
5988
|
+
}
|
|
5989
|
+
for (let i = steps.length - 1; i >= 0; i--)
|
|
5990
|
+
this.step(steps[i]);
|
|
5855
5991
|
}
|
|
5856
|
-
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
5857
5992
|
return this;
|
|
5858
5993
|
}
|
|
5859
5994
|
/**
|
|
@@ -6873,6 +7008,27 @@ function createKey(name) {
|
|
|
6873
7008
|
keys[name] = 0;
|
|
6874
7009
|
return name + "$";
|
|
6875
7010
|
}
|
|
7011
|
+
/**
|
|
7012
|
+
A key is used to [tag](https://prosemirror.net/docs/ref/#state.PluginSpec.key) plugins in a way
|
|
7013
|
+
that makes it possible to find them, given an editor state.
|
|
7014
|
+
Assigning a key does mean only one plugin of that type can be
|
|
7015
|
+
active in a state.
|
|
7016
|
+
*/
|
|
7017
|
+
class PluginKey {
|
|
7018
|
+
/**
|
|
7019
|
+
Create a plugin key.
|
|
7020
|
+
*/
|
|
7021
|
+
constructor(name = "key") { this.key = createKey(name); }
|
|
7022
|
+
/**
|
|
7023
|
+
Get the active plugin with this key, if any, from an editor
|
|
7024
|
+
state.
|
|
7025
|
+
*/
|
|
7026
|
+
get(state) { return state.config.pluginsByKey[this.key]; }
|
|
7027
|
+
/**
|
|
7028
|
+
Get the plugin's state from an editor state.
|
|
7029
|
+
*/
|
|
7030
|
+
getState(state) { return state[this.key]; }
|
|
7031
|
+
}
|
|
6876
7032
|
|
|
6877
7033
|
const domIndex = function (node) {
|
|
6878
7034
|
for (var index = 0;; index++) {
|
|
@@ -9856,7 +10012,7 @@ function maybeWrapTrusted(html) {
|
|
|
9856
10012
|
// innerHTML, even on a detached document. This wraps the string in
|
|
9857
10013
|
// a way that makes the browser allow us to use its parser again.
|
|
9858
10014
|
if (!_policy)
|
|
9859
|
-
_policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
|
|
10015
|
+
_policy = trustedTypes.defaultPolicy || trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
|
|
9860
10016
|
return _policy.createHTML(html);
|
|
9861
10017
|
}
|
|
9862
10018
|
function readHTML(html) {
|
|
@@ -10547,6 +10703,10 @@ class Dragging {
|
|
|
10547
10703
|
}
|
|
10548
10704
|
}
|
|
10549
10705
|
const dragCopyModifier = mac$3 ? "altKey" : "ctrlKey";
|
|
10706
|
+
function dragMoves(view, event) {
|
|
10707
|
+
let moves = view.someProp("dragCopies", test => !test(event));
|
|
10708
|
+
return moves != null ? moves : !event[dragCopyModifier];
|
|
10709
|
+
}
|
|
10550
10710
|
handlers.dragstart = (view, _event) => {
|
|
10551
10711
|
let event = _event;
|
|
10552
10712
|
let mouseDown = view.input.mouseDown;
|
|
@@ -10576,7 +10736,7 @@ handlers.dragstart = (view, _event) => {
|
|
|
10576
10736
|
event.dataTransfer.effectAllowed = "copyMove";
|
|
10577
10737
|
if (!brokenClipboardAPI)
|
|
10578
10738
|
event.dataTransfer.setData("text/plain", text);
|
|
10579
|
-
view.dragging = new Dragging(slice,
|
|
10739
|
+
view.dragging = new Dragging(slice, dragMoves(view, event), node);
|
|
10580
10740
|
};
|
|
10581
10741
|
handlers.dragend = view => {
|
|
10582
10742
|
let dragging = view.dragging;
|
|
@@ -10603,7 +10763,7 @@ editHandlers.drop = (view, _event) => {
|
|
|
10603
10763
|
else {
|
|
10604
10764
|
slice = parseFromClipboard(view, getText(event.dataTransfer), brokenClipboardAPI ? null : event.dataTransfer.getData("text/html"), false, $mouse);
|
|
10605
10765
|
}
|
|
10606
|
-
let move = !!(dragging &&
|
|
10766
|
+
let move = !!(dragging && dragMoves(view, event));
|
|
10607
10767
|
if (view.someProp("handleDrop", f => f(view, event, slice || Slice.empty, move))) {
|
|
10608
10768
|
event.preventDefault();
|
|
10609
10769
|
return;
|
|
@@ -11888,9 +12048,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
11888
12048
|
// as being an iOS enter press), just dispatch an Enter key instead.
|
|
11889
12049
|
if (((ios && view.input.lastIOSEnter > Date.now() - 225 &&
|
|
11890
12050
|
(!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
|
|
11891
|
-
(!inlineChange && $from.pos < parse.doc.content.size &&
|
|
12051
|
+
(!inlineChange && $from.pos < parse.doc.content.size &&
|
|
12052
|
+
(!$from.sameParent($to) || !$from.parent.inlineContent) &&
|
|
12053
|
+
!/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")) &&
|
|
11892
12054
|
(nextSel = Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) &&
|
|
11893
|
-
nextSel.head
|
|
12055
|
+
nextSel.head > $from.pos)) &&
|
|
11894
12056
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
11895
12057
|
view.input.lastIOSEnter = 0;
|
|
11896
12058
|
return;
|
|
@@ -13231,6 +13393,8 @@ function splitBlockAs(splitNode) {
|
|
|
13231
13393
|
types[0] = deflt ? { type: deflt } : null;
|
|
13232
13394
|
can = canSplit(tr.doc, splitPos, types.length, types);
|
|
13233
13395
|
}
|
|
13396
|
+
if (!can)
|
|
13397
|
+
return false;
|
|
13234
13398
|
tr.split(splitPos, types.length, types);
|
|
13235
13399
|
if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
|
|
13236
13400
|
let first = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first);
|
|
@@ -13654,6 +13818,15 @@ To reuse elements from this schema, extend or read from its
|
|
|
13654
13818
|
*/
|
|
13655
13819
|
const schema = new Schema({ nodes, marks });
|
|
13656
13820
|
|
|
13821
|
+
const TEXT_SIZES_CSS_VARIABLES = {
|
|
13822
|
+
"extra-large": "var(--vvd-typography-heading-4)",
|
|
13823
|
+
large: "var(--vvd-typography-base-extended)",
|
|
13824
|
+
normal: "var(--vvd-typography-base)",
|
|
13825
|
+
small: "var(--vvd-typography-base-condensed)"
|
|
13826
|
+
};
|
|
13827
|
+
const CSS_VARIABLES_TO_SIZES = Object.fromEntries(
|
|
13828
|
+
Object.entries(TEXT_SIZES_CSS_VARIABLES).map(([key, value]) => [value, key])
|
|
13829
|
+
);
|
|
13657
13830
|
const customMarks = {
|
|
13658
13831
|
u: {
|
|
13659
13832
|
parseDOM: [{ tag: "u" }],
|
|
@@ -13672,6 +13845,26 @@ const customMarks = {
|
|
|
13672
13845
|
toDOM() {
|
|
13673
13846
|
return ["tt", 0];
|
|
13674
13847
|
}
|
|
13848
|
+
},
|
|
13849
|
+
textSize: {
|
|
13850
|
+
attrs: { size: { default: "normal" } },
|
|
13851
|
+
parseDOM: [
|
|
13852
|
+
{
|
|
13853
|
+
tag: "span[style*='font']",
|
|
13854
|
+
getAttrs: (node) => {
|
|
13855
|
+
const style = node.getAttribute("style");
|
|
13856
|
+
const fontSize = style.match(/font:\s*([^;]+)/)?.[1]?.trim();
|
|
13857
|
+
const size = CSS_VARIABLES_TO_SIZES[fontSize];
|
|
13858
|
+
if (size) return { size };
|
|
13859
|
+
return false;
|
|
13860
|
+
}
|
|
13861
|
+
}
|
|
13862
|
+
],
|
|
13863
|
+
toDOM(mark) {
|
|
13864
|
+
const size = mark.attrs.size;
|
|
13865
|
+
const fontSize = TEXT_SIZES_CSS_VARIABLES[size] || TEXT_SIZES_CSS_VARIABLES.normal;
|
|
13866
|
+
return ["span", { style: `font: ${fontSize};` }, 0];
|
|
13867
|
+
}
|
|
13675
13868
|
}
|
|
13676
13869
|
};
|
|
13677
13870
|
const extendedSchema = new Schema({
|
|
@@ -13706,6 +13899,57 @@ class TagToSchemaMap {
|
|
|
13706
13899
|
};
|
|
13707
13900
|
}
|
|
13708
13901
|
}
|
|
13902
|
+
function setTextBlockType(styles, type) {
|
|
13903
|
+
if (styles.textBlockType && styles.textBlockType !== type || styles.textBlockType === "") {
|
|
13904
|
+
styles.textBlockType = "";
|
|
13905
|
+
} else {
|
|
13906
|
+
styles.textBlockType = type;
|
|
13907
|
+
}
|
|
13908
|
+
}
|
|
13909
|
+
function createEnterKeymapPlugin() {
|
|
13910
|
+
return keymap({
|
|
13911
|
+
["Shift-Enter"]: (state, dispatch) => {
|
|
13912
|
+
const { schema } = state;
|
|
13913
|
+
const br = schema.nodes.hard_break;
|
|
13914
|
+
const { $from, $to } = state.selection;
|
|
13915
|
+
if ($from.sameParent($to)) {
|
|
13916
|
+
dispatch && dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView());
|
|
13917
|
+
} else {
|
|
13918
|
+
if (dispatch) {
|
|
13919
|
+
const tr = state.tr;
|
|
13920
|
+
const lastSelectionBlock = state.doc.resolve($to.end());
|
|
13921
|
+
tr.delete(lastSelectionBlock.start(), $to.pos);
|
|
13922
|
+
tr.delete($from.pos, lastSelectionBlock.start() - 1);
|
|
13923
|
+
tr.insert($from.pos, br.create());
|
|
13924
|
+
const newSelection = TextSelection.create(tr.doc, $from.pos + 1);
|
|
13925
|
+
tr.setSelection(newSelection);
|
|
13926
|
+
dispatch(tr.scrollIntoView());
|
|
13927
|
+
}
|
|
13928
|
+
}
|
|
13929
|
+
return true;
|
|
13930
|
+
},
|
|
13931
|
+
Enter: (state, dispatch) => {
|
|
13932
|
+
const { schema } = state;
|
|
13933
|
+
const paragraph = schema.nodes.paragraph;
|
|
13934
|
+
const { $from, empty } = state.selection;
|
|
13935
|
+
if (!empty || $from.parent.type !== paragraph) {
|
|
13936
|
+
return false;
|
|
13937
|
+
}
|
|
13938
|
+
const tr = state.tr;
|
|
13939
|
+
const marks = $from.marks();
|
|
13940
|
+
tr.split($from.pos);
|
|
13941
|
+
if (marks.length > 0) {
|
|
13942
|
+
const newParaStart = $from.pos + 1;
|
|
13943
|
+
const zeroWidthSpace = "";
|
|
13944
|
+
const content = schema.text(zeroWidthSpace, marks);
|
|
13945
|
+
tr.insert(newParaStart, content);
|
|
13946
|
+
tr.setSelection(TextSelection.create(tr.doc, newParaStart + 1));
|
|
13947
|
+
}
|
|
13948
|
+
dispatch && dispatch(tr.scrollIntoView());
|
|
13949
|
+
return true;
|
|
13950
|
+
}
|
|
13951
|
+
});
|
|
13952
|
+
}
|
|
13709
13953
|
function createSelectionChangePlugin(onSelectionChange) {
|
|
13710
13954
|
return new Plugin({
|
|
13711
13955
|
view: () => ({
|
|
@@ -13728,6 +13972,30 @@ function convertSelectionToVividFormat({
|
|
|
13728
13972
|
end: to
|
|
13729
13973
|
};
|
|
13730
13974
|
}
|
|
13975
|
+
const isEmptyParagraph = (node) => {
|
|
13976
|
+
return node.type.name === "paragraph" && node.nodeSize === 2;
|
|
13977
|
+
};
|
|
13978
|
+
const DEFAULT_TEXT_EDITOR_PLACEHOLDER = "Start typing...";
|
|
13979
|
+
const placeholderPluginKey = new PluginKey("placeholderPlugin");
|
|
13980
|
+
const createPlaceholderPlugin = (placeholder = DEFAULT_TEXT_EDITOR_PLACEHOLDER) => {
|
|
13981
|
+
return new Plugin({
|
|
13982
|
+
key: placeholderPluginKey,
|
|
13983
|
+
props: {
|
|
13984
|
+
decorations(state) {
|
|
13985
|
+
const { $from } = state.selection;
|
|
13986
|
+
const decorations = [];
|
|
13987
|
+
if (state.doc.childCount === 1 && isEmptyParagraph($from.parent)) {
|
|
13988
|
+
const decoration = Decoration.node($from.before(), $from.after(), {
|
|
13989
|
+
"data-placeholder": placeholder,
|
|
13990
|
+
class: "placeholder"
|
|
13991
|
+
});
|
|
13992
|
+
decorations.push(decoration);
|
|
13993
|
+
}
|
|
13994
|
+
return DecorationSet.create(state.doc, decorations);
|
|
13995
|
+
}
|
|
13996
|
+
}
|
|
13997
|
+
});
|
|
13998
|
+
};
|
|
13731
13999
|
class ProseMirrorFacade {
|
|
13732
14000
|
#userContentChange = false;
|
|
13733
14001
|
#view;
|
|
@@ -13748,6 +14016,7 @@ class ProseMirrorFacade {
|
|
|
13748
14016
|
};
|
|
13749
14017
|
#handleChangeEvent = () => {
|
|
13750
14018
|
if (!this.#userContentChange) {
|
|
14019
|
+
this.#userContentChange = false;
|
|
13751
14020
|
return;
|
|
13752
14021
|
}
|
|
13753
14022
|
this.#dispatchEvent("change");
|
|
@@ -13759,7 +14028,9 @@ class ProseMirrorFacade {
|
|
|
13759
14028
|
);
|
|
13760
14029
|
}
|
|
13761
14030
|
const plugins = [
|
|
14031
|
+
createPlaceholderPlugin(),
|
|
13762
14032
|
createSelectionChangePlugin(this.#onSelectionChange),
|
|
14033
|
+
createEnterKeymapPlugin(),
|
|
13763
14034
|
keymap(baseKeymap)
|
|
13764
14035
|
];
|
|
13765
14036
|
const state = EditorState.create({
|
|
@@ -13770,6 +14041,18 @@ class ProseMirrorFacade {
|
|
|
13770
14041
|
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
13771
14042
|
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
13772
14043
|
}
|
|
14044
|
+
updatePlaceholder(placeholderText) {
|
|
14045
|
+
this.#verifyViewInitiation();
|
|
14046
|
+
const { state } = this.#view;
|
|
14047
|
+
const plugins = state.plugins.filter(
|
|
14048
|
+
(plugin) => plugin !== placeholderPluginKey.get(state)
|
|
14049
|
+
);
|
|
14050
|
+
const newPlaceholderPlugin = createPlaceholderPlugin(placeholderText);
|
|
14051
|
+
const newState = state.reconfigure({
|
|
14052
|
+
plugins: [...plugins, newPlaceholderPlugin]
|
|
14053
|
+
});
|
|
14054
|
+
this.#view.updateState(newState);
|
|
14055
|
+
}
|
|
13773
14056
|
replaceContent(content) {
|
|
13774
14057
|
this.#verifyViewInitiation();
|
|
13775
14058
|
const parser = DOMParser.fromSchema(extendedSchema);
|
|
@@ -13820,6 +14103,7 @@ class ProseMirrorFacade {
|
|
|
13820
14103
|
dispatch(tr);
|
|
13821
14104
|
}
|
|
13822
14105
|
setSelectionDecoration(decoration) {
|
|
14106
|
+
this.#verifyViewInitiation();
|
|
13823
14107
|
const SUPPORTED_DECORATIONS = {
|
|
13824
14108
|
bold: "strong",
|
|
13825
14109
|
italics: "em",
|
|
@@ -13827,7 +14111,6 @@ class ProseMirrorFacade {
|
|
|
13827
14111
|
strikethrough: "s",
|
|
13828
14112
|
monospace: "tt"
|
|
13829
14113
|
};
|
|
13830
|
-
this.#verifyViewInitiation();
|
|
13831
14114
|
const { state, dispatch } = this.#view;
|
|
13832
14115
|
const decorationKey = decoration;
|
|
13833
14116
|
const markType = state.schema.marks[SUPPORTED_DECORATIONS[decorationKey]];
|
|
@@ -13835,6 +14118,121 @@ class ProseMirrorFacade {
|
|
|
13835
14118
|
throw new Error(`${decoration} is not a supported decoration`);
|
|
13836
14119
|
}
|
|
13837
14120
|
toggleMark(markType)(state, dispatch);
|
|
14121
|
+
this.#userContentChange = true;
|
|
14122
|
+
this.#handleChangeEvent();
|
|
14123
|
+
}
|
|
14124
|
+
#getSelectionBlockType() {
|
|
14125
|
+
const { state } = this.#view;
|
|
14126
|
+
const { from, to } = state.selection;
|
|
14127
|
+
const styles = {};
|
|
14128
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14129
|
+
if (node.type.name === "heading" && node.attrs.level === 2) {
|
|
14130
|
+
setTextBlockType(styles, "title");
|
|
14131
|
+
} else if (node.type.name === "heading" && node.attrs.level === 3) {
|
|
14132
|
+
setTextBlockType(styles, "subtitle");
|
|
14133
|
+
} else if (node.type.name === "paragraph") {
|
|
14134
|
+
setTextBlockType(styles, "body");
|
|
14135
|
+
}
|
|
14136
|
+
});
|
|
14137
|
+
return styles.textBlockType;
|
|
14138
|
+
}
|
|
14139
|
+
#getSelectionTextDecoration() {
|
|
14140
|
+
const { state } = this.#view;
|
|
14141
|
+
const { from, to, empty } = state.selection;
|
|
14142
|
+
const decorations = [];
|
|
14143
|
+
if (empty) {
|
|
14144
|
+
const marks = state.doc.resolve(from).marks();
|
|
14145
|
+
if (state.schema.marks.strong && marks.some((mark) => mark.type === state.schema.marks.strong)) {
|
|
14146
|
+
decorations.push("bold");
|
|
14147
|
+
}
|
|
14148
|
+
if (state.schema.marks.em && marks.some((mark) => mark.type === state.schema.marks.em)) {
|
|
14149
|
+
decorations.push("italics");
|
|
14150
|
+
}
|
|
14151
|
+
if (state.schema.marks.u && marks.some((mark) => mark.type === state.schema.marks.u)) {
|
|
14152
|
+
decorations.push("underline");
|
|
14153
|
+
}
|
|
14154
|
+
if (state.schema.marks.s && marks.some((mark) => mark.type === state.schema.marks.s)) {
|
|
14155
|
+
decorations.push("strikethrough");
|
|
14156
|
+
}
|
|
14157
|
+
if (state.schema.marks.tt && marks.some((mark) => mark.type === state.schema.marks.tt)) {
|
|
14158
|
+
decorations.push("monospace");
|
|
14159
|
+
}
|
|
14160
|
+
} else {
|
|
14161
|
+
if (state.schema.marks.strong && state.doc.rangeHasMark(from, to, state.schema.marks.strong)) {
|
|
14162
|
+
decorations.push("bold");
|
|
14163
|
+
}
|
|
14164
|
+
if (state.schema.marks.em && state.doc.rangeHasMark(from, to, state.schema.marks.em)) {
|
|
14165
|
+
decorations.push("italics");
|
|
14166
|
+
}
|
|
14167
|
+
if (state.schema.marks.u && state.doc.rangeHasMark(from, to, state.schema.marks.u)) {
|
|
14168
|
+
decorations.push("underline");
|
|
14169
|
+
}
|
|
14170
|
+
if (state.schema.marks.s && state.doc.rangeHasMark(from, to, state.schema.marks.s)) {
|
|
14171
|
+
decorations.push("strikethrough");
|
|
14172
|
+
}
|
|
14173
|
+
if (state.schema.marks.tt && state.doc.rangeHasMark(from, to, state.schema.marks.tt)) {
|
|
14174
|
+
decorations.push("monospace");
|
|
14175
|
+
}
|
|
14176
|
+
}
|
|
14177
|
+
return decorations.length ? decorations : void 0;
|
|
14178
|
+
}
|
|
14179
|
+
#getSelectionTextSize() {
|
|
14180
|
+
const { state } = this.#view;
|
|
14181
|
+
const { from, to, empty } = state.selection;
|
|
14182
|
+
const defaultSize = "normal";
|
|
14183
|
+
if (empty) {
|
|
14184
|
+
const marks = state.doc.resolve(from).marks();
|
|
14185
|
+
const textSizeMark = marks.find(
|
|
14186
|
+
(mark) => mark.type === state.schema.marks.textSize
|
|
14187
|
+
);
|
|
14188
|
+
return textSizeMark ? textSizeMark.attrs.size : defaultSize;
|
|
14189
|
+
} else {
|
|
14190
|
+
let textSize = null;
|
|
14191
|
+
let foundMixedSizes = false;
|
|
14192
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14193
|
+
if (node.isText) {
|
|
14194
|
+
const mark = node.marks.find(
|
|
14195
|
+
(mark2) => mark2.type === state.schema.marks.textSize
|
|
14196
|
+
);
|
|
14197
|
+
if (mark) {
|
|
14198
|
+
if (textSize === null) {
|
|
14199
|
+
textSize = mark.attrs.size;
|
|
14200
|
+
} else if (textSize !== mark.attrs.size) {
|
|
14201
|
+
foundMixedSizes = true;
|
|
14202
|
+
return false;
|
|
14203
|
+
}
|
|
14204
|
+
} else if (textSize !== null) {
|
|
14205
|
+
foundMixedSizes = true;
|
|
14206
|
+
return false;
|
|
14207
|
+
}
|
|
14208
|
+
}
|
|
14209
|
+
return true;
|
|
14210
|
+
});
|
|
14211
|
+
if (foundMixedSizes) {
|
|
14212
|
+
return "";
|
|
14213
|
+
}
|
|
14214
|
+
return textSize !== null ? textSize : defaultSize;
|
|
14215
|
+
}
|
|
14216
|
+
}
|
|
14217
|
+
getSelectionStyles() {
|
|
14218
|
+
this.#verifyViewInitiation();
|
|
14219
|
+
const styles = {};
|
|
14220
|
+
styles.textBlockType = this.#getSelectionBlockType();
|
|
14221
|
+
styles.textDecoration = this.#getSelectionTextDecoration();
|
|
14222
|
+
styles.textSize = this.#getSelectionTextSize();
|
|
14223
|
+
return styles;
|
|
14224
|
+
}
|
|
14225
|
+
setTextSize(size = "normal") {
|
|
14226
|
+
this.#verifyViewInitiation();
|
|
14227
|
+
const { state, dispatch } = this.#view;
|
|
14228
|
+
const { schema, selection, tr } = state;
|
|
14229
|
+
const { from, to } = selection;
|
|
14230
|
+
const textSizeMark = schema.marks.textSize;
|
|
14231
|
+
tr.removeMark(from, to, textSizeMark);
|
|
14232
|
+
tr.addMark(from, to, textSizeMark.create({ size }));
|
|
14233
|
+
dispatch(tr.scrollIntoView());
|
|
14234
|
+
this.#userContentChange = true;
|
|
14235
|
+
this.#handleChangeEvent();
|
|
13838
14236
|
}
|
|
13839
14237
|
}
|
|
13840
14238
|
|
|
@@ -13915,6 +14313,9 @@ class RichTextEditor extends VividElement {
|
|
|
13915
14313
|
}
|
|
13916
14314
|
this.#updateEditorSelection();
|
|
13917
14315
|
}
|
|
14316
|
+
placeholderChanged() {
|
|
14317
|
+
this.#editor?.updatePlaceholder(this.placeholder);
|
|
14318
|
+
}
|
|
13918
14319
|
#handleSelectionChange;
|
|
13919
14320
|
#handleChange;
|
|
13920
14321
|
#handleInput;
|
|
@@ -13930,6 +14331,7 @@ class RichTextEditor extends VividElement {
|
|
|
13930
14331
|
this.#editor.addEventListener("change", this.#handleChange);
|
|
13931
14332
|
this.#editor.addEventListener("input", this.#handleInput);
|
|
13932
14333
|
}
|
|
14334
|
+
this.placeholderChanged();
|
|
13933
14335
|
}
|
|
13934
14336
|
setTextBlock(blockType) {
|
|
13935
14337
|
try {
|
|
@@ -13945,6 +14347,15 @@ class RichTextEditor extends VividElement {
|
|
|
13945
14347
|
console.warn(`Invalid decoration: ${decoration}`);
|
|
13946
14348
|
}
|
|
13947
14349
|
}
|
|
14350
|
+
setSelectionTextSize(textSize) {
|
|
14351
|
+
this.#editor?.setTextSize(textSize);
|
|
14352
|
+
}
|
|
14353
|
+
get selectionStyles() {
|
|
14354
|
+
if (!this.#editor) {
|
|
14355
|
+
return {};
|
|
14356
|
+
}
|
|
14357
|
+
return this.#editor.getSelectionStyles();
|
|
14358
|
+
}
|
|
13948
14359
|
focus() {
|
|
13949
14360
|
super.focus();
|
|
13950
14361
|
setTimeout(() => {
|
|
@@ -13960,6 +14371,9 @@ __decorateClass([
|
|
|
13960
14371
|
__decorateClass([
|
|
13961
14372
|
attr({ converter: nullableNumberConverter, attribute: "selection-end" })
|
|
13962
14373
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14374
|
+
__decorateClass([
|
|
14375
|
+
attr
|
|
14376
|
+
], RichTextEditor.prototype, "placeholder");
|
|
13963
14377
|
|
|
13964
14378
|
const getClasses = (_) => classNames("control");
|
|
13965
14379
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
@@ -13976,6 +14390,12 @@ function selectionDecorationSelectedHandler(event) {
|
|
|
13976
14390
|
);
|
|
13977
14391
|
menuParent(event.target).focus();
|
|
13978
14392
|
}
|
|
14393
|
+
function textSizeSelectedHandler(event) {
|
|
14394
|
+
menuParent(event.target).setSelectionTextSize(
|
|
14395
|
+
event.detail
|
|
14396
|
+
);
|
|
14397
|
+
menuParent(event.target).focus();
|
|
14398
|
+
}
|
|
13979
14399
|
function handleMenuBarSlotChange(_, { event }) {
|
|
13980
14400
|
const slot = event.target;
|
|
13981
14401
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
@@ -13998,6 +14418,10 @@ function handleMenuBarSlotChange(_, { event }) {
|
|
|
13998
14418
|
"text-decoration-selected",
|
|
13999
14419
|
selectionDecorationSelectedHandler
|
|
14000
14420
|
);
|
|
14421
|
+
menuBar.addEventListener(
|
|
14422
|
+
"text-size-selected",
|
|
14423
|
+
textSizeSelectedHandler
|
|
14424
|
+
);
|
|
14001
14425
|
}
|
|
14002
14426
|
}
|
|
14003
14427
|
const RichTextEditorTemplate = (_) => {
|