@editora/plugins 1.0.8 → 1.0.10

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 (141) hide show
  1. package/README.md +27 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +447 -0
  11. package/dist/approval-workflow.esm.js +1111 -0
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +442 -0
  16. package/dist/blocks-library.esm.js +1384 -0
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +548 -0
  21. package/dist/citations.esm.js +1530 -0
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +626 -0
  31. package/dist/conditional-content.esm.js +1421 -0
  32. package/dist/content-rules.cjs.js +408 -0
  33. package/dist/content-rules.esm.js +1147 -0
  34. package/dist/data-binding.cjs.js +321 -0
  35. package/dist/data-binding.esm.js +953 -0
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +398 -0
  38. package/dist/doc-schema.esm.js +1378 -0
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -0
  49. package/dist/enterprise.esm.js +58 -0
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +124 -93
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +105 -0
  87. package/dist/mentions.esm.js +774 -0
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +67 -51
  92. package/dist/pii-redaction.cjs.js +436 -0
  93. package/dist/pii-redaction.esm.js +1447 -0
  94. package/dist/preview.cjs.js +3 -3
  95. package/dist/preview.esm.js +37 -32
  96. package/dist/print.cjs.js +4 -4
  97. package/dist/print.esm.js +20 -17
  98. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  99. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  100. package/dist/slash-commands.cjs.js +90 -0
  101. package/dist/slash-commands.esm.js +788 -0
  102. package/dist/smart-paste.cjs.js +398 -0
  103. package/dist/smart-paste.esm.js +1444 -0
  104. package/dist/special-characters.cjs.js +7 -7
  105. package/dist/special-characters.esm.js +69 -61
  106. package/dist/spell-check.cjs.js +5 -5
  107. package/dist/spell-check.esm.js +123 -97
  108. package/dist/strikethrough.cjs.js +1 -1
  109. package/dist/strikethrough.esm.js +19 -14
  110. package/dist/style.css +1 -0
  111. package/dist/table.cjs.js +4 -4
  112. package/dist/table.esm.js +225 -191
  113. package/dist/template.cjs.js +11 -11
  114. package/dist/template.esm.js +153 -124
  115. package/dist/text-alignment.cjs.js +1 -1
  116. package/dist/text-alignment.esm.js +27 -21
  117. package/dist/text-color.cjs.js +3 -3
  118. package/dist/text-color.esm.js +87 -70
  119. package/dist/track-changes.cjs.js +77 -0
  120. package/dist/track-changes.esm.js +817 -0
  121. package/dist/translation-workflow.cjs.js +626 -0
  122. package/dist/translation-workflow.esm.js +1794 -0
  123. package/dist/version-diff.cjs.js +362 -0
  124. package/dist/version-diff.esm.js +797 -0
  125. package/index.d.ts +798 -0
  126. package/package.json +114 -9
  127. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  128. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  129. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  130. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  131. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  132. package/dist/documentManager-Jf0RbSks.js +0 -17
  133. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  134. package/dist/index-CvJk4DKa.js +0 -221
  135. package/dist/index-D3CycEFU.mjs +0 -16543
  136. package/dist/index-tqLTHcO6.js +0 -1
  137. package/dist/index.es-CE_A4QSm.js +0 -5
  138. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  139. package/dist/jspdf.es.min-BoS80556.js +0 -77
  140. package/dist/plugins.css +0 -1
  141. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
