@opengis/form 0.0.184 → 0.0.185

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.
@@ -0,0 +1,3000 @@
1
+ import { ref as C, getCurrentInstance as lt, resolveComponent as G, openBlock as v, createElementBlock as k, normalizeClass as E, createVNode as F, createElementVNode as d, unref as L, createBlock as K, Teleport as Ke, Transition as We, withCtx as R, toDisplayString as W, renderSlot as be, createCommentVNode as V, defineComponent as at, withDirectives as ce, mergeProps as nt, vModelDynamic as st, Fragment as re, vModelCheckbox as it, nextTick as ge, watch as we, onMounted as he, onBeforeUnmount as Xe, normalizeStyle as le, vShow as ke, computed as H, renderList as ne, onUnmounted as Ae, resolveDynamicComponent as Te, vModelText as ct, withModifiers as dt, createStaticVNode as ut, useModel as ft, shallowRef as pt, mergeModels as gt, markRaw as ht } from "vue";
2
+ import { r as He, _ as X, a as vt, b as mt } from "./index-DnsOnW7S.js";
3
+ import { Quote as bt, List as yt, ListOrdered as xt, CodeXml as wt, Bold as kt, Italic as _t, Underline as $t, Strikethrough as Ct, X as Be, Mail as At, Search as Ft, Link2 as St, ExternalLink as Tt, Trash2 as Lt, Table2 as Bt, AlignJustify as Et, AlignRight as It, AlignCenter as Pt, AlignLeft as jt, Check as ye, Eraser as Mt, PaintBucket as Ht, Highlighter as Nt, ChevronDown as Ee, ALargeSmall as zt, Superscript as Dt, Subscript as Ot, RemoveFormatting as Vt, Image as Rt, Undo2 as Ut, Redo2 as qt, CircleHelp as Kt, Minus as Wt, Maximize as Xt } from "lucide-vue-next";
4
+ import { notify as Ce } from "@opengis/core";
5
+ function Gt() {
6
+ const t = C(!1);
7
+ return {
8
+ isFullscreen: t,
9
+ toggleFullscreen: () => {
10
+ t.value = !t.value;
11
+ }
12
+ };
13
+ }
14
+ const Yt = "https://esm.sh", te = "3.7.2", Ge = "3.7.2", Qt = `?deps=@tiptap/core@${te},@tiptap/pm@${Ge}`, Z = (t) => `${Yt}/${t}${Qt}`, J = {
15
+ core: Z(`@tiptap/core@${te}`),
16
+ starterKit: Z(`@tiptap/starter-kit@${te}`),
17
+ textStyle: Z(`@tiptap/extension-text-style@${te}`),
18
+ table: Z(`@tiptap/extension-table@${te}`),
19
+ highlight: Z(`@tiptap/extension-highlight@${te}`),
20
+ subscript: Z(`@tiptap/extension-subscript@${te}`),
21
+ superscript: Z(`@tiptap/extension-superscript@${te}`),
22
+ link: Z(`@tiptap/extension-link@${te}`),
23
+ image: Z(`@tiptap/extension-image@${te}`),
24
+ textAlign: Z(`@tiptap/extension-text-align@${te}`),
25
+ heading: Z(`@tiptap/extension-heading@${te}`),
26
+ paragraph: Z(`@tiptap/extension-paragraph@${te}`),
27
+ pmModel: Z(`@tiptap/pm@${Ge}/model`)
28
+ }, ve = "__vs_form_tiptap_loader__", ee = (t) => import(
29
+ /* @vite-ignore */
30
+ t
31
+ ), q = (t, e) => t?.[e] || t?.default?.[e] || t?.default?.default?.[e] || t?.default || t, Zt = (t) => t.extend({
32
+ addOptions() {
33
+ return {
34
+ ...this.parent?.(),
35
+ levels: [1, 2, 3, 4, 5, 6]
36
+ };
37
+ }
38
+ }), Jt = (t, e, a, s, n) => {
39
+ const r = e.extend({
40
+ addAttributes() {
41
+ return {
42
+ ...this.parent?.(),
43
+ border: {
44
+ default: null,
45
+ parseHTML: (l) => l.getAttribute("border"),
46
+ renderHTML: (l) => l.border ? { border: l.border } : {}
47
+ },
48
+ cellpadding: {
49
+ default: null,
50
+ parseHTML: (l) => l.getAttribute("cellpadding"),
51
+ renderHTML: (l) => l.cellpadding ? { cellpadding: l.cellpadding } : {}
52
+ },
53
+ cellspacing: {
54
+ default: null,
55
+ parseHTML: (l) => l.getAttribute("cellspacing"),
56
+ renderHTML: (l) => l.cellspacing ? { cellspacing: l.cellspacing } : {}
57
+ },
58
+ style: {
59
+ default: null,
60
+ parseHTML: (l) => l.getAttribute("style"),
61
+ renderHTML: (l) => l.style ? { style: l.style } : {}
62
+ },
63
+ width: {
64
+ default: null,
65
+ parseHTML: (l) => l.getAttribute("width"),
66
+ renderHTML: (l) => l.width ? { width: l.width } : {}
67
+ }
68
+ };
69
+ },
70
+ parseHTML() {
71
+ return [
72
+ {
73
+ tag: "div.tableWrapper table",
74
+ priority: 100
75
+ },
76
+ {
77
+ tag: "table"
78
+ }
79
+ ];
80
+ }
81
+ });
82
+ return t.extend({
83
+ addExtensions() {
84
+ return [
85
+ r.configure({
86
+ resizable: !0
87
+ }),
88
+ a,
89
+ s,
90
+ n
91
+ ];
92
+ }
93
+ });
94
+ }, er = (t) => t.extend({
95
+ addAttributes() {
96
+ return {
97
+ ...this.parent?.(),
98
+ fontFamily: {
99
+ default: null,
100
+ parseHTML: (e) => e.style.fontFamily?.replace(/['"]/g, ""),
101
+ renderHTML: (e) => e.fontFamily ? {
102
+ style: `font-family: ${e.fontFamily}`
103
+ } : {}
104
+ },
105
+ fontSize: {
106
+ default: null,
107
+ parseHTML: (e) => e.style.fontSize?.replace(/['"]/g, ""),
108
+ renderHTML: (e) => e.fontSize ? {
109
+ style: `font-size: ${e.fontSize}`
110
+ } : {}
111
+ },
112
+ color: {
113
+ default: null,
114
+ parseHTML: (e) => e.style.color?.replace(/['"]/g, ""),
115
+ renderHTML: (e) => e.color ? {
116
+ style: `color: ${e.color}`
117
+ } : {}
118
+ },
119
+ backgroundColor: {
120
+ default: null,
121
+ parseHTML: (e) => e.style.backgroundColor?.replace(/['"]/g, ""),
122
+ renderHTML: (e) => !e.backgroundColor || e.backgroundColor === "transparent" ? {} : {
123
+ style: `background-color: ${e.backgroundColor}`
124
+ }
125
+ }
126
+ };
127
+ },
128
+ addCommands() {
129
+ return {
130
+ setFontFamily: (e) => ({ chain: a }) => a().setMark("textStyle", { fontFamily: e }).run(),
131
+ unsetFontFamily: () => ({ chain: e }) => e().setMark("textStyle", { fontFamily: null }).removeEmptyTextStyle().run(),
132
+ setFontSize: (e) => ({ chain: a }) => a().setMark("textStyle", { fontSize: e }).run(),
133
+ unsetFontSize: () => ({ chain: e }) => e().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run(),
134
+ setColor: (e) => ({ chain: a }) => a().setMark("textStyle", { color: e }).run(),
135
+ unsetColor: () => ({ chain: e }) => e().setMark("textStyle", { color: null }).removeEmptyTextStyle().run(),
136
+ setBackgroundColor: (e) => ({ chain: a }) => a().setMark("textStyle", { backgroundColor: e }).run(),
137
+ unsetBackgroundColor: () => ({ chain: e }) => e().setMark("textStyle", { backgroundColor: null }).removeEmptyTextStyle().run()
138
+ };
139
+ }
140
+ }), tr = (t) => t.create({
141
+ name: "iframe",
142
+ group: "block",
143
+ inline: !1,
144
+ atom: !0,
145
+ selectable: !0,
146
+ addAttributes() {
147
+ return {
148
+ src: { default: null },
149
+ width: { default: "100%" },
150
+ height: { default: "280" },
151
+ frameborder: { default: "0" },
152
+ allow: { default: null },
153
+ allowfullscreen: { default: null },
154
+ referrerpolicy: { default: null },
155
+ loading: { default: null },
156
+ class: { default: null },
157
+ title: { default: null },
158
+ style: { default: null }
159
+ };
160
+ },
161
+ parseHTML() {
162
+ return [{ tag: "iframe" }];
163
+ },
164
+ renderHTML({ HTMLAttributes: e }) {
165
+ return ["iframe", e];
166
+ }
167
+ });
168
+ async function rr() {
169
+ if (typeof window > "u") return null;
170
+ const t = window;
171
+ return t[ve] || (t[ve] = Promise.all([
172
+ ee(J.core),
173
+ ee(J.starterKit),
174
+ ee(J.textStyle),
175
+ ee(J.table),
176
+ ee(J.highlight),
177
+ ee(J.subscript),
178
+ ee(J.superscript),
179
+ ee(J.link),
180
+ ee(J.image),
181
+ ee(J.textAlign),
182
+ ee(J.heading),
183
+ ee(J.paragraph),
184
+ ee(J.pmModel)
185
+ ]).then(([
186
+ e,
187
+ a,
188
+ s,
189
+ n,
190
+ r,
191
+ l,
192
+ c,
193
+ o,
194
+ i,
195
+ w,
196
+ b,
197
+ p,
198
+ g
199
+ ]) => {
200
+ const P = q(e, "Editor"), O = q(e, "Node"), z = q(a, "StarterKit"), U = q(s, "TextStyle"), Y = q(n, "TableKit"), I = q(n, "Table"), Q = q(n, "TableRow"), oe = q(n, "TableCell"), ue = q(n, "TableHeader"), fe = q(r, "Highlight"), m = q(l, "Subscript"), _ = q(c, "Superscript"), f = q(o, "Link"), $ = q(i, "Image"), y = q(w, "TextAlign"), B = q(b, "Heading"), h = q(p, "Paragraph"), S = q(g, "DOMParser");
201
+ if (!P || !O || !z || !U || !Y || !I || !Q || !oe || !ue || !fe || !m || !_ || !f || !$ || !y || !B || !h || !S)
202
+ throw new Error("Failed to resolve one or more Tiptap modules");
203
+ return {
204
+ Editor: P,
205
+ ProseMirrorDOMParser: S,
206
+ StarterKit: z,
207
+ ExtendedTextStyle: er(U),
208
+ Highlight: fe,
209
+ Subscript: m,
210
+ Superscript: _,
211
+ Link: f,
212
+ Image: $,
213
+ TextAlign: y,
214
+ CustomHeading: Zt(B),
215
+ CustomParagraph: h,
216
+ CustomTableKit: Jt(Y, I, Q, oe, ue),
217
+ Iframe: tr(O)
218
+ };
219
+ }).catch((e) => {
220
+ throw delete t[ve], e;
221
+ })), t[ve];
222
+ }
223
+ const ie = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), _e = (t) => {
224
+ let e = ie(t || "");
225
+ return e = e.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g, (a, s, n, r) => {
226
+ const l = r ? ` title="${ie(r)}"` : "";
227
+ return `<img src="${ie(n)}" alt="${ie(s)}"${l}>`;
228
+ }), e = e.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g, (a, s, n, r) => {
229
+ const l = r ? ` title="${ie(r)}"` : "";
230
+ return `<a href="${ie(n)}"${l} target="_blank" rel="noopener noreferrer">${s}</a>`;
231
+ }), e = e.replace(/`([^`]+)`/g, "<code>$1</code>"), e = e.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>"), e = e.replace(/__([^_]+)__/g, "<strong>$1</strong>"), e = e.replace(/~~([^~]+)~~/g, "<del>$1</del>"), e = e.replace(/\*([^*\n]+)\*/g, "<em>$1</em>"), e = e.replace(/_([^_\n]+)_/g, "<em>$1</em>"), e;
232
+ }, xe = (t) => /^\s*\d+\.\s+/.test(t), Ie = (t) => /^\s*[-*+]\s+/.test(t), Ye = (t) => /^\s*[-*+]\s+\[[ xX]\]\s+/.test(t), Le = (t) => /^\s*>\s?/.test(t), Pe = (t) => /^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(t), Ne = (t) => t.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((e) => _e(e.trim())), or = (t, e) => {
233
+ const a = t[e], s = t[e + 1];
234
+ if (!a || !s || !a.includes("|") || !Pe(s))
235
+ return null;
236
+ const n = Ne(a), r = [];
237
+ let l = e + 2;
238
+ for (; l < t.length && t[l].includes("|") && t[l].trim() !== ""; ) {
239
+ const i = Ne(t[l]);
240
+ r.push(`<tr>${i.map((w) => `<td>${w}</td>`).join("")}</tr>`), l += 1;
241
+ }
242
+ const c = `<thead><tr>${n.map((i) => `<th>${i}</th>`).join("")}</tr></thead>`, o = r.length ? `<tbody>${r.join("")}</tbody>` : "";
243
+ return {
244
+ html: `<table>${c}${o}</table>`,
245
+ nextIndex: l
246
+ };
247
+ }, lr = (t, e) => {
248
+ const a = xe(t[e]), s = a ? "ol" : "ul", n = [];
249
+ let r = e;
250
+ for (; r < t.length; ) {
251
+ const l = t[r];
252
+ if (l.trim() === "" || !(a ? xe(l) : (Ie(l) || Ye(l)) && !xe(l))) break;
253
+ const o = l.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);
254
+ if (o) {
255
+ const i = o[1].toLowerCase() === "x";
256
+ n.push(`<li><input type="checkbox" disabled${i ? " checked" : ""}> ${_e(o[2])}</li>`);
257
+ } else {
258
+ const i = l.replace(/^\s*(?:[-*+]|\d+\.)\s+/, "");
259
+ n.push(`<li>${_e(i)}</li>`);
260
+ }
261
+ r += 1;
262
+ }
263
+ return {
264
+ html: `<${s}>${n.join("")}</${s}>`,
265
+ nextIndex: r
266
+ };
267
+ }, ar = (t, e) => {
268
+ const s = t[e].replace(/^```/, "").trim(), n = [];
269
+ let r = e + 1;
270
+ for (; r < t.length && !t[r].startsWith("```"); )
271
+ n.push(t[r]), r += 1;
272
+ return {
273
+ html: `<pre><code${s ? ` class="language-${ie(s)}"` : ""}>${ie(n.join(`
274
+ `))}</code></pre>`,
275
+ nextIndex: r < t.length ? r + 1 : r
276
+ };
277
+ }, nr = (t, e) => {
278
+ const a = [];
279
+ let s = e;
280
+ for (; s < t.length; ) {
281
+ const n = t[s];
282
+ if (n.trim() === "" || n.startsWith("```") || /^#{1,6}\s+/.test(n) || /^---+$/.test(n.trim()) || /^\*\*\*+$/.test(n.trim()) || Le(n) || xe(n) || Ie(n) || s + 1 < t.length && n.includes("|") && Pe(t[s + 1]))
283
+ break;
284
+ a.push(n.trim()), s += 1;
285
+ }
286
+ return {
287
+ html: `<p>${_e(a.join(" "))}</p>`,
288
+ nextIndex: s
289
+ };
290
+ }, Qe = (t) => {
291
+ const a = (t || "").replace(/\r\n/g, `
292
+ `).split(`
293
+ `), s = [];
294
+ let n = 0;
295
+ for (; n < a.length; ) {
296
+ const r = a[n], l = r.trim();
297
+ if (!l) {
298
+ n += 1;
299
+ continue;
300
+ }
301
+ if (r.startsWith("```")) {
302
+ const i = ar(a, n);
303
+ s.push(i.html), n = i.nextIndex;
304
+ continue;
305
+ }
306
+ const c = r.match(/^(#{1,6})\s+(.*)$/);
307
+ if (c) {
308
+ const i = c[1].length;
309
+ s.push(`<h${i}>${_e(c[2])}</h${i}>`), n += 1;
310
+ continue;
311
+ }
312
+ if (/^---+$/.test(l) || /^\*\*\*+$/.test(l)) {
313
+ s.push("<hr>"), n += 1;
314
+ continue;
315
+ }
316
+ if (r.includes("|") && n + 1 < a.length && Pe(a[n + 1])) {
317
+ const i = or(a, n);
318
+ if (i) {
319
+ s.push(i.html), n = i.nextIndex;
320
+ continue;
321
+ }
322
+ }
323
+ if (Le(r)) {
324
+ const i = [];
325
+ for (; n < a.length && Le(a[n]); )
326
+ i.push(a[n].replace(/^\s*>\s?/, "")), n += 1;
327
+ s.push(`<blockquote>${Qe(i.join(`
328
+ `))}</blockquote>`);
329
+ continue;
330
+ }
331
+ if (xe(r) || Ie(r) || Ye(r)) {
332
+ const i = lr(a, n);
333
+ s.push(i.html), n = i.nextIndex;
334
+ continue;
335
+ }
336
+ const o = nr(a, n);
337
+ s.push(o.html), n = o.nextIndex;
338
+ }
339
+ return s.join("");
340
+ }, Fe = (t) => (t.textContent || "").replace(/\u00a0/g, " "), Ze = (t) => Array.from(t.childNodes).map((e) => je(e)).join(""), sr = (t) => {
341
+ const e = Array.from(t.querySelectorAll("tr"));
342
+ if (!e.length) return "";
343
+ const a = (c) => `| ${Array.from(c.children).map((i) => Ze(i).trim()).join(" | ")} |`, s = e[0], n = s ? Array.from(s.children).length : 0, r = `| ${Array(Math.max(n, 1)).fill("---").join(" | ")} |`, l = e.slice(1).map((c) => a(c));
344
+ return [a(s), r, ...l].join(`
345
+ `);
346
+ }, ze = (t, e = !1) => Array.from(t.children).filter((a) => a.nodeType === Node.ELEMENT_NODE).map((a, s) => {
347
+ const n = a, r = n.querySelector('input[type="checkbox"]'), l = Array.from(n.childNodes).filter((c) => !(c instanceof HTMLInputElement)).map((c) => je(c)).join("").trim();
348
+ return r ? `- [${r.checked ? "x" : " "}] ${l}` : e ? `${s + 1}. ${l}` : `- ${l}`;
349
+ }).join(`
350
+ `);
351
+ function je(t) {
352
+ if (t.nodeType === Node.TEXT_NODE)
353
+ return Fe(t);
354
+ if (t.nodeType !== Node.ELEMENT_NODE)
355
+ return "";
356
+ const e = t, a = e.tagName.toLowerCase(), s = Ze(e);
357
+ switch (a) {
358
+ case "br":
359
+ return `
360
+ `;
361
+ case "p":
362
+ return `${s.trim()}
363
+
364
+ `;
365
+ case "strong":
366
+ case "b":
367
+ return `**${s}**`;
368
+ case "em":
369
+ case "i":
370
+ return `*${s}*`;
371
+ case "del":
372
+ case "s":
373
+ return `~~${s}~~`;
374
+ case "code":
375
+ return e.parentElement?.tagName.toLowerCase() === "pre" ? s : `\`${s}\``;
376
+ case "pre": {
377
+ const n = e.querySelector("code"), c = (n?.className || "").match(/language-([a-z0-9_-]+)/i)?.[1] || "", o = Fe(n || e);
378
+ return `\`\`\`${c}
379
+ ${o}
380
+ \`\`\`
381
+
382
+ `;
383
+ }
384
+ case "blockquote":
385
+ return `${s.trim().split(`
386
+ `).map((n) => `> ${n}`).join(`
387
+ `)}
388
+
389
+ `;
390
+ case "h1":
391
+ case "h2":
392
+ case "h3":
393
+ case "h4":
394
+ case "h5":
395
+ case "h6": {
396
+ const n = Number(a[1]);
397
+ return `${"#".repeat(n)} ${s.trim()}
398
+
399
+ `;
400
+ }
401
+ case "ul":
402
+ return `${ze(e, !1)}
403
+
404
+ `;
405
+ case "ol":
406
+ return `${ze(e, !0)}
407
+
408
+ `;
409
+ case "a": {
410
+ const n = e.getAttribute("href") || "";
411
+ return `[${s || n}](${n})`;
412
+ }
413
+ case "img": {
414
+ const n = e.getAttribute("alt") || "", r = e.getAttribute("src") || "";
415
+ return r ? `![${n}](${r})` : "";
416
+ }
417
+ case "hr":
418
+ return `---
419
+
420
+ `;
421
+ case "table":
422
+ return `${sr(e)}
423
+
424
+ `;
425
+ default:
426
+ return s;
427
+ }
428
+ }
429
+ const Je = (t) => {
430
+ if (!t) return "";
431
+ if (typeof window > "u" || typeof DOMParser > "u")
432
+ return t;
433
+ const a = new DOMParser().parseFromString(t, "text/html");
434
+ return Array.from(a.body.childNodes).map((s) => je(s)).join("").replace(/\n{3,}/g, `
435
+
436
+ `).trim();
437
+ }, ir = /* @__PURE__ */ new Set([
438
+ "area",
439
+ "base",
440
+ "br",
441
+ "col",
442
+ "embed",
443
+ "hr",
444
+ "img",
445
+ "input",
446
+ "link",
447
+ "meta",
448
+ "param",
449
+ "source",
450
+ "track",
451
+ "wbr"
452
+ ]), cr = (t) => {
453
+ if (!t) return "";
454
+ if (typeof window > "u" || typeof DOMParser > "u")
455
+ return t;
456
+ const a = new DOMParser().parseFromString(t, "text/html"), s = " ", n = (r, l) => {
457
+ if (r.nodeType === Node.TEXT_NODE) {
458
+ const g = (r.textContent || "").replace(/\s+/g, " ").trim();
459
+ return g ? [`${s.repeat(l)}${g}`] : [];
460
+ }
461
+ if (r.nodeType !== Node.ELEMENT_NODE)
462
+ return [];
463
+ const c = r, o = c.tagName.toLowerCase(), i = Array.from(c.attributes).map((g) => `${g.name}="${g.value}"`).join(" "), w = i ? `<${o} ${i}>` : `<${o}>`, b = `</${o}>`;
464
+ if (ir.has(o))
465
+ return [`${s.repeat(l)}${w}`];
466
+ const p = Array.from(c.childNodes).flatMap((g) => n(g, l + 1));
467
+ if (!p.length)
468
+ return [`${s.repeat(l)}${w}${b}`];
469
+ if (c.childNodes.length === 1 && c.firstChild?.nodeType === Node.TEXT_NODE && p.length === 1) {
470
+ const g = p[0].trim();
471
+ return [`${s.repeat(l)}${w}${g}${b}`];
472
+ }
473
+ return [
474
+ `${s.repeat(l)}${w}`,
475
+ ...p,
476
+ `${s.repeat(l)}${b}`
477
+ ];
478
+ };
479
+ return Array.from(a.body.childNodes).flatMap((r) => n(r, 0)).join(`
480
+ `);
481
+ }, dr = (t) => t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Se = (t) => {
482
+ if (!t) return "";
483
+ if (typeof window > "u" || typeof DOMParser > "u")
484
+ return t.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "");
485
+ const a = new DOMParser().parseFromString(t, "text/html");
486
+ return a.querySelectorAll("script").forEach((s) => s.remove()), a.body.innerHTML;
487
+ }, De = (t) => {
488
+ if (!t)
489
+ return { wrapper: null, bodyHtml: "" };
490
+ if (typeof window > "u" || typeof DOMParser > "u")
491
+ return { wrapper: null, bodyHtml: t };
492
+ const a = new DOMParser().parseFromString(t, "text/html"), { body: s } = a;
493
+ if (s.childElementCount !== 1)
494
+ return { wrapper: null, bodyHtml: t };
495
+ const n = s.firstElementChild;
496
+ return !n || n.tagName.toLowerCase() !== "div" ? { wrapper: null, bodyHtml: t } : {
497
+ wrapper: {
498
+ tag: n.tagName.toLowerCase(),
499
+ attributes: Array.from(n.attributes).map((r) => ({
500
+ name: r.name,
501
+ value: r.value
502
+ }))
503
+ },
504
+ bodyHtml: n.innerHTML
505
+ };
506
+ }, Oe = (t, e) => {
507
+ if (!e) return t || "";
508
+ const a = (e.attributes || []).map(({ name: n, value: r }) => `${n}="${dr(r)}"`).join(" ");
509
+ return `${a ? `<${e.tag} ${a}>` : `<${e.tag}>`}${t || ""}</${e.tag}>`;
510
+ }, Ve = async (t, e) => e !== "md" ? t || "" : Qe(t || ""), Re = async (t, e) => e !== "md" ? cr(t || "") : Je(t || ""), ur = async (t, e) => e !== "md" ? t || "" : Je(t || ""), fr = async (t) => {
511
+ try {
512
+ const e = new FormData();
513
+ return e.append("unique", "true"), e.append("file", t), (await (await fetch("/file/upload/uploads?id=&form=&table=", {
514
+ method: "POST",
515
+ body: e
516
+ })).json())?.result;
517
+ } catch (e) {
518
+ console.error(e);
519
+ }
520
+ }, pr = async (t, e, a) => {
521
+ const s = e.clipboardData?.items;
522
+ if (s) {
523
+ const n = e.clipboardData?.getData("text/html"), r = e.clipboardData?.getData("text/plain");
524
+ if (n) {
525
+ const { state: l, dispatch: c } = t, { tr: o } = l, i = a.fromSchema(t.state.schema), w = new DOMParser().parseFromString(n, "text/html").body, b = i.parse(w), p = o.replaceSelectionWith(b);
526
+ return c(p), e.preventDefault(), !0;
527
+ }
528
+ if (r) {
529
+ const { state: l, dispatch: c } = t, { tr: o } = l, i = o.insertText(r, l.selection.from, l.selection.to);
530
+ return c(i), e.preventDefault(), !0;
531
+ }
532
+ for (let l = 0; l < s.length; l++) {
533
+ const c = s[l];
534
+ if (c.type.startsWith("image/")) {
535
+ const o = c.getAsFile();
536
+ if (o) {
537
+ const i = await fr(o), { schema: w } = t.state, b = w.nodes.image.create({
538
+ src: i?.file_path
539
+ }), p = t.state.tr.replaceSelectionWith(b);
540
+ return t.dispatch(p), e.preventDefault(), !0;
541
+ }
542
+ }
543
+ }
544
+ }
545
+ return !1;
546
+ }, gr = (t) => String(t).trim().toLowerCase().split("-")[0], hr = () => typeof window > "u" ? "uk" : gr(
547
+ localStorage.getItem("language") || localStorage.getItem("locale") || navigator.language || "uk"
548
+ ), vr = (t, e) => {
549
+ const a = e.replace(/^form\.richtext\./, "");
550
+ return He?.[t]?.form?.richtext?.[a] || He?.uk?.form?.richtext?.[a] || e;
551
+ }, Ue = (t) => t.startsWith("form.richtext.") ? t : `form.richtext.${t}`;
552
+ function Me() {
553
+ const e = lt()?.appContext?.config?.globalProperties, a = e?.$i18n;
554
+ return { t: (n) => {
555
+ const r = e?.$t, l = e?.$te, c = typeof a?.te == "function" ? a.te.bind(a) : null;
556
+ if (typeof r == "function") {
557
+ const o = Ue(n);
558
+ if ((typeof l == "function" ? l(o) : typeof c == "function" ? c(o) : null) !== !1) {
559
+ const w = r(o);
560
+ if (w && w !== o)
561
+ return w;
562
+ }
563
+ }
564
+ return vr(hr(), Ue(n));
565
+ } };
566
+ }
567
+ const mr = {
568
+ components: { Quote: bt },
569
+ props: { editor: Object },
570
+ methods: {
571
+ toggleBlockquote() {
572
+ this.editor && this.editor.chain().toggleBlockquote().run();
573
+ }
574
+ }
575
+ };
576
+ function br(t, e, a, s, n, r) {
577
+ const l = G("Quote");
578
+ return v(), k("button", {
579
+ title: "Blockquote",
580
+ onClick: e[0] || (e[0] = (...c) => r.toggleBlockquote && r.toggleBlockquote(...c)),
581
+ class: E(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none", { "bg-gray-100 text-gray-900": a.editor?.isActive("blockquote") }])
582
+ }, [
583
+ F(l, { class: "h-4 w-4" })
584
+ ], 2);
585
+ }
586
+ const yr = /* @__PURE__ */ X(mr, [["render", br]]), xr = {
587
+ components: { List: yt },
588
+ props: { editor: Object },
589
+ methods: {
590
+ toggleBulletList() {
591
+ this.editor && this.editor.chain().focus().toggleBulletList().run();
592
+ }
593
+ }
594
+ };
595
+ function wr(t, e, a, s, n, r) {
596
+ const l = G("List");
597
+ return v(), k("button", {
598
+ title: "Bullet List",
599
+ onClick: e[0] || (e[0] = (...c) => r.toggleBulletList && r.toggleBulletList(...c)),
600
+ class: E(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": a.editor?.isActive("bulletList") }])
601
+ }, [
602
+ F(l, { class: "h-4 w-4" })
603
+ ], 2);
604
+ }
605
+ const kr = /* @__PURE__ */ X(xr, [["render", wr]]), _r = {
606
+ components: { ListOrdered: xt },
607
+ props: { editor: Object },
608
+ methods: {
609
+ toggleOrderedList() {
610
+ this.editor && this.editor.chain().focus().toggleOrderedList().run();
611
+ }
612
+ }
613
+ };
614
+ function $r(t, e, a, s, n, r) {
615
+ const l = G("ListOrdered");
616
+ return v(), k("button", {
617
+ title: "Ordered List",
618
+ onClick: e[0] || (e[0] = (...c) => r.toggleOrderedList && r.toggleOrderedList(...c)),
619
+ class: E(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": a.editor?.isActive("orderedList") }])
620
+ }, [
621
+ F(l, { class: "h-4 w-4" })
622
+ ], 2);
623
+ }
624
+ const Cr = /* @__PURE__ */ X(_r, [["render", $r]]), Ar = {
625
+ components: { CodeXml: wt },
626
+ props: { editor: Object },
627
+ methods: {
628
+ toggleCodeBlock() {
629
+ this.editor && this.editor.chain().focus().toggleCodeBlock().run();
630
+ }
631
+ }
632
+ };
633
+ function Fr(t, e, a, s, n, r) {
634
+ const l = G("CodeXml");
635
+ return v(), k("button", {
636
+ title: "Code Block",
637
+ onClick: e[0] || (e[0] = (...c) => r.toggleCodeBlock && r.toggleCodeBlock(...c)),
638
+ class: E(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": a.editor?.isActive("codeBlock") }])
639
+ }, [
640
+ F(l, { class: "h-4 w-4" })
641
+ ], 2);
642
+ }
643
+ const Sr = /* @__PURE__ */ X(Ar, [["render", Fr]]), Tr = {
644
+ components: { Bold: kt },
645
+ props: {
646
+ editor: Object
647
+ },
648
+ methods: {
649
+ toggleBold() {
650
+ this.editor && this.editor.commands.toggleBold();
651
+ }
652
+ }
653
+ };
654
+ function Lr(t, e, a, s, n, r) {
655
+ const l = G("Bold");
656
+ return v(), k("button", {
657
+ title: "Bold Text",
658
+ onClick: e[0] || (e[0] = (...c) => r.toggleBold && r.toggleBold(...c)),
659
+ class: E(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": a.editor?.isActive("bold") }])
660
+ }, [
661
+ F(l, { class: "h-4 w-4" }),
662
+ e[1] || (e[1] = d("span", { class: "sr-only" }, "Bold", -1))
663
+ ], 2);
664
+ }
665
+ const Br = /* @__PURE__ */ X(Tr, [["render", Lr]]), Er = {
666
+ components: { Italic: _t },
667
+ props: {
668
+ editor: Object
669
+ },
670
+ methods: {
671
+ toggleItalic() {
672
+ this.editor && this.editor.chain().toggleItalic().run();
673
+ }
674
+ }
675
+ };
676
+ function Ir(t, e, a, s, n, r) {
677
+ const l = G("Italic");
678
+ return v(), k("button", {
679
+ title: "Italic Text",
680
+ onClick: e[0] || (e[0] = (...c) => r.toggleItalic && r.toggleItalic(...c)),
681
+ class: E(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": a.editor?.isActive("italic") }])
682
+ }, [
683
+ F(l, { class: "h-4 w-4" }),
684
+ e[1] || (e[1] = d("span", { class: "sr-only" }, "Italic", -1))
685
+ ], 2);
686
+ }
687
+ const Pr = /* @__PURE__ */ X(Er, [["render", Ir]]), jr = {
688
+ __name: "vs-editor-underline",
689
+ props: { editor: Object },
690
+ setup(t) {
691
+ const e = t, a = () => {
692
+ e.editor && e.editor.chain().focus().toggleUnderline().run();
693
+ };
694
+ return (s, n) => (v(), k("button", {
695
+ title: "Underline",
696
+ onClick: a,
697
+ class: E(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100", [
698
+ t.editor?.isActive("underline") ? "bg-gray-100 text-gray-900" : "text-gray-500"
699
+ ]])
700
+ }, [
701
+ F(L($t), { class: "h-4 w-4" })
702
+ ], 2));
703
+ }
704
+ }, Mr = {
705
+ __name: "vs-editor-strike",
706
+ props: { editor: Object },
707
+ setup(t) {
708
+ const e = t, a = () => {
709
+ e.editor && e.editor.chain().focus().toggleStrike().run();
710
+ };
711
+ return (s, n) => (v(), k("button", {
712
+ title: "Strikethrough",
713
+ onClick: a,
714
+ class: E(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100", [
715
+ t.editor?.isActive("strike") ? "bg-gray-100 text-gray-900" : "text-gray-500"
716
+ ]])
717
+ }, [
718
+ F(L(Ct), { class: "h-4 w-4" })
719
+ ], 2));
720
+ }
721
+ }, Hr = {
722
+ components: { X: Be },
723
+ props: {
724
+ visible: { type: Boolean, default: () => !1 },
725
+ modelValue: { type: Boolean, default: () => !1 },
726
+ title: { type: String, default: () => "" },
727
+ size: { type: String, default: () => "" },
728
+ closeClickBack: { type: Boolean, default: () => !1 }
729
+ },
730
+ emits: ["update:visible", "update:modelValue", "onClose", "confirm", "cancel"],
731
+ inheritAttrs: !1,
732
+ name: "vs-dialog",
733
+ mounted() {
734
+ window.addEventListener("keydown", this.checkKey);
735
+ },
736
+ unmounted() {
737
+ window.removeEventListener("keydown", this.checkKey);
738
+ },
739
+ computed: {
740
+ hasSlot() {
741
+ return !!this.$slots?.footer;
742
+ },
743
+ checkSize() {
744
+ return this.size === "small" ? "md:w-5/12 w-9/12" : this.size === "medium" ? "md:w-6/12 w-9/12" : "lg:w-7/12 w-11/12";
745
+ }
746
+ },
747
+ methods: {
748
+ checkKey({ key: t }) {
749
+ t === "Escape" && this.handleClose();
750
+ },
751
+ handleClose() {
752
+ this.$emit("update:visible", !1), this.$emit("update:modelValue", !1), this.$emit("onClose");
753
+ },
754
+ handleConfirm() {
755
+ this.$emit("confirm"), this.handleClose();
756
+ },
757
+ handleCancel() {
758
+ this.$emit("cancel"), this.handleClose();
759
+ },
760
+ closeByClickBack(t, e) {
761
+ e && t.target.classList.contains("vs-dialog-overlay") && this.handleClose();
762
+ }
763
+ }
764
+ }, Nr = {
765
+ key: 0,
766
+ class: "vsTailwind ui-dialog__wrapper"
767
+ }, zr = { class: "py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]" }, Dr = { class: "font-medium text-gray-800 dark:text-[#ffffff]" }, Or = { class: "ui-dialog__content p-4" }, Vr = {
768
+ key: 0,
769
+ class: "flex justify-end gap-x-2"
770
+ };
771
+ function Rr(t, e, a, s, n, r) {
772
+ const l = G("X");
773
+ return v(), K(Ke, { to: "body" }, [
774
+ a.visible || a.modelValue ? (v(), k("div", Nr, [
775
+ d("div", {
776
+ onMousedown: e[1] || (e[1] = (c) => r.closeByClickBack(c, a.closeClickBack)),
777
+ class: "vs-dialog-overlay vs-dialog w-full h-full fixed top-0 start-0 z-[100001] bg-black bg-opacity-50"
778
+ }, [
779
+ F(We, {
780
+ name: "content",
781
+ appear: ""
782
+ }, {
783
+ default: R(() => [
784
+ d("div", {
785
+ class: E(["ui-dialog__modal opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl", [r.checkSize]])
786
+ }, [
787
+ d("div", zr, [
788
+ d("h3", Dr, W(a.title), 1),
789
+ d("button", {
790
+ type: "button",
791
+ class: "size-8 inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent bg-gray-100 text-gray-800 hover:bg-gray-200 focus:outline-none focus:bg-gray-200 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-400 dark:focus:bg-neutral-600",
792
+ onClick: e[0] || (e[0] = (...c) => r.handleClose && r.handleClose(...c))
793
+ }, [
794
+ e[2] || (e[2] = d("span", { class: "sr-only" }, "Close", -1)),
795
+ F(l, { class: "h-4 w-4 flex-shrink-0" })
796
+ ])
797
+ ]),
798
+ d("div", Or, [
799
+ be(t.$slots, "default", {}, void 0, !0)
800
+ ]),
801
+ r.hasSlot ? (v(), k("div", Vr, [
802
+ be(t.$slots, "footer", {
803
+ handleClose: r.handleClose,
804
+ handleConfirm: r.handleConfirm,
805
+ handleCancel: r.handleCancel
806
+ }, void 0, !0)
807
+ ])) : V("", !0)
808
+ ], 2)
809
+ ]),
810
+ _: 3
811
+ })
812
+ ], 32)
813
+ ])) : V("", !0)
814
+ ]);
815
+ }
816
+ const et = /* @__PURE__ */ X(Hr, [["render", Rr], ["__scopeId", "data-v-9395bb47"]]), Ur = at({
817
+ components: {
818
+ IconClose: Be,
819
+ IconSearch: Ft,
820
+ IconEmail: At
821
+ },
822
+ inheritAttrs: !1,
823
+ props: {
824
+ icon: { type: String, default: () => "" },
825
+ disabled: { type: Boolean, default: () => !1 },
826
+ clearable: { type: Boolean, default: () => !1 },
827
+ modelValue: { type: String, default: () => "" },
828
+ placeholder: { type: String, default: () => "" },
829
+ iconPosition: { type: String, default: () => "right" },
830
+ type: { type: String, default: () => "text" },
831
+ style: { type: Object, default: () => null },
832
+ size: { type: String, default: () => "md" },
833
+ attrs: { type: Object, default: () => {
834
+ } }
835
+ },
836
+ emits: ["onInput", "update:modelValue", "blur", "focus"],
837
+ computed: {
838
+ checkSize() {
839
+ return (this.style?.size || this.size) === "xs" ? "h-[32px] text-sm" : (this.style?.size || this.size) === "md" ? "h-[38px] text-sm" : (this.style?.size || this.size) === "lg" ? "h-[46px] text-[20px]" : "h-[38px] text-sm";
840
+ },
841
+ value: {
842
+ get() {
843
+ return this.modelValue;
844
+ },
845
+ set(t) {
846
+ this.$emit("update:modelValue", t.trim());
847
+ }
848
+ },
849
+ clearIconStyle() {
850
+ return [
851
+ {
852
+ "right-8": this.icon && this.iconPosition === "right",
853
+ "right-3": !this.icon || this.iconPosition !== "right",
854
+ "pointer-events-none": this.disabled
855
+ }
856
+ ];
857
+ },
858
+ iconStylePosition() {
859
+ return [
860
+ {
861
+ "left-3": this.icon && this.iconPosition === "left",
862
+ "right-3": this.icon && this.iconPosition === "right"
863
+ }
864
+ ];
865
+ },
866
+ inputStyle() {
867
+ return [
868
+ {
869
+ "!pr-8": this.clearable && !this.icon,
870
+ "!pr-7": this.clearable,
871
+ "!pr-16": this.clearable && this.icon && this.iconPosition === "right",
872
+ "!pl-8": this.icon && this.iconPosition === "left",
873
+ "!pr-[50px]": this.clearable && this.value && this.icon && this.iconPosition === "right",
874
+ "!cursor-not-allowed bg-slate-100": this.disabled,
875
+ "bg-white": !this.disabled
876
+ }
877
+ ];
878
+ }
879
+ },
880
+ methods: {
881
+ // Emits input value to the upper level
882
+ handleInput() {
883
+ this.$emit("onInput", this.modelValue);
884
+ },
885
+ handleBlur() {
886
+ this.$emit("blur");
887
+ },
888
+ handleFocus() {
889
+ this.$emit("focus");
890
+ },
891
+ // Clears input
892
+ clearInput() {
893
+ this.$emit("update:modelValue", ""), this.$emit("onInput", "");
894
+ },
895
+ async inputFocus() {
896
+ await this.$refs.vsText?.focus();
897
+ }
898
+ }
899
+ }), qr = { class: "vs-form-text relative bg-white rounded-lg" }, Kr = {
900
+ key: 2,
901
+ class: "absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"
902
+ }, Wr = ["disabled", "type", "placeholder"];
903
+ function Xr(t, e, a, s, n, r) {
904
+ const l = G("IconClose"), c = G("IconSearch"), o = G("IconEmail");
905
+ return v(), k("div", qr, [
906
+ t.clearable && t.value ? (v(), k("div", {
907
+ key: 0,
908
+ class: "absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",
909
+ onClick: e[0] || (e[0] = (...i) => t.clearInput && t.clearInput(...i))
910
+ }, [
911
+ F(l, { class: "h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500" })
912
+ ])) : V("", !0),
913
+ t.icon && t.icon === "search" ? (v(), k("div", {
914
+ key: 1,
915
+ class: E(["absolute bottom-2/4 translate-y-2/4 cursor-pointer", t.iconStylePosition])
916
+ }, [
917
+ F(c, { class: "h-4 w-4 stroke-gray-500 transition-all" })
918
+ ], 2)) : t.icon && t.icon === "email" ? (v(), k("div", Kr, [
919
+ F(o, { class: "h-4 w-4 stroke-gray-500 transition-all" })
920
+ ])) : (v(), k("i", {
921
+ key: 3,
922
+ class: E(["absolute bottom-2/4 translate-y-2/4 text-gray-500 cursor-pointer", ["ti " + t.icon, t.iconStylePosition]])
923
+ }, null, 2)),
924
+ t.clearable && t.value ? (v(), k("div", {
925
+ key: 4,
926
+ class: "absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",
927
+ onClick: e[1] || (e[1] = (...i) => t.clearInput && t.clearInput(...i))
928
+ }, [
929
+ F(l, { class: "h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500" })
930
+ ])) : V("", !0),
931
+ ce(d("input", nt({
932
+ ref: "vsText",
933
+ disabled: t.disabled,
934
+ type: t.type,
935
+ onInput: e[2] || (e[2] = (...i) => t.handleInput && t.handleInput(...i)),
936
+ placeholder: t.placeholder,
937
+ "onUpdate:modelValue": e[3] || (e[3] = (i) => t.value = i)
938
+ }, t.style?.attrs || t.attrs || {}, {
939
+ onFocus: e[4] || (e[4] = (...i) => t.handleFocus && t.handleFocus(...i)),
940
+ onBlur: e[5] || (e[5] = (...i) => t.handleBlur && t.handleBlur(...i)),
941
+ class: [[t.inputStyle, t.checkSize], "py-2 px-3 block w-full border border-solid placeholder:text-nowrap border-stone-200 rounded-lg text-sm text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"]
942
+ }), null, 16, Wr), [
943
+ [st, t.value]
944
+ ])
945
+ ]);
946
+ }
947
+ const tt = /* @__PURE__ */ X(Ur, [["render", Xr], ["__scopeId", "data-v-1e382a36"]]), Gr = ["title"], Yr = { class: "flex flex-col gap-3 p-[20px]" }, Qr = { class: "relative flex items-center gap-2" }, Zr = { class: "flex-1" }, Jr = {
948
+ key: 0,
949
+ class: "flex items-center gap-2 flex-shrink-0"
950
+ }, eo = ["title"], to = ["title"], ro = { class: "flex items-center gap-2" }, oo = {
951
+ for: "openInNewTab",
952
+ class: "text-sm text-gray-700 cursor-pointer"
953
+ }, lo = { class: "flex justify-end p-[20px] gap-[10px] border-t w-full" }, ao = /* @__PURE__ */ Object.assign({
954
+ inheritAttrs: !1
955
+ }, {
956
+ __name: "vs-editor-link",
957
+ props: { editor: Object },
958
+ setup(t) {
959
+ const { t: e } = Me(), a = t, s = C(!1), n = C(""), r = C(!1), l = C(!1), c = () => {
960
+ if (!a.editor) return;
961
+ a.editor.chain().focus().extendMarkRange("link").run();
962
+ const p = a.editor.getAttributes("link");
963
+ p.href ? (r.value = !0, n.value = p.href, l.value = p.target === "_blank") : (r.value = !1, n.value = "", l.value = !1), s.value = !0;
964
+ }, o = () => {
965
+ s.value = !1, n.value = "", r.value = !1, l.value = !1;
966
+ }, i = () => {
967
+ if (!a.editor || !n.value.trim()) return;
968
+ let p = n.value.trim();
969
+ p.match(/^https?:\/\//i) || (p = "https://" + p), a.editor.chain().focus().setLink({
970
+ href: p,
971
+ target: l.value ? "_blank" : null
972
+ }).run(), o();
973
+ }, w = () => {
974
+ a.editor && (a.editor.chain().focus().unsetLink().run(), o());
975
+ }, b = () => {
976
+ if (!n.value) return;
977
+ let p = n.value.trim();
978
+ p.match(/^https?:\/\//i) || (p = "https://" + p), window.open(p, "_blank", "noopener,noreferrer");
979
+ };
980
+ return (p, g) => (v(), k(re, null, [
981
+ d("button", {
982
+ title: L(e)("form.richtext.link") || "Посилання",
983
+ onClick: c,
984
+ class: E(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none", { "bg-gray-100 text-gray-900": t.editor?.isActive("link") }])
985
+ }, [
986
+ F(L(St), { class: "h-4 w-4" })
987
+ ], 10, Gr),
988
+ F(et, {
989
+ title: r.value ? L(e)("form.richtext.editLink") || "Редагувати посилання" : L(e)("form.richtext.linkTitle") || "Додати посилання",
990
+ visible: s.value,
991
+ "onUpdate:visible": g[2] || (g[2] = (P) => s.value = P),
992
+ size: "small"
993
+ }, {
994
+ footer: R(() => [
995
+ d("div", lo, [
996
+ d("button", {
997
+ style: { border: "1px solid #000" },
998
+ onClick: o,
999
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"
1000
+ }, W(L(e)("form.richtext.cancel") || "Скасувати"), 1),
1001
+ d("button", {
1002
+ onClick: i,
1003
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"
1004
+ }, W(r.value ? L(e)("form.richtext.update") || "Оновити" : L(e)("form.richtext.create") || "Створити"), 1)
1005
+ ])
1006
+ ]),
1007
+ default: R(() => [
1008
+ d("div", Yr, [
1009
+ d("div", Qr, [
1010
+ d("div", Zr, [
1011
+ F(tt, {
1012
+ modelValue: n.value,
1013
+ "onUpdate:modelValue": g[0] || (g[0] = (P) => n.value = P),
1014
+ placeholder: L(e)("form.richtext.linkUrl") || "Введіть URL",
1015
+ class: "w-full"
1016
+ }, null, 8, ["modelValue", "placeholder"])
1017
+ ]),
1018
+ r.value ? (v(), k("div", Jr, [
1019
+ d("button", {
1020
+ onClick: b,
1021
+ class: "text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none transition-colors",
1022
+ title: L(e)("form.richtext.openLink") || "Відкрити посилання"
1023
+ }, [
1024
+ F(L(Tt), { class: "h-4 w-4" })
1025
+ ], 8, eo),
1026
+ d("button", {
1027
+ onClick: w,
1028
+ class: "text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-red-600 hover:bg-red-50 focus:outline-none transition-colors",
1029
+ title: L(e)("form.richtext.removeLink") || "Видалити посилання"
1030
+ }, [
1031
+ F(L(Lt), { class: "h-4 w-4" })
1032
+ ], 8, to)
1033
+ ])) : V("", !0)
1034
+ ]),
1035
+ d("div", ro, [
1036
+ ce(d("input", {
1037
+ type: "checkbox",
1038
+ id: "openInNewTab",
1039
+ "onUpdate:modelValue": g[1] || (g[1] = (P) => l.value = P),
1040
+ class: "w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"
1041
+ }, null, 512), [
1042
+ [it, l.value]
1043
+ ]),
1044
+ d("label", oo, W(L(e)("form.richtext.openInNewTab") || "Відкривати в новій вкладці"), 1)
1045
+ ])
1046
+ ])
1047
+ ]),
1048
+ _: 1
1049
+ }, 8, ["title", "visible"])
1050
+ ], 64));
1051
+ }
1052
+ }), me = async (t, e, a, s = 10) => {
1053
+ if (!e || !a) return;
1054
+ await ge();
1055
+ const n = await a?.getBoundingClientRect(), r = await e?.getBoundingClientRect();
1056
+ if (!r || !n) return;
1057
+ const l = await parseInt(e?.getBoundingClientRect()?.height), c = await parseInt(e?.getBoundingClientRect()?.width), o = await parseInt(a?.getBoundingClientRect()?.height), i = await parseInt(a?.getBoundingClientRect()?.width), w = await window.innerHeight, b = await window.innerWidth;
1058
+ let p = 0, g = 0;
1059
+ const P = r.bottom + s + o;
1060
+ switch (t) {
1061
+ case "top":
1062
+ r.top - n.height - s < 0 ? p = r.top - n.height + s + o + l : p = r.top - n.height - s, b > i + r.right + 30 ? g = r.left - n.width / 2 + r.width / 2 : g = b - 30 - i;
1063
+ break;
1064
+ case "bottom":
1065
+ w > P ? p = r.bottom + s : p = r.bottom - s - o - l, g = r.left - n.width / 2 + r.width / 2;
1066
+ break;
1067
+ case "left":
1068
+ p = r.top - n.height / 2 + r.height / 2, r.left - n.width - s > 0 ? g = r.left - n.width - s : g = 10;
1069
+ break;
1070
+ case "right":
1071
+ p = r.top - n.height / 2 + r.height / 2, b - c > i ? g = r.right + s : g = b - 30 - i;
1072
+ break;
1073
+ case "top-right":
1074
+ r.top - n.height - s < 0 ? p = r.top - n.height + s + o + l : p = r.top - n.height - s, b - c > i ? g = r.right + s : g = b - 30 - i;
1075
+ break;
1076
+ case "top-left":
1077
+ r.top - n.height - s < 0 ? p = r.top - n.height + s + o + l : p = r.top - n.height - s, r.left - n.width - s > 0 ? g = r.left - n.width - s : g = 10;
1078
+ break;
1079
+ case "top-start":
1080
+ r.top - n.height - s < 0 ? p = r.top - n.height + s + o + l : p = r.top - n.height - s, r.left > 0 ? g = r.left : g = 10;
1081
+ break;
1082
+ case "bottom-right":
1083
+ w > P ? p = r.bottom + s : p = r.bottom - s - o - l, b - c > i ? g = r.left : g = b - 30 - i;
1084
+ break;
1085
+ case "bottom-left":
1086
+ w > P ? p = r.bottom + s : p = r.bottom - s - o - l, r.left > 0 ? g = r.right - i : g = 10;
1087
+ break;
1088
+ case "bottom-start":
1089
+ w > P ? p = r.bottom + s : p = r.bottom - s - o - l, r.left > 0 ? g = r.left : g = 10;
1090
+ break;
1091
+ }
1092
+ p + o > w ? p = w - o - s : p < 0 && (p = s), g + i > b ? g = b - i - s : g < 0 && (g = s), a instanceof HTMLElement && (a.style.top = `${p}px`, a.style.left = `${g}px`, a.style.position = "fixed");
1093
+ }, no = { class: "text-center" }, so = { class: "py-2 px-4 w-full text-sm text-stone-800 bg-white shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-lg focus:outline-none focus:bg-stone-100 dark:bg-neutral-900 dark:text-neutral-200 dark:focus:bg-neutral-800 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full" }, de = /* @__PURE__ */ Object.assign({
1094
+ inheritAttrs: !1
1095
+ }, {
1096
+ __name: "vs-popover",
1097
+ props: {
1098
+ isOpen: { type: Boolean, default: () => !1 },
1099
+ placement: { type: String, default: "top" },
1100
+ gap: { type: Number, default: 8 },
1101
+ width: { type: [String, Number], default: "" },
1102
+ disabled: { type: Boolean, default: !1 },
1103
+ trigger: { type: String, default: "click" },
1104
+ teleport: { type: String, default: "body" }
1105
+ },
1106
+ emits: ["isvisible"],
1107
+ setup(t, { expose: e, emit: a }) {
1108
+ const s = t, n = a, r = C(!1), l = C([]), c = C(null), o = C(null), i = C(null);
1109
+ we(r, (I) => {
1110
+ I ? (w(), window.addEventListener(
1111
+ "resize",
1112
+ () => me(s.placement, o.value, i.value)
1113
+ ), me(s.placement, o.value, i.value)) : window.removeEventListener(
1114
+ "resize",
1115
+ () => me(s.placement, o.value, i.value)
1116
+ ), n("isvisible", I);
1117
+ }), he(() => {
1118
+ window.addEventListener("click", z), window.addEventListener("popstate", U), window.addEventListener("scroll", Y, !0), w();
1119
+ }), Xe(() => {
1120
+ window.removeEventListener("click", z), window.removeEventListener("popstate", U), b();
1121
+ });
1122
+ const w = () => {
1123
+ let I = c.value;
1124
+ for (; I && I !== document.body; )
1125
+ (I.scrollHeight > I.clientHeight || I.scrollWidth > I.clientWidth) && (I.addEventListener("scroll", O), l.value.push(I)), I = I.parentElement;
1126
+ document.body && (document.body.addEventListener("scroll", O), l.value.push(document.body));
1127
+ }, b = () => {
1128
+ l.value.forEach((I) => {
1129
+ I.removeEventListener("scroll", O);
1130
+ }), l.value = [];
1131
+ }, p = () => {
1132
+ r.value = !0, me(s.placement, o.value, i.value);
1133
+ }, g = () => {
1134
+ r.value = !1;
1135
+ }, P = async () => {
1136
+ await me(s.placement, o.value, i.value), r.value = !r.value;
1137
+ }, O = () => {
1138
+ r.value = !1;
1139
+ }, z = (I) => {
1140
+ if (!I) {
1141
+ r.value = !1;
1142
+ return;
1143
+ }
1144
+ o.value?.contains(I.target) || i.value?.contains(I.target) || (r.value = !1);
1145
+ }, U = () => {
1146
+ r.value && (r.value = !1);
1147
+ }, Y = (I) => {
1148
+ r.value && i.value && !i.value.contains(I.target) && (r.value = !1);
1149
+ };
1150
+ return e({
1151
+ togglePopover: P
1152
+ }), (I, Q) => (v(), k("div", {
1153
+ ref_key: "popover",
1154
+ ref: c,
1155
+ class: "vs-popover inline-block"
1156
+ }, [
1157
+ d("div", no, [
1158
+ t.trigger === "click" ? (v(), k("div", {
1159
+ key: 0,
1160
+ ref_key: "popoverRef",
1161
+ ref: o,
1162
+ onClick: P,
1163
+ class: E({ "pointer-events-none": t.disabled })
1164
+ }, [
1165
+ be(I.$slots, "reference", {}, () => [
1166
+ Q[0] || (Q[0] = d("button", null, "Click me!", -1))
1167
+ ])
1168
+ ], 2)) : V("", !0),
1169
+ t.trigger === "hover" ? (v(), k("div", {
1170
+ key: 1,
1171
+ ref_key: "popoverRef",
1172
+ ref: o,
1173
+ onMouseover: p,
1174
+ onMouseleave: g,
1175
+ class: E({ "pointer-events-none": t.disabled })
1176
+ }, [
1177
+ be(I.$slots, "reference", {}, () => [
1178
+ Q[1] || (Q[1] = d("button", null, "Click me!", -1))
1179
+ ])
1180
+ ], 34)) : V("", !0),
1181
+ (v(), K(Ke, { to: t.teleport }, [
1182
+ F(We, { name: "fade" }, {
1183
+ default: R(() => [
1184
+ ce(d("div", {
1185
+ class: E(["vsTailwind vs-popover__content", t.placement]),
1186
+ ref_key: "contentPop",
1187
+ ref: i,
1188
+ style: le({
1189
+ width: t.width ? t.width + "px" : "fit-content",
1190
+ zIndex: 100001
1191
+ })
1192
+ }, [
1193
+ d("div", so, [
1194
+ be(I.$slots, "default", {}, () => [
1195
+ Q[2] || (Q[2] = d("span", null, "Popover content", -1))
1196
+ ])
1197
+ ])
1198
+ ], 6), [
1199
+ [ke, r.value]
1200
+ ])
1201
+ ]),
1202
+ _: 3
1203
+ })
1204
+ ], 8, ["to"]))
1205
+ ])
1206
+ ], 512));
1207
+ }
1208
+ }), io = { class: "flex flex-col gap-[2px] p-[2px]" }, co = ["onClick"], uo = {
1209
+ __name: "vs-editor-table",
1210
+ props: { editor: Object },
1211
+ setup(t) {
1212
+ const { t: e } = Me(), a = t, s = C(!1), n = C("popover"), r = () => {
1213
+ a.editor && (a.editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run(), n.value.togglePopover());
1214
+ }, l = () => {
1215
+ a.editor && (a.editor.chain().focus().addColumnAfter().run(), n.value.togglePopover());
1216
+ }, c = () => {
1217
+ a.editor && (a.editor.chain().focus().addRowAfter().run(), n.value.togglePopover());
1218
+ }, o = () => {
1219
+ a.editor && (a.editor.chain().focus().deleteColumn().run(), n.value.togglePopover());
1220
+ }, i = () => {
1221
+ a.editor && (a.editor.chain().focus().deleteRow().run(), n.value.togglePopover());
1222
+ }, w = () => {
1223
+ a.editor && (a.editor.chain().focus().deleteTable().run(), n.value.togglePopover());
1224
+ }, b = () => {
1225
+ a.editor && (a.editor.chain().focus().mergeCells().run(), n.value.togglePopover());
1226
+ }, p = () => {
1227
+ a.editor && (a.editor.chain().focus().splitCell().run(), n.value.togglePopover());
1228
+ }, g = H(() => [
1229
+ { text: e("form.richtext.createTable"), function: r },
1230
+ { text: e("form.richtext.addColumn"), function: l },
1231
+ { text: e("form.richtext.addRow"), function: c },
1232
+ { text: e("form.richtext.deleteColumn"), function: o },
1233
+ { text: e("form.richtext.deleteRow"), function: i },
1234
+ { text: e("form.richtext.deleteTable"), function: w },
1235
+ { text: e("form.richtext.mergeCells"), function: b },
1236
+ { text: e("form.richtext.splitCells"), function: p }
1237
+ ]);
1238
+ return (P, O) => (v(), K(de, {
1239
+ ref_key: "popover",
1240
+ ref: n,
1241
+ placement: "bottom",
1242
+ onIsvisible: O[0] || (O[0] = (z) => s.value = z)
1243
+ }, {
1244
+ reference: R(() => [
1245
+ d("button", {
1246
+ title: "Table",
1247
+ class: E(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100", [s.value ? "bg-gray-100 text-gray-900" : "text-gray-500"]])
1248
+ }, [
1249
+ F(L(Bt), { class: "h-4 w-4" })
1250
+ ], 2)
1251
+ ]),
1252
+ default: R(() => [
1253
+ d("div", io, [
1254
+ (v(!0), k(re, null, ne(g.value, (z, U) => (v(), k("button", {
1255
+ key: U,
1256
+ onClick: z?.function,
1257
+ class: "px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded"
1258
+ }, W(z.text), 9, co))), 128))
1259
+ ])
1260
+ ]),
1261
+ _: 1
1262
+ }, 512));
1263
+ }
1264
+ }, fo = { class: "flex gap-[4px] p-1" }, po = ["title", "onClick"], go = {
1265
+ __name: "vs-editor-align",
1266
+ props: { editor: Object },
1267
+ setup(t) {
1268
+ const e = t, a = {
1269
+ left: jt,
1270
+ center: Pt,
1271
+ right: It,
1272
+ justify: Et
1273
+ }, s = C(!1), n = C("popover"), r = C("left"), l = H(() => e.editor ? e.editor.isActive("paragraph", { textAlign: "left" }) || e.editor.isActive("heading", { textAlign: "left" }) : !1), c = H(() => e.editor ? e.editor.isActive("paragraph", { textAlign: "right" }) || e.editor.isActive("heading", { textAlign: "right" }) : !1), o = H(() => e.editor ? e.editor.isActive("paragraph", { textAlign: "center" }) || e.editor.isActive("heading", { textAlign: "center" }) : !1), i = H(() => e.editor ? e.editor.isActive("paragraph", { textAlign: "justify" }) || e.editor.isActive("heading", { textAlign: "justify" }) : !1), w = H(() => l.value || c.value || o.value || i.value), b = () => {
1274
+ c.value ? r.value = "right" : o.value ? r.value = "center" : i.value ? r.value = "justify" : r.value = "left";
1275
+ };
1276
+ we([l, c, o, i], () => {
1277
+ b();
1278
+ }, { immediate: !0 }), he(() => {
1279
+ e.editor && (e.editor.on("selectionUpdate", b), e.editor.on("update", b));
1280
+ }), Ae(() => {
1281
+ e.editor && (e.editor.off("selectionUpdate", b), e.editor.off("update", b));
1282
+ });
1283
+ const p = (P) => {
1284
+ e.editor && (e.editor.chain().focus().setTextAlign(P).run(), r.value = P);
1285
+ }, g = C([
1286
+ { id: "left", isActive: l },
1287
+ { id: "center", isActive: o },
1288
+ { id: "right", isActive: c },
1289
+ { id: "justify", isActive: i }
1290
+ ]);
1291
+ return (P, O) => (v(), K(de, {
1292
+ ref_key: "popover",
1293
+ ref: n,
1294
+ placement: "bottom",
1295
+ onIsvisible: O[0] || (O[0] = (z) => s.value = z)
1296
+ }, {
1297
+ reference: R(() => [
1298
+ d("button", {
1299
+ title: "Text Align",
1300
+ class: E(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100", [w.value ? "bg-gray-100 text-gray-900" : "text-gray-500"]])
1301
+ }, [
1302
+ (v(), K(Te(a[r.value]), {
1303
+ height: "16",
1304
+ width: "16"
1305
+ }))
1306
+ ], 2)
1307
+ ]),
1308
+ default: R(() => [
1309
+ d("div", fo, [
1310
+ (v(!0), k(re, null, ne(g.value, (z) => (v(), k("button", {
1311
+ title: "Text align " + z?.id,
1312
+ class: E(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": z?.isActive }]),
1313
+ key: z?.id,
1314
+ onClick: (U) => p(z?.id)
1315
+ }, [
1316
+ (v(), K(Te(a[z?.id]), {
1317
+ height: "16",
1318
+ width: "16"
1319
+ }))
1320
+ ], 10, po))), 128))
1321
+ ])
1322
+ ]),
1323
+ _: 1
1324
+ }, 512));
1325
+ }
1326
+ }, ho = {
1327
+ components: { VsText: tt },
1328
+ inheritAttrs: !1,
1329
+ events: ["update:modelValue"],
1330
+ props: {
1331
+ modelValue: { type: String },
1332
+ disabled: { type: Boolean, default: () => !1 },
1333
+ clearable: { type: Boolean, default: () => !1 },
1334
+ isTextInputShown: { type: Boolean, default: () => !0 }
1335
+ },
1336
+ computed: {
1337
+ value: {
1338
+ get() {
1339
+ return this.modelValue ?? "";
1340
+ },
1341
+ set(t) {
1342
+ this.$emit("update:modelValue", t);
1343
+ }
1344
+ }
1345
+ }
1346
+ }, vo = { class: "flex items-center w-full max-w-[182px]" }, mo = ["disabled"];
1347
+ function bo(t, e, a, s, n, r) {
1348
+ const l = G("vs-text");
1349
+ return v(), k("div", vo, [
1350
+ ce(d("input", {
1351
+ "onUpdate:modelValue": e[0] || (e[0] = (c) => r.value = c),
1352
+ type: "color",
1353
+ class: E(["w-[38px] h-[38px] min-h-[38px] min-w-[38px] py-[2px] px-[3px] -ml-1 dark:bg-neutral-800 border dark:border-neutral-700 border-stone-200 rounded-lg", a.disabled ? "cursor-not-allowed" : "cursor-pointer"]),
1354
+ disabled: a.disabled
1355
+ }, null, 10, mo), [
1356
+ [ct, r.value]
1357
+ ]),
1358
+ a.isTextInputShown ? (v(), K(l, {
1359
+ key: 0,
1360
+ modelValue: r.value,
1361
+ "onUpdate:modelValue": e[1] || (e[1] = (c) => r.value = c),
1362
+ class: "ml-2 w-full",
1363
+ disabled: a.disabled,
1364
+ clearable: a.clearable
1365
+ }, null, 8, ["modelValue", "disabled", "clearable"])) : V("", !0)
1366
+ ]);
1367
+ }
1368
+ const rt = /* @__PURE__ */ X(ho, [["render", bo]]), yo = { class: "flex gap-[4px] mb-[8px]" }, xo = { class: "grid grid-rows-3 grid-cols-7" }, wo = { class: "w-full h-full rounded border border-gray-300 overflow-hidden" }, ko = ["onClick", "title"], _o = {
1369
+ __name: "vs-editor-color",
1370
+ props: {
1371
+ editor: Object
1372
+ },
1373
+ setup(t) {
1374
+ const e = t, a = C(null), s = C("#000000"), n = H(() => e.editor && e.editor.getAttributes("textStyle").color || "#000000"), r = H(() => n.value !== "#000000"), l = () => {
1375
+ e.editor && (s.value = n.value);
1376
+ };
1377
+ he(() => {
1378
+ e.editor && (e.editor.on("selectionUpdate", l), e.editor.on("update", l), l());
1379
+ }), Ae(() => {
1380
+ e.editor && (e.editor.off("selectionUpdate", l), e.editor.off("update", l));
1381
+ });
1382
+ const c = C([
1383
+ "#172B4D",
1384
+ "#0747A6",
1385
+ "#008DA6",
1386
+ "#006644",
1387
+ "#FF991F",
1388
+ "#BF2600",
1389
+ "#403294",
1390
+ "#97A0AF",
1391
+ "#4C9AFF",
1392
+ "#00B8D9",
1393
+ "#36B37E",
1394
+ "#FFC400",
1395
+ "#FF5630",
1396
+ "#6554C0",
1397
+ "#FFFFFF",
1398
+ "#B3D4FF",
1399
+ "#B3F5FF",
1400
+ "#ABF5D1",
1401
+ "#FFF0B3",
1402
+ "#FFBDAD",
1403
+ "#EAE6FF"
1404
+ ]), o = (b) => {
1405
+ e.editor && (e.editor.chain().focus().setColor(b).run(), s.value = b, a.value && a.value.togglePopover());
1406
+ }, i = () => {
1407
+ o(s.value);
1408
+ }, w = (b) => ({
1409
+ "#172B4D": "Default",
1410
+ "#0747A6": "Bright blue",
1411
+ "#008DA6": "Bright blue-green",
1412
+ "#006644": "Bright green",
1413
+ "#FF991F": "Bright orange",
1414
+ "#BF2600": "Bright red",
1415
+ "#403294": "Bright purple",
1416
+ "#97A0AF": "Gray",
1417
+ "#4C9AFF": "Blue",
1418
+ "#00B8D9": "Blue-green",
1419
+ "#36B37E": "Green",
1420
+ "#FFC400": "Yellow",
1421
+ "#FF5630": "Red",
1422
+ "#6554C0": "Purple",
1423
+ "#FFFFFF": "White",
1424
+ "#B3D4FF": "Bright blue",
1425
+ "#B3F5FF": "Bright blue-green",
1426
+ "#ABF5D1": "Bright green",
1427
+ "#FFF0B3": "Bright yellow",
1428
+ "#FFBDAD": "Bright red",
1429
+ "#EAE6FF": "Bright purple"
1430
+ })[b] || b;
1431
+ return (b, p) => (v(), K(de, {
1432
+ ref_key: "popover",
1433
+ ref: a,
1434
+ placement: "bottom"
1435
+ }, {
1436
+ reference: R(() => [
1437
+ d("button", {
1438
+ title: "Text Color",
1439
+ class: E(["flex flex-col h-[30px] min-w-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex", { "bg-gray-100": r.value }])
1440
+ }, [
1441
+ p[1] || (p[1] = d("span", { class: "leading-none" }, "A", -1)),
1442
+ d("span", {
1443
+ class: "block h-1 w-5",
1444
+ style: le({ backgroundColor: s.value })
1445
+ }, null, 4)
1446
+ ], 2)
1447
+ ]),
1448
+ default: R(() => [
1449
+ d("div", null, [
1450
+ d("div", yo, [
1451
+ F(rt, {
1452
+ modelValue: s.value,
1453
+ "onUpdate:modelValue": p[0] || (p[0] = (g) => s.value = g)
1454
+ }, null, 8, ["modelValue"]),
1455
+ d("button", {
1456
+ onClick: i,
1457
+ class: "h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"
1458
+ }, [
1459
+ F(L(ye), { class: "h-4 w-4 text-white" })
1460
+ ])
1461
+ ]),
1462
+ d("div", xo, [
1463
+ (v(!0), k(re, null, ne(c.value, (g) => (v(), k("div", {
1464
+ key: g,
1465
+ class: "h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"
1466
+ }, [
1467
+ d("div", wo, [
1468
+ d("button", {
1469
+ class: "flex items-center justify-center w-full h-full",
1470
+ style: le({ backgroundColor: g }),
1471
+ onClick: (P) => o(g),
1472
+ title: w(g)
1473
+ }, [
1474
+ s.value === g ? (v(), K(L(ye), {
1475
+ key: 0,
1476
+ class: "h-4 w-4 text-gray-500"
1477
+ })) : V("", !0)
1478
+ ], 12, ko)
1479
+ ])
1480
+ ]))), 128))
1481
+ ])
1482
+ ])
1483
+ ]),
1484
+ _: 1
1485
+ }, 512));
1486
+ }
1487
+ }, $o = { class: "flex gap-[4px] mb-[8px]" }, Co = { class: "grid grid-rows-3 grid-cols-7" }, Ao = { class: "w-full h-full rounded border border-gray-300 overflow-hidden" }, Fo = ["onClick", "title"], So = ["onClick", "title"], To = {
1488
+ __name: "vs-editor-background-color",
1489
+ props: {
1490
+ editor: Object
1491
+ },
1492
+ setup(t) {
1493
+ const e = t, a = C(null), s = C("transparent"), n = H(() => e.editor && e.editor.getAttributes("textStyle").backgroundColor || "transparent"), r = H(() => n.value !== "transparent" && n.value !== ""), l = () => {
1494
+ e.editor && (s.value = n.value);
1495
+ };
1496
+ he(() => {
1497
+ e.editor && (e.editor.on("selectionUpdate", l), e.editor.on("update", l), l());
1498
+ }), Ae(() => {
1499
+ e.editor && (e.editor.off("selectionUpdate", l), e.editor.off("update", l));
1500
+ });
1501
+ const c = C([
1502
+ "#172B4D",
1503
+ "#0747A6",
1504
+ "#008DA6",
1505
+ "#006644",
1506
+ "#FF991F",
1507
+ "#BF2600",
1508
+ "#403294",
1509
+ "#97A0AF",
1510
+ "#4C9AFF",
1511
+ "#00B8D9",
1512
+ "#36B37E",
1513
+ "#FFC400",
1514
+ "#FF5630",
1515
+ "#6554C0",
1516
+ "#FFFFFF",
1517
+ "#B3D4FF",
1518
+ "#B3F5FF",
1519
+ "#ABF5D1",
1520
+ "#FFF0B3",
1521
+ "#FFBDAD",
1522
+ "#EAE6FF"
1523
+ ]), o = (b) => {
1524
+ e.editor && (e.editor.chain().focus().setBackgroundColor(b).run(), s.value = b, a.value && a.value.togglePopover());
1525
+ }, i = () => {
1526
+ o(s.value);
1527
+ }, w = (b) => ({
1528
+ "#172B4D": "Default",
1529
+ "#0747A6": "Bright blue",
1530
+ "#008DA6": "Bright blue-green",
1531
+ "#006644": "Bright green",
1532
+ "#FF991F": "Bright orange",
1533
+ "#BF2600": "Bright red",
1534
+ "#403294": "Bright purple",
1535
+ "#97A0AF": "Gray",
1536
+ "#4C9AFF": "Blue",
1537
+ "#00B8D9": "Blue-green",
1538
+ "#36B37E": "Green",
1539
+ "#FFC400": "Yellow",
1540
+ "#FF5630": "Red",
1541
+ "#6554C0": "Purple",
1542
+ transparent: "Transparent",
1543
+ "#B3D4FF": "Bright blue",
1544
+ "#B3F5FF": "Bright blue-green",
1545
+ "#ABF5D1": "Bright green",
1546
+ "#FFF0B3": "Bright yellow",
1547
+ "#FFBDAD": "Bright red",
1548
+ "#EAE6FF": "Bright purple"
1549
+ })[b] || b;
1550
+ return (b, p) => (v(), K(de, {
1551
+ ref_key: "popover",
1552
+ ref: a,
1553
+ placement: "bottom"
1554
+ }, {
1555
+ reference: R(() => [
1556
+ d("button", {
1557
+ title: "Background Color",
1558
+ class: E(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex", { "bg-gray-100": r.value }])
1559
+ }, [
1560
+ F(L(Ht), { class: "h-4 w-4" }),
1561
+ d("span", {
1562
+ class: "block h-1 w-5",
1563
+ style: le({ backgroundColor: s.value })
1564
+ }, null, 4)
1565
+ ], 2)
1566
+ ]),
1567
+ default: R(() => [
1568
+ d("div", null, [
1569
+ d("div", $o, [
1570
+ F(rt, {
1571
+ modelValue: s.value,
1572
+ "onUpdate:modelValue": p[0] || (p[0] = (g) => s.value = g)
1573
+ }, null, 8, ["modelValue"]),
1574
+ d("button", {
1575
+ onClick: i,
1576
+ class: "h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"
1577
+ }, [
1578
+ F(L(ye), { class: "h-4 w-4 text-white" })
1579
+ ])
1580
+ ]),
1581
+ d("div", Co, [
1582
+ d("button", {
1583
+ onClick: p[1] || (p[1] = (g) => o("transparent")),
1584
+ class: "col-span-7 flex items-center justify-center gap-2 bg-gray-100 rounded-md py-1 mb-2 hover:bg-gray-200"
1585
+ }, [
1586
+ F(L(Mt), { class: "h-4 w-4" }),
1587
+ p[2] || (p[2] = d("p", null, "no color", -1))
1588
+ ]),
1589
+ (v(!0), k(re, null, ne(c.value, (g) => (v(), k("div", {
1590
+ key: g,
1591
+ class: "h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"
1592
+ }, [
1593
+ d("div", Ao, [
1594
+ g !== "transparent" ? (v(), k("button", {
1595
+ key: 0,
1596
+ class: "flex items-center justify-center w-full h-full",
1597
+ style: le({ backgroundColor: g }),
1598
+ onClick: (P) => o(g),
1599
+ title: w(g)
1600
+ }, [
1601
+ s.value === g ? (v(), K(L(ye), {
1602
+ key: 0,
1603
+ class: "h-4 w-4 text-gray-500"
1604
+ })) : V("", !0)
1605
+ ], 12, Fo)) : V("", !0),
1606
+ g === "transparent" ? (v(), k("button", {
1607
+ key: 1,
1608
+ class: "flex items-center justify-center w-full h-full",
1609
+ onClick: (P) => o(g),
1610
+ title: w(g)
1611
+ }, [
1612
+ s.value === g ? (v(), K(L(ye), {
1613
+ key: 0,
1614
+ class: "h-4 w-4 text-gray-500"
1615
+ })) : V("", !0)
1616
+ ], 8, So)) : V("", !0)
1617
+ ])
1618
+ ]))), 128))
1619
+ ])
1620
+ ])
1621
+ ]),
1622
+ _: 1
1623
+ }, 512));
1624
+ }
1625
+ }, Lo = {
1626
+ __name: "vs-editor-highlight",
1627
+ props: {
1628
+ editor: Object
1629
+ },
1630
+ setup(t) {
1631
+ const e = t, a = H(() => e.editor?.isActive("highlight")), s = () => {
1632
+ e.editor && e.editor.chain().focus().toggleHighlight().run();
1633
+ };
1634
+ return (n, r) => (v(), k("button", {
1635
+ title: "Highlight",
1636
+ onClick: s,
1637
+ class: E(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex", { "bg-gray-200": a.value }])
1638
+ }, [
1639
+ F(L(Nt), { class: "h-4 w-4" })
1640
+ ], 2));
1641
+ }
1642
+ }, Bo = { class: "truncate" }, Eo = { class: "w-[200px]" }, Io = { class: "max-h-[200px] overflow-y-auto" }, Po = ["onClick"], jo = {
1643
+ __name: "vs-editor-font-family",
1644
+ props: {
1645
+ editor: Object
1646
+ },
1647
+ setup(t) {
1648
+ const e = t, a = C("popover"), s = C(!1), n = C([
1649
+ { label: "Arial", value: "Arial, sans-serif" },
1650
+ { label: "Helvetica", value: "Helvetica, sans-serif" },
1651
+ { label: "Times New Roman", value: "Times New Roman, serif" },
1652
+ { label: "Georgia", value: "Georgia, serif" },
1653
+ { label: "Verdana", value: "Verdana, sans-serif" },
1654
+ { label: "Courier New", value: "Courier New, monospace" },
1655
+ { label: "Comic Sans MS", value: "Comic Sans MS, cursive" },
1656
+ { label: "Impact", value: "Impact, sans-serif" },
1657
+ { label: "Trebuchet MS", value: "Trebuchet MS, sans-serif" },
1658
+ { label: "Palatino", value: "Palatino, serif" }
1659
+ ]), r = H(() => {
1660
+ if (!e.editor) return "Arial, sans-serif";
1661
+ for (const i of n.value)
1662
+ if (e.editor.isActive("textStyle", { fontFamily: i.value }))
1663
+ return i.value;
1664
+ return "Arial, sans-serif";
1665
+ }), l = H(() => n.value.find((w) => w.value === r.value)?.label || "Arial"), c = (i) => e.editor ? e.editor.isActive("textStyle", { fontFamily: i }) : !1, o = (i) => {
1666
+ e.editor && (e.editor.chain().focus().setFontFamily(i).run(), a.value && a.value.togglePopover());
1667
+ };
1668
+ return (i, w) => (v(), K(de, {
1669
+ ref_key: "popover",
1670
+ ref: a,
1671
+ placement: "bottom",
1672
+ onIsvisible: w[0] || (w[0] = (b) => s.value = b)
1673
+ }, {
1674
+ reference: R(() => [
1675
+ d("button", {
1676
+ title: "Font Family",
1677
+ class: E(["h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm", [s.value ? "bg-gray-100 text-gray-900" : "text-gray-700"]]),
1678
+ style: le({ fontFamily: r.value })
1679
+ }, [
1680
+ d("span", Bo, W(l.value), 1),
1681
+ F(L(Ee), { class: "ml-1 h-3 w-3 text-gray-400" })
1682
+ ], 6)
1683
+ ]),
1684
+ default: R(() => [
1685
+ d("div", Eo, [
1686
+ d("ul", Io, [
1687
+ (v(!0), k(re, null, ne(n.value, (b) => (v(), k("li", {
1688
+ key: b.value,
1689
+ class: E(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm", { "bg-gray-100": c(b.value) }]),
1690
+ style: le({ fontFamily: b.value }),
1691
+ onClick: (p) => o(b.value)
1692
+ }, W(b.label), 15, Po))), 128))
1693
+ ])
1694
+ ])
1695
+ ]),
1696
+ _: 1
1697
+ }, 512));
1698
+ }
1699
+ }, Mo = { class: "w-[120px]" }, Ho = { class: "max-h-[200px] overflow-y-auto" }, No = ["onClick"], zo = {
1700
+ __name: "vs-editor-font-size",
1701
+ props: {
1702
+ editor: Object
1703
+ },
1704
+ setup(t) {
1705
+ const e = t, a = C("popover"), s = C("14px"), n = H(() => e.editor && e.editor.getAttributes("textStyle").fontSize || "14px"), r = H(() => n.value !== "14px"), l = () => {
1706
+ e.editor && (s.value = n.value);
1707
+ };
1708
+ he(() => {
1709
+ e.editor && (e.editor.on("selectionUpdate", l), e.editor.on("update", l), l());
1710
+ }), Ae(() => {
1711
+ e.editor && (e.editor.off("selectionUpdate", l), e.editor.off("update", l));
1712
+ });
1713
+ const c = C([
1714
+ { label: "8px", value: "8px" },
1715
+ { label: "9px", value: "9px" },
1716
+ { label: "10px", value: "10px" },
1717
+ { label: "11px", value: "11px" },
1718
+ { label: "12px", value: "12px" },
1719
+ { label: "14px", value: "14px" },
1720
+ { label: "16px", value: "16px" },
1721
+ { label: "18px", value: "18px" },
1722
+ { label: "20px", value: "20px" },
1723
+ { label: "24px", value: "24px" },
1724
+ { label: "28px", value: "28px" },
1725
+ { label: "32px", value: "32px" },
1726
+ { label: "36px", value: "36px" },
1727
+ { label: "48px", value: "48px" },
1728
+ { label: "72px", value: "72px" }
1729
+ ]), o = (i) => {
1730
+ e.editor && (e.editor.chain().focus().setFontSize(i).run(), s.value = i, a.value && a.value.togglePopover());
1731
+ };
1732
+ return (i, w) => (v(), K(de, {
1733
+ ref_key: "popover",
1734
+ ref: a,
1735
+ placement: "bottom"
1736
+ }, {
1737
+ reference: R(() => [
1738
+ d("button", {
1739
+ title: "Font Size",
1740
+ class: E(["h-[30px] px-2 min-w-[30px] rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700 space-x-1", { "bg-gray-100 text-gray-900": r.value }])
1741
+ }, [
1742
+ F(L(zt), { class: "h-4 w-4" }),
1743
+ F(L(Ee), { class: "h-3 w-3 text-gray-400" })
1744
+ ], 2)
1745
+ ]),
1746
+ default: R(() => [
1747
+ d("div", Mo, [
1748
+ d("ul", Ho, [
1749
+ (v(!0), k(re, null, ne(c.value, (b) => (v(), k("li", {
1750
+ key: b.value,
1751
+ class: "px-3 py-2 hover:bg-gray-100 cursor-pointer",
1752
+ onClick: (p) => o(b.value)
1753
+ }, W(b.label), 9, No))), 128))
1754
+ ])
1755
+ ])
1756
+ ]),
1757
+ _: 1
1758
+ }, 512));
1759
+ }
1760
+ }, Do = {
1761
+ components: { Superscript: Dt },
1762
+ props: {
1763
+ editor: Object
1764
+ },
1765
+ methods: {
1766
+ toggleSuperscript() {
1767
+ this.editor && this.editor.commands.toggleSuperscript();
1768
+ }
1769
+ }
1770
+ };
1771
+ function Oo(t, e, a, s, n, r) {
1772
+ const l = G("Superscript");
1773
+ return v(), k("button", {
1774
+ title: "Superscript",
1775
+ onClick: e[0] || (e[0] = (...c) => r.toggleSuperscript && r.toggleSuperscript(...c)),
1776
+ class: E(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": a.editor?.isActive("superscript") }])
1777
+ }, [
1778
+ F(l, { class: "h-4 w-4" }),
1779
+ e[1] || (e[1] = d("span", { class: "sr-only" }, "Superscript", -1))
1780
+ ], 2);
1781
+ }
1782
+ const Vo = /* @__PURE__ */ X(Do, [["render", Oo]]), Ro = {
1783
+ components: { Subscript: Ot },
1784
+ props: {
1785
+ editor: Object
1786
+ },
1787
+ methods: {
1788
+ toggleSubscript() {
1789
+ this.editor && this.editor.commands.toggleSubscript();
1790
+ }
1791
+ }
1792
+ };
1793
+ function Uo(t, e, a, s, n, r) {
1794
+ const l = G("Subscript");
1795
+ return v(), k("button", {
1796
+ title: "Subscript",
1797
+ onClick: e[0] || (e[0] = (...c) => r.toggleSubscript && r.toggleSubscript(...c)),
1798
+ class: E(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100", { "bg-gray-100 text-gray-900": a.editor?.isActive("subscript") }])
1799
+ }, [
1800
+ F(l, { class: "h-4 w-4" }),
1801
+ e[1] || (e[1] = d("span", { class: "sr-only" }, "Subscript", -1))
1802
+ ], 2);
1803
+ }
1804
+ const qo = /* @__PURE__ */ X(Ro, [["render", Uo]]), Ko = {
1805
+ title: "Heading",
1806
+ class: "h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700"
1807
+ }, Wo = { class: "truncate" }, Xo = { class: "max-h-[200px] overflow-y-auto" }, Go = ["onClick"], Yo = {
1808
+ __name: "vs-editor-heading",
1809
+ props: {
1810
+ editor: Object
1811
+ },
1812
+ setup(t) {
1813
+ const e = t, a = C("popover"), s = C([
1814
+ { label: "Heading 1", value: 1 },
1815
+ { label: "Heading 2", value: 2 },
1816
+ { label: "Heading 3", value: 3 },
1817
+ { label: "Heading 4", value: 4 },
1818
+ { label: "Heading 5", value: 5 },
1819
+ { label: "Heading 6", value: 6 }
1820
+ ]), n = H(() => {
1821
+ if (!e.editor) return "Paragraph";
1822
+ for (let o = 1; o <= 6; o++)
1823
+ if (e.editor.isActive("heading", { level: o }))
1824
+ return `H ${o}`;
1825
+ return "P";
1826
+ }), r = (o) => ({
1827
+ 1: "font-weight:700; font-size:30px;",
1828
+ 2: "font-weight:700; font-size:26px;",
1829
+ 3: "font-weight:700; font-size:22px;",
1830
+ 4: "font-weight:700; font-size:18px;",
1831
+ 5: "font-weight:500; font-size:16px;",
1832
+ 6: "font-weight:400; font-size:14px;"
1833
+ })[o] || "", l = (o) => {
1834
+ e.editor && (e.editor.chain().focus().setHeading({ level: o }).run(), a.value && a.value.togglePopover());
1835
+ }, c = () => {
1836
+ e.editor && (e.editor.chain().focus().setParagraph().run(), a.value && a.value.togglePopover());
1837
+ };
1838
+ return (o, i) => (v(), K(de, {
1839
+ ref_key: "popover",
1840
+ ref: a,
1841
+ placement: "bottom"
1842
+ }, {
1843
+ reference: R(() => [
1844
+ d("button", Ko, [
1845
+ d("span", Wo, W(n.value), 1),
1846
+ F(L(Ee), { class: "ml-1 h-3 w-3 text-gray-400" })
1847
+ ])
1848
+ ]),
1849
+ default: R(() => [
1850
+ d("div", null, [
1851
+ d("ul", Xo, [
1852
+ (v(!0), k(re, null, ne(s.value, (w) => (v(), k("li", {
1853
+ key: w.value,
1854
+ class: E(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm", `heading-level-${w.value}`]),
1855
+ style: le(r(w.value)),
1856
+ onClick: (b) => l(w.value)
1857
+ }, W(w.label), 15, Go))), 128)),
1858
+ d("li", {
1859
+ class: "px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm border-t border-gray-200 mt-1 pt-2",
1860
+ onClick: c
1861
+ }, " Paragraph ")
1862
+ ])
1863
+ ])
1864
+ ]),
1865
+ _: 1
1866
+ }, 512));
1867
+ }
1868
+ }, Qo = /* @__PURE__ */ X(Yo, [["__scopeId", "data-v-46380488"]]), Zo = {
1869
+ components: { RemoveFormatting: Vt },
1870
+ props: {
1871
+ editor: Object
1872
+ },
1873
+ methods: {
1874
+ clearFormatting() {
1875
+ this.editor && this.editor.commands.unsetAllMarks();
1876
+ }
1877
+ }
1878
+ };
1879
+ function Jo(t, e, a, s, n, r) {
1880
+ const l = G("RemoveFormatting");
1881
+ return v(), k("button", {
1882
+ title: "Clear Formatting",
1883
+ onClick: e[0] || (e[0] = (...c) => r.clearFormatting && r.clearFormatting(...c)),
1884
+ class: "h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100"
1885
+ }, [
1886
+ F(l, { class: "h-4 w-4" }),
1887
+ e[1] || (e[1] = d("span", { class: "sr-only" }, "Clear Formatting", -1))
1888
+ ]);
1889
+ }
1890
+ const el = /* @__PURE__ */ X(Zo, [["render", Jo]]), tl = { class: "relative" }, rl = {
1891
+ key: 0,
1892
+ class: "mt-4"
1893
+ }, ol = ["src", "alt", "title"], ll = {
1894
+ key: 0,
1895
+ class: "text-sm text-red-500"
1896
+ }, al = {
1897
+ key: 1,
1898
+ class: "mt-4"
1899
+ }, nl = { class: "text-sm text-gray-600 mb-2" }, sl = { class: "flex flex-wrap gap-2" }, il = ["src", "alt", "onError"], cl = ["onClick"], dl = { class: "flex justify-end gap-x-2 p-[20px]" }, ul = /* @__PURE__ */ Object.assign({
1900
+ inheritAttrs: !1
1901
+ }, {
1902
+ __name: "vs-editor-image",
1903
+ props: {
1904
+ editor: {
1905
+ type: Object,
1906
+ required: !0
1907
+ }
1908
+ },
1909
+ setup(t) {
1910
+ const e = t, a = C(!1), s = C(!1), n = C({}), r = C(!1), l = C([]), c = C(null), o = C({
1911
+ src: "",
1912
+ file: [],
1913
+ // Завжди масив
1914
+ alt: "",
1915
+ title: "",
1916
+ width: "",
1917
+ height: "",
1918
+ link: "",
1919
+ openInNewTab: !1
1920
+ }), i = H(() => {
1921
+ if (Array.isArray(o.value.file)) {
1922
+ const m = o.value.file.filter(($) => $ instanceof File), _ = o.value.file.filter(($) => typeof $ == "string" && $.trim() !== "");
1923
+ return m.length + _.length > 1;
1924
+ }
1925
+ return o.value.file instanceof FileList ? o.value.file.length > 1 : !1;
1926
+ }), w = H(() => Array.isArray(o.value.file) ? o.value.file.filter((m) => m instanceof File).length === 1 : o.value.file instanceof FileList ? o.value.file.length === 1 : o.value.file instanceof File), b = H(() => {
1927
+ if (i.value)
1928
+ return "";
1929
+ if (o.value.src)
1930
+ return o.value.src;
1931
+ if (w.value) {
1932
+ let m = null;
1933
+ if (Array.isArray(o.value.file) || o.value.file instanceof FileList ? m = o.value.file[0] : o.value.file instanceof File && (m = o.value.file), m instanceof File) {
1934
+ const _ = l.value.find((f) => f.file === m);
1935
+ return _ ? _.preview : "";
1936
+ } else if (typeof m == "string")
1937
+ return m;
1938
+ }
1939
+ return "";
1940
+ }), p = H(() => [
1941
+ {
1942
+ name: "src",
1943
+ label: "URL зображення",
1944
+ type: "text",
1945
+ required: !1,
1946
+ placeholder: "https://example.com/image.png"
1947
+ },
1948
+ {
1949
+ name: "file",
1950
+ label: "Файл (можна вибрати кілька)",
1951
+ type: "file",
1952
+ multiple: !0,
1953
+ required: !1,
1954
+ placeholder: "Шлях до файлу зображення",
1955
+ accept: "image/*"
1956
+ },
1957
+ {
1958
+ name: "width",
1959
+ label: "Ширина",
1960
+ type: "number",
1961
+ required: !1,
1962
+ placeholder: "Ширина зображення",
1963
+ clearable: !0,
1964
+ min: 0
1965
+ },
1966
+ {
1967
+ name: "height",
1968
+ label: "Висота",
1969
+ type: "number",
1970
+ required: !1,
1971
+ placeholder: "Висота зображення",
1972
+ clearable: !0,
1973
+ min: 0
1974
+ },
1975
+ {
1976
+ name: "alt",
1977
+ label: "Альтернативний текст",
1978
+ type: "text",
1979
+ required: !1,
1980
+ placeholder: "Опис зображення"
1981
+ },
1982
+ {
1983
+ name: "title",
1984
+ label: "Заголовок (необов'язково)",
1985
+ type: "text",
1986
+ required: !1,
1987
+ placeholder: "Заголовок зображення"
1988
+ },
1989
+ {
1990
+ name: "link",
1991
+ label: "Посилання",
1992
+ type: "text",
1993
+ required: !1,
1994
+ placeholder: "https://example.com"
1995
+ },
1996
+ {
1997
+ name: "openInNewTab",
1998
+ label: "Відкривати у новій вкладці?",
1999
+ type: "switcher",
2000
+ required: !1
2001
+ }
2002
+ ]), g = () => {
2003
+ if (!e.editor) return;
2004
+ if (e.editor.isActive("image")) {
2005
+ const { state: _ } = e.editor, { selection: f } = _, { $from: $ } = f;
2006
+ let y = null, B = null;
2007
+ if ($.parent.type.name === "image")
2008
+ y = $.before($.depth), B = $.parent;
2009
+ else
2010
+ for (let x = $.depth; x > 0; x--) {
2011
+ const A = $.node(x), T = $.before(x);
2012
+ A.type.name === "paragraph" && A.forEach((D, se) => {
2013
+ if (D.type.name === "image") {
2014
+ const ae = T + se + 1;
2015
+ (y === null || Math.abs(ae - f.$from.pos) < Math.abs(y - f.$from.pos)) && (y = ae, B = D);
2016
+ }
2017
+ });
2018
+ }
2019
+ if (y !== null && B) {
2020
+ try {
2021
+ e.editor.chain().focus().setNodeSelection(y).run();
2022
+ } catch {
2023
+ e.editor.chain().focus().setTextSelection(y).run();
2024
+ }
2025
+ c.value = y;
2026
+ } else {
2027
+ e.editor.chain().focus().selectParentNode().run();
2028
+ const { state: x } = e.editor;
2029
+ c.value = x.selection.$from.pos;
2030
+ }
2031
+ const h = B ? B.attrs : e.editor.getAttributes("image");
2032
+ r.value = !0;
2033
+ let S = "", M = !1;
2034
+ const N = e.editor.getAttributes("link");
2035
+ N && N.href && (S = N.href, M = N.target === "_blank");
2036
+ const j = h.src || "", u = j ? [j] : [];
2037
+ o.value = {
2038
+ src: j,
2039
+ file: u,
2040
+ // Масив з поточним зображенням
2041
+ alt: h.alt || "",
2042
+ title: h.title || "",
2043
+ width: h.width || "",
2044
+ height: h.height || "",
2045
+ link: S,
2046
+ openInNewTab: M
2047
+ };
2048
+ } else
2049
+ r.value = !1, o.value = {
2050
+ src: "",
2051
+ file: [],
2052
+ // Завжди масив
2053
+ alt: "",
2054
+ title: "",
2055
+ width: "",
2056
+ height: "",
2057
+ link: "",
2058
+ openInNewTab: !1
2059
+ };
2060
+ s.value = !1, a.value = !0;
2061
+ }, P = () => {
2062
+ a.value = !1, s.value = !1, r.value = !1, l.value = [], c.value = null, o.value = {
2063
+ src: "",
2064
+ file: [],
2065
+ // Завжди масив
2066
+ alt: "",
2067
+ title: "",
2068
+ width: "",
2069
+ height: "",
2070
+ link: "",
2071
+ openInNewTab: !1
2072
+ };
2073
+ }, O = async (m) => {
2074
+ if (!m || m.length === 0)
2075
+ return;
2076
+ const _ = [];
2077
+ for (const f of m)
2078
+ if (f && f.type && f.type.startsWith("image/") && !l.value.some((y) => y.file === f)) {
2079
+ const y = new Promise((B, h) => {
2080
+ const S = new FileReader();
2081
+ S.onload = (M) => {
2082
+ l.value.push({
2083
+ file: f,
2084
+ preview: M.target.result,
2085
+ error: !1
2086
+ }), B();
2087
+ }, S.onerror = h, S.readAsDataURL(f);
2088
+ });
2089
+ _.push(y);
2090
+ }
2091
+ await Promise.all(_);
2092
+ }, z = (m) => {
2093
+ l.value.splice(m, 1), Array.isArray(o.value.file) && o.value.file.splice(m, 1);
2094
+ }, U = () => {
2095
+ const m = o.value.width !== null && o.value.width !== void 0 && o.value.width !== "" && String(o.value.width).trim() !== "" ? String(o.value.width).trim() : "", _ = o.value.height !== null && o.value.height !== void 0 && o.value.height !== "" && String(o.value.height).trim() !== "" ? String(o.value.height).trim() : "", f = {};
2096
+ return m && _ ? (f.width = m, f.height = _, f.style = `width: ${m}px; height: ${_}px; object-fit: fill;`) : m ? (f.width = m, f.height = void 0) : _ ? (f.height = _, f.width = void 0) : (f.width = void 0, f.height = void 0), f;
2097
+ }, Y = (m, _ = null, f = 50) => {
2098
+ const $ = () => {
2099
+ const { view: h } = m;
2100
+ if (!h || !h.dom) return;
2101
+ h.dom.querySelectorAll("img.editor-image[width][height]").forEach((N) => {
2102
+ if (N instanceof HTMLImageElement) {
2103
+ const j = N.getAttribute("width"), u = N.getAttribute("height");
2104
+ j && u && j !== "auto" && u !== "auto" && j !== "" && u !== "" && !isNaN(Number(j)) && !isNaN(Number(u)) && (N.style.cssText = `
2105
+ width: ${j}px !important;
2106
+ height: ${u}px !important;
2107
+ max-width: none !important;
2108
+ max-height: none !important;
2109
+ min-width: auto !important;
2110
+ min-height: auto !important;
2111
+ object-fit: fill !important;
2112
+ `.replace(/\s+/g, " ").trim());
2113
+ }
2114
+ });
2115
+ }, y = o.value.width, B = o.value.height;
2116
+ y && B && y !== "" && B !== "" ? [0, f, f * 2, f * 3, f * 4].forEach((S) => {
2117
+ setTimeout($, S);
2118
+ }) : ($(), setTimeout($, f));
2119
+ }, I = async () => {
2120
+ let m = [], _ = [];
2121
+ if (Array.isArray(o.value.file) ? (m = o.value.file.filter((h) => h instanceof File), _ = o.value.file.filter((h) => typeof h == "string" && h.trim() !== "")) : o.value.file instanceof FileList ? m = Array.from(o.value.file) : o.value.file instanceof File ? m = [o.value.file] : typeof o.value.file == "string" && o.value.file.trim() !== "" && (_ = [o.value.file]), m.length === 0 && _.length === 0 && n.value && n.value.file) {
2122
+ const h = n.value.file;
2123
+ Array.isArray(h) ? (m = h.filter((S) => S instanceof File), _ = h.filter((S) => typeof S == "string" && S.trim() !== "")) : h instanceof FileList ? m = Array.from(h) : h instanceof File ? m = [h] : typeof h == "string" && h.trim() !== "" && (_ = [h]);
2124
+ }
2125
+ if (_.length > 0 && !r.value) {
2126
+ for (const h of _)
2127
+ l.value.some((S) => S.url === h) || l.value.push({
2128
+ url: h,
2129
+ preview: h,
2130
+ error: !1
2131
+ });
2132
+ if (m.length === 0 && l.value.length > 0) {
2133
+ await oe();
2134
+ return;
2135
+ }
2136
+ }
2137
+ const f = m.length, $ = f + _.length;
2138
+ if (!(r.value && f <= 1)) {
2139
+ if (f > 0) {
2140
+ const h = m.filter(
2141
+ (S) => !l.value.some((M) => M.file === S)
2142
+ );
2143
+ h.length > 0 && await O(h);
2144
+ }
2145
+ }
2146
+ if (!r.value) {
2147
+ if ($ > 1 || i.value || l.value.length > 1) {
2148
+ if (l.value.length > 0) {
2149
+ await oe();
2150
+ return;
2151
+ } else if (f > 0) {
2152
+ if (await O(m), l.value.length > 0) {
2153
+ await oe();
2154
+ return;
2155
+ }
2156
+ } else if (_.length > 0) {
2157
+ await oe();
2158
+ return;
2159
+ }
2160
+ } else if (l.value.length > 1) {
2161
+ await oe();
2162
+ return;
2163
+ }
2164
+ }
2165
+ let y = o.value.src;
2166
+ if (w.value) {
2167
+ let h = null;
2168
+ if (Array.isArray(o.value.file) || o.value.file instanceof FileList ? h = o.value.file[0] : (o.value.file instanceof File || typeof o.value.file == "string") && (h = o.value.file), h instanceof File)
2169
+ try {
2170
+ const S = new FileReader(), M = await new Promise((N, j) => {
2171
+ S.onload = (u) => N(u.target.result), S.onerror = j, S.readAsDataURL(h);
2172
+ });
2173
+ y = M, r.value && (o.value.src = M);
2174
+ } catch (S) {
2175
+ console.error("Помилка при читанні файлу:", S), Ce({
2176
+ type: "error",
2177
+ title: "Помилка",
2178
+ message: "Не вдалося прочитати файл"
2179
+ });
2180
+ return;
2181
+ }
2182
+ else typeof h == "string" && h.trim() !== "" && (y = h.trim(), r.value && h.trim() !== o.value.src && (o.value.src = h.trim(), y = h.trim()));
2183
+ } else if (Array.isArray(o.value.file) && o.value.file.length === 1) {
2184
+ const h = o.value.file[0];
2185
+ typeof h == "string" && h.trim() !== "" && (y = h.trim(), (!o.value.src || o.value.src !== h.trim()) && (o.value.src = h.trim()));
2186
+ } else typeof o.value.file == "string" && o.value.file.trim() !== "" && (y = o.value.file.trim(), (!o.value.src || o.value.src !== o.value.file.trim()) && (o.value.src = o.value.file.trim()));
2187
+ const B = y || Array.isArray(o.value.file) && o.value.file.length > 0 && (o.value.file.some((h) => h instanceof File) || o.value.file.some((h) => typeof h == "string" && h.trim() !== "")) || o.value.file instanceof FileList && o.value.file.length > 0 || typeof o.value.file == "string" && o.value.file.trim() !== "";
2188
+ if (!y && !B) {
2189
+ Ce({
2190
+ type: "warning",
2191
+ title: "Попередження",
2192
+ message: "Будь ласка, введіть URL зображення або виберіть файл"
2193
+ });
2194
+ return;
2195
+ }
2196
+ if (!i.value && !B && await n.value.validate()) {
2197
+ Ce({
2198
+ type: "warning",
2199
+ title: "Попередження",
2200
+ message: "Будь ласка, заповніть всі обов'язкові поля"
2201
+ });
2202
+ return;
2203
+ }
2204
+ if (e.editor && y)
2205
+ if (r.value && c.value !== null) {
2206
+ const { state: h } = e.editor;
2207
+ try {
2208
+ e.editor.chain().focus().setNodeSelection(c.value).run();
2209
+ } catch {
2210
+ e.editor.chain().focus().setTextSelection(c.value).run();
2211
+ }
2212
+ const S = e.editor.getAttributes("link"), M = S && S.href, N = U(), j = {
2213
+ src: y,
2214
+ alt: o.value.alt || "",
2215
+ title: o.value.title || "",
2216
+ ...N
2217
+ };
2218
+ if ((!o.value.width || o.value.width === "") && (j.width = void 0), (!o.value.height || o.value.height === "") && (j.height = void 0), e.editor.chain().focus().updateAttributes("image", j).run(), setTimeout(() => {
2219
+ const { view: u } = e.editor;
2220
+ if (!u || !u.dom) return;
2221
+ u.dom.querySelectorAll("img.editor-image").forEach((T) => {
2222
+ if (T instanceof HTMLImageElement) {
2223
+ const D = T.getAttribute("src") || T.src;
2224
+ (D === y || D.includes(y.split("/").pop())) && (o.value.width && o.value.height ? (T.style.setProperty("width", `${o.value.width}px`, "important"), T.style.setProperty("height", `${o.value.height}px`, "important"), T.style.setProperty("object-fit", "fill", "important"), T.style.setProperty("max-width", "none", "important"), T.style.setProperty("max-height", "none", "important")) : (T.style.removeProperty("width"), T.style.removeProperty("height"), T.style.removeProperty("object-fit"), T.style.removeProperty("max-width"), T.style.removeProperty("max-height")));
2225
+ }
2226
+ });
2227
+ }, 20), o.value.link && o.value.link.trim() !== "") {
2228
+ let u = o.value.link.trim();
2229
+ u.match(/^https?:\/\//i) || (u = "https://" + u), M ? e.editor.chain().focus().extendMarkRange("link").setLink({
2230
+ href: u,
2231
+ target: o.value.openInNewTab ? "_blank" : null
2232
+ }).run() : e.editor.chain().focus().selectParentNode().setLink({
2233
+ href: u,
2234
+ target: o.value.openInNewTab ? "_blank" : null
2235
+ }).run();
2236
+ } else M && e.editor.chain().focus().extendMarkRange("link").unsetLink().run();
2237
+ } else {
2238
+ const { state: h } = e.editor, { selection: S } = h, { $anchor: M } = S;
2239
+ let N = null;
2240
+ for (let u = M.depth; u > 0; u--) {
2241
+ const x = M.node(u);
2242
+ if (x && x.type.name === "paragraph") {
2243
+ N = x;
2244
+ break;
2245
+ }
2246
+ }
2247
+ if (N && N.content.content.some(
2248
+ (u) => u.type.name === "image"
2249
+ )) {
2250
+ const u = Q(N, M.before(M.depth));
2251
+ if (u !== null) {
2252
+ const x = U(), A = h.schema.nodes.image.create({
2253
+ src: y,
2254
+ alt: o.value.alt || "",
2255
+ title: o.value.title || "",
2256
+ ...x
2257
+ });
2258
+ if (o.value.link && o.value.link.trim() !== "") {
2259
+ let T = o.value.link.trim();
2260
+ T.match(/^https?:\/\//i) || (T = "https://" + T);
2261
+ const D = h.schema.marks.link.create({
2262
+ href: T,
2263
+ target: o.value.openInNewTab ? "_blank" : null
2264
+ }), se = A.type.create(A.attrs, A.content, [D]);
2265
+ e.editor.chain().focus().insertContentAt(u + 1, se).run(), Y(e.editor, y);
2266
+ } else
2267
+ e.editor.chain().focus().insertContentAt(u + 1, A).run(), Y(e.editor, y);
2268
+ } else if (o.value.link && o.value.link.trim() !== "") {
2269
+ const x = U();
2270
+ e.editor.chain().focus().setImage({
2271
+ src: y,
2272
+ alt: o.value.alt || "",
2273
+ title: o.value.title || "",
2274
+ ...x
2275
+ }).run(), setTimeout(() => {
2276
+ let A = o.value.link.trim();
2277
+ A.match(/^https?:\/\//i) || (A = "https://" + A), e.editor.chain().focus().selectParentNode().setLink({
2278
+ href: A,
2279
+ target: o.value.openInNewTab ? "_blank" : null
2280
+ }).run(), Y(e.editor, y, 20);
2281
+ }, 10);
2282
+ } else {
2283
+ const x = U();
2284
+ e.editor.chain().focus().setImage({
2285
+ src: y,
2286
+ alt: o.value.alt || "",
2287
+ title: o.value.title || "",
2288
+ ...x
2289
+ }).run(), Y(e.editor, y);
2290
+ }
2291
+ } else if (o.value.link && o.value.link.trim() !== "") {
2292
+ const u = U();
2293
+ e.editor.chain().focus().setImage({
2294
+ src: y,
2295
+ alt: o.value.alt || "",
2296
+ title: o.value.title || "",
2297
+ ...u
2298
+ }).run(), setTimeout(() => {
2299
+ let x = o.value.link.trim();
2300
+ x.match(/^https?:\/\//i) || (x = "https://" + x), e.editor.chain().focus().selectParentNode().setLink({
2301
+ href: x,
2302
+ target: o.value.openInNewTab ? "_blank" : null
2303
+ }).run(), Y(e.editor, y, 20);
2304
+ }, 10);
2305
+ } else {
2306
+ const u = U();
2307
+ e.editor.chain().focus().setImage({
2308
+ src: y,
2309
+ alt: o.value.alt || "",
2310
+ title: o.value.title || "",
2311
+ ...u
2312
+ }).run(), Y(e.editor, y);
2313
+ }
2314
+ }
2315
+ P();
2316
+ }, Q = (m, _) => {
2317
+ let f = null;
2318
+ return m.forEach(($, y) => {
2319
+ $.type.name === "image" && (f = _ + y + 1);
2320
+ }), f;
2321
+ }, oe = async () => {
2322
+ if (e.editor) {
2323
+ if (l.value.length === 0)
2324
+ if (Array.isArray(o.value.file) && o.value.file.length > 0) {
2325
+ const m = o.value.file.filter((f) => typeof f == "string" && f.trim() !== ""), _ = o.value.file.filter((f) => f instanceof File);
2326
+ for (const f of m)
2327
+ l.value.some(($) => $.url === f || $.preview === f) || l.value.push({
2328
+ url: f,
2329
+ preview: f,
2330
+ error: !1
2331
+ });
2332
+ _.length > 0 && await O(_);
2333
+ } else i.value && await O(o.value.file);
2334
+ if (l.value.length !== 0)
2335
+ try {
2336
+ const m = [], _ = U();
2337
+ for (const f of l.value) {
2338
+ const $ = f.url || f.preview || "";
2339
+ if (!$) continue;
2340
+ const y = e.editor.schema.nodes.image.create({
2341
+ src: $,
2342
+ alt: o.value.alt || "",
2343
+ title: o.value.title || "",
2344
+ ..._
2345
+ });
2346
+ m.push(y);
2347
+ }
2348
+ m.length > 0 && (e.editor.chain().focus().command(({ tr: f, dispatch: $ }) => {
2349
+ if ($) {
2350
+ const { selection: y } = f, { $anchor: B } = y;
2351
+ let h = y.$anchor.pos, S = null, M = null;
2352
+ for (let j = B.depth; j > 0; j--) {
2353
+ const u = B.node(j);
2354
+ if (u && u.type.name === "paragraph") {
2355
+ S = u, M = B.start(j);
2356
+ break;
2357
+ }
2358
+ }
2359
+ if (S) {
2360
+ let j = null;
2361
+ S.forEach((u, x) => {
2362
+ u.type.name === "image" && (j = M + x + 1);
2363
+ }), j !== null ? h = j + 1 : h = M + S.content.size;
2364
+ }
2365
+ let N = h;
2366
+ return m.forEach((j) => {
2367
+ f.insert(N, j), N += j.nodeSize;
2368
+ }), !0;
2369
+ }
2370
+ return !1;
2371
+ }).run(), o.value.width && o.value.height && setTimeout(() => {
2372
+ const { view: f } = e.editor;
2373
+ f && f.dom && f.dom.querySelectorAll("img.editor-image").forEach((B) => {
2374
+ B instanceof HTMLImageElement && Array.from(l.value).some((S) => {
2375
+ const M = S.url || S.preview || "", N = B.src || B.getAttribute("src") || "";
2376
+ return N === M || N.includes(M.split("/").pop());
2377
+ }) && (B.style.setProperty("width", `${o.value.width}px`, "important"), B.style.setProperty("height", `${o.value.height}px`, "important"), B.style.setProperty("object-fit", "fill", "important"), B.style.setProperty("max-width", "none", "important"), B.style.setProperty("max-height", "none", "important"));
2378
+ });
2379
+ }, 50)), P();
2380
+ } catch (m) {
2381
+ console.error("Помилка при додаванні зображень:", m), Ce({
2382
+ type: "error",
2383
+ title: "Помилка",
2384
+ message: "Не вдалося додати зображення"
2385
+ });
2386
+ }
2387
+ }
2388
+ }, ue = async () => {
2389
+ await I();
2390
+ }, fe = () => {
2391
+ P();
2392
+ };
2393
+ return we(() => o.value.file, async (m, _) => {
2394
+ if (s.value = !1, !(r.value && Array.isArray(m) && m.length === 1 && typeof m[0] == "string" && !m.some(($) => $ instanceof File)))
2395
+ if (Array.isArray(m) && m.length > 0) {
2396
+ const f = m.filter((y) => y instanceof File), $ = m.filter((y) => typeof y == "string" && y.trim() !== "");
2397
+ if (f.length > 0 && (r.value ? r.value && f.length === 1 && $.length === 0 && (l.value = []) : l.value = [], (!r.value || f.length > 1 || $.length > 0) && await O(f), r.value && f.length === 1 && $.length === 0)) {
2398
+ const y = new FileReader();
2399
+ y.onload = (B) => {
2400
+ o.value.src = B.target.result;
2401
+ }, y.readAsDataURL(f[0]);
2402
+ }
2403
+ if ($.length > 0)
2404
+ if (r.value)
2405
+ r.value && $.length === 1 && f.length === 0 && (o.value.src = $[0]);
2406
+ else {
2407
+ f.length === 0 && (l.value = []);
2408
+ for (const y of $)
2409
+ l.value.some((B) => B.url === y || B.preview === y) || l.value.push({
2410
+ url: y,
2411
+ preview: y,
2412
+ error: !1
2413
+ });
2414
+ }
2415
+ } else m && typeof m == "object" && m instanceof FileList ? (r.value || (l.value = []), await O(Array.from(m))) : m && typeof m == "object" && !Array.isArray(m) && m instanceof File ? (r.value || (l.value = []), await O([m])) : r.value || (l.value = []);
2416
+ }, { immediate: !1 }), we(() => o.value.src, () => {
2417
+ s.value = !1;
2418
+ }), (m, _) => (v(), k("div", tl, [
2419
+ d("button", {
2420
+ onClick: g,
2421
+ class: E([
2422
+ "h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",
2423
+ t.editor?.isActive("image") ? "bg-gray-200 text-gray-900" : ""
2424
+ ]),
2425
+ title: "Додати зображення"
2426
+ }, [
2427
+ F(L(Rt), { class: "h-4 w-4" }),
2428
+ _[4] || (_[4] = d("span", { class: "sr-only" }, "Додати зображення", -1))
2429
+ ], 2),
2430
+ F(et, {
2431
+ modelValue: a.value,
2432
+ "onUpdate:modelValue": _[3] || (_[3] = (f) => a.value = f),
2433
+ title: r.value ? "Редагувати зображення" : "Додати зображення"
2434
+ }, {
2435
+ footer: R(() => [
2436
+ d("div", dl, [
2437
+ d("button", {
2438
+ onClick: fe,
2439
+ type: "button",
2440
+ class: "px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"
2441
+ }, " Скасувати "),
2442
+ d("button", {
2443
+ onClick: ue,
2444
+ type: "button",
2445
+ class: "px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"
2446
+ }, W(r.value ? "Оновити зображення" : "Додати зображення"), 1)
2447
+ ])
2448
+ ]),
2449
+ default: R(() => [
2450
+ F(vt, {
2451
+ modelValue: o.value,
2452
+ "onUpdate:modelValue": _[0] || (_[0] = (f) => o.value = f),
2453
+ schema: p.value,
2454
+ form: n.value,
2455
+ "onUpdate:form": _[1] || (_[1] = (f) => n.value = f)
2456
+ }, null, 8, ["modelValue", "schema", "form"]),
2457
+ b.value && !i.value ? (v(), k("div", rl, [
2458
+ _[5] || (_[5] = d("p", { class: "text-sm text-gray-600 mb-2" }, "Попередній перегляд:", -1)),
2459
+ ce(d("img", {
2460
+ src: b.value,
2461
+ alt: o.value.alt || "Попередній перегляд зображення",
2462
+ title: o.value.title,
2463
+ class: "max-w-full h-auto max-h-32 rounded border",
2464
+ onError: _[2] || (_[2] = (f) => s.value = !0)
2465
+ }, null, 40, ol), [
2466
+ [ke, !s.value]
2467
+ ]),
2468
+ s.value ? (v(), k("p", ll, " Не вдалося завантажити попередній перегляд зображення ")) : V("", !0)
2469
+ ])) : V("", !0),
2470
+ l.value.length > 0 ? (v(), k("div", al, [
2471
+ d("p", nl, "Попередній перегляд (" + W(l.value.length) + " зображень):", 1),
2472
+ _[6] || (_[6] = d("p", { class: "text-xs text-gray-500 mb-2" }, " Зображення будуть розміщені в ряд, якщо вони помістяться по ширині ", -1)),
2473
+ d("div", sl, [
2474
+ (v(!0), k(re, null, ne(l.value, (f, $) => (v(), k("div", {
2475
+ key: $,
2476
+ class: "relative"
2477
+ }, [
2478
+ ce(d("img", {
2479
+ src: f.preview,
2480
+ alt: `Попередній перегляд ${$ + 1}`,
2481
+ class: "max-w-[100px] max-h-[100px] rounded border object-contain",
2482
+ onError: (y) => f.error = !0
2483
+ }, null, 40, il), [
2484
+ [ke, !f.error]
2485
+ ]),
2486
+ d("button", {
2487
+ onClick: (y) => z($),
2488
+ class: "absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs hover:bg-red-600",
2489
+ type: "button"
2490
+ }, " × ", 8, cl)
2491
+ ]))), 128))
2492
+ ])
2493
+ ])) : V("", !0)
2494
+ ]),
2495
+ _: 1
2496
+ }, 8, ["modelValue", "title"])
2497
+ ]));
2498
+ }
2499
+ }), fl = { class: "flex items-center" }, pl = ["disabled"], gl = ["disabled"], hl = /* @__PURE__ */ Object.assign({
2500
+ inheritAttrs: !1
2501
+ }, {
2502
+ __name: "vs-editor-history",
2503
+ props: { editor: Object },
2504
+ setup(t) {
2505
+ const e = t, a = () => {
2506
+ e.editor?.can().undo() && e.editor.chain().focus().undo().run();
2507
+ }, s = () => {
2508
+ e.editor?.can().redo() && e.editor.chain().focus().redo().run();
2509
+ };
2510
+ return (n, r) => (v(), k("div", fl, [
2511
+ d("button", {
2512
+ onClick: a,
2513
+ class: E(["w-[30px] h-[30px] flex items-center justify-center rounded-l-full hover:text-gray-900 hover:bg-gray-100 border-r border-gray-200", [
2514
+ t.editor?.can().undo() ? "text-gray-500" : "text-gray-300 cursor-not-allowed"
2515
+ ]]),
2516
+ disabled: !t.editor?.can().undo(),
2517
+ title: "Undo (Ctrl+Z)"
2518
+ }, [
2519
+ F(L(Ut), { class: "h-4 w-4" })
2520
+ ], 10, pl),
2521
+ d("button", {
2522
+ onClick: s,
2523
+ class: E(["w-[30px] h-[30px] flex items-center justify-center rounded-r-full hover:text-gray-900 hover:bg-gray-100", [
2524
+ t.editor?.can().redo() ? "text-gray-500" : "text-gray-300 cursor-not-allowed"
2525
+ ]]),
2526
+ disabled: !t.editor?.can().redo(),
2527
+ title: "Redo (Ctrl+Y)"
2528
+ }, [
2529
+ F(L(qt), { class: "h-4 w-4" })
2530
+ ], 10, gl)
2531
+ ]));
2532
+ }
2533
+ }), vl = /* @__PURE__ */ X(hl, [["__scopeId", "data-v-2cd0a908"]]), ml = { class: "relative" }, bl = { class: "p-6" }, yl = { class: "flex justify-between items-center mb-4" }, xl = /* @__PURE__ */ Object.assign({
2534
+ inheritAttrs: !1
2535
+ }, {
2536
+ __name: "vs-editor-help",
2537
+ props: { editor: Object },
2538
+ setup(t) {
2539
+ const e = C(!1), a = C(null), s = () => {
2540
+ e.value = !e.value;
2541
+ }, n = () => {
2542
+ e.value = !1;
2543
+ };
2544
+ return (r, l) => (v(), k("div", ml, [
2545
+ d("button", {
2546
+ ref_key: "helpButton",
2547
+ ref: a,
2548
+ onClick: s,
2549
+ class: E(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 text-gray-500", [e.value ? "bg-gray-100 text-gray-900" : "text-gray-500"]]),
2550
+ title: "Markdown Shortcuts Help"
2551
+ }, [
2552
+ F(L(Kt), { class: "h-4 w-4" })
2553
+ ], 2),
2554
+ e.value ? (v(), k("div", {
2555
+ key: 0,
2556
+ class: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[100001]",
2557
+ onClick: n
2558
+ }, [
2559
+ d("div", {
2560
+ class: "bg-white rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",
2561
+ onClick: l[0] || (l[0] = dt(() => {
2562
+ }, ["stop"]))
2563
+ }, [
2564
+ d("div", bl, [
2565
+ d("div", yl, [
2566
+ l[1] || (l[1] = d("h2", { class: "text-xl font-semibold text-gray-900" }, "Common Markdown Syntax & Shortcuts", -1)),
2567
+ d("button", {
2568
+ onClick: n,
2569
+ class: "text-gray-400 hover:text-gray-600 transition-colors"
2570
+ }, [
2571
+ F(L(Be), { class: "h-6 w-6" })
2572
+ ])
2573
+ ]),
2574
+ l[2] || (l[2] = ut('<div class="space-y-6" data-v-38077376><div data-v-38077376><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-38077376>Markdown Syntax</h3><div class="overflow-x-auto" data-v-38077376><table class="w-full border-collapse" data-v-38077376><thead data-v-38077376><tr class="bg-gray-50" data-v-38077376><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-38077376>Element</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-38077376>Example</th></tr></thead><tbody class="text-sm" data-v-38077376><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Bold</td><td class="border border-gray-200 px-3 py-2" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>**bold text**</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>__bold text__</code></td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Italics</td><td class="border border-gray-200 px-3 py-2" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>*italic text*</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>_italic text_</code></td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Strikethrough</td><td class="border border-gray-200 px-3 py-2" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>~strikethrough text~</code></td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Headings</td><td class="border border-gray-200 px-3 py-2" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376># Heading 1</code>, <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>## Heading 2</code>, etc., up to <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>###### Heading 6</code></td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Unordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Use an asterisk (*), dash (-), or plus sign (+) followed by a space. </td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Ordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Use a number followed by a period and a space (e.g., <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>1. First item</code>). </td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Blockquotes</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Start with a greater-than sign (&gt;) followed by a space. </td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Inline Code</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Surround with backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>`</code>). </td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Code Blocks</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Enclose with three backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>```</code>) before and after the code. </td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Images</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>![alt text](url)</code> syntax. </td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Links</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>[Link Text](url)</code> syntax. </td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376>Checklists</td><td class="border border-gray-200 px-3 py-2" data-v-38077376> Create a list item with <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>- [ ]</code> for an incomplete task or <code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>- [x]</code> for a completed one. </td></tr></tbody></table></div></div><div data-v-38077376><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-38077376>Common Editing Shortcuts</h3><div class="overflow-x-auto" data-v-38077376><table class="w-full border-collapse" data-v-38077376><thead data-v-38077376><tr class="bg-gray-50" data-v-38077376><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-38077376>Shortcut</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-38077376>Action</th></tr></thead><tbody class="text-sm" data-v-38077376><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+A</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Select all text</td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+B</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Apply bold formatting</td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+C</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Copy selected text</td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+I</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Apply italic formatting</td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+K</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Open the insert link dialog</td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+S</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Save the current document</td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+V</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Paste copied text</td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+X</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Cut selected text</td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+Y</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Redo the last action</td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Alt+Shift+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Redo the last action</td></tr><tr data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Ctrl+Z</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Undo the last action</td></tr><tr class="bg-gray-25" data-v-38077376><td class="border border-gray-200 px-3 py-2 font-medium" data-v-38077376><code class="bg-gray-100 px-2 py-1 rounded" data-v-38077376>Alt+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-38077376>Undo the last action</td></tr></tbody></table></div></div></div>', 1))
2575
+ ])
2576
+ ])
2577
+ ])) : V("", !0)
2578
+ ]));
2579
+ }
2580
+ }), wl = /* @__PURE__ */ X(xl, [["__scopeId", "data-v-38077376"]]), kl = {
2581
+ __name: "vs-editor-horizontal-rule",
2582
+ props: {
2583
+ editor: Object
2584
+ },
2585
+ setup(t) {
2586
+ const e = t, a = () => {
2587
+ e.editor && e.editor.chain().focus().setHorizontalRule().run();
2588
+ };
2589
+ return (s, n) => (v(), k("button", {
2590
+ title: "Horizontal Rule",
2591
+ onClick: a,
2592
+ class: "flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex"
2593
+ }, [
2594
+ F(L(Wt), { class: "h-4 w-4" })
2595
+ ]));
2596
+ }
2597
+ }, _l = {
2598
+ __name: "vs-editor-fullscreen",
2599
+ props: {
2600
+ editor: Object
2601
+ },
2602
+ emits: ["toggle-fullscreen"],
2603
+ setup(t, { emit: e }) {
2604
+ const a = e, s = () => {
2605
+ a("toggle-fullscreen");
2606
+ };
2607
+ return (n, r) => (v(), k("button", {
2608
+ title: "Fullscreen",
2609
+ onClick: s,
2610
+ class: "w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100"
2611
+ }, [
2612
+ F(L(Xt), { class: "h-4 w-4" })
2613
+ ]));
2614
+ }
2615
+ }, $l = {
2616
+ bold: Br,
2617
+ italic: Pr,
2618
+ color: _o,
2619
+ background_color: To,
2620
+ highlight: Lo,
2621
+ bullet_list: kr,
2622
+ ordered_list: Cr,
2623
+ blockquote: yr,
2624
+ codeblock: Sr,
2625
+ underline: jr,
2626
+ strike: Mr,
2627
+ link: ao,
2628
+ table: uo,
2629
+ text_align: go,
2630
+ font_family: jo,
2631
+ font_size: zo,
2632
+ superscript: Vo,
2633
+ subscript: qo,
2634
+ heading: Qo,
2635
+ clear_formatting: el,
2636
+ image: ul,
2637
+ history: vl,
2638
+ help: wl,
2639
+ horizontal_rule: kl,
2640
+ fullscreen: _l
2641
+ }, qe = {
2642
+ // Базовий набір - мінімальний функціонал
2643
+ basic: [
2644
+ "history",
2645
+ "font_family",
2646
+ "font_size",
2647
+ "bold",
2648
+ "italic",
2649
+ "underline",
2650
+ "strike",
2651
+ "text_align",
2652
+ "bullet_list",
2653
+ "ordered_list",
2654
+ "link",
2655
+ "image",
2656
+ "clear_formatting",
2657
+ "help"
2658
+ ],
2659
+ // Стандартний набір - рекомендований для більшості випадків
2660
+ default: [
2661
+ "history",
2662
+ "heading",
2663
+ "font_family",
2664
+ "font_size",
2665
+ "bold",
2666
+ "italic",
2667
+ "underline",
2668
+ "strike",
2669
+ "superscript",
2670
+ "subscript",
2671
+ "color",
2672
+ "background_color",
2673
+ "highlight",
2674
+ "text_align",
2675
+ "bullet_list",
2676
+ "ordered_list",
2677
+ "blockquote",
2678
+ "codeblock",
2679
+ "table",
2680
+ "link",
2681
+ "image",
2682
+ "horizontal_rule",
2683
+ "clear_formatting",
2684
+ "fullscreen",
2685
+ "help"
2686
+ ],
2687
+ // Повний набір - всі доступні функції
2688
+ full: [
2689
+ "history",
2690
+ "heading",
2691
+ "font_family",
2692
+ "font_size",
2693
+ "bold",
2694
+ "italic",
2695
+ "underline",
2696
+ "strike",
2697
+ "color",
2698
+ "background_color",
2699
+ "highlight",
2700
+ "text_align",
2701
+ "bullet_list",
2702
+ "ordered_list",
2703
+ "blockquote",
2704
+ "codeblock",
2705
+ "table",
2706
+ "link",
2707
+ "image",
2708
+ "horizontal_rule",
2709
+ "superscript",
2710
+ "subscript",
2711
+ "clear_formatting",
2712
+ "fullscreen",
2713
+ "help"
2714
+ ]
2715
+ }, Cl = { class: "flex align-middle gap-x-0.5 border-b flex-wrap border-b-gray-200 px-[10px] py-[6px] border-solid border-transparent" }, Al = { class: "editor-body" }, Fl = {
2716
+ key: 0,
2717
+ class: "richtext-loading text-sm text-gray-500"
2718
+ }, Sl = {
2719
+ key: 1,
2720
+ class: "richtext-error text-sm text-red-600"
2721
+ }, Tl = { class: "html-source-editor" }, Ll = { class: "flex justify-end border-t border-[#e5e7eb] bg-[#f8fafc] px-4 min-h-[38px] items-start overflow-visible" }, Bl = { class: "inline-flex items-stretch -mt-px" }, Ml = /* @__PURE__ */ Object.assign({
2722
+ inheritAttrs: !1
2723
+ }, {
2724
+ __name: "vs-richtext",
2725
+ props: /* @__PURE__ */ gt({
2726
+ modelValue: { type: String, default: () => "" },
2727
+ height: { type: String, default: () => "300px" },
2728
+ format: { type: String, default: () => "html" },
2729
+ toolbar: {
2730
+ type: [Array, String],
2731
+ default: () => "default"
2732
+ }
2733
+ }, {
2734
+ modelValue: { default: "" },
2735
+ modelModifiers: {}
2736
+ }),
2737
+ emits: ["update:modelValue"],
2738
+ setup(t) {
2739
+ const e = t, a = ft(t, "modelValue"), s = C(null), n = C(null), r = pt(null), l = C(!1), c = C(""), o = C(!1), i = C(null), w = C(""), b = C(""), p = C(null), g = C(!1), { isFullscreen: P, toggleFullscreen: O } = Gt(), { t: z } = Me(), U = H(() => e.format === "md" ? "markdown" : "html"), Y = H(
2740
+ () => e.format === "md" ? z("form.richtext.markdown") : z("form.richtext.html")
2741
+ ), I = H(() => r.value || null), Q = H(() => typeof e.toolbar == "string" ? qe[e.toolbar] || qe.default : e.toolbar), oe = H(() => Q.value.map((u) => $l[u]).filter(Boolean)), ue = H(() => (i.value?.attributes || []).find((x) => x.name === "class")?.value || ""), fe = H(() => {
2742
+ const x = (i.value?.attributes || []).find((T) => T.name === "style")?.value || "", A = {};
2743
+ return x.split(";").forEach((T) => {
2744
+ const [D, ...se] = T.split(":"), ae = D?.trim(), pe = se.join(":").trim();
2745
+ !ae || !pe || ae !== "height" && (A[ae.replace(/-([a-z])/g, ($e, ot) => ot.toUpperCase())] = pe);
2746
+ }), A;
2747
+ }), m = /* @__PURE__ */ new Set(["<p></p>", "<p><br></p>"]), _ = (u) => {
2748
+ const x = u || "";
2749
+ return m.has(x) ? "" : x;
2750
+ }, f = (u) => {
2751
+ const x = u || "";
2752
+ p.value = x, a.value = x;
2753
+ }, $ = (u) => {
2754
+ if (!u || !u.view || !u.view.dom) return;
2755
+ u.view.dom.querySelectorAll("img.editor-image[width][height]").forEach((A) => {
2756
+ if (A instanceof HTMLImageElement) {
2757
+ const T = A.getAttribute("width"), D = A.getAttribute("height");
2758
+ T && D && T !== "auto" && D !== "auto" && T !== "" && D !== "" && !isNaN(Number(T)) && !isNaN(Number(D)) && (A.style.cssText = `
2759
+ width: ${T}px !important;
2760
+ height: ${D}px !important;
2761
+ max-width: none !important;
2762
+ max-height: none !important;
2763
+ min-width: auto !important;
2764
+ min-height: auto !important;
2765
+ object-fit: fill !important;
2766
+ `.replace(/\s+/g, " ").trim());
2767
+ }
2768
+ });
2769
+ }, y = async (u, { force: x = !1 } = {}) => {
2770
+ if (w.value = u || "", !r.value || o.value && !x) return;
2771
+ _(r.value.getHTML()) !== (u || "") && (r.value.commands.setContent(u || "", !1), ge(() => {
2772
+ $(r.value);
2773
+ }));
2774
+ }, B = async (u) => {
2775
+ b.value = u || "";
2776
+ }, h = async (u) => {
2777
+ const x = u || "";
2778
+ if (e.format === "html") {
2779
+ const A = Se(x), T = De(A);
2780
+ i.value = T.wrapper, await y(T.bodyHtml || ""), p.value = A;
2781
+ return;
2782
+ } else {
2783
+ i.value = null;
2784
+ const A = await Ve(x, e.format);
2785
+ await y(A || ""), o.value && await B(x);
2786
+ }
2787
+ p.value = x;
2788
+ }, S = async () => {
2789
+ if (e.format === "html") {
2790
+ const x = _(r.value?.getHTML() || w.value || ""), A = Oe(x, i.value);
2791
+ return Re(Se(A), "html");
2792
+ }
2793
+ const u = _(r.value?.getHTML() || w.value || "");
2794
+ return Re(u, e.format);
2795
+ }, M = async (u) => {
2796
+ if (o.value !== u) {
2797
+ if (u) {
2798
+ g.value = !0, o.value = !0, await B(await S()), ge(() => {
2799
+ n.value?.focus?.();
2800
+ });
2801
+ return;
2802
+ }
2803
+ if (e.format === "html") {
2804
+ const x = Se(b.value || ""), A = De(x);
2805
+ i.value = A.wrapper, await y(A.bodyHtml || "", { force: !0 });
2806
+ } else {
2807
+ const x = await Ve(b.value || "", e.format);
2808
+ await y(x || "", { force: !0 });
2809
+ }
2810
+ o.value = !1, g.value = !1, ge(() => {
2811
+ r.value?.commands?.focus?.();
2812
+ });
2813
+ }
2814
+ }, N = () => {
2815
+ o.value || r.value?.commands?.focus?.();
2816
+ }, j = async () => {
2817
+ if (!s.value) return null;
2818
+ l.value = !0, c.value = "";
2819
+ try {
2820
+ const u = await rr();
2821
+ if (!u) return null;
2822
+ const x = new u.Editor({
2823
+ element: s.value,
2824
+ content: w.value || "",
2825
+ extensions: [
2826
+ u.StarterKit.configure({
2827
+ history: {
2828
+ depth: 100,
2829
+ newGroupDelay: 500
2830
+ },
2831
+ code: {
2832
+ HTMLAttributes: {
2833
+ class: "editor-code"
2834
+ }
2835
+ },
2836
+ codeBlock: {
2837
+ HTMLAttributes: {
2838
+ class: "editor-codeblock"
2839
+ }
2840
+ },
2841
+ paragraph: !1,
2842
+ heading: !1,
2843
+ link: !1
2844
+ }),
2845
+ u.Superscript,
2846
+ u.Subscript,
2847
+ u.ExtendedTextStyle,
2848
+ u.CustomParagraph,
2849
+ u.CustomHeading,
2850
+ u.Highlight,
2851
+ u.Image.configure({
2852
+ inline: !0,
2853
+ allowBase64: !0,
2854
+ HTMLAttributes: {
2855
+ class: "editor-image"
2856
+ }
2857
+ }),
2858
+ u.TextAlign.configure({
2859
+ types: ["heading", "paragraph"]
2860
+ }),
2861
+ u.Link.configure({
2862
+ HTMLAttributes: {
2863
+ class: "editor-link"
2864
+ },
2865
+ openOnClick: !1,
2866
+ autolink: !0
2867
+ }),
2868
+ u.CustomTableKit,
2869
+ u.Iframe
2870
+ ],
2871
+ editorProps: {
2872
+ handlePaste: (A, T) => pr(A, T, u.ProseMirrorDOMParser),
2873
+ handleKeyDown: (A, T) => {
2874
+ if (T.key === "Tab") {
2875
+ const D = A.state, { $anchor: se } = D.selection;
2876
+ let ae = !1;
2877
+ for (let pe = se.depth; pe > 0; pe--) {
2878
+ const $e = se.node(pe);
2879
+ if ($e && ($e.type.name === "bulletList" || $e.type.name === "orderedList")) {
2880
+ ae = !0;
2881
+ break;
2882
+ }
2883
+ }
2884
+ return ae ? !1 : (T.preventDefault(), !0);
2885
+ }
2886
+ return !1;
2887
+ }
2888
+ }
2889
+ });
2890
+ return r.value = ht(x), r.value.on("update", async ({ editor: A }) => {
2891
+ if (o.value) return;
2892
+ const T = _(A.getHTML());
2893
+ if (w.value = T, e.format === "html") {
2894
+ const D = Oe(T, i.value);
2895
+ D !== a.value && f(D);
2896
+ } else {
2897
+ const D = await ur(T, e.format);
2898
+ D !== a.value && f(D);
2899
+ }
2900
+ setTimeout(() => {
2901
+ $(A);
2902
+ }, 10);
2903
+ }), ge(() => {
2904
+ $(r.value);
2905
+ }), x;
2906
+ } catch (u) {
2907
+ return c.value = "Failed to load rich text editor dependencies.", console.error("Failed to initialize rich text editor", u), null;
2908
+ } finally {
2909
+ l.value = !1;
2910
+ }
2911
+ };
2912
+ return we(
2913
+ () => e.modelValue,
2914
+ async (u) => {
2915
+ if (g.value) return;
2916
+ const x = u || "";
2917
+ x !== p.value && await h(x);
2918
+ },
2919
+ { immediate: !0 }
2920
+ ), he(async () => {
2921
+ await j(), ge(() => {
2922
+ r.value && setTimeout(() => {
2923
+ $(r.value);
2924
+ }, 100);
2925
+ });
2926
+ }), Xe(() => {
2927
+ r.value?.destroy?.(), r.value = null;
2928
+ }), (u, x) => (v(), k("div", {
2929
+ class: E(["bg-white rounded-md w-full", { "fixed left-0 right-0 top-0 bottom-0 z-[100000]": L(P) }])
2930
+ }, [
2931
+ d("div", Cl, [
2932
+ (v(!0), k(re, null, ne(oe.value, (A) => (v(), k(re, { key: A }, [
2933
+ r.value ? (v(), K(Te(A), {
2934
+ key: 0,
2935
+ editor: I.value,
2936
+ onToggleFullscreen: L(O)
2937
+ }, null, 40, ["editor", "onToggleFullscreen"])) : V("", !0)
2938
+ ], 64))), 128))
2939
+ ]),
2940
+ d("div", {
2941
+ onClick: N,
2942
+ class: "relative w-full px-4 py-2 bg-white rounded-b-lg editor-content",
2943
+ style: le({ height: L(P) ? "calc(95vh - 44px)" : t.height })
2944
+ }, [
2945
+ d("div", Al, [
2946
+ ce(d("div", {
2947
+ class: E(["rich-text-scroll-wrapper", ue.value]),
2948
+ style: le(fe.value)
2949
+ }, [
2950
+ d("div", {
2951
+ ref_key: "editorElement",
2952
+ ref: s,
2953
+ class: "relative w-full"
2954
+ }, null, 512),
2955
+ l.value ? (v(), k("div", Fl, "Loading editor...")) : V("", !0),
2956
+ c.value ? (v(), k("div", Sl, W(c.value), 1)) : V("", !0)
2957
+ ], 6), [
2958
+ [ke, !o.value]
2959
+ ]),
2960
+ ce(d("div", Tl, [
2961
+ F(mt, {
2962
+ ref_key: "htmlTextarea",
2963
+ ref: n,
2964
+ modelValue: b.value,
2965
+ "onUpdate:modelValue": x[0] || (x[0] = (A) => b.value = A),
2966
+ height: "100%",
2967
+ syntax: U.value,
2968
+ theme: "vs-light"
2969
+ }, null, 8, ["modelValue", "syntax"])
2970
+ ], 512), [
2971
+ [ke, o.value]
2972
+ ])
2973
+ ])
2974
+ ], 4),
2975
+ d("div", Ll, [
2976
+ d("div", Bl, [
2977
+ d("button", {
2978
+ type: "button",
2979
+ class: E([
2980
+ "min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-bl-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",
2981
+ o.value ? "text-[#8f99aa]" : "!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]"
2982
+ ]),
2983
+ onClick: x[1] || (x[1] = (A) => M(!1))
2984
+ }, W(L(z)("form.richtext.editor")), 3),
2985
+ d("button", {
2986
+ type: "button",
2987
+ class: E([
2988
+ "min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] border-l-0 bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-br-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",
2989
+ o.value ? "!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]" : "text-[#8f99aa]"
2990
+ ]),
2991
+ onClick: x[2] || (x[2] = (A) => M(!0))
2992
+ }, W(Y.value), 3)
2993
+ ])
2994
+ ])
2995
+ ], 2));
2996
+ }
2997
+ });
2998
+ export {
2999
+ Ml as default
3000
+ };