@vonage/vivid 4.27.0 → 4.29.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 +357 -80
- 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/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 +8 -9
- package/shared/calendar-picker.template.js +8 -9
- 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/definition30.cjs +2 -1
- package/shared/definition30.js +2 -1
- package/shared/definition31.cjs +5 -1
- package/shared/definition31.js +5 -1
- package/shared/definition36.cjs +1 -1
- package/shared/definition36.js +1 -1
- package/shared/definition44.cjs +184 -55
- package/shared/definition44.js +184 -55
- package/shared/definition45.cjs +12 -5
- package/shared/definition45.js +12 -5
- package/shared/definition5.cjs +86 -30
- package/shared/definition5.js +86 -30
- 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/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/inline-time-picker/inline-time-picker.d.ts +1 -0
- 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 +71 -22
- package/shared/time-selection-picker.template.js +71 -22
- 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 +211 -126
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
|
}
|
|
@@ -13883,13 +13885,51 @@ const customMarks = {
|
|
|
13883
13885
|
}
|
|
13884
13886
|
}
|
|
13885
13887
|
};
|
|
13886
|
-
const
|
|
13887
|
-
nodes:
|
|
13888
|
+
const dynamicSchema = (prefix = "vwc") => new Schema({
|
|
13889
|
+
nodes: {
|
|
13890
|
+
...schema.spec.nodes.toObject(),
|
|
13891
|
+
imageError: {
|
|
13892
|
+
inline: true,
|
|
13893
|
+
group: "inline",
|
|
13894
|
+
atom: true,
|
|
13895
|
+
attrs: {
|
|
13896
|
+
alt: { default: "" },
|
|
13897
|
+
icon: { default: "" },
|
|
13898
|
+
errorMessage: { default: "Failed to attach" },
|
|
13899
|
+
fileName: { default: "" }
|
|
13900
|
+
},
|
|
13901
|
+
toDOM(node) {
|
|
13902
|
+
return [
|
|
13903
|
+
`${prefix}-text-editor-image-placeholder`,
|
|
13904
|
+
{
|
|
13905
|
+
alt: node.attrs.alt,
|
|
13906
|
+
icon: node.attrs.icon,
|
|
13907
|
+
"error-message": node.attrs.errorMessage,
|
|
13908
|
+
"file-name": node.attrs.fileName
|
|
13909
|
+
}
|
|
13910
|
+
];
|
|
13911
|
+
},
|
|
13912
|
+
parseDOM: [
|
|
13913
|
+
{
|
|
13914
|
+
tag: `${prefix}-text-editor-image-placeholder`,
|
|
13915
|
+
getAttrs(dom) {
|
|
13916
|
+
return {
|
|
13917
|
+
alt: dom.getAttribute("alt"),
|
|
13918
|
+
icon: dom.getAttribute("icon"),
|
|
13919
|
+
errorMessage: dom.getAttribute("error-message"),
|
|
13920
|
+
fileName: dom.getAttribute("file-name")
|
|
13921
|
+
};
|
|
13922
|
+
}
|
|
13923
|
+
}
|
|
13924
|
+
]
|
|
13925
|
+
}
|
|
13926
|
+
},
|
|
13888
13927
|
marks: {
|
|
13889
13928
|
...schema.spec.marks.toObject(),
|
|
13890
13929
|
...customMarks
|
|
13891
13930
|
}
|
|
13892
13931
|
});
|
|
13932
|
+
dynamicSchema();
|
|
13893
13933
|
|
|
13894
13934
|
const NEGATIVE_SELECTION = {
|
|
13895
13935
|
start: -1,
|
|
@@ -13988,6 +14028,16 @@ function convertSelectionToVividFormat({
|
|
|
13988
14028
|
end: to
|
|
13989
14029
|
};
|
|
13990
14030
|
}
|
|
14031
|
+
function getImageErrorNode(schema, file, errorMessage = "Image loading failed") {
|
|
14032
|
+
const nodeType = schema.nodes.imageError;
|
|
14033
|
+
const imageErrorNode = nodeType.create({
|
|
14034
|
+
alt: `inline image from file ${file.name}`,
|
|
14035
|
+
fileName: file.name,
|
|
14036
|
+
icon: file.type.split("/")[1],
|
|
14037
|
+
errorMessage
|
|
14038
|
+
});
|
|
14039
|
+
return imageErrorNode;
|
|
14040
|
+
}
|
|
13991
14041
|
const isEmptyParagraph = (node) => {
|
|
13992
14042
|
return node.type.name === "paragraph" && node.nodeSize === 2;
|
|
13993
14043
|
};
|
|
@@ -14037,7 +14087,9 @@ class ProseMirrorFacade {
|
|
|
14037
14087
|
}
|
|
14038
14088
|
this.#dispatchEvent("change");
|
|
14039
14089
|
};
|
|
14040
|
-
|
|
14090
|
+
#vwcPrefix = "vwc";
|
|
14091
|
+
init(element, vwcPrefix = "vwc") {
|
|
14092
|
+
this.#vwcPrefix = vwcPrefix;
|
|
14041
14093
|
if (!(element instanceof HTMLElement)) {
|
|
14042
14094
|
throw new Error(
|
|
14043
14095
|
"ProseMirror Facade init accepts a valid HTMLElement as its first parameter"
|
|
@@ -14050,7 +14102,7 @@ class ProseMirrorFacade {
|
|
|
14050
14102
|
keymap(baseKeymap)
|
|
14051
14103
|
];
|
|
14052
14104
|
const state = EditorState.create({
|
|
14053
|
-
schema:
|
|
14105
|
+
schema: dynamicSchema(this.#vwcPrefix),
|
|
14054
14106
|
plugins
|
|
14055
14107
|
});
|
|
14056
14108
|
this.#view = new EditorView(element, { state });
|
|
@@ -14071,7 +14123,7 @@ class ProseMirrorFacade {
|
|
|
14071
14123
|
}
|
|
14072
14124
|
replaceContent(content) {
|
|
14073
14125
|
this.#verifyViewInitiation();
|
|
14074
|
-
const parser = DOMParser.fromSchema(
|
|
14126
|
+
const parser = DOMParser.fromSchema(this.#view.state.schema);
|
|
14075
14127
|
const doc = parser.parse(
|
|
14076
14128
|
new window.DOMParser().parseFromString(content, "text/html").body
|
|
14077
14129
|
);
|
|
@@ -14256,7 +14308,8 @@ class ProseMirrorFacade {
|
|
|
14256
14308
|
async addInlineImage({
|
|
14257
14309
|
file,
|
|
14258
14310
|
position,
|
|
14259
|
-
alt
|
|
14311
|
+
alt,
|
|
14312
|
+
error
|
|
14260
14313
|
}) {
|
|
14261
14314
|
this.#verifyViewInitiation();
|
|
14262
14315
|
const reader = new FileReader();
|
|
@@ -14268,7 +14321,7 @@ class ProseMirrorFacade {
|
|
|
14268
14321
|
const { state, dispatch } = this.#view;
|
|
14269
14322
|
const { schema } = state;
|
|
14270
14323
|
const imageAlt = alt ?? `inline image from file ${file.name}`;
|
|
14271
|
-
const imageNode = schema.nodes.image.create({ src, alt: imageAlt });
|
|
14324
|
+
const imageNode = error ? getImageErrorNode(schema, file, error) : schema.nodes.image.create({ src, alt: imageAlt });
|
|
14272
14325
|
let insertPos = position;
|
|
14273
14326
|
if (typeof insertPos !== "number") {
|
|
14274
14327
|
insertPos = state.selection.from;
|
|
@@ -14278,13 +14331,13 @@ class ProseMirrorFacade {
|
|
|
14278
14331
|
}
|
|
14279
14332
|
}
|
|
14280
14333
|
|
|
14281
|
-
var __defProp = Object.defineProperty;
|
|
14282
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
14334
|
+
var __defProp$1 = Object.defineProperty;
|
|
14335
|
+
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
14283
14336
|
var result = void 0 ;
|
|
14284
14337
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14285
14338
|
if (decorator = decorators[i])
|
|
14286
14339
|
result = (decorator(target, key, result) ) || result;
|
|
14287
|
-
if (result) __defProp(target, key, result);
|
|
14340
|
+
if (result) __defProp$1(target, key, result);
|
|
14288
14341
|
return result;
|
|
14289
14342
|
};
|
|
14290
14343
|
const RichTextEditorTextBlocks = {
|
|
@@ -14422,17 +14475,17 @@ class RichTextEditor extends localized.Localized(vividElement.VividElement) {
|
|
|
14422
14475
|
}
|
|
14423
14476
|
}
|
|
14424
14477
|
}
|
|
14425
|
-
__decorateClass([
|
|
14478
|
+
__decorateClass$1([
|
|
14426
14479
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-start" })
|
|
14427
14480
|
], RichTextEditor.prototype, "selectionStart");
|
|
14428
|
-
__decorateClass([
|
|
14481
|
+
__decorateClass$1([
|
|
14429
14482
|
vividElement.attr({ converter: vividElement.nullableNumberConverter, attribute: "selection-end" })
|
|
14430
14483
|
], RichTextEditor.prototype, "selectionEnd");
|
|
14431
|
-
__decorateClass([
|
|
14484
|
+
__decorateClass$1([
|
|
14432
14485
|
vividElement.attr
|
|
14433
14486
|
], RichTextEditor.prototype, "placeholder");
|
|
14434
14487
|
|
|
14435
|
-
const getClasses = (_) => classNames.classNames("control");
|
|
14488
|
+
const getClasses$1 = (_) => classNames.classNames("control");
|
|
14436
14489
|
const VALID_MENU_ELEMEMENT_SUFFIX = "menubar";
|
|
14437
14490
|
const menuParent = (target) => target.parentElement;
|
|
14438
14491
|
function textBlockSelectedHandler(event) {
|
|
@@ -14460,29 +14513,29 @@ function handleAttachmentsSlotChange(_, { event }) {
|
|
|
14460
14513
|
slotElement.assignedElements().length < 1
|
|
14461
14514
|
);
|
|
14462
14515
|
}
|
|
14463
|
-
function
|
|
14516
|
+
function handleMenubarSlotChange(_, { event }) {
|
|
14464
14517
|
const slot = event.target;
|
|
14465
14518
|
const assignedElements = slot.assignedElements({ flatten: true });
|
|
14466
|
-
const
|
|
14519
|
+
const menubar = assignedElements.find(
|
|
14467
14520
|
(element) => element.tagName.toLowerCase().endsWith(VALID_MENU_ELEMEMENT_SUFFIX)
|
|
14468
14521
|
);
|
|
14469
14522
|
assignedElements.forEach((element) => {
|
|
14470
|
-
if (element ===
|
|
14523
|
+
if (element === menubar) {
|
|
14471
14524
|
element.style.removeProperty("display");
|
|
14472
14525
|
} else {
|
|
14473
14526
|
element.style.display = "none";
|
|
14474
14527
|
}
|
|
14475
14528
|
});
|
|
14476
|
-
if (
|
|
14477
|
-
|
|
14529
|
+
if (menubar) {
|
|
14530
|
+
menubar.addEventListener(
|
|
14478
14531
|
"text-block-selected",
|
|
14479
14532
|
textBlockSelectedHandler
|
|
14480
14533
|
);
|
|
14481
|
-
|
|
14534
|
+
menubar.addEventListener(
|
|
14482
14535
|
"text-decoration-selected",
|
|
14483
14536
|
selectionDecorationSelectedHandler
|
|
14484
14537
|
);
|
|
14485
|
-
|
|
14538
|
+
menubar.addEventListener(
|
|
14486
14539
|
"text-size-selected",
|
|
14487
14540
|
textSizeSelectedHandler
|
|
14488
14541
|
);
|
|
@@ -14506,9 +14559,9 @@ function handleDragLeave(_, { event }) {
|
|
|
14506
14559
|
}
|
|
14507
14560
|
const RichTextEditorTemplate = (context) => {
|
|
14508
14561
|
const dividerTag = context.tagFor(divider.Divider);
|
|
14509
|
-
return vividElement.html`<template class="${getClasses}">
|
|
14510
|
-
<div id="editor"
|
|
14511
|
-
class="editor"
|
|
14562
|
+
return vividElement.html`<template class="${getClasses$1}">
|
|
14563
|
+
<div id="editor"
|
|
14564
|
+
class="editor"
|
|
14512
14565
|
@drop="${handleFileDrop}"
|
|
14513
14566
|
@dragenter="${handleDragEnter}"
|
|
14514
14567
|
@dragleave="${handleDragLeave}"
|
|
@@ -14523,18 +14576,94 @@ const RichTextEditorTemplate = (context) => {
|
|
|
14523
14576
|
</slot>
|
|
14524
14577
|
</div>
|
|
14525
14578
|
</div>
|
|
14526
|
-
<slot name="menu-bar"
|
|
14527
|
-
@slotchange="${
|
|
14579
|
+
<slot name="menu-bar"
|
|
14580
|
+
@slotchange="${handleMenubarSlotChange}"></slot>
|
|
14581
|
+
</template>`;
|
|
14582
|
+
};
|
|
14583
|
+
|
|
14584
|
+
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}";
|
|
14585
|
+
|
|
14586
|
+
var __defProp = Object.defineProperty;
|
|
14587
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
14588
|
+
var result = void 0 ;
|
|
14589
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14590
|
+
if (decorator = decorators[i])
|
|
14591
|
+
result = (decorator(target, key, result) ) || result;
|
|
14592
|
+
if (result) __defProp(target, key, result);
|
|
14593
|
+
return result;
|
|
14594
|
+
};
|
|
14595
|
+
class ImagePlaceholder extends vividElement.VividElement {
|
|
14596
|
+
}
|
|
14597
|
+
__decorateClass([
|
|
14598
|
+
vividElement.attr({ attribute: "file-name" })
|
|
14599
|
+
], ImagePlaceholder.prototype, "fileName");
|
|
14600
|
+
__decorateClass([
|
|
14601
|
+
vividElement.attr({ attribute: "size" })
|
|
14602
|
+
], ImagePlaceholder.prototype, "size");
|
|
14603
|
+
__decorateClass([
|
|
14604
|
+
vividElement.attr({ attribute: "error-message" })
|
|
14605
|
+
], ImagePlaceholder.prototype, "errorMessage");
|
|
14606
|
+
__decorateClass([
|
|
14607
|
+
vividElement.attr({ attribute: "icon" })
|
|
14608
|
+
], ImagePlaceholder.prototype, "icon");
|
|
14609
|
+
|
|
14610
|
+
const getClasses = (_) => classNames.classNames("base");
|
|
14611
|
+
const getIconName = ({ icon }) => {
|
|
14612
|
+
if (!icon) {
|
|
14613
|
+
return "clear-file-solid";
|
|
14614
|
+
}
|
|
14615
|
+
return `file-${icon}-solid`;
|
|
14616
|
+
};
|
|
14617
|
+
const getFileSuffix = (x) => {
|
|
14618
|
+
return x.fileName?.split(".").pop() || "";
|
|
14619
|
+
};
|
|
14620
|
+
const getFileName = (x) => {
|
|
14621
|
+
return x.fileName?.replace(/\.[^/.]+$/, "") || "";
|
|
14622
|
+
};
|
|
14623
|
+
const ImagePlaceholderTemplate = (context) => {
|
|
14624
|
+
const iconTag = context.tagFor(definition$7.Icon);
|
|
14625
|
+
return vividElement.html`<template class="${getClasses}">
|
|
14626
|
+
<div class="image-placeholder">
|
|
14627
|
+
<div class="icon">
|
|
14628
|
+
<${iconTag} name="${getIconName}" size="-5"></${iconTag}>
|
|
14629
|
+
</div>
|
|
14630
|
+
<div class="info">
|
|
14631
|
+
<div class="filename" title="${(x) => x.fileName}">
|
|
14632
|
+
<div class="name">${getFileName}</div>
|
|
14633
|
+
<div class="suffix">${getFileSuffix}</div>
|
|
14634
|
+
</div>
|
|
14635
|
+
${when.when(
|
|
14636
|
+
(x) => x.errorMessage,
|
|
14637
|
+
vividElement.html`<div class="error">
|
|
14638
|
+
<span class="error-icon"><${iconTag} name="error-solid" size="-6"></${iconTag}></span>
|
|
14639
|
+
<span class="error-text">${(x) => x.errorMessage}</span>
|
|
14640
|
+
</div>`
|
|
14641
|
+
)}
|
|
14642
|
+
</div>
|
|
14643
|
+
</div>
|
|
14528
14644
|
</template>`;
|
|
14529
14645
|
};
|
|
14530
14646
|
|
|
14647
|
+
const imagePlaceholderDefinition = vividElement.defineVividComponent(
|
|
14648
|
+
"text-editor-image-placeholder",
|
|
14649
|
+
ImagePlaceholder,
|
|
14650
|
+
ImagePlaceholderTemplate,
|
|
14651
|
+
[definition$7.iconDefinition],
|
|
14652
|
+
{
|
|
14653
|
+
styles,
|
|
14654
|
+
shadowOptions: {
|
|
14655
|
+
delegatesFocus: true
|
|
14656
|
+
}
|
|
14657
|
+
}
|
|
14658
|
+
);
|
|
14659
|
+
|
|
14531
14660
|
const richTextEditorDefinition = vividElement.defineVividComponent(
|
|
14532
14661
|
"rich-text-editor",
|
|
14533
14662
|
RichTextEditor,
|
|
14534
14663
|
RichTextEditorTemplate,
|
|
14535
|
-
[
|
|
14664
|
+
[menubarDefinition, definition$6.dividerDefinition, imagePlaceholderDefinition],
|
|
14536
14665
|
{
|
|
14537
|
-
styles: styles$
|
|
14666
|
+
styles: styles$2,
|
|
14538
14667
|
shadowOptions: {
|
|
14539
14668
|
delegatesFocus: true
|
|
14540
14669
|
}
|