@editora/plugins 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +50 -4
  2. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  3. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  4. package/dist/anchor.cjs.js +11 -11
  5. package/dist/anchor.esm.js +130 -107
  6. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  7. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  8. package/dist/background-color.cjs.js +3 -3
  9. package/dist/background-color.esm.js +116 -119
  10. package/dist/code.cjs.js +82 -102
  11. package/dist/code.esm.js +1172 -662
  12. package/dist/comments.cjs.js +10 -10
  13. package/dist/comments.esm.js +195 -177
  14. package/dist/document-manager.cjs.js +1 -1
  15. package/dist/document-manager.esm.js +1 -1
  16. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  17. package/dist/documentManager-Jf0RbSks.js +17 -0
  18. package/dist/embed-iframe.cjs.js +2 -2
  19. package/dist/embed-iframe.esm.js +8 -5
  20. package/dist/emojis.cjs.js +64 -39
  21. package/dist/emojis.esm.js +133 -104
  22. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  23. package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
  24. package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
  25. package/dist/index-CvJk4DKa.js +221 -0
  26. package/dist/index-D3CycEFU.mjs +16543 -0
  27. package/dist/index-tqLTHcO6.js +1 -0
  28. package/dist/index.cjs.js +1 -1
  29. package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
  30. package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
  31. package/dist/index.esm.js +87 -79
  32. package/dist/jspdf.es.min-BoS80556.js +77 -0
  33. package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
  34. package/dist/link.cjs.js +6 -6
  35. package/dist/link.esm.js +41 -39
  36. package/dist/math.cjs.js +21 -21
  37. package/dist/math.esm.js +151 -112
  38. package/dist/media-manager.cjs.js +15 -15
  39. package/dist/media-manager.esm.js +227 -206
  40. package/dist/merge-tag.cjs.js +44 -12
  41. package/dist/merge-tag.esm.js +368 -241
  42. package/dist/page-break.cjs.js +2 -2
  43. package/dist/page-break.esm.js +77 -69
  44. package/dist/special-characters.cjs.js +83 -45
  45. package/dist/special-characters.esm.js +149 -100
  46. package/dist/spell-check.cjs.js +9 -9
  47. package/dist/spell-check.esm.js +235 -216
  48. package/dist/template.cjs.js +14 -14
  49. package/dist/template.esm.js +157 -131
  50. package/dist/text-color.cjs.js +9 -9
  51. package/dist/text-color.esm.js +131 -115
  52. package/index.d.ts +51 -1
  53. package/package.json +3 -3
  54. package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
  55. package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
  56. package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
  57. package/dist/documentManager-_tQQfQi9.js +0 -317
  58. package/dist/index-D3pJyAsj.js +0 -1
