@editora/core 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +5 -0
  2. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-58d12bed.mjs} +23 -12
  3. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-289a112a.mjs} +112 -102
  4. package/dist/ApprovalWorkflowPlugin.native-449ce66c.mjs +1115 -0
  5. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-8aceb5cc.mjs} +16 -9
  6. package/dist/{BlockquotePlugin.native-JFmOLsxN.mjs → BlockquotePlugin.native-3541c714.mjs} +3 -2
  7. package/dist/BlocksLibraryPlugin.native-1cc51e63.mjs +1386 -0
  8. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-f9d7f8e4.mjs} +1 -1
  9. package/dist/{CapitalizationPlugin.native-DOMsh5R7.mjs → CapitalizationPlugin.native-42c135dc.mjs} +3 -2
  10. package/dist/{ChecklistPlugin.native-nuSSEFNI.mjs → ChecklistPlugin.native-3b397ee9.mjs} +43 -22
  11. package/dist/CitationsPlugin.native-169fb1e8.mjs +1532 -0
  12. package/dist/{ClearFormattingPlugin.native-Bq_XcTh2.mjs → ClearFormattingPlugin.native-77baa514.mjs} +11 -6
  13. package/dist/{CodePlugin.native-DlpTPdkd.mjs → CodePlugin.native-989cf0aa.mjs} +629 -580
  14. package/dist/{CodeSamplePlugin.native-CgGoH-X4.mjs → CodeSamplePlugin.native-6cc0148e.mjs} +19 -10
  15. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-03659874.mjs} +55 -28
  16. package/dist/ConditionalContentPlugin.native-4983143a.mjs +1424 -0
  17. package/dist/ContentRulesPlugin.native-63ed405b.mjs +1149 -0
  18. package/dist/DataBindingPlugin.native-427e9d75.mjs +956 -0
  19. package/dist/{DirectionPlugin.native-CDnbdNyl.mjs → DirectionPlugin.native-4e742f42.mjs} +19 -10
  20. package/dist/DocSchemaPlugin.native-8e41eda0.mjs +1382 -0
  21. package/dist/{DocumentManagerPlugin.native-C2cs_1w4.mjs → DocumentManagerPlugin.native-e69895ad.mjs} +4 -4
  22. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-55209c87.mjs} +70 -70
  23. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-65c5ac47.mjs} +11 -6
  24. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-f9bc255a.mjs} +7 -4
  25. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-f5647872.mjs} +19 -10
  26. package/dist/{FootnotePlugin.native-D730OGRm.mjs → FootnotePlugin.native-494657b3.mjs} +77 -39
  27. package/dist/{FullscreenPlugin.native-ChXyxeNw.mjs → FullscreenPlugin.native-87ce92e9.mjs} +1 -1
  28. package/dist/{HeadingPlugin.native-DrLYwQnQ.mjs → HeadingPlugin.native-e38c4a16.mjs} +1 -1
  29. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-92ed4be4.mjs} +43 -22
  30. package/dist/{IndentPlugin.native-BHixp8sP.mjs → IndentPlugin.native-e4ee902b.mjs} +23 -12
  31. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-7c95cfbc.mjs} +1 -1
  32. package/dist/{LineHeightPlugin.native-CM7iXdQj.mjs → LineHeightPlugin.native-5668f78c.mjs} +19 -10
  33. package/dist/{LinkPlugin.native-DYCIcdTm.mjs → LinkPlugin.native-6df29111.mjs} +9 -5
  34. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-fe2e115a.mjs} +9 -5
  35. package/dist/{MathPlugin.native-f_mDp8VL.mjs → MathPlugin.native-735bbac2.mjs} +9 -5
  36. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-3cf48a00.mjs} +219 -207
  37. package/dist/MentionPlugin.native-3b1e8c05.mjs +778 -0
  38. package/dist/{MergeTagPlugin.native-C3eOfEgw.mjs → MergeTagPlugin.native-31cf7d48.mjs} +51 -26
  39. package/dist/PIIRedactionPlugin.native-7ab10b9f.mjs +1449 -0
  40. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-1794c5fb.mjs} +67 -52
  41. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-f7b67cc0.mjs} +38 -33
  42. package/dist/{PrintPlugin.native-7qt5v7L5.mjs → PrintPlugin.native-f6a168c2.mjs} +5 -3
  43. package/dist/SlashCommandsPlugin.native-8d45e511.mjs +790 -0
  44. package/dist/SmartPastePlugin.native-a6c5efec.mjs +1447 -0
  45. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-7f06d4ba.mjs} +17 -9
  46. package/dist/{SpellCheckPlugin.native-BZB9AewP.mjs → SpellCheckPlugin.native-04e20834.mjs} +41 -21
  47. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-905e9501.mjs} +9 -5
  48. package/dist/{TablePlugin.native-DrHX-efe.mjs → TablePlugin.native-7d5458c1.mjs} +58 -30
  49. package/dist/{TemplatePlugin.native-CrpfKRJ8.mjs → TemplatePlugin.native-580f0f63.mjs} +32 -17
  50. package/dist/{TextAlignmentPlugin.native-sM_1s00t.mjs → TextAlignmentPlugin.native-9357b3ed.mjs} +11 -6
  51. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-d53ed459.mjs} +26 -14
  52. package/dist/TrackChangesPlugin.native-e96da509.mjs +818 -0
  53. package/dist/TranslationWorkflowPlugin.native-4e711b1e.mjs +1797 -0
  54. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-8080c998.mjs} +1 -1
  55. package/dist/VersionDiffPlugin.native-5bbeff85.mjs +801 -0
  56. package/dist/_commonjsHelpers-69d58be2.mjs +31 -0
  57. package/dist/{anchoredPopover-Bxds0VoB.mjs → anchoredPopover-5cca53ba.mjs} +1 -1
  58. package/dist/documentManager-8327fb6e.mjs +9166 -0
  59. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +3 -2
  60. package/dist/editora.min.js +14 -13
  61. package/dist/editora.umd.js +14 -13
  62. package/dist/{html2canvas.esm-AYkPY5LS.mjs → html2canvas.esm-c51cb3b9.mjs} +978 -894
  63. package/dist/index-072ef022.js +11 -0
  64. package/dist/index-49d31221.mjs +16860 -0
  65. package/dist/{index-yzU4NdPT.mjs → index-7da30697.mjs} +490 -358
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-b47a189f.mjs +5782 -0
  68. package/dist/index.esm.js +12 -7
  69. package/dist/{jspdf.es.min-BJGtOnRT.mjs → jspdf.es.min-780c82db.mjs} +4808 -3784
  70. package/dist/plugin-loader.js +77 -40
  71. package/dist/{purify.es-CKpwg8Tk.mjs → purify.es-3bdbcfc5.mjs} +20 -10
  72. package/dist/style.css +1 -0
  73. package/dist/webcomponent-core.js +546 -414
  74. package/dist/webcomponent-core.min.css +1 -1
  75. package/dist/webcomponent-core.min.js +40 -39
  76. package/dist/webcomponent.cjs.js +1 -1
  77. package/dist/webcomponent.esm.js +1 -1
  78. package/dist/webcomponent.js +484 -315
  79. package/dist/webcomponent.min.css +1 -1
  80. package/dist/webcomponent.min.js +6035 -558
  81. package/package.json +11 -5
  82. package/dist/_commonjsHelpers-DOllISpa.mjs +0 -32
  83. package/dist/core.css +0 -1
  84. package/dist/documentManager-vQ1VkbUY.mjs +0 -8418
  85. package/dist/index-BpE6GFbz.js +0 -10
  86. package/dist/index-BslAFzmv.mjs +0 -16544
  87. package/dist/index.es-BYD2KEo6.mjs +0 -6666
