@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,755 @@
1
+ function O(e, t) {
2
+ const o = Array.from({ length: t }).map(() => "<th><p><br></p></th>").join(""), n = Array.from({ length: e }).map(
3
+ () => `<tr>${Array.from({ length: t }).map(() => "<td><p><br></p></td>").join("")}</tr>`
4
+ ).join("");
5
+ return `<table class="rte-table"><thead><tr>${o}</tr></thead><tbody>${n}</tbody></table><p><br></p>`;
6
+ }
7
+ function q() {
8
+ return [
9
+ {
10
+ id: "paragraph",
11
+ label: "Paragraph",
12
+ description: "Switch to paragraph text",
13
+ command: "paragraph",
14
+ keywords: ["text", "normal", "p"]
15
+ },
16
+ {
17
+ id: "h1",
18
+ label: "Heading 1",
19
+ description: "Large section heading",
20
+ command: "heading1",
21
+ keywords: ["title", "header", "h1"]
22
+ },
23
+ {
24
+ id: "h2",
25
+ label: "Heading 2",
26
+ description: "Medium section heading",
27
+ command: "heading2",
28
+ keywords: ["subtitle", "header", "h2"]
29
+ },
30
+ {
31
+ id: "h3",
32
+ label: "Heading 3",
33
+ description: "Small section heading",
34
+ command: "heading3",
35
+ keywords: ["header", "h3"]
36
+ },
37
+ {
38
+ id: "bulleted-list",
39
+ label: "Bulleted List",
40
+ description: "Create a bullet list",
41
+ command: "toggleBulletList",
42
+ keywords: ["list", "ul", "bullet"]
43
+ },
44
+ {
45
+ id: "numbered-list",
46
+ label: "Numbered List",
47
+ description: "Create a numbered list",
48
+ command: "toggleOrderedList",
49
+ keywords: ["list", "ol", "numbered"]
50
+ },
51
+ {
52
+ id: "blockquote",
53
+ label: "Blockquote",
54
+ description: "Insert a quote block",
55
+ command: "toggleBlockquote",
56
+ keywords: ["quote", "citation"]
57
+ },
58
+ {
59
+ id: "table-3x3",
60
+ label: "Table 3x3",
61
+ description: "Insert a 3 x 3 table",
62
+ action: ({ insertHTML: e }) => e(O(3, 3)),
63
+ keywords: ["table", "grid", "rows", "columns"]
64
+ },
65
+ {
66
+ id: "horizontal-rule",
67
+ label: "Divider",
68
+ description: "Insert a horizontal rule",
69
+ command: "insertHorizontalRule",
70
+ keywords: ["hr", "separator", "line"]
71
+ },
72
+ {
73
+ id: "bold",
74
+ label: "Bold",
75
+ description: "Toggle bold formatting",
76
+ command: "toggleBold",
77
+ keywords: ["strong", "b"]
78
+ },
79
+ {
80
+ id: "italic",
81
+ label: "Italic",
82
+ description: "Toggle italic formatting",
83
+ command: "toggleItalic",
84
+ keywords: ["emphasis", "i"]
85
+ },
86
+ {
87
+ id: "underline",
88
+ label: "Underline",
89
+ description: "Toggle underline formatting",
90
+ command: "toggleUnderline",
91
+ keywords: ["u"]
92
+ },
93
+ {
94
+ id: "strikethrough",
95
+ label: "Strikethrough",
96
+ description: "Toggle strikethrough formatting",
97
+ command: "toggleStrikethrough",
98
+ keywords: ["strike", "s"]
99
+ },
100
+ {
101
+ id: "clear-formatting",
102
+ label: "Clear Formatting",
103
+ description: "Remove text formatting",
104
+ command: "clearFormatting",
105
+ keywords: ["reset", "plain"]
106
+ }
107
+ ];
108
+ }
109
+ function $(e) {
110
+ const t = [], o = /* @__PURE__ */ new Set();
111
+ return e.forEach((n) => {
112
+ const r = String(n.id || "").trim(), i = String(n.label || "").trim();
113
+ !r || !i || o.has(r) || (o.add(r), t.push({
114
+ ...n,
115
+ id: r,
116
+ label: i,
117
+ description: n.description ? String(n.description) : void 0,
118
+ keywords: Array.isArray(n.keywords) ? n.keywords.map((a) => String(a)).filter(Boolean) : void 0
119
+ }));
120
+ }), t;
121
+ }
122
+ function D(e) {
123
+ var r, i, a;
124
+ const t = (e.triggerChar || "/")[0] || "/", o = e.includeDefaultItems !== !1, n = o ? [...e.items || [], ...q()] : e.items || [];
125
+ return {
126
+ triggerChar: t,
127
+ minChars: Math.max(0, (r = e.minChars) != null ? r : 0),
128
+ maxQueryLength: Math.max(1, (i = e.maxQueryLength) != null ? i : 48),
129
+ maxSuggestions: Math.max(1, (a = e.maxSuggestions) != null ? a : 10),
130
+ requireBoundary: e.requireBoundary !== !1,
131
+ includeDefaultItems: o,
132
+ items: $(n),
133
+ itemRenderer: e.itemRenderer,
134
+ emptyStateText: e.emptyStateText || "No commands found",
135
+ panelLabel: e.panelLabel || "Slash commands"
136
+ };
137
+ }
138
+ const u = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark';
139
+ let v = !1;
140
+ function B() {
141
+ if (v || typeof document == "undefined") return;
142
+ v = !0;
143
+ const e = document.createElement("style");
144
+ e.id = "rte-slash-commands-styles", e.textContent = `
145
+ .rte-slash-panel {
146
+ width: min(225px, calc(100vw - 16px));
147
+ max-height: min(360px, calc(100vh - 24px));
148
+ overflow: hidden;
149
+ border: 1px solid #d9dfeb;
150
+ border-radius: 0px;
151
+ background: #ffffff;
152
+ box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
153
+ z-index: 2147483646;
154
+ }
155
+
156
+ .rte-slash-list {
157
+ max-height: min(340px, calc(100vh - 32px));
158
+ overflow: auto;
159
+ padding: 0px;
160
+ display: grid;
161
+ gap: 1px;
162
+ }
163
+
164
+ .rte-slash-item {
165
+ width: 100%;
166
+ border: none;
167
+ background: transparent;
168
+ color: #0f172a;
169
+ border-radius: 0px;
170
+ padding: 6px 9px;
171
+ text-align: left;
172
+ display: grid;
173
+ gap: 0px;
174
+ cursor: pointer;
175
+ font: inherit;
176
+ }
177
+
178
+ .rte-slash-item:hover,
179
+ .rte-slash-item.active {
180
+ background: #eff6ff;
181
+ color: #1d4ed8;
182
+ }
183
+
184
+ .rte-slash-item-title {
185
+ font-size: 13px;
186
+ font-weight: 600;
187
+ line-height: 1.35;
188
+ }
189
+
190
+ .rte-slash-item-description {
191
+ font-size: 12px;
192
+ color: #64748b;
193
+ line-height: 1.35;
194
+ }
195
+
196
+ .rte-slash-item mark {
197
+ background: rgba(59, 130, 246, 0.16);
198
+ color: inherit;
199
+ padding: 0 2px;
200
+ border-radius: 3px;
201
+ }
202
+
203
+ .rte-slash-empty {
204
+ font-size: 13px;
205
+ color: #64748b;
206
+ text-align: center;
207
+ padding: 12px;
208
+ }
209
+
210
+ ${u} .rte-slash-panel {
211
+ border-color: #364152;
212
+ background: #1f2937;
213
+ box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
214
+ }
215
+
216
+ ${u} .rte-slash-item {
217
+ color: #e5e7eb;
218
+ }
219
+
220
+ ${u} .rte-slash-item:hover,
221
+ ${u} .rte-slash-item.active {
222
+ background: #334155;
223
+ color: #bfdbfe;
224
+ }
225
+
226
+ ${u} .rte-slash-item-description,
227
+ ${u} .rte-slash-empty {
228
+ color: #9ca3af;
229
+ }
230
+ `, document.head.appendChild(e);
231
+ }
232
+ const s = ".rte-content, .editora-content", g = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap();
233
+ let b = !1, f = null, h = 0, z = 0;
234
+ function P(e) {
235
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
236
+ }
237
+ function I(e) {
238
+ return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
239
+ }
240
+ function F(e) {
241
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
242
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
243
+ const n = e.editorElement;
244
+ if (n.matches(s)) return n;
245
+ const r = n.querySelector(s);
246
+ if (r instanceof HTMLElement) return r;
247
+ }
248
+ const t = window.getSelection();
249
+ if (t && t.rangeCount > 0) {
250
+ const n = t.getRangeAt(0).startContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, i = r == null ? void 0 : r.closest(s);
251
+ if (i) return i;
252
+ }
253
+ const o = document.activeElement;
254
+ if (o) {
255
+ if (o.matches(s)) return o;
256
+ const n = o.closest(s);
257
+ if (n) return n;
258
+ }
259
+ return document.querySelector(s);
260
+ }
261
+ function m(e) {
262
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
263
+ }
264
+ function _(e) {
265
+ return e ? /\s|[([{"'`]/.test(e) : !0;
266
+ }
267
+ function E(e) {
268
+ const t = window.getSelection();
269
+ if (!t || t.rangeCount === 0) return null;
270
+ const o = t.getRangeAt(0);
271
+ return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
272
+ }
273
+ function y(e, t) {
274
+ const o = window.getSelection();
275
+ o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
276
+ }
277
+ function j(e) {
278
+ if (!e.collapsed) return null;
279
+ const t = e.startContainer, o = e.startOffset;
280
+ if (t.nodeType === Node.TEXT_NODE) {
281
+ const n = t;
282
+ return {
283
+ node: n,
284
+ textBefore: n.data.slice(0, o),
285
+ caretOffset: o
286
+ };
287
+ }
288
+ if (t.nodeType === Node.ELEMENT_NODE) {
289
+ const n = t;
290
+ if (o > 0) {
291
+ const r = n.childNodes[o - 1];
292
+ if (r && r.nodeType === Node.TEXT_NODE) {
293
+ const i = r;
294
+ return {
295
+ node: i,
296
+ textBefore: i.data,
297
+ caretOffset: i.length
298
+ };
299
+ }
300
+ }
301
+ }
302
+ return null;
303
+ }
304
+ function K(e, t, o, n) {
305
+ const r = e.lastIndexOf(t);
306
+ if (r < 0 || n && !_(e[r - 1]))
307
+ return null;
308
+ const i = e.slice(r + 1);
309
+ return /\s/.test(i) || i.length > o ? null : {
310
+ trigger: t,
311
+ query: i,
312
+ startOffset: r
313
+ };
314
+ }
315
+ function Q(e, t) {
316
+ const o = t.cloneRange();
317
+ o.collapse(!1);
318
+ const n = o.getClientRects();
319
+ if (n.length > 0)
320
+ return n[n.length - 1];
321
+ const r = document.createElement("span");
322
+ r.textContent = "​", o.insertNode(r);
323
+ const i = r.getBoundingClientRect();
324
+ return r.remove(), e.normalize(), i;
325
+ }
326
+ function A(e, t) {
327
+ if (!e.panel) return;
328
+ const o = Q(e.editor, t), n = e.panel;
329
+ n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
330
+ const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
331
+ let l = Math.max(8, Math.min(o.left, i - r.width - 8)), d = o.bottom + 8;
332
+ d + r.height > a - 8 && (d = Math.max(8, o.top - r.height - 8)), n.style.position = "fixed", n.style.left = `${l}px`, n.style.top = `${d}px`;
333
+ }
334
+ function k(e, t) {
335
+ if (!t) return m(e);
336
+ const o = e.toLowerCase(), n = t.toLowerCase(), r = o.indexOf(n);
337
+ if (r < 0) return m(e);
338
+ const i = m(e.slice(0, r)), a = m(e.slice(r, r + t.length)), l = m(e.slice(r + t.length));
339
+ return `${i}<mark>${a}</mark>${l}`;
340
+ }
341
+ function U(e, t) {
342
+ if (e.panel && e.list) return;
343
+ const o = document.createElement("div");
344
+ o.className = "rte-slash-panel", o.style.display = "none", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false");
345
+ const n = document.createElement("div");
346
+ n.className = "rte-slash-list", n.setAttribute("role", "listbox"), n.setAttribute("aria-label", t.panelLabel), o.appendChild(n), document.body.appendChild(o), e.panel = o, e.list = n, o.addEventListener("mousedown", (r) => {
347
+ r.preventDefault();
348
+ }), o.addEventListener("click", (r) => {
349
+ const i = r.target;
350
+ if (!i) return;
351
+ const a = i.closest(".rte-slash-item");
352
+ if (!a) return;
353
+ const l = Number(a.getAttribute("data-index"));
354
+ Number.isFinite(l) && M(e, l);
355
+ });
356
+ }
357
+ function c(e) {
358
+ e.panel && (e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.filteredItems = [], e.activeIndex = 0, e.query = "", e.replaceRange = null, e.anchorRange = null);
359
+ }
360
+ function W(e, t, o) {
361
+ if (!t) return e.slice(0, o);
362
+ const n = t.toLowerCase();
363
+ return e.filter((i) => [
364
+ i.id,
365
+ i.label,
366
+ i.description || "",
367
+ i.command || "",
368
+ ...i.keywords || []
369
+ ].join(" ").toLowerCase().includes(n)).slice(0, o);
370
+ }
371
+ function Z(e, t) {
372
+ if (!e.list) return;
373
+ const o = e.list;
374
+ if (o.innerHTML = "", e.filteredItems.length === 0) {
375
+ const n = document.createElement("div");
376
+ n.className = "rte-slash-empty", n.textContent = t.emptyStateText, o.appendChild(n), o.removeAttribute("aria-activedescendant");
377
+ return;
378
+ }
379
+ e.filteredItems.forEach((n, r) => {
380
+ const i = document.createElement("button");
381
+ i.type = "button", i.className = "rte-slash-item", i.setAttribute("role", "option"), i.setAttribute("data-index", String(r)), i.setAttribute("id", `rte-slash-item-${e.instanceId}-${r}`), i.setAttribute("aria-selected", r === e.activeIndex ? "true" : "false"), i.setAttribute("aria-label", n.description ? `${n.label} - ${n.description}` : n.label), r === e.activeIndex && i.classList.add("active"), t.itemRenderer ? i.innerHTML = t.itemRenderer(n, e.query) : i.innerHTML = `
382
+ <span class="rte-slash-item-title">${k(n.label, e.query)}</span>
383
+ ${n.description ? `<span class="rte-slash-item-description">${k(n.description, e.query)}</span>` : ""}
384
+ `, o.appendChild(i);
385
+ }), e.filteredItems.length > 0 && o.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
386
+ }
387
+ function G(e, t) {
388
+ if (t === e.innerHTML) return;
389
+ const o = window.execEditorCommand || window.executeEditorCommand;
390
+ if (typeof o == "function")
391
+ try {
392
+ o("recordDomTransaction", e, t, e.innerHTML);
393
+ } catch (n) {
394
+ }
395
+ }
396
+ function V(e) {
397
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
398
+ }
399
+ function L(e, t) {
400
+ e.focus({ preventScroll: !0 });
401
+ try {
402
+ if (document.execCommand("insertHTML", !1, t))
403
+ return !0;
404
+ } catch (l) {
405
+ }
406
+ const o = window.getSelection();
407
+ if (!o || o.rangeCount === 0) return !1;
408
+ const n = o.getRangeAt(0);
409
+ if (!e.contains(n.commonAncestorContainer)) return !1;
410
+ n.deleteContents();
411
+ const r = document.createElement("template");
412
+ r.innerHTML = t;
413
+ const i = r.content, a = i.lastChild;
414
+ if (n.insertNode(i), a) {
415
+ const l = document.createRange();
416
+ l.setStartAfter(a), l.collapse(!0), y(e, l);
417
+ }
418
+ return !0;
419
+ }
420
+ function X(e, t) {
421
+ e.focus({ preventScroll: !0 });
422
+ try {
423
+ if (document.execCommand("insertText", !1, t))
424
+ return !0;
425
+ } catch (a) {
426
+ }
427
+ const o = window.getSelection();
428
+ if (!o || o.rangeCount === 0) return !1;
429
+ const n = o.getRangeAt(0);
430
+ if (!e.contains(n.commonAncestorContainer)) return !1;
431
+ n.deleteContents();
432
+ const r = document.createTextNode(t);
433
+ n.insertNode(r);
434
+ const i = document.createRange();
435
+ return i.setStart(r, r.length), i.collapse(!0), y(e, i), !0;
436
+ }
437
+ function J(e, t) {
438
+ switch (e.toLowerCase()) {
439
+ case "paragraph":
440
+ case "p":
441
+ return document.execCommand("formatBlock", !1, "<p>");
442
+ case "heading1":
443
+ case "h1":
444
+ return document.execCommand("formatBlock", !1, "<h1>");
445
+ case "heading2":
446
+ case "h2":
447
+ return document.execCommand("formatBlock", !1, "<h2>");
448
+ case "heading3":
449
+ case "h3":
450
+ return document.execCommand("formatBlock", !1, "<h3>");
451
+ case "blockquote":
452
+ case "toggleblockquote":
453
+ return document.execCommand("formatBlock", !1, "<blockquote>");
454
+ case "bulletlist":
455
+ case "togglebulletlist":
456
+ case "insertunorderedlist":
457
+ return document.execCommand("insertUnorderedList");
458
+ case "numberedlist":
459
+ case "toggleorderedlist":
460
+ case "insertorderedlist":
461
+ return document.execCommand("insertOrderedList");
462
+ case "horizontalrule":
463
+ case "divider":
464
+ case "inserthorizontalrule":
465
+ return document.execCommand("insertHorizontalRule");
466
+ case "bold":
467
+ case "togglebold":
468
+ return document.execCommand("bold");
469
+ case "italic":
470
+ case "toggleitalic":
471
+ return document.execCommand("italic");
472
+ case "underline":
473
+ case "toggleunderline":
474
+ return document.execCommand("underline");
475
+ case "strikethrough":
476
+ case "togglestrikethrough":
477
+ return document.execCommand("strikeThrough");
478
+ case "clearformatting":
479
+ case "removeformat":
480
+ return document.execCommand("removeFormat");
481
+ default:
482
+ try {
483
+ return document.execCommand(e, !1, t);
484
+ } catch (n) {
485
+ return !1;
486
+ }
487
+ }
488
+ }
489
+ function S(e, t, o) {
490
+ const n = I(e);
491
+ if (n && typeof n.execCommand == "function")
492
+ try {
493
+ if (n.execCommand(t, o) !== !1) return !0;
494
+ } catch (i) {
495
+ }
496
+ const r = window.execEditorCommand || window.executeEditorCommand;
497
+ if (typeof r == "function")
498
+ try {
499
+ if (r(t, o, {
500
+ editorElement: n,
501
+ contentElement: e
502
+ }) !== !1) return !0;
503
+ } catch (i) {
504
+ }
505
+ return J(t, o);
506
+ }
507
+ async function Y(e, t) {
508
+ const o = e.editor, n = I(o), r = {
509
+ editor: o,
510
+ editorRoot: n,
511
+ query: e.query,
512
+ trigger: e.trigger,
513
+ executeCommand: (i, a) => S(o, i, a),
514
+ insertHTML: (i) => L(o, i)
515
+ };
516
+ return t.action ? await Promise.resolve(t.action(r)) !== !1 : t.insertHTML ? L(o, t.insertHTML) : t.command ? S(o, t.command, t.commandValue) : !1;
517
+ }
518
+ async function M(e, t) {
519
+ if (t < 0 || t >= e.filteredItems.length || !e.replaceRange) return;
520
+ const o = e.filteredItems[t], n = e.editor, r = n.innerHTML, i = `${e.trigger}${e.query}`;
521
+ if (!window.getSelection()) return;
522
+ const l = e.replaceRange.cloneRange();
523
+ if (!n.contains(l.commonAncestorContainer)) return;
524
+ l.deleteContents();
525
+ const d = l.cloneRange();
526
+ d.collapse(!0), y(n, d);
527
+ let x = !1;
528
+ try {
529
+ x = await Y(e, o);
530
+ } catch (le) {
531
+ x = !1;
532
+ }
533
+ c(e), x ? (V(n), G(n, r)) : i && X(n, i), n.focus({ preventScroll: !0 });
534
+ }
535
+ function R(e, t) {
536
+ if (e.filteredItems.length === 0) return;
537
+ const o = e.filteredItems.length;
538
+ if (e.activeIndex = ((e.activeIndex + t) % o + o) % o, !e.list) return;
539
+ const n = Array.from(e.list.querySelectorAll(".rte-slash-item"));
540
+ n.forEach((i, a) => {
541
+ const l = a === e.activeIndex;
542
+ i.classList.toggle("active", l), i.setAttribute("aria-selected", l ? "true" : "false");
543
+ });
544
+ const r = n[e.activeIndex];
545
+ r && (e.list.setAttribute("aria-activedescendant", r.id), r.scrollIntoView({ block: "nearest" }));
546
+ }
547
+ function T(e) {
548
+ if (!(!e.isOpen || !e.panel || !e.anchorRange)) {
549
+ if (!e.editor.isConnected) {
550
+ c(e);
551
+ return;
552
+ }
553
+ A(e, e.anchorRange);
554
+ }
555
+ }
556
+ function N(e, t, o, n, r, i) {
557
+ U(e, t), e.query = n, e.trigger = r, e.replaceRange = i.cloneRange(), e.anchorRange = o.cloneRange(), e.filteredItems = W(e.items, n, t.maxSuggestions), e.activeIndex = 0, e.isOpen = !0, e.panel && (Z(e, t), A(e, o));
558
+ }
559
+ function ee(e, t) {
560
+ const o = e.editor;
561
+ if (o.getAttribute("contenteditable") === "false") {
562
+ c(e);
563
+ return;
564
+ }
565
+ const n = E(o);
566
+ if (!n || !n.collapsed) {
567
+ c(e);
568
+ return;
569
+ }
570
+ const r = j(n);
571
+ if (!r) {
572
+ c(e);
573
+ return;
574
+ }
575
+ const i = K(
576
+ r.textBefore,
577
+ t.triggerChar,
578
+ t.maxQueryLength,
579
+ t.requireBoundary
580
+ );
581
+ if (!i) {
582
+ c(e);
583
+ return;
584
+ }
585
+ if (i.query.length < t.minChars) {
586
+ c(e);
587
+ return;
588
+ }
589
+ const a = n.cloneRange();
590
+ a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset), N(e, t, n, i.query, i.trigger, a);
591
+ }
592
+ function H(e, t) {
593
+ const o = e.editor;
594
+ if (o.getAttribute("contenteditable") === "false")
595
+ return !1;
596
+ let n = E(o);
597
+ n || (n = document.createRange(), n.selectNodeContents(o), n.collapse(!1), y(o, n));
598
+ const r = n.cloneRange();
599
+ return r.collapse(!0), N(e, t, n, "", t.triggerChar, r), !0;
600
+ }
601
+ function te(e) {
602
+ return !(e.metaKey || e.ctrlKey) || e.altKey ? !1 : e.key === "/" || e.code === "Slash";
603
+ }
604
+ function ne(e, t) {
605
+ return {
606
+ editor: e,
607
+ panel: null,
608
+ list: null,
609
+ replaceRange: null,
610
+ items: t.items,
611
+ filteredItems: [],
612
+ activeIndex: 0,
613
+ query: "",
614
+ trigger: t.triggerChar,
615
+ isOpen: !1,
616
+ instanceId: ++z,
617
+ anchorRange: null
618
+ };
619
+ }
620
+ function w(e, t) {
621
+ const o = g.get(e);
622
+ if (o)
623
+ return o.items = t.items, o;
624
+ const n = ne(e, t);
625
+ return g.set(e, n), n;
626
+ }
627
+ function re(e) {
628
+ var o;
629
+ const t = g.get(e);
630
+ t && ((o = t.panel) != null && o.parentNode && t.panel.parentNode.removeChild(t.panel), g.delete(e));
631
+ }
632
+ function C(e, t, o) {
633
+ if (p.has(e)) return;
634
+ const n = {
635
+ input: () => {
636
+ ee(t, o);
637
+ },
638
+ keydown: (r) => {
639
+ if (t.editor.getAttribute("contenteditable") === "false") {
640
+ c(t);
641
+ return;
642
+ }
643
+ if (!t.isOpen && te(r)) {
644
+ r.preventDefault(), H(t, o);
645
+ return;
646
+ }
647
+ if (t.isOpen) {
648
+ if (r.key === "ArrowDown") {
649
+ r.preventDefault(), R(t, 1);
650
+ return;
651
+ }
652
+ if (r.key === "ArrowUp") {
653
+ r.preventDefault(), R(t, -1);
654
+ return;
655
+ }
656
+ if (r.key === "Enter" || r.key === "Tab") {
657
+ if (t.filteredItems.length === 0) {
658
+ r.key === "Tab" && r.preventDefault(), c(t);
659
+ return;
660
+ }
661
+ r.preventDefault(), M(t, t.activeIndex);
662
+ return;
663
+ }
664
+ if (r.key === "Escape") {
665
+ r.preventDefault(), c(t);
666
+ return;
667
+ }
668
+ }
669
+ },
670
+ blur: () => {
671
+ window.setTimeout(() => {
672
+ const r = document.activeElement;
673
+ t.panel && r && t.panel.contains(r) || c(t);
674
+ }, 0);
675
+ },
676
+ mousedown: (r) => {
677
+ if (!t.isOpen || !t.panel) return;
678
+ const i = r.target;
679
+ i && !t.panel.contains(i) && !e.contains(i) && c(t);
680
+ },
681
+ selectionchange: () => {
682
+ if (!t.isOpen) return;
683
+ const r = E(e);
684
+ if (!r || !r.collapsed) {
685
+ c(t);
686
+ return;
687
+ }
688
+ t.anchorRange = r.cloneRange(), T(t);
689
+ },
690
+ reposition: () => {
691
+ T(t);
692
+ }
693
+ };
694
+ e.addEventListener("input", n.input), e.addEventListener("keydown", n.keydown), e.addEventListener("blur", n.blur), document.addEventListener("mousedown", n.mousedown, !0), document.addEventListener("selectionchange", n.selectionchange), window.addEventListener("resize", n.reposition, { passive: !0 }), window.addEventListener("scroll", n.reposition, !0), p.set(e, n);
695
+ }
696
+ function oe(e) {
697
+ const t = p.get(e);
698
+ t && (e.removeEventListener("input", t.input), e.removeEventListener("keydown", t.keydown), e.removeEventListener("blur", t.blur), document.removeEventListener("mousedown", t.mousedown, !0), document.removeEventListener("selectionchange", t.selectionchange), window.removeEventListener("resize", t.reposition), window.removeEventListener("scroll", t.reposition, !0), p.delete(e));
699
+ }
700
+ function ie(e) {
701
+ b || (b = !0, f = (t) => {
702
+ const o = t.target;
703
+ if (!(o instanceof Node)) return;
704
+ const n = P(o), r = (n == null ? void 0 : n.closest(s)) || null;
705
+ if (!r) return;
706
+ const i = w(r, e);
707
+ C(r, i, e);
708
+ }, document.addEventListener("focusin", f, !0));
709
+ }
710
+ function ae() {
711
+ !b || !f || (document.removeEventListener("focusin", f, !0), b = !1, f = null);
712
+ }
713
+ const ce = (e = {}) => {
714
+ B();
715
+ const t = D(e);
716
+ return {
717
+ name: "slashCommands",
718
+ toolbar: [
719
+ {
720
+ id: "slashCommands",
721
+ label: "Slash Commands",
722
+ command: "openSlashCommands",
723
+ icon: '<svg width="24" height="24" focusable="false" aria-hidden="true"><path d="M8.7 20a1 1 0 0 1-.7-.3c-.4-.4-.4-1 0-1.4L15.6 5a1 1 0 0 1 1.4 1.4L9.4 19.7a1 1 0 0 1-.7.3Zm7.8 0c-.3 0-.5 0-.7-.3l-1.8-1.8a1 1 0 1 1 1.4-1.4l1.8 1.8a1 1 0 0 1-.7 1.7Zm-9-12a1 1 0 0 1-.7-1.7L8.6 4.5A1 1 0 1 1 10 6L8.2 7.8a1 1 0 0 1-.7.3Z"></path></svg>'
724
+ }
725
+ ],
726
+ commands: {
727
+ openSlashCommands: (o, n) => {
728
+ const r = F(n);
729
+ if (!r) return !1;
730
+ const i = w(r, t);
731
+ return C(r, i, t), H(i, t);
732
+ }
733
+ },
734
+ keymap: {
735
+ "Mod-/": "openSlashCommands",
736
+ "Mod-Shift-7": "openSlashCommands"
737
+ },
738
+ init: () => {
739
+ h += 1, ie(t), Array.from(document.querySelectorAll(s)).forEach((n) => {
740
+ const r = w(n, t);
741
+ C(n, r, t);
742
+ });
743
+ },
744
+ destroy: () => {
745
+ h = Math.max(0, h - 1), Array.from(document.querySelectorAll(s)).forEach((n) => {
746
+ const r = g.get(n);
747
+ r && (c(r), oe(n), re(n));
748
+ }), h === 0 && ae();
749
+ }
750
+ };
751
+ };
752
+ export {
753
+ ce as SlashCommandsPlugin
754
+ };
755
+ //# sourceMappingURL=SlashCommandsPlugin.native-CmxvMEaE.mjs.map