@editora/core 1.0.7 → 1.0.9

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 (87) hide show
  1. package/README.md +5 -0
  2. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-58d12bed.mjs} +23 -12
  3. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-289a112a.mjs} +112 -102
  4. package/dist/ApprovalWorkflowPlugin.native-449ce66c.mjs +1115 -0
  5. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-8aceb5cc.mjs} +16 -9
  6. package/dist/{BlockquotePlugin.native-JFmOLsxN.mjs → BlockquotePlugin.native-3541c714.mjs} +3 -2
  7. package/dist/BlocksLibraryPlugin.native-1cc51e63.mjs +1386 -0
  8. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-f9d7f8e4.mjs} +1 -1
  9. package/dist/{CapitalizationPlugin.native-DOMsh5R7.mjs → CapitalizationPlugin.native-42c135dc.mjs} +3 -2
  10. package/dist/{ChecklistPlugin.native-nuSSEFNI.mjs → ChecklistPlugin.native-3b397ee9.mjs} +43 -22
  11. package/dist/CitationsPlugin.native-169fb1e8.mjs +1532 -0
  12. package/dist/{ClearFormattingPlugin.native-Bq_XcTh2.mjs → ClearFormattingPlugin.native-77baa514.mjs} +11 -6
  13. package/dist/{CodePlugin.native-DlpTPdkd.mjs → CodePlugin.native-989cf0aa.mjs} +629 -580
  14. package/dist/{CodeSamplePlugin.native-CgGoH-X4.mjs → CodeSamplePlugin.native-6cc0148e.mjs} +19 -10
  15. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-03659874.mjs} +55 -28
  16. package/dist/ConditionalContentPlugin.native-4983143a.mjs +1424 -0
  17. package/dist/ContentRulesPlugin.native-63ed405b.mjs +1149 -0
  18. package/dist/DataBindingPlugin.native-427e9d75.mjs +956 -0
  19. package/dist/{DirectionPlugin.native-CDnbdNyl.mjs → DirectionPlugin.native-4e742f42.mjs} +19 -10
  20. package/dist/DocSchemaPlugin.native-8e41eda0.mjs +1382 -0
  21. package/dist/{DocumentManagerPlugin.native-C2cs_1w4.mjs → DocumentManagerPlugin.native-e69895ad.mjs} +4 -4
  22. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-55209c87.mjs} +70 -70
  23. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-65c5ac47.mjs} +11 -6
  24. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-f9bc255a.mjs} +7 -4
  25. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-f5647872.mjs} +19 -10
  26. package/dist/{FootnotePlugin.native-D730OGRm.mjs → FootnotePlugin.native-494657b3.mjs} +77 -39
  27. package/dist/{FullscreenPlugin.native-ChXyxeNw.mjs → FullscreenPlugin.native-87ce92e9.mjs} +1 -1
  28. package/dist/{HeadingPlugin.native-DrLYwQnQ.mjs → HeadingPlugin.native-e38c4a16.mjs} +1 -1
  29. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-92ed4be4.mjs} +43 -22
  30. package/dist/{IndentPlugin.native-BHixp8sP.mjs → IndentPlugin.native-e4ee902b.mjs} +23 -12
  31. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-7c95cfbc.mjs} +1 -1
  32. package/dist/{LineHeightPlugin.native-CM7iXdQj.mjs → LineHeightPlugin.native-5668f78c.mjs} +19 -10
  33. package/dist/{LinkPlugin.native-DYCIcdTm.mjs → LinkPlugin.native-6df29111.mjs} +9 -5
  34. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-fe2e115a.mjs} +9 -5
  35. package/dist/{MathPlugin.native-f_mDp8VL.mjs → MathPlugin.native-735bbac2.mjs} +9 -5
  36. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-3cf48a00.mjs} +219 -207
  37. package/dist/MentionPlugin.native-3b1e8c05.mjs +778 -0
  38. package/dist/{MergeTagPlugin.native-C3eOfEgw.mjs → MergeTagPlugin.native-31cf7d48.mjs} +51 -26
  39. package/dist/PIIRedactionPlugin.native-7ab10b9f.mjs +1449 -0
  40. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-1794c5fb.mjs} +67 -52
  41. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-f7b67cc0.mjs} +38 -33
  42. package/dist/{PrintPlugin.native-7qt5v7L5.mjs → PrintPlugin.native-f6a168c2.mjs} +5 -3
  43. package/dist/SlashCommandsPlugin.native-8d45e511.mjs +790 -0
  44. package/dist/SmartPastePlugin.native-a6c5efec.mjs +1447 -0
  45. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-7f06d4ba.mjs} +17 -9
  46. package/dist/{SpellCheckPlugin.native-BZB9AewP.mjs → SpellCheckPlugin.native-04e20834.mjs} +41 -21
  47. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-905e9501.mjs} +9 -5
  48. package/dist/{TablePlugin.native-DrHX-efe.mjs → TablePlugin.native-7d5458c1.mjs} +58 -30
  49. package/dist/{TemplatePlugin.native-CrpfKRJ8.mjs → TemplatePlugin.native-580f0f63.mjs} +32 -17
  50. package/dist/{TextAlignmentPlugin.native-sM_1s00t.mjs → TextAlignmentPlugin.native-9357b3ed.mjs} +11 -6
  51. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-d53ed459.mjs} +26 -14
  52. package/dist/TrackChangesPlugin.native-e96da509.mjs +818 -0
  53. package/dist/TranslationWorkflowPlugin.native-4e711b1e.mjs +1797 -0
  54. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-8080c998.mjs} +1 -1
  55. package/dist/VersionDiffPlugin.native-5bbeff85.mjs +801 -0
  56. package/dist/_commonjsHelpers-69d58be2.mjs +31 -0
  57. package/dist/{anchoredPopover-Bxds0VoB.mjs → anchoredPopover-5cca53ba.mjs} +1 -1
  58. package/dist/documentManager-8327fb6e.mjs +9166 -0
  59. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +3 -2
  60. package/dist/editora.min.js +14 -13
  61. package/dist/editora.umd.js +14 -13
  62. package/dist/{html2canvas.esm-AYkPY5LS.mjs → html2canvas.esm-c51cb3b9.mjs} +978 -894
  63. package/dist/index-072ef022.js +11 -0
  64. package/dist/index-49d31221.mjs +16860 -0
  65. package/dist/{index-yzU4NdPT.mjs → index-7da30697.mjs} +490 -358
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-b47a189f.mjs +5782 -0
  68. package/dist/index.esm.js +12 -7
  69. package/dist/{jspdf.es.min-BJGtOnRT.mjs → jspdf.es.min-780c82db.mjs} +4808 -3784
  70. package/dist/plugin-loader.js +77 -40
  71. package/dist/{purify.es-CKpwg8Tk.mjs → purify.es-3bdbcfc5.mjs} +20 -10
  72. package/dist/style.css +1 -0
  73. package/dist/webcomponent-core.js +546 -414
  74. package/dist/webcomponent-core.min.css +1 -1
  75. package/dist/webcomponent-core.min.js +40 -39
  76. package/dist/webcomponent.cjs.js +1 -1
  77. package/dist/webcomponent.esm.js +1 -1
  78. package/dist/webcomponent.js +484 -315
  79. package/dist/webcomponent.min.css +1 -1
  80. package/dist/webcomponent.min.js +6035 -558
  81. package/package.json +11 -5
  82. package/dist/_commonjsHelpers-DOllISpa.mjs +0 -32
  83. package/dist/core.css +0 -1
  84. package/dist/documentManager-vQ1VkbUY.mjs +0 -8418
  85. package/dist/index-BpE6GFbz.js +0 -10
  86. package/dist/index-BslAFzmv.mjs +0 -16544
  87. package/dist/index.es-BYD2KEo6.mjs +0 -6666
