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