@@ -0,0 +1,790 @@
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 || ((l) => l.label),
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")
142
+ return;
143
+ v = !0;
144
+ const e = document.createElement("style");
145
+ e.id = "rte-slash-commands-styles", e.textContent = `
146
+ .rte-slash-panel {
147
+ width: min(225px, calc(100vw - 16px));
148
+ max-height: min(360px, calc(100vh - 24px));
149
+ overflow: hidden;
150
+ border: 1px solid #d9dfeb;
151
+ border-radius: 0px;
152
+ background: #ffffff;
153
+ box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
154
+ z-index: 2147483646;
155
+ }
156
+
157
+ .rte-slash-list {
158
+ max-height: min(340px, calc(100vh - 32px));
159
+ overflow: auto;
160
+ padding: 0px;
161
+ display: grid;
162
+ gap: 1px;
163
+ }
164
+
165
+ .rte-slash-item {
166
+ width: 100%;
167
+ border: none;
168
+ background: transparent;
169
+ color: #0f172a;
170
+ border-radius: 0px;
171
+ padding: 6px 9px;
172
+ text-align: left;
173
+ display: grid;
174
+ gap: 0px;
175
+ cursor: pointer;
176
+ font: inherit;
177
+ }
178
+
179
+ .rte-slash-item:hover,
180
+ .rte-slash-item.active {
181
+ background: #eff6ff;
182
+ color: #1d4ed8;
183
+ }
184
+
185
+ .rte-slash-item-title {
186
+ font-size: 13px;
187
+ font-weight: 600;
188
+ line-height: 1.35;
189
+ }
190
+
191
+ .rte-slash-item-description {
192
+ font-size: 12px;
193
+ color: #64748b;
194
+ line-height: 1.35;
195
+ }
196
+
197
+ .rte-slash-item mark {
198
+ background: rgba(59, 130, 246, 0.16);
199
+ color: inherit;
200
+ padding: 0 2px;
201
+ border-radius: 3px;
202
+ }
203
+
204
+ .rte-slash-empty {
205
+ font-size: 13px;
206
+ color: #64748b;
207
+ text-align: center;
208
+ padding: 12px;
209
+ }
210
+
211
+ ${u} .rte-slash-panel {
212
+ border-color: #364152;
213
+ background: #1f2937;
214
+ box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
215
+ }
216
+
217
+ ${u} .rte-slash-item {
218
+ color: #e5e7eb;
219
+ }
220
+
221
+ ${u} .rte-slash-item:hover,
222
+ ${u} .rte-slash-item.active {
223
+ background: #334155;
224
+ color: #bfdbfe;
225
+ }
226
+
227
+ ${u} .rte-slash-item-description,
228
+ ${u} .rte-slash-empty {
229
+ color: #9ca3af;
230
+ }
231
+ `, document.head.appendChild(e);
232
+ }
233
+ const s = ".rte-content, .editora-content", g = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap();
234
+ let b = !1, f = null, h = 0, z = 0;
235
+ function P(e) {
236
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
237
+ }
238
+ function I(e) {
239
+ return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
240
+ }
241
+ function F(e) {
242
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement)
243
+ return e.contentElement;
244
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
245
+ const n = e.editorElement;
246
+ if (n.matches(s))
247
+ return n;
248
+ const r = n.querySelector(s);
249
+ if (r instanceof HTMLElement)
250
+ return r;
251
+ }
252
+ const t = window.getSelection();
253
+ if (t && t.rangeCount > 0) {
254
+ const n = t.getRangeAt(0).startContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, i = r == null ? void 0 : r.closest(s);
255
+ if (i)
256
+ return i;
257
+ }
258
+ const o = document.activeElement;
259
+ if (o) {
260
+ if (o.matches(s))
261
+ return o;
262
+ const n = o.closest(s);
263
+ if (n)
264
+ return n;
265
+ }
266
+ return document.querySelector(s);
267
+ }
268
+ function m(e) {
269
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
270
+ }
271
+ function _(e) {
272
+ return e ? /\s|[([{"'`]/.test(e) : !0;
273
+ }
274
+ function E(e) {
275
+ const t = window.getSelection();
276
+ if (!t || t.rangeCount === 0)
277
+ return null;
278
+ const o = t.getRangeAt(0);
279
+ return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
280
+ }
281
+ function y(e, t) {
282
+ const o = window.getSelection();
283
+ o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
284
+ }
285
+ function j(e) {
286
+ if (!e.collapsed)
287
+ return null;
288
+ const t = e.startContainer, o = e.startOffset;
289
+ if (t.nodeType === Node.TEXT_NODE) {
290
+ const n = t;
291
+ return {
292
+ node: n,
293
+ textBefore: n.data.slice(0, o),
294
+ caretOffset: o
295
+ };
296
+ }
297
+ if (t.nodeType === Node.ELEMENT_NODE) {
298
+ const n = t;
299
+ if (o > 0) {
300
+ const r = n.childNodes[o - 1];
301
+ if (r && r.nodeType === Node.TEXT_NODE) {
302
+ const i = r;
303
+ return {
304
+ node: i,
305
+ textBefore: i.data,
306
+ caretOffset: i.length
307
+ };
308
+ }
309
+ }
310
+ }
311
+ return null;
312
+ }
313
+ function K(e, t, o, n) {
314
+ const r = e.lastIndexOf(t);
315
+ if (r < 0 || n && !_(e[r - 1]))
316
+ return null;
317
+ const i = e.slice(r + 1);
318
+ return /\s/.test(i) || i.length > o ? null : {
319
+ trigger: t,
320
+ query: i,
321
+ startOffset: r
322
+ };
323
+ }
324
+ function Q(e, t) {
325
+ const o = t.cloneRange();
326
+ o.collapse(!1);
327
+ const n = o.getClientRects();
328
+ if (n.length > 0)
329
+ return n[n.length - 1];
330
+ const r = document.createElement("span");
331
+ r.textContent = "​", o.insertNode(r);
332
+ const i = r.getBoundingClientRect();
333
+ return r.remove(), e.normalize(), i;
334
+ }
335
+ function A(e, t) {
336
+ if (!e.panel)
337
+ return;
338
+ const o = Q(e.editor, t), n = e.panel;
339
+ n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
340
+ const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
341
+ let l = Math.max(8, Math.min(o.left, i - r.width - 8)), d = o.bottom + 8;
342
+ 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`;
343
+ }
344
+ function k(e, t) {
345
+ if (!t)
346
+ return m(e);
347
+ const o = e.toLowerCase(), n = t.toLowerCase(), r = o.indexOf(n);
348
+ if (r < 0)
349
+ return m(e);
350
+ const i = m(e.slice(0, r)), a = m(e.slice(r, r + t.length)), l = m(e.slice(r + t.length));
351
+ return `${i}<mark>${a}</mark>${l}`;
352
+ }
353
+ function U(e, t) {
354
+ if (e.panel && e.list)
355
+ return;
356
+ const o = document.createElement("div");
357
+ o.className = "rte-slash-panel", o.style.display = "none", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false");
358
+ const n = document.createElement("div");
359
+ 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) => {
360
+ r.preventDefault();
361
+ }), o.addEventListener("click", (r) => {
362
+ const i = r.target;
363
+ if (!i)
364
+ return;
365
+ const a = i.closest(".rte-slash-item");
366
+ if (!a)
367
+ return;
368
+ const l = Number(a.getAttribute("data-index"));
369
+ Number.isFinite(l) && M(e, l);
370
+ });
371
+ }
372
+ function c(e) {
373
+ 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);
374
+ }
375
+ function W(e, t, o) {
376
+ if (!t)
377
+ return e.slice(0, o);
378
+ const n = t.toLowerCase();
379
+ return e.filter((i) => [
380
+ i.id,
381
+ i.label,
382
+ i.description || "",
383
+ i.command || "",
384
+ ...i.keywords || []
385
+ ].join(" ").toLowerCase().includes(n)).slice(0, o);
386
+ }
387
+ function Z(e, t) {
388
+ if (!e.list)
389
+ return;
390
+ const o = e.list;
391
+ if (o.innerHTML = "", e.filteredItems.length === 0) {
392
+ const n = document.createElement("div");
393
+ n.className = "rte-slash-empty", n.textContent = t.emptyStateText, o.appendChild(n), o.removeAttribute("aria-activedescendant");
394
+ return;
395
+ }
396
+ e.filteredItems.forEach((n, r) => {
397
+ const i = document.createElement("button");
398
+ 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 = `
399
+ <span class="rte-slash-item-title">${k(n.label, e.query)}</span>
400
+ ${n.description ? `<span class="rte-slash-item-description">${k(n.description, e.query)}</span>` : ""}
401
+ `, o.appendChild(i);
402
+ }), e.filteredItems.length > 0 && o.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
403
+ }
404
+ function G(e, t) {
405
+ if (t === e.innerHTML)
406
+ return;
407
+ const o = window.execEditorCommand || window.executeEditorCommand;
408
+ if (typeof o == "function")
409
+ try {
410
+ o("recordDomTransaction", e, t, e.innerHTML);
411
+ } catch (n) {
412
+ }
413
+ }
414
+ function V(e) {
415
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
416
+ }
417
+ function L(e, t) {
418
+ e.focus({ preventScroll: !0 });
419
+ try {
420
+ if (document.execCommand("insertHTML", !1, t))
421
+ return !0;
422
+ } catch (l) {
423
+ }
424
+ const o = window.getSelection();
425
+ if (!o || o.rangeCount === 0)
426
+ return !1;
427
+ const n = o.getRangeAt(0);
428
+ if (!e.contains(n.commonAncestorContainer))
429
+ return !1;
430
+ n.deleteContents();
431
+ const r = document.createElement("template");
432
+ r.innerHTML = t;
433
+ const i = r.content, a = i.lastChild;
434
+ if (n.insertNode(i), a) {
435
+ const l = document.createRange();
436
+ l.setStartAfter(a), l.collapse(!0), y(e, l);
437
+ }
438
+ return !0;
439
+ }
440
+ function X(e, t) {
441
+ e.focus({ preventScroll: !0 });
442
+ try {
443
+ if (document.execCommand("insertText", !1, t))
444
+ return !0;
445
+ } catch (a) {
446
+ }
447
+ const o = window.getSelection();
448
+ if (!o || o.rangeCount === 0)
449
+ return !1;
450
+ const n = o.getRangeAt(0);
451
+ if (!e.contains(n.commonAncestorContainer))
452
+ return !1;
453
+ n.deleteContents();
454
+ const r = document.createTextNode(t);
455
+ n.insertNode(r);
456
+ const i = document.createRange();
457
+ return i.setStart(r, r.length), i.collapse(!0), y(e, i), !0;
458
+ }
459
+ function J(e, t) {
460
+ switch (e.toLowerCase()) {
461
+ case "paragraph":
462
+ case "p":
463
+ return document.execCommand("formatBlock", !1, "<p>");
464
+ case "heading1":
465
+ case "h1":
466
+ return document.execCommand("formatBlock", !1, "<h1>");
467
+ case "heading2":
468
+ case "h2":
469
+ return document.execCommand("formatBlock", !1, "<h2>");
470
+ case "heading3":
471
+ case "h3":
472
+ return document.execCommand("formatBlock", !1, "<h3>");
473
+ case "blockquote":
474
+ case "toggleblockquote":
475
+ return document.execCommand("formatBlock", !1, "<blockquote>");
476
+ case "bulletlist":
477
+ case "togglebulletlist":
478
+ case "insertunorderedlist":
479
+ return document.execCommand("insertUnorderedList");
480
+ case "numberedlist":
481
+ case "toggleorderedlist":
482
+ case "insertorderedlist":
483
+ return document.execCommand("insertOrderedList");
484
+ case "horizontalrule":
485
+ case "divider":
486
+ case "inserthorizontalrule":
487
+ return document.execCommand("insertHorizontalRule");
488
+ case "bold":
489
+ case "togglebold":
490
+ return document.execCommand("bold");
491
+ case "italic":
492
+ case "toggleitalic":
493
+ return document.execCommand("italic");
494
+ case "underline":
495
+ case "toggleunderline":
496
+ return document.execCommand("underline");
497
+ case "strikethrough":
498
+ case "togglestrikethrough":
499
+ return document.execCommand("strikeThrough");
500
+ case "clearformatting":
501
+ case "removeformat":
502
+ return document.execCommand("removeFormat");
503
+ default:
504
+ try {
505
+ return document.execCommand(e, !1, t);
506
+ } catch (n) {
507
+ return !1;
508
+ }
509
+ }
510
+ }
511
+ function S(e, t, o) {
512
+ const n = I(e);
513
+ if (n && typeof n.execCommand == "function")
514
+ try {
515
+ if (n.execCommand(t, o) !== !1)
516
+ return !0;
517
+ } catch (i) {
518
+ }
519
+ const r = window.execEditorCommand || window.executeEditorCommand;
520
+ if (typeof r == "function")
521
+ try {
522
+ if (r(t, o, {
523
+ editorElement: n,
524
+ contentElement: e
525
+ }) !== !1)
526
+ return !0;
527
+ } catch (i) {
528
+ }
529
+ return J(t, o);
530
+ }
531
+ async function Y(e, t) {
532
+ const o = e.editor, n = I(o), r = {
533
+ editor: o,
534
+ editorRoot: n,
535
+ query: e.query,
536
+ trigger: e.trigger,
537
+ executeCommand: (i, a) => S(o, i, a),
538
+ insertHTML: (i) => L(o, i)
539
+ };
540
+ 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;
541
+ }
542
+ async function M(e, t) {
543
+ if (t < 0 || t >= e.filteredItems.length || !e.replaceRange)
544
+ return;
545
+ const o = e.filteredItems[t], n = e.editor, r = n.innerHTML, i = `${e.trigger}${e.query}`;
546
+ if (!window.getSelection())
547
+ return;
548
+ const l = e.replaceRange.cloneRange();
549
+ if (!n.contains(l.commonAncestorContainer))
550
+ return;
551
+ l.deleteContents();
552
+ const d = l.cloneRange();
553
+ d.collapse(!0), y(n, d);
554
+ let x = !1;
555
+ try {
556
+ x = await Y(e, o);
557
+ } catch (le) {
558
+ x = !1;
559
+ }
560
+ c(e), x ? (V(n), G(n, r)) : i && X(n, i), n.focus({ preventScroll: !0 });
561
+ }
562
+ function R(e, t) {
563
+ if (e.filteredItems.length === 0)
564
+ return;
565
+ const o = e.filteredItems.length;
566
+ if (e.activeIndex = ((e.activeIndex + t) % o + o) % o, !e.list)
567
+ return;
568
+ const n = Array.from(e.list.querySelectorAll(".rte-slash-item"));
569
+ n.forEach((i, a) => {
570
+ const l = a === e.activeIndex;
571
+ i.classList.toggle("active", l), i.setAttribute("aria-selected", l ? "true" : "false");
572
+ });
573
+ const r = n[e.activeIndex];
574
+ r && (e.list.setAttribute("aria-activedescendant", r.id), r.scrollIntoView({ block: "nearest" }));
575
+ }
576
+ function T(e) {
577
+ if (!(!e.isOpen || !e.panel || !e.anchorRange)) {
578
+ if (!e.editor.isConnected) {
579
+ c(e);
580
+ return;
581
+ }
582
+ A(e, e.anchorRange);
583
+ }
584
+ }
585
+ function N(e, t, o, n, r, i) {
586
+ 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));
587
+ }
588
+ function ee(e, t) {
589
+ const o = e.editor;
590
+ if (o.getAttribute("contenteditable") === "false") {
591
+ c(e);
592
+ return;
593
+ }
594
+ const n = E(o);
595
+ if (!n || !n.collapsed) {
596
+ c(e);
597
+ return;
598
+ }
599
+ const r = j(n);
600
+ if (!r) {
601
+ c(e);
602
+ return;
603
+ }
604
+ const i = K(
605
+ r.textBefore,
606
+ t.triggerChar,
607
+ t.maxQueryLength,
608
+ t.requireBoundary
609
+ );
610
+ if (!i) {
611
+ c(e);
612
+ return;
613
+ }
614
+ if (i.query.length < t.minChars) {
615
+ c(e);
616
+ return;
617
+ }
618
+ const a = n.cloneRange();
619
+ a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset), N(e, t, n, i.query, i.trigger, a);
620
+ }
621
+ function H(e, t) {
622
+ const o = e.editor;
623
+ if (o.getAttribute("contenteditable") === "false")
624
+ return !1;
625
+ let n = E(o);
626
+ n || (n = document.createRange(), n.selectNodeContents(o), n.collapse(!1), y(o, n));
627
+ const r = n.cloneRange();
628
+ return r.collapse(!0), N(e, t, n, "", t.triggerChar, r), !0;
629
+ }
630
+ function te(e) {
631
+ return !(e.metaKey || e.ctrlKey) || e.altKey ? !1 : e.key === "/" || e.code === "Slash";
632
+ }
633
+ function ne(e, t) {
634
+ return {
635
+ editor: e,
636
+ panel: null,
637
+ list: null,
638
+ replaceRange: null,
639
+ items: t.items,
640
+ filteredItems: [],
641
+ activeIndex: 0,
642
+ query: "",
643
+ trigger: t.triggerChar,
644
+ isOpen: !1,
645
+ instanceId: ++z,
646
+ anchorRange: null
647
+ };
648
+ }
649
+ function w(e, t) {
650
+ const o = g.get(e);
651
+ if (o)
652
+ return o.items = t.items, o;
653
+ const n = ne(e, t);
654
+ return g.set(e, n), n;
655
+ }
656
+ function re(e) {
657
+ var o;
658
+ const t = g.get(e);
659
+ t && ((o = t.panel) != null && o.parentNode && t.panel.parentNode.removeChild(t.panel), g.delete(e));
660
+ }
661
+ function C(e, t, o) {
662
+ if (p.has(e))
663
+ return;
664
+ const n = {
665
+ input: () => {
666
+ ee(t, o);
667
+ },
668
+ keydown: (r) => {
669
+ if (t.editor.getAttribute("contenteditable") === "false") {
670
+ c(t);
671
+ return;
672
+ }
673
+ if (!t.isOpen && te(r)) {
674
+ r.preventDefault(), H(t, o);
675
+ return;
676
+ }
677
+ if (t.isOpen) {
678
+ if (r.key === "ArrowDown") {
679
+ r.preventDefault(), R(t, 1);
680
+ return;
681
+ }
682
+ if (r.key === "ArrowUp") {
683
+ r.preventDefault(), R(t, -1);
684
+ return;
685
+ }
686
+ if (r.key === "Enter" || r.key === "Tab") {
687
+ if (t.filteredItems.length === 0) {
688
+ r.key === "Tab" && r.preventDefault(), c(t);
689
+ return;
690
+ }
691
+ r.preventDefault(), M(t, t.activeIndex);
692
+ return;
693
+ }
694
+ if (r.key === "Escape") {
695
+ r.preventDefault(), c(t);
696
+ return;
697
+ }
698
+ }
699
+ },
700
+ blur: () => {
701
+ window.setTimeout(() => {
702
+ const r = document.activeElement;
703
+ t.panel && r && t.panel.contains(r) || c(t);
704
+ }, 0);
705
+ },
706
+ mousedown: (r) => {
707
+ if (!t.isOpen || !t.panel)
708
+ return;
709
+ const i = r.target;
710
+ i && !t.panel.contains(i) && !e.contains(i) && c(t);
711
+ },
712
+ selectionchange: () => {
713
+ if (!t.isOpen)
714
+ return;
715
+ const r = E(e);
716
+ if (!r || !r.collapsed) {
717
+ c(t);
718
+ return;
719
+ }
720
+ t.anchorRange = r.cloneRange(), T(t);
721
+ },
722
+ reposition: () => {
723
+ T(t);
724
+ }
725
+ };
726
+ 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);
727
+ }
728
+ function oe(e) {
729
+ const t = p.get(e);
730
+ 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));
731
+ }
732
+ function ie(e) {
733
+ b || (b = !0, f = (t) => {
734
+ const o = t.target;
735
+ if (!(o instanceof Node))
736
+ return;
737
+ const n = P(o), r = (n == null ? void 0 : n.closest(s)) || null;
738
+ if (!r)
739
+ return;
740
+ const i = w(r, e);
741
+ C(r, i, e);
742
+ }, document.addEventListener("focusin", f, !0));
743
+ }
744
+ function ae() {
745
+ !b || !f || (document.removeEventListener("focusin", f, !0), b = !1, f = null);
746
+ }
747
+ const ce = (e = {}) => {
748
+ B();
749
+ const t = D(e);
750
+ return {
751
+ name: "slashCommands",
752
+ toolbar: [
753
+ {
754
+ id: "slashCommands",
755
+ label: "Slash Commands",
756
+ command: "openSlashCommands",
757
+ 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>'
758
+ }
759
+ ],
760
+ commands: {
761
+ openSlashCommands: (o, n) => {
762
+ const r = F(n);
763
+ if (!r)
764
+ return !1;
765
+ const i = w(r, t);
766
+ return C(r, i, t), H(i, t);
767
+ }
768
+ },
769
+ keymap: {
770
+ "Mod-/": "openSlashCommands",
771
+ "Mod-Shift-7": "openSlashCommands"
772
+ },
773
+ init: () => {
774
+ h += 1, ie(t), Array.from(document.querySelectorAll(s)).forEach((n) => {
775
+ const r = w(n, t);
776
+ C(n, r, t);
777
+ });
778
+ },
779
+ destroy: () => {
780
+ h = Math.max(0, h - 1), Array.from(document.querySelectorAll(s)).forEach((n) => {
781
+ const r = g.get(n);
782
+ r && (c(r), oe(n), re(n));
783
+ }), h === 0 && ae();
784
+ }
785
+ };
786
+ };
787
+ export {
788
+ ce as SlashCommandsPlugin
789
+ };
790
+ //# sourceMappingURL=SlashCommandsPlugin.native-8d45e511.mjs.map