@vonage/vivid 4.19.0-preview.0 → 4.19.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 +922 -742
- package/index.cjs +5 -0
- package/index.d.ts +1 -0
- package/index.js +2 -2
- package/lib/action-group/action-group.d.ts +0 -118
- package/lib/banner/banner.d.ts +0 -118
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +0 -118
- package/lib/checkbox/checkbox.d.ts +0 -118
- package/lib/date-picker/date-picker.d.ts +0 -472
- package/lib/date-range-picker/date-range-picker.d.ts +0 -236
- package/lib/date-time-picker/date-time-picker.d.ts +0 -472
- package/lib/date-time-picker/definition.d.ts +2 -0
- package/lib/dialog/dialog.d.ts +0 -118
- package/lib/divider/divider.d.ts +0 -118
- package/lib/menu/menu.d.ts +0 -236
- package/lib/nav-disclosure/nav-disclosure.d.ts +0 -118
- package/lib/number-field/number-field.d.ts +0 -118
- package/lib/option/option.d.ts +2 -3
- package/lib/pagination/pagination.d.ts +1 -0
- package/lib/progress/progress.d.ts +0 -118
- package/lib/progress-ring/progress-ring.d.ts +0 -118
- package/lib/rich-text-editor/definition.d.ts +2 -0
- package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +1 -0
- package/lib/rich-text-editor/menubar/definition.d.ts +2 -0
- package/lib/rich-text-editor/menubar/menubar.d.ts +4 -0
- package/lib/rich-text-editor/menubar/menubar.template.d.ts +4 -0
- package/lib/rich-text-editor/rich-text-editor.d.ts +7 -0
- package/lib/searchable-select/locale.d.ts +1 -0
- package/lib/searchable-select/searchable-select.d.ts +1 -1
- package/lib/selectable-box/selectable-box.d.ts +0 -118
- package/lib/slider/slider.d.ts +0 -118
- package/lib/split-button/split-button.d.ts +0 -118
- package/lib/switch/switch.d.ts +0 -118
- package/lib/tag-group/tag-group.d.ts +0 -118
- package/lib/tag-name-map.d.ts +73 -0
- package/lib/text-anchor/text-anchor.d.ts +0 -118
- package/lib/text-area/text-area.d.ts +0 -118
- package/lib/text-field/text-field.d.ts +0 -118
- package/lib/time-picker/time-picker.d.ts +0 -236
- package/lib/toggletip/toggletip.d.ts +0 -118
- package/lib/tooltip/tooltip.d.ts +0 -118
- package/locales/de-DE.cjs +1 -0
- package/locales/de-DE.js +1 -0
- package/locales/en-GB.cjs +1 -0
- package/locales/en-GB.js +1 -0
- package/locales/en-US.cjs +1 -0
- package/locales/en-US.js +1 -0
- package/locales/ja-JP.cjs +1 -0
- package/locales/ja-JP.js +1 -0
- package/locales/zh-CN.cjs +1 -0
- package/locales/zh-CN.js +1 -0
- package/package.json +1 -1
- package/shared/aria/delegates-aria.d.ts +0 -118
- package/shared/definition20.cjs +10 -10
- package/shared/definition20.js +1 -1
- package/shared/definition30.cjs +1 -1
- package/shared/definition30.js +1 -1
- package/shared/definition36.cjs +7 -7
- package/shared/definition36.js +7 -7
- package/shared/definition37.cjs +15 -1
- package/shared/definition37.js +15 -1
- package/shared/definition4.cjs +13 -12
- package/shared/definition4.js +13 -12
- package/shared/definition43.cjs +221 -12
- package/shared/definition43.js +222 -14
- package/shared/definition44.cjs +35 -39
- package/shared/definition44.js +35 -39
- package/shared/definition63.cjs +232 -157
- package/shared/definition63.js +232 -157
- package/shared/foundation/button/button.d.ts +0 -118
- package/shared/option.cjs +16 -19
- package/shared/option.js +16 -19
- package/shared/patterns/anchored.d.ts +0 -236
- package/shared/picker-field/mixins/calendar-picker.d.ts +0 -118
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +0 -118
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +0 -236
- package/shared/picker-field/mixins/single-date-picker.d.ts +0 -354
- package/shared/picker-field/mixins/single-value-picker.d.ts +0 -118
- package/shared/picker-field/mixins/time-selection-picker.d.ts +0 -236
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +0 -236
- package/shared/picker-field.template.js +1 -1
- package/shared/vivid-element.cjs +1 -1
- package/shared/vivid-element.js +1 -1
- 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/vivid.api.json +1260 -556
package/shared/definition43.js
CHANGED
|
@@ -1,7 +1,115 @@
|
|
|
1
|
-
import { V as VividElement, a as attr,
|
|
1
|
+
import { V as VividElement, a as attr, h as html, f as defineVividComponent, n as nullableNumberConverter, d as createRegisterFunction } from './vivid-element.js';
|
|
2
|
+
import { B as Button, b as buttonDefinition } from './definition11.js';
|
|
3
|
+
import { e as Menu, M as MenuItem, c as menuDefinition, m as menuItemDefinition } from './definition30.js';
|
|
2
4
|
import { c as classNames } from './class-names.js';
|
|
5
|
+
import { r as repeat } from './repeat.js';
|
|
3
6
|
|
|
4
|
-
const styles = "@charset \"UTF-8\"
|
|
7
|
+
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)}";
|
|
8
|
+
|
|
9
|
+
const styles = ":host{display:flex;align-items:center;padding:8px;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)}";
|
|
10
|
+
|
|
11
|
+
var __defProp$1 = Object.defineProperty;
|
|
12
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
13
|
+
var result = void 0 ;
|
|
14
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
15
|
+
if (decorator = decorators[i])
|
|
16
|
+
result = (decorator(target, key, result) ) || result;
|
|
17
|
+
if (result) __defProp$1(target, key, result);
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
class MenuBar extends VividElement {
|
|
21
|
+
}
|
|
22
|
+
__decorateClass$1([
|
|
23
|
+
attr({ attribute: "menu-items" })
|
|
24
|
+
], MenuBar.prototype, "menuItems");
|
|
25
|
+
|
|
26
|
+
function notifyMenuBarChange(menuBar, eventName, payload) {
|
|
27
|
+
menuBar.$emit(eventName, payload, { bubbles: false, composed: false });
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
const MENU_BAR_ITEMS = {
|
|
31
|
+
textSize: function(context) {
|
|
32
|
+
const buttonTag = context.tagFor(Button);
|
|
33
|
+
const menuTag = context.tagFor(Menu);
|
|
34
|
+
const menuItemTag = context.tagFor(MenuItem);
|
|
35
|
+
return html`
|
|
36
|
+
<${menuTag}
|
|
37
|
+
trigger="auto"
|
|
38
|
+
id="text-size"
|
|
39
|
+
aria-label="Menu example"
|
|
40
|
+
placement="bottom-end"
|
|
41
|
+
>
|
|
42
|
+
<${buttonTag}
|
|
43
|
+
slot="anchor"
|
|
44
|
+
aria-label="Open menu"
|
|
45
|
+
size="super-condensed"
|
|
46
|
+
appearance="ghost-light"
|
|
47
|
+
shape="pill"
|
|
48
|
+
icon="text-size-line"
|
|
49
|
+
></${buttonTag}>
|
|
50
|
+
<${menuItemTag}
|
|
51
|
+
text="Title"
|
|
52
|
+
value="title"
|
|
53
|
+
internal-part
|
|
54
|
+
class="title"
|
|
55
|
+
connotation="cta"
|
|
56
|
+
@click="${(_, { parent }) => notifyMenuBarChange(parent, "text-size-selected", "title")}"
|
|
57
|
+
></${menuItemTag}>
|
|
58
|
+
<${menuItemTag}
|
|
59
|
+
text="Subtitle"
|
|
60
|
+
value="subtitle"
|
|
61
|
+
internal-part
|
|
62
|
+
class="subtitle"
|
|
63
|
+
connotation="cta"
|
|
64
|
+
@click="${(_, { parent }) => notifyMenuBarChange(parent, "text-size-selected", "subtitle")}"
|
|
65
|
+
></${menuItemTag}>
|
|
66
|
+
<${menuItemTag}
|
|
67
|
+
text="Body"
|
|
68
|
+
value="body"
|
|
69
|
+
internal-part
|
|
70
|
+
class="body"
|
|
71
|
+
connotation="cta"
|
|
72
|
+
@click="${(_, { parent }) => notifyMenuBarChange(parent, "text-size-selected", "body")}"
|
|
73
|
+
></${menuItemTag}>
|
|
74
|
+
</${menuTag}>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const getClasses$1 = (menuBar) => classNames("control", [
|
|
79
|
+
"hide-menubar",
|
|
80
|
+
getValidMenuItems(menuBar).length === 0
|
|
81
|
+
]);
|
|
82
|
+
const validItems = ["textSize"];
|
|
83
|
+
function createMenuItem(item) {
|
|
84
|
+
return MENU_BAR_ITEMS[item];
|
|
85
|
+
}
|
|
86
|
+
function getValidMenuItems({ menuItems }) {
|
|
87
|
+
return menuItems ? menuItems.split(" ").filter((item) => validItems.includes(item)) : [];
|
|
88
|
+
}
|
|
89
|
+
function renderMenuItems(context) {
|
|
90
|
+
return () => html`${repeat(
|
|
91
|
+
getValidMenuItems,
|
|
92
|
+
html`${(menuItemName) => createMenuItem(menuItemName)(context)}`
|
|
93
|
+
)}`;
|
|
94
|
+
}
|
|
95
|
+
const MenuBarTemplate = (context) => {
|
|
96
|
+
return html`<template class="${getClasses$1}">
|
|
97
|
+
${renderMenuItems(context)}
|
|
98
|
+
</template>`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const menuBarDefinition = defineVividComponent(
|
|
102
|
+
"menubar",
|
|
103
|
+
MenuBar,
|
|
104
|
+
MenuBarTemplate,
|
|
105
|
+
[buttonDefinition, menuDefinition, menuItemDefinition],
|
|
106
|
+
{
|
|
107
|
+
styles,
|
|
108
|
+
shadowOptions: {
|
|
109
|
+
delegatesFocus: true
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
);
|
|
5
113
|
|
|
6
114
|
// ::- Persistent data structure representing an ordered mapping from
|
|
7
115
|
// strings to values, with some convenient update methods.
|
|
@@ -1289,7 +1397,7 @@ structure between the old and new data as much as possible, which a
|
|
|
1289
1397
|
tree shape like this (without back pointers) makes easy.
|
|
1290
1398
|
|
|
1291
1399
|
**Do not** directly mutate the properties of a `Node` object. See
|
|
1292
|
-
[the guide](/docs/guide/#doc) for more information.
|
|
1400
|
+
[the guide](https://prosemirror.net/docs/guide/#doc) for more information.
|
|
1293
1401
|
*/
|
|
1294
1402
|
class Node {
|
|
1295
1403
|
/**
|
|
@@ -1324,7 +1432,7 @@ class Node {
|
|
|
1324
1432
|
get children() { return this.content.content; }
|
|
1325
1433
|
/**
|
|
1326
1434
|
The size of this node, as defined by the integer-based [indexing
|
|
1327
|
-
scheme](/docs/guide/#doc.indexing). For text nodes, this is the
|
|
1435
|
+
scheme](https://prosemirror.net/docs/guide/#doc.indexing). For text nodes, this is the
|
|
1328
1436
|
amount of characters. For other leaf nodes, it is one. For
|
|
1329
1437
|
non-leaf nodes, it is the size of the content plus two (the
|
|
1330
1438
|
start and end token).
|
|
@@ -6850,11 +6958,13 @@ function clientRect(node) {
|
|
|
6850
6958
|
function scrollRectIntoView(view, rect, startDOM) {
|
|
6851
6959
|
let scrollThreshold = view.someProp("scrollThreshold") || 0, scrollMargin = view.someProp("scrollMargin") || 5;
|
|
6852
6960
|
let doc = view.dom.ownerDocument;
|
|
6853
|
-
for (let parent = startDOM || view.dom;;
|
|
6961
|
+
for (let parent = startDOM || view.dom;;) {
|
|
6854
6962
|
if (!parent)
|
|
6855
6963
|
break;
|
|
6856
|
-
if (parent.nodeType != 1)
|
|
6964
|
+
if (parent.nodeType != 1) {
|
|
6965
|
+
parent = parentNode(parent);
|
|
6857
6966
|
continue;
|
|
6967
|
+
}
|
|
6858
6968
|
let elt = parent;
|
|
6859
6969
|
let atTop = elt == doc.body;
|
|
6860
6970
|
let bounding = atTop ? windowRect(doc) : clientRect(elt);
|
|
@@ -6883,8 +6993,10 @@ function scrollRectIntoView(view, rect, startDOM) {
|
|
|
6883
6993
|
rect = { left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY };
|
|
6884
6994
|
}
|
|
6885
6995
|
}
|
|
6886
|
-
|
|
6996
|
+
let pos = atTop ? "fixed" : getComputedStyle(parent).position;
|
|
6997
|
+
if (/^(fixed|sticky)$/.test(pos))
|
|
6887
6998
|
break;
|
|
6999
|
+
parent = pos == "absolute" ? parent.offsetParent : parentNode(parent);
|
|
6888
7000
|
}
|
|
6889
7001
|
}
|
|
6890
7002
|
// Store the scroll position of the editor's parent nodes, along with
|
|
@@ -11353,6 +11465,7 @@ class DOMObserver {
|
|
|
11353
11465
|
view.input.lastFocus = 0;
|
|
11354
11466
|
selectionToDOM(view);
|
|
11355
11467
|
this.currentSelection.set(sel);
|
|
11468
|
+
view.scrollToSelection();
|
|
11356
11469
|
}
|
|
11357
11470
|
else if (from > -1 || newSel) {
|
|
11358
11471
|
if (from > -1) {
|
|
@@ -13348,6 +13461,7 @@ const marks = {
|
|
|
13348
13461
|
Code font mark. Represented as a `<code>` element.
|
|
13349
13462
|
*/
|
|
13350
13463
|
code: {
|
|
13464
|
+
code: true,
|
|
13351
13465
|
parseDOM: [{ tag: "code" }],
|
|
13352
13466
|
toDOM() { return codeDOM; }
|
|
13353
13467
|
}
|
|
@@ -13367,6 +13481,26 @@ const NEGATIVE_SELECTION = {
|
|
|
13367
13481
|
start: -1,
|
|
13368
13482
|
end: -1
|
|
13369
13483
|
};
|
|
13484
|
+
class TagToSchemaMap {
|
|
13485
|
+
static get h2() {
|
|
13486
|
+
return {
|
|
13487
|
+
type: "heading",
|
|
13488
|
+
attrs: { level: 2 }
|
|
13489
|
+
};
|
|
13490
|
+
}
|
|
13491
|
+
static get h3() {
|
|
13492
|
+
return {
|
|
13493
|
+
type: "heading",
|
|
13494
|
+
attrs: { level: 3 }
|
|
13495
|
+
};
|
|
13496
|
+
}
|
|
13497
|
+
static get p() {
|
|
13498
|
+
return {
|
|
13499
|
+
type: "paragraph",
|
|
13500
|
+
attrs: {}
|
|
13501
|
+
};
|
|
13502
|
+
}
|
|
13503
|
+
}
|
|
13370
13504
|
function createSelectionChangePlugin(onSelectionChange) {
|
|
13371
13505
|
return new Plugin({
|
|
13372
13506
|
view: () => ({
|
|
@@ -13395,10 +13529,12 @@ class ProseMirrorFacade {
|
|
|
13395
13529
|
#onSelectionChange = () => {
|
|
13396
13530
|
this.#dispatchEvent("selection-changed");
|
|
13397
13531
|
};
|
|
13398
|
-
#handleInputEvent = () => {
|
|
13532
|
+
#handleInputEvent = (e) => {
|
|
13533
|
+
e.stopPropagation();
|
|
13399
13534
|
this.#userContentChange = true;
|
|
13535
|
+
this.#dispatchEvent("input");
|
|
13400
13536
|
};
|
|
13401
|
-
#
|
|
13537
|
+
#handleChangeEvent = () => {
|
|
13402
13538
|
if (!this.#userContentChange) {
|
|
13403
13539
|
return;
|
|
13404
13540
|
}
|
|
@@ -13420,7 +13556,7 @@ class ProseMirrorFacade {
|
|
|
13420
13556
|
});
|
|
13421
13557
|
this.#view = new EditorView(element, { state });
|
|
13422
13558
|
this.#view.dom.addEventListener("input", this.#handleInputEvent);
|
|
13423
|
-
this.#view.dom.addEventListener("blur", this.#
|
|
13559
|
+
this.#view.dom.addEventListener("blur", this.#handleChangeEvent);
|
|
13424
13560
|
}
|
|
13425
13561
|
replaceContent(content) {
|
|
13426
13562
|
if (!this.#view) {
|
|
@@ -13455,6 +13591,30 @@ class ProseMirrorFacade {
|
|
|
13455
13591
|
#dispatchEvent = (eventName, detail) => {
|
|
13456
13592
|
this.#eventHandler.dispatchEvent(new CustomEvent(eventName, { detail }));
|
|
13457
13593
|
};
|
|
13594
|
+
setSelectionTag(tag) {
|
|
13595
|
+
if (!this.#view) {
|
|
13596
|
+
throw new Error(
|
|
13597
|
+
"ProseMirror was not initiated. Please use the `init` method first."
|
|
13598
|
+
);
|
|
13599
|
+
}
|
|
13600
|
+
const nodeDefinitions = TagToSchemaMap[tag] ?? {
|
|
13601
|
+
type: tag
|
|
13602
|
+
};
|
|
13603
|
+
const { state, dispatch } = this.#view;
|
|
13604
|
+
const { from, to } = state.selection;
|
|
13605
|
+
const tr = state.tr;
|
|
13606
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
13607
|
+
const nodeType = state.schema.nodes[nodeDefinitions.type];
|
|
13608
|
+
if (!nodeType) {
|
|
13609
|
+
throw new Error("Node type tag does not exist in the schema");
|
|
13610
|
+
}
|
|
13611
|
+
if (node.type === nodeType) {
|
|
13612
|
+
return;
|
|
13613
|
+
}
|
|
13614
|
+
tr.setBlockType(from, to, nodeType, nodeDefinitions.attrs);
|
|
13615
|
+
});
|
|
13616
|
+
dispatch(tr);
|
|
13617
|
+
}
|
|
13458
13618
|
}
|
|
13459
13619
|
|
|
13460
13620
|
var __defProp = Object.defineProperty;
|
|
@@ -13466,6 +13626,11 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
13466
13626
|
if (result) __defProp(target, key, result);
|
|
13467
13627
|
return result;
|
|
13468
13628
|
};
|
|
13629
|
+
const RichTextEditorTextSizes = {
|
|
13630
|
+
title: "h2",
|
|
13631
|
+
subtitle: "h3",
|
|
13632
|
+
body: "p"
|
|
13633
|
+
};
|
|
13469
13634
|
class RichTextEditor extends VividElement {
|
|
13470
13635
|
constructor() {
|
|
13471
13636
|
super();
|
|
@@ -13481,11 +13646,13 @@ class RichTextEditor extends VividElement {
|
|
|
13481
13646
|
}
|
|
13482
13647
|
};
|
|
13483
13648
|
this.selectionEnd = null;
|
|
13649
|
+
this.#selectionChangedByUser = false;
|
|
13484
13650
|
this.#handleSelectionChange = () => {
|
|
13485
13651
|
if (!this.#editor.selection()) {
|
|
13486
13652
|
return;
|
|
13487
13653
|
}
|
|
13488
13654
|
const { start, end } = this.#editor.selection();
|
|
13655
|
+
this.#selectionChangedByUser = true;
|
|
13489
13656
|
this.selectionStart = start;
|
|
13490
13657
|
this.selectionEnd = end;
|
|
13491
13658
|
this.$emit("selection-changed");
|
|
@@ -13493,6 +13660,9 @@ class RichTextEditor extends VividElement {
|
|
|
13493
13660
|
this.#handleChange = () => {
|
|
13494
13661
|
this.$emit("change");
|
|
13495
13662
|
};
|
|
13663
|
+
this.#handleInput = () => {
|
|
13664
|
+
this.$emit("input");
|
|
13665
|
+
};
|
|
13496
13666
|
}
|
|
13497
13667
|
/**
|
|
13498
13668
|
* Indicates the rich text editor's value.
|
|
@@ -13514,6 +13684,9 @@ class RichTextEditor extends VividElement {
|
|
|
13514
13684
|
return this.shadowRoot.querySelector("#editor");
|
|
13515
13685
|
}
|
|
13516
13686
|
selectionStartChanged() {
|
|
13687
|
+
if (this.#selectionChangedByUser) {
|
|
13688
|
+
return;
|
|
13689
|
+
}
|
|
13517
13690
|
if (!this.selectionStart || this.selectionEnd && this.selectionStart > this.selectionEnd) {
|
|
13518
13691
|
return;
|
|
13519
13692
|
}
|
|
@@ -13521,13 +13694,19 @@ class RichTextEditor extends VividElement {
|
|
|
13521
13694
|
}
|
|
13522
13695
|
#updateEditorSelection;
|
|
13523
13696
|
selectionEndChanged() {
|
|
13697
|
+
if (this.#selectionChangedByUser) {
|
|
13698
|
+
this.#selectionChangedByUser = false;
|
|
13699
|
+
return;
|
|
13700
|
+
}
|
|
13524
13701
|
if (this.selectionEnd && !this.selectionStart) {
|
|
13525
13702
|
this.selectionStart = 1;
|
|
13526
13703
|
}
|
|
13527
13704
|
this.#updateEditorSelection();
|
|
13528
13705
|
}
|
|
13706
|
+
#selectionChangedByUser;
|
|
13529
13707
|
#handleSelectionChange;
|
|
13530
13708
|
#handleChange;
|
|
13709
|
+
#handleInput;
|
|
13531
13710
|
connectedCallback() {
|
|
13532
13711
|
super.connectedCallback();
|
|
13533
13712
|
if (!this.#editor) {
|
|
@@ -13538,6 +13717,14 @@ class RichTextEditor extends VividElement {
|
|
|
13538
13717
|
this.#handleSelectionChange
|
|
13539
13718
|
);
|
|
13540
13719
|
this.#editor.addEventListener("change", this.#handleChange);
|
|
13720
|
+
this.#editor.addEventListener("input", this.#handleInput);
|
|
13721
|
+
}
|
|
13722
|
+
}
|
|
13723
|
+
setTextSize(size) {
|
|
13724
|
+
try {
|
|
13725
|
+
this.#editor?.setSelectionTag(RichTextEditorTextSizes[size]);
|
|
13726
|
+
} catch (e) {
|
|
13727
|
+
console.warn(`Invalid text size: ${size}`);
|
|
13541
13728
|
}
|
|
13542
13729
|
}
|
|
13543
13730
|
}
|
|
@@ -13549,9 +13736,30 @@ __decorateClass([
|
|
|
13549
13736
|
], RichTextEditor.prototype, "selectionEnd");
|
|
13550
13737
|
|
|
13551
13738
|
const getClasses = (_) => classNames("control");
|
|
13739
|
+
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
13740
|
+
function textSizeSelectedHandler(event) {
|
|
13741
|
+
this.setTextSize(event.detail);
|
|
13742
|
+
}
|
|
13743
|
+
function handleMenuBarSlotChange(richTextEditor, { event }) {
|
|
13744
|
+
const slot = event.target;
|
|
13745
|
+
const assignedElements = slot.assignedElements({ flatten: true });
|
|
13746
|
+
const menuBar = assignedElements.find(
|
|
13747
|
+
(element) => element.tagName.toLowerCase().endsWith(VALID_MENU_ELEMEMENT_SUFFIX)
|
|
13748
|
+
);
|
|
13749
|
+
assignedElements.forEach((element) => {
|
|
13750
|
+
element.style.display = element === menuBar ? "block" : "none";
|
|
13751
|
+
});
|
|
13752
|
+
if (menuBar) {
|
|
13753
|
+
menuBar.addEventListener(
|
|
13754
|
+
"text-size-selected",
|
|
13755
|
+
textSizeSelectedHandler.bind(richTextEditor)
|
|
13756
|
+
);
|
|
13757
|
+
}
|
|
13758
|
+
}
|
|
13552
13759
|
const RichTextEditorTemplate = (_) => {
|
|
13553
13760
|
return html`<template class="${getClasses}">
|
|
13554
|
-
<div id="editor"></div>
|
|
13761
|
+
<div id="editor" class="editor"></div>
|
|
13762
|
+
<slot name="menu-bar" @slotchange="${handleMenuBarSlotChange}"></slot>
|
|
13555
13763
|
</template>`;
|
|
13556
13764
|
};
|
|
13557
13765
|
|
|
@@ -13559,9 +13767,9 @@ const richTextEditorDefinition = defineVividComponent(
|
|
|
13559
13767
|
"rich-text-editor",
|
|
13560
13768
|
RichTextEditor,
|
|
13561
13769
|
RichTextEditorTemplate,
|
|
13562
|
-
[],
|
|
13770
|
+
[menuBarDefinition],
|
|
13563
13771
|
{
|
|
13564
|
-
styles,
|
|
13772
|
+
styles: styles$1,
|
|
13565
13773
|
shadowOptions: {
|
|
13566
13774
|
delegatesFocus: true
|
|
13567
13775
|
}
|
|
@@ -13571,4 +13779,4 @@ const registerRichTextEditor = createRegisterFunction(
|
|
|
13571
13779
|
richTextEditorDefinition
|
|
13572
13780
|
);
|
|
13573
13781
|
|
|
13574
|
-
export { registerRichTextEditor as a, richTextEditorDefinition as r };
|
|
13782
|
+
export { RichTextEditor as R, registerRichTextEditor as a, richTextEditorDefinition as r };
|
package/shared/definition44.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const definition$1 = require('./definition11.cjs');
|
|
4
4
|
const definition = require('./definition65.cjs');
|
|
5
5
|
const definition$3 = require('./definition28.cjs');
|
|
6
|
+
const definition$2 = require('./definition38.cjs');
|
|
6
7
|
const vividElement = require('./vivid-element.cjs');
|
|
7
8
|
const applyMixinsWithObservables = require('./applyMixinsWithObservables.cjs');
|
|
8
9
|
const scrollIntoView = require('./scrollIntoView.cjs');
|
|
@@ -10,9 +11,8 @@ const formAssociated = require('./form-associated.cjs');
|
|
|
10
11
|
const affix = require('./affix.cjs');
|
|
11
12
|
const localized = require('./localized.cjs');
|
|
12
13
|
const formElements = require('./form-elements.cjs');
|
|
13
|
-
const applyMixins = require('./apply-mixins.cjs');
|
|
14
14
|
const option = require('./option.cjs');
|
|
15
|
-
const
|
|
15
|
+
const applyMixins = require('./apply-mixins.cjs');
|
|
16
16
|
const when = require('./when.cjs');
|
|
17
17
|
const ref = require('./ref.cjs');
|
|
18
18
|
const slotted = require('./slotted.cjs');
|
|
@@ -67,7 +67,7 @@ exports.SearchableSelect = class SearchableSelect extends FormAssociatedSearchab
|
|
|
67
67
|
this.maxLines = null;
|
|
68
68
|
this.values = [];
|
|
69
69
|
this.initialValues = [];
|
|
70
|
-
this.
|
|
70
|
+
this._currentSearchText = null;
|
|
71
71
|
// --- Slotted options ---
|
|
72
72
|
/**
|
|
73
73
|
* @internal
|
|
@@ -181,29 +181,30 @@ exports.SearchableSelect = class SearchableSelect extends FormAssociatedSearchab
|
|
|
181
181
|
/**
|
|
182
182
|
* @internal
|
|
183
183
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
}
|
|
184
|
+
_currentSearchTextChanged() {
|
|
185
|
+
__privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
|
|
186
|
+
this.$emit("search-text-change", void 0, {
|
|
187
|
+
bubbles: false,
|
|
188
|
+
composed: false
|
|
189
|
+
});
|
|
192
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* The current search text of the component.
|
|
193
|
+
*/
|
|
193
194
|
get searchText() {
|
|
194
|
-
return this.
|
|
195
|
+
return this._currentSearchText ?? "";
|
|
195
196
|
}
|
|
196
197
|
/**
|
|
197
198
|
* @internal
|
|
198
199
|
*/
|
|
199
200
|
get _inputValue() {
|
|
200
|
-
return this.
|
|
201
|
+
return this._currentSearchText ?? (!this.multiple && this.value !== "" ? __privateMethod(this, _SearchableSelect_instances, textForValue_fn).call(this, this.value) ?? "" : "");
|
|
201
202
|
}
|
|
202
203
|
/**
|
|
203
204
|
* @internal
|
|
204
205
|
*/
|
|
205
206
|
_onInputInput(event) {
|
|
206
|
-
this.
|
|
207
|
+
this._currentSearchText = event.target.value;
|
|
207
208
|
}
|
|
208
209
|
/**
|
|
209
210
|
* @internal
|
|
@@ -217,7 +218,7 @@ exports.SearchableSelect = class SearchableSelect extends FormAssociatedSearchab
|
|
|
217
218
|
*/
|
|
218
219
|
_onInputBlur(_) {
|
|
219
220
|
this.open = false;
|
|
220
|
-
this.
|
|
221
|
+
this._currentSearchText = null;
|
|
221
222
|
this._changeDescription = "";
|
|
222
223
|
}
|
|
223
224
|
/**
|
|
@@ -335,6 +336,12 @@ exports.SearchableSelect = class SearchableSelect extends FormAssociatedSearchab
|
|
|
335
336
|
_tagIconSlotName(value) {
|
|
336
337
|
return `_tag-icon-${this.values.indexOf(value)}`;
|
|
337
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* @internal
|
|
341
|
+
*/
|
|
342
|
+
optionFilterChanged() {
|
|
343
|
+
__privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
|
|
344
|
+
}
|
|
338
345
|
// --- Tags ---
|
|
339
346
|
/**
|
|
340
347
|
* @internal
|
|
@@ -494,9 +501,6 @@ updateValuesThroughUserInteraction_fn = function(newValues) {
|
|
|
494
501
|
updateValuesWhileMaintainingOrder_fn = function(newValues) {
|
|
495
502
|
const oldSet = new Set(this.values);
|
|
496
503
|
const newSet = new Set(newValues);
|
|
497
|
-
if (oldSet.size === newSet.size && [...oldSet].every((v) => newSet.has(v))) {
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
504
|
this.values = [...this.values].filter((v) => newSet.has(v)).concat([...newValues].filter((v) => !oldSet.has(v)));
|
|
501
505
|
};
|
|
502
506
|
isValidValue_fn = function(value) {
|
|
@@ -533,7 +537,7 @@ handleOptionInteraction_fn = function(option) {
|
|
|
533
537
|
this._changeDescription = isSelection ? this.locale.searchableSelect.optionSelectedMessage(option.text) : this.locale.searchableSelect.optionDeselectedMessage(option.text);
|
|
534
538
|
__privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, newValues);
|
|
535
539
|
if (shouldClearSearchText) {
|
|
536
|
-
this.
|
|
540
|
+
this._currentSearchText = null;
|
|
537
541
|
}
|
|
538
542
|
};
|
|
539
543
|
_clonedTagIcons = new WeakMap();
|
|
@@ -559,17 +563,12 @@ updateClonedTagIconOfOption_fn = function(option) {
|
|
|
559
563
|
};
|
|
560
564
|
updateFilteredOptions_fn = function() {
|
|
561
565
|
const newFilteredOptions = [];
|
|
562
|
-
const
|
|
566
|
+
const optionFilter = this.optionFilter ?? ((option, searchText) => option.text.toLowerCase().includes(searchText.toLowerCase()));
|
|
563
567
|
for (const option of this._slottedOptions ?? []) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
const matches = filterOption(option, this.searchText);
|
|
569
|
-
option._hidden = !matches;
|
|
570
|
-
option._internalHighlightText = matches ? this.searchText : "";
|
|
571
|
-
}
|
|
572
|
-
if (!option.hidden && !option._hidden) {
|
|
568
|
+
option._vvdSearchText = this.searchText;
|
|
569
|
+
const matches = !this.searchText || optionFilter(option, this.searchText);
|
|
570
|
+
option._isNotMatching = !matches;
|
|
571
|
+
if (!option.hidden && matches) {
|
|
573
572
|
newFilteredOptions.push(option);
|
|
574
573
|
}
|
|
575
574
|
}
|
|
@@ -630,10 +629,7 @@ highlightNextOption_fn = function() {
|
|
|
630
629
|
__privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? -1) + 1);
|
|
631
630
|
};
|
|
632
631
|
textForValue_fn = function(value) {
|
|
633
|
-
|
|
634
|
-
(option2) => option2.value === value
|
|
635
|
-
);
|
|
636
|
-
return option.text;
|
|
632
|
+
return this._slottedOptions?.find((option) => option.value === value)?.text;
|
|
637
633
|
};
|
|
638
634
|
/**
|
|
639
635
|
* @internal
|
|
@@ -801,19 +797,19 @@ __decorateClass$1([
|
|
|
801
797
|
], exports.SearchableSelect.prototype, "_input", 2);
|
|
802
798
|
__decorateClass$1([
|
|
803
799
|
vividElement.observable
|
|
804
|
-
], exports.SearchableSelect.prototype, "
|
|
800
|
+
], exports.SearchableSelect.prototype, "_currentSearchText", 2);
|
|
805
801
|
__decorateClass$1([
|
|
806
802
|
vividElement.observable
|
|
807
803
|
], exports.SearchableSelect.prototype, "_slottedOptions", 2);
|
|
808
804
|
__decorateClass$1([
|
|
809
805
|
vividElement.observable
|
|
810
|
-
], exports.SearchableSelect.prototype, "
|
|
806
|
+
], exports.SearchableSelect.prototype, "optionFilter", 2);
|
|
811
807
|
__decorateClass$1([
|
|
812
808
|
vividElement.observable
|
|
813
|
-
], exports.SearchableSelect.prototype, "
|
|
809
|
+
], exports.SearchableSelect.prototype, "_filteredOptions", 2);
|
|
814
810
|
__decorateClass$1([
|
|
815
811
|
vividElement.observable
|
|
816
|
-
], exports.SearchableSelect.prototype, "
|
|
812
|
+
], exports.SearchableSelect.prototype, "_filteredEnabledOptions", 2);
|
|
817
813
|
__decorateClass$1([
|
|
818
814
|
vividElement.attr({
|
|
819
815
|
mode: "boolean"
|
|
@@ -1084,8 +1080,8 @@ function renderControl(context) {
|
|
|
1084
1080
|
vividElement.html`<div class="empty-message">
|
|
1085
1081
|
${when.when(
|
|
1086
1082
|
(x) => x.loading,
|
|
1087
|
-
vividElement.html
|
|
1088
|
-
|
|
1083
|
+
vividElement.html`<slot name="loading-options">
|
|
1084
|
+
${(x) => x.locale.searchableSelect.loadingOptionsMessage}
|
|
1089
1085
|
</slot>`
|
|
1090
1086
|
)}
|
|
1091
1087
|
${when.when(
|