@synopackageland/ui 0.17.9 → 0.17.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +51 -17
  3. package/dist/components/composite/comment-item/CommentItem.vue.d.ts +5 -1
  4. package/dist/components/composite/copy-button/CopyButton.vue.d.ts +2 -2
  5. package/dist/components/composite/file-picker/FilePicker.vue.d.ts +5 -2
  6. package/dist/components/composite/file-thumbs/FileThumbs.vue.d.ts +24 -0
  7. package/dist/components/composite/form/FormItem.vue.d.ts +1 -1
  8. package/dist/components/composite/form-note/FormNote.vue.d.ts +6 -2
  9. package/dist/components/composite/image-lightbox/ImageLightbox.vue.d.ts +19 -0
  10. package/dist/components/composite/mention-list/MentionList.vue.d.ts +31 -0
  11. package/dist/components/composite/rich-text-view/RichTextBlocks.vue.d.ts +14 -0
  12. package/dist/components/composite/rich-text-view/RichTextImage.vue.d.ts +12 -0
  13. package/dist/components/composite/rich-text-view/RichTextInline.vue.d.ts +23 -0
  14. package/dist/components/composite/rich-text-view/RichTextView.vue.d.ts +28 -0
  15. package/dist/components/composite/stat-tile/StatTile.vue.d.ts +1 -1
  16. package/dist/components/composite/upload-queue/UploadQueue.vue.d.ts +36 -0
  17. package/dist/components/composite/wizard/WizardStep.vue.d.ts +1 -1
  18. package/dist/components/containers/fieldset/Fieldset.vue.d.ts +6 -2
  19. package/dist/components/primitives/input/Input.vue.d.ts +13 -1
  20. package/dist/components/rich-text-editor/RichTextEditor.vue.d.ts +83 -0
  21. package/dist/components/rich-text-editor/extensions.d.ts +30 -0
  22. package/dist/components/rich-text-editor/markdown.d.ts +22 -0
  23. package/dist/i18n/filePicker.d.ts +3 -0
  24. package/dist/i18n/text.d.ts +48 -0
  25. package/dist/index.d.ts +15 -4
  26. package/dist/index.js +11305 -10025
  27. package/dist/json/catalog.d.ts +2 -2
  28. package/dist/json/registry.d.ts +34 -34
  29. package/dist/json-preview/preview.js +3608 -3161
  30. package/dist/lib/files.d.ts +28 -0
  31. package/dist/lib/mentions.d.ts +0 -10
  32. package/dist/lib/richText.d.ts +66 -0
  33. package/dist/lib/uploadQueue.d.ts +39 -0
  34. package/dist/reka-runtime.json +1 -1
  35. package/dist/rich-text.d.ts +3 -0
  36. package/dist/rich-text.js +1075 -0
  37. package/dist/theme.css +1 -1
  38. package/dist/themes/dsm7-embedded-theme.css +1 -1
  39. package/dist/themes/dsm7-embedded.css +1 -1
  40. package/dist/themes/dsm7.css +1 -1
  41. package/docs/layout-rules.md +7 -3
  42. package/docs/theme-hooks.md +14 -3
  43. package/package.json +14 -1
  44. package/dist/components/composite/comment-item/CommentInlineParts.vue.d.ts +0 -7
  45. package/dist/components/composite/mention-textarea/MentionTextarea.vue.d.ts +0 -52
  46. package/dist/lib/commentMarkdown.d.ts +0 -34
  47. /package/dist/components/composite/{mention-textarea → comment-item}/PersonInitials.vue.d.ts +0 -0
