@editora/core 1.0.5 → 1.0.7
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/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
- package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
- package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
- package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
- package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
- package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
- package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
- package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
- package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
- package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
- package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
- package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
- package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
- package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
- package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
- package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
- package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
- package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
- package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
- package/dist/editora.min.js +10 -10
- package/dist/editora.umd.js +10 -10
- package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
- package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
- package/dist/index-BslAFzmv.mjs +16544 -0
- package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
- package/dist/index.esm.js +2 -2
- package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
- package/dist/plugin-loader.js +15 -15
- package/dist/webcomponent-core.js +241 -224
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +86 -106
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +205 -188
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +477 -402
- package/package.json +16 -10
- package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
- package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
- package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
- package/dist/documentManager-irzj9n3V.mjs +0 -37627
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const j = /* @__PURE__ */ new Set([
|
|
2
2
|
"the",
|
|
3
3
|
"a",
|
|
4
4
|
"an",
|
|
@@ -109,32 +109,44 @@ 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 B = {
|
|
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
|
+
var l;
|
|
121
|
+
const t = (e == null ? void 0 : e.contentElement) || (e == null ? void 0 : e.editorElement) || null;
|
|
122
|
+
if (!(t instanceof HTMLElement)) return;
|
|
123
|
+
const r = t.getAttribute("contenteditable") === "true" ? t : (l = t.querySelector) == null ? void 0 : l.call(t, '[contenteditable="true"]');
|
|
124
|
+
if (r instanceof HTMLElement) {
|
|
125
|
+
s = r, h = r;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
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);
|
|
129
|
+
o && (s = o, h = o);
|
|
130
|
+
}
|
|
131
|
+
function P() {
|
|
120
132
|
if (typeof window == "undefined") return null;
|
|
121
|
-
const e = window[
|
|
133
|
+
const e = window[R];
|
|
122
134
|
if (!(e instanceof HTMLElement)) return null;
|
|
123
|
-
window[
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
135
|
+
window[R] = null;
|
|
136
|
+
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);
|
|
137
|
+
if (t) {
|
|
138
|
+
const n = A(t);
|
|
139
|
+
if (n) return n;
|
|
140
|
+
if (t.getAttribute("contenteditable") === "true") return t;
|
|
129
141
|
}
|
|
130
142
|
if (e.getAttribute("contenteditable") === "true")
|
|
131
143
|
return e;
|
|
132
|
-
const
|
|
133
|
-
return
|
|
144
|
+
const r = e.closest('[contenteditable="true"]');
|
|
145
|
+
return r instanceof HTMLElement ? r : null;
|
|
134
146
|
}
|
|
135
147
|
function T() {
|
|
136
|
-
let e = document.getElementById(
|
|
137
|
-
e || (e = document.createElement("style"), e.id =
|
|
148
|
+
let e = document.getElementById(H);
|
|
149
|
+
e || (e = document.createElement("style"), e.id = H, document.head.appendChild(e)), e.textContent = `
|
|
138
150
|
.rte-spell-check-panel {
|
|
139
151
|
position: absolute;
|
|
140
152
|
top: 12px;
|
|
@@ -607,143 +619,143 @@ function T() {
|
|
|
607
619
|
function k() {
|
|
608
620
|
if (s && document.contains(s))
|
|
609
621
|
return s;
|
|
610
|
-
const e =
|
|
622
|
+
const e = V();
|
|
611
623
|
return e && (s = e), e;
|
|
612
624
|
}
|
|
613
|
-
function
|
|
625
|
+
function W(e) {
|
|
614
626
|
if (!e) return;
|
|
615
|
-
const
|
|
616
|
-
|
|
627
|
+
const t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, r = t == null ? void 0 : t.closest('[contenteditable="true"]');
|
|
628
|
+
r && (s = r);
|
|
617
629
|
}
|
|
618
|
-
function
|
|
630
|
+
function A(e) {
|
|
619
631
|
if (!e) return null;
|
|
620
|
-
const
|
|
621
|
-
return
|
|
632
|
+
const t = e.querySelector('[contenteditable="true"]');
|
|
633
|
+
return t instanceof HTMLElement ? t : null;
|
|
622
634
|
}
|
|
623
|
-
function
|
|
624
|
-
if (
|
|
625
|
-
const e = (
|
|
626
|
-
const
|
|
627
|
-
if (!
|
|
628
|
-
const
|
|
635
|
+
function Q() {
|
|
636
|
+
if (_) return;
|
|
637
|
+
const e = (t) => {
|
|
638
|
+
const r = t.target;
|
|
639
|
+
if (!r) return;
|
|
640
|
+
const n = r.closest(
|
|
629
641
|
'.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]'
|
|
630
642
|
);
|
|
631
|
-
if (!
|
|
632
|
-
const o =
|
|
643
|
+
if (!n) return;
|
|
644
|
+
const o = n.closest("[data-editora-editor]"), l = A(o);
|
|
633
645
|
l && (h = l, s = l);
|
|
634
646
|
};
|
|
635
|
-
document.addEventListener("pointerdown", e, !0),
|
|
647
|
+
document.addEventListener("pointerdown", e, !0), _ = !0;
|
|
636
648
|
}
|
|
637
|
-
function
|
|
638
|
-
const e =
|
|
649
|
+
function ee() {
|
|
650
|
+
const e = P();
|
|
639
651
|
if (e && document.contains(e))
|
|
640
652
|
return s = e, h = null, e;
|
|
641
653
|
if (h && document.contains(h)) {
|
|
642
|
-
const
|
|
643
|
-
return h = null, s =
|
|
654
|
+
const t = h;
|
|
655
|
+
return h = null, s = t, t;
|
|
644
656
|
}
|
|
645
|
-
return
|
|
657
|
+
return V();
|
|
646
658
|
}
|
|
647
|
-
function
|
|
659
|
+
function te() {
|
|
648
660
|
b += 1, b === 1 && d && d.disconnect();
|
|
649
661
|
}
|
|
650
|
-
function
|
|
662
|
+
function re() {
|
|
651
663
|
if (b === 0 || (b -= 1, b > 0) || !d) return;
|
|
652
664
|
const e = k();
|
|
653
|
-
e && d.observe(e,
|
|
665
|
+
e && d.observe(e, B);
|
|
654
666
|
}
|
|
655
|
-
function
|
|
656
|
-
|
|
667
|
+
function N(e) {
|
|
668
|
+
te();
|
|
657
669
|
try {
|
|
658
670
|
return e();
|
|
659
671
|
} finally {
|
|
660
|
-
|
|
672
|
+
re();
|
|
661
673
|
}
|
|
662
674
|
}
|
|
663
|
-
const
|
|
675
|
+
const oe = () => {
|
|
664
676
|
try {
|
|
665
677
|
const e = localStorage.getItem("rte-custom-dictionary");
|
|
666
|
-
e && JSON.parse(e).forEach((
|
|
678
|
+
e && JSON.parse(e).forEach((r) => C.add(r.toLowerCase()));
|
|
667
679
|
} catch (e) {
|
|
668
680
|
console.warn("Failed to load custom dictionary:", e);
|
|
669
681
|
}
|
|
670
|
-
},
|
|
682
|
+
}, le = () => {
|
|
671
683
|
try {
|
|
672
|
-
const e = Array.from(
|
|
684
|
+
const e = Array.from(C);
|
|
673
685
|
localStorage.setItem("rte-custom-dictionary", JSON.stringify(e));
|
|
674
686
|
} catch (e) {
|
|
675
687
|
console.warn("Failed to save custom dictionary:", e);
|
|
676
688
|
}
|
|
677
689
|
};
|
|
678
|
-
function
|
|
679
|
-
const
|
|
680
|
-
for (let
|
|
681
|
-
for (let
|
|
682
|
-
for (let
|
|
690
|
+
function ne(e, t) {
|
|
691
|
+
const r = [];
|
|
692
|
+
for (let n = 0; n <= t.length; n++) r[n] = [n];
|
|
693
|
+
for (let n = 0; n <= e.length; n++) r[0][n] = n;
|
|
694
|
+
for (let n = 1; n <= t.length; n++)
|
|
683
695
|
for (let o = 1; o <= e.length; o++)
|
|
684
|
-
|
|
685
|
-
|
|
696
|
+
t.charAt(n - 1) === e.charAt(o - 1) ? r[n][o] = r[n - 1][o - 1] : r[n][o] = Math.min(
|
|
697
|
+
r[n - 1][o - 1] + 1,
|
|
686
698
|
// substitution
|
|
687
|
-
|
|
699
|
+
r[n][o - 1] + 1,
|
|
688
700
|
// insertion
|
|
689
|
-
|
|
701
|
+
r[n - 1][o] + 1
|
|
690
702
|
// deletion
|
|
691
703
|
);
|
|
692
|
-
return t
|
|
704
|
+
return r[t.length][e.length];
|
|
693
705
|
}
|
|
694
|
-
function
|
|
695
|
-
const
|
|
696
|
-
return
|
|
706
|
+
function ce(e) {
|
|
707
|
+
const t = e.toLowerCase();
|
|
708
|
+
return j.has(t) || C.has(t) || S.has(t);
|
|
697
709
|
}
|
|
698
|
-
function
|
|
699
|
-
const
|
|
700
|
-
return o.sort((l,
|
|
710
|
+
function ae(e, t = 5) {
|
|
711
|
+
const r = e.toLowerCase(), o = Array.from(j).map((l) => ({ word: l, distance: ne(r, l) }));
|
|
712
|
+
return o.sort((l, c) => l.distance - c.distance), o.filter((l) => l.distance <= 3).slice(0, t).map((l) => l.word);
|
|
701
713
|
}
|
|
702
|
-
function
|
|
714
|
+
function se(e) {
|
|
703
715
|
if (e.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
704
|
-
const
|
|
705
|
-
return !!(
|
|
706
|
-
}
|
|
707
|
-
function
|
|
708
|
-
const
|
|
709
|
-
let
|
|
710
|
-
for (; (
|
|
711
|
-
const o =
|
|
712
|
-
/https?:\/\//.test(o) || /@/.test(o) || /\{\{.*\}\}/.test(o) || /^\d+$/.test(o) ||
|
|
716
|
+
const t = e;
|
|
717
|
+
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"));
|
|
718
|
+
}
|
|
719
|
+
function ie(e) {
|
|
720
|
+
const t = [], r = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
|
|
721
|
+
let n;
|
|
722
|
+
for (; (n = r.exec(e.data)) !== null; ) {
|
|
723
|
+
const o = n[0], l = n.index, c = l + o.length;
|
|
724
|
+
/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({
|
|
713
725
|
id: `${o}-${l}`,
|
|
714
726
|
node: e,
|
|
715
727
|
startOffset: l,
|
|
716
|
-
endOffset:
|
|
728
|
+
endOffset: c,
|
|
717
729
|
word: o,
|
|
718
|
-
suggestions:
|
|
730
|
+
suggestions: ae(o),
|
|
719
731
|
ignored: !1
|
|
720
732
|
});
|
|
721
733
|
}
|
|
722
|
-
return
|
|
734
|
+
return t;
|
|
723
735
|
}
|
|
724
|
-
const
|
|
725
|
-
const e =
|
|
736
|
+
const V = () => {
|
|
737
|
+
const e = P();
|
|
726
738
|
if (e && document.contains(e))
|
|
727
739
|
return s = e, e;
|
|
728
|
-
const
|
|
729
|
-
if (
|
|
730
|
-
let
|
|
731
|
-
for (;
|
|
732
|
-
if (
|
|
733
|
-
const o =
|
|
740
|
+
const t = window.getSelection();
|
|
741
|
+
if (t && t.rangeCount > 0) {
|
|
742
|
+
let n = t.getRangeAt(0).startContainer;
|
|
743
|
+
for (; n && n !== document.body; ) {
|
|
744
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
745
|
+
const o = n;
|
|
734
746
|
if (o.getAttribute("contenteditable") === "true")
|
|
735
747
|
return o;
|
|
736
748
|
}
|
|
737
|
-
|
|
749
|
+
n = n.parentNode;
|
|
738
750
|
}
|
|
739
751
|
}
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
if (
|
|
743
|
-
return
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
746
|
-
const o =
|
|
752
|
+
const r = document.activeElement;
|
|
753
|
+
if (r) {
|
|
754
|
+
if (r.getAttribute("contenteditable") === "true")
|
|
755
|
+
return r;
|
|
756
|
+
const n = r.closest('[contenteditable="true"]');
|
|
757
|
+
if (n) return n;
|
|
758
|
+
const o = r.closest("[data-editora-editor]");
|
|
747
759
|
if (o) {
|
|
748
760
|
const l = o.querySelector('[contenteditable="true"]');
|
|
749
761
|
if (l) return l;
|
|
@@ -751,154 +763,154 @@ const B = () => {
|
|
|
751
763
|
}
|
|
752
764
|
return document.querySelector('[contenteditable="true"]');
|
|
753
765
|
};
|
|
754
|
-
function
|
|
766
|
+
function M() {
|
|
755
767
|
const e = k();
|
|
756
768
|
if (!e) return [];
|
|
757
|
-
const
|
|
769
|
+
const t = [], r = document.createTreeWalker(
|
|
758
770
|
e,
|
|
759
771
|
NodeFilter.SHOW_TEXT,
|
|
760
772
|
{
|
|
761
773
|
acceptNode: (o) => {
|
|
762
774
|
var l;
|
|
763
|
-
return !((l = o.textContent) != null && l.trim()) || o.parentNode &&
|
|
775
|
+
return !((l = o.textContent) != null && l.trim()) || o.parentNode && se(o.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
|
|
764
776
|
}
|
|
765
777
|
}
|
|
766
778
|
);
|
|
767
|
-
let
|
|
768
|
-
for (;
|
|
769
|
-
|
|
770
|
-
return
|
|
779
|
+
let n = r.nextNode();
|
|
780
|
+
for (; n; )
|
|
781
|
+
t.push(...ie(n)), n = r.nextNode();
|
|
782
|
+
return t;
|
|
771
783
|
}
|
|
772
784
|
function m(e) {
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
const
|
|
777
|
-
if (
|
|
778
|
-
for (;
|
|
779
|
-
|
|
780
|
-
|
|
785
|
+
const t = k();
|
|
786
|
+
t && (e || (e = M()), N(() => {
|
|
787
|
+
t.querySelectorAll(".rte-misspelled").forEach((r) => {
|
|
788
|
+
const n = r.parentNode;
|
|
789
|
+
if (n) {
|
|
790
|
+
for (; r.firstChild; )
|
|
791
|
+
n.insertBefore(r.firstChild, r);
|
|
792
|
+
n.removeChild(r);
|
|
781
793
|
}
|
|
782
|
-
}), e.forEach((
|
|
783
|
-
if (
|
|
784
|
-
const
|
|
785
|
-
if (!(
|
|
794
|
+
}), e.forEach((r) => {
|
|
795
|
+
if (S.has(r.word.toLowerCase())) return;
|
|
796
|
+
const n = r.node.data.length;
|
|
797
|
+
if (!(r.startOffset < 0 || r.endOffset > n || r.startOffset >= r.endOffset))
|
|
786
798
|
try {
|
|
787
799
|
const o = document.createRange();
|
|
788
|
-
o.setStart(
|
|
800
|
+
o.setStart(r.node, r.startOffset), o.setEnd(r.node, r.endOffset);
|
|
789
801
|
const l = document.createElement("span");
|
|
790
|
-
l.className = "rte-misspelled", l.setAttribute("data-word",
|
|
802
|
+
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);
|
|
791
803
|
} catch (o) {
|
|
792
804
|
}
|
|
793
805
|
});
|
|
794
|
-
}),
|
|
806
|
+
}), E(e));
|
|
795
807
|
}
|
|
796
|
-
function
|
|
808
|
+
function L() {
|
|
797
809
|
const e = k();
|
|
798
|
-
e &&
|
|
799
|
-
e.querySelectorAll(".rte-misspelled").forEach((
|
|
800
|
-
const
|
|
801
|
-
if (
|
|
802
|
-
for (;
|
|
803
|
-
|
|
804
|
-
|
|
810
|
+
e && N(() => {
|
|
811
|
+
e.querySelectorAll(".rte-misspelled").forEach((t) => {
|
|
812
|
+
const r = t.parentNode;
|
|
813
|
+
if (r) {
|
|
814
|
+
for (; t.firstChild; )
|
|
815
|
+
r.insertBefore(t.firstChild, t);
|
|
816
|
+
r.removeChild(t);
|
|
805
817
|
}
|
|
806
818
|
});
|
|
807
819
|
});
|
|
808
820
|
}
|
|
809
|
-
function
|
|
810
|
-
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
821
|
+
function de(e, t) {
|
|
822
|
+
N(() => {
|
|
823
|
+
const r = document.createRange();
|
|
824
|
+
r.setStart(e.node, e.startOffset), r.setEnd(e.node, e.endOffset);
|
|
825
|
+
const n = document.createTextNode(t);
|
|
826
|
+
r.deleteContents(), r.insertNode(n);
|
|
815
827
|
});
|
|
816
828
|
}
|
|
817
|
-
function
|
|
818
|
-
|
|
829
|
+
function G(e) {
|
|
830
|
+
S.add(e.toLowerCase()), L(), m();
|
|
819
831
|
}
|
|
820
|
-
function
|
|
821
|
-
|
|
832
|
+
function J(e) {
|
|
833
|
+
C.add(e.toLowerCase()), le(), L(), m();
|
|
822
834
|
}
|
|
823
|
-
function
|
|
824
|
-
const
|
|
825
|
-
if (!
|
|
826
|
-
e || (e =
|
|
827
|
-
const
|
|
835
|
+
function pe(e) {
|
|
836
|
+
const t = k();
|
|
837
|
+
if (!t) return { total: 0, misspelled: 0, accuracy: 100 };
|
|
838
|
+
e || (e = M());
|
|
839
|
+
const r = e.filter((c) => !S.has(c.word.toLowerCase())).length, l = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
|
|
828
840
|
return {
|
|
829
841
|
total: l,
|
|
830
|
-
misspelled:
|
|
831
|
-
accuracy: l > 0 ? (l -
|
|
842
|
+
misspelled: r,
|
|
843
|
+
accuracy: l > 0 ? (l - r) / l * 100 : 100
|
|
832
844
|
};
|
|
833
845
|
}
|
|
834
|
-
function
|
|
835
|
-
const
|
|
836
|
-
e.replaceWith(
|
|
846
|
+
function he(e, t) {
|
|
847
|
+
const r = document.createTextNode(t);
|
|
848
|
+
e.replaceWith(r);
|
|
837
849
|
}
|
|
838
|
-
function
|
|
850
|
+
function ue(e) {
|
|
839
851
|
e.classList.remove("rte-misspelled"), e.removeAttribute("data-word"), e.removeAttribute("data-suggestions"), e.removeAttribute("title"), e.style.borderBottom = "", e.style.cursor = "";
|
|
840
852
|
}
|
|
841
|
-
function
|
|
842
|
-
|
|
853
|
+
function me(e, t, r, n, o) {
|
|
854
|
+
W(o), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
|
|
843
855
|
const l = document.createElement("div");
|
|
844
|
-
if (l.className = "rte-spellcheck-menu",
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
u && (m(),
|
|
856
|
+
if (l.className = "rte-spellcheck-menu", n.slice(0, 5).forEach((p) => {
|
|
857
|
+
const v = document.createElement("div");
|
|
858
|
+
v.className = "rte-spellcheck-menu-item", v.textContent = p, v.onclick = () => {
|
|
859
|
+
he(o, p), window.setTimeout(() => {
|
|
860
|
+
u && (m(), E());
|
|
849
861
|
}, 0), l.remove();
|
|
850
|
-
}, l.appendChild(
|
|
851
|
-
}),
|
|
862
|
+
}, l.appendChild(v);
|
|
863
|
+
}), n.length > 0) {
|
|
852
864
|
const p = document.createElement("div");
|
|
853
865
|
p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", l.appendChild(p);
|
|
854
866
|
}
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}, l.appendChild(
|
|
867
|
+
const c = document.createElement("div");
|
|
868
|
+
c.className = "rte-spellcheck-menu-item meta", c.textContent = "Ignore Once", c.onclick = () => {
|
|
869
|
+
ue(o), l.remove();
|
|
870
|
+
}, l.appendChild(c);
|
|
859
871
|
const i = document.createElement("div");
|
|
860
872
|
i.className = "rte-spellcheck-menu-item meta", i.textContent = "Ignore All", i.onclick = () => {
|
|
861
|
-
|
|
873
|
+
G(r), l.remove();
|
|
862
874
|
}, l.appendChild(i);
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}, l.appendChild(
|
|
867
|
-
const
|
|
868
|
-
l.style.left = `${Math.max(8, Math.min(e,
|
|
869
|
-
const
|
|
870
|
-
l.contains(p.target) || (l.remove(), document.removeEventListener("mousedown",
|
|
875
|
+
const w = document.createElement("div");
|
|
876
|
+
w.className = "rte-spellcheck-menu-item positive", w.textContent = "Add to Dictionary", w.onclick = () => {
|
|
877
|
+
J(r), l.remove();
|
|
878
|
+
}, l.appendChild(w), document.body.appendChild(l);
|
|
879
|
+
const D = l.getBoundingClientRect(), X = window.innerWidth - D.width - 8, Z = window.innerHeight - D.height - 8;
|
|
880
|
+
l.style.left = `${Math.max(8, Math.min(e, X))}px`, l.style.top = `${Math.max(8, Math.min(t, Z))}px`;
|
|
881
|
+
const F = (p) => {
|
|
882
|
+
l.contains(p.target) || (l.remove(), document.removeEventListener("mousedown", F));
|
|
871
883
|
};
|
|
872
|
-
setTimeout(() => document.addEventListener("mousedown",
|
|
884
|
+
setTimeout(() => document.addEventListener("mousedown", F), 0);
|
|
873
885
|
}
|
|
874
|
-
function
|
|
875
|
-
|
|
876
|
-
const
|
|
877
|
-
if (
|
|
878
|
-
e.preventDefault(),
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
}, document.addEventListener("contextmenu",
|
|
886
|
+
function I() {
|
|
887
|
+
y || (x = (e) => {
|
|
888
|
+
const t = e.target;
|
|
889
|
+
if (t && t.classList.contains("rte-misspelled")) {
|
|
890
|
+
e.preventDefault(), W(t);
|
|
891
|
+
const r = t.getAttribute("data-word"), n = (t.getAttribute("data-suggestions") || "").split(",").filter((o) => o);
|
|
892
|
+
me(e.clientX, e.clientY, r, n, t);
|
|
893
|
+
}
|
|
894
|
+
}, document.addEventListener("contextmenu", x), y = !0);
|
|
883
895
|
}
|
|
884
|
-
function
|
|
885
|
-
!
|
|
896
|
+
function ke() {
|
|
897
|
+
!y || !x || (document.removeEventListener("contextmenu", x), x = null, y = !1);
|
|
886
898
|
}
|
|
887
|
-
function
|
|
899
|
+
function fe(e) {
|
|
888
900
|
return e.closest("[data-editora-editor]") || e.parentElement || e;
|
|
889
901
|
}
|
|
890
|
-
function
|
|
902
|
+
function q() {
|
|
891
903
|
const e = k();
|
|
892
904
|
if (!e)
|
|
893
905
|
throw new Error("Spell check panel requested without active editor");
|
|
894
|
-
const
|
|
906
|
+
const t = fe(e);
|
|
895
907
|
T();
|
|
896
|
-
const
|
|
897
|
-
return
|
|
908
|
+
const r = document.createElement("div");
|
|
909
|
+
return r.className = "rte-spell-check-panel", window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(r), r;
|
|
898
910
|
}
|
|
899
|
-
function
|
|
911
|
+
function E(e) {
|
|
900
912
|
if (!a) return;
|
|
901
|
-
const
|
|
913
|
+
const t = e || M(), r = pe(t);
|
|
902
914
|
a.innerHTML = `
|
|
903
915
|
<div class="rte-spellcheck-header">
|
|
904
916
|
<div>
|
|
@@ -911,20 +923,20 @@ function y(e) {
|
|
|
911
923
|
<div class="rte-spellcheck-stats">
|
|
912
924
|
<div class="rte-spellcheck-stat">
|
|
913
925
|
<span class="rte-spellcheck-stat-label">Total</span>
|
|
914
|
-
<strong class="rte-spellcheck-stat-value">${
|
|
926
|
+
<strong class="rte-spellcheck-stat-value">${r.total}</strong>
|
|
915
927
|
</div>
|
|
916
928
|
<div class="rte-spellcheck-stat">
|
|
917
929
|
<span class="rte-spellcheck-stat-label">Misspelled</span>
|
|
918
|
-
<strong class="rte-spellcheck-stat-value">${
|
|
930
|
+
<strong class="rte-spellcheck-stat-value">${r.misspelled}</strong>
|
|
919
931
|
</div>
|
|
920
932
|
<div class="rte-spellcheck-stat">
|
|
921
933
|
<span class="rte-spellcheck-stat-label">Accuracy</span>
|
|
922
|
-
<strong class="rte-spellcheck-stat-value">${
|
|
934
|
+
<strong class="rte-spellcheck-stat-value">${r.accuracy.toFixed(1)}%</strong>
|
|
923
935
|
</div>
|
|
924
936
|
</div>
|
|
925
937
|
|
|
926
938
|
<div class="rte-spellcheck-list">
|
|
927
|
-
${
|
|
939
|
+
${t.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : t.map((o, l) => `
|
|
928
940
|
<div class="rte-spellcheck-item" data-word="${o.word}" data-index="${l}">
|
|
929
941
|
<button class="rte-spellcheck-word-header" type="button">
|
|
930
942
|
<span class="rte-spellcheck-word">${o.word}</span>
|
|
@@ -932,7 +944,7 @@ function y(e) {
|
|
|
932
944
|
</button>
|
|
933
945
|
<div class="rte-spellcheck-suggestions">
|
|
934
946
|
${o.suggestions.length > 0 ? `<div class="rte-spellcheck-actions">
|
|
935
|
-
${o.suggestions.map((
|
|
947
|
+
${o.suggestions.map((c) => `<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${c}" type="button">${c}</button>`).join("")}
|
|
936
948
|
</div>` : '<div class="rte-spellcheck-subtitle">No suggestions available</div>'}
|
|
937
949
|
<div class="rte-spellcheck-actions">
|
|
938
950
|
<button class="rte-spellcheck-btn ignore-btn" type="button">Ignore</button>
|
|
@@ -943,60 +955,68 @@ function y(e) {
|
|
|
943
955
|
`).join("")}
|
|
944
956
|
</div>
|
|
945
957
|
`;
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
o.preventDefault(), o.stopPropagation(),
|
|
958
|
+
const n = a.querySelector(".rte-spellcheck-close");
|
|
959
|
+
n == null || n.addEventListener("click", (o) => {
|
|
960
|
+
o.preventDefault(), o.stopPropagation(), O();
|
|
949
961
|
}), a.querySelectorAll(".rte-spellcheck-word-header").forEach((o) => {
|
|
950
962
|
o.addEventListener("click", () => {
|
|
951
|
-
const l = o.closest(".rte-spellcheck-item"),
|
|
952
|
-
|
|
963
|
+
const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
|
|
964
|
+
c && i && (c.classList.contains("show") ? (c.classList.remove("show"), i.textContent = "▶") : (c.classList.add("show"), i.textContent = "▼"));
|
|
953
965
|
});
|
|
954
966
|
}), a.querySelectorAll(".suggestion-btn").forEach((o) => {
|
|
955
967
|
o.addEventListener("click", () => {
|
|
956
|
-
const l = o.getAttribute("data-suggestion"),
|
|
957
|
-
|
|
958
|
-
const i = parseInt((
|
|
959
|
-
|
|
968
|
+
const l = o.getAttribute("data-suggestion"), c = o.closest(".rte-spellcheck-item");
|
|
969
|
+
c == null || c.getAttribute("data-word");
|
|
970
|
+
const i = parseInt((c == null ? void 0 : c.getAttribute("data-index")) || "0");
|
|
971
|
+
t[i] && (de(t[i], l), m());
|
|
960
972
|
});
|
|
961
973
|
}), a.querySelectorAll(".ignore-btn").forEach((o) => {
|
|
962
974
|
o.addEventListener("click", () => {
|
|
963
|
-
const l = o.closest(".rte-spellcheck-item"),
|
|
964
|
-
|
|
975
|
+
const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.getAttribute("data-word");
|
|
976
|
+
G(c);
|
|
965
977
|
});
|
|
966
978
|
}), a.querySelectorAll(".add-btn").forEach((o) => {
|
|
967
979
|
o.addEventListener("click", () => {
|
|
968
|
-
const l = o.closest(".rte-spellcheck-item"),
|
|
969
|
-
|
|
980
|
+
const l = o.closest(".rte-spellcheck-item"), c = l == null ? void 0 : l.getAttribute("data-word");
|
|
981
|
+
J(c);
|
|
970
982
|
});
|
|
971
983
|
});
|
|
972
984
|
}
|
|
973
|
-
function
|
|
985
|
+
function $() {
|
|
974
986
|
const e = k();
|
|
975
|
-
e && (d && d.disconnect(), d = new MutationObserver((
|
|
976
|
-
b > 0 ||
|
|
987
|
+
e && (d && d.disconnect(), d = new MutationObserver((t) => {
|
|
988
|
+
b > 0 || t.some((r) => r.type === "characterData" || r.type === "childList") && (f && clearTimeout(f), f = window.setTimeout(() => {
|
|
977
989
|
u && m();
|
|
978
990
|
}, 350));
|
|
979
991
|
}), d.observe(e, {
|
|
980
|
-
|
|
992
|
+
...B
|
|
981
993
|
}));
|
|
982
994
|
}
|
|
983
|
-
function
|
|
995
|
+
function U() {
|
|
984
996
|
d && (d.disconnect(), d = null), f && (clearTimeout(f), f = null);
|
|
985
997
|
}
|
|
986
|
-
function
|
|
998
|
+
function Y() {
|
|
987
999
|
document.querySelectorAll(".rte-spellcheck-menu").forEach((e) => e.remove());
|
|
988
1000
|
}
|
|
989
|
-
function
|
|
990
|
-
|
|
1001
|
+
function z() {
|
|
1002
|
+
g || (g = (e) => {
|
|
1003
|
+
e.key !== "Escape" || !u || (e.preventDefault(), e.stopPropagation(), O());
|
|
1004
|
+
}, document.addEventListener("keydown", g, !0));
|
|
1005
|
+
}
|
|
1006
|
+
function be() {
|
|
1007
|
+
g && (document.removeEventListener("keydown", g, !0), g = null);
|
|
1008
|
+
}
|
|
1009
|
+
function O() {
|
|
1010
|
+
return u && (L(), U(), ke(), Y(), a && (a.remove(), a = null), s = null, h = null, u = !1, be()), !1;
|
|
991
1011
|
}
|
|
992
|
-
function
|
|
993
|
-
const e =
|
|
994
|
-
return e ? u && s && s !== e ? (
|
|
1012
|
+
function ge() {
|
|
1013
|
+
const e = ee();
|
|
1014
|
+
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;
|
|
995
1015
|
}
|
|
996
|
-
const
|
|
1016
|
+
const xe = () => ({
|
|
997
1017
|
name: "spellCheck",
|
|
998
1018
|
init: () => {
|
|
999
|
-
|
|
1019
|
+
oe(), Q();
|
|
1000
1020
|
},
|
|
1001
1021
|
toolbar: [
|
|
1002
1022
|
{
|
|
@@ -1007,13 +1027,13 @@ const ke = () => ({
|
|
|
1007
1027
|
}
|
|
1008
1028
|
],
|
|
1009
1029
|
commands: {
|
|
1010
|
-
toggleSpellCheck: () => (
|
|
1030
|
+
toggleSpellCheck: (e, t) => (K(t), ge(), !0)
|
|
1011
1031
|
},
|
|
1012
1032
|
keymap: {
|
|
1013
1033
|
F7: "toggleSpellCheck"
|
|
1014
1034
|
}
|
|
1015
1035
|
});
|
|
1016
1036
|
export {
|
|
1017
|
-
|
|
1037
|
+
xe as SpellCheckPlugin
|
|
1018
1038
|
};
|
|
1019
|
-
//# sourceMappingURL=SpellCheckPlugin.native-
|
|
1039
|
+
//# sourceMappingURL=SpellCheckPlugin.native-BZB9AewP.mjs.map
|