@editora/core 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClearFormattingPlugin.native-DIS6AN2t.mjs → ClearFormattingPlugin.native-B6ro3a1h.mjs} +49 -39
- package/dist/FormatPainterPlugin.native-CsMrKfFU.mjs +676 -0
- package/dist/editora.min.js +1 -1
- package/dist/editora.umd.js +1 -1
- package/dist/{index-CPMGUZfB.js → index-B5BzVUdg.js} +2 -2
- package/dist/{index-DBoj6QfW.mjs → index-YZ5TROdg.mjs} +10 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/plugin-loader.js +3 -0
- package/dist/webcomponent-core.js +4 -2
- package/dist/webcomponent-core.min.js +15 -15
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +23 -18
- package/dist/webcomponent.min.js +684 -684
- package/package.json +1 -1
package/dist/{ClearFormattingPlugin.native-DIS6AN2t.mjs → ClearFormattingPlugin.native-B6ro3a1h.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const T = () => ({
|
|
2
2
|
name: "clearFormatting",
|
|
3
3
|
// Toolbar button configuration
|
|
4
4
|
toolbar: [
|
|
@@ -19,10 +19,10 @@ const C = () => ({
|
|
|
19
19
|
if (!t) return !1;
|
|
20
20
|
const e = window.getSelection();
|
|
21
21
|
if (!e || e.rangeCount === 0) return !1;
|
|
22
|
-
const
|
|
23
|
-
if (!t.contains(
|
|
24
|
-
const
|
|
25
|
-
return t.focus({ preventScroll: !0 }),
|
|
22
|
+
const n = e.getRangeAt(0);
|
|
23
|
+
if (!t.contains(n.commonAncestorContainer)) return !1;
|
|
24
|
+
const r = n.cloneRange();
|
|
25
|
+
return t.focus({ preventScroll: !0 }), C(t, r), y(t, r), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
// Keyboard shortcuts
|
|
@@ -72,7 +72,7 @@ const C = () => ({
|
|
|
72
72
|
function h() {
|
|
73
73
|
const t = window.getSelection();
|
|
74
74
|
if (t && t.rangeCount > 0) {
|
|
75
|
-
const
|
|
75
|
+
const n = t.getRangeAt(0).startContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, o = r == null ? void 0 : r.closest('[contenteditable="true"], .rte-content, .editora-content');
|
|
76
76
|
if (o) return o;
|
|
77
77
|
}
|
|
78
78
|
const e = document.activeElement;
|
|
@@ -82,23 +82,23 @@ function c(t, e) {
|
|
|
82
82
|
try {
|
|
83
83
|
if (typeof t.intersectsNode == "function")
|
|
84
84
|
return t.intersectsNode(e);
|
|
85
|
-
} catch (
|
|
85
|
+
} catch (r) {
|
|
86
86
|
}
|
|
87
|
-
const
|
|
88
|
-
return e.nodeType === Node.ELEMENT_NODE ?
|
|
87
|
+
const n = document.createRange();
|
|
88
|
+
return e.nodeType === Node.ELEMENT_NODE ? n.selectNodeContents(e) : n.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, n) > 0 && t.compareBoundaryPoints(Range.START_TO_END, n) < 0;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
let e = 0,
|
|
92
|
-
for (;
|
|
93
|
-
e += 1,
|
|
90
|
+
function a(t) {
|
|
91
|
+
let e = 0, n = t;
|
|
92
|
+
for (; n && n.parentNode; )
|
|
93
|
+
e += 1, n = n.parentNode;
|
|
94
94
|
return e;
|
|
95
95
|
}
|
|
96
96
|
function m(t) {
|
|
97
97
|
g.forEach((e) => {
|
|
98
98
|
t.style.removeProperty(e);
|
|
99
|
-
}), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.length === 0 && t.removeAttribute("class");
|
|
99
|
+
}), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.contains("rte-format-painted") && t.classList.remove("rte-format-painted"), t.classList.length === 0 && t.removeAttribute("class");
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function i(t) {
|
|
102
102
|
const e = t.parentNode;
|
|
103
103
|
if (e) {
|
|
104
104
|
for (; t.firstChild; )
|
|
@@ -106,27 +106,37 @@ function a(t) {
|
|
|
106
106
|
e.removeChild(t);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function E(t) {
|
|
110
110
|
return t.tagName !== "P" || t.attributes.length > 0 || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, pre, ul, ol");
|
|
111
111
|
}
|
|
112
112
|
function l(t) {
|
|
113
113
|
Array.from(t.children).forEach((e) => {
|
|
114
|
-
|
|
114
|
+
E(e) && e.remove();
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
function s(t) {
|
|
118
|
-
l(t),
|
|
118
|
+
l(t), i(t);
|
|
119
119
|
}
|
|
120
120
|
function f(t) {
|
|
121
|
-
var
|
|
121
|
+
var n;
|
|
122
122
|
const e = document.createElement("p");
|
|
123
|
-
for (Array.from(t.attributes).forEach((
|
|
124
|
-
e.setAttribute(
|
|
123
|
+
for (Array.from(t.attributes).forEach((r) => {
|
|
124
|
+
e.setAttribute(r.name, r.value);
|
|
125
125
|
}); t.firstChild; )
|
|
126
126
|
e.appendChild(t.firstChild);
|
|
127
|
-
e.innerHTML.trim() || (e.innerHTML = "<br>"), (
|
|
127
|
+
e.innerHTML.trim() || (e.innerHTML = "<br>"), (n = t.parentNode) == null || n.replaceChild(e, t);
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function p(t) {
|
|
130
|
+
return !/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName) || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, svg, math");
|
|
131
|
+
}
|
|
132
|
+
function N(t) {
|
|
133
|
+
Array.from(
|
|
134
|
+
t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")
|
|
135
|
+
).sort((n, r) => a(r) - a(n)).forEach((n) => {
|
|
136
|
+
n.isConnected && p(n) && n.remove();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function A(t) {
|
|
130
140
|
if (l(t), t.parentElement instanceof HTMLLIElement) {
|
|
131
141
|
s(t);
|
|
132
142
|
return;
|
|
@@ -137,36 +147,36 @@ function E(t) {
|
|
|
137
147
|
}
|
|
138
148
|
f(t);
|
|
139
149
|
}
|
|
140
|
-
function
|
|
150
|
+
function y(t, e) {
|
|
141
151
|
Array.from(
|
|
142
152
|
t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
|
|
143
|
-
).forEach((
|
|
144
|
-
if (c(e,
|
|
145
|
-
if (
|
|
146
|
-
|
|
153
|
+
).forEach((r) => {
|
|
154
|
+
if (c(e, r) && d.has(r.tagName)) {
|
|
155
|
+
if (r.tagName === "BLOCKQUOTE") {
|
|
156
|
+
A(r);
|
|
147
157
|
return;
|
|
148
158
|
}
|
|
149
|
-
f(
|
|
159
|
+
f(r);
|
|
150
160
|
}
|
|
151
161
|
});
|
|
152
162
|
}
|
|
153
|
-
function
|
|
154
|
-
const
|
|
163
|
+
function C(t, e) {
|
|
164
|
+
const n = Array.from(
|
|
155
165
|
t.querySelectorAll(
|
|
156
166
|
"a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"
|
|
157
167
|
)
|
|
158
168
|
);
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
if (m(
|
|
162
|
-
|
|
169
|
+
n.sort((r, o) => a(o) - a(r)), n.forEach((r) => {
|
|
170
|
+
if (r.isConnected && c(e, r) && !(r.getAttribute("contenteditable") === "false" || r.closest('[contenteditable="false"]'))) {
|
|
171
|
+
if (m(r), u.has(r.tagName)) {
|
|
172
|
+
i(r);
|
|
163
173
|
return;
|
|
164
174
|
}
|
|
165
|
-
|
|
175
|
+
r.tagName === "SPAN" && r.attributes.length === 0 && i(r);
|
|
166
176
|
}
|
|
167
|
-
});
|
|
177
|
+
}), N(t);
|
|
168
178
|
}
|
|
169
179
|
export {
|
|
170
|
-
|
|
180
|
+
T as ClearFormattingPlugin
|
|
171
181
|
};
|
|
172
|
-
//# sourceMappingURL=ClearFormattingPlugin.native-
|
|
182
|
+
//# sourceMappingURL=ClearFormattingPlugin.native-B6ro3a1h.mjs.map
|