@@ -0,0 +1,1075 @@
1
+ import { defineComponent as At, computed as M, ref as q, watch as G, useId as St, reactive as zt, onMounted as Et, onBeforeUnmount as Bt, openBlock as p, createElementBlock as y, mergeProps as Tt, createElementVNode as B, unref as l, Fragment as Q, renderList as Z, withModifiers as F, normalizeClass as E, createBlock as T, resolveDynamicComponent as we, withCtx as I, createVNode as _, createCommentVNode as C, createTextVNode as Ge, toDisplayString as ee, normalizeStyle as It, shallowRef as Rt } from "vue";
2
+ import { useEditor as Ht, EditorContent as qt } from "@tiptap/vue-3";
3
+ import { BubbleMenu as Ft } from "@tiptap/vue-3/menus";
4
+ import { Bold as Nt, Italic as Ut, Link as Vt, List as Dt, ListOrdered as Ot, Heading2 as jt, Heading3 as Kt, Code as Gt, TextQuote as Qt, SquareCode as Wt, Strikethrough as Jt, ImagePlus as Qe, AtSign as We, Ellipsis as Xt, Unlink as Je, X as Me, RotateCw as Yt, CaseSensitive as Zt, SendHorizontal as ea } from "@lucide/vue";
5
+ import { richTextParts as ta, useUiText as aa, useUploadQueue as ra, DropdownMenu as ia, Input as Xe, Button as Ye, IconButton as te, MentionList as na, Spinner as Ze, UploadQueue as oa, isUnsupportedPicture as la, isPicture as sa } from "./index.js";
6
+ import { Extension as Ce, mergeAttributes as tt, Node as ua } from "@tiptap/core";
7
+ import da from "@tiptap/starter-kit";
8
+ import { Placeholder as ca } from "@tiptap/extensions";
9
+ import fa from "@tiptap/extension-mention";
10
+ import { Plugin as pa } from "@tiptap/pm/state";
11
+ const ma = /^(?:https?:\/\/[^\s/]|mailto:[^\s@]+@)/i;
12
+ function va(a) {
13
+ return ua.create({
14
+ name: "fileImage",
15
+ group: "block",
16
+ atom: !0,
17
+ draggable: !0,
18
+ selectable: !0,
19
+ addAttributes() {
20
+ return {
21
+ id: { default: null, parseHTML: (o) => o.getAttribute("data-file-id"), renderHTML: (o) => o.id ? { "data-file-id": o.id } : {} },
22
+ alt: { default: "", parseHTML: (o) => o.getAttribute("alt") ?? "" },
23
+ upload: { default: null, rendered: !1 },
24
+ progress: { default: 0, rendered: !1 },
25
+ src: { default: null, rendered: !1 }
26
+ };
27
+ },
28
+ // Only an image this editor made is taken back from the clipboard; any other is handled by the paste code.
29
+ parseHTML: () => [{ tag: "img[data-file-id]" }],
30
+ renderHTML: ({ HTMLAttributes: o }) => ["img", tt(o)],
31
+ addNodeView() {
32
+ return ({ node: o }) => {
33
+ let i = o;
34
+ const u = document.createElement("div");
35
+ u.className = "relative my-1 flex w-fit max-w-full overflow-hidden rounded-[var(--ui-radius-md)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-subtle)] [&.ProseMirror-selectednode]:shadow-[var(--ui-shadow-focus)]", u.setAttribute("data-ui-rich-editor-image", ""), u.contentEditable = "false";
36
+ const n = () => {
37
+ const { id: s, alt: A, upload: k, src: h } = i.attrs, m = s ? a.file(s) : void 0, v = i.attrs.progress < 0 ? "failed" : i.attrs.progress, c = h ?? m?.preview ?? m?.url ?? m?.thumb;
38
+ if (u.replaceChildren(), u.style.background = m?.dominant ?? "", u.dataset.state = v === "failed" ? "failed" : k ? "uploading" : m?.state ?? (c ? "ready" : "missing"), c) {
39
+ const f = document.createElement("img");
40
+ f.src = c, f.alt = A || m?.name || "", f.draggable = !1, f.className = `block max-h-80 max-w-full object-contain ${k ? "opacity-60" : ""}`, m?.width && m.height && (f.style.aspectRatio = `${m.width} / ${m.height}`), u.append(f);
41
+ } else {
42
+ const f = document.createElement("span");
43
+ f.className = "flex h-24 min-w-40 items-center justify-center px-3 text-[length:var(--ui-font-size-sm)] text-[var(--ui-text-secondary)]", f.textContent = a.labels.missing, u.append(f);
44
+ }
45
+ if (k) {
46
+ const f = document.createElement("span");
47
+ f.className = "absolute inset-x-0 bottom-0 h-1 bg-[var(--ui-surface-subtle)]", f.setAttribute("role", "progressbar"), f.setAttribute("aria-label", v === "failed" ? a.labels.failed : a.labels.uploading);
48
+ const x = document.createElement("span");
49
+ x.className = v === "failed" ? "block h-full w-full bg-[var(--ui-danger)]" : "block h-full bg-[var(--ui-primary)] transition-[width]", v !== "failed" && (x.style.width = `${Math.round((v ?? 0) * 100)}%`, f.setAttribute("aria-valuenow", String(Math.round((v ?? 0) * 100)))), f.append(x), u.append(f);
50
+ }
51
+ };
52
+ return n(), {
53
+ dom: u,
54
+ update: (s) => s.type !== i.type ? !1 : (i = s, n(), !0),
55
+ ignoreMutation: () => !0
56
+ };
57
+ };
58
+ }
59
+ });
60
+ }
61
+ const ba = Ce.create({
62
+ name: "listDepth",
63
+ priority: 1e3,
64
+ addKeyboardShortcuts() {
65
+ return {
66
+ Tab: ({ editor: a }) => {
67
+ const { $from: o } = a.state.selection;
68
+ let i = 0;
69
+ for (let u = o.depth; u > 0; u--) o.node(u).type.name === "listItem" && i++;
70
+ return i >= 2;
71
+ }
72
+ };
73
+ }
74
+ }), ha = Ce.create({
75
+ name: "imeBackspaceGuard",
76
+ addProseMirrorPlugins() {
77
+ const a = this.editor;
78
+ return [new pa({
79
+ filterTransaction: (o) => !a.view.composing || o.docChanged || o.selectionSet || o.storedMarksSet || Object.keys(o.meta).length > 0
80
+ })];
81
+ }
82
+ });
83
+ function ga(a) {
84
+ return [
85
+ da.configure({
86
+ heading: a.headings ? { levels: [2, 3] } : !1,
87
+ horizontalRule: !1,
88
+ underline: !1,
89
+ trailingNode: !1,
90
+ link: {
91
+ openOnClick: !1,
92
+ autolink: !0,
93
+ linkOnPaste: !0,
94
+ defaultProtocol: "https",
95
+ protocols: [],
96
+ isAllowedUri: (o) => ma.test(o),
97
+ HTMLAttributes: { rel: "noopener noreferrer", target: null }
98
+ }
99
+ }),
100
+ ca.configure({ placeholder: a.placeholder }),
101
+ ba,
102
+ ha,
103
+ va(a.image),
104
+ fa.configure({
105
+ HTMLAttributes: { class: "font-semibold text-[var(--ui-primary)]" },
106
+ renderText: ({ node: o }) => `@${o.attrs.label ?? o.attrs.id}`,
107
+ renderHTML: ({ node: o, options: i }) => ["span", tt({ "data-type": "mention", "data-id": o.attrs.id }, i.HTMLAttributes), `@${o.attrs.label ?? o.attrs.id}`],
108
+ suggestion: { char: "@", ...a.mention }
109
+ }),
110
+ Ce.create({
111
+ name: "editorKeys",
112
+ addKeyboardShortcuts() {
113
+ const o = () => !this.editor.view.composing;
114
+ return {
115
+ "Mod-Enter": () => o() && (a.submit?.() ?? !1),
116
+ "Mod-k": () => o() && a.link(),
117
+ Escape: () => o() && a.escape()
118
+ };
119
+ }
120
+ })
121
+ ];
122
+ }
123
+ function ya(a, o = {}) {
124
+ const i = [], u = ta(a, { people: o.people, headings: o.headings }).flatMap((n) => at(n, o, i));
125
+ return { doc: { type: "doc", content: u.length ? u : [{ type: "paragraph" }] }, images: i };
126
+ }
127
+ function at(a, o, i) {
128
+ if (a.type === "code") return [{ type: "codeBlock", content: a.text ? [{ type: "text", text: a.text }] : void 0 }];
129
+ if (a.type === "quote") return [{ type: "blockquote", content: a.blocks.flatMap((s) => at(s, o, i)) }];
130
+ if (a.type === "list") return [it(a, o, i)];
131
+ const u = (s) => a.type === "heading" ? { type: "heading", attrs: { level: a.level }, content: s } : { type: "paragraph", content: s }, n = rt(a.parts, u, o, i);
132
+ return o.imagesApart && a.parts.some((s) => s.type === "image") && n.every((s) => !s.content) ? [] : n;
133
+ }
134
+ function rt(a, o, i, u) {
135
+ const n = [];
136
+ let s = [];
137
+ const A = (k = !1) => {
138
+ for (; s.at(-1)?.type === "hardBreak"; ) s.pop();
139
+ for (; s[0]?.type === "hardBreak"; ) s.shift();
140
+ (s.length || k) && n.push(o(s.length ? s : [])), s = [];
141
+ };
142
+ for (const k of a) {
143
+ if (k.type !== "image") {
144
+ s.push(...ka(k));
145
+ continue;
146
+ }
147
+ if (i.imagesApart) {
148
+ u.push({ id: k.id, alt: k.alt });
149
+ continue;
150
+ }
151
+ A(), n.push({ type: "fileImage", attrs: { id: k.id, alt: k.alt } });
152
+ }
153
+ return A(!n.length), n.map((k) => k.content?.length === 0 ? { ...k, content: void 0 } : k);
154
+ }
155
+ function it(a, o, i) {
156
+ return {
157
+ type: a.ordered ? "orderedList" : "bulletList",
158
+ attrs: a.ordered ? { start: a.start } : void 0,
159
+ content: a.items.map((u) => ({
160
+ type: "listItem",
161
+ content: [
162
+ ...rt(u.parts, (n) => ({ type: "paragraph", content: n }), o, i),
163
+ ...u.list ? [it(u.list, o, i)] : []
164
+ ]
165
+ }))
166
+ };
167
+ }
168
+ function ka(a) {
169
+ if (a.type === "mention") return [{ type: "mention", attrs: { id: a.id, label: a.label } }];
170
+ if (a.type === "code") return [{ type: "text", text: a.text, marks: [{ type: "code" }] }];
171
+ const o = [];
172
+ a.strong && o.push({ type: "bold" }), a.em && o.push({ type: "italic" }), a.strike && o.push({ type: "strike" }), a.type === "link" && o.push({ type: "link", attrs: { href: a.href } });
173
+ const i = [];
174
+ return a.text.split(`
175
+ `).forEach((u, n) => {
176
+ n && i.push({ type: "hardBreak" }), u && i.push(o.length ? { type: "text", text: u, marks: o } : { type: "text", text: u });
177
+ }), i;
178
+ }
179
+ function xa(a, o = {}) {
180
+ const i = o.blockSeparator ?? `
181
+
182
+ `;
183
+ return nt(a.content ?? [], "", i).replace(/\s+$/, "");
184
+ }
185
+ function nt(a, o, i) {
186
+ const u = [];
187
+ for (const n of a) {
188
+ const s = wa(n, o);
189
+ s !== null && u.push(s);
190
+ }
191
+ return u.join(i);
192
+ }
193
+ function wa(a, o, i) {
194
+ switch (a.type) {
195
+ case "paragraph":
196
+ return _e(a.content ?? [], o);
197
+ case "heading":
198
+ return `${"#".repeat(a.attrs?.level === 3 ? 3 : 2)} ${_e(a.content ?? [], o)}`;
199
+ case "bulletList":
200
+ case "orderedList":
201
+ return st(a, 0);
202
+ case "blockquote":
203
+ return nt(a.content ?? [], "", `
204
+
205
+ `).split(`
206
+ `).map((u) => u ? `> ${u}` : ">").join(`
207
+ `);
208
+ case "codeBlock": {
209
+ const u = (a.content ?? []).map((s) => s.text ?? "").join(""), n = "`".repeat(Math.max(2, ...Array.from(u.matchAll(/`+/g), (s) => s[0].length)) + 1);
210
+ return `${n}
211
+ ${u}
212
+ ${n}`;
213
+ }
214
+ case "fileImage":
215
+ return a.attrs?.id ? lt(a) : null;
216
+ default:
217
+ return null;
218
+ }
219
+ }
220
+ const ot = (a) => a.replace(/\n/g, " ").replace(/[\\[\]]/g, "\\$&"), lt = (a) => `![${ot(String(a.attrs?.alt ?? ""))}](file:${a.attrs.id})`, Ma = (a) => a.replace(/[\\*`[\]]/g, "\\$&").replace(/~(?=~)/g, "\\~").replace(/&(?=(?:lt|gt|amp|nbsp);)/g, "\\&"), _a = /^([ \t]*)(?:(#|>|-(?=[ \t]))|(\d{1,9})(?=[.)][ \t]))/gm, Ca = (a) => a.replace(_a, (o, i, u, n) => u ? `${i}\\${u}` : `${i}${n}\\`);
221
+ function st(a, o) {
222
+ const i = a.type === "orderedList", u = Number(a.attrs?.start ?? 1) || 1, n = " ".repeat(Math.min(o, 1)), s = [];
223
+ return (a.content ?? []).forEach((A, k) => {
224
+ const h = i ? `${u + k}. ` : "- ", m = n + " ".repeat(h.length);
225
+ let v = !0;
226
+ for (const c of A.content ?? []) {
227
+ if (c.type === "bulletList" || c.type === "orderedList") {
228
+ s.push(st(c, o + 1));
229
+ continue;
230
+ }
231
+ const f = c.type === "fileImage" ? c.attrs?.id ? lt(c) : "" : c.type === "paragraph" || c.type === "heading" ? _e(c.content ?? [], m) : "";
232
+ !f && !v || (s.push(v ? `${n}${h}${f}` : `${m}${f}`), v = !1);
233
+ }
234
+ v && s.push(`${n}${h}`.trimEnd());
235
+ }), s.join(`
236
+ `);
237
+ }
238
+ const et = [["bold", "**"], ["italic", "*"], ["strike", "~~"]], $a = /^(?:https?:\/\/[^\s/]|mailto:[^\s@]+@)/i;
239
+ function _e(a, o) {
240
+ const i = [];
241
+ for (let h = 0; h < a.length; h++) {
242
+ const m = a[h];
243
+ if (m.type === "hardBreak") {
244
+ i.push({ lineBreak: !0 });
245
+ continue;
246
+ }
247
+ if (m.type === "mention") {
248
+ i.push({ marks: /* @__PURE__ */ new Set(), raw: `@[${m.attrs?.id}]` });
249
+ continue;
250
+ }
251
+ if (m.type !== "text" || !m.text) continue;
252
+ const v = new Set((m.marks ?? []).map((f) => f.type)), c = m.marks?.find((f) => f.type === "link")?.attrs?.href;
253
+ if (c && $a.test(c)) {
254
+ let f = m.text;
255
+ const x = new Set(v);
256
+ for (; a[h + 1]?.type === "text" && a[h + 1].marks?.some((z) => z.type === "link" && z.attrs?.href === c); ) {
257
+ const z = a[++h];
258
+ f += z.text;
259
+ const N = new Set((z.marks ?? []).map(($) => $.type));
260
+ for (const $ of x) N.has($) || x.delete($);
261
+ }
262
+ x.delete("link"), x.delete("code"), i.push({ marks: x, raw: `[${ot(f.trim()) || c}](${c})` });
263
+ continue;
264
+ }
265
+ if (v.has("code")) {
266
+ v.delete("code"), i.push({ marks: v, raw: `\`${m.text.replace(/`/g, "ˋ")}\`` });
267
+ continue;
268
+ }
269
+ i.push({ marks: v, raw: Ma(m.text) });
270
+ }
271
+ let u = "", n = [], s = "";
272
+ const A = (h) => {
273
+ const m = n.findIndex((v) => !h.has(v));
274
+ if (!(m < 0)) {
275
+ for (const v of n.slice(m).reverse()) u += et.find(([c]) => c === v)[1];
276
+ n = n.slice(0, m);
277
+ }
278
+ }, k = (h, m) => {
279
+ let v = 0;
280
+ for (let c = h; c < i.length; c++) {
281
+ const f = i[c];
282
+ if ("lineBreak" in f || !f.marks.has(m)) break;
283
+ v++;
284
+ }
285
+ return v;
286
+ };
287
+ return i.forEach((h, m) => {
288
+ if ("lineBreak" in h) {
289
+ A(/* @__PURE__ */ new Set()), u += s + `
290
+ ` + o, s = "";
291
+ return;
292
+ }
293
+ const v = /^\s*/.exec(h.raw)[0], c = h.raw.slice(v.length).trimEnd();
294
+ if (!c) {
295
+ s += h.raw;
296
+ return;
297
+ }
298
+ A(h.marks), u += s + v, s = h.raw.slice(v.length + c.length);
299
+ const f = et.filter(([x]) => h.marks.has(x) && !n.includes(x)).sort((x, z) => k(m, z[0]) - k(m, x[0]));
300
+ for (const [x, z] of f)
301
+ u += z, n.push(x);
302
+ u += c;
303
+ }), A(/* @__PURE__ */ new Set()), Ca(u + s).replace(/\s+$/, "");
304
+ }
305
+ const Pa = ["data-variant", "data-over"], La = ["aria-label"], Aa = ["aria-label", "title", "aria-pressed", "disabled", "data-ui-rich-tool", "onClick"], Sa = ["aria-label", "title", "disabled"], za = {
306
+ key: 1,
307
+ class: "flex items-center gap-1.5 border-b border-[var(--ui-border-subtle)] px-2 py-1.5",
308
+ "data-ui-rich-link-row": ""
309
+ }, Ea = ["aria-label"], Ba = ["aria-label", "title", "aria-pressed", "onClick"], Ta = ["aria-label"], Ia = ["data-ui-rich-attachment"], Ra = ["src", "alt"], Ha = {
310
+ key: 0,
311
+ class: "absolute inset-0 flex items-center justify-center bg-[color-mix(in_srgb,var(--ui-danger)_35%,transparent)]"
312
+ }, qa = {
313
+ key: 1,
314
+ class: "absolute inset-0 flex items-center justify-center"
315
+ }, Fa = ["aria-label", "onClick"], Na = {
316
+ key: 4,
317
+ class: "flex items-center gap-1.5 border-t border-[var(--ui-border-subtle)] px-2 py-1.5",
318
+ "data-ui-rich-link-row": ""
319
+ }, Ua = ["aria-label"], Va = ["aria-label", "title", "aria-pressed", "disabled", "data-ui-rich-tool", "onClick"], Da = {
320
+ key: 6,
321
+ class: "flex min-w-0 items-center gap-0.5 px-1 pb-1",
322
+ "data-ui-rich-actions": ""
323
+ }, Oa = ["aria-label", "title", "disabled"], ja = ["aria-label", "title", "disabled"], Ka = ["aria-label", "title", "aria-pressed", "aria-expanded", "disabled"], Ga = ["aria-label", "title", "disabled"], Qa = {
324
+ key: 7,
325
+ class: "flex flex-col gap-2 border-t border-[var(--ui-border-subtle)] px-3 py-2"
326
+ }, Wa = {
327
+ "aria-live": "polite",
328
+ class: "empty:hidden",
329
+ "data-ui-rich-notes": ""
330
+ }, oe = Rt(null), lr = /* @__PURE__ */ At({
331
+ inheritAttrs: !1,
332
+ __name: "RichTextEditor",
333
+ props: {
334
+ modelValue: { default: "" },
335
+ variant: { default: "full" },
336
+ headings: { type: Boolean, default: void 0 },
337
+ placeholder: { default: "" },
338
+ disabled: { type: Boolean, default: !1 },
339
+ invalid: { type: Boolean, default: !1 },
340
+ id: { default: void 0 },
341
+ ariaLabel: { default: void 0 },
342
+ maxlength: { default: void 0 },
343
+ maxImages: { default: void 0 },
344
+ upload: { type: Function, default: void 0 },
345
+ files: { type: Function, default: void 0 },
346
+ candidates: { default: () => [] },
347
+ filter: { type: Boolean, default: !0 },
348
+ loading: { type: Boolean, default: !1 },
349
+ sending: { type: Boolean, default: !1 }
350
+ },
351
+ emits: ["update:modelValue", "submit", "search", "pending"],
352
+ setup(a, { emit: o }) {
353
+ const i = a, u = o, n = aa(), s = M(() => i.variant === "compact"), A = M(() => i.headings ?? !s.value), k = M(() => i.maxImages ?? (s.value ? 20 : 50)), h = typeof window < "u" && window.matchMedia?.("(pointer: coarse)").matches, v = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl+", c = q([]), f = /* @__PURE__ */ new Set(), x = q([]);
354
+ let z;
355
+ function N(...e) {
356
+ clearTimeout(z), x.value = e, e.length && (z = setTimeout(() => {
357
+ x.value = [];
358
+ }, 8e3));
359
+ }
360
+ const $ = ra((e, t) => i.upload(e, t), {
361
+ onDone: (e) => ut(e),
362
+ onFailed: (e) => ue(e.key, -1)
363
+ }), U = M(() => $.tasks.filter((e) => e.status !== "done" && e.status !== "canceled")), le = M(() => U.value.length);
364
+ G(() => $.tasks.map((e) => e.status === "uploading" && e.size ? e.loaded / e.size : -2), (e) => {
365
+ e.forEach((t, r) => {
366
+ t >= 0 && ue($.tasks[r].key, t);
367
+ });
368
+ }), G(le, (e) => u("pending", e));
369
+ function ut(e) {
370
+ const t = c.value.find((r) => r.task === e.key);
371
+ t && (t.id = e.result, t.task = void 0), de(e.key, (r, d) => g.value?.view.dispatch(g.value.state.tr.setNodeMarkup(r, void 0, { ...d, id: e.result, upload: null, progress: 1 }))), $.remove(e.key), Y();
372
+ }
373
+ const se = /* @__PURE__ */ new Map();
374
+ function ue(e, t) {
375
+ const r = t < 0 ? -1 : Math.floor(t * 20) / 20;
376
+ se.get(e) !== r && (se.set(e, r), de(e, (d, w) => g.value?.view.dispatch(g.value.state.tr.setNodeMarkup(d, void 0, { ...w, progress: r }).setMeta("addToHistory", !1))));
377
+ }
378
+ function de(e, t) {
379
+ g.value?.state.doc.descendants((r, d) => {
380
+ if (!(r.type.name !== "fileImage" || r.attrs.upload !== e))
381
+ return t(d, r.attrs), !1;
382
+ });
383
+ }
384
+ function dt() {
385
+ if (s.value) return c.value.length;
386
+ let e = 0;
387
+ return g.value?.state.doc.descendants((t) => {
388
+ t.type.name === "fileImage" && e++;
389
+ }), e;
390
+ }
391
+ const ct = (e) => e.split(".").pop()?.toUpperCase() ?? "";
392
+ function ae(e, t) {
393
+ if (!i.upload || i.disabled || !e.length) return;
394
+ const r = [], d = [];
395
+ let w = k.value - dt();
396
+ for (const L of e)
397
+ la(L) ? r.push(n("{name}: {kind} images are not supported; on an iPhone, set Settings > Camera > Formats to Most Compatible", { name: L.name, kind: ct(L.name) || "HEIC" })) : sa(L) ? w <= 0 ? r.push(n("You can add up to {count} images", { count: k.value })) : (d.push(L), w--) : r.push(n("{name} is not a JPEG, PNG, WebP or GIF image", { name: L.name }));
398
+ if (N(...new Set(r)), !d.length) return;
399
+ const Ve = $.add(d).map((L, je) => {
400
+ const Ke = URL.createObjectURL(d[je]);
401
+ return f.add(Ke), { key: L.key, name: d[je].name, src: Ke };
402
+ });
403
+ if (s.value) {
404
+ c.value.push(...Ve.map((L) => ({ key: L.key, task: L.key, name: L.name, alt: "", src: L.src }))), Y();
405
+ return;
406
+ }
407
+ const De = Ve.map((L) => ({ type: "fileImage", attrs: { upload: L.key, src: L.src, alt: "", progress: 0 } })), Oe = g.value?.chain().focus();
408
+ t === void 0 ? Oe?.insertContent(De).run() : Oe?.insertContentAt(t, De).run();
409
+ }
410
+ function ft(e) {
411
+ e.task && $.remove(e.task), c.value = c.value.filter((t) => t.key !== e.key), Y();
412
+ }
413
+ function ce(e) {
414
+ se.delete(e), ue(e, 0), $.retry(e);
415
+ }
416
+ function $e(e) {
417
+ $.remove(e), c.value = c.value.filter((t) => t.task !== e), de(e, (t, r) => {
418
+ g.value?.view.dispatch(g.value.state.tr.delete(t, t + 1));
419
+ }), Y();
420
+ }
421
+ const Pe = q();
422
+ function Le() {
423
+ Pe.value?.click();
424
+ }
425
+ function pt(e) {
426
+ const t = e.target;
427
+ ae(Array.from(t.files ?? [])), t.value = "";
428
+ }
429
+ const fe = [];
430
+ function mt(e) {
431
+ const t = new DOMParser().parseFromString(e, "text/html");
432
+ let r = !1;
433
+ for (const d of Array.from(t.querySelectorAll("img"))) {
434
+ if (d.hasAttribute("data-file-id")) continue;
435
+ const w = d.getAttribute("src") ?? "";
436
+ /^data:image\//i.test(w) || w && new URL(w, location.href).origin === location.origin && !/^data:/i.test(w) ? fe.push(w) : r = !0, d.remove();
437
+ }
438
+ return r && N(n("Images from other websites are not pasted; save them first and add them as files")), fe.length && setTimeout(vt), t.body.innerHTML;
439
+ }
440
+ async function vt() {
441
+ const e = fe.splice(0), t = [];
442
+ for (const [r, d] of e.entries())
443
+ try {
444
+ const w = await (await fetch(d)).blob();
445
+ t.push(new File([w], `pasted-${r + 1}.${w.type.split("/")[1] ?? "png"}`, { type: w.type }));
446
+ } catch {
447
+ }
448
+ ae(t);
449
+ }
450
+ const pe = St(), b = zt({
451
+ open: !1,
452
+ query: "",
453
+ active: 0,
454
+ reference: null,
455
+ command: null
456
+ }), W = M(() => {
457
+ const e = b.query.toLocaleLowerCase();
458
+ return i.filter && e ? i.candidates.filter((t) => [t.label, t.id, t.description ?? ""].some((r) => r.toLocaleLowerCase().includes(e))) : i.candidates;
459
+ });
460
+ G(() => W.value.length, (e) => {
461
+ b.active >= e && (b.active = 0);
462
+ });
463
+ function Ae(e) {
464
+ const t = e.clientRect;
465
+ b.reference = t ? { getBoundingClientRect: () => t() ?? new DOMRect() } : null, b.command = (r) => e.command(r), !(e.editor.view.composing && b.open) && ((b.query !== e.query || !b.open) && (b.query = e.query, b.active = 0, u("search", e.query)), b.open = !0);
466
+ }
467
+ function Se(e) {
468
+ b.command?.({ id: e.id, label: e.label }), b.open = !1;
469
+ }
470
+ function bt({ event: e }) {
471
+ if (e.isComposing || e.keyCode === 229) return !1;
472
+ const t = W.value.length;
473
+ if (e.key === "ArrowDown" && t) b.active = (b.active + 1) % t;
474
+ else if (e.key === "ArrowUp" && t) b.active = (b.active - 1 + t) % t;
475
+ else if ((e.key === "Enter" || e.key === "Tab") && t) Se(W.value[b.active]);
476
+ else if (e.key === "Escape") b.open = !1;
477
+ else return !1;
478
+ return !0;
479
+ }
480
+ const ht = (e) => `${pe}-${e}`, S = () => g.value.chain().focus(), P = (e, t) => g.value?.isActive(e, t) ?? !1, gt = [
481
+ { key: "bold", label: "Bold", icon: Nt, shortcut: `${v}B`, active: () => P("bold"), run: () => S().toggleBold().run() },
482
+ { key: "italic", label: "Italic", icon: Ut, shortcut: `${v}I`, active: () => P("italic"), run: () => S().toggleItalic().run() },
483
+ { key: "link", label: "Link", icon: Vt, shortcut: `${v}K`, active: () => P("link"), run: () => He() },
484
+ { key: "bulletList", label: "Bulleted list", icon: Dt, active: () => P("bulletList"), run: () => S().toggleBulletList().run() },
485
+ { key: "orderedList", label: "Numbered list", icon: Ot, active: () => P("orderedList"), run: () => S().toggleOrderedList().run() },
486
+ { key: "h2", label: "Heading", icon: jt, active: () => P("heading", { level: 2 }), run: () => S().toggleHeading({ level: 2 }).run(), full: !0 },
487
+ { key: "h3", label: "Subheading", icon: Kt, active: () => P("heading", { level: 3 }), run: () => S().toggleHeading({ level: 3 }).run(), full: !0 },
488
+ { key: "code", label: "Code", icon: Gt, active: () => P("code"), run: () => S().toggleCode().run() },
489
+ { key: "quote", label: "Quote", icon: Qt, active: () => P("blockquote"), run: () => S().toggleBlockquote().run() },
490
+ { key: "codeBlock", label: "Code block", icon: Wt, active: () => P("codeBlock"), run: () => S().toggleCodeBlock().run() },
491
+ { key: "strike", label: "Strikethrough", icon: Jt, active: () => P("strike"), run: () => S().toggleStrike().run() }
492
+ ], re = M(() => gt.filter((e) => !e.full || A.value)), yt = ["bold", "italic", "link", "code", "bulletList"], kt = M(() => re.value.filter((e) => yt.includes(e.key))), V = (e) => e.shortcut ? `${n(e.label)} (${e.shortcut})` : n(e.label), me = /* @__PURE__ */ Symbol("rich-text-editor"), J = M(() => oe.value === me);
493
+ function ze() {
494
+ oe.value = J.value ? null : me, g.value?.commands.focus();
495
+ }
496
+ const ve = q(), be = q(1 / 0);
497
+ let he;
498
+ const ge = 34, ie = M(() => [
499
+ ...re.value.map((e) => ({ key: e.key, label: e.label, icon: e.icon, action: e })),
500
+ ...i.upload ? [{ key: "image", label: "Add image", icon: Qe, action: void 0 }] : [],
501
+ { key: "mention", label: "Mention someone", icon: We, action: void 0 }
502
+ ]), Ee = M(() => ie.value.length * ge <= be.value ? ie.value.length : Math.max(1, Math.floor((be.value - ge) / ge))), xt = M(() => ie.value.slice(0, Ee.value)), Be = M(() => ie.value.slice(Ee.value).map((e) => ({ key: e.key, label: n(e.label), icon: e.icon })));
503
+ function Te(e) {
504
+ if (e === "image") return Le();
505
+ if (e === "mention") return Ie();
506
+ re.value.find((t) => t.key === e)?.run();
507
+ }
508
+ function Ie() {
509
+ const e = g.value;
510
+ if (!e) return;
511
+ const { $from: t } = e.state.selection, r = t.parent.textBetween(Math.max(0, t.parentOffset - 1), t.parentOffset, `
512
+ `, " ");
513
+ S().insertContent(r && !/\s/.test(r) ? " @" : "@").run();
514
+ }
515
+ const Re = /^(?:https?:\/\/[^\s/]|mailto:[^\s@]+@)/i, D = q(!1), O = q(""), ne = q();
516
+ function He() {
517
+ return O.value = g.value?.getAttributes("link").href ?? "", D.value = !0, setTimeout(() => (ne.value?.$el?.querySelector("input") ?? ne.value?.$el)?.focus?.()), !0;
518
+ }
519
+ function wt(e) {
520
+ const t = e.trim();
521
+ return !t || Re.test(t) ? t : /^[^\s@/]+@[^\s@]+\.[^\s@]+$/.test(t) ? `mailto:${t}` : /^[^\s]+\.[^\s]+$/.test(t) ? `https://${t}` : t;
522
+ }
523
+ function ye() {
524
+ const e = wt(O.value);
525
+ if (!e) return ke();
526
+ if (!Re.test(e)) return N(n("Links start with http://, https:// or mailto:"));
527
+ g.value.state.selection.empty && !P("link") ? S().insertContent({ type: "text", text: e, marks: [{ type: "link", attrs: { href: e } }] }).run() : S().extendMarkRange("link").setLink({ href: e }).run(), j();
528
+ }
529
+ function ke() {
530
+ S().extendMarkRange("link").unsetLink().run(), j();
531
+ }
532
+ function j() {
533
+ D.value = !1, g.value?.commands.focus();
534
+ }
535
+ function qe(e) {
536
+ e.isComposing || e.keyCode === 229 || (e.key === "Enter" ? (e.preventDefault(), ye()) : e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), j()));
537
+ }
538
+ let X = i.modelValue;
539
+ function Mt() {
540
+ const e = g.value?.getJSON() ?? {}, t = xa(e, s.value ? { blockSeparator: `
541
+ ` } : {});
542
+ if (!s.value) return t;
543
+ const r = c.value.filter((d) => d.id).map((d) => `![${d.alt.replace(/[[\]\n]/g, " ")}](file:${d.id})`);
544
+ return [t, r.join(`
545
+ `)].filter(Boolean).join(`
546
+
547
+ `);
548
+ }
549
+ function Y() {
550
+ const e = Mt();
551
+ e !== X && (X = e, u("update:modelValue", e));
552
+ }
553
+ function Fe(e) {
554
+ const { doc: t, images: r } = ya(e, { people: i.candidates, headings: A.value, imagesApart: s.value });
555
+ for (const d of c.value) d.task && $.remove(d.task);
556
+ return c.value = r.map((d) => ({ key: d.id, id: d.id, name: i.files?.(d.id)?.name ?? d.alt, alt: d.alt })), t;
557
+ }
558
+ const g = Ht({
559
+ content: Fe(i.modelValue),
560
+ editable: !i.disabled,
561
+ extensions: ga({
562
+ headings: A.value,
563
+ placeholder: i.placeholder,
564
+ image: { file: (e) => i.files?.(e), labels: { uploading: n("Uploading"), failed: n("Upload failed"), missing: n("File is missing") } },
565
+ mention: {
566
+ items: () => [],
567
+ allowSpaces: !1,
568
+ render: () => ({ onStart: Ae, onUpdate: Ae, onExit: () => {
569
+ b.open = !1;
570
+ }, onKeyDown: bt })
571
+ },
572
+ submit: () => s.value ? (Ue(), !0) : !1,
573
+ link: He,
574
+ escape: () => {
575
+ if (D.value) j();
576
+ else if (J.value) ze();
577
+ else return !1;
578
+ return !0;
579
+ }
580
+ }),
581
+ editorProps: {
582
+ attributes: {
583
+ class: "outline-none",
584
+ role: "textbox",
585
+ "aria-multiline": "true",
586
+ "data-ui-rich-editor-content": ""
587
+ },
588
+ transformPastedHTML: mt,
589
+ handlePaste: (e, t) => {
590
+ const r = Array.from(t.clipboardData?.files ?? []);
591
+ if (!r.length || !i.upload) return !1;
592
+ const d = t.clipboardData?.getData("text/html") ?? "";
593
+ return d && new DOMParser().parseFromString(d, "text/html").body.textContent?.trim() ? !1 : (t.preventDefault(), ae(r), !0);
594
+ },
595
+ handleDrop: (e, t, r, d) => {
596
+ const w = Array.from(t.dataTransfer?.files ?? []);
597
+ return d || !w.length || !i.upload ? !1 : (t.preventDefault(), ae(w, e.posAtCoords({ left: t.clientX, top: t.clientY })?.pos), !0);
598
+ }
599
+ },
600
+ onUpdate: () => Y()
601
+ });
602
+ G(() => i.modelValue, (e) => {
603
+ e === X || !g.value || (X = e, g.value.commands.setContent(Fe(e), { emitUpdate: !1 }));
604
+ }), G(() => i.disabled, (e) => g.value?.setEditable(!e));
605
+ const _t = M(() => i.maxlength === void 0 ? 0 : Array.from(i.modelValue).length), K = M(() => (i.maxlength ?? 0) - _t.value), R = M(() => i.maxlength !== void 0 && K.value < 0), xe = M(() => i.maxlength !== void 0 && K.value <= i.maxlength * 0.1), Ct = M(() => !i.modelValue.trim()), Ne = M(() => !i.disabled && !i.sending && !Ct.value && !R.value && !le.value), $t = M(() => ({
606
+ id: i.id,
607
+ "aria-label": i.ariaLabel ?? (i.placeholder || void 0),
608
+ "aria-invalid": i.invalid || R.value ? "true" : void 0,
609
+ "aria-disabled": i.disabled ? "true" : void 0,
610
+ "aria-autocomplete": "list",
611
+ "aria-controls": b.open ? pe : void 0,
612
+ "aria-activedescendant": b.open && W.value.length ? ht(b.active) : void 0
613
+ }));
614
+ G([g, $t], ([e, t]) => {
615
+ const r = e?.view.dom;
616
+ if (r)
617
+ for (const [d, w] of Object.entries(t))
618
+ w === void 0 ? r.removeAttribute(d) : r.setAttribute(d, String(w));
619
+ }, { immediate: !0 });
620
+ function Ue() {
621
+ if (!Ne.value) {
622
+ le.value && N(n("Wait for the images to finish uploading"));
623
+ return;
624
+ }
625
+ u("submit", X);
626
+ }
627
+ const Pt = ({ from: e, to: t }) => !h && e !== t && !D.value && !!g.value?.isEditable && !P("codeBlock") && !P("fileImage");
628
+ Et(() => {
629
+ typeof ResizeObserver > "u" || !ve.value || (he = new ResizeObserver(([e]) => {
630
+ be.value = e.contentRect.width;
631
+ }), he.observe(ve.value));
632
+ }), Bt(() => {
633
+ he?.disconnect(), $.cancelAll(), clearTimeout(z), oe.value === me && (oe.value = null);
634
+ for (const e of f) URL.revokeObjectURL(e);
635
+ });
636
+ const H = "relative flex size-8 shrink-0 items-center justify-center rounded-[var(--ui-radius-sm)] border-0 bg-transparent p-0 text-[var(--ui-text-secondary)] outline-none hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-text)] focus-visible:shadow-[var(--ui-shadow-focus)] disabled:pointer-events-none disabled:text-[var(--ui-text-disabled)] aria-pressed:bg-[var(--ui-primary-soft)] aria-pressed:text-[var(--ui-primary)] [@media(pointer:coarse)]:size-11", Lt = [
637
+ "min-w-0 text-[length:var(--ui-font-size)] leading-5 text-[var(--ui-text)] [overflow-wrap:anywhere]",
638
+ "[&_.ProseMirror]:outline-none [&_.ProseMirror]:whitespace-pre-wrap [&_.ProseMirror_p]:m-0 [&_.ProseMirror>*+*]:mt-2",
639
+ "[&_.ProseMirror_h2]:m-0 [&_.ProseMirror_h2]:text-[1.25em] [&_.ProseMirror_h2]:font-semibold [&_.ProseMirror_h3]:m-0 [&_.ProseMirror_h3]:text-[1.1em] [&_.ProseMirror_h3]:font-semibold",
640
+ "[&_.ProseMirror_ul]:m-0 [&_.ProseMirror_ul]:list-disc [&_.ProseMirror_ul]:ps-5 [&_.ProseMirror_ol]:m-0 [&_.ProseMirror_ol]:list-decimal [&_.ProseMirror_ol]:ps-5",
641
+ "[&_.ProseMirror_blockquote]:m-0 [&_.ProseMirror_blockquote]:border-s-[3px] [&_.ProseMirror_blockquote]:border-[var(--ui-border-strong)] [&_.ProseMirror_blockquote]:ps-3 [&_.ProseMirror_blockquote]:text-[var(--ui-text-secondary)]",
642
+ "[&_.ProseMirror_pre]:m-0 [&_.ProseMirror_pre]:rounded-[var(--ui-radius-md)] [&_.ProseMirror_pre]:bg-[var(--ui-surface-subtle)] [&_.ProseMirror_pre]:px-3 [&_.ProseMirror_pre]:py-2 [&_.ProseMirror_pre]:font-[family-name:var(--ui-font-mono)] [&_.ProseMirror_pre]:text-[0.92em]",
643
+ "[&_.ProseMirror_:not(pre)>code]:rounded-[var(--ui-radius-sm)] [&_.ProseMirror_:not(pre)>code]:bg-[var(--ui-surface-subtle)] [&_.ProseMirror_:not(pre)>code]:px-1 [&_.ProseMirror_:not(pre)>code]:font-[family-name:var(--ui-font-mono)] [&_.ProseMirror_:not(pre)>code]:text-[0.92em]",
644
+ "[&_.ProseMirror_a]:text-[var(--ui-primary)] [&_.ProseMirror_a]:underline [&_.ProseMirror_a]:underline-offset-2",
645
+ "[&_.is-editor-empty:first-child]:before:pointer-events-none [&_.is-editor-empty:first-child]:before:float-start [&_.is-editor-empty:first-child]:before:h-0 [&_.is-editor-empty:first-child]:before:text-[var(--ui-text-muted)] [&_.is-editor-empty:first-child]:before:content-[attr(data-placeholder)]"
646
+ ];
647
+ return (e, t) => (p(), y("div", Tt(e.$attrs, {
648
+ class: [
649
+ "flex min-w-0 flex-col rounded-[var(--ui-radius-control)] border bg-[var(--ui-surface)] transition-[border-color,box-shadow] duration-[var(--ui-motion-fast)] focus-within:shadow-[var(--ui-shadow-focus)]",
650
+ a.invalid || R.value ? "border-[var(--ui-danger)]" : "border-[var(--ui-border)] focus-within:border-[var(--ui-primary)]",
651
+ a.disabled && "bg-[var(--ui-surface-subtle)] text-[var(--ui-text-disabled)]"
652
+ ],
653
+ "data-variant": a.variant,
654
+ "data-over": R.value ? "" : void 0,
655
+ "data-ui-rich-editor": "",
656
+ "data-syno-pkg-land-ui": ""
657
+ }), [
658
+ B("input", {
659
+ ref_key: "picker",
660
+ ref: Pe,
661
+ type: "file",
662
+ class: "sr-only",
663
+ tabindex: "-1",
664
+ "aria-hidden": "true",
665
+ accept: "image/jpeg,image/png,image/webp,image/gif",
666
+ multiple: "",
667
+ onChange: pt
668
+ }, null, 544),
669
+ s.value ? C("", !0) : (p(), y("div", {
670
+ key: 0,
671
+ ref_key: "toolbar",
672
+ ref: ve,
673
+ role: "toolbar",
674
+ "aria-label": l(n)("Formatting"),
675
+ class: "sticky top-0 z-[1] flex min-w-0 items-center gap-0.5 overflow-hidden rounded-t-[var(--ui-radius-control)] border-b border-[var(--ui-border-subtle)] bg-[var(--ui-surface)] px-1 py-1",
676
+ "data-ui-rich-toolbar": ""
677
+ }, [
678
+ (p(!0), y(Q, null, Z(xt.value, (r) => (p(), y("button", {
679
+ key: r.key,
680
+ type: "button",
681
+ class: E(H),
682
+ "aria-label": r.action ? V(r.action) : l(n)(r.label),
683
+ title: r.action ? V(r.action) : l(n)(r.label),
684
+ "aria-pressed": r.action?.active ? r.action.active() : void 0,
685
+ disabled: a.disabled,
686
+ "data-ui-rich-tool": r.key,
687
+ onMousedown: t[0] || (t[0] = F(() => {
688
+ }, ["prevent"])),
689
+ onClick: (d) => Te(r.key)
690
+ }, [
691
+ (p(), T(we(r.icon), {
692
+ class: "size-4",
693
+ "aria-hidden": "true"
694
+ }))
695
+ ], 40, Aa))), 128)),
696
+ Be.value.length ? (p(), T(l(ia), {
697
+ key: 0,
698
+ items: Be.value,
699
+ align: "end",
700
+ onSelect: Te
701
+ }, {
702
+ trigger: I(() => [
703
+ B("button", {
704
+ type: "button",
705
+ class: E(H),
706
+ "aria-label": l(n)("More"),
707
+ title: l(n)("More"),
708
+ disabled: a.disabled,
709
+ "data-ui-rich-more": "",
710
+ onMousedown: t[1] || (t[1] = F(() => {
711
+ }, ["prevent"]))
712
+ }, [
713
+ _(l(Xt), {
714
+ class: "size-4",
715
+ "aria-hidden": "true"
716
+ })
717
+ ], 40, Sa)
718
+ ]),
719
+ _: 1
720
+ }, 8, ["items"])) : C("", !0)
721
+ ], 8, La)),
722
+ D.value && !s.value ? (p(), y("div", za, [
723
+ _(l(Xe), {
724
+ ref_key: "linkInput",
725
+ ref: ne,
726
+ modelValue: O.value,
727
+ "onUpdate:modelValue": t[2] || (t[2] = (r) => O.value = r),
728
+ size: "sm",
729
+ class: "min-w-0 flex-1",
730
+ type: "url",
731
+ inputmode: "url",
732
+ "aria-label": l(n)("Link address"),
733
+ placeholder: "https://",
734
+ onKeydown: qe
735
+ }, null, 8, ["modelValue", "aria-label"]),
736
+ _(l(Ye), {
737
+ size: "sm",
738
+ variant: "primary",
739
+ onClick: ye
740
+ }, {
741
+ default: I(() => [
742
+ Ge(ee(l(n)("Apply")), 1)
743
+ ]),
744
+ _: 1
745
+ }),
746
+ P("link") ? (p(), T(l(te), {
747
+ key: 0,
748
+ size: "sm",
749
+ label: l(n)("Remove link"),
750
+ onClick: ke
751
+ }, {
752
+ default: I(() => [
753
+ _(l(Je), {
754
+ class: "size-4",
755
+ "aria-hidden": "true"
756
+ })
757
+ ]),
758
+ _: 1
759
+ }, 8, ["label"])) : C("", !0),
760
+ _(l(te), {
761
+ size: "sm",
762
+ label: l(n)("Close"),
763
+ onClick: j
764
+ }, {
765
+ default: I(() => [
766
+ _(l(Me), {
767
+ class: "size-4",
768
+ "aria-hidden": "true"
769
+ })
770
+ ]),
771
+ _: 1
772
+ }, 8, ["label"])
773
+ ])) : C("", !0),
774
+ _(l(qt), {
775
+ editor: l(g),
776
+ class: E([Lt, s.value ? "max-h-[calc(8lh+16px)] overflow-y-auto px-2.5 py-2" : "min-h-32 px-3 py-2.5"])
777
+ }, null, 8, ["editor", "class"]),
778
+ _(l(na), {
779
+ id: l(pe),
780
+ open: b.open,
781
+ reference: b.reference,
782
+ people: W.value,
783
+ active: b.active,
784
+ loading: a.loading,
785
+ boundary: l(g)?.view.dom,
786
+ onChoose: Se,
787
+ onHover: t[3] || (t[3] = (r) => {
788
+ b.active = r;
789
+ }),
790
+ onClose: t[4] || (t[4] = (r) => b.open = !1)
791
+ }, null, 8, ["id", "open", "reference", "people", "active", "loading", "boundary"]),
792
+ l(g) ? (p(), T(l(Ft), {
793
+ key: 2,
794
+ editor: l(g),
795
+ "should-show": Pt,
796
+ options: { placement: "top", offset: 6 }
797
+ }, {
798
+ default: I(() => [
799
+ B("div", {
800
+ role: "toolbar",
801
+ "aria-label": l(n)("Formatting"),
802
+ class: "flex items-center gap-0.5 rounded-[var(--ui-radius-md)] border border-[var(--ui-border)] bg-[var(--ui-surface-raised)] p-0.5 shadow-[var(--ui-shadow-menu)]",
803
+ "data-ui-rich-bubble": ""
804
+ }, [
805
+ (p(!0), y(Q, null, Z(kt.value, (r) => (p(), y("button", {
806
+ key: r.key,
807
+ type: "button",
808
+ class: E(H),
809
+ "aria-label": V(r),
810
+ title: V(r),
811
+ "aria-pressed": r.active?.(),
812
+ onMousedown: t[5] || (t[5] = F(() => {
813
+ }, ["prevent"])),
814
+ onClick: (d) => r.run()
815
+ }, [
816
+ (p(), T(we(r.icon), {
817
+ class: "size-4",
818
+ "aria-hidden": "true"
819
+ }))
820
+ ], 40, Ba))), 128))
821
+ ], 8, Ea)
822
+ ]),
823
+ _: 1
824
+ }, 8, ["editor"])) : C("", !0),
825
+ s.value && c.value.length ? (p(), y("ul", {
826
+ key: 3,
827
+ class: "m-0 flex list-none flex-wrap gap-2 px-2.5 pb-2 pt-0.5",
828
+ "aria-label": l(n)("Images"),
829
+ "data-ui-rich-attachments": ""
830
+ }, [
831
+ (p(!0), y(Q, null, Z(c.value, (r) => (p(), y("li", {
832
+ key: r.key,
833
+ class: "relative",
834
+ "data-ui-rich-attachment": r.id ?? ""
835
+ }, [
836
+ B("div", {
837
+ class: "relative flex size-16 items-center justify-center overflow-hidden rounded-[var(--ui-radius-md)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-subtle)]",
838
+ style: It({ background: a.files?.(r.id ?? "")?.dominant })
839
+ }, [
840
+ r.src ?? a.files?.(r.id ?? "")?.thumb ? (p(), y("img", {
841
+ key: 0,
842
+ src: r.src ?? a.files?.(r.id ?? "")?.thumb,
843
+ alt: r.name,
844
+ class: E(["size-full object-cover", r.task && "opacity-60"]),
845
+ draggable: "false"
846
+ }, null, 10, Ra)) : C("", !0),
847
+ r.task ? (p(), y(Q, { key: 1 }, [
848
+ l($).tasks.find((d) => d.key === r.task)?.status === "failed" ? (p(), y("span", Ha, [
849
+ _(l(te), {
850
+ size: "sm",
851
+ variant: "secondary",
852
+ label: l(n)("Retry {name}", { name: r.name }),
853
+ onClick: (d) => ce(r.task)
854
+ }, {
855
+ default: I(() => [
856
+ _(l(Yt), {
857
+ class: "size-4",
858
+ "aria-hidden": "true"
859
+ })
860
+ ]),
861
+ _: 1
862
+ }, 8, ["label", "onClick"])
863
+ ])) : (p(), y("span", qa, [
864
+ _(l(Ze), {
865
+ size: 20,
866
+ inline: "",
867
+ label: l(n)("Uploading")
868
+ }, null, 8, ["label"])
869
+ ]))
870
+ ], 64)) : C("", !0)
871
+ ], 4),
872
+ B("button", {
873
+ type: "button",
874
+ class: "absolute -end-1.5 -top-1.5 flex size-5 items-center justify-center rounded-full border border-[var(--ui-surface)] bg-[var(--ui-text-secondary)] p-0 text-[var(--ui-surface)] outline-none hover:bg-[var(--ui-text)] focus-visible:shadow-[var(--ui-shadow-focus)] after:absolute after:-inset-3 [@media(pointer:fine)]:after:hidden",
875
+ "aria-label": l(n)("Remove {name}", { name: r.name }),
876
+ "data-ui-rich-attachment-remove": "",
877
+ onClick: (d) => ft(r)
878
+ }, [
879
+ _(l(Me), {
880
+ class: "size-3",
881
+ "aria-hidden": "true"
882
+ })
883
+ ], 8, Fa)
884
+ ], 8, Ia))), 128))
885
+ ], 8, Ta)) : C("", !0),
886
+ D.value && s.value ? (p(), y("div", Na, [
887
+ _(l(Xe), {
888
+ ref_key: "linkInput",
889
+ ref: ne,
890
+ modelValue: O.value,
891
+ "onUpdate:modelValue": t[6] || (t[6] = (r) => O.value = r),
892
+ size: "sm",
893
+ class: "min-w-0 flex-1",
894
+ type: "url",
895
+ inputmode: "url",
896
+ "aria-label": l(n)("Link address"),
897
+ placeholder: "https://",
898
+ onKeydown: qe
899
+ }, null, 8, ["modelValue", "aria-label"]),
900
+ _(l(Ye), {
901
+ size: "sm",
902
+ variant: "primary",
903
+ onClick: ye
904
+ }, {
905
+ default: I(() => [
906
+ Ge(ee(l(n)("Apply")), 1)
907
+ ]),
908
+ _: 1
909
+ }),
910
+ P("link") ? (p(), T(l(te), {
911
+ key: 0,
912
+ size: "sm",
913
+ label: l(n)("Remove link"),
914
+ onClick: ke
915
+ }, {
916
+ default: I(() => [
917
+ _(l(Je), {
918
+ class: "size-4",
919
+ "aria-hidden": "true"
920
+ })
921
+ ]),
922
+ _: 1
923
+ }, 8, ["label"])) : C("", !0),
924
+ _(l(te), {
925
+ size: "sm",
926
+ label: l(n)("Close"),
927
+ onClick: j
928
+ }, {
929
+ default: I(() => [
930
+ _(l(Me), {
931
+ class: "size-4",
932
+ "aria-hidden": "true"
933
+ })
934
+ ]),
935
+ _: 1
936
+ }, 8, ["label"])
937
+ ])) : C("", !0),
938
+ s.value && J.value ? (p(), y("div", {
939
+ key: 5,
940
+ role: "toolbar",
941
+ "aria-label": l(n)("Formatting"),
942
+ class: "flex min-w-0 items-center gap-0.5 overflow-x-auto border-t border-[var(--ui-border-subtle)] px-1 py-0.5",
943
+ "data-ui-rich-format-row": ""
944
+ }, [
945
+ (p(!0), y(Q, null, Z(re.value, (r) => (p(), y("button", {
946
+ key: r.key,
947
+ type: "button",
948
+ class: E(H),
949
+ "aria-label": V(r),
950
+ title: V(r),
951
+ "aria-pressed": r.active?.(),
952
+ disabled: a.disabled,
953
+ "data-ui-rich-tool": r.key,
954
+ onMousedown: t[7] || (t[7] = F(() => {
955
+ }, ["prevent"])),
956
+ onClick: (d) => r.run()
957
+ }, [
958
+ (p(), T(we(r.icon), {
959
+ class: "size-4",
960
+ "aria-hidden": "true"
961
+ }))
962
+ ], 40, Va))), 128))
963
+ ], 8, Ua)) : C("", !0),
964
+ s.value ? (p(), y("div", Da, [
965
+ a.upload ? (p(), y("button", {
966
+ key: 0,
967
+ type: "button",
968
+ class: E(H),
969
+ "aria-label": l(n)("Add image"),
970
+ title: l(n)("Add image"),
971
+ disabled: a.disabled,
972
+ "data-ui-rich-tool": "image",
973
+ onMousedown: t[8] || (t[8] = F(() => {
974
+ }, ["prevent"])),
975
+ onClick: Le
976
+ }, [
977
+ _(l(Qe), {
978
+ class: "size-4",
979
+ "aria-hidden": "true"
980
+ })
981
+ ], 40, Oa)) : C("", !0),
982
+ B("button", {
983
+ type: "button",
984
+ class: E(H),
985
+ "aria-label": l(n)("Mention someone"),
986
+ title: l(n)("Mention someone"),
987
+ disabled: a.disabled,
988
+ "data-ui-rich-tool": "mention",
989
+ onMousedown: t[9] || (t[9] = F(() => {
990
+ }, ["prevent"])),
991
+ onClick: Ie
992
+ }, [
993
+ _(l(We), {
994
+ class: "size-4",
995
+ "aria-hidden": "true"
996
+ })
997
+ ], 40, ja),
998
+ B("button", {
999
+ type: "button",
1000
+ class: E(H),
1001
+ "aria-label": l(n)("Formatting"),
1002
+ title: l(n)("Formatting"),
1003
+ "aria-pressed": J.value,
1004
+ "aria-expanded": J.value,
1005
+ disabled: a.disabled,
1006
+ "data-ui-rich-format-toggle": "",
1007
+ onMousedown: t[10] || (t[10] = F(() => {
1008
+ }, ["prevent"])),
1009
+ onClick: ze
1010
+ }, [
1011
+ _(l(Zt), {
1012
+ class: "size-4",
1013
+ "aria-hidden": "true"
1014
+ })
1015
+ ], 40, Ka),
1016
+ t[14] || (t[14] = B("span", { class: "flex-1" }, null, -1)),
1017
+ xe.value ? (p(), y("span", {
1018
+ key: 1,
1019
+ "aria-live": "polite",
1020
+ class: E(["px-1 text-[length:var(--ui-font-size-sm)] tabular-nums", R.value ? "text-[var(--ui-danger-text)]" : "text-[var(--ui-text-secondary)]"]),
1021
+ "data-ui-rich-count": ""
1022
+ }, ee(R.value ? l(n)("{count} characters over the limit", { count: -K.value }) : l(n)("{count} characters left", { count: K.value })), 3)) : C("", !0),
1023
+ B("button", {
1024
+ type: "button",
1025
+ class: E([H, "text-[var(--ui-primary)] disabled:text-[var(--ui-text-disabled)]"]),
1026
+ "aria-label": `${l(n)("Send")} (${l(v)}Enter)`,
1027
+ title: `${l(n)("Send")} (${l(v)}Enter)`,
1028
+ disabled: !Ne.value,
1029
+ "data-ui-rich-send": "",
1030
+ onMousedown: t[11] || (t[11] = F(() => {
1031
+ }, ["prevent"])),
1032
+ onClick: Ue
1033
+ }, [
1034
+ a.sending ? (p(), T(l(Ze), {
1035
+ key: 0,
1036
+ size: 16,
1037
+ inline: "",
1038
+ label: l(n)("Sending")
1039
+ }, null, 8, ["label"])) : (p(), T(l(ea), {
1040
+ key: 1,
1041
+ class: "size-4 rtl:-scale-x-100",
1042
+ "aria-hidden": "true"
1043
+ }))
1044
+ ], 42, Ga)
1045
+ ])) : C("", !0),
1046
+ !s.value && (xe.value || U.value.length) ? (p(), y("div", Qa, [
1047
+ xe.value ? (p(), y("span", {
1048
+ key: 0,
1049
+ "aria-live": "polite",
1050
+ class: E(["self-end text-[length:var(--ui-font-size-sm)] tabular-nums", R.value ? "text-[var(--ui-danger-text)]" : "text-[var(--ui-text-secondary)]"]),
1051
+ "data-ui-rich-count": ""
1052
+ }, ee(R.value ? l(n)("{count} characters over the limit", { count: -K.value }) : l(n)("{count} characters left", { count: K.value })), 3)) : C("", !0),
1053
+ U.value.length ? (p(), T(l(oa), {
1054
+ key: 1,
1055
+ tasks: U.value,
1056
+ onRetry: ce,
1057
+ onCancel: $e,
1058
+ onRetryAll: t[12] || (t[12] = (r) => U.value.forEach((d) => d.status === "failed" && ce(d.key))),
1059
+ onCancelAll: t[13] || (t[13] = (r) => U.value.forEach((d) => $e(d.key)))
1060
+ }, null, 8, ["tasks"])) : C("", !0)
1061
+ ])) : C("", !0),
1062
+ B("div", Wa, [
1063
+ (p(!0), y(Q, null, Z(x.value, (r) => (p(), y("p", {
1064
+ key: r,
1065
+ class: "m-0 border-t border-[var(--ui-border-subtle)] px-3 py-1.5 text-[length:var(--ui-font-size-sm)] text-[var(--ui-danger-text)]"
1066
+ }, ee(r), 1))), 128))
1067
+ ])
1068
+ ], 16, Pa));
1069
+ }
1070
+ });
1071
+ export {
1072
+ lr as RichTextEditor,
1073
+ xa as docToMarkdown,
1074
+ ya as markdownToDoc
1075
+ };