@webx-ui/core 0.44.0 → 0.45.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.
Files changed (40) hide show
  1. package/dist/{CodeEditor-gPYUUsSB.js → CodeEditor-MaAGoziu.js} +2 -2
  2. package/dist/{CodeEditor-gPYUUsSB.js.map → CodeEditor-MaAGoziu.js.map} +1 -1
  3. package/dist/RichText-CoaDjyK5.js +845 -0
  4. package/dist/RichText-CoaDjyK5.js.map +1 -0
  5. package/dist/components/Action/Action.d.ts +4 -1
  6. package/dist/components/Action/types.d.ts +9 -0
  7. package/dist/components/Autocomplete/Autocomplete.d.ts +2 -2
  8. package/dist/components/Button/Button.d.ts +1 -1
  9. package/dist/components/Cascader/Cascader.d.ts +1 -1
  10. package/dist/components/ColorPicker/ColorPicker.d.ts +1 -1
  11. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  12. package/dist/components/DateRangePicker/DateRangePicker.d.ts +1 -1
  13. package/dist/components/DateTimePicker/DateTimePicker.d.ts +1 -1
  14. package/dist/components/Dropdown/Dropdown.d.ts +1 -1
  15. package/dist/components/DropdownItem/DropdownItem.d.ts +1 -1
  16. package/dist/components/FileCard/FileCard.d.ts +6 -6
  17. package/dist/components/IconPicker/IconPicker.d.ts +1 -1
  18. package/dist/components/ImageEditor/ImageEditor.d.ts +2 -2
  19. package/dist/components/Input/Input.d.ts +1 -1
  20. package/dist/components/InputNumber/InputNumber.d.ts +1 -1
  21. package/dist/components/Popconfirm/Popconfirm.d.ts +9 -5
  22. package/dist/components/Rate/Rate.d.ts +1 -1
  23. package/dist/components/RichText/RichText.d.ts +4 -1
  24. package/dist/components/RichText/index.d.ts +11 -3
  25. package/dist/components/RichText/types.d.ts +10 -1
  26. package/dist/components/Segmented/Segmented.d.ts +1 -1
  27. package/dist/components/Select/Select.d.ts +1 -1
  28. package/dist/components/TagsInput/TagsInput.d.ts +1 -1
  29. package/dist/components/Textarea/Textarea.d.ts +1 -1
  30. package/dist/components/TimePicker/TimePicker.d.ts +1 -1
  31. package/dist/{index-OwTgLBpg.js → index-Ba5vX487.js} +4205 -4158
  32. package/dist/index-Ba5vX487.js.map +1 -0
  33. package/dist/index.js +1 -1
  34. package/dist/internal/ConfirmDialog.d.ts +2 -2
  35. package/dist/internal/ImageEditorDialog.d.ts +3 -3
  36. package/dist/style.css +1 -1
  37. package/package.json +1 -1
  38. package/dist/RichText-Dmaf7-UT.js +0 -805
  39. package/dist/RichText-Dmaf7-UT.js.map +0 -1
  40. package/dist/index-OwTgLBpg.js.map +0 -1
