@editora/plugins 1.0.10 → 1.0.12

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 (139) hide show
  1. package/README.md +1 -1
  2. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  3. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +80 -98
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +115 -128
  8. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  9. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  10. package/dist/approval-workflow.cjs.js +40 -40
  11. package/dist/approval-workflow.esm.js +208 -249
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +55 -68
  14. package/dist/blockquote.esm.js +1 -2
  15. package/dist/blocks-library.cjs.js +45 -45
  16. package/dist/blocks-library.esm.js +178 -245
  17. package/dist/capitalization.esm.js +1 -2
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +58 -82
  20. package/dist/citations.cjs.js +37 -37
  21. package/dist/citations.esm.js +439 -512
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +27 -33
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +82 -93
  26. package/dist/code.cjs.js +119 -42
  27. package/dist/code.esm.js +2560 -760
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +116 -158
  30. package/dist/conditional-content.cjs.js +90 -90
  31. package/dist/conditional-content.esm.js +371 -432
  32. package/dist/content-rules.cjs.js +7 -7
  33. package/dist/content-rules.esm.js +105 -159
  34. package/dist/data-binding.cjs.js +46 -46
  35. package/dist/data-binding.esm.js +328 -368
  36. package/dist/direction.esm.js +9 -18
  37. package/dist/doc-schema.cjs.js +29 -29
  38. package/dist/doc-schema.esm.js +240 -308
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +4 -5
  41. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  42. package/dist/documentManager-Jf0RbSks.js +17 -0
  43. package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +73 -81
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +65 -77
  48. package/dist/enterprise.cjs.js +1 -1
  49. package/dist/enterprise.esm.js +54 -56
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +39 -47
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +37 -53
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +76 -117
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +70 -92
  58. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  59. package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +12 -24
  62. package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
  63. package/dist/index-CvJk4DKa.js +221 -0
  64. package/dist/index-D3CycEFU.mjs +16543 -0
  65. package/dist/index-tqLTHcO6.js +1 -0
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-CE_A4QSm.js +5 -0
  68. package/dist/index.es-DQ78mYYo.mjs +6665 -0
  69. package/dist/index.esm.js +125 -128
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +8 -9
  72. package/dist/jspdf.es.min-BoS80556.js +77 -0
  73. package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +11 -24
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +24 -30
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +20 -25
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +59 -61
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +139 -146
  84. package/dist/media-manager.cjs.js +31 -31
  85. package/dist/media-manager.esm.js +285 -300
  86. package/dist/mentions.cjs.js +9 -9
  87. package/dist/mentions.esm.js +238 -286
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +177 -216
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +33 -49
  92. package/dist/pii-redaction.cjs.js +19 -19
  93. package/dist/pii-redaction.esm.js +393 -463
  94. package/dist/plugins.css +1 -0
  95. package/dist/preview.esm.js +5 -10
  96. package/dist/print.cjs.js +4 -4
  97. package/dist/print.esm.js +17 -20
  98. package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
  99. package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
  100. package/dist/slash-commands.cjs.js +2 -2
  101. package/dist/slash-commands.esm.js +39 -75
  102. package/dist/smart-paste.cjs.js +27 -27
  103. package/dist/smart-paste.esm.js +280 -336
  104. package/dist/special-characters.cjs.js +7 -7
  105. package/dist/special-characters.esm.js +61 -69
  106. package/dist/spell-check.cjs.js +5 -5
  107. package/dist/spell-check.esm.js +97 -123
  108. package/dist/strikethrough.cjs.js +1 -1
  109. package/dist/strikethrough.esm.js +14 -19
  110. package/dist/table.cjs.js +4 -4
  111. package/dist/table.esm.js +191 -225
  112. package/dist/template.cjs.js +21 -20
  113. package/dist/template.esm.js +715 -196
  114. package/dist/text-alignment.cjs.js +1 -1
  115. package/dist/text-alignment.esm.js +21 -27
  116. package/dist/text-color.cjs.js +3 -3
  117. package/dist/text-color.esm.js +70 -87
  118. package/dist/track-changes.cjs.js +2 -2
  119. package/dist/track-changes.esm.js +100 -162
  120. package/dist/translation-workflow.cjs.js +74 -74
  121. package/dist/translation-workflow.esm.js +602 -678
  122. package/dist/version-diff.cjs.js +14 -14
  123. package/dist/version-diff.esm.js +128 -157
  124. package/package.json +1 -1
  125. package/dist/_commonjsHelpers-6763f629.js +0 -1
  126. package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
  127. package/dist/anchoredPopover-33f1358d.mjs +0 -109
  128. package/dist/anchoredPopover-8151d535.js +0 -1
  129. package/dist/documentManager-25b6203c.mjs +0 -9122
  130. package/dist/documentManager-b69e7054.js +0 -17
  131. package/dist/html2canvas.esm-09133e29.js +0 -22
  132. package/dist/index-656d224b.js +0 -231
  133. package/dist/index-6a8c48bb.js +0 -1
  134. package/dist/index-d027b7e2.mjs +0 -16859
  135. package/dist/index.es-730f2d98.mjs +0 -5775
  136. package/dist/index.es-dd40173b.js +0 -18
  137. package/dist/jspdf.es.min-90db2c97.js +0 -243
  138. package/dist/style.css +0 -1
  139. /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
