@editora/core 1.0.7 → 1.0.8

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 (34) hide show
  1. package/LICENSE +21 -0
  2. package/dist/ApprovalWorkflowPlugin.native-C3jtAYjG.mjs +1076 -0
  3. package/dist/BlocksLibraryPlugin.native-HMWKxWNs.mjs +1327 -0
  4. package/dist/CitationsPlugin.native-BnU0qCwR.mjs +1464 -0
  5. package/dist/ConditionalContentPlugin.native-CfhY46rU.mjs +1367 -0
  6. package/dist/ContentRulesPlugin.native-nBLQ8QFZ.mjs +1099 -0
  7. package/dist/DataBindingPlugin.native-jQ1JPRTp.mjs +917 -0
  8. package/dist/DocSchemaPlugin.native-CHOge18O.mjs +1325 -0
  9. package/dist/MentionPlugin.native-BMDlOqur.mjs +734 -0
  10. package/dist/PIIRedactionPlugin.native-DcsjmtV1.mjs +1396 -0
  11. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +37 -37
  12. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +30 -30
  13. package/dist/SlashCommandsPlugin.native-CmxvMEaE.mjs +755 -0
  14. package/dist/SmartPastePlugin.native-BOKKtF07.mjs +1398 -0
  15. package/dist/TrackChangesPlugin.native-Bghu2q4a.mjs +761 -0
  16. package/dist/TranslationWorkflowPlugin.native-Bz6jDGvj.mjs +1728 -0
  17. package/dist/VersionDiffPlugin.native-Bvxgy--t.mjs +776 -0
  18. package/dist/editora.min.js +13 -13
  19. package/dist/editora.umd.js +13 -13
  20. package/dist/index-D1LOqg5C.js +10 -0
  21. package/dist/{index-yzU4NdPT.mjs → index-DqC57IEH.mjs} +424 -331
  22. package/dist/index.cjs.js +1 -1
  23. package/dist/index.esm.js +2 -2
  24. package/dist/plugin-loader.js +77 -40
  25. package/dist/webcomponent-core.js +479 -386
  26. package/dist/webcomponent-core.min.css +1 -1
  27. package/dist/webcomponent-core.min.js +39 -39
  28. package/dist/webcomponent.cjs.js +1 -1
  29. package/dist/webcomponent.esm.js +1 -1
  30. package/dist/webcomponent.js +417 -287
  31. package/dist/webcomponent.min.css +1 -1
  32. package/dist/webcomponent.min.js +5664 -394
  33. package/package.json +2 -2
  34. package/dist/index-BpE6GFbz.js +0 -10