@@ -1,4 +1,4 @@
1
- const H = /* @__PURE__ */ new Set([
1
+ const B = /* @__PURE__ */ new Set([
2
2
  "the",
3
3
  "a",
4
4
  "an",
@@ -109,32 +109,43 @@ const H = /* @__PURE__ */ new Set([
109
109
  "demo",
110
110
  "lorem",
111
111
  "ipsum"
112
- ]), E = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set();
113
- let u = !1, d = null, f = null, a = null, s = null, g = null, v = !1, h = null, O = !1, b = 0;
114
- const $ = {
112
+ ]), C = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Set();
113
+ let u = !1, d = null, f = null, a = null, s = null, x = null, y = !1, h = null, _ = !1, b = 0, g = null;
114
+ const j = {
115
115
  characterData: !0,
116
116
  childList: !0,
117
117
  subtree: !0
118
- }, D = "rte-spellcheck-styles", F = "__editoraCommandEditorRoot";
119
- function q() {
118
+ }, H = "rte-spellcheck-styles", R = "__editoraCommandEditorRoot";
119
+ function K(e) {
120
+ const t = e?.contentElement || e?.editorElement || null;
121
+ if (!(t instanceof HTMLElement)) return;
122
+ const r = t.getAttribute("contenteditable") === "true" ? t : t.querySelector?.('[contenteditable="true"]');
123
+ if (r instanceof HTMLElement) {
124
+ s = r, h = r;
125
+ return;
126
+ }
127
+ const l = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null), o = A(l);
128
+ o && (s = o, h = o);
129
+ }
130
+ function P() {
120
131
  if (typeof window > "u") return null;
121
- const e = window[F];
132
+ const e = window[R];
122
133
  if (!(e instanceof HTMLElement)) return null;
123
- window[F] = null;
124
- const r = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
125
- if (r) {
126
- const l = B(r);
134
+ window[R] = null;
135
+ 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);
136
+ if (t) {
137
+ const l = A(t);
127
138
  if (l) return l;
128
- if (r.getAttribute("contenteditable") === "true") return r;
139
+ if (t.getAttribute("contenteditable") === "true") return t;
129
140
  }
130
141
  if (e.getAttribute("contenteditable") === "true")
131
142
  return e;
132
- const t = e.closest('[contenteditable="true"]');
133
- return t instanceof HTMLElement ? t : null;
143
+ const r = e.closest('[contenteditable="true"]');
144
+ return r instanceof HTMLElement ? r : null;
134
145
  }
135
146
  function T() {
136
- let e = document.getElementById(D);
137
- e || (e = document.createElement("style"), e.id = D, document.head.appendChild(e)), e.textContent = `
147
+ let e = document.getElementById(H);
148
+ e || (e = document.createElement("style"), e.id = H, document.head.appendChild(e)), e.textContent = `
138
149
  .rte-spell-check-panel {
139
150
  position: absolute;
140
151
  top: 12px;
@@ -607,127 +618,127 @@ function T() {
607
618
  function k() {
608
619
  if (s && document.contains(s))
609
620
  return s;
610
- const e = j();
621
+ const e = V();
611
622
  return e && (s = e), e;
612
623
  }
613
- function z(e) {
624
+ function W(e) {
614
625
  if (!e) return;
615
- const t = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]');
616
- t && (s = t);
626
+ const r = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]');
627
+ r && (s = r);
617
628
  }
618
- function B(e) {
629
+ function A(e) {
619
630
  if (!e) return null;
620
- const r = e.querySelector('[contenteditable="true"]');
621
- return r instanceof HTMLElement ? r : null;
631
+ const t = e.querySelector('[contenteditable="true"]');
632
+ return t instanceof HTMLElement ? t : null;
622
633
  }
623
- function X() {
624
- if (O) return;
625
- const e = (r) => {
626
- const t = r.target;
627
- if (!t) return;
628
- const l = t.closest(
634
+ function Q() {
635
+ if (_) return;
636
+ const e = (t) => {
637
+ const r = t.target;
638
+ if (!r) return;
639
+ const l = r.closest(
629
640
  '.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]'
630
641
  );
631
642
  if (!l) return;
632
- const o = l.closest("[data-editora-editor]"), c = B(o);
633
- c && (h = c, s = c);
643
+ const o = l.closest("[data-editora-editor]"), n = A(o);
644
+ n && (h = n, s = n);
634
645
  };
635
- document.addEventListener("pointerdown", e, !0), O = !0;
646
+ document.addEventListener("pointerdown", e, !0), _ = !0;
636
647
  }
637
- function Z() {
638
- const e = q();
648
+ function ee() {
649
+ const e = P();
639
650
  if (e && document.contains(e))
640
651
  return s = e, h = null, e;
641
652
  if (h && document.contains(h)) {
642
- const r = h;
643
- return h = null, s = r, r;
653
+ const t = h;
654
+ return h = null, s = t, t;
644
655
  }
645
- return j();
656
+ return V();
646
657
  }
647
- function K() {
658
+ function te() {
648
659
  b += 1, b === 1 && d && d.disconnect();
649
660
  }
650
- function Q() {
661
+ function re() {
651
662
  if (b === 0 || (b -= 1, b > 0) || !d) return;
652
663
  const e = k();
653
- e && d.observe(e, $);
664
+ e && d.observe(e, j);
654
665
  }
655
- function L(e) {
656
- K();
666
+ function N(e) {
667
+ te();
657
668
  try {
658
669
  return e();
659
670
  } finally {
660
- Q();
671
+ re();
661
672
  }
662
673
  }
663
- const ee = () => {
674
+ const oe = () => {
664
675
  try {
665
676
  const e = localStorage.getItem("rte-custom-dictionary");
666
- e && JSON.parse(e).forEach((t) => E.add(t.toLowerCase()));
677
+ e && JSON.parse(e).forEach((r) => C.add(r.toLowerCase()));
667
678
  } catch (e) {
668
679
  console.warn("Failed to load custom dictionary:", e);
669
680
  }
670
- }, te = () => {
681
+ }, le = () => {
671
682
  try {
672
- const e = Array.from(E);
683
+ const e = Array.from(C);
673
684
  localStorage.setItem("rte-custom-dictionary", JSON.stringify(e));
674
685
  } catch (e) {
675
686
  console.warn("Failed to save custom dictionary:", e);
676
687
  }
677
688
  };
678
- function re(e, r) {
679
- const t = [];
680
- for (let l = 0; l <= r.length; l++) t[l] = [l];
681
- for (let l = 0; l <= e.length; l++) t[0][l] = l;
682
- for (let l = 1; l <= r.length; l++)
689
+ function ne(e, t) {
690
+ const r = [];
691
+ for (let l = 0; l <= t.length; l++) r[l] = [l];
692
+ for (let l = 0; l <= e.length; l++) r[0][l] = l;
693
+ for (let l = 1; l <= t.length; l++)
683
694
  for (let o = 1; o <= e.length; o++)
684
- r.charAt(l - 1) === e.charAt(o - 1) ? t[l][o] = t[l - 1][o - 1] : t[l][o] = Math.min(
685
- t[l - 1][o - 1] + 1,
695
+ t.charAt(l - 1) === e.charAt(o - 1) ? r[l][o] = r[l - 1][o - 1] : r[l][o] = Math.min(
696
+ r[l - 1][o - 1] + 1,
686
697
  // substitution
687
- t[l][o - 1] + 1,
698
+ r[l][o - 1] + 1,
688
699
  // insertion
689
- t[l - 1][o] + 1
700
+ r[l - 1][o] + 1
690
701
  // deletion
691
702
  );
692
- return t[r.length][e.length];
703
+ return r[t.length][e.length];
693
704
  }
694
- function oe(e) {
695
- const r = e.toLowerCase();
696
- return H.has(r) || E.has(r) || C.has(r);
705
+ function ce(e) {
706
+ const t = e.toLowerCase();
707
+ return B.has(t) || C.has(t) || S.has(t);
697
708
  }
698
- function le(e, r = 5) {
699
- const t = e.toLowerCase(), o = Array.from(H).map((c) => ({ word: c, distance: re(t, c) }));
700
- return o.sort((c, n) => c.distance - n.distance), o.filter((c) => c.distance <= 3).slice(0, r).map((c) => c.word);
709
+ function ae(e, t = 5) {
710
+ const r = e.toLowerCase(), o = Array.from(B).map((n) => ({ word: n, distance: ne(r, n) }));
711
+ return o.sort((n, c) => n.distance - c.distance), o.filter((n) => n.distance <= 3).slice(0, t).map((n) => n.word);
701
712
  }
702
- function ce(e) {
713
+ function se(e) {
703
714
  if (e.nodeType !== Node.ELEMENT_NODE) return !1;
704
- const r = e;
705
- return !!(r.closest('code, pre, [contenteditable="false"], .rte-widget, .rte-template, .rte-comment, .rte-merge-tag') || r.hasAttribute("data-comment-id") || r.hasAttribute("data-template") || r.hasAttribute("data-merge-tag"));
715
+ const t = e;
716
+ 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"));
706
717
  }
707
- function ne(e) {
708
- const r = [], t = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
718
+ function ie(e) {
719
+ const t = [], r = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
709
720
  let l;
710
- for (; (l = t.exec(e.data)) !== null; ) {
711
- const o = l[0], c = l.index, n = c + o.length;
712
- /https?:\/\//.test(o) || /@/.test(o) || /\{\{.*\}\}/.test(o) || /^\d+$/.test(o) || oe(o) || /[a-z][A-Z]/.test(o) || /-/.test(o) || o[0] === o[0].toUpperCase() && o.length > 1 || r.push({
713
- id: `${o}-${c}`,
721
+ for (; (l = r.exec(e.data)) !== null; ) {
722
+ const o = l[0], n = l.index, c = n + o.length;
723
+ /https?:\/\//.test(o) || /@/.test(o) || /\{\{.*\}\}/.test(o) || /^\d+$/.test(o) || ce(o) || /[a-z][A-Z]/.test(o) || /-/.test(o) || o[0] === o[0].toUpperCase() && o.length > 1 || t.push({
724
+ id: `${o}-${n}`,
714
725
  node: e,
715
- startOffset: c,
716
- endOffset: n,
726
+ startOffset: n,
727
+ endOffset: c,
717
728
  word: o,
718
- suggestions: le(o),
729
+ suggestions: ae(o),
719
730
  ignored: !1
720
731
  });
721
732
  }
722
- return r;
733
+ return t;
723
734
  }
724
- const j = () => {
725
- const e = q();
735
+ const V = () => {
736
+ const e = P();
726
737
  if (e && document.contains(e))
727
738
  return s = e, e;
728
- const r = window.getSelection();
729
- if (r && r.rangeCount > 0) {
730
- let l = r.getRangeAt(0).startContainer;
739
+ const t = window.getSelection();
740
+ if (t && t.rangeCount > 0) {
741
+ let l = t.getRangeAt(0).startContainer;
731
742
  for (; l && l !== document.body; ) {
732
743
  if (l.nodeType === Node.ELEMENT_NODE) {
733
744
  const o = l;
@@ -737,165 +748,165 @@ const j = () => {
737
748
  l = l.parentNode;
738
749
  }
739
750
  }
740
- const t = document.activeElement;
741
- if (t) {
742
- if (t.getAttribute("contenteditable") === "true")
743
- return t;
744
- const l = t.closest('[contenteditable="true"]');
751
+ const r = document.activeElement;
752
+ if (r) {
753
+ if (r.getAttribute("contenteditable") === "true")
754
+ return r;
755
+ const l = r.closest('[contenteditable="true"]');
745
756
  if (l) return l;
746
- const o = t.closest("[data-editora-editor]");
757
+ const o = r.closest("[data-editora-editor]");
747
758
  if (o) {
748
- const c = o.querySelector('[contenteditable="true"]');
749
- if (c) return c;
759
+ const n = o.querySelector('[contenteditable="true"]');
760
+ if (n) return n;
750
761
  }
751
762
  }
752
763
  return document.querySelector('[contenteditable="true"]');
753
764
  };
754
- function N() {
765
+ function M() {
755
766
  const e = k();
756
767
  if (!e) return [];
757
- const r = [], t = document.createTreeWalker(
768
+ const t = [], r = document.createTreeWalker(
758
769
  e,
759
770
  NodeFilter.SHOW_TEXT,
760
771
  {
761
- acceptNode: (o) => !o.textContent?.trim() || o.parentNode && ce(o.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
772
+ acceptNode: (o) => !o.textContent?.trim() || o.parentNode && se(o.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
762
773
  }
763
774
  );
764
- let l = t.nextNode();
775
+ let l = r.nextNode();
765
776
  for (; l; )
766
- r.push(...ne(l)), l = t.nextNode();
767
- return r;
777
+ t.push(...ie(l)), l = r.nextNode();
778
+ return t;
768
779
  }
769
780
  function m(e) {
770
- const r = k();
771
- r && (e || (e = N()), L(() => {
772
- r.querySelectorAll(".rte-misspelled").forEach((t) => {
773
- const l = t.parentNode;
781
+ const t = k();
782
+ t && (e || (e = M()), N(() => {
783
+ t.querySelectorAll(".rte-misspelled").forEach((r) => {
784
+ const l = r.parentNode;
774
785
  if (l) {
775
- for (; t.firstChild; )
776
- l.insertBefore(t.firstChild, t);
777
- l.removeChild(t);
786
+ for (; r.firstChild; )
787
+ l.insertBefore(r.firstChild, r);
788
+ l.removeChild(r);
778
789
  }
779
- }), e.forEach((t) => {
780
- if (C.has(t.word.toLowerCase())) return;
781
- const l = t.node.data.length;
782
- if (!(t.startOffset < 0 || t.endOffset > l || t.startOffset >= t.endOffset))
790
+ }), e.forEach((r) => {
791
+ if (S.has(r.word.toLowerCase())) return;
792
+ const l = r.node.data.length;
793
+ if (!(r.startOffset < 0 || r.endOffset > l || r.startOffset >= r.endOffset))
783
794
  try {
784
795
  const o = document.createRange();
785
- o.setStart(t.node, t.startOffset), o.setEnd(t.node, t.endOffset);
786
- const c = document.createElement("span");
787
- c.className = "rte-misspelled", c.setAttribute("data-word", t.word), c.setAttribute("data-suggestions", t.suggestions.join(",")), c.setAttribute("title", `Suggestions: ${t.suggestions.join(", ")}`), c.style.borderBottom = "2px wavy red", c.style.cursor = "pointer", o.surroundContents(c);
796
+ o.setStart(r.node, r.startOffset), o.setEnd(r.node, r.endOffset);
797
+ const n = document.createElement("span");
798
+ 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", o.surroundContents(n);
788
799
  } catch {
789
800
  }
790
801
  });
791
- }), y(e));
802
+ }), E(e));
792
803
  }
793
- function S() {
804
+ function L() {
794
805
  const e = k();
795
- e && L(() => {
796
- e.querySelectorAll(".rte-misspelled").forEach((r) => {
797
- const t = r.parentNode;
798
- if (t) {
799
- for (; r.firstChild; )
800
- t.insertBefore(r.firstChild, r);
801
- t.removeChild(r);
806
+ e && N(() => {
807
+ e.querySelectorAll(".rte-misspelled").forEach((t) => {
808
+ const r = t.parentNode;
809
+ if (r) {
810
+ for (; t.firstChild; )
811
+ r.insertBefore(t.firstChild, t);
812
+ r.removeChild(t);
802
813
  }
803
814
  });
804
815
  });
805
816
  }
806
- function ae(e, r) {
807
- L(() => {
808
- const t = document.createRange();
809
- t.setStart(e.node, e.startOffset), t.setEnd(e.node, e.endOffset);
810
- const l = document.createTextNode(r);
811
- t.deleteContents(), t.insertNode(l);
817
+ function de(e, t) {
818
+ N(() => {
819
+ const r = document.createRange();
820
+ r.setStart(e.node, e.startOffset), r.setEnd(e.node, e.endOffset);
821
+ const l = document.createTextNode(t);
822
+ r.deleteContents(), r.insertNode(l);
812
823
  });
813
824
  }
814
- function P(e) {
815
- C.add(e.toLowerCase()), S(), m();
825
+ function G(e) {
826
+ S.add(e.toLowerCase()), L(), m();
816
827
  }
817
- function W(e) {
818
- E.add(e.toLowerCase()), te(), S(), m();
828
+ function J(e) {
829
+ C.add(e.toLowerCase()), le(), L(), m();
819
830
  }
820
- function se(e) {
821
- const r = k();
822
- if (!r) return { total: 0, misspelled: 0, accuracy: 100 };
823
- e || (e = N());
824
- const t = e.filter((n) => !C.has(n.word.toLowerCase())).length, c = ((r.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
831
+ function pe(e) {
832
+ const t = k();
833
+ if (!t) return { total: 0, misspelled: 0, accuracy: 100 };
834
+ e || (e = M());
835
+ const r = e.filter((c) => !S.has(c.word.toLowerCase())).length, n = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
825
836
  return {
826
- total: c,
827
- misspelled: t,
828
- accuracy: c > 0 ? (c - t) / c * 100 : 100
837
+ total: n,
838
+ misspelled: r,
839
+ accuracy: n > 0 ? (n - r) / n * 100 : 100
829
840
  };
830
841
  }
831
- function ie(e, r) {
832
- const t = document.createTextNode(r);
833
- e.replaceWith(t);
842
+ function he(e, t) {
843
+ const r = document.createTextNode(t);
844
+ e.replaceWith(r);
834
845
  }
835
- function de(e) {
846
+ function ue(e) {
836
847
  e.classList.remove("rte-misspelled"), e.removeAttribute("data-word"), e.removeAttribute("data-suggestions"), e.removeAttribute("title"), e.style.borderBottom = "", e.style.cursor = "";
837
848
  }
838
- function pe(e, r, t, l, o) {
839
- z(o), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
840
- const c = document.createElement("div");
841
- if (c.className = "rte-spellcheck-menu", l.slice(0, 5).forEach((p) => {
842
- const w = document.createElement("div");
843
- w.className = "rte-spellcheck-menu-item", w.textContent = p, w.onclick = () => {
844
- ie(o, p), window.setTimeout(() => {
845
- u && (m(), y());
846
- }, 0), c.remove();
847
- }, c.appendChild(w);
849
+ function me(e, t, r, l, o) {
850
+ W(o), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
851
+ const n = document.createElement("div");
852
+ if (n.className = "rte-spellcheck-menu", l.slice(0, 5).forEach((p) => {
853
+ const v = document.createElement("div");
854
+ v.className = "rte-spellcheck-menu-item", v.textContent = p, v.onclick = () => {
855
+ he(o, p), window.setTimeout(() => {
856
+ u && (m(), E());
857
+ }, 0), n.remove();
858
+ }, n.appendChild(v);
848
859
  }), l.length > 0) {
849
860
  const p = document.createElement("div");
850
- p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", c.appendChild(p);
861
+ p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", n.appendChild(p);
851
862
  }
852
- const n = document.createElement("div");
853
- n.className = "rte-spellcheck-menu-item meta", n.textContent = "Ignore Once", n.onclick = () => {
854
- de(o), c.remove();
855
- }, c.appendChild(n);
863
+ const c = document.createElement("div");
864
+ c.className = "rte-spellcheck-menu-item meta", c.textContent = "Ignore Once", c.onclick = () => {
865
+ ue(o), n.remove();
866
+ }, n.appendChild(c);
856
867
  const i = document.createElement("div");
857
868
  i.className = "rte-spellcheck-menu-item meta", i.textContent = "Ignore All", i.onclick = () => {
858
- P(t), c.remove();
859
- }, c.appendChild(i);
860
- const x = document.createElement("div");
861
- x.className = "rte-spellcheck-menu-item positive", x.textContent = "Add to Dictionary", x.onclick = () => {
862
- W(t), c.remove();
863
- }, c.appendChild(x), document.body.appendChild(c);
864
- const A = c.getBoundingClientRect(), U = window.innerWidth - A.width - 8, Y = window.innerHeight - A.height - 8;
865
- c.style.left = `${Math.max(8, Math.min(e, U))}px`, c.style.top = `${Math.max(8, Math.min(r, Y))}px`;
866
- const M = (p) => {
867
- c.contains(p.target) || (c.remove(), document.removeEventListener("mousedown", M));
869
+ G(r), n.remove();
870
+ }, n.appendChild(i);
871
+ const w = document.createElement("div");
872
+ w.className = "rte-spellcheck-menu-item positive", w.textContent = "Add to Dictionary", w.onclick = () => {
873
+ J(r), n.remove();
874
+ }, n.appendChild(w), document.body.appendChild(n);
875
+ const D = n.getBoundingClientRect(), X = window.innerWidth - D.width - 8, Z = window.innerHeight - D.height - 8;
876
+ n.style.left = `${Math.max(8, Math.min(e, X))}px`, n.style.top = `${Math.max(8, Math.min(t, Z))}px`;
877
+ const F = (p) => {
878
+ n.contains(p.target) || (n.remove(), document.removeEventListener("mousedown", F));
868
879
  };
869
- setTimeout(() => document.addEventListener("mousedown", M), 0);
880
+ setTimeout(() => document.addEventListener("mousedown", F), 0);
870
881
  }
871
- function _() {
872
- v || (g = (e) => {
873
- const r = e.target;
874
- if (r && r.classList.contains("rte-misspelled")) {
875
- e.preventDefault(), z(r);
876
- const t = r.getAttribute("data-word"), l = (r.getAttribute("data-suggestions") || "").split(",").filter((o) => o);
877
- pe(e.clientX, e.clientY, t, l, r);
878
- }
879
- }, document.addEventListener("contextmenu", g), v = !0);
882
+ function I() {
883
+ y || (x = (e) => {
884
+ const t = e.target;
885
+ if (t && t.classList.contains("rte-misspelled")) {
886
+ e.preventDefault(), W(t);
887
+ const r = t.getAttribute("data-word"), l = (t.getAttribute("data-suggestions") || "").split(",").filter((o) => o);
888
+ me(e.clientX, e.clientY, r, l, t);
889
+ }
890
+ }, document.addEventListener("contextmenu", x), y = !0);
880
891
  }
881
- function he() {
882
- !v || !g || (document.removeEventListener("contextmenu", g), g = null, v = !1);
892
+ function ke() {
893
+ !y || !x || (document.removeEventListener("contextmenu", x), x = null, y = !1);
883
894
  }
884
- function ue(e) {
895
+ function fe(e) {
885
896
  return e.closest("[data-editora-editor]") || e.parentElement || e;
886
897
  }
887
- function I() {
898
+ function q() {
888
899
  const e = k();
889
900
  if (!e)
890
901
  throw new Error("Spell check panel requested without active editor");
891
- const r = ue(e);
902
+ const t = fe(e);
892
903
  T();
893
- const t = document.createElement("div");
894
- return t.className = "rte-spell-check-panel", window.getComputedStyle(r).position === "static" && (r.style.position = "relative"), r.appendChild(t), t;
904
+ const r = document.createElement("div");
905
+ return r.className = "rte-spell-check-panel", window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(r), r;
895
906
  }
896
- function y(e) {
907
+ function E(e) {
897
908
  if (!a) return;
898
- const r = e || N(), t = se(r);
909
+ const t = e || M(), r = pe(t);
899
910
  a.innerHTML = `
900
911
  <div class="rte-spellcheck-header">
901
912
  <div>
@@ -908,28 +919,28 @@ function y(e) {
908
919
  <div class="rte-spellcheck-stats">
909
920
  <div class="rte-spellcheck-stat">
910
921
  <span class="rte-spellcheck-stat-label">Total</span>
911
- <strong class="rte-spellcheck-stat-value">${t.total}</strong>
922
+ <strong class="rte-spellcheck-stat-value">${r.total}</strong>
912
923
  </div>
913
924
  <div class="rte-spellcheck-stat">
914
925
  <span class="rte-spellcheck-stat-label">Misspelled</span>
915
- <strong class="rte-spellcheck-stat-value">${t.misspelled}</strong>
926
+ <strong class="rte-spellcheck-stat-value">${r.misspelled}</strong>
916
927
  </div>
917
928
  <div class="rte-spellcheck-stat">
918
929
  <span class="rte-spellcheck-stat-label">Accuracy</span>
919
- <strong class="rte-spellcheck-stat-value">${t.accuracy.toFixed(1)}%</strong>
930
+ <strong class="rte-spellcheck-stat-value">${r.accuracy.toFixed(1)}%</strong>
920
931
  </div>
921
932
  </div>
922
933
 
923
934
  <div class="rte-spellcheck-list">
924
- ${r.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : r.map((o, c) => `
925
- <div class="rte-spellcheck-item" data-word="${o.word}" data-index="${c}">
935
+ ${t.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : t.map((o, n) => `
936
+ <div class="rte-spellcheck-item" data-word="${o.word}" data-index="${n}">
926
937
  <button class="rte-spellcheck-word-header" type="button">
927
938
  <span class="rte-spellcheck-word">${o.word}</span>
928
939
  <span class="rte-spellcheck-caret">▶</span>
929
940
  </button>
930
941
  <div class="rte-spellcheck-suggestions">
931
942
  ${o.suggestions.length > 0 ? `<div class="rte-spellcheck-actions">
932
- ${o.suggestions.map((n) => `<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${n}" type="button">${n}</button>`).join("")}
943
+ ${o.suggestions.map((c) => `<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${c}" type="button">${c}</button>`).join("")}
933
944
  </div>` : '<div class="rte-spellcheck-subtitle">No suggestions available</div>'}
934
945
  <div class="rte-spellcheck-actions">
935
946
  <button class="rte-spellcheck-btn ignore-btn" type="button">Ignore</button>
@@ -940,58 +951,66 @@ function y(e) {
940
951
  `).join("")}
941
952
  </div>
942
953
  `, a.querySelector(".rte-spellcheck-close")?.addEventListener("click", (o) => {
943
- o.preventDefault(), o.stopPropagation(), J();
954
+ o.preventDefault(), o.stopPropagation(), O();
944
955
  }), a.querySelectorAll(".rte-spellcheck-word-header").forEach((o) => {
945
956
  o.addEventListener("click", () => {
946
- const n = o.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
947
- n && i && (n.classList.contains("show") ? (n.classList.remove("show"), i.textContent = "▶") : (n.classList.add("show"), i.textContent = "▼"));
957
+ const c = o.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
958
+ c && i && (c.classList.contains("show") ? (c.classList.remove("show"), i.textContent = "▶") : (c.classList.add("show"), i.textContent = "▼"));
948
959
  });
949
960
  }), a.querySelectorAll(".suggestion-btn").forEach((o) => {
950
961
  o.addEventListener("click", () => {
951
- const c = o.getAttribute("data-suggestion"), n = o.closest(".rte-spellcheck-item");
952
- n?.getAttribute("data-word");
953
- const i = parseInt(n?.getAttribute("data-index") || "0");
954
- r[i] && (ae(r[i], c), m());
962
+ const n = o.getAttribute("data-suggestion"), c = o.closest(".rte-spellcheck-item");
963
+ c?.getAttribute("data-word");
964
+ const i = parseInt(c?.getAttribute("data-index") || "0");
965
+ t[i] && (de(t[i], n), m());
955
966
  });
956
967
  }), a.querySelectorAll(".ignore-btn").forEach((o) => {
957
968
  o.addEventListener("click", () => {
958
- const n = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
959
- P(n);
969
+ const c = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
970
+ G(c);
960
971
  });
961
972
  }), a.querySelectorAll(".add-btn").forEach((o) => {
962
973
  o.addEventListener("click", () => {
963
- const n = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
964
- W(n);
974
+ const c = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
975
+ J(c);
965
976
  });
966
977
  });
967
978
  }
968
- function R() {
979
+ function $() {
969
980
  const e = k();
970
- e && (d && d.disconnect(), d = new MutationObserver((r) => {
971
- b > 0 || r.some((t) => t.type === "characterData" || t.type === "childList") && (f && clearTimeout(f), f = window.setTimeout(() => {
981
+ e && (d && d.disconnect(), d = new MutationObserver((t) => {
982
+ b > 0 || t.some((r) => r.type === "characterData" || r.type === "childList") && (f && clearTimeout(f), f = window.setTimeout(() => {
972
983
  u && m();
973
984
  }, 350));
974
985
  }), d.observe(e, {
975
- ...$
986
+ ...j
976
987
  }));
977
988
  }
978
- function V() {
989
+ function U() {
979
990
  d && (d.disconnect(), d = null), f && (clearTimeout(f), f = null);
980
991
  }
981
- function G() {
992
+ function Y() {
982
993
  document.querySelectorAll(".rte-spellcheck-menu").forEach((e) => e.remove());
983
994
  }
984
- function J() {
985
- return u && (S(), V(), he(), G(), a && (a.remove(), a = null), s = null, h = null, u = !1), !1;
995
+ function z() {
996
+ g || (g = (e) => {
997
+ e.key !== "Escape" || !u || (e.preventDefault(), e.stopPropagation(), O());
998
+ }, document.addEventListener("keydown", g, !0));
999
+ }
1000
+ function be() {
1001
+ g && (document.removeEventListener("keydown", g, !0), g = null);
1002
+ }
1003
+ function O() {
1004
+ return u && (L(), U(), ke(), Y(), a && (a.remove(), a = null), s = null, h = null, u = !1, be()), !1;
986
1005
  }
987
- function me() {
988
- const e = Z();
989
- return e ? u && s && s !== e ? (S(), V(), G(), a && (a.remove(), a = null), s = e, T(), _(), m(), R(), a = I(), y(), !0) : u ? J() : (s = e, u = !0, T(), _(), m(), R(), a && (a.remove(), a = null), a = I(), y(), !0) : !1;
1006
+ function ge() {
1007
+ const e = ee();
1008
+ return e ? u && s && s !== e ? (L(), U(), Y(), a && (a.remove(), a = null), s = e, T(), I(), z(), m(), $(), a = q(), E(), !0) : u ? O() : (s = e, u = !0, T(), I(), z(), m(), $(), a && (a.remove(), a = null), a = q(), E(), !0) : !1;
990
1009
  }
991
- const ke = () => ({
1010
+ const xe = () => ({
992
1011
  name: "spellCheck",
993
1012
  init: () => {
994
- ee(), X();
1013
+ oe(), Q();
995
1014
  },
996
1015
  toolbar: [
997
1016
  {
@@ -1002,12 +1021,12 @@ const ke = () => ({
1002
1021
  }
1003
1022
  ],
1004
1023
  commands: {
1005
- toggleSpellCheck: () => (me(), !0)
1024
+ toggleSpellCheck: (e, t) => (K(t), ge(), !0)
1006
1025
  },
1007
1026
  keymap: {
1008
1027
  F7: "toggleSpellCheck"
1009
1028
  }
1010
1029
  });
1011
1030
  export {
1012
- ke as SpellCheckPlugin
1031
+ xe as SpellCheckPlugin
1013
1032
  };