@@ -0,0 +1,845 @@
1
+ import { defineComponent as Ae, openBlock as r, createElementBlock as v, normalizeClass as Ce, createElementVNode as _, unref as i, toDisplayString as H, computed as k, useModel as Qe, ref as L, watch as ee, onMounted as Je, createBlock as E, Teleport as Xe, withKeys as be, Fragment as I, renderList as te, withModifiers as Y, createCommentVNode as g, withDirectives as me, vModelText as et, createVNode as R, createTextVNode as j, withCtx as ke, normalizeStyle as tt, vShow as lt, mergeModels as ge, nextTick as le } from "vue";
2
+ import { Mark as nt, Node as ot, Extension as xe, createDocument as at, getHTMLFromFragment as it } from "@tiptap/core";
3
+ import { useEditor as rt, EditorContent as st } from "@tiptap/vue-3";
4
+ import Me from "@tiptap/starter-kit";
5
+ import { TableKit as ut } from "@tiptap/extension-table";
6
+ import ct from "@tiptap/extension-image";
7
+ import dt from "@tiptap/extension-youtube";
8
+ import ft from "@tiptap/extension-file-handler";
9
+ import { PluginKey as vt, Plugin as ht } from "@tiptap/pm/state";
10
+ import { DecorationSet as ye, Decoration as pt } from "@tiptap/pm/view";
11
+ import { _ as _e, b as bt, t as mt, u as kt, a as gt, c as xt, d as Mt, L as yt, W as we, e as wt, f as Lt, r as Tt, g as At } from "./index-Ba5vX487.js";
12
+ const Ct = {
13
+ bold: "M7 5h6a3.5 3.5 0 0 1 0 7H7zm0 7h7a3.5 3.5 0 0 1 0 7H7z",
14
+ italic: "M15 5h-5M14 19H9M13.5 5 10.5 19",
15
+ accent: "M5 19 12 5l7 14M8 13h8M18 4.5h.01",
16
+ strike: "M5 12h14M8 8.5A3 3 0 0 1 11 6h2a3 3 0 0 1 3 2.5M16 15.5A3 3 0 0 1 13 18h-2a3 3 0 0 1-3-2.5",
17
+ code: "m9 8-5 4 5 4M15 8l5 4-5 4",
18
+ bulletList: "M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01",
19
+ orderedList: "M10 6h10M10 12h10M10 18h10M4 6h1v4M4 10h2M4 14h2v2H4v2h2",
20
+ blockquote: "M7 15V9h4v6H7l-2 3M15 15V9h4v6h-4l-2 3",
21
+ hr: "M4 12h16",
22
+ link: "M10 13a4 4 0 0 0 5.7.4l2.6-2.6a4 4 0 0 0-5.7-5.7l-1.5 1.5M14 11a4 4 0 0 0-5.7-.4l-2.6 2.6a4 4 0 0 0 5.7 5.7l1.5-1.5",
23
+ table: "M4 6h16v12H4zM4 10h16M10 10v8M4 14h16",
24
+ image: "M4 6h16v12H4zM4 15l4-4 4 4 3-3 5 5M9 9.5h.01",
25
+ youtube: "M3 8.5A2.5 2.5 0 0 1 5.5 6h13A2.5 2.5 0 0 1 21 8.5v7a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 15.5zM10.5 9.5l4 2.5-4 2.5z",
26
+ undo: "M4 9h11a4.5 4.5 0 0 1 0 9h-4M4 9l4-4M4 9l4 4",
27
+ redo: "M20 9H9a4.5 4.5 0 0 0 0 9h4M20 9l-4-4M20 9l-4 4",
28
+ source: "m8 8-4 4 4 4M16 8l4 4-4 4M13.5 5l-3 14",
29
+ rowAfter: "M4 5h16M4 11h16M8 15v6M5 18h6",
30
+ rowBefore: "M4 19h16M4 13h16M8 3v6M5 6h6",
31
+ columnAfter: "M5 4v16M11 4v16M15 8h6M18 5v6",
32
+ columnBefore: "M19 4v16M13 4v16M3 8h6M6 5v6",
33
+ deleteRow: "M4 8h16M4 16h16M9 12h6",
34
+ deleteColumn: "M8 4v16M16 4v16M12 9v6",
35
+ deleteTable: "M5 7h14M9 7V5h6v2M7 7l1 12h8l1-12M10 11v4M14 11v4",
36
+ mergeCells: "M4 6h16v12H4zM12 6v3M12 15v3M9 12h6M9 12l2-2M9 12l2 2",
37
+ token: "M9 4H6v16h3M15 4h3v16h-3",
38
+ expand: "M14 4h6v6M10 20H4v-6M20 4l-6 6M4 20l6-6",
39
+ collapse: "M20 10h-6V4M4 14h6v6M14 10l6-6M10 14l-6 6",
40
+ check: "m5 13 4 4L19 7",
41
+ close: "M6 6l12 12M18 6 6 18"
42
+ }, _t = ["title", "aria-label", "aria-pressed", "disabled"], Ht = {
43
+ key: 0,
44
+ viewBox: "0 0 24 24",
45
+ fill: "none",
46
+ "aria-hidden": "true"
47
+ }, Bt = ["d"], Et = {
48
+ key: 1,
49
+ class: "wx-rich-text__tool-text"
50
+ }, St = /* @__PURE__ */ Ae({
51
+ name: "WxRichTextToolbarButton",
52
+ __name: "ToolbarButton",
53
+ props: {
54
+ icon: { default: void 0 },
55
+ text: { default: void 0 },
56
+ label: {},
57
+ active: { type: Boolean, default: !1 },
58
+ disabled: { type: Boolean, default: !1 }
59
+ },
60
+ emits: ["click"],
61
+ setup(o) {
62
+ return (x, f) => (r(), v("button", {
63
+ type: "button",
64
+ class: Ce(["wx-rich-text__tool", { "is-active": o.active }]),
65
+ title: o.label,
66
+ "aria-label": o.label,
67
+ "aria-pressed": o.active,
68
+ disabled: o.disabled,
69
+ onClick: f[0] || (f[0] = (n) => x.$emit("click"))
70
+ }, [
71
+ o.icon ? (r(), v("svg", Ht, [
72
+ _("path", {
73
+ d: i(Ct)[o.icon],
74
+ stroke: "currentColor",
75
+ "stroke-width": "1.7",
76
+ "stroke-linecap": "round",
77
+ "stroke-linejoin": "round"
78
+ }, null, 8, Bt)
79
+ ])) : (r(), v("span", Et, H(o.text), 1))
80
+ ], 10, _t));
81
+ }
82
+ }), z = /* @__PURE__ */ _e(St, [["__scopeId", "data-v-c8c7e143"]]), $t = /* @__PURE__ */ new Set([
83
+ "ul",
84
+ "ol",
85
+ "li",
86
+ "blockquote",
87
+ "table",
88
+ "colgroup",
89
+ "thead",
90
+ "tbody",
91
+ "tfoot",
92
+ "tr",
93
+ "th",
94
+ "td",
95
+ "div",
96
+ "figure"
97
+ ]), It = /* @__PURE__ */ new Set([
98
+ "p",
99
+ "h1",
100
+ "h2",
101
+ "h3",
102
+ "h4",
103
+ "h5",
104
+ "h6",
105
+ "pre",
106
+ "hr",
107
+ "img",
108
+ "iframe",
109
+ "col",
110
+ "figcaption"
111
+ ]), Rt = /* @__PURE__ */ new Set(["hr", "img", "br", "col", "wbr", "source", "input"]), zt = /<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*?(\/?)>/g;
112
+ function Dt(o, x = " ") {
113
+ let f = "", n = 0, h = 0, d = 0, s = 0;
114
+ const b = () => {
115
+ f += `
116
+ ${x.repeat(n)}`;
117
+ };
118
+ for (const D of o.matchAll(zt)) {
119
+ const [T, S, a, O] = D, A = a.toLowerCase();
120
+ if (f += o.slice(s, D.index), s = D.index + T.length, d > 0 && A !== "pre") {
121
+ f += T;
122
+ continue;
123
+ }
124
+ const P = h === 0, K = Rt.has(A) || O === "/";
125
+ if ($t.has(A) && P) {
126
+ S ? (n = Math.max(0, n - 1), b(), f += T) : (b(), f += T, K || (n += 1));
127
+ continue;
128
+ }
129
+ if (It.has(A)) {
130
+ !S && P && b(), f += T, A === "pre" && (d += S ? -1 : 1), K || (h += S ? -1 : 1), h = Math.max(0, h);
131
+ continue;
132
+ }
133
+ f += T;
134
+ }
135
+ return f += o.slice(s), f.replace(/^\n/, "");
136
+ }
137
+ const Ot = { b: "strong", i: "em", del: "s", strike: "s" };
138
+ function Le(o) {
139
+ const x = /* @__PURE__ */ new Map(), f = (h) => {
140
+ x.set(h, (x.get(h) ?? 0) + 1);
141
+ }, n = document.createElement("template");
142
+ n.innerHTML = o;
143
+ for (const h of n.content.querySelectorAll("*")) {
144
+ const d = h.tagName.toLowerCase(), s = Ot[d] ?? d;
145
+ f(`<${s}>`);
146
+ for (const b of h.getAttributeNames()) f(`${b} on <${s}>`);
147
+ }
148
+ return x;
149
+ }
150
+ function Pt(o, x) {
151
+ const f = Le(o), n = Le(x), h = [];
152
+ for (const [s, b] of f)
153
+ (n.get(s) ?? 0) < b && h.push(s);
154
+ const d = new Set(h.filter((s) => s.startsWith("<")));
155
+ return h.filter((s) => {
156
+ const b = / on (<[^>]+>)$/.exec(s);
157
+ return !b || !d.has(b[1]);
158
+ });
159
+ }
160
+ const Vt = [
161
+ "bold",
162
+ "italic",
163
+ "strike",
164
+ "code",
165
+ "divider",
166
+ "h2",
167
+ "h3",
168
+ "h4",
169
+ "divider",
170
+ "bulletList",
171
+ "orderedList",
172
+ "blockquote",
173
+ "hr",
174
+ "divider",
175
+ "link",
176
+ "table",
177
+ "image",
178
+ "youtube",
179
+ "divider",
180
+ "undo",
181
+ "redo",
182
+ "divider",
183
+ "source"
184
+ ], Nt = ["bold", "italic", "accent"], Ft = [
185
+ "image/png",
186
+ "image/jpeg",
187
+ "image/gif",
188
+ "image/webp",
189
+ "image/svg+xml"
190
+ ], G = {
191
+ bold: { label: "Bold", icon: "bold" },
192
+ italic: { label: "Italic", icon: "italic" },
193
+ accent: { label: "Accent", icon: "accent" },
194
+ strike: { label: "Strikethrough", icon: "strike" },
195
+ code: { label: "Inline code", icon: "code" },
196
+ h2: { label: "Heading 2", text: "H2" },
197
+ h3: { label: "Heading 3", text: "H3" },
198
+ h4: { label: "Heading 4", text: "H4" },
199
+ bulletList: { label: "Bulleted list", icon: "bulletList" },
200
+ orderedList: { label: "Numbered list", icon: "orderedList" },
201
+ blockquote: { label: "Quote", icon: "blockquote" },
202
+ hr: { label: "Divider", icon: "hr" },
203
+ link: { label: "Link", icon: "link" },
204
+ table: { label: "Table", icon: "table" },
205
+ image: { label: "Image", icon: "image" },
206
+ youtube: { label: "YouTube video", icon: "youtube" },
207
+ undo: { label: "Undo", icon: "undo" },
208
+ redo: { label: "Redo", icon: "redo" },
209
+ source: { label: "HTML source", icon: "source" }
210
+ }, Te = [
211
+ { key: "addRowAfter", label: "Row below", icon: "rowAfter" },
212
+ { key: "addRowBefore", label: "Row above", icon: "rowBefore" },
213
+ { key: "addColumnAfter", label: "Column after", icon: "columnAfter" },
214
+ { key: "addColumnBefore", label: "Column before", icon: "columnBefore" },
215
+ { key: "deleteRow", label: "Delete row", icon: "deleteRow" },
216
+ { key: "deleteColumn", label: "Delete column", icon: "deleteColumn" },
217
+ { key: "mergeOrSplit", label: "Merge or split cells", icon: "mergeCells" },
218
+ { key: "deleteTable", label: "Delete table", icon: "deleteTable" }
219
+ ], Kt = ["aria-label"], Ut = {
220
+ key: 0,
221
+ class: "wx-rich-text__divider",
222
+ "aria-hidden": "true"
223
+ }, qt = {
224
+ key: 1,
225
+ class: "wx-rich-text__uploading"
226
+ }, Wt = {
227
+ key: 2,
228
+ class: "wx-rich-text__toolbar wx-rich-text__toolbar--table"
229
+ }, Yt = ["for"], jt = ["id", "placeholder"], Gt = {
230
+ key: 4,
231
+ class: "wx-rich-text__prompt wx-rich-text__loss",
232
+ role: "alert"
233
+ }, Zt = { class: "wx-rich-text__loss-text" }, Qt = {
234
+ key: 5,
235
+ class: "wx-rich-text__source"
236
+ }, Jt = {
237
+ key: 0,
238
+ class: "wx-rich-text__placeholder"
239
+ }, Xt = ["accept"], el = /* @__PURE__ */ Ae({
240
+ name: "WxRichText",
241
+ inheritAttrs: !1,
242
+ __name: "RichText",
243
+ props: /* @__PURE__ */ ge({
244
+ placeholder: { default: void 0 },
245
+ disabled: { type: Boolean, default: void 0 },
246
+ readonly: { type: Boolean, default: !1 },
247
+ size: { default: void 0 },
248
+ status: { default: void 0 },
249
+ id: { default: void 0 },
250
+ ariaLabel: { default: void 0 },
251
+ inline: { type: Boolean, default: !1 },
252
+ minHeight: { default: void 0 },
253
+ tools: { default: void 0 },
254
+ upload: { type: Function, default: void 0 },
255
+ pickImage: { type: Function, default: void 0 },
256
+ accept: { default: () => Ft },
257
+ labels: { default: void 0 },
258
+ expandable: { type: Boolean, default: !0 },
259
+ localized: { type: Boolean, default: !1 },
260
+ tokens: { default: void 0 },
261
+ tokensTitle: { default: "Placeholders" },
262
+ tokensLabel: { default: "Insert a placeholder" }
263
+ }, {
264
+ modelValue: { default: "" },
265
+ modelModifiers: {}
266
+ }),
267
+ emits: /* @__PURE__ */ ge(["change", "focus", "blur", "uploadError", "expand"], ["update:modelValue"]),
268
+ setup(o, { expose: x, emit: f }) {
269
+ const n = o, h = {
270
+ toolbar: "Text formatting",
271
+ linkAddress: "Link address",
272
+ youtubeAddress: "YouTube URL",
273
+ apply: "Apply",
274
+ cancel: "Cancel",
275
+ uploading: "Uploading…",
276
+ sourceLoss: "The editor does not keep this markup and will remove it:",
277
+ sourceDrop: "Remove it",
278
+ sourceKeep: "Keep editing",
279
+ expand: "Expand",
280
+ collapse: "Collapse"
281
+ };
282
+ function d(e) {
283
+ const t = n.labels?.[e] ?? h[e];
284
+ return t !== void 0 ? t : e in G ? G[e].label : Te.find((l) => l.key === e)?.label ?? e;
285
+ }
286
+ const s = f, b = ct.extend({
287
+ addAttributes() {
288
+ return {
289
+ ...this.parent?.(),
290
+ path: {
291
+ default: null,
292
+ parseHTML: (e) => e.getAttribute("data-wx-path"),
293
+ renderHTML: (e) => e.path === null || e.path === void 0 ? {} : { "data-wx-path": String(e.path) }
294
+ }
295
+ };
296
+ }
297
+ }), D = nt.create({
298
+ name: "accent",
299
+ parseHTML: () => [{ tag: "span" }],
300
+ renderHTML: () => ["span", 0]
301
+ }), T = ot.create({ name: "doc", topNode: !0, content: "text*" }), S = xe.create({
302
+ name: "wxOneLine",
303
+ addKeyboardShortcuts: () => ({
304
+ Enter: () => !0,
305
+ "Shift-Enter": () => !0,
306
+ "Mod-Enter": () => !0
307
+ })
308
+ }), a = bt(() => n.tokens), O = k(() => a.all.value.length > 0), A = new vt("wxTokenChips"), P = xe.create({
309
+ name: "wxTokenChips",
310
+ addProseMirrorPlugins: () => [
311
+ new ht({
312
+ key: A,
313
+ props: {
314
+ decorations: (e) => {
315
+ const t = a.known.value;
316
+ if (t.size === 0) return ye.empty;
317
+ const l = [];
318
+ return e.doc.descendants((c, B) => {
319
+ if (!(!c.isText || !c.text))
320
+ for (const F of mt(c.text, t))
321
+ l.push(
322
+ pt.inline(B + F.from, B + F.to, {
323
+ class: "wx-token",
324
+ "data-token": F.name
325
+ })
326
+ );
327
+ }), ye.create(e.doc, l);
328
+ }
329
+ }
330
+ })
331
+ ]
332
+ });
333
+ function K() {
334
+ return [
335
+ Me.configure({
336
+ document: !1,
337
+ paragraph: !1,
338
+ heading: !1,
339
+ blockquote: !1,
340
+ bulletList: !1,
341
+ orderedList: !1,
342
+ listItem: !1,
343
+ listKeymap: !1,
344
+ codeBlock: !1,
345
+ code: !1,
346
+ horizontalRule: !1,
347
+ hardBreak: !1,
348
+ strike: !1,
349
+ underline: !1,
350
+ link: !1,
351
+ trailingNode: !1,
352
+ gapcursor: !1
353
+ }),
354
+ T,
355
+ D,
356
+ S,
357
+ P
358
+ ];
359
+ }
360
+ function He() {
361
+ return [
362
+ Me.configure({
363
+ link: {
364
+ openOnClick: !1,
365
+ autolink: !0,
366
+ HTMLAttributes: { rel: "noopener noreferrer nofollow", target: "_blank" }
367
+ }
368
+ }),
369
+ ut.configure({ table: { resizable: !0 } }),
370
+ b.configure({ HTMLAttributes: { class: "wx-rich-text__image" } }),
371
+ dt.configure({ nocookie: !0, width: 640, height: 360 }),
372
+ ft.configure({
373
+ allowedMimeTypes: n.accept,
374
+ onDrop: (e, t, l) => {
375
+ X(t, l);
376
+ },
377
+ onPaste: (e, t) => {
378
+ X(t);
379
+ }
380
+ }),
381
+ P
382
+ ];
383
+ }
384
+ const Be = k(() => n.tools ?? (n.inline ? Nt : Vt)), ne = k(() => n.minHeight ?? (n.inline ? void 0 : "220px")), Ee = Qe(o, "modelValue"), m = kt(n), M = gt(n, Ee), U = k(() => M.on.value ? M.active.value : void 0), V = k(() => M.read(U.value)), q = L(!1), Z = L(0), oe = L(null), y = L(null), $ = k(() => !m.disabled.value && !n.readonly), p = L(null), C = L(null);
385
+ let Q = "";
386
+ function W() {
387
+ const e = u.value;
388
+ return !e || e.isEmpty ? "" : e.getHTML();
389
+ }
390
+ const u = rt({
391
+ content: V.value,
392
+ editable: $.value,
393
+ extensions: n.inline ? K() : He(),
394
+ editorProps: {
395
+ // The list's keys first: Enter picks a placeholder rather than splitting the paragraph.
396
+ // Then Esc, which ProseMirror would otherwise spend on selecting the paragraph around the
397
+ // caret — and which over the whole window means "give me the form back".
398
+ handleKeyDown: (e, t) => a.keydown(t, re) || Re(t),
399
+ ...n.inline ? {
400
+ // Pasted lines become one line: the breaks would otherwise vanish between the words
401
+ // and glue the last of one line to the first of the next.
402
+ transformPastedText: (e) => e.replace(/\s*[\r\n]+\s*/g, " ")
403
+ } : {}
404
+ },
405
+ onUpdate: () => {
406
+ const e = W();
407
+ e !== V.value && (M.write(U.value, e), s("change", e), ie());
408
+ },
409
+ onSelectionUpdate: () => {
410
+ a.open.value && ie();
411
+ },
412
+ onFocus: () => {
413
+ q.value = !0, s("focus");
414
+ },
415
+ onBlur: () => {
416
+ q.value = !1, a.close(), s("blur");
417
+ }
418
+ });
419
+ ee(V, (e) => {
420
+ const t = u.value;
421
+ if (t) {
422
+ if (p.value !== null) {
423
+ e !== p.value && fe(e);
424
+ return;
425
+ }
426
+ e !== W() && t.commands.setContent(e, { emitUpdate: !1 });
427
+ }
428
+ }), ee($, (e) => u.value?.setEditable(e, !1)), ee(a.known, () => {
429
+ const e = u.value;
430
+ e && e.view.dispatch(e.state.tr.setMeta(A, !0));
431
+ });
432
+ const N = L(null), Se = k(() => `${m.id.value}-tokens`);
433
+ function ae(e) {
434
+ try {
435
+ const t = u.value?.view.coordsAtPos(e);
436
+ if (t && t.bottom > t.top)
437
+ return Lt(Tt(t.left, t.top, 0, t.bottom - t.top), N.value);
438
+ } catch {
439
+ }
440
+ return At(N.value, null);
441
+ }
442
+ function ie() {
443
+ const e = u.value;
444
+ if (!e || !O.value || !$.value) return;
445
+ const { selection: t } = e.state, { $from: l } = t;
446
+ if (!t.empty || !l.parent.isTextblock) return a.close();
447
+ const c = l.parent.textBetween(0, l.parentOffset, void 0, "");
448
+ a.suggest(
449
+ c,
450
+ l.pos,
451
+ () => ae(l.pos - c.length + c.lastIndexOf("["))
452
+ );
453
+ }
454
+ function re(e, t) {
455
+ const l = u.value;
456
+ l && l.chain().focus().command(({ tr: c }) => (c.insertText(xt(e), t.from, t.to), !0)).run();
457
+ }
458
+ function $e() {
459
+ const e = u.value;
460
+ if (!e) return;
461
+ if (a.open.value && a.browsing.value) return a.close();
462
+ const { from: t, to: l } = e.state.selection;
463
+ e.commands.focus(), a.browse({ from: t, to: l }, ae(t));
464
+ }
465
+ const w = L(!1), se = L(!1);
466
+ Je(() => {
467
+ se.value = !!N.value?.closest('[role="dialog"]');
468
+ });
469
+ const Ie = k(() => n.expandable && !n.inline && !se.value);
470
+ function J(e) {
471
+ w.value !== e && (w.value = e, a.close(), s("expand", e), le(() => {
472
+ p.value === null && u.value?.commands.focus();
473
+ }));
474
+ }
475
+ function Re(e) {
476
+ return e.key !== "Escape" || !w.value ? !1 : (e.stopPropagation(), J(!1), !0);
477
+ }
478
+ function ze(e) {
479
+ !w.value || e.defaultPrevented || (e.preventDefault(), e.stopPropagation(), J(!1));
480
+ }
481
+ const De = k(() => u.value?.isEmpty ?? !0), Oe = k(() => u.value?.isActive("table") ?? !1), Pe = k(() => [
482
+ "wx-rich-text",
483
+ `wx-rich-text--${m.size.value}`,
484
+ {
485
+ [`wx-rich-text--${m.status.value}`]: m.status.value !== "default",
486
+ "is-focused": q.value,
487
+ "is-disabled": m.disabled.value,
488
+ "is-readonly": n.readonly,
489
+ "is-localized": M.on.value,
490
+ "is-inline": n.inline,
491
+ "is-expanded": w.value
492
+ }
493
+ ]);
494
+ function Ve(e) {
495
+ M.active.value = e, le(() => u.value?.commands.focus());
496
+ }
497
+ function ue(e, t) {
498
+ const l = u.value;
499
+ if (!l) return;
500
+ const c = t ?? l.state.selection.anchor;
501
+ l.chain().focus().insertContentAt(c, {
502
+ type: "image",
503
+ attrs: { src: e.url, alt: e.alt, path: e.path ?? null }
504
+ }).run();
505
+ }
506
+ async function X(e, t) {
507
+ if (n.upload)
508
+ for (const l of e) {
509
+ Z.value += 1;
510
+ try {
511
+ ue(await n.upload(l), t);
512
+ } catch (c) {
513
+ s("uploadError", c, l);
514
+ } finally {
515
+ Z.value -= 1;
516
+ }
517
+ }
518
+ }
519
+ async function Ne() {
520
+ if (n.pickImage) {
521
+ const e = await n.pickImage();
522
+ e && ue(typeof e == "string" ? { url: e } : e);
523
+ return;
524
+ }
525
+ oe.value?.click();
526
+ }
527
+ function Fe(e) {
528
+ const t = e.target, l = Array.from(t.files ?? []);
529
+ t.value = "", X(l);
530
+ }
531
+ function ce(e) {
532
+ const t = e === "link" ? u.value?.getAttributes("link").href ?? "" : "";
533
+ y.value = { kind: e, value: String(t) };
534
+ }
535
+ function de() {
536
+ const e = u.value, t = y.value;
537
+ if (!e || !t) return;
538
+ const l = t.value.trim();
539
+ t.kind === "link" ? l ? e.chain().focus().extendMarkRange("link").setLink({ href: l }).run() : e.chain().focus().extendMarkRange("link").unsetLink().run() : l && e.commands.setYoutubeVideo({ src: l }), y.value = null;
540
+ }
541
+ function fe(e = W()) {
542
+ y.value = null, C.value = null, Q = Dt(e), p.value = Q;
543
+ }
544
+ function Ke(e) {
545
+ p.value = e, C.value = null, e !== V.value && (M.write(U.value, e), s("change", e));
546
+ }
547
+ function ve(e = !1) {
548
+ const t = u.value, l = p.value;
549
+ if (!t || l === null) return;
550
+ const c = l !== Q;
551
+ if (c && !e) {
552
+ const F = at(l, t.schema), pe = Pt(l, it(F.content, t.schema));
553
+ if (pe.length > 0) {
554
+ C.value = pe;
555
+ return;
556
+ }
557
+ }
558
+ C.value = null, p.value = null, c && t.commands.setContent(l, { emitUpdate: !1 });
559
+ const B = W();
560
+ B !== V.value && (M.write(U.value, B), s("change", B)), le(() => t.commands.focus());
561
+ }
562
+ function he(e) {
563
+ q.value = e, s(e ? "focus" : "blur");
564
+ }
565
+ function Ue() {
566
+ p.value === null ? fe() : ve();
567
+ }
568
+ function qe(e) {
569
+ return e === "source" ? m.disabled.value : !$.value || p.value !== null;
570
+ }
571
+ function We(e) {
572
+ return e === "image" ? !!(n.upload || n.pickImage) : !0;
573
+ }
574
+ const Ye = k(() => Be.value.filter(We));
575
+ function je(e) {
576
+ if (e === "source") return p.value !== null;
577
+ const t = u.value;
578
+ if (!t) return !1;
579
+ switch (e) {
580
+ case "h2":
581
+ return t.isActive("heading", { level: 2 });
582
+ case "h3":
583
+ return t.isActive("heading", { level: 3 });
584
+ case "h4":
585
+ return t.isActive("heading", { level: 4 });
586
+ default:
587
+ return t.isActive(e);
588
+ }
589
+ }
590
+ function Ge(e) {
591
+ if (e === "source") return Ue();
592
+ const t = u.value;
593
+ if (!t) return;
594
+ const l = t.chain().focus();
595
+ switch (e) {
596
+ case "bold":
597
+ l.toggleBold().run();
598
+ break;
599
+ case "italic":
600
+ l.toggleItalic().run();
601
+ break;
602
+ case "accent":
603
+ l.toggleMark("accent").run();
604
+ break;
605
+ case "strike":
606
+ l.toggleStrike().run();
607
+ break;
608
+ case "code":
609
+ l.toggleCode().run();
610
+ break;
611
+ case "h2":
612
+ l.toggleHeading({ level: 2 }).run();
613
+ break;
614
+ case "h3":
615
+ l.toggleHeading({ level: 3 }).run();
616
+ break;
617
+ case "h4":
618
+ l.toggleHeading({ level: 4 }).run();
619
+ break;
620
+ case "bulletList":
621
+ l.toggleBulletList().run();
622
+ break;
623
+ case "orderedList":
624
+ l.toggleOrderedList().run();
625
+ break;
626
+ case "blockquote":
627
+ l.toggleBlockquote().run();
628
+ break;
629
+ case "hr":
630
+ l.setHorizontalRule().run();
631
+ break;
632
+ case "undo":
633
+ l.undo().run();
634
+ break;
635
+ case "redo":
636
+ l.redo().run();
637
+ break;
638
+ case "table":
639
+ l.insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run();
640
+ break;
641
+ case "link":
642
+ ce("link");
643
+ break;
644
+ case "youtube":
645
+ ce("youtube");
646
+ break;
647
+ case "image":
648
+ Ne();
649
+ break;
650
+ }
651
+ }
652
+ function Ze(e) {
653
+ const t = u.value;
654
+ if (!t) return;
655
+ t.chain().focus()[e]().run();
656
+ }
657
+ return x({
658
+ editor: u,
659
+ focus: () => u.value?.commands.focus(),
660
+ clear: () => u.value?.commands.clearContent(!0)
661
+ }), (e, t) => (r(), E(Xe, {
662
+ to: "body",
663
+ disabled: !w.value
664
+ }, [
665
+ _("div", {
666
+ ref_key: "rootRef",
667
+ ref: N,
668
+ class: Ce(Pe.value),
669
+ onKeydown: be(ze, ["esc"])
670
+ }, [
671
+ _("div", {
672
+ class: "wx-rich-text__toolbar",
673
+ role: "toolbar",
674
+ "aria-label": o.ariaLabel ?? d("toolbar")
675
+ }, [
676
+ (r(!0), v(I, null, te(Ye.value, (l, c) => (r(), v(I, {
677
+ key: `${l}-${c}`
678
+ }, [
679
+ l === "divider" ? (r(), v("span", Ut)) : (r(), E(z, {
680
+ key: 1,
681
+ icon: i(G)[l].icon,
682
+ text: i(G)[l].text,
683
+ label: d(l),
684
+ active: je(l),
685
+ disabled: qe(l),
686
+ onClick: (B) => Ge(l)
687
+ }, null, 8, ["icon", "text", "label", "active", "disabled", "onClick"]))
688
+ ], 64))), 128)),
689
+ O.value ? (r(), E(z, {
690
+ key: 0,
691
+ class: "wx-rich-text__tokens",
692
+ icon: "token",
693
+ label: o.tokensLabel,
694
+ active: i(a).open.value && i(a).browsing.value,
695
+ disabled: !$.value || p.value !== null,
696
+ onMousedown: t[0] || (t[0] = Y(() => {
697
+ }, ["prevent"])),
698
+ onClick: $e
699
+ }, null, 8, ["label", "active", "disabled"])) : g("", !0),
700
+ Z.value > 0 ? (r(), v("span", qt, H(d("uploading")), 1)) : g("", !0),
701
+ Ie.value ? (r(), E(z, {
702
+ key: 2,
703
+ class: "wx-rich-text__expand",
704
+ icon: w.value ? "collapse" : "expand",
705
+ label: d(w.value ? "collapse" : "expand"),
706
+ disabled: i(m).disabled.value,
707
+ onMousedown: t[1] || (t[1] = Y(() => {
708
+ }, ["prevent"])),
709
+ onClick: t[2] || (t[2] = (l) => J(!w.value))
710
+ }, null, 8, ["icon", "label", "disabled"])) : g("", !0)
711
+ ], 8, Kt),
712
+ O.value ? (r(), E(Mt, {
713
+ key: 0,
714
+ open: i(a).open.value,
715
+ items: i(a).items.value,
716
+ active: i(a).active.value,
717
+ anchor: i(a).anchor.value,
718
+ "list-id": Se.value,
719
+ title: i(a).browsing.value ? o.tokensTitle : void 0,
720
+ owner: N.value,
721
+ onChoose: t[3] || (t[3] = (l) => i(a).choose(l, re)),
722
+ onHover: t[4] || (t[4] = (l) => i(a).active.value = l),
723
+ onClose: t[5] || (t[5] = (l) => i(a).close())
724
+ }, null, 8, ["open", "items", "active", "anchor", "list-id", "title", "owner"])) : g("", !0),
725
+ i(M).on.value ? (r(), E(yt, {
726
+ key: 1,
727
+ locales: i(M).list.value,
728
+ active: i(M).active.value,
729
+ onChoose: Ve
730
+ }, null, 8, ["locales", "active"])) : g("", !0),
731
+ Oe.value && $.value && p.value === null ? (r(), v("div", Wt, [
732
+ (r(!0), v(I, null, te(i(Te), (l) => (r(), E(z, {
733
+ key: l.key,
734
+ icon: l.icon,
735
+ label: d(l.key),
736
+ onClick: (c) => Ze(l.key)
737
+ }, null, 8, ["icon", "label", "onClick"]))), 128))
738
+ ])) : g("", !0),
739
+ y.value ? (r(), v("form", {
740
+ key: 3,
741
+ class: "wx-rich-text__prompt",
742
+ onSubmit: Y(de, ["prevent"])
743
+ }, [
744
+ _("label", {
745
+ class: "wx-rich-text__prompt-label",
746
+ for: `${i(m).id.value}-prompt`
747
+ }, H(d(y.value.kind === "link" ? "linkAddress" : "youtubeAddress")), 9, Yt),
748
+ me(_("input", {
749
+ id: `${i(m).id.value}-prompt`,
750
+ "onUpdate:modelValue": t[6] || (t[6] = (l) => y.value.value = l),
751
+ class: "wx-rich-text__prompt-input",
752
+ type: "url",
753
+ placeholder: y.value.kind === "link" ? "https://example.com" : "https://youtu.be/…",
754
+ onKeydown: t[7] || (t[7] = be(Y((l) => y.value = null, ["prevent"]), ["esc"]))
755
+ }, null, 40, jt), [
756
+ [et, y.value.value]
757
+ ]),
758
+ R(z, {
759
+ icon: "check",
760
+ label: d("apply"),
761
+ onClick: de
762
+ }, null, 8, ["label"]),
763
+ R(z, {
764
+ icon: "close",
765
+ label: d("cancel"),
766
+ onClick: t[8] || (t[8] = (l) => y.value = null)
767
+ }, null, 8, ["label"])
768
+ ], 32)) : g("", !0),
769
+ C.value ? (r(), v("div", Gt, [
770
+ _("p", Zt, [
771
+ j(H(d("sourceLoss")) + " ", 1),
772
+ (r(!0), v(I, null, te(C.value, (l, c) => (r(), v(I, { key: l }, [
773
+ _("code", null, H(l), 1),
774
+ c < C.value.length - 1 ? (r(), v(I, { key: 0 }, [
775
+ j(", ")
776
+ ], 64)) : g("", !0)
777
+ ], 64))), 128))
778
+ ]),
779
+ R(we, {
780
+ size: "sm",
781
+ type: "danger",
782
+ variant: "outline",
783
+ onClick: t[9] || (t[9] = (l) => ve(!0))
784
+ }, {
785
+ default: ke(() => [
786
+ j(H(d("sourceDrop")), 1)
787
+ ]),
788
+ _: 1
789
+ }),
790
+ R(we, {
791
+ size: "sm",
792
+ variant: "text",
793
+ onClick: t[10] || (t[10] = (l) => C.value = null)
794
+ }, {
795
+ default: ke(() => [
796
+ j(H(d("sourceKeep")), 1)
797
+ ]),
798
+ _: 1
799
+ })
800
+ ])) : g("", !0),
801
+ p.value !== null ? (r(), v("div", Qt, [
802
+ R(i(wt), {
803
+ "model-value": p.value,
804
+ language: "html",
805
+ "line-wrapping": "",
806
+ "min-height": ne.value,
807
+ readonly: o.readonly,
808
+ disabled: i(m).disabled.value,
809
+ "aria-label": d("source"),
810
+ "onUpdate:modelValue": Ke,
811
+ onFocus: t[11] || (t[11] = (l) => he(!0)),
812
+ onBlur: t[12] || (t[12] = (l) => he(!1))
813
+ }, null, 8, ["model-value", "min-height", "readonly", "disabled", "aria-label"])
814
+ ])) : g("", !0),
815
+ me(_("div", {
816
+ class: "wx-rich-text__body",
817
+ style: tt({ minHeight: ne.value })
818
+ }, [
819
+ o.placeholder && De.value ? (r(), v("span", Jt, H(o.placeholder), 1)) : g("", !0),
820
+ R(i(st), {
821
+ editor: i(u),
822
+ class: "wx-rich-text__content",
823
+ "aria-describedby": i(m).describedBy.value
824
+ }, null, 8, ["editor", "aria-describedby"])
825
+ ], 4), [
826
+ [lt, p.value === null]
827
+ ]),
828
+ o.upload && !o.pickImage ? (r(), v("input", {
829
+ key: 6,
830
+ ref_key: "fileInput",
831
+ ref: oe,
832
+ class: "wx-rich-text__file",
833
+ type: "file",
834
+ accept: o.accept.join(","),
835
+ multiple: "",
836
+ onChange: Fe
837
+ }, null, 40, Xt)) : g("", !0)
838
+ ], 34)
839
+ ], 8, ["disabled"]));
840
+ }
841
+ }), fl = /* @__PURE__ */ _e(el, [["__scopeId", "data-v-64994289"]]);
842
+ export {
843
+ fl as default
844
+ };
845
+ //# sourceMappingURL=RichText-CoaDjyK5.js.map