@@ -0,0 +1,734 @@
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) return;
5
+ const o = window.execEditorCommand || window.executeEditorCommand;
6
+ if (typeof o == "function")
7
+ try {
8
+ o("recordDomTransaction", e, n, e.innerHTML);
9
+ } catch (t) {
10
+ }
11
+ }
12
+ function J(e) {
13
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
14
+ }
15
+ function h(e, n) {
16
+ const o = window.getSelection();
17
+ o && (o.removeAllRanges(), o.addRange(n), e.focus({ preventScroll: !0 }));
18
+ }
19
+ function A(e, n) {
20
+ return e.startContainer === n.startContainer && e.startOffset === n.startOffset && e.endContainer === n.endContainer && e.endOffset === n.endOffset;
21
+ }
22
+ function E(e) {
23
+ const n = window.getSelection();
24
+ if (!n || n.rangeCount === 0) return null;
25
+ const o = n.getRangeAt(0);
26
+ return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
27
+ }
28
+ function C(e) {
29
+ Array.from(e.querySelectorAll(w)).forEach((o) => {
30
+ o.setAttribute("data-mention", "true"), o.setAttribute("contenteditable", "false"), o.setAttribute("spellcheck", "false"), o.setAttribute("draggable", "false"), o.classList.add("rte-mention");
31
+ });
32
+ }
33
+ function Q(e) {
34
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
35
+ }
36
+ function ae(e) {
37
+ return e.closest(ie) || e;
38
+ }
39
+ function L(e) {
40
+ 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;
41
+ }
42
+ function le(e) {
43
+ const n = ae(e);
44
+ if (L(n)) return !0;
45
+ const o = n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
46
+ return L(o) ? !0 : L(document.documentElement) || L(document.body);
47
+ }
48
+ function Z(e, n) {
49
+ e.classList.remove("rte-mention-theme-dark"), le(n) && e.classList.add("rte-mention-theme-dark");
50
+ }
51
+ function se(e) {
52
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
53
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
54
+ const t = e.editorElement;
55
+ if (t.matches(p)) return t;
56
+ const r = t.querySelector(p);
57
+ if (r instanceof HTMLElement) return r;
58
+ }
59
+ const n = window.getSelection();
60
+ if (n && n.rangeCount > 0) {
61
+ const t = n.getRangeAt(0).startContainer, r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement, i = r == null ? void 0 : r.closest(p);
62
+ if (i) return i;
63
+ }
64
+ const o = document.activeElement;
65
+ if (o) {
66
+ if (o.matches(p)) return o;
67
+ const t = o.closest(p);
68
+ if (t) return t;
69
+ }
70
+ return document.querySelector(p);
71
+ }
72
+ function x(e) {
73
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
74
+ }
75
+ function q(e) {
76
+ return typeof e == "object" && e !== null && !Array.isArray(e);
77
+ }
78
+ function ce(e, n) {
79
+ return n ? n.split(".").filter(Boolean).reduce((o, t) => {
80
+ if (!(!q(o) && !Array.isArray(o)))
81
+ return o[t];
82
+ }, e) : e;
83
+ }
84
+ function ue(e) {
85
+ return e ? /\s|[([{"'`]/.test(e) : !0;
86
+ }
87
+ function de(e) {
88
+ if (!e.collapsed) return null;
89
+ const n = e.startContainer, o = e.startOffset;
90
+ if (n.nodeType === Node.TEXT_NODE) {
91
+ const t = n;
92
+ return {
93
+ node: t,
94
+ textBefore: t.data.slice(0, o),
95
+ caretOffset: o
96
+ };
97
+ }
98
+ if (n.nodeType === Node.ELEMENT_NODE) {
99
+ const t = n;
100
+ if (o > 0) {
101
+ const r = t.childNodes[o - 1];
102
+ if (r && r.nodeType === Node.TEXT_NODE) {
103
+ const i = r;
104
+ return {
105
+ node: i,
106
+ textBefore: i.data,
107
+ caretOffset: i.length
108
+ };
109
+ }
110
+ }
111
+ }
112
+ return null;
113
+ }
114
+ function fe(e, n, o) {
115
+ let t = -1, r = "";
116
+ if (n.forEach((a) => {
117
+ const l = e.lastIndexOf(a);
118
+ l > t && (t = l, r = a);
119
+ }), t < 0 || !ue(e[t - 1])) return null;
120
+ const i = e.slice(t + 1);
121
+ return /\s/.test(i) || i.length > o ? null : {
122
+ trigger: r,
123
+ query: i,
124
+ startOffset: t
125
+ };
126
+ }
127
+ function me(e, n) {
128
+ const o = n.cloneRange();
129
+ o.collapse(!1);
130
+ const t = o.getClientRects();
131
+ if (t.length > 0)
132
+ return t[t.length - 1];
133
+ const r = document.createElement("span");
134
+ r.textContent = "​", r.style.position = "relative", o.insertNode(r);
135
+ const i = r.getBoundingClientRect();
136
+ return r.remove(), e.normalize(), i;
137
+ }
138
+ function ge(e, n) {
139
+ if (e.panel && e.list) return;
140
+ const o = document.createElement("div");
141
+ o.className = "rte-mention-panel", o.style.display = "none";
142
+ const t = document.createElement("div");
143
+ 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) => {
144
+ r.preventDefault();
145
+ }), o.addEventListener("click", (r) => {
146
+ const i = r.target;
147
+ if (!i) return;
148
+ const a = i.closest(".rte-mention-item");
149
+ if (!a) return;
150
+ const l = Number(a.getAttribute("data-index"));
151
+ Number.isFinite(l) && ee(e, n, l);
152
+ });
153
+ }
154
+ function m(e) {
155
+ 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);
156
+ }
157
+ function U(e, n) {
158
+ if (!e.panel) return;
159
+ Z(e.panel, e.editor);
160
+ const o = me(e.editor, n), t = e.panel;
161
+ t.style.display = "block", t.classList.add("show"), t.style.left = "0px", t.style.top = "0px";
162
+ const r = t.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
163
+ let l = Math.max(8, Math.min(o.left, i - r.width - 8)), s = o.bottom + 8;
164
+ 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`;
165
+ }
166
+ function pe(e, n) {
167
+ if (!n) return x(e);
168
+ const o = e.toLowerCase(), t = n.toLowerCase(), r = o.indexOf(t);
169
+ if (r < 0) return x(e);
170
+ const i = x(e.slice(0, r)), a = x(e.slice(r, r + n.length)), l = x(e.slice(r + n.length));
171
+ return `${i}<mark>${a}</mark>${l}`;
172
+ }
173
+ function W(e, n) {
174
+ if (!e.list) return;
175
+ const o = e.list;
176
+ if (o.innerHTML = "", e.loading) {
177
+ const t = document.createElement("div");
178
+ t.className = "rte-mention-empty", t.textContent = n.loadingText, o.appendChild(t);
179
+ return;
180
+ }
181
+ if (e.items.length === 0) {
182
+ const t = document.createElement("div");
183
+ t.className = "rte-mention-empty", t.textContent = e.query.length > 0 ? n.noResultsText : n.emptyStateText, o.appendChild(t);
184
+ return;
185
+ }
186
+ e.items.forEach((t, r) => {
187
+ const i = document.createElement("button");
188
+ i.type = "button", i.className = "rte-mention-item", r === e.activeIndex && i.classList.add("active"), i.setAttribute("data-index", String(r));
189
+ 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>` : ""}`;
190
+ i.innerHTML = a, o.appendChild(i);
191
+ });
192
+ }
193
+ function Y(e, n) {
194
+ const o = /* @__PURE__ */ new Set(), t = [];
195
+ return e.forEach((r) => {
196
+ const i = (r.id || "").trim();
197
+ !i || o.has(i) || (o.add(i), t.push({
198
+ id: i,
199
+ label: r.label || i,
200
+ value: r.value,
201
+ meta: r.meta
202
+ }));
203
+ }), t.slice(0, n);
204
+ }
205
+ function he(e, n) {
206
+ if (e.buildRequest) {
207
+ const c = e.buildRequest(n);
208
+ return {
209
+ url: c.url,
210
+ init: c.init || {}
211
+ };
212
+ }
213
+ 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 = {
214
+ method: o,
215
+ headers: { ...t },
216
+ credentials: e.credentials,
217
+ mode: e.mode,
218
+ cache: e.cache,
219
+ signal: n.signal
220
+ }, f = new URL(e.url, window.location.origin);
221
+ if (o === "GET" || o === "HEAD") {
222
+ const c = new URLSearchParams(f.search);
223
+ 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();
224
+ } else {
225
+ const c = typeof e.body == "function" ? e.body(n) : e.body, u = {
226
+ [r]: n.query,
227
+ [i]: n.trigger,
228
+ [a]: n.limit,
229
+ ...l
230
+ }, g = c != null ? c : u;
231
+ if (q(g)) {
232
+ s.body = JSON.stringify(g);
233
+ const y = s.headers;
234
+ !y["Content-Type"] && !y["content-type"] && (y["Content-Type"] = "application/json");
235
+ } else
236
+ s.body = g;
237
+ }
238
+ return { url: f.toString(), init: s };
239
+ }
240
+ async function ye(e, n, o, t) {
241
+ var f, c;
242
+ const r = n.api;
243
+ if (!r) return [];
244
+ e.abortController && e.abortController.abort();
245
+ const i = new AbortController();
246
+ e.abortController = i;
247
+ const a = {
248
+ query: o,
249
+ trigger: t,
250
+ limit: n.maxSuggestions,
251
+ signal: i.signal
252
+ }, l = Math.max(0, (f = r.timeoutMs) != null ? f : 1e4);
253
+ let s = null;
254
+ l > 0 && (s = window.setTimeout(() => i.abort(), l));
255
+ try {
256
+ const { url: u, init: g } = he(r, a), y = await fetch(u, {
257
+ ...g,
258
+ signal: i.signal
259
+ });
260
+ if (!y.ok)
261
+ throw new Error(`Mention API request failed: ${y.status}`);
262
+ const v = (r.responseType || "json") === "text" ? await y.text() : await y.json();
263
+ let I = [];
264
+ if (r.transformResponse)
265
+ I = r.transformResponse(v, a) || [];
266
+ else {
267
+ const P = ce(v, r.responsePath);
268
+ I = (Array.isArray(P) ? P : Array.isArray(v) ? v : []).map((d, re) => {
269
+ var _, $, B, j, z;
270
+ if (r.mapItem)
271
+ return r.mapItem(d, re);
272
+ if (!q(d)) return null;
273
+ const H = String((B = ($ = (_ = d.id) != null ? _ : d.value) != null ? $ : d.key) != null ? B : "").trim();
274
+ if (!H) return null;
275
+ const oe = String((z = (j = d.label) != null ? j : d.name) != null ? z : H).trim();
276
+ return {
277
+ id: H,
278
+ label: oe,
279
+ value: d.value ? String(d.value) : void 0,
280
+ meta: d.meta ? String(d.meta) : void 0
281
+ };
282
+ }).filter((d) => !!d);
283
+ }
284
+ return Y(I, n.maxSuggestions);
285
+ } catch (u) {
286
+ return (u == null ? void 0 : u.name) !== "AbortError" && ((c = r.onError) == null || c.call(r, u, a)), [];
287
+ } finally {
288
+ s !== null && window.clearTimeout(s), e.abortController === i && (e.abortController = null);
289
+ }
290
+ }
291
+ async function be(e, n, o, t) {
292
+ const r = ++e.requestId;
293
+ let i = [];
294
+ if (n.search) {
295
+ const a = await n.search(o, t);
296
+ i = Array.isArray(a) ? a : [];
297
+ } else if (n.api)
298
+ i = await ye(e, n, o, t);
299
+ else {
300
+ const a = o.toLowerCase();
301
+ i = n.items.filter((l) => a ? l.label.toLowerCase().includes(a) || l.id.toLowerCase().includes(a) : !0);
302
+ }
303
+ return r !== e.requestId ? [] : Y(i, n.maxSuggestions);
304
+ }
305
+ function Ee(e, n, o) {
306
+ const t = e.editor;
307
+ if (C(t), !window.getSelection()) return !1;
308
+ const i = t.innerHTML;
309
+ let a = e.replaceRange ? e.replaceRange.cloneRange() : E(t);
310
+ if (!a || !t.contains(a.commonAncestorContainer) && (a = E(t), !a))
311
+ return !1;
312
+ const l = O(t, a.cloneRange(), "after");
313
+ A(l, a) || (h(t, l), a = l), a.deleteContents();
314
+ const s = document.createElement("span");
315
+ 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);
316
+ let f = s, c = 1;
317
+ if (n.insertSpaceAfterMention) {
318
+ const g = document.createTextNode(" ");
319
+ s.after(g), f = g, c = 1;
320
+ }
321
+ const u = document.createRange();
322
+ return u.setStart(f, c), u.collapse(!0), h(t, u), m(e), C(t), J(t), X(t, i), !0;
323
+ }
324
+ function ee(e, n, o) {
325
+ if (o < 0 || o >= e.items.length) return;
326
+ const t = e.items[o];
327
+ Ee(e, n, t);
328
+ }
329
+ function xe(e) {
330
+ return e.startContainer !== e.endContainer || e.startContainer.nodeType !== Node.ELEMENT_NODE || e.endOffset - e.startOffset !== 1 ? null : e.startContainer.childNodes[e.startOffset] || null;
331
+ }
332
+ function we(e, n) {
333
+ const o = xe(e);
334
+ return !(o instanceof HTMLElement) || !o.matches(w) || !n.contains(o) ? null : o;
335
+ }
336
+ function ne(e, n) {
337
+ const o = we(e, n);
338
+ if (o) return o;
339
+ const t = Q(e.startContainer), r = t == null ? void 0 : t.closest(w);
340
+ if (r && n.contains(r)) return r;
341
+ const i = Q(e.endContainer), a = i == null ? void 0 : i.closest(w);
342
+ return a && n.contains(a) ? a : null;
343
+ }
344
+ function O(e, n, o = "after") {
345
+ const t = ne(n, e);
346
+ if (!t) return n;
347
+ const r = document.createRange();
348
+ return o === "before" ? r.setStartBefore(t) : r.setStartAfter(t), r.collapse(!0), r;
349
+ }
350
+ function G(e, n, o = "after") {
351
+ const t = document.createRange();
352
+ o === "before" ? t.setStartBefore(n) : t.setStartAfter(n), t.collapse(!0), h(e, t);
353
+ }
354
+ function Te(e, n, o) {
355
+ if (!e.collapsed) return null;
356
+ const t = e.startContainer, r = e.startOffset;
357
+ let i = null;
358
+ if (t.nodeType === Node.TEXT_NODE) {
359
+ const a = t;
360
+ n === "backward" && r === 0 ? i = a.previousSibling : n === "forward" && r === a.length && (i = a.nextSibling);
361
+ } else if (t.nodeType === Node.ELEMENT_NODE) {
362
+ const a = t;
363
+ n === "backward" && r > 0 ? i = a.childNodes[r - 1] || null : n === "forward" && r < a.childNodes.length && (i = a.childNodes[r] || null);
364
+ }
365
+ return !(i instanceof HTMLElement) || !i.matches(w) || !o.contains(i) ? null : i;
366
+ }
367
+ function K(e, n) {
368
+ const o = E(e);
369
+ if (!o) return !1;
370
+ const t = Te(o, n, e);
371
+ if (!t) return !1;
372
+ const r = t.parentNode;
373
+ if (!r) return !1;
374
+ const i = e.innerHTML, a = Array.prototype.indexOf.call(r.childNodes, t);
375
+ t.remove();
376
+ const l = document.createRange();
377
+ return l.setStart(r, Math.max(0, a)), l.collapse(!0), h(e, l), J(e), X(e, i), !0;
378
+ }
379
+ function te(e, n, o, t, r, i) {
380
+ var s;
381
+ 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) return;
382
+ e.isOpen || (e.panel.style.display = "block", e.panel.classList.add("show"), e.isOpen = !0), W(e, n), U(e, o);
383
+ const a = () => {
384
+ e.debounceHandle = null, be(e, n, t, r).then((f) => {
385
+ e.loading = !1, e.items = f, e.activeIndex = 0, e.panel && (W(e, n), U(e, o));
386
+ });
387
+ }, l = n.api && !n.search ? Math.max(0, (s = n.api.debounceMs) != null ? s : 180) : 0;
388
+ l > 0 ? e.debounceHandle = window.setTimeout(a, l) : a();
389
+ }
390
+ function Ce(e, n) {
391
+ const o = e.editor;
392
+ C(o);
393
+ let t = E(o);
394
+ if (!t || !t.collapsed) {
395
+ m(e);
396
+ return;
397
+ }
398
+ const r = O(o, t.cloneRange(), "after");
399
+ if (!A(r, t)) {
400
+ h(o, r), t = r, m(e);
401
+ return;
402
+ }
403
+ const i = de(t);
404
+ if (!i) {
405
+ m(e);
406
+ return;
407
+ }
408
+ const a = fe(i.textBefore, n.triggerChars, n.maxQueryLength);
409
+ if (!a) {
410
+ m(e);
411
+ return;
412
+ }
413
+ if (a.query.length < n.minChars) {
414
+ m(e);
415
+ return;
416
+ }
417
+ const l = t.cloneRange();
418
+ l.setStart(i.node, a.startOffset), l.setEnd(i.node, i.caretOffset), te(e, n, t, a.query, a.trigger, l);
419
+ }
420
+ function V(e, n) {
421
+ if (e.items.length === 0) return;
422
+ const o = e.items.length;
423
+ if (e.activeIndex = ((e.activeIndex + n) % o + o) % o, !e.list) return;
424
+ const t = Array.from(e.list.querySelectorAll(".rte-mention-item"));
425
+ t.forEach((i, a) => i.classList.toggle("active", a === e.activeIndex));
426
+ const r = t[e.activeIndex];
427
+ r == null || r.scrollIntoView({ block: "nearest" });
428
+ }
429
+ function ve(e) {
430
+ return {
431
+ editor: e,
432
+ panel: null,
433
+ list: null,
434
+ replaceRange: null,
435
+ items: [],
436
+ activeIndex: 0,
437
+ query: "",
438
+ trigger: "@",
439
+ loading: !1,
440
+ isOpen: !1,
441
+ requestId: 0,
442
+ debounceHandle: null,
443
+ abortController: null
444
+ };
445
+ }
446
+ function ke(e) {
447
+ var o;
448
+ const n = R.get(e);
449
+ n && ((o = n.panel) != null && o.parentNode && n.panel.parentNode.removeChild(n.panel), R.delete(e));
450
+ }
451
+ function D(e, n, o) {
452
+ if (N.has(e)) return;
453
+ C(e);
454
+ const t = {
455
+ beforeInput: (r) => {
456
+ C(e);
457
+ const i = E(e);
458
+ if (!i) return;
459
+ const a = ne(i, e);
460
+ if (!a) return;
461
+ const l = r.inputType || "";
462
+ if (l.startsWith("insert")) {
463
+ if (r.preventDefault(), G(e, a, "after"), l === "insertParagraph" || l === "insertLineBreak") {
464
+ const s = l === "insertLineBreak" ? "insertLineBreak" : "insertParagraph";
465
+ document.execCommand(s, !1);
466
+ return;
467
+ }
468
+ if (l === "insertText" || l === "insertCompositionText") {
469
+ const s = r.data || "";
470
+ if (!s) return;
471
+ document.execCommand("insertText", !1, s);
472
+ }
473
+ }
474
+ },
475
+ input: () => {
476
+ Ce(n, o);
477
+ },
478
+ keydown: (r) => {
479
+ if (n.isOpen) {
480
+ if (r.key === "ArrowDown") {
481
+ r.preventDefault(), V(n, 1);
482
+ return;
483
+ }
484
+ if (r.key === "ArrowUp") {
485
+ r.preventDefault(), V(n, -1);
486
+ return;
487
+ }
488
+ if (r.key === "Enter" || r.key === "Tab") {
489
+ r.preventDefault(), ee(n, o, n.activeIndex);
490
+ return;
491
+ }
492
+ if (r.key === "Escape") {
493
+ r.preventDefault(), m(n);
494
+ return;
495
+ }
496
+ }
497
+ const i = E(e);
498
+ if (i) {
499
+ const a = O(e, i.cloneRange(), "after");
500
+ if (!A(a, i)) {
501
+ if (r.key === "Enter") {
502
+ r.preventDefault(), h(e, a), document.execCommand("insertParagraph", !1);
503
+ return;
504
+ }
505
+ r.key.length === 1 && !r.metaKey && !r.ctrlKey && !r.altKey && h(e, a);
506
+ }
507
+ }
508
+ if (r.key === "Backspace" && K(e, "backward")) {
509
+ r.preventDefault();
510
+ return;
511
+ }
512
+ if (r.key === "Delete" && K(e, "forward")) {
513
+ r.preventDefault();
514
+ return;
515
+ }
516
+ },
517
+ click: (r) => {
518
+ const i = r.target;
519
+ if (!i) return;
520
+ const a = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement, l = a == null ? void 0 : a.closest(w);
521
+ !l || !e.contains(l) || (r.preventDefault(), r.stopPropagation(), G(e, l, "after"), m(n));
522
+ },
523
+ blur: () => {
524
+ window.setTimeout(() => {
525
+ const r = document.activeElement;
526
+ n.panel && r && n.panel.contains(r) || m(n);
527
+ }, 0);
528
+ },
529
+ mousedown: (r) => {
530
+ if (!n.isOpen || !n.panel) return;
531
+ const i = r.target;
532
+ i && !n.panel.contains(i) && !e.contains(i) && m(n);
533
+ }
534
+ };
535
+ 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);
536
+ }
537
+ function Le(e) {
538
+ const n = N.get(e);
539
+ 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));
540
+ }
541
+ function Me() {
542
+ if (F || typeof document == "undefined") return;
543
+ F = !0;
544
+ const e = document.createElement("style");
545
+ e.id = "rte-mention-plugin-styles", e.textContent = `
546
+ .rte-mention {
547
+ display: inline-block;
548
+ padding: 0 6px;
549
+ margin: 0 1px;
550
+ border-radius: 10px;
551
+ background: #e8f0ff;
552
+ color: #1d4ed8;
553
+ font-weight: 600;
554
+ line-height: 1.6;
555
+ white-space: nowrap;
556
+ cursor: pointer;
557
+ }
558
+
559
+ .rte-mention-panel {
560
+ width: min(320px, calc(100vw - 16px));
561
+ max-height: min(320px, calc(100vh - 32px));
562
+ overflow: hidden;
563
+ border: 1px solid #d9dfeb;
564
+ border-radius: 3px;
565
+ background: #ffffff;
566
+ box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
567
+ z-index: 2147483646;
568
+ }
569
+
570
+ .rte-mention-list {
571
+ max-height: min(300px, calc(100vh - 56px));
572
+ overflow: auto;
573
+ padding: 0px;
574
+ }
575
+
576
+ .rte-mention-item {
577
+ width: 100%;
578
+ display: flex;
579
+ align-items: center;
580
+ justify-content: space-between;
581
+ gap: 12px;
582
+ border: none;
583
+ background: transparent;
584
+ padding: 10px 12px;
585
+ border-radius: 0px;
586
+ color: #0f172a;
587
+ text-align: left;
588
+ cursor: pointer;
589
+ font: inherit;
590
+ }
591
+
592
+ .rte-mention-item:hover,
593
+ .rte-mention-item.active {
594
+ background: #eff6ff;
595
+ color: #1d4ed8;
596
+ }
597
+
598
+ .rte-mention-item-label mark {
599
+ background: rgba(59, 130, 246, 0.16);
600
+ color: inherit;
601
+ padding: 0 2px;
602
+ border-radius: 3px;
603
+ }
604
+
605
+ .rte-mention-item-meta {
606
+ font-size: 12px;
607
+ color: #64748b;
608
+ white-space: nowrap;
609
+ }
610
+
611
+ .rte-mention-empty {
612
+ padding: 12px;
613
+ color: #64748b;
614
+ font-size: 13px;
615
+ text-align: center;
616
+ }
617
+
618
+ ${b} .rte-mention {
619
+ background: rgba(37, 99, 235, 0.25);
620
+ color: #bfdbfe;
621
+ }
622
+
623
+ ${b} .rte-mention-panel,
624
+ .rte-mention-panel.rte-mention-theme-dark {
625
+ border-color: #364152;
626
+ background: #1f2937;
627
+ box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
628
+ }
629
+
630
+ ${b} .rte-mention-item,
631
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item {
632
+ color: #e5e7eb;
633
+ }
634
+
635
+ ${b} .rte-mention-item:hover,
636
+ ${b} .rte-mention-item.active,
637
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item:hover,
638
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item.active {
639
+ background: #334155;
640
+ color: #bfdbfe;
641
+ }
642
+
643
+ ${b} .rte-mention-item-meta,
644
+ ${b} .rte-mention-empty,
645
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-item-meta,
646
+ .rte-mention-panel.rte-mention-theme-dark .rte-mention-empty {
647
+ color: #9ca3af;
648
+ }
649
+ `, document.head.appendChild(e);
650
+ }
651
+ function Re(e) {
652
+ var o, t, r;
653
+ const n = (e.triggerChars || ["@"]).filter((i) => typeof i == "string" && i.length > 0).map((i) => i[0]);
654
+ return {
655
+ triggerChars: n.length > 0 ? n : ["@"],
656
+ minChars: Math.max(0, (o = e.minChars) != null ? o : 1),
657
+ maxQueryLength: Math.max(1, (t = e.maxQueryLength) != null ? t : 32),
658
+ maxSuggestions: Math.max(1, (r = e.maxSuggestions) != null ? r : 8),
659
+ items: e.items || [
660
+ { id: "john.doe", label: "John Doe", meta: "john@acme.com" },
661
+ { id: "sarah.lee", label: "Sarah Lee", meta: "sarah@acme.com" },
662
+ { id: "alex.chen", label: "Alex Chen", meta: "alex@acme.com" }
663
+ ],
664
+ api: e.api,
665
+ search: e.search,
666
+ itemRenderer: e.itemRenderer,
667
+ emptyStateText: e.emptyStateText || "Type to search mentions",
668
+ noResultsText: e.noResultsText || "No matching mentions",
669
+ loadingText: e.loadingText || "Loading...",
670
+ insertSpaceAfterMention: e.insertSpaceAfterMention !== !1
671
+ };
672
+ }
673
+ function M(e) {
674
+ const n = R.get(e);
675
+ if (n) return n;
676
+ const o = ve(e);
677
+ return R.set(e, o), o;
678
+ }
679
+ function Ne(e) {
680
+ S || (S = !0, T = (n) => {
681
+ const o = n.target;
682
+ if (!(o instanceof Node)) return;
683
+ const t = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement, r = (t == null ? void 0 : t.closest(p)) || null;
684
+ if (!r) return;
685
+ const i = M(r);
686
+ D(r, i, e);
687
+ }, document.addEventListener("focusin", T, !0));
688
+ }
689
+ function Se() {
690
+ !S || !T || (document.removeEventListener("focusin", T, !0), S = !1, T = null);
691
+ }
692
+ const Ie = (e = {}) => {
693
+ Me();
694
+ const n = Re(e);
695
+ return {
696
+ name: "mentions",
697
+ toolbar: [
698
+ {
699
+ label: "Mention",
700
+ command: "insertMention",
701
+ 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>'
702
+ }
703
+ ],
704
+ commands: {
705
+ insertMention: (o, t) => {
706
+ const r = se(t);
707
+ if (!r) return !1;
708
+ const i = M(r);
709
+ D(r, i, n);
710
+ let a = E(r);
711
+ a || (a = document.createRange(), a.selectNodeContents(r), a.collapse(!1), h(r, a));
712
+ const l = O(r, a.cloneRange(), "after");
713
+ A(l, a) || (h(r, l), a = l), i.query = "";
714
+ const s = a.cloneRange();
715
+ return i.trigger = n.triggerChars[0], te(i, n, a, "", i.trigger, s), !0;
716
+ }
717
+ },
718
+ init: () => {
719
+ k += 1, Ne(n), Array.from(document.querySelectorAll(p)).forEach((t) => {
720
+ const r = M(t);
721
+ D(t, r, n);
722
+ });
723
+ },
724
+ destroy: () => {
725
+ k = Math.max(0, k - 1), Array.from(document.querySelectorAll(p)).forEach((t) => {
726
+ m(M(t)), Le(t), ke(t);
727
+ }), k === 0 && Se();
728
+ }
729
+ };
730
+ };
731
+ export {
732
+ Ie as MentionPlugin
733
+ };
734
+ //# sourceMappingURL=MentionPlugin.native-BMDlOqur.mjs.map