@editora/core 1.0.22 → 1.0.24

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 (65) hide show
  1. package/README.md +247 -243
  2. package/dist/{A11yCheckerPlugin.native-qW_njhLY.mjs → A11yCheckerPlugin.native-BBCsR5Ur.mjs} +7 -5
  3. package/dist/{AnchorPlugin.native-Drmxhy98.mjs → AnchorPlugin.native-Dk9R26cF.mjs} +20 -19
  4. package/dist/{ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs → ApprovalWorkflowPlugin.native-AeJsehXM.mjs} +56 -55
  5. package/dist/{BackgroundColorPlugin.native-H3XyYD7_.mjs → BackgroundColorPlugin.native-DCAd94kp.mjs} +103 -98
  6. package/dist/{BlocksLibraryPlugin.native-CownM6Rk.mjs → BlocksLibraryPlugin.native-D9OPcnQV.mjs} +42 -43
  7. package/dist/{CitationsPlugin.native-C_7wWQ-k.mjs → CitationsPlugin.native-BFChgCSV.mjs} +51 -51
  8. package/dist/{CodePlugin.native-CAHk9ecG.mjs → CodePlugin.native-BRBEIqY7.mjs} +167 -113
  9. package/dist/{CodePlugin.native-DZgIez08.mjs → CodePlugin.native-CPfKDrkr.mjs} +1383 -1094
  10. package/dist/{CodeSamplePlugin.native-svbAFWh_.mjs → CodeSamplePlugin.native-Bai8bgl3.mjs} +5 -5
  11. package/dist/{CommentsPlugin.native-DncTHiEe.mjs → CommentsPlugin.native-DHCDUm9f.mjs} +161 -141
  12. package/dist/{ConditionalContentPlugin.native-Bf7XgRSW.mjs → ConditionalContentPlugin.native-B3R6xcqn.mjs} +3 -3
  13. package/dist/{ContentRulesPlugin.native-vPx5nC73.mjs → ContentRulesPlugin.native-BISqhQKJ.mjs} +52 -52
  14. package/dist/{DataBindingPlugin.native-B7lpI_0c.mjs → DataBindingPlugin.native-DbaDeXNp.mjs} +37 -37
  15. package/dist/{DocumentManagerPlugin.native-B8K-Oqom.mjs → DocumentManagerPlugin.native-tZqIa9o5.mjs} +21 -20
  16. package/dist/{EmbedIframePlugin.native-BfZ_HGlV.mjs → EmbedIframePlugin.native-qHMf1Jtg.mjs} +7 -7
  17. package/dist/{EmojisPlugin.native-D92aaOKi.mjs → EmojisPlugin.native-B64efKg5.mjs} +4 -4
  18. package/dist/{FormatPainterPlugin.native-BhjzsiVq.mjs → FormatPainterPlugin.native-CAc1N6xU.mjs} +183 -161
  19. package/dist/{HeadingPlugin.native-DZdvubrQ.mjs → HeadingPlugin.native-C3YiGERx.mjs} +85 -72
  20. package/dist/HistoryPlugin.native-C8GyxsgC.mjs +330 -0
  21. package/dist/{LinkPlugin.native-BsQXYsK6.mjs → LinkPlugin.native-Dt_p6Ukb.mjs} +4 -4
  22. package/dist/ListPlugin.native-UYaoRiub.mjs +239 -0
  23. package/dist/{MathPlugin.native-Byo3WL0f.mjs → MathPlugin.native-Cq9WQ7cq.mjs} +148 -130
  24. package/dist/MediaManagerPlugin.native-BjrEarV6.mjs +1161 -0
  25. package/dist/{MediaManagerPlugin.native-BT1NZIJS.mjs → MediaManagerPlugin.native-CRi24Mrb.mjs} +340 -281
  26. package/dist/{MentionPlugin.native-S_lwGZQO.mjs → MentionPlugin.native-Zb1dwdxU.mjs} +304 -300
  27. package/dist/{MergeTagPlugin.native-7-6F3S1Y.mjs → MergeTagPlugin.native-BXkVPvCo.mjs} +6 -4
  28. package/dist/{PIIRedactionPlugin.native-g7j4jOmm.mjs → PIIRedactionPlugin.native-Cm0bpzQb.mjs} +2 -2
  29. package/dist/{PreviewPlugin.native-Dv5OsffK.mjs → PreviewPlugin.native-CrfiwP2J.mjs} +2 -2
  30. package/dist/{SlashCommandsPlugin.native-BDIIwGNs.mjs → SlashCommandsPlugin.native-BzGTRmMB.mjs} +264 -240
  31. package/dist/{SmartPastePlugin.native-BATLCds5.mjs → SmartPastePlugin.native-DnOJhDsf.mjs} +2 -2
  32. package/dist/{SpecialCharactersPlugin.native-CdZoc1GB.mjs → SpecialCharactersPlugin.native-B0XaCfjZ.mjs} +4 -4
  33. package/dist/{SpellCheckPlugin.native-BGm2qPfn.mjs → SpellCheckPlugin.native-BE7os1Xj.mjs} +302 -265
  34. package/dist/{TablePlugin.native-C1YZ372P.mjs → TablePlugin.native-CWxEFpV8.mjs} +159 -136
  35. package/dist/{TemplatePlugin.native-Dwk8TgxI.mjs → TemplatePlugin.native-OD8Wc1R7.mjs} +6 -4
  36. package/dist/{TextColorPlugin.native-KMZ2uzlq.mjs → TextColorPlugin.native-C2IjioNM.mjs} +75 -71
  37. package/dist/{TranslationWorkflowPlugin.native-CZtG--06.mjs → TranslationWorkflowPlugin.native-BGXVJD9f.mjs} +101 -98
  38. package/dist/{VersionDiffPlugin.native-Ca1fMWUJ.mjs → VersionDiffPlugin.native-DJZIzFSK.mjs} +11 -11
  39. package/dist/anchoredPopover-QN4jNbW1.mjs +134 -0
  40. package/dist/confirmDialog-BP8hZPpX.mjs +112 -0
  41. package/dist/dialogHelpers-Dzn8DHoF.mjs +194 -0
  42. package/dist/{documentManager-BWK_-KJp.mjs → documentManager-8gnG-uG_.mjs} +1728 -1715
  43. package/dist/editora.min.js +21 -21
  44. package/dist/editora.umd.js +10 -10
  45. package/dist/{index-C1sO7DAC.js → index--wO0CZVN.js} +6 -6
  46. package/dist/{index-DGMYWPLx.mjs → index-BICrB5kg.mjs} +397 -326
  47. package/dist/index.cjs.js +1 -1
  48. package/dist/index.esm.js +2 -2
  49. package/dist/katex-DLIObQUm.mjs +11683 -0
  50. package/dist/katex.min--Ws3c9be.mjs +6 -0
  51. package/dist/notify-DCQGpmq-.mjs +60 -0
  52. package/dist/plugin-loader.js +54 -54
  53. package/dist/webcomponent-core.js +305 -234
  54. package/dist/webcomponent-core.min.css +1 -1
  55. package/dist/webcomponent-core.min.js +153 -80
  56. package/dist/webcomponent.cjs.js +1 -1
  57. package/dist/webcomponent.esm.js +1 -1
  58. package/dist/webcomponent.js +631 -560
  59. package/dist/webcomponent.min.css +1 -1
  60. package/dist/webcomponent.min.js +1677 -1328
  61. package/package.json +1 -1
  62. package/dist/HistoryPlugin.native-DPvhks6h.mjs +0 -246
  63. package/dist/ListPlugin.native-Bt0LANbO.mjs +0 -139
  64. package/dist/anchoredPopover-DJFD2oAP.mjs +0 -116
  65. package/dist/dialogHelpers-DBf7WqYH.mjs +0 -40
