@editora/plugins 1.0.22 → 1.1.0

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 (103) hide show
  1. package/README.md +1 -1
  2. package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-BwhZsI5v.js} +11 -11
  3. package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-CojLCp6C.mjs} +61 -53
  4. package/dist/MediaManagerPlugin.native-CycfjOi4.js +1841 -0
  5. package/dist/MediaManagerPlugin.native-DZrmcmnm.mjs +4688 -0
  6. package/dist/a11y-checker.cjs.js +3 -3
  7. package/dist/a11y-checker.esm.js +6 -4
  8. package/dist/anchor.cjs.js +4 -4
  9. package/dist/anchor.esm.js +19 -18
  10. package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
  11. package/dist/anchoredPopover-Cygmit_o.js +1 -0
  12. package/dist/approval-workflow.cjs.js +7 -7
  13. package/dist/approval-workflow.esm.js +55 -54
  14. package/dist/background-color.cjs.js +2 -2
  15. package/dist/background-color.esm.js +72 -67
  16. package/dist/blocks-library.cjs.js +18 -19
  17. package/dist/blocks-library.esm.js +41 -42
  18. package/dist/citations.cjs.js +4 -4
  19. package/dist/citations.esm.js +50 -50
  20. package/dist/code-sample.cjs.js +10 -10
  21. package/dist/code-sample.esm.js +4 -4
  22. package/dist/code.cjs.js +1 -1
  23. package/dist/code.esm.js +1 -1
  24. package/dist/comments.cjs.js +23 -11
  25. package/dist/comments.esm.js +167 -149
  26. package/dist/conditional-content.cjs.js +2 -2
  27. package/dist/conditional-content.esm.js +2 -2
  28. package/dist/confirmDialog-D3S8BhIM.js +42 -0
  29. package/dist/confirmDialog-DR4c8j6S.mjs +87 -0
  30. package/dist/content-rules.cjs.js +6 -6
  31. package/dist/content-rules.esm.js +51 -51
  32. package/dist/data-binding.cjs.js +2 -2
  33. package/dist/data-binding.esm.js +2 -2
  34. package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
  35. package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
  36. package/dist/document-manager.cjs.js +1 -1
  37. package/dist/document-manager.esm.js +1 -1
  38. package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
  39. package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
  40. package/dist/embed-iframe.cjs.js +6 -6
  41. package/dist/embed-iframe.esm.js +6 -6
  42. package/dist/emojis.cjs.js +5 -5
  43. package/dist/emojis.esm.js +3 -3
  44. package/dist/enterprise.cjs.js +1 -1
  45. package/dist/enterprise.esm.js +12 -12
  46. package/dist/format-painter.cjs.js +1 -1
  47. package/dist/format-painter.esm.js +172 -151
  48. package/dist/heading.cjs.js +1 -1
  49. package/dist/heading.esm.js +96 -83
  50. package/dist/history.cjs.js +1 -1
  51. package/dist/history.esm.js +176 -97
  52. package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
  53. package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/index.esm.js +90 -83
  56. package/dist/katex-Cc3-mvOY.js +257 -0
  57. package/dist/katex-DoRnZ_sp.mjs +11682 -0
  58. package/dist/katex.min--Ws3c9be.mjs +5 -0
  59. package/dist/katex.min-Dk2VscxB.js +2 -0
  60. package/dist/link.cjs.js +3 -3
  61. package/dist/link.esm.js +3 -3
  62. package/dist/list.cjs.js +1 -1
  63. package/dist/list.esm.js +140 -52
  64. package/dist/math.cjs.js +14 -14
  65. package/dist/math.esm.js +149 -136
  66. package/dist/media-manager.cjs.js +1 -619
  67. package/dist/media-manager.esm.js +30 -1017
  68. package/dist/mentions.cjs.js +12 -12
  69. package/dist/mentions.esm.js +149 -143
  70. package/dist/merge-tag.cjs.js +5 -3
  71. package/dist/merge-tag.esm.js +5 -3
  72. package/dist/notify-BkbzMopb.js +32 -0
  73. package/dist/notify-zOp-mUOJ.mjs +59 -0
  74. package/dist/pii-redaction.cjs.js +1 -1
  75. package/dist/pii-redaction.esm.js +1 -1
  76. package/dist/preview.cjs.js +1 -1
  77. package/dist/preview.esm.js +1 -1
  78. package/dist/shared-config.cjs.js +1 -1
  79. package/dist/shared-config.esm.js +14 -14
  80. package/dist/slash-commands.cjs.js +5 -5
  81. package/dist/slash-commands.esm.js +259 -236
  82. package/dist/smart-paste.cjs.js +1 -1
  83. package/dist/smart-paste.esm.js +1 -1
  84. package/dist/special-characters.cjs.js +3 -3
  85. package/dist/special-characters.esm.js +3 -3
  86. package/dist/spell-check.cjs.js +9 -9
  87. package/dist/spell-check.esm.js +288 -251
  88. package/dist/table.cjs.js +14 -14
  89. package/dist/table.esm.js +175 -154
  90. package/dist/template.cjs.js +5 -3
  91. package/dist/template.esm.js +15 -13
  92. package/dist/text-color.cjs.js +4 -4
  93. package/dist/text-color.esm.js +38 -34
  94. package/dist/translation-workflow.cjs.js +9 -9
  95. package/dist/translation-workflow.esm.js +98 -95
  96. package/dist/version-diff.cjs.js +4 -4
  97. package/dist/version-diff.esm.js +36 -36
  98. package/index.d.ts +183 -2
  99. package/package.json +6 -5
  100. package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
  101. package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
  102. package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
  103. package/dist/dialogHelpers-zU6zpMIA.js +0 -12
