@editora/plugins 1.0.20 → 1.0.22
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 +259 -645
- package/dist/a11y-checker.cjs.js +1 -1
- package/dist/a11y-checker.esm.js +18 -18
- package/dist/anchor.cjs.js +6 -6
- package/dist/anchor.esm.js +57 -57
- package/dist/blockquote.cjs.js +1 -1
- package/dist/blockquote.esm.js +31 -31
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +25 -25
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +30 -30
- package/dist/collaboration.cjs.js +8 -8
- package/dist/collaboration.esm.js +1279 -1169
- package/dist/comments.cjs.js +1 -1
- package/dist/comments.esm.js +1 -1
- package/dist/direction.cjs.js +1 -1
- package/dist/direction.esm.js +26 -26
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +26 -26
- package/dist/preview.cjs.js +1 -1
- package/dist/preview.esm.js +3 -3
- package/dist/spell-check.cjs.js +2 -2
- package/dist/spell-check.esm.js +19 -19
- package/dist/template.cjs.js +5 -5
- package/dist/template.esm.js +23 -23
- package/package.json +6 -5
package/dist/comments.cjs.js
CHANGED
|
@@ -351,4 +351,4 @@
|
|
|
351
351
|
margin-right: 0;
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
`,document.head.appendChild(e)}const ee=()=>({name:"comments",toolbar:[{label:"Add Comment",command:"addComment",type:"button",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32"
|
|
354
|
+
`,document.head.appendChild(e)}const ee=()=>({name:"comments",toolbar:[{label:"Add Comment",command:"addComment",type:"button",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect fill="none" width="32" height="32"></rect></svg>'},{label:"Show / Hide Comments",command:"toggleComments",type:"button",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16 1H4V11H8L10 13L12 11H16V1Z" fill="#000000"></path><path d="M2 5V13H7.17157L8.70711 14.5355L7.29289 15.9497L6.34315 15H0V5H2Z" fill="#000000"></path></svg>'}],commands:{addComment:(e,t)=>{q(t),M();const r=u();return r?(r.savedSelection=V(r.root),r.savedSelection&&window.getSelection()?.removeAllRanges(),w(r,!0),d(r),r.panelElement?.querySelector(".new-comment-textarea")?.focus({preventScroll:!0}),!0):!1},toggleComments:(e,t)=>{q(t),M();const r=u();return r?(w(r,!r.panelVisible),r.panelVisible&&d(r),!0):!1}},keymap:{}});exports.CommentsPlugin=ee;
|
package/dist/comments.esm.js
CHANGED
|
@@ -727,7 +727,7 @@ const te = () => ({
|
|
|
727
727
|
// - any other icon reusing the same auto-generated class name would
|
|
728
728
|
// collide with it. Inlined the one declaration it held (fill="none")
|
|
729
729
|
// directly on the rect instead, so there's nothing to leak.
|
|
730
|
-
icon: '<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32"
|
|
730
|
+
icon: '<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect fill="none" width="32" height="32"></rect></svg>'
|
|
731
731
|
},
|
|
732
732
|
{
|
|
733
733
|
label: "Show / Hide Comments",
|
package/dist/direction.cjs.js
CHANGED
|
@@ -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 a='.rte-content, .editora-content, [contenteditable="true"]',T="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",g=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE","TABLE","FIGURE","UL","OL"]),d=e=>g.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",m=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,L=e=>{const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const o=t.querySelector(a);if(o instanceof HTMLElement)return o;if(t.getAttribute("contenteditable")==="true")return t}const r=window.__editoraCommandEditorRoot;if(r instanceof HTMLElement){const o=r.querySelector(a);if(o instanceof HTMLElement)return o;if(r.getAttribute("contenteditable")==="true")return r}const i=window.getSelection();if(i&&i.rangeCount>0){const o=m(i.getRangeAt(0).startContainer),c=o?.closest(a);if(c instanceof HTMLElement)return c;const f=o?.closest(T)?.querySelector(a);if(f instanceof HTMLElement)return f}const l=document.activeElement,s=l instanceof HTMLElement?l.closest(a):null;return s instanceof HTMLElement?s:document.querySelector(a)},C=e=>{const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t},h=(e,n)=>{let t=m(n);for(;t&&t!==e&&e.contains(t);){if(d(t))return t;t=t.parentElement}return d(e)?e:null},u=(e,n)=>{const t=h(e,n);if(!t||t===e)return null;const r=t.closest("li");return r instanceof HTMLElement&&e.contains(r)?r:t},w=(e,n)=>{if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0},R=(e,n)=>{const t=[],r=new Set,i=o=>{!o||r.has(o)||o===n||!n.contains(o)||d(o)&&(r.add(o),t.push(o))};if(e.collapsed)return i(u(n,e.startContainer)),t;i(u(n,e.startContainer)),i(u(n,e.endContainer));const l=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const c=o;return!d(c)||c.closest("li")&&c.tagName!=="LI"?NodeFilter.FILTER_SKIP:w(e,c)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let s=l.nextNode();for(;s;)i(s),s=l.nextNode();return t.length===0&&i(u(n,e.commonAncestorContainer)),t.filter(o=>!t.some(c=>c!==o&&o.contains(c)))},M=(e,n,t)=>{if(n!==t){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,n,t);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}catch{}}},E=(e,n)=>{const t=L(n);if(!t)return!1;const r=C(t);if(!r)return!1;const i=R(r,t);if(i.length===0)return!1;const l=t.innerHTML;i.forEach(o=>{o.setAttribute("dir",e)});const s=t.innerHTML;return l===s?!1:(M(t,l,s),t.dispatchEvent(new window.Event("input",{bubbles:!0})),!0)},p=()=>({name:"direction",toolbar:[{label:"Left to Right",command:"setDirectionLTR",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-l"},{label:"Right to Left",command:"setDirectionRTL",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-r"}],commands:{setDirectionLTR:(e,n)=>{try{return E("ltr",n)}catch(t){return console.error("Failed to set LTR direction:",t),!1}},setDirectionRTL:(e,n)=>{try{return E("rtl",n)}catch(t){return console.error("Failed to set RTL direction:",t),!1}}},keymap:{"Mod-Shift-l":"setDirectionLTR","Mod-Shift-r":"setDirectionRTL"}});exports.DirectionPlugin=p;
|
package/dist/direction.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", g = /* @__PURE__ */ new Set([
|
|
2
2
|
"P",
|
|
3
3
|
"DIV",
|
|
4
4
|
"H1",
|
|
@@ -14,36 +14,36 @@ const l = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data
|
|
|
14
14
|
"FIGURE",
|
|
15
15
|
"UL",
|
|
16
16
|
"OL"
|
|
17
|
-
]), d = (e) =>
|
|
17
|
+
]), d = (e) => g.has(e.tagName) && e.getAttribute("contenteditable") !== "true", m = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, L = (e) => {
|
|
18
18
|
const n = e?.contentElement;
|
|
19
19
|
if (n instanceof HTMLElement) return n;
|
|
20
20
|
const t = e?.editorElement;
|
|
21
21
|
if (t instanceof HTMLElement) {
|
|
22
|
-
const o = t.querySelector(
|
|
22
|
+
const o = t.querySelector(a);
|
|
23
23
|
if (o instanceof HTMLElement) return o;
|
|
24
24
|
if (t.getAttribute("contenteditable") === "true") return t;
|
|
25
25
|
}
|
|
26
26
|
const r = window.__editoraCommandEditorRoot;
|
|
27
27
|
if (r instanceof HTMLElement) {
|
|
28
|
-
const o = r.querySelector(
|
|
28
|
+
const o = r.querySelector(a);
|
|
29
29
|
if (o instanceof HTMLElement) return o;
|
|
30
30
|
if (r.getAttribute("contenteditable") === "true") return r;
|
|
31
31
|
}
|
|
32
32
|
const i = window.getSelection();
|
|
33
33
|
if (i && i.rangeCount > 0) {
|
|
34
|
-
const o = m(i.getRangeAt(0).startContainer), c = o?.closest(
|
|
34
|
+
const o = m(i.getRangeAt(0).startContainer), c = o?.closest(a);
|
|
35
35
|
if (c instanceof HTMLElement) return c;
|
|
36
|
-
const f = o?.closest(T)?.querySelector(
|
|
36
|
+
const f = o?.closest(T)?.querySelector(a);
|
|
37
37
|
if (f instanceof HTMLElement) return f;
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
return s instanceof HTMLElement ? s : document.querySelector(
|
|
41
|
-
},
|
|
39
|
+
const l = document.activeElement, s = l instanceof HTMLElement ? l.closest(a) : null;
|
|
40
|
+
return s instanceof HTMLElement ? s : document.querySelector(a);
|
|
41
|
+
}, C = (e) => {
|
|
42
42
|
const n = window.getSelection();
|
|
43
43
|
if (!n || n.rangeCount === 0) return null;
|
|
44
44
|
const t = n.getRangeAt(0);
|
|
45
45
|
return !e.contains(t.startContainer) || !e.contains(t.endContainer) ? null : t;
|
|
46
|
-
},
|
|
46
|
+
}, h = (e, n) => {
|
|
47
47
|
let t = m(n);
|
|
48
48
|
for (; t && t !== e && e.contains(t); ) {
|
|
49
49
|
if (d(t)) return t;
|
|
@@ -51,11 +51,11 @@ const l = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data
|
|
|
51
51
|
}
|
|
52
52
|
return d(e) ? e : null;
|
|
53
53
|
}, u = (e, n) => {
|
|
54
|
-
const t =
|
|
54
|
+
const t = h(e, n);
|
|
55
55
|
if (!t || t === e) return null;
|
|
56
56
|
const r = t.closest("li");
|
|
57
57
|
return r instanceof HTMLElement && e.contains(r) ? r : t;
|
|
58
|
-
},
|
|
58
|
+
}, w = (e, n) => {
|
|
59
59
|
if (typeof e.intersectsNode == "function")
|
|
60
60
|
try {
|
|
61
61
|
return e.intersectsNode(n);
|
|
@@ -64,26 +64,26 @@ const l = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data
|
|
|
64
64
|
}
|
|
65
65
|
const t = document.createRange();
|
|
66
66
|
return t.selectNode(n), e.compareBoundaryPoints(Range.END_TO_START, t) < 0 && e.compareBoundaryPoints(Range.START_TO_END, t) > 0;
|
|
67
|
-
},
|
|
67
|
+
}, R = (e, n) => {
|
|
68
68
|
const t = [], r = /* @__PURE__ */ new Set(), i = (o) => {
|
|
69
69
|
!o || r.has(o) || o === n || !n.contains(o) || d(o) && (r.add(o), t.push(o));
|
|
70
70
|
};
|
|
71
71
|
if (e.collapsed)
|
|
72
72
|
return i(u(n, e.startContainer)), t;
|
|
73
73
|
i(u(n, e.startContainer)), i(u(n, e.endContainer));
|
|
74
|
-
const
|
|
74
|
+
const l = document.createTreeWalker(
|
|
75
75
|
n,
|
|
76
76
|
NodeFilter.SHOW_ELEMENT,
|
|
77
77
|
{
|
|
78
78
|
acceptNode: (o) => {
|
|
79
79
|
const c = o;
|
|
80
|
-
return !d(c) || c.closest("li") && c.tagName !== "LI" ? NodeFilter.FILTER_SKIP :
|
|
80
|
+
return !d(c) || c.closest("li") && c.tagName !== "LI" ? NodeFilter.FILTER_SKIP : w(e, c) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
|
-
let s =
|
|
84
|
+
let s = l.nextNode();
|
|
85
85
|
for (; s; )
|
|
86
|
-
i(s), s =
|
|
86
|
+
i(s), s = l.nextNode();
|
|
87
87
|
return t.length === 0 && i(u(n, e.commonAncestorContainer)), t.filter((o) => !t.some((c) => c !== o && o.contains(c)));
|
|
88
88
|
}, p = (e, n, t) => {
|
|
89
89
|
if (n !== t) {
|
|
@@ -98,31 +98,31 @@ const l = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}, E = (e, n) => {
|
|
101
|
-
const t =
|
|
101
|
+
const t = L(n);
|
|
102
102
|
if (!t) return !1;
|
|
103
|
-
const r =
|
|
103
|
+
const r = C(t);
|
|
104
104
|
if (!r) return !1;
|
|
105
|
-
const i =
|
|
105
|
+
const i = R(r, t);
|
|
106
106
|
if (i.length === 0) return !1;
|
|
107
|
-
const
|
|
107
|
+
const l = t.innerHTML;
|
|
108
108
|
i.forEach((o) => {
|
|
109
109
|
o.setAttribute("dir", e);
|
|
110
110
|
});
|
|
111
111
|
const s = t.innerHTML;
|
|
112
|
-
return
|
|
113
|
-
},
|
|
112
|
+
return l === s ? !1 : (p(t, l, s), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), !0);
|
|
113
|
+
}, k = () => ({
|
|
114
114
|
name: "direction",
|
|
115
115
|
toolbar: [
|
|
116
116
|
{
|
|
117
117
|
label: "Left to Right",
|
|
118
118
|
command: "setDirectionLTR",
|
|
119
|
-
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g
|
|
119
|
+
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
|
|
120
120
|
shortcut: "Mod-Shift-l"
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
label: "Right to Left",
|
|
124
124
|
command: "setDirectionRTL",
|
|
125
|
-
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g
|
|
125
|
+
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
|
|
126
126
|
shortcut: "Mod-Shift-r"
|
|
127
127
|
}
|
|
128
128
|
],
|
|
@@ -148,5 +148,5 @@ const l = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data
|
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
export {
|
|
151
|
-
|
|
151
|
+
k as DirectionPlugin
|
|
152
152
|
};
|
package/dist/font-family.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("./historyHelpers-Cu8Pk7m1.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("./historyHelpers-Cu8Pk7m1.js"),h=()=>({name:"fontFamily",marks:{fontFamily:{attrs:{family:{default:null}},parseDOM:[{tag:'span[style*="font-family"]',getAttrs:e=>{const t=e.style.fontFamily;return t?{family:t}:!1}},{tag:"font[face]",getAttrs:e=>{const t=e.getAttribute("face");return t?{family:t}:!1}}],toDOM:e=>["span",{style:`font-family: ${e.attrs?.family}`},0]}},toolbar:[{label:"Font Family",command:"setFontFamily",type:"inline-menu",options:[{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Courier New",value:"Courier New, monospace"},{label:"Georgia",value:"Georgia, serif"},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Helvetica",value:"Helvetica, Arial, sans-serif"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Impact",value:"Impact, sans-serif"}],icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M15 4h7v2h-7zm1 4h6v2h-6zm2 4h4v2h-4zM9.307 4l-6 16h2.137l1.875-5h6.363l1.875 5h2.137l-6-16H9.307zm-1.239 9L10.5 6.515 12.932 13H8.068z"></path></g></svg>'}],commands:{setFontFamily:e=>{if(!e)return!1;try{return b(e),!0}catch(n){return console.error("Failed to set font family:",n),!1}}},keymap:{"Mod-Shift-f":"setFontFamily"}}),g="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";function S(e){return!!e.cloneContents().querySelector(g)}function f(e){return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')}function u(e){e&&e.dispatchEvent(new Event("input",{bubbles:!0}))}function A(e,n){const t=document.createElement("span");for(const o of Array.from(e.attributes))o.name==="face"||o.name==="style"||t.setAttribute(o.name,o.value);const r=e.getAttribute("style");for(r&&t.setAttribute("style",r),t.style.fontFamily=n,t.classList.add("rte-font-family");e.firstChild;)t.appendChild(e.firstChild);e.parentNode?.replaceChild(t,e)}function F(e){e.querySelectorAll("span").forEach(t=>{t.childElementCount>0||(t.textContent||"").trim().length>0||t.remove()})}function C(e,n,t){if(S(e))return!1;const r=document.createElement("span");r.style.fontFamily=t,r.className="rte-font-family";try{e.surroundContents(r)}catch{const l=e.extractContents();r.appendChild(l),e.insertNode(r)}const o=document.createRange();return o.selectNodeContents(r),n.removeAllRanges(),n.addRange(o),!0}function b(e){const n=window.getSelection();if(!n||n.rangeCount===0)return;const t=f(n.getRangeAt(0).commonAncestorContainer),r=t?t.innerHTML:null;v(e),t&&r!==null&&p.recordDomHistory(t,r)}function v(e){const n=window.getSelection();if(!n||n.rangeCount===0)return;const t=n.getRangeAt(0),r=t.cloneRange(),o=f(t.commonAncestorContainer);if(t.collapsed)return;const l=t.commonAncestorContainer,s=N(l);if(s&&E(t,s)){s.style.fontFamily=e,s.classList.add("rte-font-family");const a=document.createRange();a.selectNodeContents(s),n.removeAllRanges(),n.addRange(a),u(o);return}if(!o)return;const m=new Set(Array.from(o.querySelectorAll("font[face]"))),d=new Set(Array.from(o.querySelectorAll("span[style*='font-family']")));o.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}const y=e.split(",").map(a=>a.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean)[0]||"Arial";let i=document.execCommand("fontName",!1,y),c=!1;Array.from(o.querySelectorAll("font[face]")).forEach(a=>{m.has(a)||(A(a,e),c=!0)}),Array.from(o.querySelectorAll("span[style*='font-family']")).forEach(a=>{d.has(a)||(a.style.fontFamily=e,a.classList.add("rte-font-family"),c=!0)}),i||(i=C(r,n,e)),(i||c)&&(F(o),u(o))}function N(e){let n=e;for(;n;){if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(t.tagName==="SPAN"&&t.style.fontFamily)return t}n=n.parentNode}return null}function E(e,n){const t=e.startContainer,r=e.endContainer,o=n.contains(t)||t.nodeType===Node.TEXT_NODE&&t.parentElement===n,l=n.contains(r)||r.nodeType===Node.TEXT_NODE&&r.parentElement===n;return o&&l}exports.FontFamilyPlugin=h;
|
package/dist/font-family.esm.js
CHANGED
|
@@ -40,7 +40,7 @@ const R = () => ({
|
|
|
40
40
|
{ label: "Trebuchet MS", value: "Trebuchet MS, sans-serif" },
|
|
41
41
|
{ label: "Impact", value: "Impact, sans-serif" }
|
|
42
42
|
],
|
|
43
|
-
icon: '<svg fill="#000000" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g
|
|
43
|
+
icon: '<svg fill="#000000" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M15 4h7v2h-7zm1 4h6v2h-6zm2 4h4v2h-4zM9.307 4l-6 16h2.137l1.875-5h6.363l1.875 5h2.137l-6-16H9.307zm-1.239 9L10.5 6.515 12.932 13H8.068z"></path></g></svg>'
|
|
44
44
|
}
|
|
45
45
|
],
|
|
46
46
|
commands: {
|
|
@@ -66,16 +66,16 @@ function m(e) {
|
|
|
66
66
|
function f(e) {
|
|
67
67
|
e && e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function A(e, n) {
|
|
70
70
|
const t = document.createElement("span");
|
|
71
71
|
for (const o of Array.from(e.attributes))
|
|
72
72
|
o.name === "face" || o.name === "style" || t.setAttribute(o.name, o.value);
|
|
73
|
-
const
|
|
74
|
-
for (
|
|
73
|
+
const a = e.getAttribute("style");
|
|
74
|
+
for (a && t.setAttribute("style", a), t.style.fontFamily = n, t.classList.add("rte-font-family"); e.firstChild; )
|
|
75
75
|
t.appendChild(e.firstChild);
|
|
76
76
|
e.parentNode?.replaceChild(t, e);
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function S(e) {
|
|
79
79
|
e.querySelectorAll("span").forEach((t) => {
|
|
80
80
|
t.childElementCount > 0 || (t.textContent || "").trim().length > 0 || t.remove();
|
|
81
81
|
});
|
|
@@ -83,34 +83,34 @@ function A(e) {
|
|
|
83
83
|
function C(e, n, t) {
|
|
84
84
|
if (g(e))
|
|
85
85
|
return !1;
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const a = document.createElement("span");
|
|
87
|
+
a.style.fontFamily = t, a.className = "rte-font-family";
|
|
88
88
|
try {
|
|
89
|
-
e.surroundContents(
|
|
89
|
+
e.surroundContents(a);
|
|
90
90
|
} catch {
|
|
91
91
|
const l = e.extractContents();
|
|
92
|
-
|
|
92
|
+
a.appendChild(l), e.insertNode(a);
|
|
93
93
|
}
|
|
94
94
|
const o = document.createRange();
|
|
95
|
-
return o.selectNodeContents(
|
|
95
|
+
return o.selectNodeContents(a), n.removeAllRanges(), n.addRange(o), !0;
|
|
96
96
|
}
|
|
97
97
|
function F(e) {
|
|
98
98
|
const n = window.getSelection();
|
|
99
99
|
if (!n || n.rangeCount === 0) return;
|
|
100
|
-
const t = m(n.getRangeAt(0).commonAncestorContainer),
|
|
101
|
-
b(e), t &&
|
|
100
|
+
const t = m(n.getRangeAt(0).commonAncestorContainer), a = t ? t.innerHTML : null;
|
|
101
|
+
b(e), t && a !== null && p(t, a);
|
|
102
102
|
}
|
|
103
103
|
function b(e) {
|
|
104
104
|
const n = window.getSelection();
|
|
105
105
|
if (!n || n.rangeCount === 0) return;
|
|
106
|
-
const t = n.getRangeAt(0),
|
|
106
|
+
const t = n.getRangeAt(0), a = t.cloneRange(), o = m(t.commonAncestorContainer);
|
|
107
107
|
if (t.collapsed)
|
|
108
108
|
return;
|
|
109
|
-
const l = t.commonAncestorContainer,
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
109
|
+
const l = t.commonAncestorContainer, s = v(l);
|
|
110
|
+
if (s && N(t, s)) {
|
|
111
|
+
s.style.fontFamily = e, s.classList.add("rte-font-family");
|
|
112
|
+
const r = document.createRange();
|
|
113
|
+
r.selectNodeContents(s), n.removeAllRanges(), n.addRange(r), f(o);
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
if (!o) return;
|
|
@@ -126,17 +126,17 @@ function b(e) {
|
|
|
126
126
|
document.execCommand("styleWithCSS", !1, "true");
|
|
127
127
|
} catch {
|
|
128
128
|
}
|
|
129
|
-
const y = e.split(",").map((
|
|
130
|
-
let
|
|
129
|
+
const y = e.split(",").map((r) => r.trim().replace(/^['"]|['"]$/g, "")).filter(Boolean)[0] || "Arial";
|
|
130
|
+
let i = document.execCommand("fontName", !1, y), c = !1;
|
|
131
131
|
Array.from(
|
|
132
132
|
o.querySelectorAll("font[face]")
|
|
133
|
-
).forEach((
|
|
134
|
-
u.has(
|
|
133
|
+
).forEach((r) => {
|
|
134
|
+
u.has(r) || (A(r, e), c = !0);
|
|
135
135
|
}), Array.from(
|
|
136
136
|
o.querySelectorAll("span[style*='font-family']")
|
|
137
|
-
).forEach((
|
|
138
|
-
d.has(
|
|
139
|
-
}),
|
|
137
|
+
).forEach((r) => {
|
|
138
|
+
d.has(r) || (r.style.fontFamily = e, r.classList.add("rte-font-family"), c = !0);
|
|
139
|
+
}), i || (i = C(a, n, e)), (i || c) && (S(o), f(o));
|
|
140
140
|
}
|
|
141
141
|
function v(e) {
|
|
142
142
|
let n = e;
|
|
@@ -151,7 +151,7 @@ function v(e) {
|
|
|
151
151
|
return null;
|
|
152
152
|
}
|
|
153
153
|
function N(e, n) {
|
|
154
|
-
const t = e.startContainer,
|
|
154
|
+
const t = e.startContainer, a = e.endContainer, o = n.contains(t) || t.nodeType === Node.TEXT_NODE && t.parentElement === n, l = n.contains(a) || a.nodeType === Node.TEXT_NODE && a.parentElement === n;
|
|
155
155
|
return o && l;
|
|
156
156
|
}
|
|
157
157
|
export {
|
package/dist/preview.cjs.js
CHANGED
|
@@ -227,4 +227,4 @@
|
|
|
227
227
|
</svg>
|
|
228
228
|
</button>
|
|
229
229
|
</div>
|
|
230
|
-
`;const l=document.createElement("div");l.className="rte-preview-editor-body";const p=document.createElement("div");p.className="rte-preview-editor-content";const c=document.createElement("div");c.className="rte-preview-editor-light-editor",c.innerHTML=t,p.appendChild(c),l.appendChild(p),i.appendChild(n),i.appendChild(l),e.appendChild(i);const d=()=>{e.parentNode&&e.parentNode.removeChild(e),a=!1,s=null,document.removeEventListener("keydown",g)};s=d;const g=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),d())},m=n.querySelector(".rte-preview-editor-close-btn");m&&m.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),d()}),e.addEventListener("click",o=>{o.target===e&&d()}),document.addEventListener("keydown",g),document.body.appendChild(e)},y=()=>({name:"preview",toolbar:[{label:"Preview",command:"togglePreview",icon:'<svg fill="#000000" version="1.1"
|
|
230
|
+
`;const l=document.createElement("div");l.className="rte-preview-editor-body";const p=document.createElement("div");p.className="rte-preview-editor-content";const c=document.createElement("div");c.className="rte-preview-editor-light-editor",c.innerHTML=t,p.appendChild(c),l.appendChild(p),i.appendChild(n),i.appendChild(l),e.appendChild(i);const d=()=>{e.parentNode&&e.parentNode.removeChild(e),a=!1,s=null,document.removeEventListener("keydown",g)};s=d;const g=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),d())},m=n.querySelector(".rte-preview-editor-close-btn");m&&m.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),d()}),e.addEventListener("click",o=>{o.target===e&&d()}),document.addEventListener("keydown",g),document.body.appendChild(e)},y=()=>({name:"preview",toolbar:[{label:"Preview",command:"togglePreview",icon:'<svg fill="#000000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 92 92" enable-background="new 0 0 92 92" xml:space="preserve"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M91.3,43.8C90.6,42.8,74.4,19,46,19C17.6,19,1.4,42.8,0.7,43.8c-0.9,1.3-0.9,3.1,0,4.5 C1.4,49.2,17.6,73,46,73c28.4,0,44.6-23.8,45.3-24.8C92.2,46.9,92.2,45.1,91.3,43.8z M46,65C26.7,65,13.5,51.4,9,46 c4.5-5.5,17.6-19,37-19c19.3,0,32.5,13.6,37,19C78.4,51.5,65.3,65,46,65z M48.3,29.6c-4.4-0.6-8.7,0.5-12.3,3.2c0,0,0,0,0,0 c-7.3,5.5-8.8,15.9-3.3,23.2c2.7,3.6,6.5,5.8,10.9,6.5c0.8,0.1,1.6,0.2,2.3,0.2c3.6,0,7-1.2,9.9-3.3c7.3-5.5,8.8-15.9,3.3-23.2 C56.6,32.5,52.7,30.2,48.3,29.6z M52.3,54.5c-2.2,1.7-5,2.4-7.8,2c-2.8-0.4-5.3-1.9-7-4.1C34.1,47.7,35,41,39.7,37.5 c2.2-1.7,5-2.4,7.8-2c2.8,0.4,5.3,1.9,7,4.1C57.9,44.3,57,51,52.3,54.5z M51.9,40c0.8,0.7,1.2,1.8,1.2,2.8c0,1-0.4,2.1-1.2,2.8 c-0.7,0.7-1.8,1.2-2.8,1.2c-1.1,0-2.1-0.4-2.8-1.2c-0.8-0.8-1.2-1.8-1.2-2.8c0-1.1,0.4-2.1,1.2-2.8c0.7-0.8,1.8-1.2,2.8-1.2 C50.2,38.9,51.2,39.3,51.9,40z"></path> </g></svg>'}],commands:{togglePreview:()=>(a?s?.():x(),!0)},keymap:{}});exports.PreviewPlugin=y;
|
package/dist/preview.esm.js
CHANGED
|
@@ -302,13 +302,13 @@ const w = () => {
|
|
|
302
302
|
}), e.addEventListener("click", (o) => {
|
|
303
303
|
o.target === e && d();
|
|
304
304
|
}), document.addEventListener("keydown", m), document.body.appendChild(e);
|
|
305
|
-
},
|
|
305
|
+
}, k = () => ({
|
|
306
306
|
name: "preview",
|
|
307
307
|
toolbar: [
|
|
308
308
|
{
|
|
309
309
|
label: "Preview",
|
|
310
310
|
command: "togglePreview",
|
|
311
|
-
icon: '<svg fill="#000000" version="1.1"
|
|
311
|
+
icon: '<svg fill="#000000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 92 92" enable-background="new 0 0 92 92" xml:space="preserve"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M91.3,43.8C90.6,42.8,74.4,19,46,19C17.6,19,1.4,42.8,0.7,43.8c-0.9,1.3-0.9,3.1,0,4.5 C1.4,49.2,17.6,73,46,73c28.4,0,44.6-23.8,45.3-24.8C92.2,46.9,92.2,45.1,91.3,43.8z M46,65C26.7,65,13.5,51.4,9,46 c4.5-5.5,17.6-19,37-19c19.3,0,32.5,13.6,37,19C78.4,51.5,65.3,65,46,65z M48.3,29.6c-4.4-0.6-8.7,0.5-12.3,3.2c0,0,0,0,0,0 c-7.3,5.5-8.8,15.9-3.3,23.2c2.7,3.6,6.5,5.8,10.9,6.5c0.8,0.1,1.6,0.2,2.3,0.2c3.6,0,7-1.2,9.9-3.3c7.3-5.5,8.8-15.9,3.3-23.2 C56.6,32.5,52.7,30.2,48.3,29.6z M52.3,54.5c-2.2,1.7-5,2.4-7.8,2c-2.8-0.4-5.3-1.9-7-4.1C34.1,47.7,35,41,39.7,37.5 c2.2-1.7,5-2.4,7.8-2c2.8,0.4,5.3,1.9,7,4.1C57.9,44.3,57,51,52.3,54.5z M51.9,40c0.8,0.7,1.2,1.8,1.2,2.8c0,1-0.4,2.1-1.2,2.8 c-0.7,0.7-1.8,1.2-2.8,1.2c-1.1,0-2.1-0.4-2.8-1.2c-0.8-0.8-1.2-1.8-1.2-2.8c0-1.1,0.4-2.1,1.2-2.8c0.7-0.8,1.8-1.2,2.8-1.2 C50.2,38.9,51.2,39.3,51.9,40z"></path> </g></svg>'
|
|
312
312
|
}
|
|
313
313
|
],
|
|
314
314
|
commands: {
|
|
@@ -317,5 +317,5 @@ const w = () => {
|
|
|
317
317
|
keymap: {}
|
|
318
318
|
});
|
|
319
319
|
export {
|
|
320
|
-
|
|
320
|
+
k as PreviewPlugin
|
|
321
321
|
};
|
package/dist/spell-check.cjs.js
CHANGED
|
@@ -466,7 +466,7 @@
|
|
|
466
466
|
:is([theme="dark"], [data-theme="dark"], .dark, .editora-theme-dark) .rte-spellcheck-menu-item.positive {
|
|
467
467
|
color: #93c5fd;
|
|
468
468
|
}
|
|
469
|
-
`}function h(){if(l&&document.contains(l))return l;const e=
|
|
469
|
+
`}function h(){if(l&&document.contains(l))return l;const e=J();return e&&(l=e),e}function W(e){if(!e)return;const r=(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest('[contenteditable="true"]');r&&(l=r)}function S(e){if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null}function ee(){if(O)return;const e=t=>{const r=t.target;if(!r)return;const a=r.closest('.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]');if(!a)return;const i=a.closest("[data-editora-editor]"),s=S(i);s&&(u=s,l=s)};document.addEventListener("pointerdown",e,!0),O=!0}function te(){const e=P();if(e&&document.contains(e))return l=e,u=null,e;if(u&&document.contains(u)){const t=u;return u=null,l=t,t}return J()}function ie(){f+=1,f===1&&d&&d.disconnect()}function ae(){if(f===0||(f-=1,f>0)||!d)return;const e=h();e&&d.observe(e,B)}function L(e){ie();try{return e()}finally{ae()}}const re=()=>{try{const e=localStorage.getItem("rte-custom-dictionary");e&&JSON.parse(e).forEach(r=>z.add(r.toLowerCase()))}catch(e){console.warn("Failed to load custom dictionary:",e)}},se=()=>{try{const e=Array.from(z);localStorage.setItem("rte-custom-dictionary",JSON.stringify(e))}catch(e){console.warn("Failed to save custom dictionary:",e)}};function ne(e,t){const r=[];for(let a=0;a<=t.length;a++)r[a]=[a];for(let a=0;a<=e.length;a++)r[0][a]=a;for(let a=1;a<=t.length;a++)for(let i=1;i<=e.length;i++)t.charAt(a-1)===e.charAt(i-1)?r[a][i]=r[a-1][i-1]:r[a][i]=Math.min(r[a-1][i-1]+1,r[a][i-1]+1,r[a-1][i]+1);return r[t.length][e.length]}function oe(e){const t=e.toLowerCase();return $.has(t)||z.has(t)||q.has(t)}function le(e,t=5){const r=e.toLowerCase(),i=Array.from($).map(s=>({word:s,distance:ne(r,s)}));return i.sort((s,n)=>s.distance-n.distance),i.filter(s=>s.distance<=3).slice(0,t).map(s=>s.word)}function ce(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;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"))}function de(e){const t=[],r=/([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;let a;for(;(a=r.exec(e.data))!==null;){const i=a[0],s=a.index,n=s+i.length;/https?:\/\//.test(i)||/@/.test(i)||/\{\{.*\}\}/.test(i)||/^\d+$/.test(i)||oe(i)||/[a-z][A-Z]/.test(i)||/-/.test(i)||i[0]===i[0].toUpperCase()&&i.length>1||t.push({id:`${i}-${s}`,node:e,startOffset:s,endOffset:n,word:i,suggestions:le(i),ignored:!1})}return t}const J=()=>{const e=P();if(e&&document.contains(e))return l=e,e;const t=window.getSelection();if(t&&t.rangeCount>0){let a=t.getRangeAt(0).startContainer;for(;a&&a!==document.body;){if(a.nodeType===Node.ELEMENT_NODE){const i=a;if(i.getAttribute("contenteditable")==="true")return i}a=a.parentNode}}const r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const a=r.closest('[contenteditable="true"]');if(a)return a;const i=r.closest("[data-editora-editor]");if(i){const s=i.querySelector('[contenteditable="true"]');if(s)return s}}return document.querySelector('[contenteditable="true"]')};function T(){const e=h();if(!e)return[];const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:i=>!i.textContent?.trim()||i.parentNode&&ce(i.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let a=r.nextNode();for(;a;)t.push(...de(a)),a=r.nextNode();return t}function g(e){const t=h();t&&(e||(e=T()),L(()=>{t.querySelectorAll(".rte-misspelled").forEach(a=>{const i=a.parentNode;if(i){for(;a.firstChild;)i.insertBefore(a.firstChild,a);i.removeChild(a)}}),[...e].sort((a,i)=>i.startOffset-a.startOffset).forEach(a=>{if(q.has(a.word.toLowerCase()))return;const i=a.node.data.length;if(!(a.startOffset<0||a.endOffset>i||a.startOffset>=a.endOffset))try{const s=document.createRange();s.setStart(a.node,a.startOffset),s.setEnd(a.node,a.endOffset);const n=document.createElement("span");n.className="rte-misspelled",n.setAttribute("data-word",a.word),n.setAttribute("data-suggestions",a.suggestions.join(",")),n.setAttribute("title",`Suggestions: ${a.suggestions.join(", ")}`),n.style.borderBottom="2px wavy red",n.style.cursor="pointer",s.surroundContents(n)}catch{}})}),j(e))}function E(){const e=h();e&&L(()=>{e.querySelectorAll(".rte-misspelled").forEach(t=>{const r=t.parentNode;if(r){for(;t.firstChild;)r.insertBefore(t.firstChild,t);r.removeChild(t)}})})}function pe(e,t){L(()=>{const r=document.createRange();r.setStart(e.node,e.startOffset),r.setEnd(e.node,e.endOffset);const a=document.createTextNode(t);r.deleteContents(),r.insertNode(a)})}function U(e){q.add(e.toLowerCase()),E(),g()}function Y(e){z.add(e.toLowerCase()),se(),E(),g()}function ue(e){const t=h();if(!t)return{total:0,misspelled:0,accuracy:100};e||(e=T());const r=e.filter(n=>!q.has(n.word.toLowerCase())).length,s=((t.textContent||"").match(/[\p{L}\p{M}\p{N}]+/gu)||[]).length;return{total:s,misspelled:r,accuracy:s>0?(s-r)/s*100:100}}function me(e,t){const r=document.createTextNode(t);e.replaceWith(r)}function ge(e){e.classList.remove("rte-misspelled"),e.removeAttribute("data-word"),e.removeAttribute("data-suggestions"),e.removeAttribute("title"),e.style.borderBottom="",e.style.cursor=""}function he(e,t,r,a,i){W(i),document.querySelectorAll(".rte-spellcheck-menu").forEach(p=>p.remove());const s=document.createElement("div");if(s.className="rte-spellcheck-menu",a.slice(0,5).forEach(p=>{const w=document.createElement("div");w.className="rte-spellcheck-menu-item",w.textContent=p,w.onclick=()=>{me(i,p),window.setTimeout(()=>{m&&(g(),j())},0),s.remove()},s.appendChild(w)}),a.length>0){const p=document.createElement("div");p.style.cssText="height: 1px; background: #ddd; margin: 4px 0;",s.appendChild(p)}const n=document.createElement("div");n.className="rte-spellcheck-menu-item meta",n.textContent="Ignore Once",n.onclick=()=>{ge(i),s.remove()},s.appendChild(n);const c=document.createElement("div");c.className="rte-spellcheck-menu-item meta",c.textContent="Ignore All",c.onclick=()=>{U(r),s.remove()},s.appendChild(c);const k=document.createElement("div");k.className="rte-spellcheck-menu-item positive",k.textContent="Add to Dictionary",k.onclick=()=>{Y(r),s.remove()},s.appendChild(k),document.body.appendChild(s);const A=s.getBoundingClientRect(),Z=window.innerWidth-A.width-8,G=window.innerHeight-A.height-8;s.style.left=`${Math.max(8,Math.min(e,Z))}px`,s.style.top=`${Math.max(8,Math.min(t,G))}px`;const M=p=>{s.contains(p.target)||(s.remove(),document.removeEventListener("mousedown",M))};setTimeout(()=>document.addEventListener("mousedown",M),0)}function H(){x||(v=e=>{const t=e.target;if(t&&t.classList.contains("rte-misspelled")){e.preventDefault(),W(t);const r=t.getAttribute("data-word"),a=(t.getAttribute("data-suggestions")||"").split(",").filter(i=>i);he(e.clientX,e.clientY,r,a,t)}},document.addEventListener("contextmenu",v),x=!0)}function be(){!x||!v||(document.removeEventListener("contextmenu",v),v=null,x=!1)}function fe(e){return e.closest("[data-editora-editor]")||e.parentElement||e}function _(){const e=h();if(!e)throw new Error("Spell check panel requested without active editor");const t=fe(e);C();const r=document.createElement("div");return r.className="rte-spell-check-panel",window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.appendChild(r),r}function j(e){if(!o)return;const t=e||T(),r=ue(t);o.innerHTML=`
|
|
470
470
|
<div class="rte-spellcheck-header">
|
|
471
471
|
<div>
|
|
472
472
|
<h3 class="rte-spellcheck-title">Spell Check</h3>
|
|
@@ -509,4 +509,4 @@
|
|
|
509
509
|
</div>
|
|
510
510
|
`).join("")}
|
|
511
511
|
</div>
|
|
512
|
-
`,o.querySelector(".rte-spellcheck-close")?.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),N()}),o.querySelectorAll(".rte-spellcheck-word-header").forEach(i=>{i.addEventListener("click",()=>{const n=i.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"),c=i.querySelector(".rte-spellcheck-caret");n&&c&&(n.classList.contains("show")?(n.classList.remove("show"),c.textContent="▶"):(n.classList.add("show"),c.textContent="▼"))})}),o.querySelectorAll(".suggestion-btn").forEach(i=>{i.addEventListener("click",()=>{const s=i.getAttribute("data-suggestion"),n=i.closest(".rte-spellcheck-item"),c=parseInt(n?.getAttribute("data-index")||"0",10);s!==null&&t[c]&&(pe(t[c],s),g())})}),o.querySelectorAll(".ignore-btn").forEach(i=>{i.addEventListener("click",()=>{const s=i.closest(".rte-spellcheck-item")?.getAttribute("data-word");s&&
|
|
512
|
+
`,o.querySelector(".rte-spellcheck-close")?.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),N()}),o.querySelectorAll(".rte-spellcheck-word-header").forEach(i=>{i.addEventListener("click",()=>{const n=i.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"),c=i.querySelector(".rte-spellcheck-caret");n&&c&&(n.classList.contains("show")?(n.classList.remove("show"),c.textContent="▶"):(n.classList.add("show"),c.textContent="▼"))})}),o.querySelectorAll(".suggestion-btn").forEach(i=>{i.addEventListener("click",()=>{const s=i.getAttribute("data-suggestion"),n=i.closest(".rte-spellcheck-item"),c=parseInt(n?.getAttribute("data-index")||"0",10);s!==null&&t[c]&&(pe(t[c],s),g())})}),o.querySelectorAll(".ignore-btn").forEach(i=>{i.addEventListener("click",()=>{const s=i.closest(".rte-spellcheck-item")?.getAttribute("data-word");s&&U(s)})}),o.querySelectorAll(".add-btn").forEach(i=>{i.addEventListener("click",()=>{const s=i.closest(".rte-spellcheck-item")?.getAttribute("data-word");s&&Y(s)})})}function I(){const e=h();e&&(d&&d.disconnect(),d=new MutationObserver(t=>{f>0||t.some(r=>r.type==="characterData"||r.type==="childList")&&(b&&clearTimeout(b),b=window.setTimeout(()=>{m&&g()},350))}),d.observe(e,{...B}))}function V(){d&&(d.disconnect(),d=null),b&&(clearTimeout(b),b=null)}function X(){document.querySelectorAll(".rte-spellcheck-menu").forEach(e=>e.remove())}function R(){y||(y=e=>{e.key!=="Escape"||!m||(e.preventDefault(),e.stopPropagation(),N())},document.addEventListener("keydown",y,!0))}function ye(){y&&(document.removeEventListener("keydown",y,!0),y=null)}function N(){return m&&(E(),V(),be(),X(),o&&(o.remove(),o=null),l=null,u=null,m=!1,ye()),!1}function ve(){const e=te();return e?m&&l&&l!==e?(E(),V(),X(),o&&(o.remove(),o=null),l=e,C(),H(),R(),g(),I(),o=_(),j(),!0):m?N():(l=e,m=!0,C(),H(),R(),g(),I(),o&&(o.remove(),o=null),o=_(),j(),!0):!1}const ke=()=>({name:"spellCheck",init:()=>{re(),ee()},toolbar:[{label:"Spell Check",command:"toggleSpellCheck",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M3 12.5L3.84375 9.5M3.84375 9.5L5 5.38889C5 5.38889 5.25 4.5 6 4.5C6.75 4.5 7 5.38889 7 5.38889L8.15625 9.5M3.84375 9.5H8.15625M9 12.5L8.15625 9.5M13 16.8333L15.4615 19.5L21 13.5M12 8.5H15C16.1046 8.5 17 7.60457 17 6.5C17 5.39543 16.1046 4.5 15 4.5H12V8.5ZM12 8.5H16C17.1046 8.5 18 9.39543 18 10.5C18 11.6046 17.1046 12.5 16 12.5H12V8.5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"F7"}],commands:{toggleSpellCheck:(e,t)=>(Q(t),ve(),!0)},keymap:{F7:"toggleSpellCheck"}});exports.SpellCheckPlugin=ke;
|
package/dist/spell-check.esm.js
CHANGED
|
@@ -10514,7 +10514,7 @@ function C() {
|
|
|
10514
10514
|
function h() {
|
|
10515
10515
|
if (l && document.contains(l))
|
|
10516
10516
|
return l;
|
|
10517
|
-
const e =
|
|
10517
|
+
const e = J();
|
|
10518
10518
|
return e && (l = e), e;
|
|
10519
10519
|
}
|
|
10520
10520
|
function W(e) {
|
|
@@ -10549,7 +10549,7 @@ function te() {
|
|
|
10549
10549
|
const t = u;
|
|
10550
10550
|
return u = null, l = t, t;
|
|
10551
10551
|
}
|
|
10552
|
-
return
|
|
10552
|
+
return J();
|
|
10553
10553
|
}
|
|
10554
10554
|
function ie() {
|
|
10555
10555
|
f += 1, f === 1 && d && d.disconnect();
|
|
@@ -10628,7 +10628,7 @@ function de(e) {
|
|
|
10628
10628
|
}
|
|
10629
10629
|
return t;
|
|
10630
10630
|
}
|
|
10631
|
-
const
|
|
10631
|
+
const J = () => {
|
|
10632
10632
|
const e = P();
|
|
10633
10633
|
if (e && document.contains(e))
|
|
10634
10634
|
return l = e, e;
|
|
@@ -10718,10 +10718,10 @@ function pe(e, t) {
|
|
|
10718
10718
|
r.deleteContents(), r.insertNode(a);
|
|
10719
10719
|
});
|
|
10720
10720
|
}
|
|
10721
|
-
function
|
|
10721
|
+
function U(e) {
|
|
10722
10722
|
q.add(e.toLowerCase()), E(), g();
|
|
10723
10723
|
}
|
|
10724
|
-
function
|
|
10724
|
+
function Y(e) {
|
|
10725
10725
|
z.add(e.toLowerCase()), se(), E(), g();
|
|
10726
10726
|
}
|
|
10727
10727
|
function ue(e) {
|
|
@@ -10762,14 +10762,14 @@ function he(e, t, r, a, i) {
|
|
|
10762
10762
|
}, s.appendChild(n);
|
|
10763
10763
|
const c = document.createElement("div");
|
|
10764
10764
|
c.className = "rte-spellcheck-menu-item meta", c.textContent = "Ignore All", c.onclick = () => {
|
|
10765
|
-
|
|
10765
|
+
U(r), s.remove();
|
|
10766
10766
|
}, s.appendChild(c);
|
|
10767
10767
|
const k = document.createElement("div");
|
|
10768
10768
|
k.className = "rte-spellcheck-menu-item positive", k.textContent = "Add to Dictionary", k.onclick = () => {
|
|
10769
|
-
|
|
10769
|
+
Y(r), s.remove();
|
|
10770
10770
|
}, s.appendChild(k), document.body.appendChild(s);
|
|
10771
|
-
const A = s.getBoundingClientRect(),
|
|
10772
|
-
s.style.left = `${Math.max(8, Math.min(e,
|
|
10771
|
+
const A = s.getBoundingClientRect(), Z = window.innerWidth - A.width - 8, G = window.innerHeight - A.height - 8;
|
|
10772
|
+
s.style.left = `${Math.max(8, Math.min(e, Z))}px`, s.style.top = `${Math.max(8, Math.min(t, G))}px`;
|
|
10773
10773
|
const M = (p) => {
|
|
10774
10774
|
s.contains(p.target) || (s.remove(), document.removeEventListener("mousedown", M));
|
|
10775
10775
|
};
|
|
@@ -10791,7 +10791,7 @@ function be() {
|
|
|
10791
10791
|
function fe(e) {
|
|
10792
10792
|
return e.closest("[data-editora-editor]") || e.parentElement || e;
|
|
10793
10793
|
}
|
|
10794
|
-
function
|
|
10794
|
+
function I() {
|
|
10795
10795
|
const e = h();
|
|
10796
10796
|
if (!e)
|
|
10797
10797
|
throw new Error("Spell check panel requested without active editor");
|
|
@@ -10861,16 +10861,16 @@ function j(e) {
|
|
|
10861
10861
|
}), o.querySelectorAll(".ignore-btn").forEach((i) => {
|
|
10862
10862
|
i.addEventListener("click", () => {
|
|
10863
10863
|
const s = i.closest(".rte-spellcheck-item")?.getAttribute("data-word");
|
|
10864
|
-
s &&
|
|
10864
|
+
s && U(s);
|
|
10865
10865
|
});
|
|
10866
10866
|
}), o.querySelectorAll(".add-btn").forEach((i) => {
|
|
10867
10867
|
i.addEventListener("click", () => {
|
|
10868
10868
|
const s = i.closest(".rte-spellcheck-item")?.getAttribute("data-word");
|
|
10869
|
-
s &&
|
|
10869
|
+
s && Y(s);
|
|
10870
10870
|
});
|
|
10871
10871
|
});
|
|
10872
10872
|
}
|
|
10873
|
-
function
|
|
10873
|
+
function _() {
|
|
10874
10874
|
const e = h();
|
|
10875
10875
|
e && (d && d.disconnect(), d = new MutationObserver((t) => {
|
|
10876
10876
|
f > 0 || t.some((r) => r.type === "characterData" || r.type === "childList") && (b && clearTimeout(b), b = window.setTimeout(() => {
|
|
@@ -10880,13 +10880,13 @@ function R() {
|
|
|
10880
10880
|
...B
|
|
10881
10881
|
}));
|
|
10882
10882
|
}
|
|
10883
|
-
function
|
|
10883
|
+
function V() {
|
|
10884
10884
|
d && (d.disconnect(), d = null), b && (clearTimeout(b), b = null);
|
|
10885
10885
|
}
|
|
10886
|
-
function
|
|
10886
|
+
function X() {
|
|
10887
10887
|
document.querySelectorAll(".rte-spellcheck-menu").forEach((e) => e.remove());
|
|
10888
10888
|
}
|
|
10889
|
-
function
|
|
10889
|
+
function R() {
|
|
10890
10890
|
y || (y = (e) => {
|
|
10891
10891
|
e.key !== "Escape" || !m || (e.preventDefault(), e.stopPropagation(), N());
|
|
10892
10892
|
}, document.addEventListener("keydown", y, !0));
|
|
@@ -10895,11 +10895,11 @@ function ye() {
|
|
|
10895
10895
|
y && (document.removeEventListener("keydown", y, !0), y = null);
|
|
10896
10896
|
}
|
|
10897
10897
|
function N() {
|
|
10898
|
-
return m && (E(),
|
|
10898
|
+
return m && (E(), V(), be(), X(), o && (o.remove(), o = null), l = null, u = null, m = !1, ye()), !1;
|
|
10899
10899
|
}
|
|
10900
10900
|
function ve() {
|
|
10901
10901
|
const e = te();
|
|
10902
|
-
return e ? m && l && l !== e ? (E(),
|
|
10902
|
+
return e ? m && l && l !== e ? (E(), V(), X(), o && (o.remove(), o = null), l = e, C(), H(), R(), g(), _(), o = I(), j(), !0) : m ? N() : (l = e, m = !0, C(), H(), R(), g(), _(), o && (o.remove(), o = null), o = I(), j(), !0) : !1;
|
|
10903
10903
|
}
|
|
10904
10904
|
const ke = () => ({
|
|
10905
10905
|
name: "spellCheck",
|
|
@@ -10910,7 +10910,7 @@ const ke = () => ({
|
|
|
10910
10910
|
{
|
|
10911
10911
|
label: "Spell Check",
|
|
10912
10912
|
command: "toggleSpellCheck",
|
|
10913
|
-
icon: '<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g
|
|
10913
|
+
icon: '<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path d="M3 12.5L3.84375 9.5M3.84375 9.5L5 5.38889C5 5.38889 5.25 4.5 6 4.5C6.75 4.5 7 5.38889 7 5.38889L8.15625 9.5M3.84375 9.5H8.15625M9 12.5L8.15625 9.5M13 16.8333L15.4615 19.5L21 13.5M12 8.5H15C16.1046 8.5 17 7.60457 17 6.5C17 5.39543 16.1046 4.5 15 4.5H12V8.5ZM12 8.5H16C17.1046 8.5 18 9.39543 18 10.5C18 11.6046 17.1046 12.5 16 12.5H12V8.5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
|
|
10914
10914
|
shortcut: "F7"
|
|
10915
10915
|
}
|
|
10916
10916
|
],
|