@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.cjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vividElement = require('./vivid-element.cjs');
|
|
4
|
-
const
|
|
5
|
-
const definition$
|
|
6
|
-
const definition
|
|
7
|
-
const definition$3 = require('./
|
|
4
|
+
const localized = require('./localized.cjs');
|
|
5
|
+
const definition$2 = require('./definition11.cjs');
|
|
6
|
+
const definition = require('./definition23.cjs');
|
|
7
|
+
const definition$3 = require('./definition60.cjs');
|
|
8
|
+
const definition$4 = require('./definition45.cjs');
|
|
8
9
|
const option = require('./option.cjs');
|
|
9
|
-
const
|
|
10
|
+
const definition$1 = require('./definition30.cjs');
|
|
10
11
|
const repeat = require('./repeat.cjs');
|
|
11
|
-
const
|
|
12
|
+
const classNames = require('./class-names.cjs');
|
|
13
|
+
const definition$5 = require('./definition36.cjs');
|
|
12
14
|
|
|
13
|
-
const styles$1 = "@charset \"UTF-8\";.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:\"\";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-menu{margin:0 -4px;line-height:1}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.ProseMirror-menuitem{margin-right:3px;display:inline-block}.ProseMirror-menuseparator{border-right:1px solid #ddd;margin-right:3px}.ProseMirror-menu-dropdown,.ProseMirror-menu-dropdown-menu{font-size:90%;white-space:nowrap}.ProseMirror-menu-dropdown{vertical-align:1px;cursor:pointer;position:relative;padding-right:15px}.ProseMirror-menu-dropdown-wrap{padding:1px 0 1px 4px;display:inline-block;position:relative}.ProseMirror-menu-dropdown:after{content:\"\";border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 2px)}.ProseMirror-menu-dropdown-menu,.ProseMirror-menu-submenu{position:absolute;background:#fff;color:#666;border:1px solid #aaa;padding:2px}.ProseMirror-menu-dropdown-menu{z-index:15;min-width:6em}.ProseMirror-menu-dropdown-item{cursor:pointer;padding:2px 8px 2px 4px}.ProseMirror-menu-dropdown-item:hover{background:#f2f2f2}.ProseMirror-menu-submenu-wrap{position:relative;margin-right:-4px}.ProseMirror-menu-submenu-label:after{content:\"\";border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 4px)}.ProseMirror-menu-submenu{display:none;min-width:4em;left:100%;top:-3px}.ProseMirror-menu-active{background:#eee;border-radius:4px}.ProseMirror-menu-disabled{opacity:.3}.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu,.ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu{display:block}.ProseMirror-menubar{border-top-left-radius:inherit;border-top-right-radius:inherit;position:relative;min-height:1em;color:#666;padding:1px 6px;top:0;left:0;right:0;border-bottom:1px solid silver;background:#fff;z-index:10;-moz-box-sizing:border-box;box-sizing:border-box;overflow:visible}.ProseMirror-icon{display:inline-block;line-height:.8;vertical-align:-2px;padding:2px 8px;cursor:pointer}.ProseMirror-menu-disabled.ProseMirror-icon{cursor:default}.ProseMirror-icon svg{fill:currentColor;height:1em}.ProseMirror-icon span{vertical-align:text-top}.ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}.ProseMirror-gapcursor:after{content:\"\";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid black;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}.ProseMirror-focused .ProseMirror-gapcursor{display:block}.ProseMirror-example-setup-style hr{padding:2px 10px;border:none;margin:1em 0}.ProseMirror-example-setup-style hr:after{content:\"\";display:block;height:1px;background-color:silver;line-height:2px}.ProseMirror ul,.ProseMirror ol{padding-left:30px}.ProseMirror blockquote{padding-left:1em;border-left:3px solid #eee;margin-left:0;margin-right:0}.ProseMirror-example-setup-style img{cursor:default}.ProseMirror-prompt{background:#fff;padding:5px 10px 5px 15px;border:1px solid silver;position:fixed;border-radius:3px;z-index:11;box-shadow:-.5px 2px 5px #0003}.ProseMirror-prompt h5{margin:0;font-weight:400;font-size:100%;color:#444}.ProseMirror-prompt input[type=text],.ProseMirror-prompt textarea{background:#eee;border:none;outline:none}.ProseMirror-prompt input[type=text]{padding:0 4px}.ProseMirror-prompt-close{position:absolute;left:2px;top:1px;color:#666;border:none;background:transparent;padding:0}.ProseMirror-prompt-close:after{content:\"✕\";font-size:12px}.ProseMirror-invalid{background:#ffc;border:1px solid #cc7;border-radius:4px;padding:5px 10px;position:absolute;min-width:10em}.ProseMirror-prompt-buttons{margin-top:5px;display:none}.editor{box-sizing:border-box;background:var(--vvd-color-canvas);background-clip:padding-box;color:var(--vvd-color-canvas-text)}.ProseMirror{position:relative;box-sizing:border-box;padding:10px 16px;block-size:120px;font:var(--vvd-typography-base);font-feature-settings:\"liga\" 0;font-variant-ligatures:none;line-height:1.2;outline:none;overflow-y:auto;white-space:break-spaces;word-wrap:break-word}.ProseMirror pre{white-space:pre-wrap}.ProseMirror p{margin-bottom:1em}.ProseMirror p:first-child,.ProseMirror h1:first-child,.ProseMirror h2:first-child,.ProseMirror h3:first-child,.ProseMirror h4:first-child,.ProseMirror h5:first-child,.ProseMirror h6:first-child{margin-top:10px}h2{font:var(--vvd-typography-heading-4)}h3{font:var(--vvd-typography-base-extended)}p{font:var(--vvd-typography-base)}";
|
|
15
|
+
const styles$1 = "@charset \"UTF-8\";.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:\"\";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-menu{margin:0 -4px;line-height:1}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.ProseMirror-menuitem{margin-right:3px;display:inline-block}.ProseMirror-menuseparator{border-right:1px solid #ddd;margin-right:3px}.ProseMirror-menu-dropdown,.ProseMirror-menu-dropdown-menu{font-size:90%;white-space:nowrap}.ProseMirror-menu-dropdown{vertical-align:1px;cursor:pointer;position:relative;padding-right:15px}.ProseMirror-menu-dropdown-wrap{padding:1px 0 1px 4px;display:inline-block;position:relative}.ProseMirror-menu-dropdown:after{content:\"\";border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 2px)}.ProseMirror-menu-dropdown-menu,.ProseMirror-menu-submenu{position:absolute;background:#fff;color:#666;border:1px solid #aaa;padding:2px}.ProseMirror-menu-dropdown-menu{z-index:15;min-width:6em}.ProseMirror-menu-dropdown-item{cursor:pointer;padding:2px 8px 2px 4px}.ProseMirror-menu-dropdown-item:hover{background:#f2f2f2}.ProseMirror-menu-submenu-wrap{position:relative;margin-right:-4px}.ProseMirror-menu-submenu-label:after{content:\"\";border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:4px solid currentColor;opacity:.6;position:absolute;right:4px;top:calc(50% - 4px)}.ProseMirror-menu-submenu{display:none;min-width:4em;left:100%;top:-3px}.ProseMirror-menu-active{background:#eee;border-radius:4px}.ProseMirror-menu-disabled{opacity:.3}.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu,.ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu{display:block}.ProseMirror-menubar{border-top-left-radius:inherit;border-top-right-radius:inherit;position:relative;min-height:1em;color:#666;padding:1px 6px;top:0;left:0;right:0;border-bottom:1px solid silver;background:#fff;z-index:10;-moz-box-sizing:border-box;box-sizing:border-box;overflow:visible}.ProseMirror-icon{display:inline-block;line-height:.8;vertical-align:-2px;padding:2px 8px;cursor:pointer}.ProseMirror-menu-disabled.ProseMirror-icon{cursor:default}.ProseMirror-icon svg{fill:currentColor;height:1em}.ProseMirror-icon span{vertical-align:text-top}.ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}.ProseMirror-gapcursor:after{content:\"\";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid black;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}.ProseMirror-focused .ProseMirror-gapcursor{display:block}.ProseMirror-example-setup-style hr{padding:2px 10px;border:none;margin:1em 0}.ProseMirror-example-setup-style hr:after{content:\"\";display:block;height:1px;background-color:silver;line-height:2px}.ProseMirror ul,.ProseMirror ol{padding-left:30px}.ProseMirror blockquote{padding-left:1em;border-left:3px solid #eee;margin-left:0;margin-right:0}.ProseMirror-example-setup-style img{cursor:default}.ProseMirror-prompt{background:#fff;padding:5px 10px 5px 15px;border:1px solid silver;position:fixed;border-radius:3px;z-index:11;box-shadow:-.5px 2px 5px #0003}.ProseMirror-prompt h5{margin:0;font-weight:400;font-size:100%;color:#444}.ProseMirror-prompt input[type=text],.ProseMirror-prompt textarea{background:#eee;border:none;outline:none}.ProseMirror-prompt input[type=text]{padding:0 4px}.ProseMirror-prompt-close{position:absolute;left:2px;top:1px;color:#666;border:none;background:transparent;padding:0}.ProseMirror-prompt-close:after{content:\"✕\";font-size:12px}.ProseMirror-invalid{background:#ffc;border:1px solid #cc7;border-radius:4px;padding:5px 10px;position:absolute;min-width:10em}.ProseMirror-prompt-buttons{margin-top:5px;display:none}.placeholder:before{position:absolute;color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font:var(--vvd-typography-base);pointer-events:none}.editor{box-sizing:border-box;background:var(--vvd-color-canvas);background-clip:padding-box;color:var(--vvd-color-canvas-text)}.ProseMirror{position:relative;box-sizing:border-box;padding:10px 16px;block-size:120px;font:var(--vvd-typography-base);font-feature-settings:\"liga\" 0;font-variant-ligatures:none;line-height:1.2;outline:none;overflow-y:auto;white-space:break-spaces;word-wrap:break-word}.ProseMirror pre{white-space:pre-wrap}.ProseMirror p{margin-bottom:1em}.ProseMirror p:first-child,.ProseMirror h1:first-child,.ProseMirror h2:first-child,.ProseMirror h3:first-child,.ProseMirror h4:first-child,.ProseMirror h5:first-child,.ProseMirror h6:first-child{margin-top:10px}h2{font:var(--vvd-typography-heading-4)}h3{font:var(--vvd-typography-base-extended)}p{font:var(--vvd-typography-base)}";
|
|
14
16
|
|
|
15
|
-
const styles = ":host{display:flex;align-items:center;
|
|
17
|
+
const styles = ":host{display:flex;align-items:center;background-color:var(--vvd-color-neutral-50);gap:4px}:host .hide-menubar{display:none}.title{--_text-primary-custom-size: var(--vvd-typography-heading-4)}.subtitle{--_text-primary-custom-size: var(--vvd-typography-base-extended)}.body{--_text-primary-custom-size: var(--vvd-typography-base)}.divider{height:28px}#text-block{width:104px}";
|
|
16
18
|
|
|
17
19
|
var __defProp$1 = Object.defineProperty;
|
|
18
20
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
@@ -23,7 +25,39 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
|
23
25
|
if (result) __defProp$1(target, key, result);
|
|
24
26
|
return result;
|
|
25
27
|
};
|
|
26
|
-
class MenuBar extends vividElement.VividElement {
|
|
28
|
+
class MenuBar extends localized.Localized(vividElement.VividElement) {
|
|
29
|
+
get #textEditorElement() {
|
|
30
|
+
return this.parentElement;
|
|
31
|
+
}
|
|
32
|
+
#updateTextStyleState = () => {
|
|
33
|
+
this.dispatchEvent(
|
|
34
|
+
new CustomEvent("text-styles-changed", {
|
|
35
|
+
detail: this.#textEditorElement?.selectionStyles
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
super.connectedCallback();
|
|
41
|
+
this.#textEditorElement.addEventListener(
|
|
42
|
+
"selection-changed",
|
|
43
|
+
this.#updateTextStyleState
|
|
44
|
+
);
|
|
45
|
+
this.#textEditorElement.addEventListener(
|
|
46
|
+
"change",
|
|
47
|
+
this.#updateTextStyleState
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
disconnectedCallback() {
|
|
51
|
+
super.disconnectedCallback();
|
|
52
|
+
this.#textEditorElement?.removeEventListener(
|
|
53
|
+
"selection-changed",
|
|
54
|
+
this.#updateTextStyleState
|
|
55
|
+
);
|
|
56
|
+
this.#textEditorElement?.removeEventListener(
|
|
57
|
+
"change",
|
|
58
|
+
this.#updateTextStyleState
|
|
59
|
+
);
|
|
60
|
+
}
|
|
27
61
|
}
|
|
28
62
|
__decorateClass$1([
|
|
29
63
|
vividElement.attr({ attribute: "menu-items" })
|
|
@@ -60,76 +94,91 @@ const TEXT_DECORATION_ITEMS = [
|
|
|
60
94
|
value: "monospace"
|
|
61
95
|
}
|
|
62
96
|
];
|
|
97
|
+
const TEXT_SIZES = [
|
|
98
|
+
{
|
|
99
|
+
text: "Extra Large",
|
|
100
|
+
value: "extra-large"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
text: "Large",
|
|
104
|
+
value: "large"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
text: "Normal",
|
|
108
|
+
value: "normal"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
text: "Small",
|
|
112
|
+
value: "small"
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
const textBlockEventHandler = (event) => {
|
|
116
|
+
const customEvent = event;
|
|
117
|
+
if (!customEvent || !customEvent.detail || customEvent.detail.textBlockType === void 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const menu = customEvent.target;
|
|
121
|
+
menu.shadowRoot.querySelector("#text-block").setAttribute("current-value", customEvent.detail.textBlockType);
|
|
122
|
+
};
|
|
123
|
+
const textDecorationEventHandler = (event) => {
|
|
124
|
+
const customEvent = event;
|
|
125
|
+
if (!customEvent || !customEvent.detail) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const menu = customEvent.target;
|
|
129
|
+
const selectionButtons = menu.shadowRoot.querySelectorAll(
|
|
130
|
+
"#text-decoration .selection-button"
|
|
131
|
+
);
|
|
132
|
+
selectionButtons.forEach((button) => button.removeAttribute("active"));
|
|
133
|
+
customEvent.detail.textDecoration !== void 0 && TEXT_DECORATION_ITEMS.forEach((menuItemConfig, index) => {
|
|
134
|
+
if (customEvent.detail.textDecoration.indexOf(menuItemConfig.value) >= 0) {
|
|
135
|
+
selectionButtons[index].toggleAttribute("active", true);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
const textSizeEventHandler = (event) => {
|
|
140
|
+
const customEvent = event;
|
|
141
|
+
if (!customEvent || !customEvent.detail) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const menu = customEvent.target;
|
|
145
|
+
const selectionTextSize = customEvent.detail.textSize ?? "normal";
|
|
146
|
+
const textSizeElements = menu.shadowRoot.querySelectorAll(
|
|
147
|
+
".menubar-selector-menuitem"
|
|
148
|
+
);
|
|
149
|
+
textSizeElements.forEach((textSizeElement) => {
|
|
150
|
+
textSizeElement.toggleAttribute(
|
|
151
|
+
"checked",
|
|
152
|
+
textSizeElement.getAttribute("value") === selectionTextSize
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
};
|
|
63
156
|
const MENU_BAR_ITEMS = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
placement="bottom-end"
|
|
75
|
-
>
|
|
76
|
-
<${tooltipTag} slot="anchor" text="Text Block Type" placement="top">
|
|
77
|
-
<${buttonTag}
|
|
78
|
-
slot="anchor"
|
|
79
|
-
aria-label="Open text block menu"
|
|
80
|
-
size="super-condensed"
|
|
81
|
-
appearance="ghost-light"
|
|
82
|
-
shape="pill"
|
|
83
|
-
icon="text-size-line"
|
|
84
|
-
></${buttonTag}>
|
|
85
|
-
</${tooltipTag}>
|
|
86
|
-
<${menuItemTag}
|
|
87
|
-
text="Title"
|
|
88
|
-
value="title"
|
|
89
|
-
internal-part
|
|
90
|
-
class="title"
|
|
91
|
-
connotation="cta"
|
|
92
|
-
@click="${(_, { parent }) =>
|
|
93
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'title')}"
|
|
94
|
-
></${menuItemTag}>
|
|
95
|
-
<${menuItemTag}
|
|
96
|
-
text="Subtitle"
|
|
97
|
-
value="subtitle"
|
|
98
|
-
internal-part
|
|
99
|
-
class="subtitle"
|
|
100
|
-
connotation="cta"
|
|
101
|
-
@click="${(_, { parent }) =>
|
|
102
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'subtitle')}"
|
|
103
|
-
></${menuItemTag}>
|
|
104
|
-
<${menuItemTag}
|
|
105
|
-
text="Body"
|
|
106
|
-
value="body"
|
|
107
|
-
internal-part
|
|
108
|
-
class="body"
|
|
109
|
-
connotation="cta"
|
|
110
|
-
@click="${(_, { parent }) =>
|
|
111
|
-
notifyMenuBarChange(parent, 'text-block-selected', 'body')}"
|
|
112
|
-
></${menuItemTag}>
|
|
113
|
-
</${menuTag}>
|
|
114
|
-
`;
|
|
115
|
-
},*/
|
|
116
|
-
textBlock: function(context) {
|
|
117
|
-
const selectTag = context.tagFor(definition$3.Select);
|
|
118
|
-
const optionTag = context.tagFor(option.ListboxOption);
|
|
119
|
-
const tooltipTag = context.tagFor(definition$2.Tooltip);
|
|
120
|
-
return vividElement.html`
|
|
121
|
-
<${tooltipTag} text="Text Block Type" placement="top">
|
|
157
|
+
textBlock: {
|
|
158
|
+
registerStateProperty: function(menuBar) {
|
|
159
|
+
menuBar.addEventListener("text-styles-changed", textBlockEventHandler);
|
|
160
|
+
},
|
|
161
|
+
render: function(context) {
|
|
162
|
+
const selectTag = context.tagFor(definition$4.Select);
|
|
163
|
+
const optionTag = context.tagFor(option.ListboxOption);
|
|
164
|
+
const tooltipTag = context.tagFor(definition$3.Tooltip);
|
|
165
|
+
return vividElement.html`
|
|
166
|
+
<${tooltipTag} text="${(_, { parent }) => parent.locale.richTextEditor.textBlockType}" placement="top">
|
|
122
167
|
<${selectTag}
|
|
168
|
+
scale="condensed"
|
|
169
|
+
shape="rounded"
|
|
170
|
+
appearance="ghost"
|
|
123
171
|
slot="anchor"
|
|
124
172
|
trigger="auto"
|
|
125
173
|
id="text-block"
|
|
126
174
|
aria-label="Text Block"
|
|
127
175
|
placement="bottom-end"
|
|
176
|
+
value="${(_, { parent }) => parent.textBlockType}"
|
|
128
177
|
@change="${(_, { parent, event }) => notifyMenuBarChange(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
178
|
+
parent,
|
|
179
|
+
"text-block-selected",
|
|
180
|
+
event.target.value
|
|
181
|
+
)}"
|
|
133
182
|
>
|
|
134
183
|
<${optionTag}
|
|
135
184
|
text="Title"
|
|
@@ -155,44 +204,115 @@ const MENU_BAR_ITEMS = {
|
|
|
155
204
|
</${selectTag}>
|
|
156
205
|
</${tooltipTag}>
|
|
157
206
|
`;
|
|
207
|
+
}
|
|
158
208
|
},
|
|
159
|
-
textDecoration:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
209
|
+
textDecoration: {
|
|
210
|
+
registerStateProperty: function(menuBar) {
|
|
211
|
+
menuBar.addEventListener(
|
|
212
|
+
"text-styles-changed",
|
|
213
|
+
textDecorationEventHandler
|
|
214
|
+
);
|
|
215
|
+
},
|
|
216
|
+
render: function(context) {
|
|
217
|
+
const buttonTag = context.tagFor(definition$2.Button);
|
|
218
|
+
const tooltipTag = context.tagFor(definition$3.Tooltip);
|
|
219
|
+
return vividElement.html`
|
|
220
|
+
<span id="text-decoration">
|
|
221
|
+
${repeat.repeat(
|
|
222
|
+
(_) => TEXT_DECORATION_ITEMS,
|
|
223
|
+
vividElement.html`
|
|
224
|
+
<${tooltipTag} text="${(x, { parentContext: { parent } }) => parent.locale.richTextEditor[x.value]}" placement="top">
|
|
225
|
+
<${buttonTag}
|
|
226
|
+
class="selection-button"
|
|
227
|
+
slot="anchor"
|
|
228
|
+
aria-label="${(x, { parentContext: { parent } }) => parent.locale.richTextEditor[x.value]}"
|
|
229
|
+
size="super-condensed"
|
|
230
|
+
appearance="ghost-light"
|
|
231
|
+
shape="rounded"
|
|
232
|
+
icon="${(x) => x.icon}"
|
|
233
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
234
|
+
c.parentContext.parent,
|
|
235
|
+
"text-decoration-selected",
|
|
236
|
+
x.value
|
|
237
|
+
)}"')}"
|
|
238
|
+
></${buttonTag}>
|
|
239
|
+
</${tooltipTag}>
|
|
183
240
|
`
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
241
|
+
)}
|
|
242
|
+
</span>
|
|
243
|
+
`;
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
textSize: {
|
|
247
|
+
registerStateProperty: function(menuBar) {
|
|
248
|
+
menuBar.addEventListener("text-styles-changed", textSizeEventHandler);
|
|
249
|
+
},
|
|
250
|
+
render: function(context) {
|
|
251
|
+
const menuTag = context.tagFor(definition$1.Menu);
|
|
252
|
+
const buttonTag = context.tagFor(definition$2.Button);
|
|
253
|
+
const tooltipTag = context.tagFor(definition$3.Tooltip);
|
|
254
|
+
const menuItemTag = context.tagFor(definition$1.MenuItem);
|
|
255
|
+
return vividElement.html`
|
|
256
|
+
<${menuTag}
|
|
257
|
+
auto-dismiss
|
|
258
|
+
trigger="auto"
|
|
259
|
+
id="text-size"
|
|
260
|
+
aria-label="Text Size"
|
|
261
|
+
placement="bottom-end"
|
|
262
|
+
>
|
|
263
|
+
<${tooltipTag} slot="anchor" text="${(_, { parent }) => parent.locale.richTextEditor.textSize}" placement="top">
|
|
264
|
+
<${buttonTag}
|
|
265
|
+
slot="anchor"
|
|
266
|
+
aria-label="Open text size menu"
|
|
267
|
+
size="super-condensed"
|
|
268
|
+
appearance="ghost-light"
|
|
269
|
+
shape="pill"
|
|
270
|
+
icon="text-size-line"
|
|
271
|
+
></${buttonTag}>
|
|
272
|
+
</${tooltipTag}>
|
|
273
|
+
${repeat.repeat(
|
|
274
|
+
(_) => TEXT_SIZES,
|
|
275
|
+
vividElement.html`
|
|
276
|
+
<${menuItemTag}
|
|
277
|
+
check-appearance="tick-only"
|
|
278
|
+
role="menuitemcheckbox"
|
|
279
|
+
text="${(x) => x.text}"
|
|
280
|
+
value="${(x) => x.value}"
|
|
281
|
+
internal-part
|
|
282
|
+
class="menubar-selector-menuitem"
|
|
283
|
+
connotation="cta"
|
|
284
|
+
@click="${(x, c) => notifyMenuBarChange(
|
|
285
|
+
c.parentContext.parent,
|
|
286
|
+
"text-size-selected",
|
|
287
|
+
x.value
|
|
288
|
+
)}"
|
|
289
|
+
></${menuItemTag}>
|
|
290
|
+
`
|
|
291
|
+
)}
|
|
292
|
+
</${menuTag}>
|
|
293
|
+
`;
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
divider: {
|
|
297
|
+
render: function(context) {
|
|
298
|
+
const dividerTag = context.tagFor(definition.Divider);
|
|
299
|
+
return vividElement.html`
|
|
300
|
+
<${dividerTag} class="divider" orientation="vertical"></${dividerTag}>
|
|
301
|
+
`;
|
|
302
|
+
}
|
|
187
303
|
}
|
|
188
304
|
};
|
|
305
|
+
|
|
189
306
|
const getClasses$1 = (menuBar) => classNames.classNames("control", [
|
|
190
307
|
"hide-menubar",
|
|
191
308
|
getValidMenuItems(menuBar).length === 0
|
|
192
309
|
]);
|
|
193
|
-
const validItems = ["textBlock", "textDecoration"];
|
|
310
|
+
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
311
|
+
function getPropertyStateRgistrationFunction(item) {
|
|
312
|
+
return MENU_BAR_ITEMS[item].registerStateProperty;
|
|
313
|
+
}
|
|
194
314
|
function createMenuItem(item) {
|
|
195
|
-
return MENU_BAR_ITEMS[item];
|
|
315
|
+
return MENU_BAR_ITEMS[item].render;
|
|
196
316
|
}
|
|
197
317
|
function getValidMenuItems({ menuItems }) {
|
|
198
318
|
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
@@ -200,7 +320,10 @@ function getValidMenuItems({ menuItems }) {
|
|
|
200
320
|
function renderMenuItems(context) {
|
|
201
321
|
return () => vividElement.html`${repeat.repeat(
|
|
202
322
|
getValidMenuItems,
|
|
203
|
-
vividElement.html`${(menuItemName) =>
|
|
323
|
+
vividElement.html`${(menuItemName, { parent }) => {
|
|
324
|
+
getPropertyStateRgistrationFunction(menuItemName)?.(parent);
|
|
325
|
+
return createMenuItem(menuItemName)(context);
|
|
326
|
+
}}`
|
|
204
327
|
)}`;
|
|
205
328
|
}
|
|
206
329
|
const MenuBarTemplate = (context) => {
|
|
@@ -214,11 +337,13 @@ const menuBarDefinition = vividElement.defineVividComponent(
|
|
|
214
337
|
MenuBar,
|
|
215
338
|
MenuBarTemplate,
|
|
216
339
|
[
|
|
217
|
-
definition.buttonDefinition,
|
|
218
|
-
definition$
|
|
219
|
-
definition$
|
|
220
|
-
definition
|
|
221
|
-
definition$
|
|
340
|
+
definition$2.buttonDefinition,
|
|
341
|
+
definition$4.selectDefinition,
|
|
342
|
+
definition$5.listboxOptionDefinition,
|
|
343
|
+
definition.dividerDefinition,
|
|
344
|
+
definition$3.tooltipDefinition,
|
|
345
|
+
definition$1.menuDefinition,
|
|
346
|
+
definition$1.menuItemDefinition
|
|
222
347
|
],
|
|
223
348
|
{
|
|
224
349
|
styles,
|
|
@@ -3195,7 +3320,7 @@ class ParseContext {
|
|
|
3195
3320
|
value = value.replace(/\r\n?/g, "\n");
|
|
3196
3321
|
}
|
|
3197
3322
|
if (value)
|
|
3198
|
-
this.insertNode(this.parser.schema.text(value), marks);
|
|
3323
|
+
this.insertNode(this.parser.schema.text(value), marks, !/\S/.test(value));
|
|
3199
3324
|
this.findInText(dom);
|
|
3200
3325
|
}
|
|
3201
3326
|
else {
|
|
@@ -3259,7 +3384,7 @@ class ParseContext {
|
|
|
3259
3384
|
ignoreFallback(dom, marks) {
|
|
3260
3385
|
// Ignored BR nodes should at least create an inline context
|
|
3261
3386
|
if (dom.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent))
|
|
3262
|
-
this.findPlace(this.parser.schema.text("-"), marks);
|
|
3387
|
+
this.findPlace(this.parser.schema.text("-"), marks, true);
|
|
3263
3388
|
}
|
|
3264
3389
|
// Run any style parser associated with the node's styles. Either
|
|
3265
3390
|
// return an updated array of marks, or null to indicate some of the
|
|
@@ -3307,7 +3432,7 @@ class ParseContext {
|
|
|
3307
3432
|
marks = inner;
|
|
3308
3433
|
}
|
|
3309
3434
|
}
|
|
3310
|
-
else if (!this.insertNode(nodeType.create(rule.attrs), marks)) {
|
|
3435
|
+
else if (!this.insertNode(nodeType.create(rule.attrs), marks, dom.nodeName == "BR")) {
|
|
3311
3436
|
this.leafFallback(dom, marks);
|
|
3312
3437
|
}
|
|
3313
3438
|
}
|
|
@@ -3324,7 +3449,7 @@ class ParseContext {
|
|
|
3324
3449
|
}
|
|
3325
3450
|
else if (rule.getContent) {
|
|
3326
3451
|
this.findInside(dom);
|
|
3327
|
-
rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node, marks));
|
|
3452
|
+
rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node, marks, false));
|
|
3328
3453
|
}
|
|
3329
3454
|
else {
|
|
3330
3455
|
let contentDOM = dom;
|
|
@@ -3355,19 +3480,22 @@ class ParseContext {
|
|
|
3355
3480
|
// Try to find a way to fit the given node type into the current
|
|
3356
3481
|
// context. May add intermediate wrappers and/or leave non-solid
|
|
3357
3482
|
// nodes that we're in.
|
|
3358
|
-
findPlace(node, marks) {
|
|
3483
|
+
findPlace(node, marks, cautious) {
|
|
3359
3484
|
let route, sync;
|
|
3360
|
-
for (let depth = this.open; depth >= 0; depth--) {
|
|
3485
|
+
for (let depth = this.open, penalty = 0; depth >= 0; depth--) {
|
|
3361
3486
|
let cx = this.nodes[depth];
|
|
3362
3487
|
let found = cx.findWrapping(node);
|
|
3363
|
-
if (found && (!route || route.length > found.length)) {
|
|
3488
|
+
if (found && (!route || route.length > found.length + penalty)) {
|
|
3364
3489
|
route = found;
|
|
3365
3490
|
sync = cx;
|
|
3366
3491
|
if (!found.length)
|
|
3367
3492
|
break;
|
|
3368
3493
|
}
|
|
3369
|
-
if (cx.solid)
|
|
3370
|
-
|
|
3494
|
+
if (cx.solid) {
|
|
3495
|
+
if (cautious)
|
|
3496
|
+
break;
|
|
3497
|
+
penalty += 2;
|
|
3498
|
+
}
|
|
3371
3499
|
}
|
|
3372
3500
|
if (!route)
|
|
3373
3501
|
return null;
|
|
@@ -3377,13 +3505,13 @@ class ParseContext {
|
|
|
3377
3505
|
return marks;
|
|
3378
3506
|
}
|
|
3379
3507
|
// Try to insert the given node, adjusting the context when needed.
|
|
3380
|
-
insertNode(node, marks) {
|
|
3508
|
+
insertNode(node, marks, cautious) {
|
|
3381
3509
|
if (node.isInline && this.needsBlock && !this.top.type) {
|
|
3382
3510
|
let block = this.textblockFromContext();
|
|
3383
3511
|
if (block)
|
|
3384
3512
|
marks = this.enterInner(block, null, marks);
|
|
3385
3513
|
}
|
|
3386
|
-
let innerMarks = this.findPlace(node, marks);
|
|
3514
|
+
let innerMarks = this.findPlace(node, marks, cautious);
|
|
3387
3515
|
if (innerMarks) {
|
|
3388
3516
|
this.closeExtra();
|
|
3389
3517
|
let top = this.top;
|
|
@@ -3401,7 +3529,7 @@ class ParseContext {
|
|
|
3401
3529
|
// Try to start a node of the given type, adjusting the context when
|
|
3402
3530
|
// necessary.
|
|
3403
3531
|
enter(type, attrs, marks, preserveWS) {
|
|
3404
|
-
let innerMarks = this.findPlace(type.create(attrs), marks);
|
|
3532
|
+
let innerMarks = this.findPlace(type.create(attrs), marks, false);
|
|
3405
3533
|
if (innerMarks)
|
|
3406
3534
|
innerMarks = this.enterInner(type, attrs, marks, true, preserveWS);
|
|
3407
3535
|
return innerMarks;
|
|
@@ -4535,7 +4663,7 @@ class ReplaceStep extends Step {
|
|
|
4535
4663
|
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
|
|
4536
4664
|
if (from.deletedAcross && to.deletedAcross)
|
|
4537
4665
|
return null;
|
|
4538
|
-
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
|
|
4666
|
+
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
|
|
4539
4667
|
}
|
|
4540
4668
|
merge(other) {
|
|
4541
4669
|
if (!(other instanceof ReplaceStep) || other.structure || this.structure)
|
|
@@ -5843,19 +5971,26 @@ class Transform {
|
|
|
5843
5971
|
return this;
|
|
5844
5972
|
}
|
|
5845
5973
|
/**
|
|
5846
|
-
Remove a mark (or
|
|
5974
|
+
Remove a mark (or all marks of the given type) from the node at
|
|
5847
5975
|
position `pos`.
|
|
5848
5976
|
*/
|
|
5849
5977
|
removeNodeMark(pos, mark) {
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5978
|
+
let node = this.doc.nodeAt(pos);
|
|
5979
|
+
if (!node)
|
|
5980
|
+
throw new RangeError("No node at position " + pos);
|
|
5981
|
+
if (mark instanceof Mark) {
|
|
5982
|
+
if (mark.isInSet(node.marks))
|
|
5983
|
+
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
5984
|
+
}
|
|
5985
|
+
else {
|
|
5986
|
+
let set = node.marks, found, steps = [];
|
|
5987
|
+
while (found = mark.isInSet(set)) {
|
|
5988
|
+
steps.push(new RemoveNodeMarkStep(pos, found));
|
|
5989
|
+
set = found.removeFromSet(set);
|
|
5990
|
+
}
|
|
5991
|
+
for (let i = steps.length - 1; i >= 0; i--)
|
|
5992
|
+
this.step(steps[i]);
|
|
5857
5993
|
}
|
|
5858
|
-
this.step(new RemoveNodeMarkStep(pos, mark));
|
|
5859
5994
|
return this;
|
|
5860
5995
|
}
|
|
5861
5996
|
/**
|
|
@@ -6875,6 +7010,27 @@ function createKey(name) {
|
|
|
6875
7010
|
keys[name] = 0;
|
|
6876
7011
|
return name + "$";
|
|
6877
7012
|
}
|
|
7013
|
+
/**
|
|
7014
|
+
A key is used to [tag](https://prosemirror.net/docs/ref/#state.PluginSpec.key) plugins in a way
|
|
7015
|
+
that makes it possible to find them, given an editor state.
|
|
7016
|
+
Assigning a key does mean only one plugin of that type can be
|
|
7017
|
+
active in a state.
|
|
7018
|
+
*/
|
|
7019
|
+
class PluginKey {
|
|
7020
|
+
/**
|
|
7021
|
+
Create a plugin key.
|
|
7022
|
+
*/
|
|
7023
|
+
constructor(name = "key") { this.key = createKey(name); }
|
|
7024
|
+
/**
|
|
7025
|
+
Get the active plugin with this key, if any, from an editor
|
|
7026
|
+
state.
|
|
7027
|
+
*/
|
|
7028
|
+
get(state) { return state.config.pluginsByKey[this.key]; }
|
|
7029
|
+
/**
|
|
7030
|
+
Get the plugin's state from an editor state.
|
|
7031
|
+
*/
|
|
7032
|
+
getState(state) { return state[this.key]; }
|
|
7033
|
+
}
|
|
6878
7034
|
|
|
6879
7035
|
const domIndex = function (node) {
|
|
6880
7036
|
for (var index = 0;; index++) {
|
|
@@ -9858,7 +10014,7 @@ function maybeWrapTrusted(html) {
|
|
|
9858
10014
|
// innerHTML, even on a detached document. This wraps the string in
|
|
9859
10015
|
// a way that makes the browser allow us to use its parser again.
|
|
9860
10016
|
if (!_policy)
|
|
9861
|
-
_policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
|
|
10017
|
+
_policy = trustedTypes.defaultPolicy || trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
|
|
9862
10018
|
return _policy.createHTML(html);
|
|
9863
10019
|
}
|
|
9864
10020
|
function readHTML(html) {
|
|
@@ -10549,6 +10705,10 @@ class Dragging {
|
|
|
10549
10705
|
}
|
|
10550
10706
|
}
|
|
10551
10707
|
const dragCopyModifier = mac$3 ? "altKey" : "ctrlKey";
|
|
10708
|
+
function dragMoves(view, event) {
|
|
10709
|
+
let moves = view.someProp("dragCopies", test => !test(event));
|
|
10710
|
+
return moves != null ? moves : !event[dragCopyModifier];
|
|
10711
|
+
}
|
|
10552
10712
|
handlers.dragstart = (view, _event) => {
|
|
10553
10713
|
let event = _event;
|
|
10554
10714
|
let mouseDown = view.input.mouseDown;
|
|
@@ -10578,7 +10738,7 @@ handlers.dragstart = (view, _event) => {
|
|
|
10578
10738
|
event.dataTransfer.effectAllowed = "copyMove";
|
|
10579
10739
|
if (!brokenClipboardAPI)
|
|
10580
10740
|
event.dataTransfer.setData("text/plain", text);
|
|
10581
|
-
view.dragging = new Dragging(slice,
|
|
10741
|
+
view.dragging = new Dragging(slice, dragMoves(view, event), node);
|
|
10582
10742
|
};
|
|
10583
10743
|
handlers.dragend = view => {
|
|
10584
10744
|
let dragging = view.dragging;
|
|
@@ -10605,7 +10765,7 @@ editHandlers.drop = (view, _event) => {
|
|
|
10605
10765
|
else {
|
|
10606
10766
|
slice = parseFromClipboard(view, getText(event.dataTransfer), brokenClipboardAPI ? null : event.dataTransfer.getData("text/html"), false, $mouse);
|
|
10607
10767
|
}
|
|
10608
|
-
let move = !!(dragging &&
|
|
10768
|
+
let move = !!(dragging && dragMoves(view, event));
|
|
10609
10769
|
if (view.someProp("handleDrop", f => f(view, event, slice || Slice.empty, move))) {
|
|
10610
10770
|
event.preventDefault();
|
|
10611
10771
|
return;
|
|
@@ -11890,9 +12050,11 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
11890
12050
|
// as being an iOS enter press), just dispatch an Enter key instead.
|
|
11891
12051
|
if (((ios && view.input.lastIOSEnter > Date.now() - 225 &&
|
|
11892
12052
|
(!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
|
|
11893
|
-
(!inlineChange && $from.pos < parse.doc.content.size &&
|
|
12053
|
+
(!inlineChange && $from.pos < parse.doc.content.size &&
|
|
12054
|
+
(!$from.sameParent($to) || !$from.parent.inlineContent) &&
|
|
12055
|
+
!/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")) &&
|
|
11894
12056
|
(nextSel = Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) &&
|
|
11895
|
-
nextSel.head
|
|
12057
|
+
nextSel.head > $from.pos)) &&
|
|
11896
12058
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
11897
12059
|
view.input.lastIOSEnter = 0;
|
|
11898
12060
|
return;
|
|
@@ -13233,6 +13395,8 @@ function splitBlockAs(splitNode) {
|
|
|
13233
13395
|
types[0] = deflt ? { type: deflt } : null;
|
|
13234
13396
|
can = canSplit(tr.doc, splitPos, types.length, types);
|
|
13235
13397
|
}
|
|
13398
|
+
if (!can)
|
|
13399
|
+
return false;
|
|
13236
13400
|
tr.split(splitPos, types.length, types);
|
|
13237
13401
|
if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
|
|
13238
13402
|
let first = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first);
|
|
@@ -13656,6 +13820,15 @@ To reuse elements from this schema, extend or read from its
|
|
|
13656
13820
|
*/
|
|
13657
13821
|
const schema = new Schema({ nodes, marks });
|
|
13658
13822
|
|
|
13823
|
+
const TEXT_SIZES_CSS_VARIABLES = {
|
|
13824
|
+
"extra-large": "var(--vvd-typography-heading-4)",
|
|
13825
|
+
large: "var(--vvd-typography-base-extended)",
|
|
13826
|
+
normal: "var(--vvd-typography-base)",
|
|
13827
|
+
small: "var(--vvd-typography-base-condensed)"
|
|
13828
|
+
};
|
|
13829
|
+
const CSS_VARIABLES_TO_SIZES = Object.fromEntries(
|
|
13830
|
+
Object.entries(TEXT_SIZES_CSS_VARIABLES).map(([key, value]) => [value, key])
|
|
13831
|
+
);
|
|
13659
13832
|
const customMarks = {
|
|
13660
13833
|
u: {
|
|
13661
13834
|
parseDOM: [{ tag: "u" }],
|
|
@@ -13674,6 +13847,26 @@ const customMarks = {
|
|
|
13674
13847
|
toDOM() {
|
|
13675
13848
|
return ["tt", 0];
|
|
13676
13849
|
}
|
|
13850
|
+
},
|
|
13851
|
+
textSize: {
|
|
13852
|
+
attrs: { size: { default: "normal" } },
|
|
13853
|
+
parseDOM: [
|
|
13854
|
+
{
|
|
13855
|
+
tag: "span[style*='font']",
|
|
13856
|
+
getAttrs: (node) => {
|
|
13857
|
+
const style = node.getAttribute("style");
|
|
13858
|
+
const fontSize = style.match(/font:\s*([^;]+)/)?.[1]?.trim();
|
|
13859
|
+
const size = CSS_VARIABLES_TO_SIZES[fontSize];
|
|
13860
|
+
if (size) return { size };
|
|
13861
|
+
return false;
|
|
13862
|
+
}
|
|
13863
|
+
}
|
|
13864
|
+
],
|
|
13865
|
+
toDOM(mark) {
|
|
13866
|
+
const size = mark.attrs.size;
|
|
13867
|
+
const fontSize = TEXT_SIZES_CSS_VARIABLES[size] || TEXT_SIZES_CSS_VARIABLES.normal;
|
|
13868
|
+
return ["span", { style: `font: ${fontSize};` }, 0];
|
|
13869
|
+
}
|
|
13677
13870
|
}
|
|
13678
13871
|
};
|
|
13679
13872
|
const extendedSchema = new Schema({
|
|
@@ -13708,6 +13901,57 @@ class TagToSchemaMap {
|
|
|
13708
13901
|
};
|
|
13709
13902
|
}
|
|
13710
13903
|
}
|
|
13904
|
+
function setTextBlockType(styles, type) {
|
|
13905
|
+
if (styles.textBlockType && styles.textBlockType !== type || styles.textBlockType === "") {
|
|
13906
|
+
styles.textBlockType = "";
|
|
13907
|
+
} else {
|
|
13908
|
+
styles.textBlockType = type;
|
|
13909
|
+
}
|
|
13910
|
+
}
|
|
13911
|
+
function createEnterKeymapPlugin() {
|
|
13912
|
+
return keymap({
|
|
13913
|
+
["Shift-Enter"]: (state, dispatch) => {
|
|
13914
|
+
const { schema } = state;
|
|
13915
|
+
const br = schema.nodes.hard_break;
|
|
13916
|
+
const { $from, $to } = state.selection;
|
|
13917
|
+
if ($from.sameParent($to)) {
|
|
13918
|
+
dispatch && dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView());
|
|
13919
|
+
} else {
|
|
13920
|
+
if (dispatch) {
|
|
13921
|
+
const tr = state.tr;
|
|
13922
|
+
const lastSelectionBlock = state.doc.resolve($to.end());
|
|
13923
|
+
tr.delete(lastSelectionBlock.start(), $to.pos);
|
|
13924
|
+
tr.delete($from.pos, lastSelectionBlock.start() - 1);
|
|
13925
|
+
tr.insert($from.pos, br.create());
|
|
13926
|
+
const newSelection = TextSelection.create(tr.doc, $from.pos + 1);
|
|
13927
|
+
tr.setSelection(newSelection);
|
|
13928
|
+
dispatch(tr.scrollIntoView());
|
|
13929
|
+
}
|
|
13930
|
+
}
|
|
13931
|
+
return true;
|
|
13932
|
+
},
|
|
13933
|
+
Enter: (state, dispatch) => {
|
|
13934
|
+
const { schema } = state;
|
|
13935
|
+
const paragraph = schema.nodes.paragraph;
|
|
13936
|
+
const { $from, empty } = state.selection;
|
|
13937
|
+
if (!empty || $from.parent.type !== paragraph) {
|
|
13938
|
+
return false;
|
|
13939
|
+
}
|
|
13940
|
+
const tr = state.tr;
|
|
13941
|
+
const marks = $from.marks();
|
|
13942
|
+
tr.split($from.pos);
|
|
13943
|
+
if (marks.length > 0) {
|
|
13944
|
+
const newParaStart = $from.pos + 1;
|
|
13945
|
+
const zeroWidthSpace = "";
|
|
13946
|
+
const content = schema.text(zeroWidthSpace, marks);
|
|
13947
|
+
tr.insert(newParaStart, content);
|
|
13948
|
+
tr.setSelection(TextSelection.create(tr.doc, newParaStart + 1));
|
|
13949
|
+
}
|
|
13950
|
+
dispatch && dispatch(tr.scrollIntoView());
|
|
13951
|
+
return true;
|
|
13952
|
+
}
|
|
13953
|
+
});
|
|
13954
|
+
}
|
|
13711
13955
|
function createSelectionChangePlugin(onSelectionChange) {
|
|
13712
13956
|
return new Plugin({
|
|
13713
13957
|
view: () => ({
|
|
@@ -13730,6 +13974,30 @@ function convertSelectionToVividFormat({
|
|
|
13730
13974
|
end: to
|
|
13731
13975
|
};
|
|
13732
13976
|
}
|
|
13977
|
+
const isEmptyParagraph = (node) => {
|
|
13978
|
+
return node.type.name === "paragraph" && node.nodeSize === 2;
|
|
13979
|
+
};
|
|
13980
|
+
const DEFAULT_TEXT_EDITOR_PLACEHOLDER = "Start typing...";
|
|
13981
|
+
const placeholderPluginKey = new PluginKey("placeholderPlugin");
|
|
13982
|
+
const createPlaceholderPlugin = (placeholder = DEFAULT_TEXT_EDITOR_PLACEHOLDER) => {
|
|
13983
|
+
return new Plugin({
|
|
13984
|
+
key: placeholderPluginKey,
|
|
13985
|
+
props: {
|
|
13986
|
+
decorations(state) {
|
|
13987
|
+
const { $from } = state.selection;
|
|
13988
|
+
const decorations = [];
|
|
13989
|
+
if (state.doc.childCount === 1 && isEmptyParagraph($from.parent)) {
|
|
13990
|
+
const decoration = Decoration.node($from.before(), $from.after(), {
|
|
13991
|
+
"data-placeholder": placeholder,
|
|
13992
|
+
class: "placeholder"
|
|
13993
|
+
});
|
|
13994
|
+
decorations.push(decoration);
|
|
13995
|
+
}
|
|
13996
|
+
return DecorationSet.create(state.doc, decorations);
|
|
13997
|
+
}
|
|
13998
|
+
}
|
|
13999
|
+
});
|
|
14000
|
+
};
|
|
13733
14001
|
class ProseMirrorFacade {
|
|
13734
14002
|
#userContentChange = false;
|
|
13735
14003
|
#view;
|
|
@@ -13750,6 +14018,7 @@ class ProseMirrorFacade {
|
|
|
13750
14018
|
};
|
|
13751
14019
|
#handleChangeEvent = () => {
|
|
13752
14020
|
if (!this.#userContentChange) {
|
|
14021
|
+
this.#userContentChange = false;
|
|
13753
14022
|
return;
|
|
13754
14023
|
}
|
|
13755
14024
|
this.#dispatchEvent("change");
|
|
@@ -13761,7 +14030,9 @@ class ProseMirrorFacade {
|
|
|
13761
14030
|
);
|
|
13762
14031
|
}
|
|
13763
14032
|
const plugins = [
|
|
14033
|
+
createPlaceholderPlugin(),
|
|
13764
14034
|
createSelectionChangePlugin(this.#onSelectionChange),
|
|
14035
|
+
createEnterKeymapPlugin(),
|
|
13765
14036
|
keymap(baseKeymap)
|
|
13766
14037
|
];
|
|
13767
14038
|
const state = EditorState.create({
|
|
@@ -13772,6 +14043,18 @@ class ProseMirrorFacade {
|
|
|
13772
14043
|
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
13773
14044
|
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
13774
14045
|
}
|
|
14046
|
+
updatePlaceholder(placeholderText) {
|
|
14047
|
+
this.#verifyViewInitiation();
|
|
14048
|
+
const { state } = this.#view;
|
|
14049
|
+
const plugins = state.plugins.filter(
|
|
14050
|
+
(plugin) => plugin !== placeholderPluginKey.get(state)
|
|
14051
|
+
);
|
|
14052
|
+
const newPlaceholderPlugin = createPlaceholderPlugin(placeholderText);
|
|
14053
|
+
const newState = state.reconfigure({
|
|
14054
|
+
plugins: [...plugins, newPlaceholderPlugin]
|
|
14055
|
+
});
|
|
14056
|
+
this.#view.updateState(newState);
|
|
14057
|
+
}
|
|
13775
14058
|
replaceContent(content) {
|
|
13776
14059
|
this.#verifyViewInitiation();
|
|
13777
14060
|
const parser = DOMParser.fromSchema(extendedSchema);
|
|
@@ -13822,6 +14105,7 @@ class ProseMirrorFacade {
|
|
|
13822
14105
|
dispatch(tr);
|
|
13823
14106
|
}
|
|
13824
14107
|
setSelectionDecoration(decoration) {
|
|
14108
|
+
this.#verifyViewInitiation();
|
|
13825
14109
|
const SUPPORTED_DECORATIONS = {
|
|
13826
14110
|
bold: "strong",
|
|
13827
14111
|
italics: "em",
|
|
@@ -13829,7 +14113,6 @@ class ProseMirrorFacade {
|
|
|
13829
14113
|
strikethrough: "s",
|
|
13830
14114
|
monospace: "tt"
|
|
13831
14115
|
};
|
|
13832
|
-
this.#verifyViewInitiation();
|
|
13833
14116
|
const { state, dispatch } = this.#view;
|
|
13834
14117
|
const decorationKey = decoration;
|
|
13835
14118
|
const markType = state.schema.marks[SUPPORTED_DECORATIONS[decorationKey]];
|
|
@@ -13837,6 +14120,121 @@ class ProseMirrorFacade {
|
|
|
13837
14120
|
throw new Error(`${decoration} is not a supported decoration`);
|
|
13838
14121
|
}
|
|
13839
14122
|
toggleMark(markType)(state, dispatch);
|
|
14123
|
+
this.#userContentChange = true;
|
|
14124
|
+
this.#handleChangeEvent();
|
|
14125
|
+
}
|
|
14126
|
+
#getSelectionBlockType() {
|
|
14127
|
+
const { state } = this.#view;
|
|
14128
|
+
const { from, to } = state.selection;
|
|
14129
|
+
const styles = {};
|
|
14130
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14131
|
+
if (node.type.name === "heading" && node.attrs.level === 2) {
|
|
14132
|
+
setTextBlockType(styles, "title");
|
|
14133
|
+
} else if (node.type.name === "heading" && node.attrs.level === 3) {
|
|
14134
|
+
setTextBlockType(styles, "subtitle");
|
|
14135
|
+
} else if (node.type.name === "paragraph") {
|
|
14136
|
+
setTextBlockType(styles, "body");
|
|
14137
|
+
}
|
|
14138
|
+
});
|
|
14139
|
+
return styles.textBlockType;
|
|
14140
|
+
}
|
|
14141
|
+
#getSelectionTextDecoration() {
|
|
14142
|
+
const { state } = this.#view;
|
|
14143
|
+
const { from, to, empty } = state.selection;
|
|
14144
|
+
const decorations = [];
|
|
14145
|
+
if (empty) {
|
|
14146
|
+
const marks = state.doc.resolve(from).marks();
|
|
14147
|
+
if (state.schema.marks.strong && marks.some((mark) => mark.type === state.schema.marks.strong)) {
|
|
14148
|
+
decorations.push("bold");
|
|
14149
|
+
}
|
|
14150
|
+
if (state.schema.marks.em && marks.some((mark) => mark.type === state.schema.marks.em)) {
|
|
14151
|
+
decorations.push("italics");
|
|
14152
|
+
}
|
|
14153
|
+
if (state.schema.marks.u && marks.some((mark) => mark.type === state.schema.marks.u)) {
|
|
14154
|
+
decorations.push("underline");
|
|
14155
|
+
}
|
|
14156
|
+
if (state.schema.marks.s && marks.some((mark) => mark.type === state.schema.marks.s)) {
|
|
14157
|
+
decorations.push("strikethrough");
|
|
14158
|
+
}
|
|
14159
|
+
if (state.schema.marks.tt && marks.some((mark) => mark.type === state.schema.marks.tt)) {
|
|
14160
|
+
decorations.push("monospace");
|
|
14161
|
+
}
|
|
14162
|
+
} else {
|
|
14163
|
+
if (state.schema.marks.strong && state.doc.rangeHasMark(from, to, state.schema.marks.strong)) {
|
|
14164
|
+
decorations.push("bold");
|
|
14165
|
+
}
|
|
14166
|
+
if (state.schema.marks.em && state.doc.rangeHasMark(from, to, state.schema.marks.em)) {
|
|
14167
|
+
decorations.push("italics");
|
|
14168
|
+
}
|
|
14169
|
+
if (state.schema.marks.u && state.doc.rangeHasMark(from, to, state.schema.marks.u)) {
|
|
14170
|
+
decorations.push("underline");
|
|
14171
|
+
}
|
|
14172
|
+
if (state.schema.marks.s && state.doc.rangeHasMark(from, to, state.schema.marks.s)) {
|
|
14173
|
+
decorations.push("strikethrough");
|
|
14174
|
+
}
|
|
14175
|
+
if (state.schema.marks.tt && state.doc.rangeHasMark(from, to, state.schema.marks.tt)) {
|
|
14176
|
+
decorations.push("monospace");
|
|
14177
|
+
}
|
|
14178
|
+
}
|
|
14179
|
+
return decorations.length ? decorations : void 0;
|
|
14180
|
+
}
|
|
14181
|
+
#getSelectionTextSize() {
|
|
14182
|
+
const { state } = this.#view;
|
|
14183
|
+
const { from, to, empty } = state.selection;
|
|
14184
|
+
const defaultSize = "normal";
|
|
14185
|
+
if (empty) {
|
|
14186
|
+
const marks = state.doc.resolve(from).marks();
|
|
14187
|
+
const textSizeMark = marks.find(
|
|
14188
|
+
(mark) => mark.type === state.schema.marks.textSize
|
|
14189
|
+
);
|
|
14190
|
+
return textSizeMark ? textSizeMark.attrs.size : defaultSize;
|
|
14191
|
+
} else {
|
|
14192
|
+
let textSize = null;
|
|
14193
|
+
let foundMixedSizes = false;
|
|
14194
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
14195
|
+
if (node.isText) {
|
|
14196
|
+
const mark = node.marks.find(
|
|
14197
|
+
(mark2) => mark2.type === state.schema.marks.textSize
|
|
14198
|
+
);
|
|
14199
|
+
if (mark) {
|
|
14200
|
+
if (textSize === null) {
|
|
14201
|
+
textSize = mark.attrs.size;
|
|
14202
|
+
} else if (textSize !== mark.attrs.size) {
|
|
14203
|
+
foundMixedSizes = true;
|
|
14204
|
+
return false;
|
|
14205
|
+
}
|
|
14206
|
+
} else if (textSize !== null) {
|
|
14207
|
+
foundMixedSizes = true;
|
|
14208
|
+
return false;
|
|
14209
|
+
}
|
|
14210
|
+
}
|
|
14211
|
+
return true;
|
|
14212
|
+
});
|
|
14213
|
+
if (foundMixedSizes) {
|
|
14214
|
+
return "";
|
|
14215
|
+
}
|
|
14216
|
+
return textSize !== null ? textSize : defaultSize;
|
|
14217
|
+
}
|
|
14218
|
+
}
|
|
14219
|
+
getSelectionStyles() {
|
|
14220
|
+
this.#verifyViewInitiation();
|
|
14221
|
+
const styles = {};
|
|
14222
|
+
styles.textBlockType = this.#getSelectionBlockType();
|
|
14223
|
+
styles.textDecoration = this.#getSelectionTextDecoration();
|
|
14224
|
+
styles.textSize = this.#getSelectionTextSize();
|
|
14225
|
+
return styles;
|
|
14226
|
+
}
|
|
14227
|
+
setTextSize(size = "normal") {
|
|
14228
|
+
this.#verifyViewInitiation();
|
|
14229
|
+
const { state, dispatch } = this.#view;
|
|
14230
|
+
const { schema, selection, tr } = state;
|
|
14231
|
+
const { from, to } = selection;
|
|
14232
|
+
const textSizeMark = schema.marks.textSize;
|
|
14233
|
+
tr.removeMark(from, to, textSizeMark);
|
|
14234
|
+
tr.addMark(from, to, textSizeMark.create({ size }));
|
|
14235
|
+
dispatch(tr.scrollIntoView());
|
|
14236
|
+
this.#userContentChange = true;
|
|
14237
|
+
this.#handleChangeEvent();
|
|
13840
14238
|
}
|
|
13841
14239
|
}
|
|
13842
14240
|
|
|
@@ -13917,6 +14315,9 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13917
14315
|
}
|
|
13918
14316
|
this.#updateEditorSelection();
|
|
13919
14317
|
}
|
|
14318
|
+
placeholderChanged() {
|
|
14319
|
+
this.#editor?.updatePlaceholder(this.placeholder);
|
|
14320
|
+
}
|
|
13920
14321
|
#handleSelectionChange;
|
|
13921
14322
|
#handleChange;
|
|
13922
14323
|
#handleInput;
|
|
@@ -13932,6 +14333,7 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13932
14333
|
this.#editor.addEventListener("change", this.#handleChange);
|
|
13933
14334
|
this.#editor.addEventListener("input", this.#handleInput);
|
|
13934
14335
|
}
|
|
14336
|
+
this.placeholderChanged();
|
|
13935
14337
|
}
|
|
13936
14338
|
setTextBlock(blockType) {
|
|
13937
14339
|
try {
|
|
@@ -13947,6 +14349,15 @@ class RichTextEditor extends vividElement.VividElement {
|
|
|
13947
14349
|
console.warn(`Invalid decoration: ${decoration}`);
|
|
13948
14350
|
}
|
|
13949
14351
|
}
|
|
14352
|
+
setSelectionTextSize(textSize) {
|
|
14353
|
+
this.#editor?.setTextSize(textSize);
|
|
14354
|
+
}
|
|
14355
|
+
get selectionStyles() {
|
|
14356
|
+
if (!this.#editor) {
|
|
14357
|
+
return {};
|
|
14358
|
+
}
|
|
14359
|
+
return this.#editor.getSelectionStyles();
|
|
14360
|
+
}
|
|
13950
14361
|
focus() {
|
|
13951
14362
|
super.focus();
|
|
13952
14363
|
setTimeout(() => {
|
|
@@ -13962,6 +14373,9 @@ __decorateClass([
|
|
|
13962
14373
|
__decorateClass([
|
|
13963
14374
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-end" })
|
|
13964
14375
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14376
|
+
__decorateClass([
|
|
14377
|
+
vividElement.attr
|
|
14378
|
+
], RichTextEditor.prototype, "placeholder");
|
|
13965
14379
|
|
|
13966
14380
|
const getClasses = (_) => classNames.classNames("control");
|
|
13967
14381
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
@@ -13978,6 +14392,12 @@ function selectionDecorationSelectedHandler(event) {
|
|
|
13978
14392
|
);
|
|
13979
14393
|
menuParent(event.target).focus();
|
|
13980
14394
|
}
|
|
14395
|
+
function textSizeSelectedHandler(event) {
|
|
14396
|
+
menuParent(event.target).setSelectionTextSize(
|
|
14397
|
+
event.detail
|
|
14398
|
+
);
|
|
14399
|
+
menuParent(event.target).focus();
|
|
14400
|
+
}
|
|
13981
14401
|
function handleMenuBarSlotChange(_, { event }) {
|
|
13982
14402
|
const slot = event.target;
|
|
13983
14403
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
@@ -14000,6 +14420,10 @@ function handleMenuBarSlotChange(_, { event }) {
|
|
|
14000
14420
|
"text-decoration-selected",
|
|
14001
14421
|
selectionDecorationSelectedHandler
|
|
14002
14422
|
);
|
|
14423
|
+
menuBar.addEventListener(
|
|
14424
|
+
"text-size-selected",
|
|
14425
|
+
textSizeSelectedHandler
|
|
14426
|
+
);
|
|
14003
14427
|
}
|
|
14004
14428
|
}
|
|
14005
14429
|
const RichTextEditorTemplate = (_) => {
|