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