@editora/plugins 1.0.8 → 1.0.10
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.
- package/README.md +27 -0
- package/dist/_commonjsHelpers-6763f629.js +1 -0
- package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +98 -80
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +128 -115
- package/dist/anchoredPopover-33f1358d.mjs +109 -0
- package/dist/anchoredPopover-8151d535.js +1 -0
- package/dist/approval-workflow.cjs.js +447 -0
- package/dist/approval-workflow.esm.js +1111 -0
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +68 -55
- package/dist/blockquote.esm.js +2 -1
- package/dist/blocks-library.cjs.js +442 -0
- package/dist/blocks-library.esm.js +1384 -0
- package/dist/capitalization.esm.js +2 -1
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +82 -58
- package/dist/citations.cjs.js +548 -0
- package/dist/citations.esm.js +1530 -0
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +33 -27
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +93 -82
- package/dist/code.cjs.js +32 -32
- package/dist/code.esm.js +653 -594
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +158 -116
- package/dist/conditional-content.cjs.js +626 -0
- package/dist/conditional-content.esm.js +1421 -0
- package/dist/content-rules.cjs.js +408 -0
- package/dist/content-rules.esm.js +1147 -0
- package/dist/data-binding.cjs.js +321 -0
- package/dist/data-binding.esm.js +953 -0
- package/dist/direction.esm.js +18 -9
- package/dist/doc-schema.cjs.js +398 -0
- package/dist/doc-schema.esm.js +1378 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +5 -4
- package/dist/documentManager-25b6203c.mjs +9122 -0
- package/dist/documentManager-b69e7054.js +17 -0
- package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +81 -73
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +77 -65
- package/dist/enterprise.cjs.js +1 -0
- package/dist/enterprise.esm.js +58 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +47 -39
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +53 -37
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +117 -76
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +92 -70
- package/dist/html2canvas.esm-09133e29.js +22 -0
- package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +24 -12
- package/dist/index-656d224b.js +231 -0
- package/dist/index-6a8c48bb.js +1 -0
- package/dist/index-d027b7e2.mjs +16859 -0
- package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-730f2d98.mjs +5775 -0
- package/dist/index.es-dd40173b.js +18 -0
- package/dist/index.esm.js +124 -93
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +9 -8
- package/dist/jspdf.es.min-90db2c97.js +243 -0
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +24 -11
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +30 -24
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +25 -20
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +61 -59
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +146 -139
- package/dist/media-manager.cjs.js +38 -38
- package/dist/media-manager.esm.js +325 -308
- package/dist/mentions.cjs.js +105 -0
- package/dist/mentions.esm.js +774 -0
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +216 -177
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +67 -51
- package/dist/pii-redaction.cjs.js +436 -0
- package/dist/pii-redaction.esm.js +1447 -0
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +37 -32
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +20 -17
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
- package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
- package/dist/slash-commands.cjs.js +90 -0
- package/dist/slash-commands.esm.js +788 -0
- package/dist/smart-paste.cjs.js +398 -0
- package/dist/smart-paste.esm.js +1444 -0
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +69 -61
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +123 -97
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +19 -14
- package/dist/style.css +1 -0
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +225 -191
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +153 -124
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +27 -21
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +87 -70
- package/dist/track-changes.cjs.js +77 -0
- package/dist/track-changes.esm.js +817 -0
- package/dist/translation-workflow.cjs.js +626 -0
- package/dist/translation-workflow.esm.js +1794 -0
- package/dist/version-diff.cjs.js +362 -0
- package/dist/version-diff.esm.js +797 -0
- package/index.d.ts +798 -0
- package/package.json +114 -9
- package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
- package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/documentManager-CTqRftU8.mjs +0 -8369
- package/dist/documentManager-Jf0RbSks.js +0 -17
- package/dist/html2canvas.esm-B5qzocYs.js +0 -5
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-D3CycEFU.mjs +0 -16543
- package/dist/index-tqLTHcO6.js +0 -1
- package/dist/index.es-CE_A4QSm.js +0 -5
- package/dist/index.es-DQ78mYYo.mjs +0 -6665
- package/dist/jspdf.es.min-BoS80556.js +0 -77
- package/dist/plugins.css +0 -1
- /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
package/dist/spell-check.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const j = /* @__PURE__ */ new Set([
|
|
2
2
|
"the",
|
|
3
3
|
"a",
|
|
4
4
|
"an",
|
|
@@ -111,32 +111,38 @@ const B = /* @__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
|
|
114
|
+
const B = {
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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"]');
|
|
123
125
|
if (r instanceof HTMLElement) {
|
|
124
126
|
s = r, h = r;
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
|
-
const
|
|
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);
|
|
128
130
|
o && (s = o, h = o);
|
|
129
131
|
}
|
|
130
132
|
function P() {
|
|
131
|
-
if (typeof window > "u")
|
|
133
|
+
if (typeof window > "u")
|
|
134
|
+
return null;
|
|
132
135
|
const e = window[R];
|
|
133
|
-
if (!(e instanceof HTMLElement))
|
|
136
|
+
if (!(e instanceof HTMLElement))
|
|
137
|
+
return null;
|
|
134
138
|
window[R] = null;
|
|
135
139
|
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
140
|
if (t) {
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
|
|
141
|
+
const n = A(t);
|
|
142
|
+
if (n)
|
|
143
|
+
return n;
|
|
144
|
+
if (t.getAttribute("contenteditable") === "true")
|
|
145
|
+
return t;
|
|
140
146
|
}
|
|
141
147
|
if (e.getAttribute("contenteditable") === "true")
|
|
142
148
|
return e;
|
|
@@ -622,26 +628,31 @@ function k() {
|
|
|
622
628
|
return e && (s = e), e;
|
|
623
629
|
}
|
|
624
630
|
function W(e) {
|
|
625
|
-
if (!e)
|
|
626
|
-
|
|
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"]');
|
|
627
634
|
r && (s = r);
|
|
628
635
|
}
|
|
629
636
|
function A(e) {
|
|
630
|
-
if (!e)
|
|
637
|
+
if (!e)
|
|
638
|
+
return null;
|
|
631
639
|
const t = e.querySelector('[contenteditable="true"]');
|
|
632
640
|
return t instanceof HTMLElement ? t : null;
|
|
633
641
|
}
|
|
634
642
|
function Q() {
|
|
635
|
-
if (_)
|
|
643
|
+
if (_)
|
|
644
|
+
return;
|
|
636
645
|
const e = (t) => {
|
|
637
646
|
const r = t.target;
|
|
638
|
-
if (!r)
|
|
639
|
-
|
|
647
|
+
if (!r)
|
|
648
|
+
return;
|
|
649
|
+
const n = r.closest(
|
|
640
650
|
'.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]'
|
|
641
651
|
);
|
|
642
|
-
if (!
|
|
643
|
-
|
|
644
|
-
|
|
652
|
+
if (!n)
|
|
653
|
+
return;
|
|
654
|
+
const o = n.closest("[data-editora-editor]"), l = A(o);
|
|
655
|
+
l && (h = l, s = l);
|
|
645
656
|
};
|
|
646
657
|
document.addEventListener("pointerdown", e, !0), _ = !0;
|
|
647
658
|
}
|
|
@@ -659,9 +670,10 @@ function te() {
|
|
|
659
670
|
b += 1, b === 1 && d && d.disconnect();
|
|
660
671
|
}
|
|
661
672
|
function re() {
|
|
662
|
-
if (b === 0 || (b -= 1, b > 0) || !d)
|
|
673
|
+
if (b === 0 || (b -= 1, b > 0) || !d)
|
|
674
|
+
return;
|
|
663
675
|
const e = k();
|
|
664
|
-
e && d.observe(e,
|
|
676
|
+
e && d.observe(e, B);
|
|
665
677
|
}
|
|
666
678
|
function N(e) {
|
|
667
679
|
te();
|
|
@@ -688,42 +700,45 @@ const oe = () => {
|
|
|
688
700
|
};
|
|
689
701
|
function ne(e, t) {
|
|
690
702
|
const r = [];
|
|
691
|
-
for (let
|
|
692
|
-
|
|
693
|
-
for (let
|
|
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++)
|
|
694
708
|
for (let o = 1; o <= e.length; o++)
|
|
695
|
-
t.charAt(
|
|
696
|
-
r[
|
|
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,
|
|
697
711
|
// substitution
|
|
698
|
-
r[
|
|
712
|
+
r[n][o - 1] + 1,
|
|
699
713
|
// insertion
|
|
700
|
-
r[
|
|
714
|
+
r[n - 1][o] + 1
|
|
701
715
|
// deletion
|
|
702
716
|
);
|
|
703
717
|
return r[t.length][e.length];
|
|
704
718
|
}
|
|
705
719
|
function ce(e) {
|
|
706
720
|
const t = e.toLowerCase();
|
|
707
|
-
return
|
|
721
|
+
return j.has(t) || C.has(t) || S.has(t);
|
|
708
722
|
}
|
|
709
723
|
function ae(e, t = 5) {
|
|
710
|
-
const r = e.toLowerCase(), o = Array.from(
|
|
711
|
-
return o.sort((
|
|
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);
|
|
712
726
|
}
|
|
713
727
|
function se(e) {
|
|
714
|
-
if (e.nodeType !== Node.ELEMENT_NODE)
|
|
728
|
+
if (e.nodeType !== Node.ELEMENT_NODE)
|
|
729
|
+
return !1;
|
|
715
730
|
const t = e;
|
|
716
731
|
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"));
|
|
717
732
|
}
|
|
718
733
|
function ie(e) {
|
|
719
734
|
const t = [], r = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
|
|
720
|
-
let
|
|
721
|
-
for (; (
|
|
722
|
-
const o =
|
|
735
|
+
let n;
|
|
736
|
+
for (; (n = r.exec(e.data)) !== null; ) {
|
|
737
|
+
const o = n[0], l = n.index, c = l + o.length;
|
|
723
738
|
/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}-${
|
|
739
|
+
id: `${o}-${l}`,
|
|
725
740
|
node: e,
|
|
726
|
-
startOffset:
|
|
741
|
+
startOffset: l,
|
|
727
742
|
endOffset: c,
|
|
728
743
|
word: o,
|
|
729
744
|
suggestions: ae(o),
|
|
@@ -738,64 +753,71 @@ const V = () => {
|
|
|
738
753
|
return s = e, e;
|
|
739
754
|
const t = window.getSelection();
|
|
740
755
|
if (t && t.rangeCount > 0) {
|
|
741
|
-
let
|
|
742
|
-
for (;
|
|
743
|
-
if (
|
|
744
|
-
const o =
|
|
756
|
+
let n = t.getRangeAt(0).startContainer;
|
|
757
|
+
for (; n && n !== document.body; ) {
|
|
758
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
759
|
+
const o = n;
|
|
745
760
|
if (o.getAttribute("contenteditable") === "true")
|
|
746
761
|
return o;
|
|
747
762
|
}
|
|
748
|
-
|
|
763
|
+
n = n.parentNode;
|
|
749
764
|
}
|
|
750
765
|
}
|
|
751
766
|
const r = document.activeElement;
|
|
752
767
|
if (r) {
|
|
753
768
|
if (r.getAttribute("contenteditable") === "true")
|
|
754
769
|
return r;
|
|
755
|
-
const
|
|
756
|
-
if (
|
|
770
|
+
const n = r.closest('[contenteditable="true"]');
|
|
771
|
+
if (n)
|
|
772
|
+
return n;
|
|
757
773
|
const o = r.closest("[data-editora-editor]");
|
|
758
774
|
if (o) {
|
|
759
|
-
const
|
|
760
|
-
if (
|
|
775
|
+
const l = o.querySelector('[contenteditable="true"]');
|
|
776
|
+
if (l)
|
|
777
|
+
return l;
|
|
761
778
|
}
|
|
762
779
|
}
|
|
763
780
|
return document.querySelector('[contenteditable="true"]');
|
|
764
781
|
};
|
|
765
782
|
function M() {
|
|
766
783
|
const e = k();
|
|
767
|
-
if (!e)
|
|
784
|
+
if (!e)
|
|
785
|
+
return [];
|
|
768
786
|
const t = [], r = document.createTreeWalker(
|
|
769
787
|
e,
|
|
770
788
|
NodeFilter.SHOW_TEXT,
|
|
771
789
|
{
|
|
772
|
-
acceptNode: (o) =>
|
|
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
|
+
}
|
|
773
794
|
}
|
|
774
795
|
);
|
|
775
|
-
let
|
|
776
|
-
for (;
|
|
777
|
-
t.push(...ie(
|
|
796
|
+
let n = r.nextNode();
|
|
797
|
+
for (; n; )
|
|
798
|
+
t.push(...ie(n)), n = r.nextNode();
|
|
778
799
|
return t;
|
|
779
800
|
}
|
|
780
801
|
function m(e) {
|
|
781
802
|
const t = k();
|
|
782
803
|
t && (e || (e = M()), N(() => {
|
|
783
804
|
t.querySelectorAll(".rte-misspelled").forEach((r) => {
|
|
784
|
-
const
|
|
785
|
-
if (
|
|
805
|
+
const n = r.parentNode;
|
|
806
|
+
if (n) {
|
|
786
807
|
for (; r.firstChild; )
|
|
787
|
-
|
|
788
|
-
|
|
808
|
+
n.insertBefore(r.firstChild, r);
|
|
809
|
+
n.removeChild(r);
|
|
789
810
|
}
|
|
790
811
|
}), e.forEach((r) => {
|
|
791
|
-
if (S.has(r.word.toLowerCase()))
|
|
792
|
-
|
|
793
|
-
|
|
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))
|
|
794
816
|
try {
|
|
795
817
|
const o = document.createRange();
|
|
796
818
|
o.setStart(r.node, r.startOffset), o.setEnd(r.node, r.endOffset);
|
|
797
|
-
const
|
|
798
|
-
|
|
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);
|
|
799
821
|
} catch {
|
|
800
822
|
}
|
|
801
823
|
});
|
|
@@ -818,8 +840,8 @@ function de(e, t) {
|
|
|
818
840
|
N(() => {
|
|
819
841
|
const r = document.createRange();
|
|
820
842
|
r.setStart(e.node, e.startOffset), r.setEnd(e.node, e.endOffset);
|
|
821
|
-
const
|
|
822
|
-
r.deleteContents(), r.insertNode(
|
|
843
|
+
const n = document.createTextNode(t);
|
|
844
|
+
r.deleteContents(), r.insertNode(n);
|
|
823
845
|
});
|
|
824
846
|
}
|
|
825
847
|
function G(e) {
|
|
@@ -830,13 +852,14 @@ function J(e) {
|
|
|
830
852
|
}
|
|
831
853
|
function pe(e) {
|
|
832
854
|
const t = k();
|
|
833
|
-
if (!t)
|
|
855
|
+
if (!t)
|
|
856
|
+
return { total: 0, misspelled: 0, accuracy: 100 };
|
|
834
857
|
e || (e = M());
|
|
835
|
-
const r = e.filter((c) => !S.has(c.word.toLowerCase())).length,
|
|
858
|
+
const r = e.filter((c) => !S.has(c.word.toLowerCase())).length, l = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
|
|
836
859
|
return {
|
|
837
|
-
total:
|
|
860
|
+
total: l,
|
|
838
861
|
misspelled: r,
|
|
839
|
-
accuracy:
|
|
862
|
+
accuracy: l > 0 ? (l - r) / l * 100 : 100
|
|
840
863
|
};
|
|
841
864
|
}
|
|
842
865
|
function he(e, t) {
|
|
@@ -846,36 +869,36 @@ function he(e, t) {
|
|
|
846
869
|
function ue(e) {
|
|
847
870
|
e.classList.remove("rte-misspelled"), e.removeAttribute("data-word"), e.removeAttribute("data-suggestions"), e.removeAttribute("title"), e.style.borderBottom = "", e.style.cursor = "";
|
|
848
871
|
}
|
|
849
|
-
function me(e, t, r,
|
|
872
|
+
function me(e, t, r, n, o) {
|
|
850
873
|
W(o), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
|
|
851
|
-
const
|
|
852
|
-
if (
|
|
874
|
+
const l = document.createElement("div");
|
|
875
|
+
if (l.className = "rte-spellcheck-menu", n.slice(0, 5).forEach((p) => {
|
|
853
876
|
const v = document.createElement("div");
|
|
854
877
|
v.className = "rte-spellcheck-menu-item", v.textContent = p, v.onclick = () => {
|
|
855
878
|
he(o, p), window.setTimeout(() => {
|
|
856
879
|
u && (m(), E());
|
|
857
|
-
}, 0),
|
|
858
|
-
},
|
|
859
|
-
}),
|
|
880
|
+
}, 0), l.remove();
|
|
881
|
+
}, l.appendChild(v);
|
|
882
|
+
}), n.length > 0) {
|
|
860
883
|
const p = document.createElement("div");
|
|
861
|
-
p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;",
|
|
884
|
+
p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", l.appendChild(p);
|
|
862
885
|
}
|
|
863
886
|
const c = document.createElement("div");
|
|
864
887
|
c.className = "rte-spellcheck-menu-item meta", c.textContent = "Ignore Once", c.onclick = () => {
|
|
865
|
-
ue(o),
|
|
866
|
-
},
|
|
888
|
+
ue(o), l.remove();
|
|
889
|
+
}, l.appendChild(c);
|
|
867
890
|
const i = document.createElement("div");
|
|
868
891
|
i.className = "rte-spellcheck-menu-item meta", i.textContent = "Ignore All", i.onclick = () => {
|
|
869
|
-
G(r),
|
|
870
|
-
},
|
|
892
|
+
G(r), l.remove();
|
|
893
|
+
}, l.appendChild(i);
|
|
871
894
|
const w = document.createElement("div");
|
|
872
895
|
w.className = "rte-spellcheck-menu-item positive", w.textContent = "Add to Dictionary", w.onclick = () => {
|
|
873
|
-
J(r),
|
|
874
|
-
},
|
|
875
|
-
const D =
|
|
876
|
-
|
|
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`;
|
|
877
900
|
const F = (p) => {
|
|
878
|
-
|
|
901
|
+
l.contains(p.target) || (l.remove(), document.removeEventListener("mousedown", F));
|
|
879
902
|
};
|
|
880
903
|
setTimeout(() => document.addEventListener("mousedown", F), 0);
|
|
881
904
|
}
|
|
@@ -884,8 +907,8 @@ function I() {
|
|
|
884
907
|
const t = e.target;
|
|
885
908
|
if (t && t.classList.contains("rte-misspelled")) {
|
|
886
909
|
e.preventDefault(), W(t);
|
|
887
|
-
const r = t.getAttribute("data-word"),
|
|
888
|
-
me(e.clientX, e.clientY, r,
|
|
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);
|
|
889
912
|
}
|
|
890
913
|
}, document.addEventListener("contextmenu", x), y = !0);
|
|
891
914
|
}
|
|
@@ -905,7 +928,8 @@ function q() {
|
|
|
905
928
|
return r.className = "rte-spell-check-panel", window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(r), r;
|
|
906
929
|
}
|
|
907
930
|
function E(e) {
|
|
908
|
-
if (!a)
|
|
931
|
+
if (!a)
|
|
932
|
+
return;
|
|
909
933
|
const t = e || M(), r = pe(t);
|
|
910
934
|
a.innerHTML = `
|
|
911
935
|
<div class="rte-spellcheck-header">
|
|
@@ -932,8 +956,8 @@ function E(e) {
|
|
|
932
956
|
</div>
|
|
933
957
|
|
|
934
958
|
<div class="rte-spellcheck-list">
|
|
935
|
-
${t.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : t.map((o,
|
|
936
|
-
<div class="rte-spellcheck-item" data-word="${o.word}" data-index="${
|
|
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}">
|
|
937
961
|
<button class="rte-spellcheck-word-header" type="button">
|
|
938
962
|
<span class="rte-spellcheck-word">${o.word}</span>
|
|
939
963
|
<span class="rte-spellcheck-caret">▶</span>
|
|
@@ -950,28 +974,30 @@ function E(e) {
|
|
|
950
974
|
</div>
|
|
951
975
|
`).join("")}
|
|
952
976
|
</div>
|
|
953
|
-
|
|
977
|
+
`;
|
|
978
|
+
const n = a.querySelector(".rte-spellcheck-close");
|
|
979
|
+
n == null || n.addEventListener("click", (o) => {
|
|
954
980
|
o.preventDefault(), o.stopPropagation(), O();
|
|
955
981
|
}), a.querySelectorAll(".rte-spellcheck-word-header").forEach((o) => {
|
|
956
982
|
o.addEventListener("click", () => {
|
|
957
|
-
const
|
|
983
|
+
const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
|
|
958
984
|
c && i && (c.classList.contains("show") ? (c.classList.remove("show"), i.textContent = "▶") : (c.classList.add("show"), i.textContent = "▼"));
|
|
959
985
|
});
|
|
960
986
|
}), a.querySelectorAll(".suggestion-btn").forEach((o) => {
|
|
961
987
|
o.addEventListener("click", () => {
|
|
962
|
-
const
|
|
963
|
-
c
|
|
964
|
-
const i = parseInt(c
|
|
965
|
-
t[i] && (de(t[i],
|
|
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());
|
|
966
992
|
});
|
|
967
993
|
}), a.querySelectorAll(".ignore-btn").forEach((o) => {
|
|
968
994
|
o.addEventListener("click", () => {
|
|
969
|
-
const
|
|
995
|
+
const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.getAttribute("data-word");
|
|
970
996
|
G(c);
|
|
971
997
|
});
|
|
972
998
|
}), a.querySelectorAll(".add-btn").forEach((o) => {
|
|
973
999
|
o.addEventListener("click", () => {
|
|
974
|
-
const
|
|
1000
|
+
const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.getAttribute("data-word");
|
|
975
1001
|
J(c);
|
|
976
1002
|
});
|
|
977
1003
|
});
|
|
@@ -983,7 +1009,7 @@ function $() {
|
|
|
983
1009
|
u && m();
|
|
984
1010
|
}, 350));
|
|
985
1011
|
}), d.observe(e, {
|
|
986
|
-
...
|
|
1012
|
+
...B
|
|
987
1013
|
}));
|
|
988
1014
|
}
|
|
989
1015
|
function U() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = () => ({
|
|
2
2
|
name: "strikethrough",
|
|
3
3
|
// Schema definition for strikethrough mark
|
|
4
4
|
marks: {
|
|
@@ -30,15 +30,18 @@ const l = () => ({
|
|
|
30
30
|
* Toggle strikethrough formatting on current selection
|
|
31
31
|
*/
|
|
32
32
|
toggleStrikethrough: () => {
|
|
33
|
-
const t =
|
|
34
|
-
if (!t)
|
|
33
|
+
const t = c();
|
|
34
|
+
if (!t)
|
|
35
|
+
return !1;
|
|
35
36
|
const n = window.getSelection();
|
|
36
|
-
if (!n || n.rangeCount === 0)
|
|
37
|
+
if (!n || n.rangeCount === 0)
|
|
38
|
+
return !1;
|
|
37
39
|
const e = n.getRangeAt(0);
|
|
38
|
-
if (!t.contains(e.commonAncestorContainer))
|
|
40
|
+
if (!t.contains(e.commonAncestorContainer))
|
|
41
|
+
return !1;
|
|
39
42
|
t.focus({ preventScroll: !0 });
|
|
40
43
|
const o = document.execCommand("strikeThrough", !1);
|
|
41
|
-
return
|
|
44
|
+
return s(t), t.dispatchEvent(new Event("input", { bubbles: !0 })), o !== !1;
|
|
42
45
|
}
|
|
43
46
|
},
|
|
44
47
|
// Keyboard shortcuts
|
|
@@ -47,25 +50,27 @@ const l = () => ({
|
|
|
47
50
|
"Mod-Shift-X": "toggleStrikethrough"
|
|
48
51
|
}
|
|
49
52
|
});
|
|
50
|
-
function
|
|
53
|
+
function c() {
|
|
51
54
|
const t = window.getSelection();
|
|
52
55
|
if (t && t.rangeCount > 0) {
|
|
53
|
-
const e = t.getRangeAt(0).startContainer,
|
|
54
|
-
if (r)
|
|
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;
|
|
55
59
|
}
|
|
56
60
|
const n = document.activeElement;
|
|
57
61
|
return n ? n.getAttribute("contenteditable") === "true" ? n : n.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
|
|
58
62
|
}
|
|
59
|
-
function
|
|
63
|
+
function s(t) {
|
|
60
64
|
t.querySelectorAll("strike, del").forEach((e) => {
|
|
65
|
+
var r;
|
|
61
66
|
const o = document.createElement("s");
|
|
62
|
-
for (const
|
|
63
|
-
|
|
67
|
+
for (const i of Array.from(e.attributes))
|
|
68
|
+
i.name !== "style" && o.setAttribute(i.name, i.value);
|
|
64
69
|
for (; e.firstChild; )
|
|
65
70
|
o.appendChild(e.firstChild);
|
|
66
|
-
e.parentNode
|
|
71
|
+
(r = e.parentNode) == null || r.replaceChild(o, e);
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
74
|
export {
|
|
70
|
-
|
|
75
|
+
a as StrikethroughPlugin
|
|
71
76
|
};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.rte-table,table{border-collapse:collapse;width:100%;margin:1rem 0;border:1px solid #ddd;font-size:14px;line-height:1.4;position:relative}.rte-table td,.rte-table th,table td,table th{border:1px solid #ddd;padding:8px 12px;min-width:80px;vertical-align:top;position:relative;-webkit-user-select:none;user-select:none}.rte-table td:focus,.rte-table th:focus,table td:focus,table th:focus{outline:2px solid #007acc;outline-offset:-2px}.rte-table th,table th{background-color:#f8f9fa;font-weight:600;text-align:left}.rte-table td p,table td p{margin:0;padding:0}.rte-table td p:empty:before,table td p:empty:before{content:"";display:inline-block}.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before{content:"Type here...";color:#999;font-style:italic;pointer-events:none}.rte-table tr:hover,table tr:hover{background-color:#f8f9fa}.rte-table td.selected,table td.selected{background-color:#e3f2fd;border-color:#2196f3}.table-toolbar{background:white;border:1px solid #d0d0d0;border-radius:4px;box-shadow:0 2px 8px #0000001a;padding:4px;display:flex;align-items:center;gap:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;min-width:max-content}.toolbar-section{display:flex;align-items:center;gap:2px}.toolbar-divider{width:1px;height:20px;background:#e0e0e0;margin:0 4px}.toolbar-icon-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid transparent;background:transparent;cursor:pointer;color:#333;border-radius:3px;transition:all .2s ease;flex-shrink:0;font-size:14px;line-height:1}.toolbar-icon-btn svg{width:16px;height:16px}.toolbar-icon-btn:hover:not(:disabled){background:#f0f0f0;border-color:#d0d0d0;color:#06c}.toolbar-icon-btn:active:not(:disabled){background:#e8f0ff;border-color:#06c;transform:scale(.95)}.toolbar-icon-btn:disabled{opacity:.4;cursor:not-allowed;color:#ccc}.toolbar-icon-btn-danger{color:#d32f2f}.toolbar-icon-btn-danger:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-danger:active:not(:disabled){background:#ffebee}.toolbar-icon-btn-delete{color:#d32f2f}.toolbar-icon-btn-delete:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-delete:active:not(:disabled){background:#ffebee}.resize-handle{opacity:0;transition:all .15s ease}.resize-handle:hover{opacity:1}td:hover>.resize-handle,th:hover>.resize-handle{opacity:1}.table-resize-handle{position:absolute;bottom:-4px;right:-4px;width:12px;height:12px;background:transparent;cursor:nwse-resize;z-index:10;transition:background .15s ease}.table-resize-handle:after{content:"";position:absolute;bottom:0;right:0;width:8px;height:8px;background:rgba(0,102,204,.3);border-bottom:2px solid #0066cc;border-right:2px solid #0066cc;border-radius:0 0 2px;opacity:0;transition:opacity .15s ease}.table-resize-handle:hover:after{opacity:1}.rte-table:hover .table-resize-handle:after,table:hover .table-resize-handle:after{opacity:1}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table,table){border-color:#607088;background:#24303c;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td,.rte-table th,table td,table th){border-color:#607088;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table th,table th){background:linear-gradient(180deg,#3b4553 0%,#333d4a 100%);color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table tr:hover,table tr:hover){background-color:#58a6ff1f}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td.selected,table td.selected){background-color:#58a6ff47;border-color:#79beff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before){color:#94a3b8}:is([data-theme=dark],.dark,.editora-theme-dark) .table-toolbar{background:linear-gradient(180deg,#2f3844 0%,#2a323c 100%);border-color:#4d596b;box-shadow:0 8px 20px #00000073}.table-toolbar.rte-theme-dark{background:linear-gradient(180deg,#2f3844 0%,#2a323c 100%);border-color:#4d596b;box-shadow:0 8px 20px #00000073}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-divider{background:#4d596b}.table-toolbar.rte-theme-dark .toolbar-divider{background:#4d596b}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn{color:#d7deea;border-color:transparent}.table-toolbar.rte-theme-dark .toolbar-icon-btn{color:#d7deea;border-color:transparent}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg{color:currentColor;fill:currentColor}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg{color:currentColor;fill:currentColor}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}.table-toolbar.rte-theme-dark .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}.table-toolbar.rte-theme-dark .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:disabled{color:#7f8ca1}.table-toolbar.rte-theme-dark .toolbar-icon-btn:disabled{color:#7f8ca1}@media (max-width: 768px){.rte-table,table{font-size:12px}.rte-table td,.rte-table th,table td,table th{padding:4px 6px;min-width:60px}.table-toolbar{padding:3px;gap:0;max-width:90vw;overflow-x:auto}.toolbar-icon-btn{width:26px;height:26px}.toolbar-divider{height:18px}}@media print{.rte-table,table{border:1px solid #000}.rte-table td,.rte-table th,table td,table th{border:1px solid #000;padding:4px}.table-toolbar{display:none}}
|
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-
|
|
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=`
|
|
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=
|
|
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=`
|
|
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
|
-
`,
|
|
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">
|
|
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":()=>(
|
|
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;
|