@@ -1,10 +1,11 @@
1
- function H(e, t) {
2
- const o = Array.from({ length: t }).map(() => "<th><p><br></p></th>").join(""), n = Array.from({ length: e }).map(
1
+ import { a as f } from "./dialogHelpers-Dzn8DHoF.mjs";
2
+ function q(e, t) {
3
+ const r = Array.from({ length: t }).map(() => "<th><p><br></p></th>").join(""), n = Array.from({ length: e }).map(
3
4
  () => `<tr>${Array.from({ length: t }).map(() => "<td><p><br></p></td>").join("")}</tr>`
4
5
  ).join("");
5
- return `<table class="rte-table"><thead><tr>${o}</tr></thead><tbody>${n}</tbody></table><p><br></p>`;
6
+ return `<table class="rte-table"><thead><tr>${r}</tr></thead><tbody>${n}</tbody></table><p><br></p>`;
6
7
  }
7
- function q() {
8
+ function $() {
8
9
  return [
9
10
  {
10
11
  id: "paragraph",
@@ -59,7 +60,7 @@ function q() {
59
60
  id: "table-3x3",
60
61
  label: "Table 3x3",
61
62
  description: "Insert a 3 x 3 table",
62
- action: ({ insertHTML: e }) => e(H(3, 3)),
63
+ action: ({ insertHTML: e }) => e(q(3, 3)),
63
64
  keywords: ["table", "grid", "rows", "columns"]
64
65
  },
65
66
  {
@@ -106,40 +107,40 @@ function q() {
106
107
  }
107
108
  ];
108
109
  }
109
- function $(e) {
110
- const t = [], o = /* @__PURE__ */ new Set();
110
+ function D(e) {
111
+ const t = [], r = /* @__PURE__ */ new Set();
111
112
  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({
113
+ const o = String(n.id || "").trim(), i = String(n.label || "").trim();
114
+ !o || !i || r.has(o) || (r.add(o), t.push({
114
115
  ...n,
115
- id: r,
116
+ id: o,
116
117
  label: i,
117
118
  description: n.description ? String(n.description) : void 0,
118
119
  keywords: Array.isArray(n.keywords) ? n.keywords.map((a) => String(a)).filter(Boolean) : void 0
119
120
  }));
120
121
  }), t;
121
122
  }
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 || [];
123
+ function B(e) {
124
+ var o, i, a;
125
+ const t = (e.triggerChar || "/")[0] || "/", r = e.includeDefaultItems !== !1, n = r ? [...e.items || [], ...$()] : e.items || [];
125
126
  return {
126
127
  triggerChar: t,
127
- minChars: Math.max(0, (r = e.minChars) != null ? r : 0),
128
+ minChars: Math.max(0, (o = e.minChars) != null ? o : 0),
128
129
  maxQueryLength: Math.max(1, (i = e.maxQueryLength) != null ? i : 48),
129
130
  maxSuggestions: Math.max(1, (a = e.maxSuggestions) != null ? a : 10),
130
131
  requireBoundary: e.requireBoundary !== !1,
131
- includeDefaultItems: o,
132
- items: $(n),
132
+ includeDefaultItems: r,
133
+ items: D(n),
133
134
  itemRenderer: e.itemRenderer || ((l) => l.label),
134
135
  emptyStateText: e.emptyStateText || "No commands found",
135
136
  panelLabel: e.panelLabel || "Slash commands"
136
137
  };
137
138
  }
138
139
  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;
140
+ let k = !1;
141
+ function z() {
142
+ if (k || typeof document == "undefined") return;
143
+ k = !0;
143
144
  const e = document.createElement("style");
144
145
  e.id = "rte-slash-commands-styles", e.textContent = `
145
146
  .rte-slash-panel {
@@ -235,68 +236,85 @@ function B() {
235
236
  }
236
237
  `, document.head.appendChild(e);
237
238
  }
238
- const c = ".rte-content, .editora-content", z = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark', g = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap();
239
- let b = !1, f = null, h = 0, P = 0;
240
- function _(e) {
239
+ const _ = /^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TD|TH)$/, P = 'br, img, video, audio, iframe, hr, table, svg, canvas, object, embed, [contenteditable="false"]';
240
+ function F(e, t) {
241
+ var o;
242
+ let r = t.startContainer;
243
+ r.nodeType !== Node.ELEMENT_NODE && (r = r.parentNode);
244
+ let n = null;
245
+ for (; r && r !== e; ) {
246
+ if (r instanceof HTMLElement && _.test(r.tagName)) {
247
+ n = r;
248
+ break;
249
+ }
250
+ r = r.parentNode;
251
+ }
252
+ return !n || !e.contains(n) || ((o = n.textContent) != null ? o : "") !== "" || n.querySelector(P) ? null : (Array.from(n.childNodes).forEach((i) => {
253
+ i.nodeType === Node.TEXT_NODE && i.data === "" && n.removeChild(i);
254
+ }), n.appendChild(document.createElement("br")), t.setStart(n, 0), t.collapse(!0), n);
255
+ }
256
+ const d = ".rte-content, .editora-content", j = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark', h = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap();
257
+ let y = !1, g = null, p = 0, K = 0;
258
+ function Q(e) {
241
259
  return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
242
260
  }
243
- function I(e) {
261
+ function A(e) {
244
262
  return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
245
263
  }
246
- function F(e) {
264
+ function U(e) {
247
265
  if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
248
266
  if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
249
267
  const n = e.editorElement;
250
- if (n.matches(c)) return n;
251
- const r = n.querySelector(c);
252
- if (r instanceof HTMLElement) return r;
268
+ if (n.matches(d)) return n;
269
+ const o = n.querySelector(d);
270
+ if (o instanceof HTMLElement) return o;
253
271
  }
254
272
  const t = window.getSelection();
255
273
  if (t && t.rangeCount > 0) {
256
- const n = t.getRangeAt(0).startContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, i = r == null ? void 0 : r.closest(c);
274
+ const n = t.getRangeAt(0).startContainer, o = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, i = o == null ? void 0 : o.closest(d);
257
275
  if (i) return i;
258
276
  }
259
- const o = document.activeElement;
260
- if (o) {
261
- if (o.matches(c)) return o;
262
- const n = o.closest(c);
277
+ const r = document.activeElement;
278
+ if (r) {
279
+ if (r.matches(d)) return r;
280
+ const n = r.closest(d);
263
281
  if (n) return n;
264
282
  }
265
- return document.querySelector(c);
283
+ return document.querySelector(d);
266
284
  }
267
285
  function m(e) {
268
286
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
269
287
  }
270
- function j(e) {
288
+ function W(e) {
271
289
  return e ? /\s|[([{"'`]/.test(e) : !0;
272
290
  }
273
- function E(e) {
291
+ function v(e) {
274
292
  const t = window.getSelection();
275
293
  if (!t || t.rangeCount === 0) return null;
276
- const o = t.getRangeAt(0);
277
- return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
294
+ const r = t.getRangeAt(0);
295
+ return e.contains(r.commonAncestorContainer) ? r.cloneRange() : null;
278
296
  }
279
- function y(e, t) {
280
- const o = window.getSelection();
281
- o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
297
+ function E(e, t) {
298
+ const r = window.getSelection();
299
+ r && (r.removeAllRanges(), r.addRange(t), e.focus({ preventScroll: !0 }));
282
300
  }
283
- function K(e) {
301
+ function G(e) {
284
302
  if (!e.collapsed) return null;
285
- const t = e.startContainer, o = e.startOffset;
303
+ const t = e.startContainer, r = e.startOffset;
286
304
  if (t.nodeType === Node.TEXT_NODE) {
287
305
  const n = t;
288
306
  return {
289
307
  node: n,
290
- textBefore: n.data.slice(0, o),
291
- caretOffset: o
308
+ textBefore: n.data.slice(0, r),
309
+ caretOffset: r
292
310
  };
293
311
  }
294
312
  if (t.nodeType === Node.ELEMENT_NODE) {
295
313
  const n = t;
296
- if (o > 0) {
297
- const r = n.childNodes[o - 1];
298
- if (r && r.nodeType === Node.TEXT_NODE) {
299
- const i = r;
314
+ if (r > 0) {
315
+ const o = n.childNodes[r - 1];
316
+ if (o && o.nodeType === Node.TEXT_NODE) {
317
+ const i = o;
300
318
  return {
301
319
  node: i,
302
320
  textBefore: i.data,
@@ -307,64 +325,64 @@ function K(e) {
307
325
  }
308
326
  return null;
309
327
  }
310
- function Q(e, t, o, n) {
311
- const r = e.lastIndexOf(t);
312
- if (r < 0 || n && !j(e[r - 1]))
328
+ function V(e, t, r, n) {
329
+ const o = e.lastIndexOf(t);
330
+ if (o < 0 || n && !W(e[o - 1]))
313
331
  return null;
314
- const i = e.slice(r + 1);
315
- return /\s/.test(i) || i.length > o ? null : {
332
+ const i = e.slice(o + 1);
333
+ return /\s/.test(i) || i.length > r ? null : {
316
334
  trigger: t,
317
335
  query: i,
318
- startOffset: r
336
+ startOffset: o
319
337
  };
320
338
  }
321
- function U(e, t) {
322
- const o = t.cloneRange();
323
- o.collapse(!1);
324
- const n = o.getClientRects();
339
+ function X(e, t) {
340
+ const r = t.cloneRange();
341
+ r.collapse(!1);
342
+ const n = r.getClientRects();
325
343
  if (n.length > 0)
326
344
  return n[n.length - 1];
327
- const r = document.createElement("span");
328
- r.textContent = "​", o.insertNode(r);
329
- const i = r.getBoundingClientRect();
330
- return r.remove(), e.normalize(), i;
345
+ const o = document.createElement("span");
346
+ o.textContent = "​", r.insertNode(o);
347
+ const i = o.getBoundingClientRect();
348
+ return o.remove(), e.normalize(), i;
331
349
  }
332
- function A(e, t) {
350
+ function N(e, t) {
333
351
  if (!e.panel) return;
334
- const o = U(e.editor, t), n = e.panel;
335
- n.classList.toggle("rte-slash-theme-dark", !!e.editor.closest(z)), n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
336
- const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, l = Math.max(8, Math.min(o.left, i - r.width - 8));
337
- let d = o.bottom + 8;
338
- 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`;
352
+ const r = X(e.editor, t), n = e.panel;
353
+ n.classList.toggle("rte-slash-theme-dark", !!e.editor.closest(j)), n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
354
+ const o = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, l = Math.max(8, Math.min(r.left, i - o.width - 8));
355
+ let c = r.bottom + 8;
356
+ c + o.height > a - 8 && (c = Math.max(8, r.top - o.height - 8)), n.style.position = "fixed", n.style.left = `${l}px`, n.style.top = `${c}px`;
339
357
  }
340
- function k(e, t) {
358
+ function L(e, t) {
341
359
  if (!t) return m(e);
342
- const o = e.toLowerCase(), n = t.toLowerCase(), r = o.indexOf(n);
343
- if (r < 0) return m(e);
344
- const i = m(e.slice(0, r)), a = m(e.slice(r, r + t.length)), l = m(e.slice(r + t.length));
360
+ const r = e.toLowerCase(), n = t.toLowerCase(), o = r.indexOf(n);
361
+ if (o < 0) return m(e);
362
+ const i = m(e.slice(0, o)), a = m(e.slice(o, o + t.length)), l = m(e.slice(o + t.length));
345
363
  return `${i}<mark>${a}</mark>${l}`;
346
364
  }
347
- function W(e, t) {
365
+ function Z(e, t) {
348
366
  if (e.panel && e.list) return;
349
- const o = document.createElement("div");
350
- o.className = "rte-slash-panel", o.style.display = "none", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false");
367
+ const r = document.createElement("div");
368
+ r.className = "rte-slash-panel", r.style.display = "none", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "false");
351
369
  const n = document.createElement("div");
352
- 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) => {
353
- r.preventDefault();
354
- }), o.addEventListener("click", (r) => {
355
- const i = r.target;
370
+ 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) => {
371
+ o.preventDefault();
372
+ }), r.addEventListener("click", (o) => {
373
+ const i = o.target;
356
374
  if (!i) return;
357
375
  const a = i.closest(".rte-slash-item");
358
376
  if (!a) return;
359
377
  const l = Number(a.getAttribute("data-index"));
360
- Number.isFinite(l) && N(e, l);
378
+ Number.isFinite(l) && O(e, l);
361
379
  });
362
380
  }
363
381
  function s(e) {
364
- 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);
382
+ 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, f(e.editor, null, null));
365
383
  }
366
- function Z(e, t, o) {
367
- if (!t) return e.slice(0, o);
384
+ function J(e, t, r) {
385
+ if (!t) return e.slice(0, r);
368
386
  const n = t.toLowerCase();
369
387
  return e.filter((i) => [
370
388
  i.id,
@@ -372,75 +390,79 @@ function Z(e, t, o) {
372
390
  i.description || "",
373
391
  i.command || "",
374
392
  ...i.keywords || []
375
- ].join(" ").toLowerCase().includes(n)).slice(0, o);
393
+ ].join(" ").toLowerCase().includes(n)).slice(0, r);
376
394
  }
377
- function G(e, t) {
395
+ function Y(e, t) {
378
396
  if (!e.list) return;
379
- const o = e.list;
380
- if (o.innerHTML = "", e.filteredItems.length === 0) {
397
+ const r = e.list;
398
+ if (r.innerHTML = "", e.filteredItems.length === 0) {
381
399
  const n = document.createElement("div");
382
- n.className = "rte-slash-empty", n.textContent = t.emptyStateText, o.appendChild(n), o.removeAttribute("aria-activedescendant");
400
+ n.className = "rte-slash-empty", n.textContent = t.emptyStateText, r.appendChild(n), r.removeAttribute("aria-activedescendant"), f(e.editor, null, null);
383
401
  return;
384
402
  }
385
- e.filteredItems.forEach((n, r) => {
403
+ if (e.filteredItems.forEach((n, o) => {
386
404
  const i = document.createElement("button");
387
- 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 = `
388
- <span class="rte-slash-item-title">${k(n.label, e.query)}</span>
389
- ${n.description ? `<span class="rte-slash-item-description">${k(n.description, e.query)}</span>` : ""}
390
- `, o.appendChild(i);
391
- }), e.filteredItems.length > 0 && o.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
392
- }
393
- function V(e, t) {
405
+ 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 = `
406
+ <span class="rte-slash-item-title">${L(n.label, e.query)}</span>
407
+ ${n.description ? `<span class="rte-slash-item-description">${L(n.description, e.query)}</span>` : ""}
408
+ `, r.appendChild(i);
409
+ }), e.filteredItems.length > 0) {
410
+ const n = `rte-slash-item-${e.instanceId}-${e.activeIndex}`;
411
+ r.setAttribute("aria-activedescendant", n), f(e.editor, r, r.querySelector(`[id="${n}"]`));
412
+ } else
413
+ f(e.editor, null, null);
414
+ }
415
+ function ee(e, t) {
394
416
  if (t === e.innerHTML) return;
395
- const o = window.execEditorCommand || window.executeEditorCommand;
396
- if (typeof o == "function")
417
+ const r = window.execEditorCommand || window.executeEditorCommand;
418
+ if (typeof r == "function")
397
419
  try {
398
- o("recordDomTransaction", e, t, e.innerHTML);
420
+ r("recordDomTransaction", e, t, e.innerHTML);
399
421
  } catch (n) {
400
422
  }
401
423
  }
402
- function X(e) {
424
+ function te(e) {
403
425
  e.dispatchEvent(new Event("input", { bubbles: !0 }));
404
426
  }
405
- function L(e, t) {
427
+ function T(e, t) {
406
428
  e.focus({ preventScroll: !0 });
407
429
  try {
408
430
  if (document.execCommand("insertHTML", !1, t))
409
431
  return !0;
410
432
  } catch (l) {
411
433
  }
412
- const o = window.getSelection();
413
- if (!o || o.rangeCount === 0) return !1;
414
- const n = o.getRangeAt(0);
434
+ const r = window.getSelection();
435
+ if (!r || r.rangeCount === 0) return !1;
436
+ const n = r.getRangeAt(0);
415
437
  if (!e.contains(n.commonAncestorContainer)) return !1;
416
438
  n.deleteContents();
417
- const r = document.createElement("template");
418
- r.innerHTML = t;
419
- const i = r.content, a = i.lastChild;
439
+ const o = document.createElement("template");
440
+ o.innerHTML = t;
441
+ const i = o.content, a = i.lastChild;
420
442
  if (n.insertNode(i), a) {
421
443
  const l = document.createRange();
422
- l.setStartAfter(a), l.collapse(!0), y(e, l);
444
+ l.setStartAfter(a), l.collapse(!0), E(e, l);
423
445
  }
424
446
  return !0;
425
447
  }
426
- function J(e, t) {
448
+ function ne(e, t) {
427
449
  e.focus({ preventScroll: !0 });
428
450
  try {
429
451
  if (document.execCommand("insertText", !1, t))
430
452
  return !0;
431
453
  } catch (a) {
432
454
  }
433
- const o = window.getSelection();
434
- if (!o || o.rangeCount === 0) return !1;
435
- const n = o.getRangeAt(0);
455
+ const r = window.getSelection();
456
+ if (!r || r.rangeCount === 0) return !1;
457
+ const n = r.getRangeAt(0);
436
458
  if (!e.contains(n.commonAncestorContainer)) return !1;
437
459
  n.deleteContents();
438
- const r = document.createTextNode(t);
439
- n.insertNode(r);
460
+ const o = document.createTextNode(t);
461
+ n.insertNode(o);
440
462
  const i = document.createRange();
441
- return i.setStart(r, r.length), i.collapse(!0), y(e, i), !0;
463
+ return i.setStart(o, o.length), i.collapse(!0), E(e, i), !0;
442
464
  }
443
- function Y(e, t) {
465
+ function re(e, t) {
444
466
  switch (e.toLowerCase()) {
445
467
  case "paragraph":
446
468
  case "p":
@@ -492,94 +514,96 @@ function Y(e, t) {
492
514
  }
493
515
  }
494
516
  }
495
- function S(e, t, o) {
496
- const n = I(e);
517
+ function S(e, t, r) {
518
+ const n = A(e);
497
519
  if (n && typeof n.execCommand == "function")
498
520
  try {
499
- if (n.execCommand(t, o) !== !1) return !0;
500
- } catch (i) {
521
+ if (n.execCommand(t, r) !== !1) return !0;
522
+ } catch (a) {
501
523
  }
502
- const r = window.execEditorCommand || window.executeEditorCommand;
503
- if (typeof r == "function")
524
+ const o = [window.executeEditorCommand, window.execEditorCommand].filter(
525
+ (a, l, c) => typeof a == "function" && c.indexOf(a) === l
526
+ ), i = {
527
+ editorElement: n,
528
+ contentElement: e
529
+ };
530
+ for (const a of o)
504
531
  try {
505
- if (r(t, o, {
506
- editorElement: n,
507
- contentElement: e
508
- }) !== !1) return !0;
509
- } catch (i) {
532
+ if (a(t, r, i) !== !1) return !0;
533
+ } catch (l) {
510
534
  }
511
- return Y(t, o);
535
+ return re(t, r);
512
536
  }
513
- async function ee(e, t) {
514
- const o = e.editor, n = I(o), r = {
515
- editor: o,
537
+ async function oe(e, t) {
538
+ const r = e.editor, n = A(r), o = {
539
+ editor: r,
516
540
  editorRoot: n,
517
541
  query: e.query,
518
542
  trigger: e.trigger,
519
- executeCommand: (i, a) => S(o, i, a),
520
- insertHTML: (i) => L(o, i)
543
+ executeCommand: (i, a) => S(r, i, a),
544
+ insertHTML: (i) => T(r, i)
521
545
  };
522
- 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;
546
+ return t.action ? await Promise.resolve(t.action(o)) !== !1 : t.insertHTML ? T(r, t.insertHTML) : t.command ? S(r, t.command, t.commandValue) : !1;
523
547
  }
524
- async function N(e, t) {
548
+ async function O(e, t) {
525
549
  if (t < 0 || t >= e.filteredItems.length || !e.replaceRange) return;
526
- const o = e.filteredItems[t], n = e.editor, r = n.innerHTML, i = `${e.trigger}${e.query}`;
550
+ const r = e.filteredItems[t], n = e.editor, o = n.innerHTML, i = `${e.trigger}${e.query}`;
527
551
  if (!window.getSelection()) return;
528
552
  const l = e.replaceRange.cloneRange();
529
553
  if (!n.contains(l.commonAncestorContainer)) return;
530
554
  l.deleteContents();
531
- const d = l.cloneRange();
532
- d.collapse(!0), y(n, d);
555
+ const c = l.cloneRange();
556
+ c.collapse(!0), F(n, c), E(n, c);
533
557
  let x = !1;
534
558
  try {
535
- x = await ee(e, o);
536
- } catch (se) {
559
+ x = await oe(e, r);
560
+ } catch (me) {
537
561
  x = !1;
538
562
  }
539
- s(e), x ? (X(n), V(n, r)) : i && J(n, i), n.focus({ preventScroll: !0 });
563
+ s(e), x ? (te(n), ee(n, o)) : i && ne(n, i), n.focus({ preventScroll: !0 });
540
564
  }
541
565
  function R(e, t) {
542
566
  if (e.filteredItems.length === 0) return;
543
- const o = e.filteredItems.length;
544
- if (e.activeIndex = ((e.activeIndex + t) % o + o) % o, !e.list) return;
567
+ const r = e.filteredItems.length;
568
+ if (e.activeIndex = ((e.activeIndex + t) % r + r) % r, !e.list) return;
545
569
  const n = Array.from(e.list.querySelectorAll(".rte-slash-item"));
546
570
  n.forEach((i, a) => {
547
571
  const l = a === e.activeIndex;
548
572
  i.classList.toggle("active", l), i.setAttribute("aria-selected", l ? "true" : "false");
549
573
  });
550
- const r = n[e.activeIndex];
551
- r && (e.list.setAttribute("aria-activedescendant", r.id), r.scrollIntoView({ block: "nearest" }));
574
+ const o = n[e.activeIndex];
575
+ o && (e.list.setAttribute("aria-activedescendant", o.id), f(e.editor, e.list, o), o.scrollIntoView({ block: "nearest" }));
552
576
  }
553
- function T(e) {
577
+ function I(e) {
554
578
  if (!(!e.isOpen || !e.panel || !e.anchorRange)) {
555
579
  if (!e.editor.isConnected) {
556
580
  s(e);
557
581
  return;
558
582
  }
559
- A(e, e.anchorRange);
583
+ N(e, e.anchorRange);
560
584
  }
561
585
  }
562
- function M(e, t, o, n, r, i) {
563
- W(e, t), e.query = n, e.trigger = r, e.replaceRange = i.cloneRange(), e.anchorRange = o.cloneRange(), e.filteredItems = Z(e.items, n, t.maxSuggestions), e.activeIndex = 0, e.isOpen = !0, e.panel && (G(e, t), A(e, o));
586
+ function M(e, t, r, n, o, i) {
587
+ Z(e, t), e.query = n, e.trigger = o, e.replaceRange = i.cloneRange(), e.anchorRange = r.cloneRange(), e.filteredItems = J(e.items, n, t.maxSuggestions), e.activeIndex = 0, e.isOpen = !0, e.panel && (Y(e, t), N(e, r));
564
588
  }
565
- function te(e, t) {
566
- const o = e.editor;
567
- if (o.getAttribute("contenteditable") === "false") {
589
+ function ie(e, t) {
590
+ const r = e.editor;
591
+ if (r.getAttribute("contenteditable") === "false") {
568
592
  s(e);
569
593
  return;
570
594
  }
571
- const n = E(o);
595
+ const n = v(r);
572
596
  if (!n || !n.collapsed) {
573
597
  s(e);
574
598
  return;
575
599
  }
576
- const r = K(n);
577
- if (!r) {
600
+ const o = G(n);
601
+ if (!o) {
578
602
  s(e);
579
603
  return;
580
604
  }
581
- const i = Q(
582
- r.textBefore,
605
+ const i = V(
606
+ o.textBefore,
583
607
  t.triggerChar,
584
608
  t.maxQueryLength,
585
609
  t.requireBoundary
@@ -592,25 +616,25 @@ function te(e, t) {
592
616
  s(e);
593
617
  return;
594
618
  }
595
- if (e.dismissedNode === r.node && e.dismissedOffset === i.startOffset)
619
+ if (e.dismissedNode === o.node && e.dismissedOffset === i.startOffset)
596
620
  return;
597
621
  e.dismissedNode = null, e.dismissedOffset = -1;
598
622
  const a = n.cloneRange();
599
- a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset), M(e, t, n, i.query, i.trigger, a);
623
+ a.setStart(o.node, i.startOffset), a.setEnd(o.node, o.caretOffset), M(e, t, n, i.query, i.trigger, a);
600
624
  }
601
- function O(e, t) {
602
- const o = e.editor;
603
- if (o.getAttribute("contenteditable") === "false")
625
+ function H(e, t) {
626
+ const r = e.editor;
627
+ if (r.getAttribute("contenteditable") === "false")
604
628
  return !1;
605
- let n = E(o);
606
- n || (n = document.createRange(), n.selectNodeContents(o), n.collapse(!1), y(o, n));
607
- const r = n.cloneRange();
608
- return r.collapse(!0), M(e, t, n, "", t.triggerChar, r), !0;
629
+ let n = v(r);
630
+ n || (n = document.createRange(), n.selectNodeContents(r), n.collapse(!1), E(r, n));
631
+ const o = n.cloneRange();
632
+ return o.collapse(!0), M(e, t, n, "", t.triggerChar, o), !0;
609
633
  }
610
- function ne(e) {
634
+ function ae(e) {
611
635
  return !(e.metaKey || e.ctrlKey) || e.altKey ? !1 : e.key === "/" || e.code === "Slash";
612
636
  }
613
- function re(e, t) {
637
+ function le(e, t) {
614
638
  return {
615
639
  editor: e,
616
640
  panel: null,
@@ -622,108 +646,108 @@ function re(e, t) {
622
646
  query: "",
623
647
  trigger: t.triggerChar,
624
648
  isOpen: !1,
625
- instanceId: ++P,
649
+ instanceId: ++K,
626
650
  anchorRange: null,
627
651
  dismissedNode: null,
628
652
  dismissedOffset: -1
629
653
  };
630
654
  }
631
655
  function w(e, t) {
632
- const o = g.get(e);
633
- if (o)
634
- return o.items = t.items, o;
635
- const n = re(e, t);
636
- return g.set(e, n), n;
637
- }
638
- function oe(e) {
639
- var o;
640
- const t = g.get(e);
641
- t && ((o = t.panel) != null && o.parentNode && t.panel.parentNode.removeChild(t.panel), g.delete(e));
642
- }
643
- function C(e, t, o) {
644
- if (p.has(e)) return;
656
+ const r = h.get(e);
657
+ if (r)
658
+ return r.items = t.items, r;
659
+ const n = le(e, t);
660
+ return h.set(e, n), n;
661
+ }
662
+ function se(e) {
663
+ var r;
664
+ const t = h.get(e);
665
+ t && ((r = t.panel) != null && r.parentNode && t.panel.parentNode.removeChild(t.panel), h.delete(e));
666
+ }
667
+ function C(e, t, r) {
668
+ if (b.has(e)) return;
645
669
  const n = {
646
670
  input: () => {
647
- te(t, o);
671
+ ie(t, r);
648
672
  },
649
- keydown: (r) => {
673
+ keydown: (o) => {
650
674
  if (t.editor.getAttribute("contenteditable") === "false") {
651
675
  s(t);
652
676
  return;
653
677
  }
654
- if (!t.isOpen && ne(r)) {
655
- r.preventDefault(), O(t, o);
678
+ if (!t.isOpen && ae(o)) {
679
+ o.preventDefault(), H(t, r);
656
680
  return;
657
681
  }
658
682
  if (t.isOpen) {
659
- if (r.key === "ArrowDown") {
660
- r.preventDefault(), R(t, 1);
683
+ if (o.key === "ArrowDown") {
684
+ o.preventDefault(), R(t, 1);
661
685
  return;
662
686
  }
663
- if (r.key === "ArrowUp") {
664
- r.preventDefault(), R(t, -1);
687
+ if (o.key === "ArrowUp") {
688
+ o.preventDefault(), R(t, -1);
665
689
  return;
666
690
  }
667
- if (r.key === "Enter" || r.key === "Tab") {
691
+ if (o.key === "Enter" || o.key === "Tab") {
668
692
  if (t.filteredItems.length === 0) {
669
- r.key === "Tab" && r.preventDefault(), s(t);
693
+ o.key === "Tab" && o.preventDefault(), s(t);
670
694
  return;
671
695
  }
672
- r.preventDefault(), N(t, t.activeIndex);
696
+ o.preventDefault(), O(t, t.activeIndex);
673
697
  return;
674
698
  }
675
- if (r.key === "Escape") {
676
- r.preventDefault(), t.replaceRange && (t.dismissedNode = t.replaceRange.startContainer, t.dismissedOffset = t.replaceRange.startOffset), s(t);
699
+ if (o.key === "Escape") {
700
+ o.preventDefault(), t.replaceRange && (t.dismissedNode = t.replaceRange.startContainer, t.dismissedOffset = t.replaceRange.startOffset), s(t);
677
701
  return;
678
702
  }
679
703
  }
680
704
  },
681
705
  blur: () => {
682
706
  window.setTimeout(() => {
683
- const r = document.activeElement;
684
- t.panel && r && t.panel.contains(r) || s(t);
707
+ const o = document.activeElement;
708
+ t.panel && o && t.panel.contains(o) || s(t);
685
709
  }, 0);
686
710
  },
687
- mousedown: (r) => {
711
+ mousedown: (o) => {
688
712
  if (!t.isOpen || !t.panel) return;
689
- const i = r.target;
713
+ const i = o.target;
690
714
  i && !t.panel.contains(i) && !e.contains(i) && s(t);
691
715
  },
692
716
  selectionchange: () => {
693
717
  if (!t.isOpen) return;
694
- const r = E(e);
695
- if (!r || !r.collapsed) {
718
+ const o = v(e);
719
+ if (!o || !o.collapsed) {
696
720
  s(t);
697
721
  return;
698
722
  }
699
- t.anchorRange = r.cloneRange(), T(t);
723
+ t.anchorRange = o.cloneRange(), I(t);
700
724
  },
701
725
  reposition: () => {
702
- T(t);
726
+ I(t);
703
727
  }
704
728
  };
705
- 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);
706
- }
707
- function ie(e) {
708
- const t = p.get(e);
709
- 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));
710
- }
711
- function ae(e) {
712
- b || (b = !0, f = (t) => {
713
- const o = t.target;
714
- if (!(o instanceof Node)) return;
715
- const n = _(o), r = (n == null ? void 0 : n.closest(c)) || null;
716
- if (!r) return;
717
- const i = w(r, e);
718
- C(r, i, e);
719
- }, document.addEventListener("focusin", f, !0));
720
- }
721
- function le() {
722
- !b || !f || (document.removeEventListener("focusin", f, !0), b = !1, f = null);
723
- }
724
- const ce = (e = {}) => {
725
- B();
726
- const t = D(e);
729
+ 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), b.set(e, n);
730
+ }
731
+ function ce(e) {
732
+ const t = b.get(e);
733
+ 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), b.delete(e));
734
+ }
735
+ function de(e) {
736
+ y || (y = !0, g = (t) => {
737
+ const r = t.target;
738
+ if (!(r instanceof Node)) return;
739
+ const n = Q(r), o = (n == null ? void 0 : n.closest(d)) || null;
740
+ if (!o) return;
741
+ const i = w(o, e);
742
+ C(o, i, e);
743
+ }, document.addEventListener("focusin", g, !0));
744
+ }
745
+ function ue() {
746
+ !y || !g || (document.removeEventListener("focusin", g, !0), y = !1, g = null);
747
+ }
748
+ const ge = (e = {}) => {
749
+ z();
750
+ const t = B(e);
727
751
  return {
728
752
  name: "slashCommands",
729
753
  toolbar: [
@@ -735,11 +759,11 @@ const ce = (e = {}) => {
735
759
  }
736
760
  ],
737
761
  commands: {
738
- openSlashCommands: (o, n) => {
739
- const r = F(n);
740
- if (!r) return !1;
741
- const i = w(r, t);
742
- return C(r, i, t), O(i, t);
762
+ openSlashCommands: (r, n) => {
763
+ const o = U(n);
764
+ if (!o) return !1;
765
+ const i = w(o, t);
766
+ return C(o, i, t), H(i, t);
743
767
  }
744
768
  },
745
769
  keymap: {
@@ -747,20 +771,20 @@ const ce = (e = {}) => {
747
771
  "Mod-Shift-7": "openSlashCommands"
748
772
  },
749
773
  init: () => {
750
- h += 1, ae(t), Array.from(document.querySelectorAll(c)).forEach((n) => {
751
- const r = w(n, t);
752
- C(n, r, t);
774
+ p += 1, de(t), Array.from(document.querySelectorAll(d)).forEach((n) => {
775
+ const o = w(n, t);
776
+ C(n, o, t);
753
777
  });
754
778
  },
755
779
  destroy: () => {
756
- h = Math.max(0, h - 1), Array.from(document.querySelectorAll(c)).forEach((n) => {
757
- const r = g.get(n);
758
- r && (s(r), ie(n), oe(n));
759
- }), h === 0 && le();
780
+ p = Math.max(0, p - 1), Array.from(document.querySelectorAll(d)).forEach((n) => {
781
+ const o = h.get(n);
782
+ o && (s(o), ce(n), se(n));
783
+ }), p === 0 && ue();
760
784
  }
761
785
  };
762
786
  };
763
787
  export {
764
- ce as SlashCommandsPlugin
788
+ ge as SlashCommandsPlugin
765
789
  };
766
- //# sourceMappingURL=SlashCommandsPlugin.native-BDIIwGNs.mjs.map
790
+ //# sourceMappingURL=SlashCommandsPlugin.native-BzGTRmMB.mjs.map