@@ -1,4 +1,4 @@
1
- const j = /* @__PURE__ */ new Set([
1
+ const B = /* @__PURE__ */ new Set([
2
2
  "the",
3
3
  "a",
4
4
  "an",
@@ -111,38 +111,32 @@ const j = /* @__PURE__ */ new Set([
111
111
  "ipsum"
112
112
  ]), C = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Set();
113
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 B = {
114
+ const j = {
115
115
  characterData: !0,
116
116
  childList: !0,
117
117
  subtree: !0
118
118
  }, H = "rte-spellcheck-styles", R = "__editoraCommandEditorRoot";
119
119
  function K(e) {
120
- var l;
121
- const t = (e == null ? void 0 : e.contentElement) || (e == null ? void 0 : e.editorElement) || null;
122
- if (!(t instanceof HTMLElement))
123
- return;
124
- const r = t.getAttribute("contenteditable") === "true" ? t : (l = t.querySelector) == null ? void 0 : l.call(t, '[contenteditable="true"]');
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"]');
125
123
  if (r instanceof HTMLElement) {
126
124
  s = r, h = r;
127
125
  return;
128
126
  }
129
- const n = 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(n);
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);
130
128
  o && (s = o, h = o);
131
129
  }
132
130
  function P() {
133
- if (typeof window > "u")
134
- return null;
131
+ if (typeof window > "u") return null;
135
132
  const e = window[R];
136
- if (!(e instanceof HTMLElement))
137
- return null;
133
+ if (!(e instanceof HTMLElement)) return null;
138
134
  window[R] = null;
139
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);
140
136
  if (t) {
141
- const n = A(t);
142
- if (n)
143
- return n;
144
- if (t.getAttribute("contenteditable") === "true")
145
- return t;
137
+ const l = A(t);
138
+ if (l) return l;
139
+ if (t.getAttribute("contenteditable") === "true") return t;
146
140
  }
147
141
  if (e.getAttribute("contenteditable") === "true")
148
142
  return e;
@@ -628,31 +622,26 @@ function k() {
628
622
  return e && (s = e), e;
629
623
  }
630
624
  function W(e) {
631
- if (!e)
632
- return;
633
- const t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, r = t == null ? void 0 : t.closest('[contenteditable="true"]');
625
+ if (!e) return;
626
+ const r = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]');
634
627
  r && (s = r);
635
628
  }
636
629
  function A(e) {
637
- if (!e)
638
- return null;
630
+ if (!e) return null;
639
631
  const t = e.querySelector('[contenteditable="true"]');
640
632
  return t instanceof HTMLElement ? t : null;
641
633
  }
642
634
  function Q() {
643
- if (_)
644
- return;
635
+ if (_) return;
645
636
  const e = (t) => {
646
637
  const r = t.target;
647
- if (!r)
648
- return;
649
- const n = r.closest(
638
+ if (!r) return;
639
+ const l = r.closest(
650
640
  '.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]'
651
641
  );
652
- if (!n)
653
- return;
654
- const o = n.closest("[data-editora-editor]"), l = A(o);
655
- l && (h = l, s = l);
642
+ if (!l) return;
643
+ const o = l.closest("[data-editora-editor]"), n = A(o);
644
+ n && (h = n, s = n);
656
645
  };
657
646
  document.addEventListener("pointerdown", e, !0), _ = !0;
658
647
  }
@@ -670,10 +659,9 @@ function te() {
670
659
  b += 1, b === 1 && d && d.disconnect();
671
660
  }
672
661
  function re() {
673
- if (b === 0 || (b -= 1, b > 0) || !d)
674
- return;
662
+ if (b === 0 || (b -= 1, b > 0) || !d) return;
675
663
  const e = k();
676
- e && d.observe(e, B);
664
+ e && d.observe(e, j);
677
665
  }
678
666
  function N(e) {
679
667
  te();
@@ -700,45 +688,42 @@ const oe = () => {
700
688
  };
701
689
  function ne(e, t) {
702
690
  const r = [];
703
- for (let n = 0; n <= t.length; n++)
704
- r[n] = [n];
705
- for (let n = 0; n <= e.length; n++)
706
- r[0][n] = n;
707
- for (let n = 1; n <= t.length; n++)
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++)
708
694
  for (let o = 1; o <= e.length; o++)
709
- t.charAt(n - 1) === e.charAt(o - 1) ? r[n][o] = r[n - 1][o - 1] : r[n][o] = Math.min(
710
- r[n - 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,
711
697
  // substitution
712
- r[n][o - 1] + 1,
698
+ r[l][o - 1] + 1,
713
699
  // insertion
714
- r[n - 1][o] + 1
700
+ r[l - 1][o] + 1
715
701
  // deletion
716
702
  );
717
703
  return r[t.length][e.length];
718
704
  }
719
705
  function ce(e) {
720
706
  const t = e.toLowerCase();
721
- return j.has(t) || C.has(t) || S.has(t);
707
+ return B.has(t) || C.has(t) || S.has(t);
722
708
  }
723
709
  function ae(e, t = 5) {
724
- const r = e.toLowerCase(), o = Array.from(j).map((l) => ({ word: l, distance: ne(r, l) }));
725
- return o.sort((l, c) => l.distance - c.distance), o.filter((l) => l.distance <= 3).slice(0, t).map((l) => l.word);
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);
726
712
  }
727
713
  function se(e) {
728
- if (e.nodeType !== Node.ELEMENT_NODE)
729
- return !1;
714
+ if (e.nodeType !== Node.ELEMENT_NODE) return !1;
730
715
  const t = e;
731
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"));
732
717
  }
733
718
  function ie(e) {
734
719
  const t = [], r = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
735
- let n;
736
- for (; (n = r.exec(e.data)) !== null; ) {
737
- const o = n[0], l = n.index, c = l + o.length;
720
+ let l;
721
+ for (; (l = r.exec(e.data)) !== null; ) {
722
+ const o = l[0], n = l.index, c = n + o.length;
738
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({
739
- id: `${o}-${l}`,
724
+ id: `${o}-${n}`,
740
725
  node: e,
741
- startOffset: l,
726
+ startOffset: n,
742
727
  endOffset: c,
743
728
  word: o,
744
729
  suggestions: ae(o),
@@ -753,71 +738,64 @@ const V = () => {
753
738
  return s = e, e;
754
739
  const t = window.getSelection();
755
740
  if (t && t.rangeCount > 0) {
756
- let n = t.getRangeAt(0).startContainer;
757
- for (; n && n !== document.body; ) {
758
- if (n.nodeType === Node.ELEMENT_NODE) {
759
- const o = n;
741
+ let l = t.getRangeAt(0).startContainer;
742
+ for (; l && l !== document.body; ) {
743
+ if (l.nodeType === Node.ELEMENT_NODE) {
744
+ const o = l;
760
745
  if (o.getAttribute("contenteditable") === "true")
761
746
  return o;
762
747
  }
763
- n = n.parentNode;
748
+ l = l.parentNode;
764
749
  }
765
750
  }
766
751
  const r = document.activeElement;
767
752
  if (r) {
768
753
  if (r.getAttribute("contenteditable") === "true")
769
754
  return r;
770
- const n = r.closest('[contenteditable="true"]');
771
- if (n)
772
- return n;
755
+ const l = r.closest('[contenteditable="true"]');
756
+ if (l) return l;
773
757
  const o = r.closest("[data-editora-editor]");
774
758
  if (o) {
775
- const l = o.querySelector('[contenteditable="true"]');
776
- if (l)
777
- return l;
759
+ const n = o.querySelector('[contenteditable="true"]');
760
+ if (n) return n;
778
761
  }
779
762
  }
780
763
  return document.querySelector('[contenteditable="true"]');
781
764
  };
782
765
  function M() {
783
766
  const e = k();
784
- if (!e)
785
- return [];
767
+ if (!e) return [];
786
768
  const t = [], r = document.createTreeWalker(
787
769
  e,
788
770
  NodeFilter.SHOW_TEXT,
789
771
  {
790
- acceptNode: (o) => {
791
- var l;
792
- return !((l = o.textContent) != null && l.trim()) || o.parentNode && se(o.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
793
- }
772
+ acceptNode: (o) => !o.textContent?.trim() || o.parentNode && se(o.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
794
773
  }
795
774
  );
796
- let n = r.nextNode();
797
- for (; n; )
798
- t.push(...ie(n)), n = r.nextNode();
775
+ let l = r.nextNode();
776
+ for (; l; )
777
+ t.push(...ie(l)), l = r.nextNode();
799
778
  return t;
800
779
  }
801
780
  function m(e) {
802
781
  const t = k();
803
782
  t && (e || (e = M()), N(() => {
804
783
  t.querySelectorAll(".rte-misspelled").forEach((r) => {
805
- const n = r.parentNode;
806
- if (n) {
784
+ const l = r.parentNode;
785
+ if (l) {
807
786
  for (; r.firstChild; )
808
- n.insertBefore(r.firstChild, r);
809
- n.removeChild(r);
787
+ l.insertBefore(r.firstChild, r);
788
+ l.removeChild(r);
810
789
  }
811
790
  }), e.forEach((r) => {
812
- if (S.has(r.word.toLowerCase()))
813
- return;
814
- const n = r.node.data.length;
815
- if (!(r.startOffset < 0 || r.endOffset > n || r.startOffset >= r.endOffset))
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))
816
794
  try {
817
795
  const o = document.createRange();
818
796
  o.setStart(r.node, r.startOffset), o.setEnd(r.node, r.endOffset);
819
- const l = document.createElement("span");
820
- l.className = "rte-misspelled", l.setAttribute("data-word", r.word), l.setAttribute("data-suggestions", r.suggestions.join(",")), l.setAttribute("title", `Suggestions: ${r.suggestions.join(", ")}`), l.style.borderBottom = "2px wavy red", l.style.cursor = "pointer", o.surroundContents(l);
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);
821
799
  } catch {
822
800
  }
823
801
  });
@@ -840,8 +818,8 @@ function de(e, t) {
840
818
  N(() => {
841
819
  const r = document.createRange();
842
820
  r.setStart(e.node, e.startOffset), r.setEnd(e.node, e.endOffset);
843
- const n = document.createTextNode(t);
844
- r.deleteContents(), r.insertNode(n);
821
+ const l = document.createTextNode(t);
822
+ r.deleteContents(), r.insertNode(l);
845
823
  });
846
824
  }
847
825
  function G(e) {
@@ -852,14 +830,13 @@ function J(e) {
852
830
  }
853
831
  function pe(e) {
854
832
  const t = k();
855
- if (!t)
856
- return { total: 0, misspelled: 0, accuracy: 100 };
833
+ if (!t) return { total: 0, misspelled: 0, accuracy: 100 };
857
834
  e || (e = M());
858
- const r = e.filter((c) => !S.has(c.word.toLowerCase())).length, l = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
835
+ const r = e.filter((c) => !S.has(c.word.toLowerCase())).length, n = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
859
836
  return {
860
- total: l,
837
+ total: n,
861
838
  misspelled: r,
862
- accuracy: l > 0 ? (l - r) / l * 100 : 100
839
+ accuracy: n > 0 ? (n - r) / n * 100 : 100
863
840
  };
864
841
  }
865
842
  function he(e, t) {
@@ -869,36 +846,36 @@ function he(e, t) {
869
846
  function ue(e) {
870
847
  e.classList.remove("rte-misspelled"), e.removeAttribute("data-word"), e.removeAttribute("data-suggestions"), e.removeAttribute("title"), e.style.borderBottom = "", e.style.cursor = "";
871
848
  }
872
- function me(e, t, r, n, o) {
849
+ function me(e, t, r, l, o) {
873
850
  W(o), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
874
- const l = document.createElement("div");
875
- if (l.className = "rte-spellcheck-menu", n.slice(0, 5).forEach((p) => {
851
+ const n = document.createElement("div");
852
+ if (n.className = "rte-spellcheck-menu", l.slice(0, 5).forEach((p) => {
876
853
  const v = document.createElement("div");
877
854
  v.className = "rte-spellcheck-menu-item", v.textContent = p, v.onclick = () => {
878
855
  he(o, p), window.setTimeout(() => {
879
856
  u && (m(), E());
880
- }, 0), l.remove();
881
- }, l.appendChild(v);
882
- }), n.length > 0) {
857
+ }, 0), n.remove();
858
+ }, n.appendChild(v);
859
+ }), l.length > 0) {
883
860
  const p = document.createElement("div");
884
- p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", l.appendChild(p);
861
+ p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", n.appendChild(p);
885
862
  }
886
863
  const c = document.createElement("div");
887
864
  c.className = "rte-spellcheck-menu-item meta", c.textContent = "Ignore Once", c.onclick = () => {
888
- ue(o), l.remove();
889
- }, l.appendChild(c);
865
+ ue(o), n.remove();
866
+ }, n.appendChild(c);
890
867
  const i = document.createElement("div");
891
868
  i.className = "rte-spellcheck-menu-item meta", i.textContent = "Ignore All", i.onclick = () => {
892
- G(r), l.remove();
893
- }, l.appendChild(i);
869
+ G(r), n.remove();
870
+ }, n.appendChild(i);
894
871
  const w = document.createElement("div");
895
872
  w.className = "rte-spellcheck-menu-item positive", w.textContent = "Add to Dictionary", w.onclick = () => {
896
- J(r), l.remove();
897
- }, l.appendChild(w), document.body.appendChild(l);
898
- const D = l.getBoundingClientRect(), X = window.innerWidth - D.width - 8, Z = window.innerHeight - D.height - 8;
899
- l.style.left = `${Math.max(8, Math.min(e, X))}px`, l.style.top = `${Math.max(8, Math.min(t, Z))}px`;
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`;
900
877
  const F = (p) => {
901
- l.contains(p.target) || (l.remove(), document.removeEventListener("mousedown", F));
878
+ n.contains(p.target) || (n.remove(), document.removeEventListener("mousedown", F));
902
879
  };
903
880
  setTimeout(() => document.addEventListener("mousedown", F), 0);
904
881
  }
@@ -907,8 +884,8 @@ function I() {
907
884
  const t = e.target;
908
885
  if (t && t.classList.contains("rte-misspelled")) {
909
886
  e.preventDefault(), W(t);
910
- const r = t.getAttribute("data-word"), n = (t.getAttribute("data-suggestions") || "").split(",").filter((o) => o);
911
- me(e.clientX, e.clientY, r, n, 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);
912
889
  }
913
890
  }, document.addEventListener("contextmenu", x), y = !0);
914
891
  }
@@ -928,8 +905,7 @@ function q() {
928
905
  return r.className = "rte-spell-check-panel", window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(r), r;
929
906
  }
930
907
  function E(e) {
931
- if (!a)
932
- return;
908
+ if (!a) return;
933
909
  const t = e || M(), r = pe(t);
934
910
  a.innerHTML = `
935
911
  <div class="rte-spellcheck-header">
@@ -956,8 +932,8 @@ function E(e) {
956
932
  </div>
957
933
 
958
934
  <div class="rte-spellcheck-list">
959
- ${t.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : t.map((o, l) => `
960
- <div class="rte-spellcheck-item" data-word="${o.word}" data-index="${l}">
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}">
961
937
  <button class="rte-spellcheck-word-header" type="button">
962
938
  <span class="rte-spellcheck-word">${o.word}</span>
963
939
  <span class="rte-spellcheck-caret">▶</span>
@@ -974,30 +950,28 @@ function E(e) {
974
950
  </div>
975
951
  `).join("")}
976
952
  </div>
977
- `;
978
- const n = a.querySelector(".rte-spellcheck-close");
979
- n == null || n.addEventListener("click", (o) => {
953
+ `, a.querySelector(".rte-spellcheck-close")?.addEventListener("click", (o) => {
980
954
  o.preventDefault(), o.stopPropagation(), O();
981
955
  }), a.querySelectorAll(".rte-spellcheck-word-header").forEach((o) => {
982
956
  o.addEventListener("click", () => {
983
- const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
957
+ const c = o.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
984
958
  c && i && (c.classList.contains("show") ? (c.classList.remove("show"), i.textContent = "▶") : (c.classList.add("show"), i.textContent = "▼"));
985
959
  });
986
960
  }), a.querySelectorAll(".suggestion-btn").forEach((o) => {
987
961
  o.addEventListener("click", () => {
988
- const l = o.getAttribute("data-suggestion"), c = o.closest(".rte-spellcheck-item");
989
- c == null || c.getAttribute("data-word");
990
- const i = parseInt((c == null ? void 0 : c.getAttribute("data-index")) || "0");
991
- t[i] && (de(t[i], l), 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());
992
966
  });
993
967
  }), a.querySelectorAll(".ignore-btn").forEach((o) => {
994
968
  o.addEventListener("click", () => {
995
- const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.getAttribute("data-word");
969
+ const c = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
996
970
  G(c);
997
971
  });
998
972
  }), a.querySelectorAll(".add-btn").forEach((o) => {
999
973
  o.addEventListener("click", () => {
1000
- const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.getAttribute("data-word");
974
+ const c = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
1001
975
  J(c);
1002
976
  });
1003
977
  });
@@ -1009,7 +983,7 @@ function $() {
1009
983
  u && m();
1010
984
  }, 350));
1011
985
  }), d.observe(e, {
1012
- ...B
986
+ ...j
1013
987
  }));
1014
988
  }
1015
989
  function U() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:t=>(typeof t=="string"?t:t.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:()=>{const t=l();if(!t)return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const e=n.getRangeAt(0);if(!t.contains(e.commonAncestorContainer))return!1;t.focus({preventScroll:!0});const o=document.execCommand("strikeThrough",!1);return s(t),t.dispatchEvent(new Event("input",{bubbles:!0})),o!==!1}},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function l(){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).startContainer,o=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement,r=o==null?void 0:o.closest('[contenteditable="true"], .rte-content, .editora-content');if(r)return r}const n=document.activeElement;return n?n.getAttribute("contenteditable")==="true"?n:n.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function s(t){t.querySelectorAll("strike, del").forEach(e=>{var r;const o=document.createElement("s");for(const i of Array.from(e.attributes))i.name!=="style"&&o.setAttribute(i.name,i.value);for(;e.firstChild;)o.appendChild(e.firstChild);(r=e.parentNode)==null||r.replaceChild(o,e)})}exports.StrikethroughPlugin=c;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:t=>(typeof t=="string"?t:t.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:()=>{const t=l();if(!t)return!1;const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const e=n.getRangeAt(0);if(!t.contains(e.commonAncestorContainer))return!1;t.focus({preventScroll:!0});const o=document.execCommand("strikeThrough",!1);return c(t),t.dispatchEvent(new Event("input",{bubbles:!0})),o!==!1}},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function l(){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).startContainer,r=(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(r)return r}const n=document.activeElement;return n?n.getAttribute("contenteditable")==="true"?n:n.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function c(t){t.querySelectorAll("strike, del").forEach(e=>{const o=document.createElement("s");for(const r of Array.from(e.attributes))r.name!=="style"&&o.setAttribute(r.name,r.value);for(;e.firstChild;)o.appendChild(e.firstChild);e.parentNode?.replaceChild(o,e)})}exports.StrikethroughPlugin=i;
@@ -1,4 +1,4 @@
1
- const a = () => ({
1
+ const l = () => ({
2
2
  name: "strikethrough",
3
3
  // Schema definition for strikethrough mark
4
4
  marks: {
@@ -30,18 +30,15 @@ const a = () => ({
30
30
  * Toggle strikethrough formatting on current selection
31
31
  */
32
32
  toggleStrikethrough: () => {
33
- const t = c();
34
- if (!t)
35
- return !1;
33
+ const t = i();
34
+ if (!t) return !1;
36
35
  const n = window.getSelection();
37
- if (!n || n.rangeCount === 0)
38
- return !1;
36
+ if (!n || n.rangeCount === 0) return !1;
39
37
  const e = n.getRangeAt(0);
40
- if (!t.contains(e.commonAncestorContainer))
41
- return !1;
38
+ if (!t.contains(e.commonAncestorContainer)) return !1;
42
39
  t.focus({ preventScroll: !0 });
43
40
  const o = document.execCommand("strikeThrough", !1);
44
- return s(t), t.dispatchEvent(new Event("input", { bubbles: !0 })), o !== !1;
41
+ return c(t), t.dispatchEvent(new Event("input", { bubbles: !0 })), o !== !1;
45
42
  }
46
43
  },
47
44
  // Keyboard shortcuts
@@ -50,27 +47,25 @@ const a = () => ({
50
47
  "Mod-Shift-X": "toggleStrikethrough"
51
48
  }
52
49
  });
53
- function c() {
50
+ function i() {
54
51
  const t = window.getSelection();
55
52
  if (t && t.rangeCount > 0) {
56
- const e = t.getRangeAt(0).startContainer, o = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, r = o == null ? void 0 : o.closest('[contenteditable="true"], .rte-content, .editora-content');
57
- if (r)
58
- return r;
53
+ const e = t.getRangeAt(0).startContainer, r = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');
54
+ if (r) return r;
59
55
  }
60
56
  const n = document.activeElement;
61
57
  return n ? n.getAttribute("contenteditable") === "true" ? n : n.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
62
58
  }
63
- function s(t) {
59
+ function c(t) {
64
60
  t.querySelectorAll("strike, del").forEach((e) => {
65
- var r;
66
61
  const o = document.createElement("s");
67
- for (const i of Array.from(e.attributes))
68
- i.name !== "style" && o.setAttribute(i.name, i.value);
62
+ for (const r of Array.from(e.attributes))
63
+ r.name !== "style" && o.setAttribute(r.name, r.value);
69
64
  for (; e.firstChild; )
70
65
  o.appendChild(e.firstChild);
71
- (r = e.parentNode) == null || r.replaceChild(o, e);
66
+ e.parentNode?.replaceChild(o, e);
72
67
  });
73
68
  }
74
69
  export {
75
- a as StrikethroughPlugin
70
+ l as StrikethroughPlugin
76
71
  };
package/dist/table.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("./editorContainerHelpers-36b8ddf3.js");let h=null,m=null,x=null,I=null,M=null,S=null,V=null;const C='[data-theme="dark"], .dark, .editora-theme-dark';let w=!1,v=null,L=0,k=0,E=!1,A=0,B=0,D=0,N=0;const _=()=>{const e=R.findEditorContainerFromSelection(),t=R.getContentElement(e);if(!t)return alert("Please place your cursor in the editor before inserting a table"),!1;const n=window.getSelection();if(!n||n.rangeCount===0)return;const l=n.getRangeAt(0),r=document.createElement("table");r.className="rte-table";const o=document.createElement("thead"),a=document.createElement("tr");for(let d=0;d<3;d++){const c=document.createElement("th"),u=document.createElement("p");u.appendChild(document.createElement("br")),c.appendChild(u),a.appendChild(c)}o.appendChild(a);const i=document.createElement("tbody");for(let d=0;d<2;d++){const c=document.createElement("tr");for(let u=0;u<3;u++){const p=document.createElement("td"),f=document.createElement("p");f.appendChild(document.createElement("br")),p.appendChild(f),c.appendChild(p)}i.appendChild(c)}r.appendChild(o),r.appendChild(i),l.deleteContents(),l.insertNode(r);const s=r.querySelector("th p");if(s){const d=document.createRange();d.setStart(s,0),d.collapse(!0),n.removeAllRanges(),n.addRange(d)}t.focus()},X=()=>{var a;const e=b();if(!e)return;const{table:t,rowIndex:n}=e,l=document.createElement("tr"),r=((a=t.rows[0])==null?void 0:a.cells.length)||0;for(let i=0;i<r;i++){const s=document.createElement("td"),d=document.createElement("p");d.innerHTML="<br>",s.appendChild(d),l.appendChild(s)}const o=t.rows[n];o&&o.parentElement?o.parentElement.insertBefore(l,o):t.appendChild(l),g()},z=()=>{var o;const e=b();if(!e)return;const{table:t,rowIndex:n}=e,l=document.createElement("tr"),r=((o=t.rows[0])==null?void 0:o.cells.length)||0;for(let a=0;a<r;a++){const i=document.createElement("td"),s=document.createElement("p");s.innerHTML="<br>",i.appendChild(s),l.appendChild(i)}n>=t.rows.length-1?t.appendChild(l):t.insertBefore(l,t.rows[n+1]),g()},P=()=>{const e=b();if(!e)return;const{table:t,colIndex:n}=e;for(let l=0;l<t.rows.length;l++){const r=t.rows[l],o=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",o.appendChild(a),n===0?r.insertBefore(o,r.cells[0]):r.insertBefore(o,r.cells[n])}g()},T=()=>{const e=b();if(!e)return;const{table:t,colIndex:n}=e;for(let l=0;l<t.rows.length;l++){const r=t.rows[l],o=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",o.appendChild(a),n>=r.cells.length-1?r.appendChild(o):r.insertBefore(o,r.cells[n+1])}g()},O=()=>{const e=b();if(!e||e.rowCount<=1)return;const{table:t,rowIndex:n}=e;t.deleteRow(n),g()},W=()=>{const e=b();if(!e||e.cellCount<=1)return;const{table:t,colIndex:n}=e;for(let l=0;l<t.rows.length;l++){const r=t.rows[l];r.cells[n]&&r.deleteCell(n)}g()},K=()=>{var o;const e=b();if(!e)return;const{table:t,rowIndex:n}=e,l=t.rows[n];if(((o=l.parentElement)==null?void 0:o.tagName.toLowerCase())==="thead"){const a=t.querySelector("tbody")||t.appendChild(document.createElement("tbody")),i=t.querySelector("thead");i&&(a.insertBefore(l,a.firstChild),i.rows.length===0&&i.remove())}else{let a=t.querySelector("thead");a||(a=document.createElement("thead"),t.insertBefore(a,t.firstChild)),a.appendChild(l)}g()},Y=()=>{var l;const e=b();if(!e)return;const{table:t,colIndex:n}=e;for(let r=0;r<t.rows.length;r++){const o=t.rows[r].cells[n];if(o){const a=o.tagName.toLowerCase()==="th"?"td":"th",i=document.createElement(a);i.innerHTML=o.innerHTML;for(let s=0;s<o.attributes.length;s++){const d=o.attributes[s];i.setAttribute(d.name,d.value)}(l=o.parentNode)==null||l.replaceChild(i,o)}}g()},F=()=>{const e=b();if(!e)return;e.table.remove(),document.dispatchEvent(new CustomEvent("tableDeleted"))},U=()=>{var u,p;const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=e.getRangeAt(0).startContainer;if(!(n.nodeType===Node.TEXT_NODE?(u=n.parentElement)==null?void 0:u.closest("table"):n.closest("table")))return;let r=null;if(n.nodeType===Node.TEXT_NODE?r=(p=n.parentElement)==null?void 0:p.closest("td, th"):n.nodeType===Node.ELEMENT_NODE&&(r=n.closest("td, th")),!r)return;const o=r.parentElement;if(!o)return;let a=-1;for(let f=0;f<o.cells.length;f++)if(o.cells[f]===r){a=f;break}if(a===-1||a===o.cells.length-1)return;const i=o.cells[a+1];if(!i)return;const s=parseInt(r.getAttribute("colspan")||"1"),d=parseInt(i.getAttribute("colspan")||"1");r.setAttribute("colspan",String(s+d)),Array.from(i.childNodes).forEach(f=>{r.appendChild(f)}),i.remove(),g()};function b(){var s,d,c;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0).startContainer;let l=n.nodeType===Node.TEXT_NODE?(s=n.parentElement)==null?void 0:s.closest("table"):n.closest("table");if(!l)return null;const r=l;let o=0,a=0;const i=n.nodeType===Node.TEXT_NODE?(d=n.parentElement)==null?void 0:d.closest("td, th"):n.closest("td, th");if(i){let u=i.parentElement;for(;u&&u!==r.rows[o]&&(o++,!(o>=r.rows.length)););const p=u;if(p){for(let f=0;f<p.cells.length;f++)if(p.cells[f]===i){a=f;break}}}return{table:r,rowIndex:o,colIndex:a,rowCount:r.rows.length,cellCount:((c=r.rows[0])==null?void 0:c.cells.length)||0}}function g(){if(!h||!m)return;const e=b();if(!e)return;const t=e.rowCount>1,n=e.cellCount>1;q(t,n)}function j(){x=()=>{const e=b();e?G(e.table):y()},I=e=>{const t=e.target,n=t.closest("table"),l=t.closest(".table-toolbar");!n&&!l&&y()},M=()=>{y()},S=()=>{m&&h&&h.style.display!=="none"&&H(m)},V=()=>{m&&h&&h.style.display!=="none"&&H(m)},document.addEventListener("selectionchange",x),document.addEventListener("mousedown",I),document.addEventListener("tableDeleted",M),window.addEventListener("scroll",S,!0),window.addEventListener("resize",V)}function H(e){if(!h)return;const t=e.getBoundingClientRect(),n=h.getBoundingClientRect(),l=n.height||40,r=n.width||280,o=10;let a=t.top-l-o,i=t.left+t.width/2-r/2;a<o&&(a=t.bottom+o),i<o&&(i=o);const s=window.innerWidth;i+r>s-o&&(i=s-r-o);const d=window.innerHeight;a+l>d-o&&(a=d-l-o),h.style.top=a+"px",h.style.left=i+"px"}function G(e){m=e,h||(h=J(),document.body.appendChild(h));const t=!!e.closest(C)||document.body.matches(C)||document.documentElement.matches(C);h.classList.toggle("rte-theme-dark",t),h.style.display="flex",h.style.visibility="hidden",requestAnimationFrame(()=>{H(e),h&&(h.style.visibility="visible")});const n=b();n&&q(n.rowCount>1,n.cellCount>1),Z(e)}function y(){if(h&&(h.style.display="none"),m){m.querySelectorAll(".resize-handle").forEach(n=>n.remove());const t=m.querySelector(".table-resize-handle");t&&t.remove()}m=null}function q(e,t){if(!h)return;const n=h.querySelector('[data-action="deleteRow"]'),l=h.querySelector('[data-action="deleteColumn"]');n&&(n.disabled=!e),l&&(l.disabled=!t)}function J(){const e=document.createElement("div");e.className="table-toolbar",e.style.cssText=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("./editorContainerHelpers-CFbfiOJI.js");let h=null,m=null,x=null,I=null,M=null,S=null,V=null;const w='[data-theme="dark"], .dark, .editora-theme-dark';let g=!1,p=null,L=0,k=0,C=!1,A=0,B=0,D=0,N=0;const _=()=>{const e=R.findEditorContainerFromSelection(),t=R.getContentElement(e);if(!t)return alert("Please place your cursor in the editor before inserting a table"),!1;const n=window.getSelection();if(!n||n.rangeCount===0)return;const r=n.getRangeAt(0),o=document.createElement("table");o.className="rte-table";const l=document.createElement("thead"),a=document.createElement("tr");for(let c=0;c<3;c++){const s=document.createElement("th"),u=document.createElement("p");u.appendChild(document.createElement("br")),s.appendChild(u),a.appendChild(s)}l.appendChild(a);const i=document.createElement("tbody");for(let c=0;c<2;c++){const s=document.createElement("tr");for(let u=0;u<3;u++){const v=document.createElement("td"),T=document.createElement("p");T.appendChild(document.createElement("br")),v.appendChild(T),s.appendChild(v)}i.appendChild(s)}o.appendChild(l),o.appendChild(i),r.deleteContents(),r.insertNode(o);const d=o.querySelector("th p");if(d){const c=document.createRange();c.setStart(d,0),c.collapse(!0),n.removeAllRanges(),n.addRange(c)}t.focus()},X=()=>{const e=f();if(!e)return;const{table:t,rowIndex:n}=e,r=document.createElement("tr"),o=t.rows[0]?.cells.length||0;for(let a=0;a<o;a++){const i=document.createElement("td"),d=document.createElement("p");d.innerHTML="<br>",i.appendChild(d),r.appendChild(i)}const l=t.rows[n];l&&l.parentElement?l.parentElement.insertBefore(r,l):t.appendChild(r),b()},H=()=>{const e=f();if(!e)return;const{table:t,rowIndex:n}=e,r=document.createElement("tr"),o=t.rows[0]?.cells.length||0;for(let l=0;l<o;l++){const a=document.createElement("td"),i=document.createElement("p");i.innerHTML="<br>",a.appendChild(i),r.appendChild(a)}n>=t.rows.length-1?t.appendChild(r):t.insertBefore(r,t.rows[n+1]),b()},P=()=>{const e=f();if(!e)return;const{table:t,colIndex:n}=e;for(let r=0;r<t.rows.length;r++){const o=t.rows[r],l=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",l.appendChild(a),n===0?o.insertBefore(l,o.cells[0]):o.insertBefore(l,o.cells[n])}b()},z=()=>{const e=f();if(!e)return;const{table:t,colIndex:n}=e;for(let r=0;r<t.rows.length;r++){const o=t.rows[r],l=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",l.appendChild(a),n>=o.cells.length-1?o.appendChild(l):o.insertBefore(l,o.cells[n+1])}b()},O=()=>{const e=f();if(!e||e.rowCount<=1)return;const{table:t,rowIndex:n}=e;t.deleteRow(n),b()},W=()=>{const e=f();if(!e||e.cellCount<=1)return;const{table:t,colIndex:n}=e;for(let r=0;r<t.rows.length;r++){const o=t.rows[r];o.cells[n]&&o.deleteCell(n)}b()},K=()=>{const e=f();if(!e)return;const{table:t,rowIndex:n}=e,r=t.rows[n];if(r.parentElement?.tagName.toLowerCase()==="thead"){const l=t.querySelector("tbody")||t.appendChild(document.createElement("tbody")),a=t.querySelector("thead");a&&(l.insertBefore(r,l.firstChild),a.rows.length===0&&a.remove())}else{let l=t.querySelector("thead");l||(l=document.createElement("thead"),t.insertBefore(l,t.firstChild)),l.appendChild(r)}b()},Y=()=>{const e=f();if(!e)return;const{table:t,colIndex:n}=e;for(let r=0;r<t.rows.length;r++){const o=t.rows[r].cells[n];if(o){const l=o.tagName.toLowerCase()==="th"?"td":"th",a=document.createElement(l);a.innerHTML=o.innerHTML;for(let i=0;i<o.attributes.length;i++){const d=o.attributes[i];a.setAttribute(d.name,d.value)}o.parentNode?.replaceChild(a,o)}}b()},F=()=>{const e=f();if(!e)return;e.table.remove(),document.dispatchEvent(new CustomEvent("tableDeleted"))},U=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=e.getRangeAt(0).startContainer;if(!(n.nodeType===Node.TEXT_NODE?n.parentElement?.closest("table"):n.closest("table")))return;let o=null;if(n.nodeType===Node.TEXT_NODE?o=n.parentElement?.closest("td, th"):n.nodeType===Node.ELEMENT_NODE&&(o=n.closest("td, th")),!o)return;const l=o.parentElement;if(!l)return;let a=-1;for(let u=0;u<l.cells.length;u++)if(l.cells[u]===o){a=u;break}if(a===-1||a===l.cells.length-1)return;const i=l.cells[a+1];if(!i)return;const d=parseInt(o.getAttribute("colspan")||"1"),c=parseInt(i.getAttribute("colspan")||"1");o.setAttribute("colspan",String(d+c)),Array.from(i.childNodes).forEach(u=>{o.appendChild(u)}),i.remove(),b()};function f(){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0).startContainer;let r=n.nodeType===Node.TEXT_NODE?n.parentElement?.closest("table"):n.closest("table");if(!r)return null;const o=r;let l=0,a=0;const i=n.nodeType===Node.TEXT_NODE?n.parentElement?.closest("td, th"):n.closest("td, th");if(i){let d=i.parentElement;for(;d&&d!==o.rows[l]&&(l++,!(l>=o.rows.length)););const c=d;if(c){for(let s=0;s<c.cells.length;s++)if(c.cells[s]===i){a=s;break}}}return{table:o,rowIndex:l,colIndex:a,rowCount:o.rows.length,cellCount:o.rows[0]?.cells.length||0}}function b(){if(!h||!m)return;const e=f();if(!e)return;const t=e.rowCount>1,n=e.cellCount>1;q(t,n)}function j(){x=()=>{const e=f();e?G(e.table):E()},I=e=>{const t=e.target,n=t.closest("table"),r=t.closest(".table-toolbar");!n&&!r&&E()},M=()=>{E()},S=()=>{m&&h&&h.style.display!=="none"&&y(m)},V=()=>{m&&h&&h.style.display!=="none"&&y(m)},document.addEventListener("selectionchange",x),document.addEventListener("mousedown",I),document.addEventListener("tableDeleted",M),window.addEventListener("scroll",S,!0),window.addEventListener("resize",V)}function y(e){if(!h)return;const t=e.getBoundingClientRect(),n=h.getBoundingClientRect(),r=n.height||40,o=n.width||280,l=10;let a=t.top-r-l,i=t.left+t.width/2-o/2;a<l&&(a=t.bottom+l),i<l&&(i=l);const d=window.innerWidth;i+o>d-l&&(i=d-o-l);const c=window.innerHeight;a+r>c-l&&(a=c-r-l),h.style.top=a+"px",h.style.left=i+"px"}function G(e){m=e,h||(h=J(),document.body.appendChild(h));const t=!!e.closest(w)||document.body.matches(w)||document.documentElement.matches(w);h.classList.toggle("rte-theme-dark",t),h.style.display="flex",h.style.visibility="hidden",requestAnimationFrame(()=>{y(e),h&&(h.style.visibility="visible")});const n=f();n&&q(n.rowCount>1,n.cellCount>1),Z(e)}function E(){if(h&&(h.style.display="none"),m){m.querySelectorAll(".resize-handle").forEach(n=>n.remove());const t=m.querySelector(".table-resize-handle");t&&t.remove()}m=null}function q(e,t){if(!h)return;const n=h.querySelector('[data-action="deleteRow"]'),r=h.querySelector('[data-action="deleteColumn"]');n&&(n.disabled=!e),r&&(r.disabled=!t)}function J(){const e=document.createElement("div");e.className="table-toolbar",e.style.cssText=`
2
2
  position: fixed;
3
3
  z-index: 1000;
4
4
  display: none;
5
- `,e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Table editing toolbar");const t=c=>{const u=document.createElement("button");return u.className="toolbar-icon-btn",c.danger&&u.classList.add("toolbar-icon-btn-danger"),c.delete&&u.classList.add("toolbar-icon-btn-delete"),u.innerHTML=c.icon,u.title=c.title,u.setAttribute("aria-label",c.title),u.setAttribute("type","button"),u.setAttribute("data-action",c.action),u.onclick=()=>Q(c.action),u},n=()=>{const c=document.createElement("div");return c.className="toolbar-divider",c},l=(...c)=>{const u=document.createElement("div");return u.className="toolbar-section",c.forEach(p=>u.appendChild(p)),u},r=l(t({icon:te(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),t({icon:ne(),title:"Add row below",action:"addRowBelow"}),t({icon:oe(),title:"Delete row",action:"deleteRow",danger:!0})),o=l(t({icon:le(),title:"Add column left",action:"addColumnLeft"}),t({icon:re(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),t({icon:ae(),title:"Delete column",action:"deleteColumn",danger:!0})),a=l(t({icon:ie(),title:"Toggle header row",action:"toggleHeaderRow"}),t({icon:se(),title:"Toggle header column",action:"toggleHeaderColumn"})),i=l(t({icon:ce(),title:"Merge cells (horizontally)",action:"mergeCells"})),s=l(t({icon:de(),title:"Delete table",action:"deleteTable",delete:!0}));e.appendChild(r),e.appendChild(n()),e.appendChild(o),e.appendChild(n()),e.appendChild(a),e.appendChild(n()),e.appendChild(i),e.appendChild(n()),e.appendChild(s);const d=c=>{!h||h.style.display==="none"||(c.ctrlKey||c.metaKey)&&c.shiftKey&&(c.key==="r"||c.key==="R"?(c.preventDefault(),z()):(c.key==="c"||c.key==="C")&&(c.preventDefault(),T()))};return window.addEventListener("keydown",d),e}function Q(e){switch(e){case"addRowAbove":X();break;case"addRowBelow":z();break;case"addColumnLeft":P();break;case"addColumnRight":T();break;case"deleteRow":O();break;case"deleteColumn":W();break;case"toggleHeaderRow":K();break;case"toggleHeaderColumn":Y();break;case"deleteTable":F();break;case"mergeCells":U();break}}function Z(e){e.querySelectorAll(".resize-handle").forEach(a=>a.remove());const n=e.querySelector(".table-resize-handle");n&&n.remove();const l=e.querySelector("thead tr, tbody tr:first-child");if(!l)return;const r=l.querySelectorAll("td, th");r.forEach((a,i)=>{if(i===r.length-1)return;const s=document.createElement("div");s.className="resize-handle",s.style.cssText=`
5
+ `,e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Table editing toolbar");const t=s=>{const u=document.createElement("button");return u.className="toolbar-icon-btn",s.danger&&u.classList.add("toolbar-icon-btn-danger"),s.delete&&u.classList.add("toolbar-icon-btn-delete"),u.innerHTML=s.icon,u.title=s.title,u.setAttribute("aria-label",s.title),u.setAttribute("type","button"),u.setAttribute("data-action",s.action),u.onclick=()=>Q(s.action),u},n=()=>{const s=document.createElement("div");return s.className="toolbar-divider",s},r=(...s)=>{const u=document.createElement("div");return u.className="toolbar-section",s.forEach(v=>u.appendChild(v)),u},o=r(t({icon:te(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),t({icon:ne(),title:"Add row below",action:"addRowBelow"}),t({icon:oe(),title:"Delete row",action:"deleteRow",danger:!0})),l=r(t({icon:le(),title:"Add column left",action:"addColumnLeft"}),t({icon:re(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),t({icon:ae(),title:"Delete column",action:"deleteColumn",danger:!0})),a=r(t({icon:ie(),title:"Toggle header row",action:"toggleHeaderRow"}),t({icon:se(),title:"Toggle header column",action:"toggleHeaderColumn"})),i=r(t({icon:ce(),title:"Merge cells (horizontally)",action:"mergeCells"})),d=r(t({icon:de(),title:"Delete table",action:"deleteTable",delete:!0}));e.appendChild(o),e.appendChild(n()),e.appendChild(l),e.appendChild(n()),e.appendChild(a),e.appendChild(n()),e.appendChild(i),e.appendChild(n()),e.appendChild(d);const c=s=>{!h||h.style.display==="none"||(s.ctrlKey||s.metaKey)&&s.shiftKey&&(s.key==="r"||s.key==="R"?(s.preventDefault(),H()):(s.key==="c"||s.key==="C")&&(s.preventDefault(),z()))};return window.addEventListener("keydown",c),e}function Q(e){switch(e){case"addRowAbove":X();break;case"addRowBelow":H();break;case"addColumnLeft":P();break;case"addColumnRight":z();break;case"deleteRow":O();break;case"deleteColumn":W();break;case"toggleHeaderRow":K();break;case"toggleHeaderColumn":Y();break;case"deleteTable":F();break;case"mergeCells":U();break}}function Z(e){e.querySelectorAll(".resize-handle").forEach(a=>a.remove());const n=e.querySelector(".table-resize-handle");n&&n.remove();const r=e.querySelector("thead tr, tbody tr:first-child");if(!r)return;const o=r.querySelectorAll("td, th");o.forEach((a,i)=>{if(i===o.length-1)return;const d=document.createElement("div");d.className="resize-handle",d.style.cssText=`
6
6
  position: absolute;
7
7
  right: -4px;
8
8
  top: 0;
@@ -12,7 +12,7 @@
12
12
  cursor: col-resize;
13
13
  z-index: 10;
14
14
  transition: background 0.15s ease;
15
- `,s.addEventListener("mouseenter",()=>{w||(s.style.background="rgba(0, 102, 204, 0.3)")}),s.addEventListener("mouseleave",()=>{w||(s.style.background="transparent")}),s.addEventListener("mousedown",d=>{d.preventDefault(),d.stopPropagation(),$(d,i)}),a.style.position="relative",a.appendChild(s)});const o=document.createElement("div");o.className="table-resize-handle",o.addEventListener("mousedown",a=>{a.preventDefault(),a.stopPropagation(),ee(a)}),e.appendChild(o)}function $(e,t){if(w=!0,v=t,L=e.clientX,!m)return;const n=m.querySelector("thead tr, tbody tr:first-child");n&&n.cells[t]&&(k=n.cells[t].offsetWidth),document.body.style.cursor="col-resize",document.body.style.userSelect="none";const l=o=>{if(!w||v===null||!m)return;const a=o.clientX-L,i=Math.max(50,k+a);m.querySelectorAll("tr").forEach(d=>{d.cells[v]&&(d.cells[v].style.width=i+"px")})},r=()=>{w=!1,v=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",r)}function ee(e){if(!m)return;E=!0,A=e.clientX,B=e.clientY,D=m.offsetWidth,N=m.offsetHeight,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none";const t=l=>{if(!E||!m)return;const r=l.clientX-A,o=l.clientY-B,a=Math.max(200,D+r),i=Math.max(100,N+o);m.style.width=a+"px",m.style.height=i+"px"},n=()=>{E=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)}function te(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
15
+ `,d.addEventListener("mouseenter",()=>{g||(d.style.background="rgba(0, 102, 204, 0.3)")}),d.addEventListener("mouseleave",()=>{g||(d.style.background="transparent")}),d.addEventListener("mousedown",c=>{c.preventDefault(),c.stopPropagation(),$(c,i)}),a.style.position="relative",a.appendChild(d)});const l=document.createElement("div");l.className="table-resize-handle",l.addEventListener("mousedown",a=>{a.preventDefault(),a.stopPropagation(),ee(a)}),e.appendChild(l)}function $(e,t){if(g=!0,p=t,L=e.clientX,!m)return;const n=m.querySelector("thead tr, tbody tr:first-child");n&&n.cells[t]&&(k=n.cells[t].offsetWidth),document.body.style.cursor="col-resize",document.body.style.userSelect="none";const r=l=>{if(!g||p===null||!m)return;const a=l.clientX-L,i=Math.max(50,k+a);m.querySelectorAll("tr").forEach(c=>{c.cells[p]&&(c.cells[p].style.width=i+"px")})},o=()=>{g=!1,p=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",o)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",o)}function ee(e){if(!m)return;C=!0,A=e.clientX,B=e.clientY,D=m.offsetWidth,N=m.offsetHeight,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none";const t=r=>{if(!C||!m)return;const o=r.clientX-A,l=r.clientY-B,a=Math.max(200,D+o),i=Math.max(100,N+l);m.style.width=a+"px",m.style.height=i+"px"},n=()=>{C=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)}function te(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
16
16
  <path d="M2 7h12V5H2v2zm0 4h12V9H2v2zM8 1v3H5v2h3v3h2V6h3V4h-3V1H8z"/>
17
17
  </svg>`}function ne(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
18
18
  <path d="M2 3h12V1H2v2zm0 4h12V5H2v2zm6 4v3h3v-2h2v-2h-2v-3h-2v3H5v2h3z"/>
@@ -32,4 +32,4 @@
32
32
  <path d="M3 1h10v1H3V1zm1 2v11h8V3H4zM6 5h1v6H6V5zm3 0h1v6H9V5z"/>
33
33
  </svg>`}function ce(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
34
34
  <path d="M2 2h4v3H2V2zm5 0h4v3H7V2zm5 0h2v3h-2V2zm-10 4h4v3H2V6zm5 0h4v3H7V6zm5 0h2v3h-2V6zm-10 4h4v3H2v-3zm5 0h4v3H7v-3zm5 0h2v3h-2v-3z"/>
35
- </svg>`}if(typeof window<"u"&&!window.__tablePluginInitialized){window.__tablePluginInitialized=!0;const e=()=>{j()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e,100)}const ue=()=>({name:"table",toolbar:[{label:"Insert Table",command:"insertTable",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>'}],commands:{insertTable:()=>(_(),!0)},keymap:{"Mod-Shift-r":()=>(z(),!0),"Mod-Shift-c":()=>(T(),!0)}});exports.TablePlugin=ue;
35
+ </svg>`}if(typeof window<"u"&&!window.__tablePluginInitialized){window.__tablePluginInitialized=!0;const e=()=>{j()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e,100)}const ue=()=>({name:"table",toolbar:[{label:"Insert Table",command:"insertTable",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>'}],commands:{insertTable:()=>(_(),!0)},keymap:{"Mod-Shift-r":()=>(H(),!0),"Mod-Shift-c":()=>(z(),!0)}});exports.TablePlugin=ue;