@@ -0,0 +1,778 @@
1
+ const p = ".rte-content, .editora-content", ie = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", w = '.rte-mention[data-mention="true"]', b = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', R = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap();
2
+ let F = !1, S = !1, T = null, k = 0;
3
+ function X(e, n) {
4
+ if (n === e.innerHTML)
5
+ return;
6
+ const o = window.execEditorCommand || window.executeEditorCommand;
7
+ if (typeof o == "function")
8
+ try {
9
+ o("recordDomTransaction", e, n, e.innerHTML);
10
+ } catch (t) {
11
+ }
12
+ }
13
+ function J(e) {
14
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
15
+ }
16
+ function h(e, n) {
17
+ const o = window.getSelection();
18
+ o && (o.removeAllRanges(), o.addRange(n), e.focus({ preventScroll: !0 }));
19
+ }
20
+ function A(e, n) {
21
+ return e.startContainer === n.startContainer && e.startOffset === n.startOffset && e.endContainer === n.endContainer && e.endOffset === n.endOffset;
22
+ }
23
+ function E(e) {
24
+ const n = window.getSelection();
25
+ if (!n || n.rangeCount === 0)
26
+ return null;
27
+ const o = n.getRangeAt(0);
28
+ return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
29
+ }
30
+ function C(e) {
31
+ Array.from(e.querySelectorAll(w)).forEach((o) => {
32
+ o.setAttribute("data-mention", "true"), o.setAttribute("contenteditable", "false"), o.setAttribute("spellcheck", "false"), o.setAttribute("draggable", "false"), o.classList.add("rte-mention");
33
+ });
34
+ }
35
+ function Q(e) {
36
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
37
+ }
38
+ function ae(e) {
39
+ return e.closest(ie) || e;
40
+ }
41
+ function L(e) {
42
+ return e ? (e.getAttribute("data-theme") || e.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark") : !1;
43
+ }
44
+ function le(e) {
45
+ const n = ae(e);
46
+ if (L(n))
47
+ return !0;
48
+ const o = n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
49
+ return L(o) ? !0 : L(document.documentElement) || L(document.body);
50
+ }
51
+ function Z(e, n) {
52
+ e.classList.remove("rte-mention-theme-dark"), le(n) && e.classList.add("rte-mention-theme-dark");
53
+ }
54
+ function se(e) {
55
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement)
56
+ return e.contentElement;
57
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
58
+ const t = e.editorElement;
59
+ if (t.matches(p))
60
+ return t;
61
+ const r = t.querySelector(p);
62
+ if (r instanceof HTMLElement)
63
+ return r;
64
+ }
65
+ const n = window.getSelection();
66
+ if (n && n.rangeCount > 0) {
67
+ const t = n.getRangeAt(0).startContainer, r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement, i = r == null ? void 0 : r.closest(p);
68
+ if (i)
69
+ return i;
70
+ }
71
+ const o = document.activeElement;
72
+ if (o) {
73
+ if (o.matches(p))
74
+ return o;
75
+ const t = o.closest(p);
76
+ if (t)
77
+ return t;
78
+ }
79
+ return document.querySelector(p);
80
+ }
81
+ function x(e) {
82
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
83
+ }
84
+ function q(e) {
85
+ return typeof e == "object" && e !== null && !Array.isArray(e);
86
+ }
87
+ function ce(e, n) {
88
+ return n ? n.split(".").filter(Boolean).reduce((o, t) => {
89
+ if (!(!q(o) && !Array.isArray(o)))
90
+ return o[t];
91
+ }, e) : e;
92
+ }
93
+ function ue(e) {
94
+ return e ? /\s|[([{"'`]/.test(e) : !0;
95
+ }
96
+ function de(e) {
97
+ if (!e.collapsed)
98
+ return null;
99
+ const n = e.startContainer, o = e.startOffset;
100
+ if (n.nodeType === Node.TEXT_NODE) {
101
+ const t = n;
102
+ return {
103
+ node: t,
104
+ textBefore: t.data.slice(0, o),
105
+ caretOffset: o
106
+ };
107
+ }
108
+ if (n.nodeType === Node.ELEMENT_NODE) {
109
+ const t = n;
110
+ if (o > 0) {
111
+ const r = t.childNodes[o - 1];
112
+ if (r && r.nodeType === Node.TEXT_NODE) {
113
+ const i = r;
114
+ return {
115
+ node: i,
116
+ textBefore: i.data,
117
+ caretOffset: i.length
118
+ };
119
+ }
120
+ }
121
+ }
122
+ return null;
123
+ }
124
+ function fe(e, n, o) {
125
+ let t = -1, r = "";
126
+ if (n.forEach((a) => {
127
+ const l = e.lastIndexOf(a);
128
+ l > t && (t = l, r = a);
129
+ }), t < 0 || !ue(e[t - 1]))
130
+ return null;
131
+ const i = e.slice(t + 1);
132
+ return /\s/.test(i) || i.length > o ? null : {
133
+ trigger: r,
134
+ query: i,
135
+ startOffset: t
136
+ };
137
+ }
138
+ function me(e, n) {
139
+ const o = n.cloneRange();
140
+ o.collapse(!1);
141
+ const t = o.getClientRects();
142
+ if (t.length > 0)
143
+ return t[t.length - 1];
144
+ const r = document.createElement("span");
145
+ r.textContent = "​", r.style.position = "relative", o.insertNode(r);
146
+ const i = r.getBoundingClientRect();
147
+ return r.remove(), e.normalize(), i;
148
+ }
149
+ function ge(e, n) {
150
+ if (e.panel && e.list)
151
+ return;
152
+ const o = document.createElement("div");
153
+ o.className = "rte-mention-panel", o.style.display = "none";
154
+ const t = document.createElement("div");
155
+ t.className = "rte-mention-list", o.appendChild(t), document.body.appendChild(o), Z(o, e.editor), e.panel = o, e.list = t, o.addEventListener("mousedown", (r) => {
156
+ r.preventDefault();
157
+ }), o.addEventListener("click", (r) => {
158
+ const i = r.target;
159
+ if (!i)
160
+ return;
161
+ const a = i.closest(".rte-mention-item");
162
+ if (!a)
163
+ return;
164
+ const l = Number(a.getAttribute("data-index"));
165
+ Number.isFinite(l) && ee(e, n, l);
166
+ });
167
+ }
168
+ function m(e) {
169
+ e.panel && (e.debounceHandle !== null && (window.clearTimeout(e.debounceHandle), e.debounceHandle = null), e.abortController && (e.abortController.abort(), e.abortController = null), e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.loading = !1, e.items = [], e.activeIndex = 0, e.query = "", e.replaceRange = null);
170
+ }
171
+ function U(e, n) {
172
+ if (!e.panel)
173
+ return;
174
+ Z(e.panel, e.editor);
175
+ const o = me(e.editor, n), t = e.panel;
176
+ t.style.display = "block", t.classList.add("show"), t.style.left = "0px", t.style.top = "0px";
177
+ const r = t.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
178
+ let l = Math.max(8, Math.min(o.left, i - r.width - 8)), s = o.bottom + 8;
179
+ s + r.height > a - 8 && (s = Math.max(8, o.top - r.height - 8)), t.style.position = "fixed", t.style.left = `${l}px`, t.style.top = `${s}px`;
180
+ }
181
+ function pe(e, n) {
182
+ if (!n)
183
+ return x(e);
184
+ const o = e.toLowerCase(), t = n.toLowerCase(), r = o.indexOf(t);
185
+ if (r < 0)
186
+ return x(e);
187
+ const i = x(e.slice(0, r)), a = x(e.slice(r, r + n.length)), l = x(e.slice(r + n.length));
188
+ return `${i}<mark>${a}</mark>${l}`;
189
+ }
190
+ function W(e, n) {
191
+ if (!e.list)
192
+ return;
193
+ const o = e.list;
194
+ if (o.innerHTML = "", e.loading) {
195
+ const t = document.createElement("div");
196
+ t.className = "rte-mention-empty", t.textContent = n.loadingText, o.appendChild(t);
197
+ return;
198
+ }
199
+ if (e.items.length === 0) {
200
+ const t = document.createElement("div");
201
+ t.className = "rte-mention-empty", t.textContent = e.query.length > 0 ? n.noResultsText : n.emptyStateText, o.appendChild(t);
202
+ return;
203
+ }
204
+ e.items.forEach((t, r) => {
205
+ const i = document.createElement("button");
206
+ i.type = "button", i.className = "rte-mention-item", r === e.activeIndex && i.classList.add("active"), i.setAttribute("data-index", String(r));
207
+ const a = n.itemRenderer ? n.itemRenderer(t, e.query) : `<span class="rte-mention-item-label">${pe(t.label, e.query)}</span>${t.meta ? `<span class="rte-mention-item-meta">${x(t.meta)}</span>` : ""}`;
208
+ i.innerHTML = a, o.appendChild(i);
209
+ });
210
+ }
211
+ function Y(e, n) {
212
+ const o = /* @__PURE__ */ new Set(), t = [];
213
+ return e.forEach((r) => {
214
+ const i = (r.id || "").trim();
215
+ !i || o.has(i) || (o.add(i), t.push({
216
+ id: i,
217
+ label: r.label || i,
218
+ value: r.value,
219
+ meta: r.meta
220
+ }));
221
+ }), t.slice(0, n);
222
+ }
223
+ function he(e, n) {
224
+ if (e.buildRequest) {
225
+ const c = e.buildRequest(n);
226
+ return {
227
+ url: c.url,
228
+ init: c.init || {}
229
+ };
230
+ }
231
+ const o = (e.method || "GET").toUpperCase(), t = typeof e.headers == "function" ? e.headers(n) : e.headers || {}, r = e.queryParam || "q", i = e.triggerParam || "trigger", a = e.limitParam || "limit", l = e.staticParams || {}, s = {
232
+ method: o,
233
+ headers: { ...t },
234
+ credentials: e.credentials,
235
+ mode: e.mode,
236
+ cache: e.cache,
237
+ signal: n.signal
238
+ }, f = new URL(e.url, window.location.origin);
239
+ if (o === "GET" || o === "HEAD") {
240
+ const c = new URLSearchParams(f.search);
241
+ Object.entries(l).forEach(([u, g]) => c.set(u, String(g))), c.set(r, n.query), c.set(i, n.trigger), c.set(a, String(n.limit)), f.search = c.toString();
242
+ } else {
243
+ const c = typeof e.body == "function" ? e.body(n) : e.body, u = {
244
+ [r]: n.query,
245
+ [i]: n.trigger,
246
+ [a]: n.limit,
247
+ ...l
248
+ }, g = c != null ? c : u;
249
+ if (q(g)) {
250
+ s.body = JSON.stringify(g);
251
+ const y = s.headers;
252
+ !y["Content-Type"] && !y["content-type"] && (y["Content-Type"] = "application/json");
253
+ } else
254
+ s.body = g;
255
+ }
256
+ return { url: f.toString(), init: s };
257
+ }
258
+ async function ye(e, n, o, t) {
259
+ var f, c;
260
+ const r = n.api;
261
+ if (!r)
262
+ return [];
263
+ e.abortController && e.abortController.abort();
264
+ const i = new AbortController();
265
+ e.abortController = i;
266
+ const a = {
267
+ query: o,
268
+ trigger: t,
269
+ limit: n.maxSuggestions,
270
+ signal: i.signal
271
+ }, l = Math.max(0, (f = r.timeoutMs) != null ? f : 1e4);
272
+ let s = null;
273
+ l > 0 && (s = window.setTimeout(() => i.abort(), l));
274
+ try {
275
+ const { url: u, init: g } = he(r, a), y = await fetch(u, {
276
+ ...g,
277
+ signal: i.signal
278
+ });
279
+ if (!y.ok)
280
+ throw new Error(`Mention API request failed: ${y.status}`);
281
+ const v = (r.responseType || "json") === "text" ? await y.text() : await y.json();
282
+ let I = [];
283
+ if (r.transformResponse)
284
+ I = r.transformResponse(v, a) || [];
285
+ else {
286
+ const P = ce(v, r.responsePath);
287
+ I = (Array.isArray(P) ? P : Array.isArray(v) ? v : []).map((d, re) => {
288
+ var _, $, B, j, z;
289
+ if (r.mapItem)
290
+ return r.mapItem(d, re);
291
+ if (!q(d))
292
+ return null;
293
+ const H = String((B = ($ = (_ = d.id) != null ? _ : d.value) != null ? $ : d.key) != null ? B : "").trim();
294
+ if (!H)
295
+ return null;
296
+ const oe = String((z = (j = d.label) != null ? j : d.name) != null ? z : H).trim();
297
+ return {
298
+ id: H,
299
+ label: oe,
300
+ value: d.value ? String(d.value) : void 0,
301
+ meta: d.meta ? String(d.meta) : void 0
302
+ };
303
+ }).filter((d) => !!d);
304
+ }
305
+ return Y(I, n.maxSuggestions);
306
+ } catch (u) {
307
+ return (u == null ? void 0 : u.name) !== "AbortError" && ((c = r.onError) == null || c.call(r, u, a)), [];
308
+ } finally {
309
+ s !== null && window.clearTimeout(s), e.abortController === i && (e.abortController = null);
310
+ }
311
+ }
312
+ async function be(e, n, o, t) {
313
+ const r = ++e.requestId;
314
+ let i = [];
315
+ if (n.search) {
316
+ const a = await n.search(o, t);
317
+ i = Array.isArray(a) ? a : [];
318
+ } else if (n.api)
319
+ i = await ye(e, n, o, t);
320
+ else {
321
+ const a = o.toLowerCase();
322
+ i = n.items.filter((l) => a ? l.label.toLowerCase().includes(a) || l.id.toLowerCase().includes(a) : !0);
323
+ }
324
+ return r !== e.requestId ? [] : Y(i, n.maxSuggestions);
325
+ }
326
+ function Ee(e, n, o) {
327
+ const t = e.editor;
328
+ if (C(t), !window.getSelection())
329
+ return !1;
330
+ const i = t.innerHTML;
331
+ let a = e.replaceRange ? e.replaceRange.cloneRange() : E(t);
332
+ if (!a || !t.contains(a.commonAncestorContainer) && (a = E(t), !a))
333
+ return !1;
334
+ const l = O(t, a.cloneRange(), "after");
335
+ A(l, a) || (h(t, l), a = l), a.deleteContents();
336
+ const s = document.createElement("span");
337
+ s.className = "rte-mention", s.setAttribute("data-mention", "true"), s.setAttribute("data-mention-id", o.id), s.setAttribute("contenteditable", "false"), s.textContent = o.value || `${e.trigger}${o.label}`, a.insertNode(s);
338
+ let f = s, c = 1;
339
+ if (n.insertSpaceAfterMention) {
340
+ const g = document.createTextNode(" ");
341
+ s.after(g), f = g, c = 1;
342
+ }
343
+ const u = document.createRange();
344
+ return u.setStart(f, c), u.collapse(!0), h(t, u), m(e), C(t), J(t), X(t, i), !0;
345
+ }
346
+ function ee(e, n, o) {
347
+ if (o < 0 || o >= e.items.length)
348
+ return;
349
+ const t = e.items[o];
350
+ Ee(e, n, t);
351
+ }
352
+ function xe(e) {
353
+ return e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE || e.endOffset - e.startOffset !== 1 ? null : e.startContainer.childNodes[e.startOffset] || null;
354
+ }
355
+ function we(e, n) {
356
+ const o = xe(e);
357
+ return !(o instanceof HTMLElement) || !o.matches(w) || !n.contains(o) ? null : o;
358
+ }
359
+ function ne(e, n) {
360
+ const o = we(e, n);
361
+ if (o)
362
+ return o;
363
+ const t = Q(e.startContainer), r = t == null ? void 0 : t.closest(w);
364
+ if (r && n.contains(r))
365
+ return r;
366
+ const i = Q(e.endContainer), a = i == null ? void 0 : i.closest(w);
367
+ return a && n.contains(a) ? a : null;
368
+ }
369
+ function O(e, n, o = "after") {
370
+ const t = ne(n, e);
371
+ if (!t)
372
+ return n;
373
+ const r = document.createRange();
374
+ return o === "before" ? r.setStartBefore(t) : r.setStartAfter(t), r.collapse(!0), r;
375
+ }
376
+ function G(e, n, o = "after") {
377
+ const t = document.createRange();
378
+ o === "before" ? t.setStartBefore(n) : t.setStartAfter(n), t.collapse(!0), h(e, t);
379
+ }
380
+ function Te(e, n, o) {
381
+ if (!e.collapsed)
382
+ return null;
383
+ const t = e.startContainer, r = e.startOffset;
384
+ let i = null;
385
+ if (t.nodeType === Node.TEXT_NODE) {
386
+ const a = t;
387
+ n === "backward" && r === 0 ? i = a.previousSibling : n === "forward" && r === a.length && (i = a.nextSibling);
388
+ } else if (t.nodeType === Node.ELEMENT_NODE) {
389
+ const a = t;
390
+ n === "backward" && r > 0 ? i = a.childNodes[r - 1] || null : n === "forward" && r < a.childNodes.length && (i = a.childNodes[r] || null);
391
+ }
392
+ return !(i instanceof HTMLElement) || !i.matches(w) || !o.contains(i) ? null : i;
393
+ }
394
+ function K(e, n) {
395
+ const o = E(e);
396
+ if (!o)
397
+ return !1;
398
+ const t = Te(o, n, e);
399
+ if (!t)
400
+ return !1;
401
+ const r = t.parentNode;
402
+ if (!r)
403
+ return !1;
404
+ const i = e.innerHTML, a = Array.prototype.indexOf.call(r.childNodes, t);
405
+ t.remove();
406
+ const l = document.createRange();
407
+ return l.setStart(r, Math.max(0, a)), l.collapse(!0), h(e, l), J(e), X(e, i), !0;
408
+ }
409
+ function te(e, n, o, t, r, i) {
410
+ var s;
411
+ if (ge(e, n), e.query = t, e.trigger = r, e.replaceRange = i.cloneRange(), e.loading = !!(n.api && !n.search), e.debounceHandle !== null && (window.clearTimeout(e.debounceHandle), e.debounceHandle = null), !e.panel)
412
+ return;
413
+ e.isOpen || (e.panel.style.display = "block", e.panel.classList.add("show"), e.isOpen = !0), W(e, n), U(e, o);
414
+ const a = () => {
415
+ e.debounceHandle = null, be(e, n, t, r).then((f) => {
416
+ e.loading = !1, e.items = f, e.activeIndex = 0, e.panel && (W(e, n), U(e, o));
417
+ });
418
+ }, l = n.api && !n.search ? Math.max(0, (s = n.api.debounceMs) != null ? s : 180) : 0;
419
+ l > 0 ? e.debounceHandle = window.setTimeout(a, l) : a();
420
+ }
421
+ function Ce(e, n) {
422
+ const o = e.editor;
423
+ C(o);
424
+ let t = E(o);
425
+ if (!t || !t.collapsed) {
426
+ m(e);
427
+ return;
428
+ }
429
+ const r = O(o, t.cloneRange(), "after");
430
+ if (!A(r, t)) {
431
+ h(o, r), t = r, m(e);
432
+ return;
433
+ }
434
+ const i = de(t);
435
+ if (!i) {
436
+ m(e);
437
+ return;
438
+ }
439
+ const a = fe(i.textBefore, n.triggerChars, n.maxQueryLength);
440
+ if (!a) {
441
+ m(e);
442
+ return;
443
+ }
444
+ if (a.query.length < n.minChars) {
445
+ m(e);
446
+ return;
447
+ }
448
+ const l = t.cloneRange();
449
+ l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset), te(e, n, t, a.query, a.trigger, l);
450
+ }
451
+ function V(e, n) {
452
+ if (e.items.length === 0)
453
+ return;
454
+ const o = e.items.length;
455
+ if (e.activeIndex = ((e.activeIndex + n) % o + o) % o, !e.list)
456
+ return;
457
+ const t = Array.from(e.list.querySelectorAll(".rte-mention-item"));
458
+ t.forEach((i, a) => i.classList.toggle("active", a === e.activeIndex));
459
+ const r = t[e.activeIndex];
460
+ r == null || r.scrollIntoView({ block: "nearest" });
461
+ }
462
+ function ve(e) {
463
+ return {
464
+ editor: e,
465
+ panel: null,
466
+ list: null,
467
+ replaceRange: null,
468
+ items: [],
469
+ activeIndex: 0,
470
+ query: "",
471
+ trigger: "@",
472
+ loading: !1,
473
+ isOpen: !1,
474
+ requestId: 0,
475
+ debounceHandle: null,
476
+ abortController: null
477
+ };
478
+ }
479
+ function ke(e) {
480
+ var o;
481
+ const n = R.get(e);
482
+ n && ((o = n.panel) != null && o.parentNode && n.panel.parentNode.removeChild(n.panel), R.delete(e));
483
+ }
484
+ function D(e, n, o) {
485
+ if (N.has(e))
486
+ return;
487
+ C(e);
488
+ const t = {
489
+ beforeInput: (r) => {
490
+ C(e);
491
+ const i = E(e);
492
+ if (!i)
493
+ return;
494
+ const a = ne(i, e);
495
+ if (!a)
496
+ return;
497
+ const l = r.inputType || "";
498
+ if (l.startsWith("insert")) {
499
+ if (r.preventDefault(), G(e, a, "after"), l === "insertParagraph" || l === "insertLineBreak") {
500
+ const s = l === "insertLineBreak" ? "insertLineBreak" : "insertParagraph";
501
+ document.execCommand(s, !1);
502
+ return;
503
+ }
504
+ if (l === "insertText" || l === "insertCompositionText") {
505
+ const s = r.data || "";
506
+ if (!s)
507
+ return;
508
+ document.execCommand("insertText", !1, s);
509
+ }
510
+ }
511
+ },
512
+ input: () => {
513
+ Ce(n, o);
514
+ },
515
+ keydown: (r) => {
516
+ if (n.isOpen) {
517
+ if (r.key === "ArrowDown") {
518
+ r.preventDefault(), V(n, 1);
519
+ return;
520
+ }
521
+ if (r.key === "ArrowUp") {
522
+ r.preventDefault(), V(n, -1);
523
+ return;
524
+ }
525
+ if (r.key === "Enter" || r.key === "Tab") {
526
+ r.preventDefault(), ee(n, o, n.activeIndex);
527
+ return;
528
+ }
529
+ if (r.key === "Escape") {
530
+ r.preventDefault(), m(n);
531
+ return;
532
+ }
533
+ }
534
+ const i = E(e);
535
+ if (i) {
536
+ const a = O(e, i.cloneRange(), "after");
537
+ if (!A(a, i)) {
538
+ if (r.key === "Enter") {
539
+ r.preventDefault(), h(e, a), document.execCommand("insertParagraph", !1);
540
+ return;
541
+ }
542
+ r.key.length === 1 && !r.metaKey && !r.ctrlKey && !r.altKey && h(e, a);
543
+ }
544
+ }
545
+ if (r.key === "Backspace" && K(e, "backward")) {
546
+ r.preventDefault();
547
+ return;
548
+ }
549
+ if (r.key === "Delete" && K(e, "forward")) {
550
+ r.preventDefault();
551
+ return;
552
+ }
553
+ },
554
+ click: (r) => {
555
+ const i = r.target;
556
+ if (!i)
557
+ return;
558
+ const a = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement, l = a == null ? void 0 : a.closest(w);
559
+ !l || !e.contains(l) || (r.preventDefault(), r.stopPropagation(), G(e, l, "after"), m(n));
560
+ },
561
+ blur: () => {
562
+ window.setTimeout(() => {
563
+ const r = document.activeElement;
564
+ n.panel && r && n.panel.contains(r) || m(n);
565
+ }, 0);
566
+ },
567
+ mousedown: (r) => {
568
+ if (!n.isOpen || !n.panel)
569
+ return;
570
+ const i = r.target;
571
+ i && !n.panel.contains(i) && !e.contains(i) && m(n);
572
+ }
573
+ };
574
+ e.addEventListener("beforeinput", t.beforeInput), e.addEventListener("input", t.input), e.addEventListener("keydown", t.keydown), e.addEventListener("click", t.click), e.addEventListener("blur", t.blur), document.addEventListener("mousedown", t.mousedown, !0), N.set(e, t);
575
+ }
576
+ function Le(e) {
577
+ const n = N.get(e);
578
+ n && (e.removeEventListener("beforeinput", n.beforeInput), e.removeEventListener("input", n.input), e.removeEventListener("keydown", n.keydown), e.removeEventListener("click", n.click), e.removeEventListener("blur", n.blur), document.removeEventListener("mousedown", n.mousedown, !0), N.delete(e));
579
+ }
580
+ function Me() {
581
+ if (F || typeof document == "undefined")
582
+ return;
583
+ F = !0;
584
+ const e = document.createElement("style");
585
+ e.id = "rte-mention-plugin-styles", e.textContent = `
586
+ .rte-mention {
587
+ display: inline-block;
588
+ padding: 0 6px;
589
+ margin: 0 1px;
590
+ border-radius: 10px;
591
+ background: #e8f0ff;
592
+ color: #1d4ed8;
593
+ font-weight: 600;
594
+ line-height: 1.6;
595
+ white-space: nowrap;
596
+ cursor: pointer;
597
+ }
598
+
599
+ .rte-mention-panel {
600
+ width: min(320px, calc(100vw - 16px));
601
+ max-height: min(320px, calc(100vh - 32px));
602
+ overflow: hidden;
603
+ border: 1px solid #d9dfeb;
604
+ border-radius: 3px;
605
+ background: #ffffff;
606
+ box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
607
+ z-index: 2147483646;
608
+ }
609
+
610
+ .rte-mention-list {
611
+ max-height: min(300px, calc(100vh - 56px));
612
+ overflow: auto;
613
+ padding: 0px;
614
+ }
615
+
616
+ .rte-mention-item {
617
+ width: 100%;
618
+ display: flex;
619
+ align-items: center;
620
+ justify-content: space-between;
621
+ gap: 12px;
622
+ border: none;
623
+ background: transparent;
624
+ padding: 10px 12px;
625
+ border-radius: 0px;
626
+ color: #0f172a;
627
+ text-align: left;
628
+ cursor: pointer;
629
+ font: inherit;
630
+ }
631
+
632
+ .rte-mention-item:hover,
633
+ .rte-mention-item.active {
634
+ background: #eff6ff;
635
+ color: #1d4ed8;
636
+ }
637
+
638
+ .rte-mention-item-label mark {
639
+ background: rgba(59, 130, 246, 0.16);
640
+ color: inherit;
641
+ padding: 0 2px;
642
+ border-radius: 3px;
643
+ }
644
+
645
+ .rte-mention-item-meta {
646
+ font-size: 12px;
647
+ color: #64748b;
648
+ white-space: nowrap;
649
+ }
650
+
651
+ .rte-mention-empty {
652
+ padding: 12px;
653
+ color: #64748b;
654
+ font-size: 13px;
655
+ text-align: center;
656
+ }
657
+
658
+ ${b} .rte-mention {
659
+ background: rgba(37, 99, 235, 0.25);
660
+ color: #bfdbfe;
661
+ }
662
+
663
+ ${b} .rte-mention-panel,
664
+ .rte-mention-panel.rte-mention-theme-dark {
665
+ border-color: #364152;
666
+ background: #1f2937;
667
+ box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
668
+ }
669
+
670
+ ${b} .rte-mention-item,
671
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item {
672
+ color: #e5e7eb;
673
+ }
674
+
675
+ ${b} .rte-mention-item:hover,
676
+ ${b} .rte-mention-item.active,
677
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item:hover,
678
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item.active {
679
+ background: #334155;
680
+ color: #bfdbfe;
681
+ }
682
+
683
+ ${b} .rte-mention-item-meta,
684
+ ${b} .rte-mention-empty,
685
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item-meta,
686
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-empty {
687
+ color: #9ca3af;
688
+ }
689
+ `, document.head.appendChild(e);
690
+ }
691
+ function Re(e) {
692
+ var o, t, r;
693
+ const n = (e.triggerChars || ["@"]).filter((i) => typeof i == "string" && i.length > 0).map((i) => i[0]);
694
+ return {
695
+ triggerChars: n.length > 0 ? n : ["@"],
696
+ minChars: Math.max(0, (o = e.minChars) != null ? o : 1),
697
+ maxQueryLength: Math.max(1, (t = e.maxQueryLength) != null ? t : 32),
698
+ maxSuggestions: Math.max(1, (r = e.maxSuggestions) != null ? r : 8),
699
+ items: e.items || [
700
+ { id: "john.doe", label: "John Doe", meta: "john@acme.com" },
701
+ { id: "sarah.lee", label: "Sarah Lee", meta: "sarah@acme.com" },
702
+ { id: "alex.chen", label: "Alex Chen", meta: "alex@acme.com" }
703
+ ],
704
+ api: e.api,
705
+ search: e.search,
706
+ itemRenderer: e.itemRenderer,
707
+ emptyStateText: e.emptyStateText || "Type to search mentions",
708
+ noResultsText: e.noResultsText || "No matching mentions",
709
+ loadingText: e.loadingText || "Loading...",
710
+ insertSpaceAfterMention: e.insertSpaceAfterMention !== !1
711
+ };
712
+ }
713
+ function M(e) {
714
+ const n = R.get(e);
715
+ if (n)
716
+ return n;
717
+ const o = ve(e);
718
+ return R.set(e, o), o;
719
+ }
720
+ function Ne(e) {
721
+ S || (S = !0, T = (n) => {
722
+ const o = n.target;
723
+ if (!(o instanceof Node))
724
+ return;
725
+ const t = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement, r = (t == null ? void 0 : t.closest(p)) || null;
726
+ if (!r)
727
+ return;
728
+ const i = M(r);
729
+ D(r, i, e);
730
+ }, document.addEventListener("focusin", T, !0));
731
+ }
732
+ function Se() {
733
+ !S || !T || (document.removeEventListener("focusin", T, !0), S = !1, T = null);
734
+ }
735
+ const Ie = (e = {}) => {
736
+ Me();
737
+ const n = Re(e);
738
+ return {
739
+ name: "mentions",
740
+ toolbar: [
741
+ {
742
+ label: "Mention",
743
+ command: "insertMention",
744
+ icon: '<svg width="24" height="24" focusable="false"><path d="M12.1 4a7.9 7.9 0 0 0-8 8c0 4.4 3.6 8 8 8 1.6 0 3-.4 4.4-1.3.4-.3.5-.9.2-1.3a1 1 0 0 0-1.3-.3 6 6 0 0 1-3.3.9 6 6 0 1 1 6-6v1.6c0 .8-.5 1.4-1.2 1.4-.8 0-1.2-.6-1.2-1.4V12c0-2-1.6-3.5-3.7-3.5s-3.8 1.6-3.8 3.6c0 2 1.7 3.6 3.8 3.6 1 0 1.9-.4 2.6-1 .5 1 1.4 1.6 2.5 1.6 1.8 0 3.2-1.5 3.2-3.4V12A7.9 7.9 0 0 0 12 4Zm0 9.7c-1 0-1.8-.8-1.8-1.7s.8-1.7 1.8-1.7c1 0 1.7.8 1.7 1.7s-.8 1.7-1.7 1.7Z"></path></svg>'
745
+ }
746
+ ],
747
+ commands: {
748
+ insertMention: (o, t) => {
749
+ const r = se(t);
750
+ if (!r)
751
+ return !1;
752
+ const i = M(r);
753
+ D(r, i, n);
754
+ let a = E(r);
755
+ a || (a = document.createRange(), a.selectNodeContents(r), a.collapse(!1), h(r, a));
756
+ const l = O(r, a.cloneRange(), "after");
757
+ A(l, a) || (h(r, l), a = l), i.query = "";
758
+ const s = a.cloneRange();
759
+ return i.trigger = n.triggerChars[0], te(i, n, a, "", i.trigger, s), !0;
760
+ }
761
+ },
762
+ init: () => {
763
+ k += 1, Ne(n), Array.from(document.querySelectorAll(p)).forEach((t) => {
764
+ const r = M(t);
765
+ D(t, r, n);
766
+ });
767
+ },
768
+ destroy: () => {
769
+ k = Math.max(0, k - 1), Array.from(document.querySelectorAll(p)).forEach((t) => {
770
+ m(M(t)), Le(t), ke(t);
771
+ }), k === 0 && Se();
772
+ }
773
+ };
774
+ };
775
+ export {
776
+ Ie as MentionPlugin
777
+ };
778
+ //# sourceMappingURL=MentionPlugin.native-3b1e8c05.mjs.map