@@ -1,4 +1,5 @@
1
- const K = [
1
+ import { f as D, k as Q, p as ee } from "./dialogHelpers-BbwpIXD9.mjs";
2
+ const te = [
2
3
  "a",
3
4
  "aa",
4
5
  "aaa",
@@ -9999,49 +10000,89 @@ const K = [
9999
10000
  "zu",
10000
10001
  "zum",
10001
10002
  "zus"
10002
- ], $ = /* @__PURE__ */ new Set([
10003
- ...K,
10003
+ ];
10004
+ function ie(e, t, a = 1 / 0) {
10005
+ if (e === t) return 0;
10006
+ if (Math.abs(e.length - t.length) > a) return a + 1;
10007
+ const s = [];
10008
+ for (let i = 0; i <= e.length; i++)
10009
+ s[i] = [i];
10010
+ for (let i = 1; i <= t.length; i++) s[0][i] = i;
10011
+ for (let i = 1; i <= e.length; i++) {
10012
+ let n = 1 / 0;
10013
+ for (let o = 1; o <= t.length; o++) {
10014
+ const l = e.charCodeAt(i - 1) === t.charCodeAt(o - 1) ? 0 : 1;
10015
+ let p = Math.min(s[i - 1][o] + 1, s[i][o - 1] + 1, s[i - 1][o - 1] + l);
10016
+ i > 1 && o > 1 && e.charCodeAt(i - 1) === t.charCodeAt(o - 2) && e.charCodeAt(i - 2) === t.charCodeAt(o - 1) && (p = Math.min(p, s[i - 2][o - 2] + 1)), s[i][o] = p, p < n && (n = p);
10017
+ }
10018
+ if (n > a) return a + 1;
10019
+ }
10020
+ return s[e.length][t.length];
10021
+ }
10022
+ function ae(e) {
10023
+ return e <= 4 ? 1 : e <= 7 ? 2 : 3;
10024
+ }
10025
+ function re(e, t, a = 5) {
10026
+ const r = e.toLowerCase(), s = ae(r.length), i = [], n = [...r].sort().join("");
10027
+ let o = 0;
10028
+ for (const l of t) {
10029
+ if (o += 1, Math.abs(l.length - r.length) > s) continue;
10030
+ const p = ie(r, l, s);
10031
+ p > s || i.push({
10032
+ word: l,
10033
+ distance: p,
10034
+ notAnagram: [...l].sort().join("") === n ? 0 : 1,
10035
+ sameInitial: l[0] === r[0] ? 0 : 1,
10036
+ rank: o
10037
+ });
10038
+ }
10039
+ return i.sort(
10040
+ (l, p) => l.distance - p.distance || l.notAnagram - p.notAnagram || l.sameInitial - p.sameInitial || l.rank - p.rank
10041
+ ), i.slice(0, a).map((l) => l.word);
10042
+ }
10043
+ const P = /* @__PURE__ */ new Set([
10044
+ ...te,
10004
10045
  "hers",
10005
10046
  "theirs",
10006
10047
  "lorem",
10007
10048
  "ipsum"
10008
- ]), z = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Set();
10009
- let m = !1, d = null, b = null, o = null, l = null, v = null, x = !1, u = null, O = !1, f = 0, y = null;
10010
- const B = {
10049
+ ]), q = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set();
10050
+ let h = !1, u = null, y = null, c = null, d = null, w = null, j = !1, g = null, F = !1, v = 0, k = null;
10051
+ const W = {
10011
10052
  characterData: !0,
10012
10053
  childList: !0,
10013
10054
  subtree: !0
10014
- }, D = "rte-spellcheck-styles", F = "__editoraCommandEditorRoot";
10015
- function Q(e) {
10055
+ }, I = "rte-spellcheck-styles", H = "__editoraCommandEditorRoot";
10056
+ function se(e) {
10016
10057
  const t = e?.contentElement || e?.editorElement || null;
10017
10058
  if (!(t instanceof HTMLElement)) return;
10018
- const r = t.getAttribute("contenteditable") === "true" ? t : t.querySelector?.('[contenteditable="true"]');
10019
- if (r instanceof HTMLElement) {
10020
- l = r, u = r;
10059
+ const a = t.getAttribute("contenteditable") === "true" ? t : t.querySelector?.('[contenteditable="true"]');
10060
+ if (a instanceof HTMLElement) {
10061
+ d = a, g = a;
10021
10062
  return;
10022
10063
  }
10023
- const a = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null), i = S(a);
10024
- i && (l = i, u = i);
10064
+ const r = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null), s = A(r);
10065
+ s && (d = s, g = s);
10025
10066
  }
10026
- function P() {
10067
+ function G() {
10027
10068
  if (typeof window > "u") return null;
10028
- const e = window[F];
10069
+ const e = window[H];
10029
10070
  if (!(e instanceof HTMLElement)) return null;
10030
- window[F] = null;
10071
+ window[H] = null;
10031
10072
  const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
10032
10073
  if (t) {
10033
- const a = S(t);
10034
- if (a) return a;
10074
+ const r = A(t);
10075
+ if (r) return r;
10035
10076
  if (t.getAttribute("contenteditable") === "true") return t;
10036
10077
  }
10037
10078
  if (e.getAttribute("contenteditable") === "true")
10038
10079
  return e;
10039
- const r = e.closest('[contenteditable="true"]');
10040
- return r instanceof HTMLElement ? r : null;
10080
+ const a = e.closest('[contenteditable="true"]');
10081
+ return a instanceof HTMLElement ? a : null;
10041
10082
  }
10042
- function C() {
10043
- let e = document.getElementById(D);
10044
- e || (e = document.createElement("style"), e.id = D, document.head.appendChild(e)), e.textContent = `
10083
+ function S() {
10084
+ let e = document.getElementById(I);
10085
+ e || (e = document.createElement("style"), e.id = I, document.head.appendChild(e)), e.textContent = `
10045
10086
  .rte-spell-check-panel {
10046
10087
  position: absolute;
10047
10088
  top: 12px;
@@ -10511,299 +10552,283 @@ function C() {
10511
10552
  }
10512
10553
  `;
10513
10554
  }
10514
- function h() {
10515
- if (l && document.contains(l))
10516
- return l;
10517
- const e = J();
10518
- return e && (l = e), e;
10555
+ function f() {
10556
+ if (d && document.contains(d))
10557
+ return d;
10558
+ const e = U();
10559
+ return e && (d = e), e;
10519
10560
  }
10520
- function W(e) {
10561
+ function J(e) {
10521
10562
  if (!e) return;
10522
- const r = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]');
10523
- r && (l = r);
10563
+ const a = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]');
10564
+ a && (d = a);
10524
10565
  }
10525
- function S(e) {
10566
+ function A(e) {
10526
10567
  if (!e) return null;
10527
10568
  const t = e.querySelector('[contenteditable="true"]');
10528
10569
  return t instanceof HTMLElement ? t : null;
10529
10570
  }
10530
- function ee() {
10531
- if (O) return;
10571
+ function ne() {
10572
+ if (F) return;
10532
10573
  const e = (t) => {
10533
- const r = t.target;
10534
- if (!r) return;
10535
- const a = r.closest(
10574
+ const a = t.target;
10575
+ if (!a) return;
10576
+ const r = a.closest(
10536
10577
  '.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]'
10537
10578
  );
10538
- if (!a) return;
10539
- const i = a.closest("[data-editora-editor]"), s = S(i);
10540
- s && (u = s, l = s);
10579
+ if (!r) return;
10580
+ const s = r.closest("[data-editora-editor]"), i = A(s);
10581
+ i && (g = i, d = i);
10541
10582
  };
10542
- document.addEventListener("pointerdown", e, !0), O = !0;
10583
+ document.addEventListener("pointerdown", e, !0), F = !0;
10543
10584
  }
10544
- function te() {
10545
- const e = P();
10585
+ function oe() {
10586
+ const e = G();
10546
10587
  if (e && document.contains(e))
10547
- return l = e, u = null, e;
10548
- if (u && document.contains(u)) {
10549
- const t = u;
10550
- return u = null, l = t, t;
10588
+ return d = e, g = null, e;
10589
+ if (g && document.contains(g)) {
10590
+ const t = g;
10591
+ return g = null, d = t, t;
10551
10592
  }
10552
- return J();
10593
+ return U();
10553
10594
  }
10554
- function ie() {
10555
- f += 1, f === 1 && d && d.disconnect();
10595
+ function le() {
10596
+ v += 1, v === 1 && u && u.disconnect();
10556
10597
  }
10557
- function ae() {
10558
- if (f === 0 || (f -= 1, f > 0) || !d) return;
10559
- const e = h();
10560
- e && d.observe(e, B);
10598
+ function ce() {
10599
+ if (v === 0 || (v -= 1, v > 0) || !u) return;
10600
+ const e = f();
10601
+ e && u.observe(e, W);
10561
10602
  }
10562
10603
  function L(e) {
10563
- ie();
10604
+ le();
10564
10605
  try {
10565
10606
  return e();
10566
10607
  } finally {
10567
- ae();
10608
+ ce();
10568
10609
  }
10569
10610
  }
10570
- const re = () => {
10611
+ const de = () => {
10571
10612
  try {
10572
10613
  const e = localStorage.getItem("rte-custom-dictionary");
10573
- e && JSON.parse(e).forEach((r) => z.add(r.toLowerCase()));
10614
+ e && JSON.parse(e).forEach((a) => q.add(a.toLowerCase()));
10574
10615
  } catch (e) {
10575
10616
  console.warn("Failed to load custom dictionary:", e);
10576
10617
  }
10577
- }, se = () => {
10618
+ }, pe = () => {
10578
10619
  try {
10579
- const e = Array.from(z);
10620
+ const e = Array.from(q);
10580
10621
  localStorage.setItem("rte-custom-dictionary", JSON.stringify(e));
10581
10622
  } catch (e) {
10582
10623
  console.warn("Failed to save custom dictionary:", e);
10583
10624
  }
10584
10625
  };
10585
- function ne(e, t) {
10586
- const r = [];
10587
- for (let a = 0; a <= t.length; a++) r[a] = [a];
10588
- for (let a = 0; a <= e.length; a++) r[0][a] = a;
10589
- for (let a = 1; a <= t.length; a++)
10590
- for (let i = 1; i <= e.length; i++)
10591
- t.charAt(a - 1) === e.charAt(i - 1) ? r[a][i] = r[a - 1][i - 1] : r[a][i] = Math.min(
10592
- r[a - 1][i - 1] + 1,
10593
- // substitution
10594
- r[a][i - 1] + 1,
10595
- // insertion
10596
- r[a - 1][i] + 1
10597
- // deletion
10598
- );
10599
- return r[t.length][e.length];
10600
- }
10601
- function oe(e) {
10626
+ function ue(e) {
10602
10627
  const t = e.toLowerCase();
10603
- return $.has(t) || z.has(t) || q.has(t);
10628
+ return P.has(t) || q.has(t) || E.has(t);
10604
10629
  }
10605
- function le(e, t = 5) {
10606
- const r = e.toLowerCase(), i = Array.from($).map((s) => ({ word: s, distance: ne(r, s) }));
10607
- return i.sort((s, n) => s.distance - n.distance), i.filter((s) => s.distance <= 3).slice(0, t).map((s) => s.word);
10630
+ function me(e, t = 5) {
10631
+ return re(e, P, t);
10608
10632
  }
10609
- function ce(e) {
10633
+ function ge(e) {
10610
10634
  if (e.nodeType !== Node.ELEMENT_NODE) return !1;
10611
10635
  const t = e;
10612
10636
  return !!(t.closest('code, pre, [contenteditable="false"], .rte-widget, .rte-template, .rte-comment, .rte-merge-tag') || t.hasAttribute("data-comment-id") || t.hasAttribute("data-template") || t.hasAttribute("data-merge-tag"));
10613
10637
  }
10614
- function de(e) {
10615
- const t = [], r = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
10616
- let a;
10617
- for (; (a = r.exec(e.data)) !== null; ) {
10618
- const i = a[0], s = a.index, n = s + i.length;
10619
- /https?:\/\//.test(i) || /@/.test(i) || /\{\{.*\}\}/.test(i) || /^\d+$/.test(i) || oe(i) || /[a-z][A-Z]/.test(i) || /-/.test(i) || i[0] === i[0].toUpperCase() && i.length > 1 || t.push({
10620
- id: `${i}-${s}`,
10638
+ function he(e) {
10639
+ const t = [], a = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
10640
+ let r;
10641
+ for (; (r = a.exec(e.data)) !== null; ) {
10642
+ const s = r[0], i = r.index, n = i + s.length;
10643
+ /https?:\/\//.test(s) || /@/.test(s) || /\{\{.*\}\}/.test(s) || /^\d+$/.test(s) || ue(s) || /[a-z][A-Z]/.test(s) || /-/.test(s) || s[0] === s[0].toUpperCase() && s.length > 1 || t.push({
10644
+ id: `${s}-${i}`,
10621
10645
  node: e,
10622
- startOffset: s,
10646
+ startOffset: i,
10623
10647
  endOffset: n,
10624
- word: i,
10625
- suggestions: le(i),
10648
+ word: s,
10649
+ suggestions: me(s),
10626
10650
  ignored: !1
10627
10651
  });
10628
10652
  }
10629
10653
  return t;
10630
10654
  }
10631
- const J = () => {
10632
- const e = P();
10655
+ const U = () => {
10656
+ const e = G();
10633
10657
  if (e && document.contains(e))
10634
- return l = e, e;
10658
+ return d = e, e;
10635
10659
  const t = window.getSelection();
10636
10660
  if (t && t.rangeCount > 0) {
10637
- let a = t.getRangeAt(0).startContainer;
10638
- for (; a && a !== document.body; ) {
10639
- if (a.nodeType === Node.ELEMENT_NODE) {
10640
- const i = a;
10641
- if (i.getAttribute("contenteditable") === "true")
10642
- return i;
10661
+ let r = t.getRangeAt(0).startContainer;
10662
+ for (; r && r !== document.body; ) {
10663
+ if (r.nodeType === Node.ELEMENT_NODE) {
10664
+ const s = r;
10665
+ if (s.getAttribute("contenteditable") === "true")
10666
+ return s;
10643
10667
  }
10644
- a = a.parentNode;
10668
+ r = r.parentNode;
10645
10669
  }
10646
10670
  }
10647
- const r = document.activeElement;
10648
- if (r) {
10649
- if (r.getAttribute("contenteditable") === "true")
10650
- return r;
10651
- const a = r.closest('[contenteditable="true"]');
10652
- if (a) return a;
10653
- const i = r.closest("[data-editora-editor]");
10654
- if (i) {
10655
- const s = i.querySelector('[contenteditable="true"]');
10656
- if (s) return s;
10671
+ const a = document.activeElement;
10672
+ if (a) {
10673
+ if (a.getAttribute("contenteditable") === "true")
10674
+ return a;
10675
+ const r = a.closest('[contenteditable="true"]');
10676
+ if (r) return r;
10677
+ const s = a.closest("[data-editora-editor]");
10678
+ if (s) {
10679
+ const i = s.querySelector('[contenteditable="true"]');
10680
+ if (i) return i;
10657
10681
  }
10658
10682
  }
10659
10683
  return document.querySelector('[contenteditable="true"]');
10660
10684
  };
10661
10685
  function T() {
10662
- const e = h();
10686
+ const e = f();
10663
10687
  if (!e) return [];
10664
- const t = [], r = document.createTreeWalker(
10688
+ const t = [], a = document.createTreeWalker(
10665
10689
  e,
10666
10690
  NodeFilter.SHOW_TEXT,
10667
10691
  {
10668
- acceptNode: (i) => !i.textContent?.trim() || i.parentNode && ce(i.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
10692
+ acceptNode: (s) => !s.textContent?.trim() || s.parentNode && ge(s.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
10669
10693
  }
10670
10694
  );
10671
- let a = r.nextNode();
10672
- for (; a; )
10673
- t.push(...de(a)), a = r.nextNode();
10695
+ let r = a.nextNode();
10696
+ for (; r; )
10697
+ t.push(...he(r)), r = a.nextNode();
10674
10698
  return t;
10675
10699
  }
10676
- function g(e) {
10677
- const t = h();
10700
+ function b(e) {
10701
+ const t = f();
10678
10702
  t && (e || (e = T()), L(() => {
10679
- t.querySelectorAll(".rte-misspelled").forEach((a) => {
10680
- const i = a.parentNode;
10681
- if (i) {
10682
- for (; a.firstChild; )
10683
- i.insertBefore(a.firstChild, a);
10684
- i.removeChild(a);
10703
+ t.querySelectorAll(".rte-misspelled").forEach((r) => {
10704
+ const s = r.parentNode;
10705
+ if (s) {
10706
+ for (; r.firstChild; )
10707
+ s.insertBefore(r.firstChild, r);
10708
+ s.removeChild(r);
10685
10709
  }
10686
- }), [...e].sort((a, i) => i.startOffset - a.startOffset).forEach((a) => {
10687
- if (q.has(a.word.toLowerCase())) return;
10688
- const i = a.node.data.length;
10689
- if (!(a.startOffset < 0 || a.endOffset > i || a.startOffset >= a.endOffset))
10710
+ }), [...e].sort((r, s) => s.startOffset - r.startOffset).forEach((r) => {
10711
+ if (E.has(r.word.toLowerCase())) return;
10712
+ const s = r.node.data.length;
10713
+ if (!(r.startOffset < 0 || r.endOffset > s || r.startOffset >= r.endOffset))
10690
10714
  try {
10691
- const s = document.createRange();
10692
- s.setStart(a.node, a.startOffset), s.setEnd(a.node, a.endOffset);
10715
+ const i = document.createRange();
10716
+ i.setStart(r.node, r.startOffset), i.setEnd(r.node, r.endOffset);
10693
10717
  const n = document.createElement("span");
10694
- n.className = "rte-misspelled", n.setAttribute("data-word", a.word), n.setAttribute("data-suggestions", a.suggestions.join(",")), n.setAttribute("title", `Suggestions: ${a.suggestions.join(", ")}`), n.style.borderBottom = "2px wavy red", n.style.cursor = "pointer", s.surroundContents(n);
10718
+ n.className = "rte-misspelled", n.setAttribute("data-word", r.word), n.setAttribute("data-suggestions", r.suggestions.join(",")), n.setAttribute("title", `Suggestions: ${r.suggestions.join(", ")}`), n.style.borderBottom = "2px wavy red", n.style.cursor = "pointer", i.surroundContents(n);
10695
10719
  } catch {
10696
10720
  }
10697
10721
  });
10698
- }), j(e));
10722
+ }), z(e));
10699
10723
  }
10700
- function E() {
10701
- const e = h();
10724
+ function C() {
10725
+ const e = f();
10702
10726
  e && L(() => {
10703
10727
  e.querySelectorAll(".rte-misspelled").forEach((t) => {
10704
- const r = t.parentNode;
10705
- if (r) {
10728
+ const a = t.parentNode;
10729
+ if (a) {
10706
10730
  for (; t.firstChild; )
10707
- r.insertBefore(t.firstChild, t);
10708
- r.removeChild(t);
10731
+ a.insertBefore(t.firstChild, t);
10732
+ a.removeChild(t);
10709
10733
  }
10710
10734
  });
10711
10735
  });
10712
10736
  }
10713
- function pe(e, t) {
10737
+ function be(e, t) {
10714
10738
  L(() => {
10715
- const r = document.createRange();
10716
- r.setStart(e.node, e.startOffset), r.setEnd(e.node, e.endOffset);
10717
- const a = document.createTextNode(t);
10718
- r.deleteContents(), r.insertNode(a);
10739
+ const a = document.createRange();
10740
+ a.setStart(e.node, e.startOffset), a.setEnd(e.node, e.endOffset);
10741
+ const r = document.createTextNode(t);
10742
+ a.deleteContents(), a.insertNode(r);
10719
10743
  });
10720
10744
  }
10721
- function U(e) {
10722
- q.add(e.toLowerCase()), E(), g();
10723
- }
10724
10745
  function Y(e) {
10725
- z.add(e.toLowerCase()), se(), E(), g();
10746
+ E.add(e.toLowerCase()), C(), b();
10726
10747
  }
10727
- function ue(e) {
10728
- const t = h();
10748
+ function V(e) {
10749
+ q.add(e.toLowerCase()), pe(), C(), b();
10750
+ }
10751
+ function fe(e) {
10752
+ const t = f();
10729
10753
  if (!t) return { total: 0, misspelled: 0, accuracy: 100 };
10730
10754
  e || (e = T());
10731
- const r = e.filter((n) => !q.has(n.word.toLowerCase())).length, s = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
10755
+ const a = e.filter((n) => !E.has(n.word.toLowerCase())).length, i = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
10732
10756
  return {
10733
- total: s,
10734
- misspelled: r,
10735
- accuracy: s > 0 ? (s - r) / s * 100 : 100
10757
+ total: i,
10758
+ misspelled: a,
10759
+ accuracy: i > 0 ? (i - a) / i * 100 : 100
10736
10760
  };
10737
10761
  }
10738
- function me(e, t) {
10739
- const r = document.createTextNode(t);
10740
- e.replaceWith(r);
10762
+ function ye(e, t) {
10763
+ const a = document.createTextNode(t);
10764
+ e.replaceWith(a);
10741
10765
  }
10742
- function ge(e) {
10766
+ function ve(e) {
10743
10767
  e.classList.remove("rte-misspelled"), e.removeAttribute("data-word"), e.removeAttribute("data-suggestions"), e.removeAttribute("title"), e.style.borderBottom = "", e.style.cursor = "";
10744
10768
  }
10745
- function he(e, t, r, a, i) {
10746
- W(i), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
10747
- const s = document.createElement("div");
10748
- if (s.className = "rte-spellcheck-menu", a.slice(0, 5).forEach((p) => {
10749
- const w = document.createElement("div");
10750
- w.className = "rte-spellcheck-menu-item", w.textContent = p, w.onclick = () => {
10751
- me(i, p), window.setTimeout(() => {
10752
- m && (g(), j());
10753
- }, 0), s.remove();
10754
- }, s.appendChild(w);
10755
- }), a.length > 0) {
10756
- const p = document.createElement("div");
10757
- p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", s.appendChild(p);
10769
+ function ke(e, t, a, r, s) {
10770
+ J(s), document.querySelectorAll(".rte-spellcheck-menu").forEach((m) => m.remove());
10771
+ const i = document.createElement("div");
10772
+ if (i.className = "rte-spellcheck-menu", r.slice(0, 5).forEach((m) => {
10773
+ const x = document.createElement("div");
10774
+ x.className = "rte-spellcheck-menu-item", x.textContent = m, x.onclick = () => {
10775
+ ye(s, m), window.setTimeout(() => {
10776
+ h && (b(), z());
10777
+ }, 0), i.remove();
10778
+ }, i.appendChild(x);
10779
+ }), r.length > 0) {
10780
+ const m = document.createElement("div");
10781
+ m.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", i.appendChild(m);
10758
10782
  }
10759
10783
  const n = document.createElement("div");
10760
10784
  n.className = "rte-spellcheck-menu-item meta", n.textContent = "Ignore Once", n.onclick = () => {
10761
- ge(i), s.remove();
10762
- }, s.appendChild(n);
10763
- const c = document.createElement("div");
10764
- c.className = "rte-spellcheck-menu-item meta", c.textContent = "Ignore All", c.onclick = () => {
10765
- U(r), s.remove();
10766
- }, s.appendChild(c);
10767
- const k = document.createElement("div");
10768
- k.className = "rte-spellcheck-menu-item positive", k.textContent = "Add to Dictionary", k.onclick = () => {
10769
- Y(r), s.remove();
10770
- }, s.appendChild(k), document.body.appendChild(s);
10771
- const A = s.getBoundingClientRect(), Z = window.innerWidth - A.width - 8, G = window.innerHeight - A.height - 8;
10772
- s.style.left = `${Math.max(8, Math.min(e, Z))}px`, s.style.top = `${Math.max(8, Math.min(t, G))}px`;
10773
- const M = (p) => {
10774
- s.contains(p.target) || (s.remove(), document.removeEventListener("mousedown", M));
10785
+ ve(s), i.remove();
10786
+ }, i.appendChild(n);
10787
+ const o = document.createElement("div");
10788
+ o.className = "rte-spellcheck-menu-item meta", o.textContent = "Ignore All", o.onclick = () => {
10789
+ Y(a), i.remove();
10790
+ }, i.appendChild(o);
10791
+ const l = document.createElement("div");
10792
+ l.className = "rte-spellcheck-menu-item positive", l.textContent = "Add to Dictionary", l.onclick = () => {
10793
+ V(a), i.remove();
10794
+ }, i.appendChild(l), document.body.appendChild(i);
10795
+ const p = i.getBoundingClientRect(), Z = window.innerWidth - p.width - 8, K = window.innerHeight - p.height - 8;
10796
+ i.style.left = `${Math.max(8, Math.min(e, Z))}px`, i.style.top = `${Math.max(8, Math.min(t, K))}px`;
10797
+ const O = (m) => {
10798
+ i.contains(m.target) || (i.remove(), document.removeEventListener("mousedown", O));
10775
10799
  };
10776
- setTimeout(() => document.addEventListener("mousedown", M), 0);
10800
+ setTimeout(() => document.addEventListener("mousedown", O), 0);
10777
10801
  }
10778
- function H() {
10779
- x || (v = (e) => {
10802
+ function _() {
10803
+ j || (w = (e) => {
10780
10804
  const t = e.target;
10781
10805
  if (t && t.classList.contains("rte-misspelled")) {
10782
- e.preventDefault(), W(t);
10783
- const r = t.getAttribute("data-word"), a = (t.getAttribute("data-suggestions") || "").split(",").filter((i) => i);
10784
- he(e.clientX, e.clientY, r, a, t);
10806
+ e.preventDefault(), J(t);
10807
+ const a = t.getAttribute("data-word"), r = (t.getAttribute("data-suggestions") || "").split(",").filter((s) => s);
10808
+ ke(e.clientX, e.clientY, a, r, t);
10785
10809
  }
10786
- }, document.addEventListener("contextmenu", v), x = !0);
10810
+ }, document.addEventListener("contextmenu", w), j = !0);
10787
10811
  }
10788
- function be() {
10789
- !x || !v || (document.removeEventListener("contextmenu", v), v = null, x = !1);
10812
+ function we() {
10813
+ !j || !w || (document.removeEventListener("contextmenu", w), w = null, j = !1);
10790
10814
  }
10791
- function fe(e) {
10815
+ function xe(e) {
10792
10816
  return e.closest("[data-editora-editor]") || e.parentElement || e;
10793
10817
  }
10794
- function I() {
10795
- const e = h();
10818
+ function R() {
10819
+ const e = f();
10796
10820
  if (!e)
10797
10821
  throw new Error("Spell check panel requested without active editor");
10798
- const t = fe(e);
10799
- C();
10800
- const r = document.createElement("div");
10801
- return r.className = "rte-spell-check-panel", window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(r), r;
10822
+ const t = xe(e);
10823
+ S();
10824
+ const a = document.createElement("div");
10825
+ return a.className = "rte-spell-check-panel", a.setAttribute("role", "complementary"), a.setAttribute("aria-label", "Spell check"), window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(a), a;
10802
10826
  }
10803
- function j(e) {
10804
- if (!o) return;
10805
- const t = e || T(), r = ue(t);
10806
- o.innerHTML = `
10827
+ function z(e) {
10828
+ if (!c) return;
10829
+ const t = e || T(), a = fe(t), r = c;
10830
+ Q(r, () => {
10831
+ r.innerHTML = `
10807
10832
  <div class="rte-spellcheck-header">
10808
10833
  <div>
10809
10834
  <h3 class="rte-spellcheck-title">Spell Check</h3>
@@ -10815,28 +10840,28 @@ function j(e) {
10815
10840
  <div class="rte-spellcheck-stats">
10816
10841
  <div class="rte-spellcheck-stat">
10817
10842
  <span class="rte-spellcheck-stat-label">Total</span>
10818
- <strong class="rte-spellcheck-stat-value">${r.total}</strong>
10843
+ <strong class="rte-spellcheck-stat-value">${a.total}</strong>
10819
10844
  </div>
10820
10845
  <div class="rte-spellcheck-stat">
10821
10846
  <span class="rte-spellcheck-stat-label">Misspelled</span>
10822
- <strong class="rte-spellcheck-stat-value">${r.misspelled}</strong>
10847
+ <strong class="rte-spellcheck-stat-value">${a.misspelled}</strong>
10823
10848
  </div>
10824
10849
  <div class="rte-spellcheck-stat">
10825
10850
  <span class="rte-spellcheck-stat-label">Accuracy</span>
10826
- <strong class="rte-spellcheck-stat-value">${r.accuracy.toFixed(1)}%</strong>
10851
+ <strong class="rte-spellcheck-stat-value">${a.accuracy.toFixed(1)}%</strong>
10827
10852
  </div>
10828
10853
  </div>
10829
10854
 
10830
10855
  <div class="rte-spellcheck-list">
10831
- ${t.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : t.map((i, s) => `
10832
- <div class="rte-spellcheck-item" data-word="${i.word}" data-index="${s}">
10856
+ ${t.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : t.map((i, n) => `
10857
+ <div class="rte-spellcheck-item" data-word="${i.word}" data-index="${n}">
10833
10858
  <button class="rte-spellcheck-word-header" type="button">
10834
10859
  <span class="rte-spellcheck-word">${i.word}</span>
10835
10860
  <span class="rte-spellcheck-caret">▶</span>
10836
10861
  </button>
10837
10862
  <div class="rte-spellcheck-suggestions">
10838
10863
  ${i.suggestions.length > 0 ? `<div class="rte-spellcheck-actions">
10839
- ${i.suggestions.map((n) => `<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${n}" type="button">${n}</button>`).join("")}
10864
+ ${i.suggestions.map((o) => `<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${o}" type="button">${o}</button>`).join("")}
10840
10865
  </div>` : '<div class="rte-spellcheck-subtitle">No suggestions available</div>'}
10841
10866
  <div class="rte-spellcheck-actions">
10842
10867
  <button class="rte-spellcheck-btn ignore-btn" type="button">Ignore</button>
@@ -10846,65 +10871,77 @@ function j(e) {
10846
10871
  </div>
10847
10872
  `).join("")}
10848
10873
  </div>
10849
- `, o.querySelector(".rte-spellcheck-close")?.addEventListener("click", (i) => {
10850
- i.preventDefault(), i.stopPropagation(), N();
10851
- }), o.querySelectorAll(".rte-spellcheck-word-header").forEach((i) => {
10874
+ `;
10875
+ }), c.querySelector(".rte-spellcheck-close")?.addEventListener("click", (i) => {
10876
+ i.preventDefault(), i.stopPropagation(), M(!0);
10877
+ }), c.querySelectorAll(".rte-spellcheck-word-header").forEach((i) => {
10852
10878
  i.addEventListener("click", () => {
10853
- const n = i.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"), c = i.querySelector(".rte-spellcheck-caret");
10854
- n && c && (n.classList.contains("show") ? (n.classList.remove("show"), c.textContent = "▶") : (n.classList.add("show"), c.textContent = "▼"));
10879
+ const o = i.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"), l = i.querySelector(".rte-spellcheck-caret");
10880
+ o && l && (o.classList.contains("show") ? (o.classList.remove("show"), l.textContent = "▶") : (o.classList.add("show"), l.textContent = "▼"));
10855
10881
  });
10856
- }), o.querySelectorAll(".suggestion-btn").forEach((i) => {
10882
+ }), c.querySelectorAll(".suggestion-btn").forEach((i) => {
10857
10883
  i.addEventListener("click", () => {
10858
- const s = i.getAttribute("data-suggestion"), n = i.closest(".rte-spellcheck-item"), c = parseInt(n?.getAttribute("data-index") || "0", 10);
10859
- s !== null && t[c] && (pe(t[c], s), g());
10884
+ const n = i.getAttribute("data-suggestion"), o = i.closest(".rte-spellcheck-item"), l = parseInt(o?.getAttribute("data-index") || "0", 10);
10885
+ n !== null && t[l] && (be(t[l], n), b());
10860
10886
  });
10861
- }), o.querySelectorAll(".ignore-btn").forEach((i) => {
10887
+ }), c.querySelectorAll(".ignore-btn").forEach((i) => {
10862
10888
  i.addEventListener("click", () => {
10863
- const s = i.closest(".rte-spellcheck-item")?.getAttribute("data-word");
10864
- s && U(s);
10889
+ const n = i.closest(".rte-spellcheck-item")?.getAttribute("data-word");
10890
+ n && Y(n);
10865
10891
  });
10866
- }), o.querySelectorAll(".add-btn").forEach((i) => {
10892
+ }), c.querySelectorAll(".add-btn").forEach((i) => {
10867
10893
  i.addEventListener("click", () => {
10868
- const s = i.closest(".rte-spellcheck-item")?.getAttribute("data-word");
10869
- s && Y(s);
10894
+ const n = i.closest(".rte-spellcheck-item")?.getAttribute("data-word");
10895
+ n && V(n);
10870
10896
  });
10871
10897
  });
10872
10898
  }
10873
- function _() {
10874
- const e = h();
10875
- e && (d && d.disconnect(), d = new MutationObserver((t) => {
10876
- f > 0 || t.some((r) => r.type === "characterData" || r.type === "childList") && (b && clearTimeout(b), b = window.setTimeout(() => {
10877
- m && g();
10899
+ function $() {
10900
+ const e = f();
10901
+ e && (u && u.disconnect(), u = new MutationObserver((t) => {
10902
+ v > 0 || t.some((a) => a.type === "characterData" || a.type === "childList") && (y && clearTimeout(y), y = window.setTimeout(() => {
10903
+ h && b();
10878
10904
  }, 350));
10879
- }), d.observe(e, {
10880
- ...B
10905
+ }), u.observe(e, {
10906
+ ...W
10881
10907
  }));
10882
10908
  }
10883
- function V() {
10884
- d && (d.disconnect(), d = null), b && (clearTimeout(b), b = null);
10885
- }
10886
10909
  function X() {
10910
+ u && (u.disconnect(), u = null), y && (clearTimeout(y), y = null);
10911
+ }
10912
+ function N() {
10887
10913
  document.querySelectorAll(".rte-spellcheck-menu").forEach((e) => e.remove());
10888
10914
  }
10889
- function R() {
10890
- y || (y = (e) => {
10891
- e.key !== "Escape" || !m || (e.preventDefault(), e.stopPropagation(), N());
10892
- }, document.addEventListener("keydown", y, !0));
10915
+ function B() {
10916
+ k || (k = (e) => {
10917
+ if (e.key !== "Escape" || !h) return;
10918
+ const t = e.target;
10919
+ if (t && (c?.contains(t) || d?.contains(t))) {
10920
+ if (e.preventDefault(), e.stopPropagation(), document.querySelector(".rte-spellcheck-menu")) {
10921
+ N();
10922
+ return;
10923
+ }
10924
+ M();
10925
+ }
10926
+ }, document.addEventListener("keydown", k, !0));
10893
10927
  }
10894
- function ye() {
10895
- y && (document.removeEventListener("keydown", y, !0), y = null);
10928
+ function je() {
10929
+ k && (document.removeEventListener("keydown", k, !0), k = null);
10896
10930
  }
10897
- function N() {
10898
- return m && (E(), V(), be(), X(), o && (o.remove(), o = null), l = null, u = null, m = !1, ye()), !1;
10931
+ function M(e = !1) {
10932
+ if (!h) return !1;
10933
+ C(), X(), we(), N();
10934
+ const t = e || ee(c) ? d : null;
10935
+ return c && (c.remove(), c = null), d = null, g = null, h = !1, je(), t?.focus({ preventScroll: !0 }), !1;
10899
10936
  }
10900
- function ve() {
10901
- const e = te();
10902
- return e ? m && l && l !== e ? (E(), V(), X(), o && (o.remove(), o = null), l = e, C(), H(), R(), g(), _(), o = I(), j(), !0) : m ? N() : (l = e, m = !0, C(), H(), R(), g(), _(), o && (o.remove(), o = null), o = I(), j(), !0) : !1;
10937
+ function ze() {
10938
+ const e = oe();
10939
+ return e ? h && d && d !== e ? (C(), X(), N(), c && (c.remove(), c = null), d = e, S(), _(), B(), b(), $(), c = R(), z(), D(c), !0) : h ? M() : (d = e, h = !0, S(), _(), B(), b(), $(), c && (c.remove(), c = null), c = R(), z(), D(c), !0) : !1;
10903
10940
  }
10904
- const ke = () => ({
10941
+ const Ee = () => ({
10905
10942
  name: "spellCheck",
10906
10943
  init: () => {
10907
- re(), ee();
10944
+ de(), ne();
10908
10945
  },
10909
10946
  toolbar: [
10910
10947
  {
@@ -10915,12 +10952,12 @@ const ke = () => ({
10915
10952
  }
10916
10953
  ],
10917
10954
  commands: {
10918
- toggleSpellCheck: (e, t) => (Q(t), ve(), !0)
10955
+ toggleSpellCheck: (e, t) => (se(t), ze(), !0)
10919
10956
  },
10920
10957
  keymap: {
10921
10958
  F7: "toggleSpellCheck"
10922
10959
  }
10923
10960
  });
10924
10961
  export {
10925
- ke as SpellCheckPlugin
10962
+ Ee as SpellCheckPlugin
10926
10963
  };