@@ -0,0 +1,774 @@
1
+ const g = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", x = '.rte-mention[data-mention="true"]', y = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', R = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap();
2
+ let _ = !1, S = !1, w = null, k = 0;
3
+ function U(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 {
11
+ }
12
+ }
13
+ function W(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 b(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 T(e) {
31
+ Array.from(e.querySelectorAll(x)).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 $(e) {
36
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
37
+ }
38
+ function ne(e) {
39
+ return e.closest(ee) || 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 te(e) {
45
+ const n = ne(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 G(e, n) {
52
+ e.classList.remove("rte-mention-theme-dark"), te(n) && e.classList.add("rte-mention-theme-dark");
53
+ }
54
+ function re(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(g))
60
+ return t;
61
+ const r = t.querySelector(g);
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(g);
68
+ if (i)
69
+ return i;
70
+ }
71
+ const o = document.activeElement;
72
+ if (o) {
73
+ if (o.matches(g))
74
+ return o;
75
+ const t = o.closest(g);
76
+ if (t)
77
+ return t;
78
+ }
79
+ return document.querySelector(g);
80
+ }
81
+ function E(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 oe(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 ie(e) {
94
+ return e ? /\s|[([{"'`]/.test(e) : !0;
95
+ }
96
+ function ae(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 le(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 || !ie(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 se(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 ce(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), G(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) && V(e, n, l);
166
+ });
167
+ }
168
+ function f(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 B(e, n) {
172
+ if (!e.panel)
173
+ return;
174
+ G(e.panel, e.editor);
175
+ const o = se(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 ue(e, n) {
182
+ if (!n)
183
+ return E(e);
184
+ const o = e.toLowerCase(), t = n.toLowerCase(), r = o.indexOf(t);
185
+ if (r < 0)
186
+ return E(e);
187
+ const i = E(e.slice(0, r)), a = E(e.slice(r, r + n.length)), l = E(e.slice(r + n.length));
188
+ return `${i}<mark>${a}</mark>${l}`;
189
+ }
190
+ function j(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">${ue(t.label, e.query)}</span>${t.meta ? `<span class="rte-mention-item-meta">${E(t.meta)}</span>` : ""}`;
208
+ i.innerHTML = a, o.appendChild(i);
209
+ });
210
+ }
211
+ function K(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 de(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
+ }, m = new URL(e.url, window.location.origin);
239
+ if (o === "GET" || o === "HEAD") {
240
+ const c = new URLSearchParams(m.search);
241
+ Object.entries(l).forEach(([p, u]) => c.set(p, String(u))), c.set(r, n.query), c.set(i, n.trigger), c.set(a, String(n.limit)), m.search = c.toString();
242
+ } else {
243
+ const c = typeof e.body == "function" ? e.body(n) : e.body, p = {
244
+ [r]: n.query,
245
+ [i]: n.trigger,
246
+ [a]: n.limit,
247
+ ...l
248
+ }, u = c ?? p;
249
+ if (q(u)) {
250
+ s.body = JSON.stringify(u);
251
+ const C = s.headers;
252
+ !C["Content-Type"] && !C["content-type"] && (C["Content-Type"] = "application/json");
253
+ } else
254
+ s.body = u;
255
+ }
256
+ return { url: m.toString(), init: s };
257
+ }
258
+ async function fe(e, n, o, t) {
259
+ var m;
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, r.timeoutMs ?? 1e4);
272
+ let s = null;
273
+ l > 0 && (s = window.setTimeout(() => i.abort(), l));
274
+ try {
275
+ const { url: c, init: p } = de(r, a), u = await fetch(c, {
276
+ ...p,
277
+ signal: i.signal
278
+ });
279
+ if (!u.ok)
280
+ throw new Error(`Mention API request failed: ${u.status}`);
281
+ const v = (r.responseType || "json") === "text" ? await u.text() : await u.json();
282
+ let I = [];
283
+ if (r.transformResponse)
284
+ I = r.transformResponse(v, a) || [];
285
+ else {
286
+ const P = oe(v, r.responsePath);
287
+ I = (Array.isArray(P) ? P : Array.isArray(v) ? v : []).map((d, Z) => {
288
+ if (r.mapItem)
289
+ return r.mapItem(d, Z);
290
+ if (!q(d))
291
+ return null;
292
+ const H = String(d.id ?? d.value ?? d.key ?? "").trim();
293
+ if (!H)
294
+ return null;
295
+ const Y = String(d.label ?? d.name ?? H).trim();
296
+ return {
297
+ id: H,
298
+ label: Y,
299
+ value: d.value ? String(d.value) : void 0,
300
+ meta: d.meta ? String(d.meta) : void 0
301
+ };
302
+ }).filter((d) => !!d);
303
+ }
304
+ return K(I, n.maxSuggestions);
305
+ } catch (c) {
306
+ return (c == null ? void 0 : c.name) !== "AbortError" && ((m = r.onError) == null || m.call(r, c, a)), [];
307
+ } finally {
308
+ s !== null && window.clearTimeout(s), e.abortController === i && (e.abortController = null);
309
+ }
310
+ }
311
+ async function me(e, n, o, t) {
312
+ const r = ++e.requestId;
313
+ let i = [];
314
+ if (n.search) {
315
+ const a = await n.search(o, t);
316
+ i = Array.isArray(a) ? a : [];
317
+ } else if (n.api)
318
+ i = await fe(e, n, o, t);
319
+ else {
320
+ const a = o.toLowerCase();
321
+ i = n.items.filter((l) => a ? l.label.toLowerCase().includes(a) || l.id.toLowerCase().includes(a) : !0);
322
+ }
323
+ return r !== e.requestId ? [] : K(i, n.maxSuggestions);
324
+ }
325
+ function pe(e, n, o) {
326
+ const t = e.editor;
327
+ if (T(t), !window.getSelection())
328
+ return !1;
329
+ const i = t.innerHTML;
330
+ let a = e.replaceRange ? e.replaceRange.cloneRange() : b(t);
331
+ if (!a || !t.contains(a.commonAncestorContainer) && (a = b(t), !a))
332
+ return !1;
333
+ const l = O(t, a.cloneRange(), "after");
334
+ A(l, a) || (h(t, l), a = l), a.deleteContents();
335
+ const s = document.createElement("span");
336
+ 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);
337
+ let m = s, c = 1;
338
+ if (n.insertSpaceAfterMention) {
339
+ const u = document.createTextNode(" ");
340
+ s.after(u), m = u, c = 1;
341
+ }
342
+ const p = document.createRange();
343
+ return p.setStart(m, c), p.collapse(!0), h(t, p), f(e), T(t), W(t), U(t, i), !0;
344
+ }
345
+ function V(e, n, o) {
346
+ if (o < 0 || o >= e.items.length)
347
+ return;
348
+ const t = e.items[o];
349
+ pe(e, n, t);
350
+ }
351
+ function ge(e) {
352
+ return e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE || e.endOffset - e.startOffset !== 1 ? null : e.startContainer.childNodes[e.startOffset] || null;
353
+ }
354
+ function he(e, n) {
355
+ const o = ge(e);
356
+ return !(o instanceof HTMLElement) || !o.matches(x) || !n.contains(o) ? null : o;
357
+ }
358
+ function X(e, n) {
359
+ const o = he(e, n);
360
+ if (o)
361
+ return o;
362
+ const t = $(e.startContainer), r = t == null ? void 0 : t.closest(x);
363
+ if (r && n.contains(r))
364
+ return r;
365
+ const i = $(e.endContainer), a = i == null ? void 0 : i.closest(x);
366
+ return a && n.contains(a) ? a : null;
367
+ }
368
+ function O(e, n, o = "after") {
369
+ const t = X(n, e);
370
+ if (!t)
371
+ return n;
372
+ const r = document.createRange();
373
+ return o === "before" ? r.setStartBefore(t) : r.setStartAfter(t), r.collapse(!0), r;
374
+ }
375
+ function z(e, n, o = "after") {
376
+ const t = document.createRange();
377
+ o === "before" ? t.setStartBefore(n) : t.setStartAfter(n), t.collapse(!0), h(e, t);
378
+ }
379
+ function ye(e, n, o) {
380
+ if (!e.collapsed)
381
+ return null;
382
+ const t = e.startContainer, r = e.startOffset;
383
+ let i = null;
384
+ if (t.nodeType === Node.TEXT_NODE) {
385
+ const a = t;
386
+ n === "backward" && r === 0 ? i = a.previousSibling : n === "forward" && r === a.length && (i = a.nextSibling);
387
+ } else if (t.nodeType === Node.ELEMENT_NODE) {
388
+ const a = t;
389
+ n === "backward" && r > 0 ? i = a.childNodes[r - 1] || null : n === "forward" && r < a.childNodes.length && (i = a.childNodes[r] || null);
390
+ }
391
+ return !(i instanceof HTMLElement) || !i.matches(x) || !o.contains(i) ? null : i;
392
+ }
393
+ function F(e, n) {
394
+ const o = b(e);
395
+ if (!o)
396
+ return !1;
397
+ const t = ye(o, n, e);
398
+ if (!t)
399
+ return !1;
400
+ const r = t.parentNode;
401
+ if (!r)
402
+ return !1;
403
+ const i = e.innerHTML, a = Array.prototype.indexOf.call(r.childNodes, t);
404
+ t.remove();
405
+ const l = document.createRange();
406
+ return l.setStart(r, Math.max(0, a)), l.collapse(!0), h(e, l), W(e), U(e, i), !0;
407
+ }
408
+ function J(e, n, o, t, r, i) {
409
+ if (ce(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)
410
+ return;
411
+ e.isOpen || (e.panel.style.display = "block", e.panel.classList.add("show"), e.isOpen = !0), j(e, n), B(e, o);
412
+ const a = () => {
413
+ e.debounceHandle = null, me(e, n, t, r).then((s) => {
414
+ e.loading = !1, e.items = s, e.activeIndex = 0, e.panel && (j(e, n), B(e, o));
415
+ });
416
+ }, l = n.api && !n.search ? Math.max(0, n.api.debounceMs ?? 180) : 0;
417
+ l > 0 ? e.debounceHandle = window.setTimeout(a, l) : a();
418
+ }
419
+ function be(e, n) {
420
+ const o = e.editor;
421
+ T(o);
422
+ let t = b(o);
423
+ if (!t || !t.collapsed) {
424
+ f(e);
425
+ return;
426
+ }
427
+ const r = O(o, t.cloneRange(), "after");
428
+ if (!A(r, t)) {
429
+ h(o, r), t = r, f(e);
430
+ return;
431
+ }
432
+ const i = ae(t);
433
+ if (!i) {
434
+ f(e);
435
+ return;
436
+ }
437
+ const a = le(i.textBefore, n.triggerChars, n.maxQueryLength);
438
+ if (!a) {
439
+ f(e);
440
+ return;
441
+ }
442
+ if (a.query.length < n.minChars) {
443
+ f(e);
444
+ return;
445
+ }
446
+ const l = t.cloneRange();
447
+ l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset), J(e, n, t, a.query, a.trigger, l);
448
+ }
449
+ function Q(e, n) {
450
+ if (e.items.length === 0)
451
+ return;
452
+ const o = e.items.length;
453
+ if (e.activeIndex = ((e.activeIndex + n) % o + o) % o, !e.list)
454
+ return;
455
+ const t = Array.from(e.list.querySelectorAll(".rte-mention-item"));
456
+ t.forEach((i, a) => i.classList.toggle("active", a === e.activeIndex));
457
+ const r = t[e.activeIndex];
458
+ r == null || r.scrollIntoView({ block: "nearest" });
459
+ }
460
+ function Ee(e) {
461
+ return {
462
+ editor: e,
463
+ panel: null,
464
+ list: null,
465
+ replaceRange: null,
466
+ items: [],
467
+ activeIndex: 0,
468
+ query: "",
469
+ trigger: "@",
470
+ loading: !1,
471
+ isOpen: !1,
472
+ requestId: 0,
473
+ debounceHandle: null,
474
+ abortController: null
475
+ };
476
+ }
477
+ function xe(e) {
478
+ var o;
479
+ const n = R.get(e);
480
+ n && ((o = n.panel) != null && o.parentNode && n.panel.parentNode.removeChild(n.panel), R.delete(e));
481
+ }
482
+ function D(e, n, o) {
483
+ if (N.has(e))
484
+ return;
485
+ T(e);
486
+ const t = {
487
+ beforeInput: (r) => {
488
+ T(e);
489
+ const i = b(e);
490
+ if (!i)
491
+ return;
492
+ const a = X(i, e);
493
+ if (!a)
494
+ return;
495
+ const l = r.inputType || "";
496
+ if (l.startsWith("insert")) {
497
+ if (r.preventDefault(), z(e, a, "after"), l === "insertParagraph" || l === "insertLineBreak") {
498
+ const s = l === "insertLineBreak" ? "insertLineBreak" : "insertParagraph";
499
+ document.execCommand(s, !1);
500
+ return;
501
+ }
502
+ if (l === "insertText" || l === "insertCompositionText") {
503
+ const s = r.data || "";
504
+ if (!s)
505
+ return;
506
+ document.execCommand("insertText", !1, s);
507
+ }
508
+ }
509
+ },
510
+ input: () => {
511
+ be(n, o);
512
+ },
513
+ keydown: (r) => {
514
+ if (n.isOpen) {
515
+ if (r.key === "ArrowDown") {
516
+ r.preventDefault(), Q(n, 1);
517
+ return;
518
+ }
519
+ if (r.key === "ArrowUp") {
520
+ r.preventDefault(), Q(n, -1);
521
+ return;
522
+ }
523
+ if (r.key === "Enter" || r.key === "Tab") {
524
+ r.preventDefault(), V(n, o, n.activeIndex);
525
+ return;
526
+ }
527
+ if (r.key === "Escape") {
528
+ r.preventDefault(), f(n);
529
+ return;
530
+ }
531
+ }
532
+ const i = b(e);
533
+ if (i) {
534
+ const a = O(e, i.cloneRange(), "after");
535
+ if (!A(a, i)) {
536
+ if (r.key === "Enter") {
537
+ r.preventDefault(), h(e, a), document.execCommand("insertParagraph", !1);
538
+ return;
539
+ }
540
+ r.key.length === 1 && !r.metaKey && !r.ctrlKey && !r.altKey && h(e, a);
541
+ }
542
+ }
543
+ if (r.key === "Backspace" && F(e, "backward")) {
544
+ r.preventDefault();
545
+ return;
546
+ }
547
+ if (r.key === "Delete" && F(e, "forward")) {
548
+ r.preventDefault();
549
+ return;
550
+ }
551
+ },
552
+ click: (r) => {
553
+ const i = r.target;
554
+ if (!i)
555
+ return;
556
+ const a = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement, l = a == null ? void 0 : a.closest(x);
557
+ !l || !e.contains(l) || (r.preventDefault(), r.stopPropagation(), z(e, l, "after"), f(n));
558
+ },
559
+ blur: () => {
560
+ window.setTimeout(() => {
561
+ const r = document.activeElement;
562
+ n.panel && r && n.panel.contains(r) || f(n);
563
+ }, 0);
564
+ },
565
+ mousedown: (r) => {
566
+ if (!n.isOpen || !n.panel)
567
+ return;
568
+ const i = r.target;
569
+ i && !n.panel.contains(i) && !e.contains(i) && f(n);
570
+ }
571
+ };
572
+ 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);
573
+ }
574
+ function we(e) {
575
+ const n = N.get(e);
576
+ 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));
577
+ }
578
+ function Te() {
579
+ if (_ || typeof document > "u")
580
+ return;
581
+ _ = !0;
582
+ const e = document.createElement("style");
583
+ e.id = "rte-mention-plugin-styles", e.textContent = `
584
+ .rte-mention {
585
+ display: inline-block;
586
+ padding: 0 6px;
587
+ margin: 0 1px;
588
+ border-radius: 10px;
589
+ background: #e8f0ff;
590
+ color: #1d4ed8;
591
+ font-weight: 600;
592
+ line-height: 1.6;
593
+ white-space: nowrap;
594
+ cursor: pointer;
595
+ }
596
+
597
+ .rte-mention-panel {
598
+ width: min(320px, calc(100vw - 16px));
599
+ max-height: min(320px, calc(100vh - 32px));
600
+ overflow: hidden;
601
+ border: 1px solid #d9dfeb;
602
+ border-radius: 3px;
603
+ background: #ffffff;
604
+ box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
605
+ z-index: 2147483646;
606
+ }
607
+
608
+ .rte-mention-list {
609
+ max-height: min(300px, calc(100vh - 56px));
610
+ overflow: auto;
611
+ padding: 0px;
612
+ }
613
+
614
+ .rte-mention-item {
615
+ width: 100%;
616
+ display: flex;
617
+ align-items: center;
618
+ justify-content: space-between;
619
+ gap: 12px;
620
+ border: none;
621
+ background: transparent;
622
+ padding: 10px 12px;
623
+ border-radius: 0px;
624
+ color: #0f172a;
625
+ text-align: left;
626
+ cursor: pointer;
627
+ font: inherit;
628
+ }
629
+
630
+ .rte-mention-item:hover,
631
+ .rte-mention-item.active {
632
+ background: #eff6ff;
633
+ color: #1d4ed8;
634
+ }
635
+
636
+ .rte-mention-item-label mark {
637
+ background: rgba(59, 130, 246, 0.16);
638
+ color: inherit;
639
+ padding: 0 2px;
640
+ border-radius: 3px;
641
+ }
642
+
643
+ .rte-mention-item-meta {
644
+ font-size: 12px;
645
+ color: #64748b;
646
+ white-space: nowrap;
647
+ }
648
+
649
+ .rte-mention-empty {
650
+ padding: 12px;
651
+ color: #64748b;
652
+ font-size: 13px;
653
+ text-align: center;
654
+ }
655
+
656
+ ${y} .rte-mention {
657
+ background: rgba(37, 99, 235, 0.25);
658
+ color: #bfdbfe;
659
+ }
660
+
661
+ ${y} .rte-mention-panel,
662
+ .rte-mention-panel.rte-mention-theme-dark {
663
+ border-color: #364152;
664
+ background: #1f2937;
665
+ box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
666
+ }
667
+
668
+ ${y} .rte-mention-item,
669
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item {
670
+ color: #e5e7eb;
671
+ }
672
+
673
+ ${y} .rte-mention-item:hover,
674
+ ${y} .rte-mention-item.active,
675
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item:hover,
676
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item.active {
677
+ background: #334155;
678
+ color: #bfdbfe;
679
+ }
680
+
681
+ ${y} .rte-mention-item-meta,
682
+ ${y} .rte-mention-empty,
683
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item-meta,
684
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-empty {
685
+ color: #9ca3af;
686
+ }
687
+ `, document.head.appendChild(e);
688
+ }
689
+ function Ce(e) {
690
+ const n = (e.triggerChars || ["@"]).filter((o) => typeof o == "string" && o.length > 0).map((o) => o[0]);
691
+ return {
692
+ triggerChars: n.length > 0 ? n : ["@"],
693
+ minChars: Math.max(0, e.minChars ?? 1),
694
+ maxQueryLength: Math.max(1, e.maxQueryLength ?? 32),
695
+ maxSuggestions: Math.max(1, e.maxSuggestions ?? 8),
696
+ items: e.items || [
697
+ { id: "john.doe", label: "John Doe", meta: "john@acme.com" },
698
+ { id: "sarah.lee", label: "Sarah Lee", meta: "sarah@acme.com" },
699
+ { id: "alex.chen", label: "Alex Chen", meta: "alex@acme.com" }
700
+ ],
701
+ api: e.api,
702
+ search: e.search,
703
+ itemRenderer: e.itemRenderer,
704
+ emptyStateText: e.emptyStateText || "Type to search mentions",
705
+ noResultsText: e.noResultsText || "No matching mentions",
706
+ loadingText: e.loadingText || "Loading...",
707
+ insertSpaceAfterMention: e.insertSpaceAfterMention !== !1
708
+ };
709
+ }
710
+ function M(e) {
711
+ const n = R.get(e);
712
+ if (n)
713
+ return n;
714
+ const o = Ee(e);
715
+ return R.set(e, o), o;
716
+ }
717
+ function ve(e) {
718
+ S || (S = !0, w = (n) => {
719
+ const o = n.target;
720
+ if (!(o instanceof Node))
721
+ return;
722
+ const t = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement, r = (t == null ? void 0 : t.closest(g)) || null;
723
+ if (!r)
724
+ return;
725
+ const i = M(r);
726
+ D(r, i, e);
727
+ }, document.addEventListener("focusin", w, !0));
728
+ }
729
+ function ke() {
730
+ !S || !w || (document.removeEventListener("focusin", w, !0), S = !1, w = null);
731
+ }
732
+ const Me = (e = {}) => {
733
+ Te();
734
+ const n = Ce(e);
735
+ return {
736
+ name: "mentions",
737
+ toolbar: [
738
+ {
739
+ label: "Mention",
740
+ command: "insertMention",
741
+ 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>'
742
+ }
743
+ ],
744
+ commands: {
745
+ insertMention: (o, t) => {
746
+ const r = re(t);
747
+ if (!r)
748
+ return !1;
749
+ const i = M(r);
750
+ D(r, i, n);
751
+ let a = b(r);
752
+ a || (a = document.createRange(), a.selectNodeContents(r), a.collapse(!1), h(r, a));
753
+ const l = O(r, a.cloneRange(), "after");
754
+ A(l, a) || (h(r, l), a = l), i.query = "";
755
+ const s = a.cloneRange();
756
+ return i.trigger = n.triggerChars[0], J(i, n, a, "", i.trigger, s), !0;
757
+ }
758
+ },
759
+ init: () => {
760
+ k += 1, ve(n), Array.from(document.querySelectorAll(g)).forEach((t) => {
761
+ const r = M(t);
762
+ D(t, r, n);
763
+ });
764
+ },
765
+ destroy: () => {
766
+ k = Math.max(0, k - 1), Array.from(document.querySelectorAll(g)).forEach((t) => {
767
+ f(M(t)), we(t), xe(t);
768
+ }), k === 0 && ke();
769
+ }
770
+ };
771
+ };
772
+ export {
773
+ Me as MentionPlugin
774
+ };