@vonage/vivid 4.28.0 → 4.30.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 +707 -86
- package/lib/accordion-item/accordion-item.d.ts +3 -1
- package/lib/audio-player/audio-player.d.ts +4 -3
- package/lib/data-grid/data-grid.d.ts +2 -0
- package/lib/data-grid/locale.d.ts +1 -0
- package/lib/date-picker/date-picker.d.ts +4 -2
- package/lib/date-time-picker/date-time-picker.d.ts +6 -3
- package/lib/divider/definition.d.ts +1 -0
- package/lib/divider/divider.d.ts +5 -1
- package/lib/option/option.d.ts +4 -7
- package/lib/rich-text-editor/facades/prose-mirror-vivid.schema.d.ts +2 -1
- package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +2 -2
- package/lib/rich-text-editor/image-placeholder/definition.d.ts +2 -0
- package/lib/rich-text-editor/image-placeholder/image-placeholder.d.ts +7 -0
- package/lib/rich-text-editor/image-placeholder/image-placeholder.template.d.ts +4 -0
- package/lib/rich-text-editor/menubar/consts.d.ts +2 -2
- package/lib/rich-text-editor/menubar/definition.d.ts +2 -2
- package/lib/rich-text-editor/menubar/menubar.d.ts +2 -2
- package/lib/rich-text-editor/menubar/menubar.template.d.ts +2 -2
- package/lib/rich-text-editor/rich-text-editor.d.ts +1 -0
- package/lib/selectable-box/selectable-box.d.ts +2 -0
- package/lib/split-button/split-button.d.ts +1 -1
- package/lib/tag/tag.d.ts +1 -1
- package/lib/time-picker/time-picker.d.ts +4 -2
- package/locales/de-DE.cjs +2 -1
- package/locales/de-DE.js +2 -1
- package/locales/en-GB.cjs +2 -1
- package/locales/en-GB.js +2 -1
- package/locales/en-US.cjs +2 -1
- package/locales/en-US.js +2 -1
- package/locales/ja-JP.cjs +2 -1
- package/locales/ja-JP.js +2 -1
- package/locales/zh-CN.cjs +2 -1
- package/locales/zh-CN.js +2 -1
- package/package.json +2 -1
- package/shared/calendar-picker.template.cjs +6 -5
- package/shared/calendar-picker.template.js +6 -5
- package/shared/definition.cjs +11 -2
- package/shared/definition.js +11 -2
- package/shared/definition16.cjs +33 -30
- package/shared/definition16.js +33 -30
- package/shared/definition17.cjs +137 -1
- package/shared/definition17.js +138 -2
- package/shared/definition23.cjs +12 -7
- package/shared/definition23.js +12 -7
- package/shared/definition28.cjs +1 -2
- package/shared/definition28.js +2 -2
- package/shared/definition36.cjs +1 -1
- package/shared/definition36.js +1 -1
- package/shared/definition44.cjs +194 -77
- package/shared/definition44.js +194 -77
- package/shared/definition45.cjs +12 -5
- package/shared/definition45.js +12 -5
- package/shared/definition47.cjs +11 -5
- package/shared/definition47.js +11 -5
- package/shared/definition5.cjs +86 -30
- package/shared/definition5.js +86 -30
- package/shared/definition50.cjs +1 -1
- package/shared/definition50.js +1 -1
- package/shared/definition56.cjs +1 -1
- package/shared/definition56.js +1 -1
- package/shared/definition58.cjs +10 -29
- package/shared/definition58.js +12 -31
- package/shared/definition61.cjs +11 -0
- package/shared/definition61.js +11 -0
- package/shared/definition64.cjs +1 -1
- package/shared/definition64.js +1 -1
- package/shared/definition67.cjs +27 -16
- package/shared/definition67.js +27 -16
- package/shared/divider.cjs +7 -2
- package/shared/divider.js +7 -2
- package/shared/option.cjs +36 -38
- package/shared/option.js +37 -39
- package/shared/picker-field/mixins/single-date-picker.d.ts +4 -2
- package/shared/picker-field/mixins/single-value-picker.d.ts +2 -1
- package/shared/picker-field/mixins/time-selection-picker.d.ts +4 -2
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +4 -2
- package/shared/single-value-picker.cjs +40 -6
- package/shared/single-value-picker.js +40 -6
- package/shared/text-field.cjs +1 -1
- package/shared/text-field.js +1 -1
- package/shared/time-selection-picker.template.cjs +2 -2
- package/shared/time-selection-picker.template.js +2 -2
- package/shared/vivid-element.cjs +2 -1
- package/shared/vivid-element.js +2 -2
- 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 +294 -129
package/shared/definition44.cjs
CHANGED
|
@@ -13,11 +13,13 @@ const option = require('./option.cjs');
|
|
|
13
13
|
const repeat = require('./repeat.cjs');
|
|
14
14
|
const classNames = require('./class-names.cjs');
|
|
15
15
|
const localized = require('./localized.cjs');
|
|
16
|
+
const definition$7 = require('./definition28.cjs');
|
|
17
|
+
const when = require('./when.cjs');
|
|
16
18
|
|
|
17
|
-
const styles$
|
|
19
|
+
const styles$2 = "@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)}:host{display:block}#editor{--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}#editor{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}#editor ::-webkit-scrollbar{width:4px}#editor ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}#editor ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}#editor{position:relative;display:flex;flex-direction:column;block-size:100%;overflow-y:auto}[contenteditable=true]{overflow:unset;block-size:unset}#attachments-wrapper{order:1}#attachments-wrapper .divider{padding:0 12px}.hidden{display:none}.drag-overlay{position:absolute;z-index:10;display:none;align-items:center;justify-content:center;border:1px dashed var(--vvd-color-cta-400);border-radius:8px;background:var(--vvd-color-cta-100);font:var(--vvd-typography-base);inset:0;opacity:.8;pointer-events:none;transition:opacity .2s}.drag-over .drag-overlay{display:flex}";
|
|
18
20
|
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
+
function notifyMenubarChange(menubar, eventName, payload) {
|
|
22
|
+
menubar.$emit(eventName, payload, { bubbles: false, composed: false });
|
|
21
23
|
return true;
|
|
22
24
|
}
|
|
23
25
|
const TEXT_DECORATION_ITEMS = [
|
|
@@ -108,8 +110,8 @@ const textSizeEventHandler = (event) => {
|
|
|
108
110
|
};
|
|
109
111
|
const MENU_BAR_ITEMS = {
|
|
110
112
|
textBlock: {
|
|
111
|
-
registerStateProperty: function(
|
|
112
|
-
|
|
113
|
+
registerStateProperty: function(menubar) {
|
|
114
|
+
menubar.addEventListener("text-styles-changed", textBlockEventHandler);
|
|
113
115
|
},
|
|
114
116
|
render: function(context) {
|
|
115
117
|
const selectTag = context.tagFor(definition$4.Select);
|
|
@@ -127,7 +129,7 @@ const MENU_BAR_ITEMS = {
|
|
|
127
129
|
aria-label="Text Block"
|
|
128
130
|
placement="bottom-end"
|
|
129
131
|
value="${(_, { parent }) => parent.textBlockType}"
|
|
130
|
-
@change="${(_, { parent, event }) =>
|
|
132
|
+
@change="${(_, { parent, event }) => notifyMenubarChange(
|
|
131
133
|
parent,
|
|
132
134
|
"text-block-selected",
|
|
133
135
|
event.target.value
|
|
@@ -160,8 +162,8 @@ const MENU_BAR_ITEMS = {
|
|
|
160
162
|
}
|
|
161
163
|
},
|
|
162
164
|
textDecoration: {
|
|
163
|
-
registerStateProperty: function(
|
|
164
|
-
|
|
165
|
+
registerStateProperty: function(menubar) {
|
|
166
|
+
menubar.addEventListener(
|
|
165
167
|
"text-styles-changed",
|
|
166
168
|
textDecorationEventHandler
|
|
167
169
|
);
|
|
@@ -183,7 +185,7 @@ const MENU_BAR_ITEMS = {
|
|
|
183
185
|
appearance="ghost-light"
|
|
184
186
|
shape="rounded"
|
|
185
187
|
icon="${(x) => x.icon}"
|
|
186
|
-
@click="${(x, c) =>
|
|
188
|
+
@click="${(x, c) => notifyMenubarChange(
|
|
187
189
|
c.parentContext.parent,
|
|
188
190
|
"text-decoration-selected",
|
|
189
191
|
x.value
|
|
@@ -197,8 +199,8 @@ const MENU_BAR_ITEMS = {
|
|
|
197
199
|
}
|
|
198
200
|
},
|
|
199
201
|
textSize: {
|
|
200
|
-
registerStateProperty: function(
|
|
201
|
-
|
|
202
|
+
registerStateProperty: function(menubar) {
|
|
203
|
+
menubar.addEventListener("text-styles-changed", textSizeEventHandler);
|
|
202
204
|
},
|
|
203
205
|
render: function(context) {
|
|
204
206
|
const menuTag = context.tagFor(definition.Menu);
|
|
@@ -234,7 +236,7 @@ const MENU_BAR_ITEMS = {
|
|
|
234
236
|
internal-part
|
|
235
237
|
class="menubar-selector-menuitem"
|
|
236
238
|
connotation="cta"
|
|
237
|
-
@click="${(x, c) =>
|
|
239
|
+
@click="${(x, c) => notifyMenubarChange(
|
|
238
240
|
c.parentContext.parent,
|
|
239
241
|
"text-size-selected",
|
|
240
242
|
x.value
|
|
@@ -256,16 +258,16 @@ const MENU_BAR_ITEMS = {
|
|
|
256
258
|
}
|
|
257
259
|
};
|
|
258
260
|
|
|
259
|
-
var __defProp$
|
|
260
|
-
var __decorateClass$
|
|
261
|
+
var __defProp$2 = Object.defineProperty;
|
|
262
|
+
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
261
263
|
var result = void 0 ;
|
|
262
264
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
263
265
|
if (decorator = decorators[i])
|
|
264
266
|
result = (decorator(target, key, result) ) || result;
|
|
265
|
-
if (result) __defProp$
|
|
267
|
+
if (result) __defProp$2(target, key, result);
|
|
266
268
|
return result;
|
|
267
269
|
};
|
|
268
|
-
class
|
|
270
|
+
class Menubar extends localized.Localized(vividElement.VividElement) {
|
|
269
271
|
get #textEditorElement() {
|
|
270
272
|
return this.parentElement;
|
|
271
273
|
}
|
|
@@ -299,13 +301,13 @@ class MenuBar extends localized.Localized(vividElement.VividElement) {
|
|
|
299
301
|
);
|
|
300
302
|
}
|
|
301
303
|
}
|
|
302
|
-
__decorateClass$
|
|
304
|
+
__decorateClass$2([
|
|
303
305
|
vividElement.attr({ attribute: "menu-items" })
|
|
304
|
-
],
|
|
306
|
+
], Menubar.prototype, "menuItems");
|
|
305
307
|
|
|
306
|
-
const getClasses$
|
|
308
|
+
const getClasses$2 = (menubar) => classNames.classNames("control", [
|
|
307
309
|
"hide-menubar",
|
|
308
|
-
getValidMenuItems(
|
|
310
|
+
getValidMenuItems(menubar).length === 0
|
|
309
311
|
]);
|
|
310
312
|
const validItems = ["textBlock", "textDecoration", "textSize", "divider"];
|
|
311
313
|
function getPropertyStateRgistrationFunction(item) {
|
|
@@ -326,18 +328,18 @@ function renderMenuItems(context) {
|
|
|
326
328
|
}}`
|
|
327
329
|
)}`;
|
|
328
330
|
}
|
|
329
|
-
const
|
|
330
|
-
return vividElement.html`<template class="${getClasses$
|
|
331
|
+
const MenubarTemplate = (context) => {
|
|
332
|
+
return vividElement.html`<template class="${getClasses$2}">
|
|
331
333
|
${renderMenuItems(context)}
|
|
332
334
|
</template>`;
|
|
333
335
|
};
|
|
334
336
|
|
|
335
|
-
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}";
|
|
337
|
+
const styles$1 = ":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}";
|
|
336
338
|
|
|
337
|
-
const
|
|
339
|
+
const menubarDefinition = vividElement.defineVividComponent(
|
|
338
340
|
"menubar",
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
Menubar,
|
|
342
|
+
MenubarTemplate,
|
|
341
343
|
[
|
|
342
344
|
definition$1.buttonDefinition,
|
|
343
345
|
definition$4.selectDefinition,
|
|
@@ -348,7 +350,7 @@ const menuBarDefinition = vividElement.defineVividComponent(
|
|
|
348
350
|
definition$3.menuItemDefinition
|
|
349
351
|
],
|
|
350
352
|
{
|
|
351
|
-
styles,
|
|
353
|
+
styles: styles$1,
|
|
352
354
|
shadowOptions: {
|
|
353
355
|
delegatesFocus: true
|
|
354
356
|
}
|
|
@@ -763,7 +765,7 @@ class Fragment {
|
|
|
763
765
|
position in this fragment. The result object will be reused
|
|
764
766
|
(overwritten) the next time the function is called. @internal
|
|
765
767
|
*/
|
|
766
|
-
findIndex(pos
|
|
768
|
+
findIndex(pos) {
|
|
767
769
|
if (pos == 0)
|
|
768
770
|
return retIndex(0, pos);
|
|
769
771
|
if (pos == this.size)
|
|
@@ -773,7 +775,7 @@ class Fragment {
|
|
|
773
775
|
for (let i = 0, curPos = 0;; i++) {
|
|
774
776
|
let cur = this.child(i), end = curPos + cur.nodeSize;
|
|
775
777
|
if (end >= pos) {
|
|
776
|
-
if (end == pos
|
|
778
|
+
if (end == pos)
|
|
777
779
|
return retIndex(i + 1, end);
|
|
778
780
|
return retIndex(i, curPos);
|
|
779
781
|
}
|
|
@@ -1734,7 +1736,7 @@ class Node {
|
|
|
1734
1736
|
`blockSeparator` is given, it will be inserted to separate text
|
|
1735
1737
|
from different block nodes. If `leafText` is given, it'll be
|
|
1736
1738
|
inserted for every non-text leaf node encountered, otherwise
|
|
1737
|
-
[`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec
|
|
1739
|
+
[`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec.leafText) will be used.
|
|
1738
1740
|
*/
|
|
1739
1741
|
textBetween(from, to, blockSeparator, leafText) {
|
|
1740
1742
|
return this.content.textBetween(from, to, blockSeparator, leafText);
|
|
@@ -2944,8 +2946,8 @@ class Schema {
|
|
|
2944
2946
|
let type = this.marks[prop], excl = type.spec.excludes;
|
|
2945
2947
|
type.excluded = excl == null ? [type] : excl == "" ? [] : gatherMarks(this, excl.split(" "));
|
|
2946
2948
|
}
|
|
2947
|
-
this.nodeFromJSON =
|
|
2948
|
-
this.markFromJSON =
|
|
2949
|
+
this.nodeFromJSON = json => Node.fromJSON(this, json);
|
|
2950
|
+
this.markFromJSON = json => Mark.fromJSON(this, json);
|
|
2949
2951
|
this.topNodeType = this.nodes[this.spec.topNode || "doc"];
|
|
2950
2952
|
this.cached.wrappings = Object.create(null);
|
|
2951
2953
|
}
|
|
@@ -2981,20 +2983,6 @@ class Schema {
|
|
|
2981
2983
|
return type.create(attrs);
|
|
2982
2984
|
}
|
|
2983
2985
|
/**
|
|
2984
|
-
Deserialize a node from its JSON representation. This method is
|
|
2985
|
-
bound.
|
|
2986
|
-
*/
|
|
2987
|
-
nodeFromJSON(json) {
|
|
2988
|
-
return Node.fromJSON(this, json);
|
|
2989
|
-
}
|
|
2990
|
-
/**
|
|
2991
|
-
Deserialize a mark from its JSON representation. This method is
|
|
2992
|
-
bound.
|
|
2993
|
-
*/
|
|
2994
|
-
markFromJSON(json) {
|
|
2995
|
-
return Mark.fromJSON(this, json);
|
|
2996
|
-
}
|
|
2997
|
-
/**
|
|
2998
2986
|
@internal
|
|
2999
2987
|
*/
|
|
3000
2988
|
nodeType(name) {
|
|
@@ -3176,7 +3164,7 @@ class DOMParser {
|
|
|
3176
3164
|
/**
|
|
3177
3165
|
Construct a DOM parser using the parsing rules listed in a
|
|
3178
3166
|
schema's [node specs](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM), reordered by
|
|
3179
|
-
[priority](https://prosemirror.net/docs/ref/#model.
|
|
3167
|
+
[priority](https://prosemirror.net/docs/ref/#model.GenericParseRule.priority).
|
|
3180
3168
|
*/
|
|
3181
3169
|
static fromSchema(schema) {
|
|
3182
3170
|
return schema.cached.domParser ||
|
|
@@ -3927,6 +3915,8 @@ function renderSpec(doc, structure, xmlNS, blockArraysIn) {
|
|
|
3927
3915
|
let space = name.indexOf(" ");
|
|
3928
3916
|
if (space > 0)
|
|
3929
3917
|
dom.setAttributeNS(name.slice(0, space), name.slice(space + 1), attrs[name]);
|
|
3918
|
+
else if (name == "style" && dom.style)
|
|
3919
|
+
dom.style.cssText = attrs[name];
|
|
3930
3920
|
else
|
|
3931
3921
|
dom.setAttribute(name, attrs[name]);
|
|
3932
3922
|
}
|
|
@@ -7446,7 +7436,7 @@ function posFromCaret(view, node, offset, coords) {
|
|
|
7446
7436
|
if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM) &&
|
|
7447
7437
|
// Ignore elements with zero-size bounding rectangles
|
|
7448
7438
|
((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
|
|
7449
|
-
if (desc.node.isBlock && desc.parent) {
|
|
7439
|
+
if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {
|
|
7450
7440
|
// Only apply the horizontal test to the innermost block. Vertical for any parent.
|
|
7451
7441
|
if (!sawBlock && rect.left > coords.left || rect.top > coords.top)
|
|
7452
7442
|
outsideBlock = desc.posBefore;
|
|
@@ -11960,7 +11950,7 @@ function ruleFromNode(dom) {
|
|
|
11960
11950
|
}
|
|
11961
11951
|
return null;
|
|
11962
11952
|
}
|
|
11963
|
-
const isInline = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
|
|
11953
|
+
const isInline = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
|
|
11964
11954
|
function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
11965
11955
|
let compositionID = view.input.compositionPendingChanges || (view.composing ? view.input.compositionID : 0);
|
|
11966
11956
|
view.input.compositionPendingChanges = 0;
|
|
@@ -13883,13 +13873,51 @@ const customMarks = {
|
|
|
13883
13873
|
}
|
|
13884
13874
|
}
|
|
13885
13875
|
};
|
|
13886
|
-
const
|
|
13887
|
-
nodes:
|
|
13876
|
+
const dynamicSchema = (prefix = "vwc") => new Schema({
|
|
13877
|
+
nodes: {
|
|
13878
|
+
...schema.spec.nodes.toObject(),
|
|
13879
|
+
imageError: {
|
|
13880
|
+
inline: true,
|
|
13881
|
+
group: "inline",
|
|
13882
|
+
atom: true,
|
|
13883
|
+
attrs: {
|
|
13884
|
+
alt: { default: "" },
|
|
13885
|
+
icon: { default: "" },
|
|
13886
|
+
errorMessage: { default: "Failed to attach" },
|
|
13887
|
+
fileName: { default: "" }
|
|
13888
|
+
},
|
|
13889
|
+
toDOM(node) {
|
|
13890
|
+
return [
|
|
13891
|
+
`${prefix}-text-editor-image-placeholder`,
|
|
13892
|
+
{
|
|
13893
|
+
alt: node.attrs.alt,
|
|
13894
|
+
icon: node.attrs.icon,
|
|
13895
|
+
"error-message": node.attrs.errorMessage,
|
|
13896
|
+
"file-name": node.attrs.fileName
|
|
13897
|
+
}
|
|
13898
|
+
];
|
|
13899
|
+
},
|
|
13900
|
+
parseDOM: [
|
|
13901
|
+
{
|
|
13902
|
+
tag: `${prefix}-text-editor-image-placeholder`,
|
|
13903
|
+
getAttrs(dom) {
|
|
13904
|
+
return {
|
|
13905
|
+
alt: dom.getAttribute("alt"),
|
|
13906
|
+
icon: dom.getAttribute("icon"),
|
|
13907
|
+
errorMessage: dom.getAttribute("error-message"),
|
|
13908
|
+
fileName: dom.getAttribute("file-name")
|
|
13909
|
+
};
|
|
13910
|
+
}
|
|
13911
|
+
}
|
|
13912
|
+
]
|
|
13913
|
+
}
|
|
13914
|
+
},
|
|
13888
13915
|
marks: {
|
|
13889
13916
|
...schema.spec.marks.toObject(),
|
|
13890
13917
|
...customMarks
|
|
13891
13918
|
}
|
|
13892
13919
|
});
|
|
13920
|
+
dynamicSchema();
|
|
13893
13921
|
|
|
13894
13922
|
const NEGATIVE_SELECTION = {
|
|
13895
13923
|
start: -1,
|
|
@@ -13988,6 +14016,16 @@ function convertSelectionToVividFormat({
|
|
|
13988
14016
|
end: to
|
|
13989
14017
|
};
|
|
13990
14018
|
}
|
|
14019
|
+
function getImageErrorNode(schema, file, errorMessage = "Image loading failed") {
|
|
14020
|
+
const nodeType = schema.nodes.imageError;
|
|
14021
|
+
const imageErrorNode = nodeType.create({
|
|
14022
|
+
alt: `inline image from file ${file.name}`,
|
|
14023
|
+
fileName: file.name,
|
|
14024
|
+
icon: file.type.split("/")[1],
|
|
14025
|
+
errorMessage
|
|
14026
|
+
});
|
|
14027
|
+
return imageErrorNode;
|
|
14028
|
+
}
|
|
13991
14029
|
const isEmptyParagraph = (node) => {
|
|
13992
14030
|
return node.type.name === "paragraph" && node.nodeSize === 2;
|
|
13993
14031
|
};
|
|
@@ -14037,7 +14075,9 @@ class ProseMirrorFacade {
|
|
|
14037
14075
|
}
|
|
14038
14076
|
this.#dispatchEvent("change");
|
|
14039
14077
|
};
|
|
14040
|
-
|
|
14078
|
+
#vwcPrefix = "vwc";
|
|
14079
|
+
init(element, vwcPrefix = "vwc") {
|
|
14080
|
+
this.#vwcPrefix = vwcPrefix;
|
|
14041
14081
|
if (!(element instanceof HTMLElement)) {
|
|
14042
14082
|
throw new Error(
|
|
14043
14083
|
"ProseMirror Facade init accepts a valid HTMLElement as its first parameter"
|
|
@@ -14050,7 +14090,7 @@ class ProseMirrorFacade {
|
|
|
14050
14090
|
keymap(baseKeymap)
|
|
14051
14091
|
];
|
|
14052
14092
|
const state = EditorState.create({
|
|
14053
|
-
schema:
|
|
14093
|
+
schema: dynamicSchema(this.#vwcPrefix),
|
|
14054
14094
|
plugins
|
|
14055
14095
|
});
|
|
14056
14096
|
this.#view = new EditorView(element, { state });
|
|
@@ -14071,7 +14111,7 @@ class ProseMirrorFacade {
|
|
|
14071
14111
|
}
|
|
14072
14112
|
replaceContent(content) {
|
|
14073
14113
|
this.#verifyViewInitiation();
|
|
14074
|
-
const parser = DOMParser.fromSchema(
|
|
14114
|
+
const parser = DOMParser.fromSchema(this.#view.state.schema);
|
|
14075
14115
|
const doc = parser.parse(
|
|
14076
14116
|
new window.DOMParser().parseFromString(content, "text/html").body
|
|
14077
14117
|
);
|
|
@@ -14256,7 +14296,8 @@ class ProseMirrorFacade {
|
|
|
14256
14296
|
async addInlineImage({
|
|
14257
14297
|
file,
|
|
14258
14298
|
position,
|
|
14259
|
-
alt
|
|
14299
|
+
alt,
|
|
14300
|
+
error
|
|
14260
14301
|
}) {
|
|
14261
14302
|
this.#verifyViewInitiation();
|
|
14262
14303
|
const reader = new FileReader();
|
|
@@ -14268,7 +14309,7 @@ class ProseMirrorFacade {
|
|
|
14268
14309
|
const { state, dispatch } = this.#view;
|
|
14269
14310
|
const { schema } = state;
|
|
14270
14311
|
const imageAlt = alt ?? `inline image from file ${file.name}`;
|
|
14271
|
-
const imageNode = schema.nodes.image.create({ src, alt: imageAlt });
|
|
14312
|
+
const imageNode = error ? getImageErrorNode(schema, file, error) : schema.nodes.image.create({ src, alt: imageAlt });
|
|
14272
14313
|
let insertPos = position;
|
|
14273
14314
|
if (typeof insertPos !== "number") {
|
|
14274
14315
|
insertPos = state.selection.from;
|
|
@@ -14278,13 +14319,13 @@ class ProseMirrorFacade {
|
|
|
14278
14319
|
}
|
|
14279
14320
|
}
|
|
14280
14321
|
|
|
14281
|
-
var __defProp = Object.defineProperty;
|
|
14282
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
14322
|
+
var __defProp$1 = Object.defineProperty;
|
|
14323
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
14283
14324
|
var result = void 0 ;
|
|
14284
14325
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14285
14326
|
if (decorator = decorators[i])
|
|
14286
14327
|
result = (decorator(target, key, result) ) || result;
|
|
14287
|
-
if (result) __defProp(target, key, result);
|
|
14328
|
+
if (result) __defProp$1(target, key, result);
|
|
14288
14329
|
return result;
|
|
14289
14330
|
};
|
|
14290
14331
|
const RichTextEditorTextBlocks = {
|
|
@@ -14422,17 +14463,17 @@ class RichTextEditor extends localized.Localized(vividElement.VividElement) {
|
|
|
14422
14463
|
}
|
|
14423
14464
|
}
|
|
14424
14465
|
}
|
|
14425
|
-
__decorateClass([
|
|
14466
|
+
__decorateClass$1([
|
|
14426
14467
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-start" })
|
|
14427
14468
|
], RichTextEditor.prototype, "selectionStart");
|
|
14428
|
-
__decorateClass([
|
|
14469
|
+
__decorateClass$1([
|
|
14429
14470
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-end" })
|
|
14430
14471
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14431
|
-
__decorateClass([
|
|
14472
|
+
__decorateClass$1([
|
|
14432
14473
|
vividElement.attr
|
|
14433
14474
|
], RichTextEditor.prototype, "placeholder");
|
|
14434
14475
|
|
|
14435
|
-
const getClasses = (_) => classNames.classNames("control");
|
|
14476
|
+
const getClasses$1 = (_) => classNames.classNames("control");
|
|
14436
14477
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
14437
14478
|
const menuParent = (target) => target.parentElement;
|
|
14438
14479
|
function textBlockSelectedHandler(event) {
|
|
@@ -14460,29 +14501,29 @@ function handleAttachmentsSlotChange(_, { event }) {
|
|
|
14460
14501
|
slotElement.assignedElements().length < 1
|
|
14461
14502
|
);
|
|
14462
14503
|
}
|
|
14463
|
-
function
|
|
14504
|
+
function handleMenubarSlotChange(_, { event }) {
|
|
14464
14505
|
const slot = event.target;
|
|
14465
14506
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
14466
|
-
const
|
|
14507
|
+
const menubar = assignedElements.find(
|
|
14467
14508
|
(element) => element.tagName.toLowerCase().endsWith(VALID_MENU_ELEMEMENT_SUFFIX)
|
|
14468
14509
|
);
|
|
14469
14510
|
assignedElements.forEach((element) => {
|
|
14470
|
-
if (element ===
|
|
14511
|
+
if (element === menubar) {
|
|
14471
14512
|
element.style.removeProperty("display");
|
|
14472
14513
|
} else {
|
|
14473
14514
|
element.style.display = "none";
|
|
14474
14515
|
}
|
|
14475
14516
|
});
|
|
14476
|
-
if (
|
|
14477
|
-
|
|
14517
|
+
if (menubar) {
|
|
14518
|
+
menubar.addEventListener(
|
|
14478
14519
|
"text-block-selected",
|
|
14479
14520
|
textBlockSelectedHandler
|
|
14480
14521
|
);
|
|
14481
|
-
|
|
14522
|
+
menubar.addEventListener(
|
|
14482
14523
|
"text-decoration-selected",
|
|
14483
14524
|
selectionDecorationSelectedHandler
|
|
14484
14525
|
);
|
|
14485
|
-
|
|
14526
|
+
menubar.addEventListener(
|
|
14486
14527
|
"text-size-selected",
|
|
14487
14528
|
textSizeSelectedHandler
|
|
14488
14529
|
);
|
|
@@ -14506,9 +14547,9 @@ function handleDragLeave(_, { event }) {
|
|
|
14506
14547
|
}
|
|
14507
14548
|
const RichTextEditorTemplate = (context) => {
|
|
14508
14549
|
const dividerTag = context.tagFor(divider.Divider);
|
|
14509
|
-
return vividElement.html`<template class="${getClasses}">
|
|
14510
|
-
<div id="editor"
|
|
14511
|
-
class="editor"
|
|
14550
|
+
return vividElement.html`<template class="${getClasses$1}">
|
|
14551
|
+
<div id="editor"
|
|
14552
|
+
class="editor"
|
|
14512
14553
|
@drop="${handleFileDrop}"
|
|
14513
14554
|
@dragenter="${handleDragEnter}"
|
|
14514
14555
|
@dragleave="${handleDragLeave}"
|
|
@@ -14523,18 +14564,94 @@ const RichTextEditorTemplate = (context) => {
|
|
|
14523
14564
|
</slot>
|
|
14524
14565
|
</div>
|
|
14525
14566
|
</div>
|
|
14526
|
-
<slot name="menu-bar"
|
|
14527
|
-
@slotchange="${
|
|
14567
|
+
<slot name="menu-bar"
|
|
14568
|
+
@slotchange="${handleMenubarSlotChange}"></slot>
|
|
14528
14569
|
</template>`;
|
|
14529
14570
|
};
|
|
14530
14571
|
|
|
14572
|
+
const styles = ":host{white-space:normal}.image-placeholder{display:flex;width:250px;height:64px;box-sizing:border-box;align-items:center;padding:16px;border:1px solid var(--vvd-color-neutral-200);border-radius:12px;background-color:var(--vvd-color-canvas);gap:16px}.icon{display:flex;width:40px;height:40px;box-sizing:border-box;flex-shrink:0;align-items:center;justify-content:center;border-radius:8px;background-color:color-mix(in srgb,var(--vvd-color-neutral-950),transparent 90%);color:var(--vvd-color-neutral-600)}.info{display:flex;flex-direction:column;min-inline-size:0}.filename{display:flex;overflow:hidden;width:100%;max-width:220px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-condensed-bold);white-space:nowrap}.name{overflow:hidden;flex:1 1 auto;text-overflow:ellipsis}.suffix{flex:0 0 auto;margin-left:4px}.error{display:flex;align-items:center;color:var(--vvd-color-alert-600);font:var(--vvd-typography-base-condensed);gap:6px}";
|
|
14573
|
+
|
|
14574
|
+
var __defProp = Object.defineProperty;
|
|
14575
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
14576
|
+
var result = void 0 ;
|
|
14577
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14578
|
+
if (decorator = decorators[i])
|
|
14579
|
+
result = (decorator(target, key, result) ) || result;
|
|
14580
|
+
if (result) __defProp(target, key, result);
|
|
14581
|
+
return result;
|
|
14582
|
+
};
|
|
14583
|
+
class ImagePlaceholder extends vividElement.VividElement {
|
|
14584
|
+
}
|
|
14585
|
+
__decorateClass([
|
|
14586
|
+
vividElement.attr({ attribute: "file-name" })
|
|
14587
|
+
], ImagePlaceholder.prototype, "fileName");
|
|
14588
|
+
__decorateClass([
|
|
14589
|
+
vividElement.attr({ attribute: "size" })
|
|
14590
|
+
], ImagePlaceholder.prototype, "size");
|
|
14591
|
+
__decorateClass([
|
|
14592
|
+
vividElement.attr({ attribute: "error-message" })
|
|
14593
|
+
], ImagePlaceholder.prototype, "errorMessage");
|
|
14594
|
+
__decorateClass([
|
|
14595
|
+
vividElement.attr({ attribute: "icon" })
|
|
14596
|
+
], ImagePlaceholder.prototype, "icon");
|
|
14597
|
+
|
|
14598
|
+
const getClasses = (_) => classNames.classNames("base");
|
|
14599
|
+
const getIconName = ({ icon }) => {
|
|
14600
|
+
if (!icon) {
|
|
14601
|
+
return "clear-file-solid";
|
|
14602
|
+
}
|
|
14603
|
+
return `file-${icon}-solid`;
|
|
14604
|
+
};
|
|
14605
|
+
const getFileSuffix = (x) => {
|
|
14606
|
+
return x.fileName?.split(".").pop() || "";
|
|
14607
|
+
};
|
|
14608
|
+
const getFileName = (x) => {
|
|
14609
|
+
return x.fileName?.replace(/\.[^/.]+$/, "") || "";
|
|
14610
|
+
};
|
|
14611
|
+
const ImagePlaceholderTemplate = (context) => {
|
|
14612
|
+
const iconTag = context.tagFor(definition$7.Icon);
|
|
14613
|
+
return vividElement.html`<template class="${getClasses}">
|
|
14614
|
+
<div class="image-placeholder">
|
|
14615
|
+
<div class="icon">
|
|
14616
|
+
<${iconTag} name="${getIconName}" size="-5"></${iconTag}>
|
|
14617
|
+
</div>
|
|
14618
|
+
<div class="info">
|
|
14619
|
+
<div class="filename" title="${(x) => x.fileName}">
|
|
14620
|
+
<div class="name">${getFileName}</div>
|
|
14621
|
+
<div class="suffix">${getFileSuffix}</div>
|
|
14622
|
+
</div>
|
|
14623
|
+
${when.when(
|
|
14624
|
+
(x) => x.errorMessage,
|
|
14625
|
+
vividElement.html`<div class="error">
|
|
14626
|
+
<span class="error-icon"><${iconTag} name="error-solid" size="-6"></${iconTag}></span>
|
|
14627
|
+
<span class="error-text">${(x) => x.errorMessage}</span>
|
|
14628
|
+
</div>`
|
|
14629
|
+
)}
|
|
14630
|
+
</div>
|
|
14631
|
+
</div>
|
|
14632
|
+
</template>`;
|
|
14633
|
+
};
|
|
14634
|
+
|
|
14635
|
+
const imagePlaceholderDefinition = vividElement.defineVividComponent(
|
|
14636
|
+
"text-editor-image-placeholder",
|
|
14637
|
+
ImagePlaceholder,
|
|
14638
|
+
ImagePlaceholderTemplate,
|
|
14639
|
+
[definition$7.iconDefinition],
|
|
14640
|
+
{
|
|
14641
|
+
styles,
|
|
14642
|
+
shadowOptions: {
|
|
14643
|
+
delegatesFocus: true
|
|
14644
|
+
}
|
|
14645
|
+
}
|
|
14646
|
+
);
|
|
14647
|
+
|
|
14531
14648
|
const richTextEditorDefinition = vividElement.defineVividComponent(
|
|
14532
14649
|
"rich-text-editor",
|
|
14533
14650
|
RichTextEditor,
|
|
14534
14651
|
RichTextEditorTemplate,
|
|
14535
|
-
[
|
|
14652
|
+
[menubarDefinition, definition$6.dividerDefinition, imagePlaceholderDefinition],
|
|
14536
14653
|
{
|
|
14537
|
-
styles: styles$
|
|
14654
|
+
styles: styles$2,
|
|
14538
14655
|
shadowOptions: {
|
|
14539
14656
|
delegatesFocus: true
|
|
14540
14657
|
}
|