@editora/plugins 1.0.14 → 1.0.16
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +45 -35
- package/dist/format-painter.cjs.js +1 -0
- package/dist/format-painter.esm.js +666 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +105 -103
- package/index.d.ts +35 -0
- package/package.json +11 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ajay Kumar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# @editora/plugins
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@editora/plugins)
|
|
4
|
+
[](https://github.com/ajaykr089/Editora/blob/main/LICENSE)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://bundlephobia.com/package/@editora/plugins)
|
|
7
|
+
|
|
3
8
|
> [!IMPORTANT]
|
|
4
9
|
> **Live Website:** https://editora-ecosystem.netlify.app/
|
|
5
10
|
> **Storybook:** https://editora-ecosystem-storybook.netlify.app/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=m();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=m();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const r=e.getRangeAt(0);if(!t.contains(r.commonAncestorContainer))return!1;const n=r.cloneRange();return t.focus({preventScroll:!0}),T(t,n),C(t,n),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),d=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),g=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),h=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function m(){const t=window.getSelection();if(t&&t.rangeCount>0){const r=t.getRangeAt(0).startContainer,o=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(o)return o}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function c(t,e){try{if(typeof t.intersectsNode=="function")return t.intersectsNode(e)}catch{}const r=document.createRange();return e.nodeType===Node.ELEMENT_NODE?r.selectNodeContents(e):r.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,r)>0&&t.compareBoundaryPoints(Range.START_TO_END,r)<0}function a(t){let e=0,r=t;for(;r&&r.parentNode;)e+=1,r=r.parentNode;return e}function E(t){h.forEach(e=>{t.style.removeProperty(e)}),(!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")}function i(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function p(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function l(t){Array.from(t.children).forEach(e=>{p(e)&&e.remove()})}function s(t){l(t),i(t)}function f(t){const e=document.createElement("p");for(Array.from(t.attributes).forEach(r=>{e.setAttribute(r.name,r.value)});t.firstChild;)e.appendChild(t.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),t.parentNode?.replaceChild(e,t)}function N(t){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")}function A(t){Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")).sort((r,n)=>a(n)-a(r)).forEach(r=>{r.isConnected&&N(r)&&r.remove()})}function y(t){if(l(t),t.parentElement instanceof HTMLLIElement){s(t);return}if(Array.from(t.childNodes).filter(o=>o.nodeType!==Node.TEXT_NODE||(o.textContent||"").trim()!=="").some(o=>o instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(o.tagName))){s(t);return}f(t)}function C(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(n=>{if(c(e,n)&&g.has(n.tagName)){if(n.tagName==="BLOCKQUOTE"){y(n);return}f(n)}})}function T(t,e){const r=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));r.sort((n,o)=>a(o)-a(n)),r.forEach(n=>{if(n.isConnected&&c(e,n)&&!(n.getAttribute("contenteditable")==="false"||n.closest('[contenteditable="false"]'))){if(E(n),d.has(n.tagName)){i(n);return}n.tagName==="SPAN"&&n.attributes.length===0&&i(n)}}),A(t)}exports.ClearFormattingPlugin=u;
|
|
@@ -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 r = e.getRangeAt(0);
|
|
23
|
+
if (!t.contains(r.commonAncestorContainer)) return !1;
|
|
24
|
+
const n = r.cloneRange();
|
|
25
|
+
return t.focus({ preventScroll: !0 }), C(t, n), y(t, n), 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 r = t.getRangeAt(0).startContainer, o = (r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');
|
|
76
76
|
if (o) return o;
|
|
77
77
|
}
|
|
78
78
|
const e = document.activeElement;
|
|
@@ -84,21 +84,21 @@ function c(t, e) {
|
|
|
84
84
|
return t.intersectsNode(e);
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
|
-
const
|
|
88
|
-
return e.nodeType === Node.ELEMENT_NODE ?
|
|
87
|
+
const r = document.createRange();
|
|
88
|
+
return e.nodeType === Node.ELEMENT_NODE ? r.selectNodeContents(e) : r.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, r) > 0 && t.compareBoundaryPoints(Range.START_TO_END, r) < 0;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
let e = 0,
|
|
92
|
-
for (;
|
|
93
|
-
e += 1,
|
|
90
|
+
function a(t) {
|
|
91
|
+
let e = 0, r = t;
|
|
92
|
+
for (; r && r.parentNode; )
|
|
93
|
+
e += 1, r = r.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,26 +106,36 @@ 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
121
|
const e = document.createElement("p");
|
|
122
|
-
for (Array.from(t.attributes).forEach((
|
|
123
|
-
e.setAttribute(
|
|
122
|
+
for (Array.from(t.attributes).forEach((r) => {
|
|
123
|
+
e.setAttribute(r.name, r.value);
|
|
124
124
|
}); t.firstChild; )
|
|
125
125
|
e.appendChild(t.firstChild);
|
|
126
126
|
e.innerHTML.trim() || (e.innerHTML = "<br>"), t.parentNode?.replaceChild(e, t);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function p(t) {
|
|
129
|
+
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");
|
|
130
|
+
}
|
|
131
|
+
function N(t) {
|
|
132
|
+
Array.from(
|
|
133
|
+
t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")
|
|
134
|
+
).sort((r, n) => a(n) - a(r)).forEach((r) => {
|
|
135
|
+
r.isConnected && p(r) && r.remove();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function A(t) {
|
|
129
139
|
if (l(t), t.parentElement instanceof HTMLLIElement) {
|
|
130
140
|
s(t);
|
|
131
141
|
return;
|
|
@@ -136,35 +146,35 @@ function E(t) {
|
|
|
136
146
|
}
|
|
137
147
|
f(t);
|
|
138
148
|
}
|
|
139
|
-
function
|
|
149
|
+
function y(t, e) {
|
|
140
150
|
Array.from(
|
|
141
151
|
t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
|
|
142
|
-
).forEach((
|
|
143
|
-
if (c(e,
|
|
144
|
-
if (
|
|
145
|
-
|
|
152
|
+
).forEach((n) => {
|
|
153
|
+
if (c(e, n) && d.has(n.tagName)) {
|
|
154
|
+
if (n.tagName === "BLOCKQUOTE") {
|
|
155
|
+
A(n);
|
|
146
156
|
return;
|
|
147
157
|
}
|
|
148
|
-
f(
|
|
158
|
+
f(n);
|
|
149
159
|
}
|
|
150
160
|
});
|
|
151
161
|
}
|
|
152
|
-
function
|
|
153
|
-
const
|
|
162
|
+
function C(t, e) {
|
|
163
|
+
const r = Array.from(
|
|
154
164
|
t.querySelectorAll(
|
|
155
165
|
"a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"
|
|
156
166
|
)
|
|
157
167
|
);
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
if (m(
|
|
161
|
-
|
|
168
|
+
r.sort((n, o) => a(o) - a(n)), r.forEach((n) => {
|
|
169
|
+
if (n.isConnected && c(e, n) && !(n.getAttribute("contenteditable") === "false" || n.closest('[contenteditable="false"]'))) {
|
|
170
|
+
if (m(n), u.has(n.tagName)) {
|
|
171
|
+
i(n);
|
|
162
172
|
return;
|
|
163
173
|
}
|
|
164
|
-
|
|
174
|
+
n.tagName === "SPAN" && n.attributes.length === 0 && i(n);
|
|
165
175
|
}
|
|
166
|
-
});
|
|
176
|
+
}), N(t);
|
|
167
177
|
}
|
|
168
178
|
export {
|
|
169
|
-
|
|
179
|
+
T as ClearFormattingPlugin
|
|
170
180
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E='.rte-content, .editora-content, [contenteditable="true"]',st="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",N="p,div,li,h1,h2,h3,h4,h5,h6,blockquote,pre,td,th",_="ul,ol",y="b,strong,i,em,u,s,strike,font,span",w="td,th",d="data-editora-format-painter-bookmark",O=["link","address","comments","citations","track-changes"],L=["fontFamily","fontSize","color","backgroundColor","textTransform"],at=["textAlign","lineHeight","marginLeft","marginRight"],lt=["listStyleType"],ct=["borderCollapse","borderSpacing","width"],ut=["backgroundColor","textAlign","verticalAlign","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","paddingTop","paddingRight","paddingBottom","paddingLeft"],X={background:"backgroundcolor",bgcolor:"backgroundcolor",blockquote:"block",blocks:"block",font:"fontfamily",fontname:"fontfamily",fontsize:"fontsize",foreground:"color",forecolor:"color",heading:"block",headings:"block",liststyle:"list",lists:"list",strike:"strikethrough",tablecell:"table",tablecells:"table",textcolor:"color",texttransform:"texttransform"},ft='<svg width="24" height="24" focusable="false" viewBox="0 0 24 24"><path d="M17.8 3.2a2.8 2.8 0 0 1 4 4L14 15l-4-4 7.8-7.8Zm-1.4 4.2L19 10l1.4-1.4-2.6-2.6-1.4 1.4Zm-7.8 5 3 3-1.4 1.4c-.5.5-1.2.8-1.9.8H7.2l-1.6 1.6a2.7 2.7 0 0 1-3.8 0 1 1 0 0 1 0-1.4l6.8-5.4Zm-.2 3.2H9l-4.6 3.7c.2 0 .5-.2.7-.4l1.9-1.9c.2-.2.4-.3.7-.3h1.1c.2 0 .5-.1.6-.3l.2-.2-1.2-1.3ZM5.5 3l.7 1.8L8 5.5l-1.8.7L5.5 8l-.7-1.8L3 5.5l1.8-.7L5.5 3Zm3.8 4.4.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2-1.2-.5 1.2-.5.5-1.2Z" fill-rule="evenodd"></path></svg>',v=new WeakMap;let I=null,P=!1,p={ignoredFormats:O,keepActiveAfterMouseApply:!1};const dt=(t={})=>{const e={ignoredFormats:t.ignoredFormats??O,keepActiveAfterMouseApply:t.keepActiveAfterMouseApply??!1};return p=e,{name:"formatPainter",toolbar:[{label:"Format Painter",command:"toggleFormatPainter",icon:ft,shortcut:"Ctrl+Alt+C / Ctrl+Alt+V"}],commands:{retrieveFormats:(n,r)=>Y(r,e),paintFormats:(n,r)=>J(r,e),toggleFormatPainter:(n,r)=>mt(r,e),cancelFormatPainter:(n,r)=>j(r)},initialize:()=>{gt()}}};function Y(t,e=p){const n=C(t);if(!n)return!1;const r=U(n,e);if(!r)return!1;const o=g(n);return o.options=e,o.snapshot=r,I=r,M(n,!1),!0}function J(t,e=p){const n=C(t);if(!n)return!1;const r=g(n);r.options=e;const o=r.snapshot||I;return o?Q(n,o):!1}function mt(t,e=p){const n=C(t);if(!n)return!1;const r=g(n);if(r.options=e,r.active)return h(n,!1),!0;const o=U(n,e);return o?(r.snapshot=o,I=o,h(n,!0),!0):!1}function j(t){const e=C(t);return e?(h(e,!1),!0):(document.querySelectorAll(`${E}.rte-format-painter-active`).forEach(n=>{h(n,!1)}),!0)}function gt(){P||typeof document>"u"||(P=!0,document.addEventListener("keydown",Et,!0),document.addEventListener("mouseup",ht,!0))}function Et(t){const e=t.key.toLowerCase(),n=t.ctrlKey||t.metaKey;if(t.key==="Escape"){j();return}if(!n||!t.altKey||t.shiftKey)return;const r=G()||C();if(r){if(e==="c"){Y({contentElement:r},g(r).options)&&t.preventDefault();return}e==="v"&&J({contentElement:r},g(r).options)&&t.preventDefault()}}function ht(t){const e=t.target;if(e?.closest(".rte-toolbar-wrapper, .editora-toolbar-container"))return;const n=e?.closest(E);if(!(n instanceof HTMLElement))return;const r=g(n);if(!r.active||!r.snapshot)return;const o=window.getSelection();if(!o||o.rangeCount===0||o.getRangeAt(0).collapsed)return;Q(n,r.snapshot)&&!r.options.keepActiveAfterMouseApply&&h(n,!1)}function g(t){let e=v.get(t);return e||(e={snapshot:null,active:!1,options:p},v.set(t,e)),e}function C(t){if(t?.contentElement instanceof HTMLElement)return t.contentElement;const e=D(t?.editorElement??null);if(e)return e;const n=typeof window<"u"?window.__editoraCommandEditorRoot:null,r=D(n);return r||G()||pt()}function D(t){return t?t.matches(E)?t:t.querySelector(E):null}function G(){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0),r=f(e.commonAncestorContainer)?.closest(E);return r instanceof HTMLElement?r:null}function pt(){const t=document.activeElement;if(!(t instanceof HTMLElement))return null;const e=t.closest(E);return e instanceof HTMLElement?e:null}function f(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function U(t,e){const n=window.getSelection(),r=n&&n.rangeCount>0?n.getRangeAt(0):null,o=r?r.collapsed?r.startContainer:r.commonAncestorContainer:null,i=f(o)||t;if(!t.contains(i))return null;const s=ne(e.ignoredFormats),a=nt(i,t),l=i.closest("li"),u=l?.closest(_),m=i.closest(w),it=m?.closest("table");return{inline:Ct(r,i,t,s),block:!c(s,"block")&&a?Nt(a,s):null,list:!c(s,"list")&&u?St(u,l):null,table:c(s,"table")?null:kt(it,m,s),ignoredFormats:s}}function Ct(t,e,n,r){if(!t||t.collapsed)return H(e,r);const i=Tt(t,e,n).map(s=>H(s,r));return bt(i)}function Tt(t,e,n){const r=[],o=document.createTreeWalker(t.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:s=>!n.contains(s)||!t.intersectsNode(s)?NodeFilter.FILTER_REJECT:(s.textContent||"").trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let i=o.nextNode();for(;i&&r.length<64;){const s=f(i);s&&!r.includes(s)&&r.push(s),i=o.nextNode()}return r.length>0?r:[e]}function H(t,e){const n=window.getComputedStyle(t),r={};c(e,"bold")||(r.bold=At(t,n)),c(e,"italic")||(r.italic=yt(t,n)),c(e,"underline")||(r.underline=$(t,n,"underline")),c(e,"strikethrough")||(r.strikethrough=$(t,n,"line-through"));const o={};return L.forEach(i=>{if(c(e,i))return;const s=n[i];Lt(i,s)&&(o[i]=s)}),{marks:r,styles:o}}function bt(t){const e={};["bold","italic","underline","strikethrough"].forEach(o=>{const i=t.map(s=>s.marks[o]).filter(s=>s!=null);i.length!==0&&(e[o]=i.every(Boolean))});const r={};return L.forEach(o=>{const i=t.map(s=>s.styles[o]).filter(s=>!!s);i.length===t.length&&i.every(s=>s===i[0])&&(r[o]=i[0])}),{marks:e,styles:r}}function Nt(t,e){const n=window.getComputedStyle(t),r={};at.forEach(s=>{if(c(e,s))return;const l=t.style[s]||n[s];Rt(s,l)&&(r[s]=l)});const o={},i=t.getAttribute("dir")||t.style.direction;return(i==="ltr"||i==="rtl"||i==="auto")&&(o.dir=i),{tagName:rt(t),styles:r,attrs:o}}function St(t,e){const n={};lt.forEach(i=>{const s=t.style[i]||window.getComputedStyle(t)[i];s&&s!=="disc"&&s!=="decimal"&&(n[i]=s)});const r={};b(t,r,"data-type"),b(t,r,"type");const o={};return e&&(b(e,o,"data-type"),b(e,o,"data-checked")),{tagName:t.tagName.toLowerCase()==="ol"?"ol":"ul",styles:n,attrs:r,itemAttrs:o}}function kt(t,e,n){return!t&&!e?null:{table:t?W(t,ct,n):null,cell:e?W(e,ut,n):null}}function W(t,e,n){const r=window.getComputedStyle(t),o={};return e.forEach(i=>{if(c(n,i))return;const a=t.style[i]||r[i];wt(i,a)&&(o[i]=a)}),{styles:o,attrs:{}}}function At(t,e){if(t.closest("b,strong"))return!0;const n=e.fontWeight;return/^(bold|bolder|[5-9]\d{2,})$/.test(n)}function yt(t,e){return!!t.closest("i,em")||e.fontStyle==="italic"}function $(t,e,n){const r=n==="underline"?"u":"s,strike";return!!t.closest(r)||e.textDecorationLine.includes(n)}function Lt(t,e){return!(!e||t==="backgroundColor"&&(e==="rgba(0, 0, 0, 0)"||e==="transparent")||t==="textTransform"&&e==="none")}function Rt(t,e){return!(!e||t==="textAlign"&&e==="start"||t==="lineHeight"&&e==="normal"||(t==="marginLeft"||t==="marginRight")&&e==="0px")}function wt(t,e){return!(!e||(t==="backgroundColor"||t.endsWith("Color"))&&(e==="rgba(0, 0, 0, 0)"||e==="transparent")||t==="textAlign"&&e==="start"||t==="verticalAlign"&&e==="middle"||t.endsWith("Width")&&e==="0px"||t.endsWith("Style")&&e==="none"||t.startsWith("padding")&&e==="0px"||t==="borderSpacing"&&e==="0px"||t==="width"&&e==="auto")}function Q(t,e){const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const r=n.getRangeAt(0);if(!t.contains(r.startContainer)||!t.contains(r.endContainer))return!1;const o=t.innerHTML,i=!r.collapsed,s=jt(t);Mt(t,r,e.table),Ft(t,r,e),s?.();const a=window.getSelection(),l=a&&a.rangeCount>0?a.getRangeAt(0):null;i&&a&&l&&t.contains(l.startContainer)&&t.contains(l.endContainer)&&_t(l,a,e),Qt(t),te(t);const u=t.innerHTML;return o===u?!1:(ee(t,o,u),t.dispatchEvent(new Event("input",{bubbles:!0})),!0)}function Ft(t,e,n){const r=Yt(t,e);n.list&&Kt(r,n.list),n.block&&r.forEach(o=>{const i=o.isConnected?o:null;if(!i)return;const s=Zt(i,n.block.tagName);S(s,n.block.styles),n.block.attrs.dir?s.setAttribute("dir",n.block.attrs.dir):s.removeAttribute("dir")})}function Mt(t,e,n){if(!n)return;const r=Vt(t,e);if(n.cell&&r.forEach(i=>{S(i,n.cell.styles)}),!n.table)return;const o=new Set;if(r.forEach(i=>{const s=i.closest("table");s instanceof HTMLElement&&o.add(s)}),o.size===0){const i=f(e.startContainer)?.closest("table");i instanceof HTMLElement&&t.contains(i)&&o.add(i)}o.forEach(i=>{S(i,n.table.styles)})}function _t(t,e,n){Pt(t);const r=n.inline,o=t.cloneContents();if(Jt(o)){Ot(t,e,n);return}const i=t.extractContents();zt(i,n);const s=document.createDocumentFragment(),a=K("start"),l=K("end");s.appendChild(a),s.appendChild(et(i,r)),s.appendChild(l),t.insertNode(s),Ht(a,l,n);const u=document.createRange();u.setStartAfter(a),u.setEndBefore(l),e.removeAllRanges(),e.addRange(u)}function Ot(t,e,n){const r=It(t),o=[];if(r.forEach(s=>{let a=xt(s,t);if(!a||!a.data.trim()||qt(a))return;a=Bt(a,n);const l=et(document.createTextNode(a.data),n.inline);a.parentNode?.replaceChild(l,a),o.push(l)}),o.length===0)return;const i=document.createRange();i.setStartBefore(o[0]),i.setEndAfter(o[o.length-1]),e.removeAllRanges(),e.addRange(i)}function It(t){if(t.startContainer===t.endContainer&&t.startContainer.nodeType===Node.TEXT_NODE)return[t.startContainer];const e=[],n=document.createTreeWalker(t.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:o=>!o.textContent||!o.textContent.trim()||!t.intersectsNode(o)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let r=n.nextNode();for(;r;)e.push(r),r=n.nextNode();return e}function xt(t,e){const n=t.data.length;let r=0,o=n;if(t===e.startContainer&&(r=Math.max(0,Math.min(e.startOffset,n))),t===e.endContainer&&(o=Math.max(0,Math.min(e.endOffset,n))),r>=o)return null;let i=t;return o<i.data.length&&i.splitText(o),r>0&&(i=i.splitText(r)),i}function Bt(t,e){let n=t,r=n.parentElement;for(;r&&r.matches(y)&&!x(r,e)&&tt(r,e);)vt(r,n),r=n.parentElement;return n}function vt(t,e){const n=t.parentNode;if(!n||e.parentNode!==t)return;const r=t.cloneNode(!1),o=t.cloneNode(!1);for(;t.firstChild&&t.firstChild!==e;)r.appendChild(t.firstChild);for(;e.nextSibling;)o.appendChild(e.nextSibling);q(r)&&n.insertBefore(r,t),n.insertBefore(e,t),q(o)&&n.insertBefore(o,t),n.removeChild(t)}function q(t){return Array.from(t.childNodes).some(e=>e.nodeType!==Node.TEXT_NODE?!0:!!(e.textContent||"").trim())}function Pt(t){let e=f(t.startContainer),n=f(t.endContainer);for(;e&&e===n&&e.matches(y);){if(!Dt(t,e))return;t.selectNode(e),e=e.parentElement,n=f(t.endContainer)}}function Dt(t,e){const n=document.createRange();return n.selectNodeContents(e),t.compareBoundaryPoints(Range.START_TO_START,n)===0&&t.compareBoundaryPoints(Range.END_TO_END,n)===0}function Ht(t,e,n){let r=f(t.parentNode);for(;r&&r.contains(e);){const o=r.parentElement;r.matches(y)&&!x(r,n)&&Wt(r,t,e)&&tt(r,n)&&k(r),r=o}}function Wt(t,e,n){let r="before";for(const o of Array.from(t.childNodes)){if(o===e){r="inside";continue}if(o===n){r="after";continue}if(r!=="inside"&&!$t(o))return!1}return r==="after"}function $t(t){return t.nodeType===Node.TEXT_NODE?!(t.textContent||"").replace(/\uFEFF/g,"").trim():t.nodeType===Node.COMMENT_NODE?ot(t):t.nodeType!==Node.ELEMENT_NODE?!0:t.hasAttribute(d)}function tt(t,e){return t.matches("span")?L.some(n=>!c(e.ignoredFormats,n)):t.matches("b,strong")?!c(e.ignoredFormats,"bold"):t.matches("i,em")?!c(e.ignoredFormats,"italic"):t.matches("u")?!c(e.ignoredFormats,"underline"):t.matches("s,strike")?!c(e.ignoredFormats,"strikethrough"):!0}function qt(t){return t.nodeType!==Node.TEXT_NODE||(t.textContent||"").trim()?!1:!!t.parentElement?.matches(_)}function et(t,e){let n=t;const r=Object.entries(e.styles);if(r.length>0){const o=document.createElement("span");o.classList.add("rte-format-painted"),r.forEach(([i,s])=>{o.style.setProperty(B(i),s)}),o.appendChild(n),n=o}return e.marks.strikethrough&&(n=T("s",n)),e.marks.underline&&(n=T("u",n)),e.marks.italic&&(n=T("i",n)),e.marks.bold&&(n=T("b",n)),n}function T(t,e){const n=document.createElement(t);return n.appendChild(e),n}function zt(t,e){Array.from(t.querySelectorAll(y)).forEach(n=>{if(n instanceof HTMLElement&&!x(n,e)){if(n.matches("span")){if(L.forEach(r=>{c(e.ignoredFormats,r)||n.style.removeProperty(B(r))}),n.getAttribute("style")||n.attributes.length>0)return;k(n);return}n.matches("b,strong")&&c(e.ignoredFormats,"bold")||n.matches("i,em")&&c(e.ignoredFormats,"italic")||n.matches("u")&&c(e.ignoredFormats,"underline")||n.matches("s,strike")&&c(e.ignoredFormats,"strikethrough")||k(n)}})}function x(t,e){return!!(t.matches("a")&&c(e.ignoredFormats,"link")||R(t,"comment")&&c(e.ignoredFormats,"comments")||R(t,"citation")&&c(e.ignoredFormats,"citations")||R(t,"track")&&c(e.ignoredFormats,"trackchanges"))}function R(t,e){const n=e.toLowerCase();return t.className.toString().toLowerCase().includes(n)?!0:Array.from(t.attributes).some(o=>{const i=A(o.name),s=o.value.toLowerCase();return i.includes(n)||s.includes(n)})}function Kt(t,e){t.filter(r=>r.tagName.toLowerCase()==="li").forEach(r=>{const o=r.closest(_);if(!o)return;const i=Xt(o,e.tagName);S(i,e.styles),Z(i,e.attrs),Z(r,e.itemAttrs)})}function Vt(t,e){const n=Array.from(t.querySelectorAll(w)).filter(o=>o instanceof HTMLElement&&e.intersectsNode(o));if(n.length>0)return n;const r=f(e.startContainer)?.closest(w);return r instanceof HTMLElement&&t.contains(r)?[r]:[]}function S(t,e){Object.entries(e).forEach(([n,r])=>{t.style.setProperty(B(n),r)})}function Zt(t,e){const n=rt(t);if(n===e||n==="li"||n==="td"||n==="th")return t;if(e==="blockquote"){const o=document.createElement("blockquote");for(;t.firstChild;)o.appendChild(t.firstChild);return F(t,o),t.parentNode?.replaceChild(o,t),o}if(!/^(p|div|h[1-6]|pre)$/.test(e))return t;const r=document.createElement(e);for(;t.firstChild;)r.appendChild(t.firstChild);return F(t,r),t.parentNode?.replaceChild(r,t),r}function Xt(t,e){if(t.tagName.toLowerCase()===e)return t;const n=document.createElement(e);for(;t.firstChild;)n.appendChild(t.firstChild);return F(t,n),t.parentNode?.replaceChild(n,t),n}function Yt(t,e){const n=Array.from(t.querySelectorAll(N)).filter(o=>o instanceof HTMLElement&&e.intersectsNode(o));if(n.length>0)return n.filter(o=>!n.some(i=>i!==o&&i.contains(o)));const r=nt(f(e.startContainer),t);return r?[r]:[]}function nt(t,e){const n=t?.closest(N);return n instanceof HTMLElement&&e.contains(n)?n:null}function rt(t){const e=t.tagName.toLowerCase();return e==="blockquote"||/^h[1-6]$/.test(e)||e==="pre"||e==="li"||e==="td"||e==="th"?e:"p"}function Jt(t){return Array.from(t.childNodes).some(e=>{if(e.nodeType!==Node.ELEMENT_NODE)return!1;const n=e;return n.matches(N)||!!n.querySelector(N)})}function jt(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(!t.contains(n.startContainer)||!t.contains(n.endContainer))return null;const r=n.collapsed,o=z("start"),i=z("end"),s=n.cloneRange();if(!r){const l=s.cloneRange();l.collapse(!1),l.insertNode(i)}const a=s.cloneRange();return a.collapse(!0),a.insertNode(o),()=>{const l=V(t,"start"),u=V(t,"end");if(!l)return;const m=document.createRange();r||!u?(m.setStartAfter(l),m.collapse(!0)):(m.setStartAfter(l),m.setEndBefore(u)),e.removeAllRanges(),e.addRange(m)}}function z(t){return document.createComment(`${d}:selection:${t}`)}function K(t){return document.createComment(`${d}:inline:${t}`)}function ot(t){return Gt(t)||Ut(t)}function Gt(t){return t.nodeType===Node.COMMENT_NODE&&(t.nodeValue===`${d}:selection:start`||t.nodeValue===`${d}:selection:end`)}function Ut(t){return t.nodeType===Node.COMMENT_NODE&&(t.nodeValue===`${d}:inline:start`||t.nodeValue===`${d}:inline:end`)}function V(t,e){const n=`${d}:selection:${e}`,r=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT);let o=r.nextNode();for(;o;){if(o.nodeValue===n)return o;o=r.nextNode()}return null}function Qt(t){t.querySelectorAll(`[${d}]`).forEach(o=>o.remove());const e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];let r=e.nextNode();for(;r;)ot(r)&&n.push(r),r=e.nextNode();n.forEach(o=>o.remove())}function te(t){t.querySelectorAll("span").forEach(e=>{e instanceof HTMLElement&&(e.attributes.length>0||k(e))})}function k(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function b(t,e,n){const r=t.getAttribute(n);r!=null&&(e[n]=r)}function Z(t,e){["data-type","data-checked","type"].forEach(n=>{e[n]!=null&&t.setAttribute(n,e[n])})}function F(t,e){Array.from(t.attributes).forEach(n=>{n.name!=="style"&&e.setAttribute(n.name,n.value)})}function h(t,e){const n=g(t);if(n.active===e&&t.classList.contains("rte-format-painter-active")===e){M(t,e);return}n.active=e,t.classList.toggle("rte-format-painter-active",e),M(t,e)}function M(t,e){const n=t.closest(st)||document;n.querySelectorAll('[data-command="toggleFormatPainter"], [data-command="formatPainter"]').forEach(o=>{o instanceof HTMLElement&&(o.classList.toggle("active",e),o.setAttribute("data-active",e?"true":"false"),o.setAttribute("aria-pressed",e?"true":"false"))}),n.dispatchEvent(new CustomEvent("editora:format-painter-toggle",{bubbles:!0,detail:{active:e}}))}function ee(t,e,n){if(e===n)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch{try{r("recordDomTransaction",t,e,n)}catch{}}}function ne(t){return(t??O).map(A).map(e=>X[e]||e).filter(Boolean)}function c(t,e){const n=X[A(e)]||A(e);return t.includes(n)}function A(t){return t.toLowerCase().replace(/[^a-z0-9]/g,"")}function B(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}exports.FormatPainterPlugin=dt;
|
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
const E = '.rte-content, .editora-content, [contenteditable="true"]', st = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", N = "p,div,li,h1,h2,h3,h4,h5,h6,blockquote,pre,td,th", _ = "ul,ol", y = "b,strong,i,em,u,s,strike,font,span", w = "td,th", d = "data-editora-format-painter-bookmark", O = ["link", "address", "comments", "citations", "track-changes"], L = [
|
|
2
|
+
"fontFamily",
|
|
3
|
+
"fontSize",
|
|
4
|
+
"color",
|
|
5
|
+
"backgroundColor",
|
|
6
|
+
"textTransform"
|
|
7
|
+
], at = [
|
|
8
|
+
"textAlign",
|
|
9
|
+
"lineHeight",
|
|
10
|
+
"marginLeft",
|
|
11
|
+
"marginRight"
|
|
12
|
+
], lt = ["listStyleType"], ct = [
|
|
13
|
+
"borderCollapse",
|
|
14
|
+
"borderSpacing",
|
|
15
|
+
"width"
|
|
16
|
+
], ut = [
|
|
17
|
+
"backgroundColor",
|
|
18
|
+
"textAlign",
|
|
19
|
+
"verticalAlign",
|
|
20
|
+
"borderTopColor",
|
|
21
|
+
"borderRightColor",
|
|
22
|
+
"borderBottomColor",
|
|
23
|
+
"borderLeftColor",
|
|
24
|
+
"borderTopStyle",
|
|
25
|
+
"borderRightStyle",
|
|
26
|
+
"borderBottomStyle",
|
|
27
|
+
"borderLeftStyle",
|
|
28
|
+
"borderTopWidth",
|
|
29
|
+
"borderRightWidth",
|
|
30
|
+
"borderBottomWidth",
|
|
31
|
+
"borderLeftWidth",
|
|
32
|
+
"paddingTop",
|
|
33
|
+
"paddingRight",
|
|
34
|
+
"paddingBottom",
|
|
35
|
+
"paddingLeft"
|
|
36
|
+
], X = {
|
|
37
|
+
background: "backgroundcolor",
|
|
38
|
+
bgcolor: "backgroundcolor",
|
|
39
|
+
blockquote: "block",
|
|
40
|
+
blocks: "block",
|
|
41
|
+
font: "fontfamily",
|
|
42
|
+
fontname: "fontfamily",
|
|
43
|
+
fontsize: "fontsize",
|
|
44
|
+
foreground: "color",
|
|
45
|
+
forecolor: "color",
|
|
46
|
+
heading: "block",
|
|
47
|
+
headings: "block",
|
|
48
|
+
liststyle: "list",
|
|
49
|
+
lists: "list",
|
|
50
|
+
strike: "strikethrough",
|
|
51
|
+
tablecell: "table",
|
|
52
|
+
tablecells: "table",
|
|
53
|
+
textcolor: "color",
|
|
54
|
+
texttransform: "texttransform"
|
|
55
|
+
}, ft = '<svg width="24" height="24" focusable="false" viewBox="0 0 24 24"><path d="M17.8 3.2a2.8 2.8 0 0 1 4 4L14 15l-4-4 7.8-7.8Zm-1.4 4.2L19 10l1.4-1.4-2.6-2.6-1.4 1.4Zm-7.8 5 3 3-1.4 1.4c-.5.5-1.2.8-1.9.8H7.2l-1.6 1.6a2.7 2.7 0 0 1-3.8 0 1 1 0 0 1 0-1.4l6.8-5.4Zm-.2 3.2H9l-4.6 3.7c.2 0 .5-.2.7-.4l1.9-1.9c.2-.2.4-.3.7-.3h1.1c.2 0 .5-.1.6-.3l.2-.2-1.2-1.3ZM5.5 3l.7 1.8L8 5.5l-1.8.7L5.5 8l-.7-1.8L3 5.5l1.8-.7L5.5 3Zm3.8 4.4.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2-1.2-.5 1.2-.5.5-1.2Z" fill-rule="evenodd"></path></svg>', v = /* @__PURE__ */ new WeakMap();
|
|
56
|
+
let I = null, P = !1, p = {
|
|
57
|
+
ignoredFormats: O,
|
|
58
|
+
keepActiveAfterMouseApply: !1
|
|
59
|
+
};
|
|
60
|
+
const ne = (t = {}) => {
|
|
61
|
+
const e = {
|
|
62
|
+
ignoredFormats: t.ignoredFormats ?? O,
|
|
63
|
+
keepActiveAfterMouseApply: t.keepActiveAfterMouseApply ?? !1
|
|
64
|
+
};
|
|
65
|
+
return p = e, {
|
|
66
|
+
name: "formatPainter",
|
|
67
|
+
toolbar: [
|
|
68
|
+
{
|
|
69
|
+
label: "Format Painter",
|
|
70
|
+
command: "toggleFormatPainter",
|
|
71
|
+
icon: ft,
|
|
72
|
+
shortcut: "Ctrl+Alt+C / Ctrl+Alt+V"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
commands: {
|
|
76
|
+
retrieveFormats: (n, r) => Y(r, e),
|
|
77
|
+
paintFormats: (n, r) => J(r, e),
|
|
78
|
+
toggleFormatPainter: (n, r) => dt(r, e),
|
|
79
|
+
cancelFormatPainter: (n, r) => G(r)
|
|
80
|
+
},
|
|
81
|
+
initialize: () => {
|
|
82
|
+
mt();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
function Y(t, e = p) {
|
|
87
|
+
const n = C(t);
|
|
88
|
+
if (!n) return !1;
|
|
89
|
+
const r = U(n, e);
|
|
90
|
+
if (!r) return !1;
|
|
91
|
+
const o = g(n);
|
|
92
|
+
return o.options = e, o.snapshot = r, I = r, M(n, !1), !0;
|
|
93
|
+
}
|
|
94
|
+
function J(t, e = p) {
|
|
95
|
+
const n = C(t);
|
|
96
|
+
if (!n) return !1;
|
|
97
|
+
const r = g(n);
|
|
98
|
+
r.options = e;
|
|
99
|
+
const o = r.snapshot || I;
|
|
100
|
+
return o ? Q(n, o) : !1;
|
|
101
|
+
}
|
|
102
|
+
function dt(t, e = p) {
|
|
103
|
+
const n = C(t);
|
|
104
|
+
if (!n) return !1;
|
|
105
|
+
const r = g(n);
|
|
106
|
+
if (r.options = e, r.active)
|
|
107
|
+
return h(n, !1), !0;
|
|
108
|
+
const o = U(n, e);
|
|
109
|
+
return o ? (r.snapshot = o, I = o, h(n, !0), !0) : !1;
|
|
110
|
+
}
|
|
111
|
+
function G(t) {
|
|
112
|
+
const e = C(t);
|
|
113
|
+
return e ? (h(e, !1), !0) : (document.querySelectorAll(`${E}.rte-format-painter-active`).forEach((n) => {
|
|
114
|
+
h(n, !1);
|
|
115
|
+
}), !0);
|
|
116
|
+
}
|
|
117
|
+
function mt() {
|
|
118
|
+
P || typeof document > "u" || (P = !0, document.addEventListener("keydown", gt, !0), document.addEventListener("mouseup", Et, !0));
|
|
119
|
+
}
|
|
120
|
+
function gt(t) {
|
|
121
|
+
const e = t.key.toLowerCase(), n = t.ctrlKey || t.metaKey;
|
|
122
|
+
if (t.key === "Escape") {
|
|
123
|
+
G();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!n || !t.altKey || t.shiftKey) return;
|
|
127
|
+
const r = j() || C();
|
|
128
|
+
if (r) {
|
|
129
|
+
if (e === "c") {
|
|
130
|
+
Y({ contentElement: r }, g(r).options) && t.preventDefault();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
e === "v" && J({ contentElement: r }, g(r).options) && t.preventDefault();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function Et(t) {
|
|
137
|
+
const e = t.target;
|
|
138
|
+
if (e?.closest(".rte-toolbar-wrapper, .editora-toolbar-container")) return;
|
|
139
|
+
const n = e?.closest(E);
|
|
140
|
+
if (!(n instanceof HTMLElement)) return;
|
|
141
|
+
const r = g(n);
|
|
142
|
+
if (!r.active || !r.snapshot) return;
|
|
143
|
+
const o = window.getSelection();
|
|
144
|
+
if (!o || o.rangeCount === 0 || o.getRangeAt(0).collapsed) return;
|
|
145
|
+
Q(n, r.snapshot) && !r.options.keepActiveAfterMouseApply && h(n, !1);
|
|
146
|
+
}
|
|
147
|
+
function g(t) {
|
|
148
|
+
let e = v.get(t);
|
|
149
|
+
return e || (e = { snapshot: null, active: !1, options: p }, v.set(t, e)), e;
|
|
150
|
+
}
|
|
151
|
+
function C(t) {
|
|
152
|
+
if (t?.contentElement instanceof HTMLElement) return t.contentElement;
|
|
153
|
+
const e = D(t?.editorElement ?? null);
|
|
154
|
+
if (e) return e;
|
|
155
|
+
const n = typeof window < "u" ? window.__editoraCommandEditorRoot : null, r = D(n);
|
|
156
|
+
return r || j() || ht();
|
|
157
|
+
}
|
|
158
|
+
function D(t) {
|
|
159
|
+
return t ? t.matches(E) ? t : t.querySelector(E) : null;
|
|
160
|
+
}
|
|
161
|
+
function j() {
|
|
162
|
+
const t = window.getSelection();
|
|
163
|
+
if (!t || t.rangeCount === 0) return null;
|
|
164
|
+
const e = t.getRangeAt(0), r = f(e.commonAncestorContainer)?.closest(E);
|
|
165
|
+
return r instanceof HTMLElement ? r : null;
|
|
166
|
+
}
|
|
167
|
+
function ht() {
|
|
168
|
+
const t = document.activeElement;
|
|
169
|
+
if (!(t instanceof HTMLElement)) return null;
|
|
170
|
+
const e = t.closest(E);
|
|
171
|
+
return e instanceof HTMLElement ? e : null;
|
|
172
|
+
}
|
|
173
|
+
function f(t) {
|
|
174
|
+
return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
|
|
175
|
+
}
|
|
176
|
+
function U(t, e) {
|
|
177
|
+
const n = window.getSelection(), r = n && n.rangeCount > 0 ? n.getRangeAt(0) : null, o = r ? r.collapsed ? r.startContainer : r.commonAncestorContainer : null, i = f(o) || t;
|
|
178
|
+
if (!t.contains(i)) return null;
|
|
179
|
+
const s = ee(e.ignoredFormats), a = nt(i, t), l = i.closest("li"), u = l?.closest(_), m = i.closest(w), it = m?.closest("table");
|
|
180
|
+
return {
|
|
181
|
+
inline: pt(r, i, t, s),
|
|
182
|
+
block: !c(s, "block") && a ? bt(a, s) : null,
|
|
183
|
+
list: !c(s, "list") && u ? Nt(u, l) : null,
|
|
184
|
+
table: c(s, "table") ? null : St(it, m, s),
|
|
185
|
+
ignoredFormats: s
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function pt(t, e, n, r) {
|
|
189
|
+
if (!t || t.collapsed)
|
|
190
|
+
return H(e, r);
|
|
191
|
+
const i = Ct(t, e, n).map((s) => H(s, r));
|
|
192
|
+
return Tt(i);
|
|
193
|
+
}
|
|
194
|
+
function Ct(t, e, n) {
|
|
195
|
+
const r = [], o = document.createTreeWalker(
|
|
196
|
+
t.commonAncestorContainer,
|
|
197
|
+
NodeFilter.SHOW_TEXT,
|
|
198
|
+
{
|
|
199
|
+
acceptNode: (s) => !n.contains(s) || !t.intersectsNode(s) ? NodeFilter.FILTER_REJECT : (s.textContent || "").trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
let i = o.nextNode();
|
|
203
|
+
for (; i && r.length < 64; ) {
|
|
204
|
+
const s = f(i);
|
|
205
|
+
s && !r.includes(s) && r.push(s), i = o.nextNode();
|
|
206
|
+
}
|
|
207
|
+
return r.length > 0 ? r : [e];
|
|
208
|
+
}
|
|
209
|
+
function H(t, e) {
|
|
210
|
+
const n = window.getComputedStyle(t), r = {};
|
|
211
|
+
c(e, "bold") || (r.bold = kt(t, n)), c(e, "italic") || (r.italic = At(t, n)), c(e, "underline") || (r.underline = $(t, n, "underline")), c(e, "strikethrough") || (r.strikethrough = $(t, n, "line-through"));
|
|
212
|
+
const o = {};
|
|
213
|
+
return L.forEach((i) => {
|
|
214
|
+
if (c(e, i)) return;
|
|
215
|
+
const s = n[i];
|
|
216
|
+
yt(i, s) && (o[i] = s);
|
|
217
|
+
}), { marks: r, styles: o };
|
|
218
|
+
}
|
|
219
|
+
function Tt(t) {
|
|
220
|
+
const e = {};
|
|
221
|
+
["bold", "italic", "underline", "strikethrough"].forEach((o) => {
|
|
222
|
+
const i = t.map((s) => s.marks[o]).filter((s) => s != null);
|
|
223
|
+
i.length !== 0 && (e[o] = i.every(Boolean));
|
|
224
|
+
});
|
|
225
|
+
const r = {};
|
|
226
|
+
return L.forEach((o) => {
|
|
227
|
+
const i = t.map((s) => s.styles[o]).filter((s) => !!s);
|
|
228
|
+
i.length === t.length && i.every((s) => s === i[0]) && (r[o] = i[0]);
|
|
229
|
+
}), { marks: e, styles: r };
|
|
230
|
+
}
|
|
231
|
+
function bt(t, e) {
|
|
232
|
+
const n = window.getComputedStyle(t), r = {};
|
|
233
|
+
at.forEach((s) => {
|
|
234
|
+
if (c(e, s)) return;
|
|
235
|
+
const l = t.style[s] || n[s];
|
|
236
|
+
Lt(s, l) && (r[s] = l);
|
|
237
|
+
});
|
|
238
|
+
const o = {}, i = t.getAttribute("dir") || t.style.direction;
|
|
239
|
+
return (i === "ltr" || i === "rtl" || i === "auto") && (o.dir = i), {
|
|
240
|
+
tagName: rt(t),
|
|
241
|
+
styles: r,
|
|
242
|
+
attrs: o
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function Nt(t, e) {
|
|
246
|
+
const n = {};
|
|
247
|
+
lt.forEach((i) => {
|
|
248
|
+
const s = t.style[i] || window.getComputedStyle(t)[i];
|
|
249
|
+
s && s !== "disc" && s !== "decimal" && (n[i] = s);
|
|
250
|
+
});
|
|
251
|
+
const r = {};
|
|
252
|
+
b(t, r, "data-type"), b(t, r, "type");
|
|
253
|
+
const o = {};
|
|
254
|
+
return e && (b(e, o, "data-type"), b(e, o, "data-checked")), {
|
|
255
|
+
tagName: t.tagName.toLowerCase() === "ol" ? "ol" : "ul",
|
|
256
|
+
styles: n,
|
|
257
|
+
attrs: r,
|
|
258
|
+
itemAttrs: o
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function St(t, e, n) {
|
|
262
|
+
return !t && !e ? null : {
|
|
263
|
+
table: t ? W(t, ct, n) : null,
|
|
264
|
+
cell: e ? W(e, ut, n) : null
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function W(t, e, n) {
|
|
268
|
+
const r = window.getComputedStyle(t), o = {};
|
|
269
|
+
return e.forEach((i) => {
|
|
270
|
+
if (c(n, i)) return;
|
|
271
|
+
const a = t.style[i] || r[i];
|
|
272
|
+
Rt(i, a) && (o[i] = a);
|
|
273
|
+
}), { styles: o, attrs: {} };
|
|
274
|
+
}
|
|
275
|
+
function kt(t, e) {
|
|
276
|
+
if (t.closest("b,strong")) return !0;
|
|
277
|
+
const n = e.fontWeight;
|
|
278
|
+
return /^(bold|bolder|[5-9]\d{2,})$/.test(n);
|
|
279
|
+
}
|
|
280
|
+
function At(t, e) {
|
|
281
|
+
return !!t.closest("i,em") || e.fontStyle === "italic";
|
|
282
|
+
}
|
|
283
|
+
function $(t, e, n) {
|
|
284
|
+
const r = n === "underline" ? "u" : "s,strike";
|
|
285
|
+
return !!t.closest(r) || e.textDecorationLine.includes(n);
|
|
286
|
+
}
|
|
287
|
+
function yt(t, e) {
|
|
288
|
+
return !(!e || t === "backgroundColor" && (e === "rgba(0, 0, 0, 0)" || e === "transparent") || t === "textTransform" && e === "none");
|
|
289
|
+
}
|
|
290
|
+
function Lt(t, e) {
|
|
291
|
+
return !(!e || t === "textAlign" && e === "start" || t === "lineHeight" && e === "normal" || (t === "marginLeft" || t === "marginRight") && e === "0px");
|
|
292
|
+
}
|
|
293
|
+
function Rt(t, e) {
|
|
294
|
+
return !(!e || (t === "backgroundColor" || t.endsWith("Color")) && (e === "rgba(0, 0, 0, 0)" || e === "transparent") || t === "textAlign" && e === "start" || t === "verticalAlign" && e === "middle" || t.endsWith("Width") && e === "0px" || t.endsWith("Style") && e === "none" || t.startsWith("padding") && e === "0px" || t === "borderSpacing" && e === "0px" || t === "width" && e === "auto");
|
|
295
|
+
}
|
|
296
|
+
function Q(t, e) {
|
|
297
|
+
const n = window.getSelection();
|
|
298
|
+
if (!n || n.rangeCount === 0) return !1;
|
|
299
|
+
const r = n.getRangeAt(0);
|
|
300
|
+
if (!t.contains(r.startContainer) || !t.contains(r.endContainer)) return !1;
|
|
301
|
+
const o = t.innerHTML, i = !r.collapsed, s = Jt(t);
|
|
302
|
+
Ft(t, r, e.table), wt(t, r, e), s?.();
|
|
303
|
+
const a = window.getSelection(), l = a && a.rangeCount > 0 ? a.getRangeAt(0) : null;
|
|
304
|
+
i && a && l && t.contains(l.startContainer) && t.contains(l.endContainer) && Mt(l, a, e), Ut(t), Qt(t);
|
|
305
|
+
const u = t.innerHTML;
|
|
306
|
+
return o === u ? !1 : (te(t, o, u), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0);
|
|
307
|
+
}
|
|
308
|
+
function wt(t, e, n) {
|
|
309
|
+
const r = Xt(t, e);
|
|
310
|
+
n.list && zt(r, n.list), n.block && r.forEach((o) => {
|
|
311
|
+
const i = o.isConnected ? o : null;
|
|
312
|
+
if (!i) return;
|
|
313
|
+
const s = Vt(i, n.block.tagName);
|
|
314
|
+
S(s, n.block.styles), n.block.attrs.dir ? s.setAttribute("dir", n.block.attrs.dir) : s.removeAttribute("dir");
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function Ft(t, e, n) {
|
|
318
|
+
if (!n) return;
|
|
319
|
+
const r = Kt(t, e);
|
|
320
|
+
if (n.cell && r.forEach((i) => {
|
|
321
|
+
S(i, n.cell.styles);
|
|
322
|
+
}), !n.table) return;
|
|
323
|
+
const o = /* @__PURE__ */ new Set();
|
|
324
|
+
if (r.forEach((i) => {
|
|
325
|
+
const s = i.closest("table");
|
|
326
|
+
s instanceof HTMLElement && o.add(s);
|
|
327
|
+
}), o.size === 0) {
|
|
328
|
+
const i = f(e.startContainer)?.closest("table");
|
|
329
|
+
i instanceof HTMLElement && t.contains(i) && o.add(i);
|
|
330
|
+
}
|
|
331
|
+
o.forEach((i) => {
|
|
332
|
+
S(i, n.table.styles);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
function Mt(t, e, n) {
|
|
336
|
+
vt(t);
|
|
337
|
+
const r = n.inline, o = t.cloneContents();
|
|
338
|
+
if (Yt(o)) {
|
|
339
|
+
_t(t, e, n);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const i = t.extractContents();
|
|
343
|
+
qt(i, n);
|
|
344
|
+
const s = document.createDocumentFragment(), a = K("start"), l = K("end");
|
|
345
|
+
s.appendChild(a), s.appendChild(et(i, r)), s.appendChild(l), t.insertNode(s), Dt(a, l, n);
|
|
346
|
+
const u = document.createRange();
|
|
347
|
+
u.setStartAfter(a), u.setEndBefore(l), e.removeAllRanges(), e.addRange(u);
|
|
348
|
+
}
|
|
349
|
+
function _t(t, e, n) {
|
|
350
|
+
const r = Ot(t), o = [];
|
|
351
|
+
if (r.forEach((s) => {
|
|
352
|
+
let a = It(s, t);
|
|
353
|
+
if (!a || !a.data.trim() || $t(a)) return;
|
|
354
|
+
a = xt(a, n);
|
|
355
|
+
const l = et(document.createTextNode(a.data), n.inline);
|
|
356
|
+
a.parentNode?.replaceChild(l, a), o.push(l);
|
|
357
|
+
}), o.length === 0) return;
|
|
358
|
+
const i = document.createRange();
|
|
359
|
+
i.setStartBefore(o[0]), i.setEndAfter(o[o.length - 1]), e.removeAllRanges(), e.addRange(i);
|
|
360
|
+
}
|
|
361
|
+
function Ot(t) {
|
|
362
|
+
if (t.startContainer === t.endContainer && t.startContainer.nodeType === Node.TEXT_NODE)
|
|
363
|
+
return [t.startContainer];
|
|
364
|
+
const e = [], n = document.createTreeWalker(t.commonAncestorContainer, NodeFilter.SHOW_TEXT, {
|
|
365
|
+
acceptNode: (o) => !o.textContent || !o.textContent.trim() || !t.intersectsNode(o) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
|
|
366
|
+
});
|
|
367
|
+
let r = n.nextNode();
|
|
368
|
+
for (; r; )
|
|
369
|
+
e.push(r), r = n.nextNode();
|
|
370
|
+
return e;
|
|
371
|
+
}
|
|
372
|
+
function It(t, e) {
|
|
373
|
+
const n = t.data.length;
|
|
374
|
+
let r = 0, o = n;
|
|
375
|
+
if (t === e.startContainer && (r = Math.max(0, Math.min(e.startOffset, n))), t === e.endContainer && (o = Math.max(0, Math.min(e.endOffset, n))), r >= o) return null;
|
|
376
|
+
let i = t;
|
|
377
|
+
return o < i.data.length && i.splitText(o), r > 0 && (i = i.splitText(r)), i;
|
|
378
|
+
}
|
|
379
|
+
function xt(t, e) {
|
|
380
|
+
let n = t, r = n.parentElement;
|
|
381
|
+
for (; r && r.matches(y) && !x(r, e) && tt(r, e); )
|
|
382
|
+
Bt(r, n), r = n.parentElement;
|
|
383
|
+
return n;
|
|
384
|
+
}
|
|
385
|
+
function Bt(t, e) {
|
|
386
|
+
const n = t.parentNode;
|
|
387
|
+
if (!n || e.parentNode !== t) return;
|
|
388
|
+
const r = t.cloneNode(!1), o = t.cloneNode(!1);
|
|
389
|
+
for (; t.firstChild && t.firstChild !== e; )
|
|
390
|
+
r.appendChild(t.firstChild);
|
|
391
|
+
for (; e.nextSibling; )
|
|
392
|
+
o.appendChild(e.nextSibling);
|
|
393
|
+
q(r) && n.insertBefore(r, t), n.insertBefore(e, t), q(o) && n.insertBefore(o, t), n.removeChild(t);
|
|
394
|
+
}
|
|
395
|
+
function q(t) {
|
|
396
|
+
return Array.from(t.childNodes).some((e) => e.nodeType !== Node.TEXT_NODE ? !0 : !!(e.textContent || "").trim());
|
|
397
|
+
}
|
|
398
|
+
function vt(t) {
|
|
399
|
+
let e = f(t.startContainer), n = f(t.endContainer);
|
|
400
|
+
for (; e && e === n && e.matches(y); ) {
|
|
401
|
+
if (!Pt(t, e)) return;
|
|
402
|
+
t.selectNode(e), e = e.parentElement, n = f(t.endContainer);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function Pt(t, e) {
|
|
406
|
+
const n = document.createRange();
|
|
407
|
+
return n.selectNodeContents(e), t.compareBoundaryPoints(Range.START_TO_START, n) === 0 && t.compareBoundaryPoints(Range.END_TO_END, n) === 0;
|
|
408
|
+
}
|
|
409
|
+
function Dt(t, e, n) {
|
|
410
|
+
let r = f(t.parentNode);
|
|
411
|
+
for (; r && r.contains(e); ) {
|
|
412
|
+
const o = r.parentElement;
|
|
413
|
+
r.matches(y) && !x(r, n) && Ht(r, t, e) && tt(r, n) && k(r), r = o;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function Ht(t, e, n) {
|
|
417
|
+
let r = "before";
|
|
418
|
+
for (const o of Array.from(t.childNodes)) {
|
|
419
|
+
if (o === e) {
|
|
420
|
+
r = "inside";
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (o === n) {
|
|
424
|
+
r = "after";
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (r !== "inside" && !Wt(o))
|
|
428
|
+
return !1;
|
|
429
|
+
}
|
|
430
|
+
return r === "after";
|
|
431
|
+
}
|
|
432
|
+
function Wt(t) {
|
|
433
|
+
return t.nodeType === Node.TEXT_NODE ? !(t.textContent || "").replace(/\uFEFF/g, "").trim() : t.nodeType === Node.COMMENT_NODE ? ot(t) : t.nodeType !== Node.ELEMENT_NODE ? !0 : t.hasAttribute(d);
|
|
434
|
+
}
|
|
435
|
+
function tt(t, e) {
|
|
436
|
+
return t.matches("span") ? L.some((n) => !c(e.ignoredFormats, n)) : t.matches("b,strong") ? !c(e.ignoredFormats, "bold") : t.matches("i,em") ? !c(e.ignoredFormats, "italic") : t.matches("u") ? !c(e.ignoredFormats, "underline") : t.matches("s,strike") ? !c(e.ignoredFormats, "strikethrough") : !0;
|
|
437
|
+
}
|
|
438
|
+
function $t(t) {
|
|
439
|
+
return t.nodeType !== Node.TEXT_NODE || (t.textContent || "").trim() ? !1 : !!t.parentElement?.matches(_);
|
|
440
|
+
}
|
|
441
|
+
function et(t, e) {
|
|
442
|
+
let n = t;
|
|
443
|
+
const r = Object.entries(e.styles);
|
|
444
|
+
if (r.length > 0) {
|
|
445
|
+
const o = document.createElement("span");
|
|
446
|
+
o.classList.add("rte-format-painted"), r.forEach(([i, s]) => {
|
|
447
|
+
o.style.setProperty(B(i), s);
|
|
448
|
+
}), o.appendChild(n), n = o;
|
|
449
|
+
}
|
|
450
|
+
return e.marks.strikethrough && (n = T("s", n)), e.marks.underline && (n = T("u", n)), e.marks.italic && (n = T("i", n)), e.marks.bold && (n = T("b", n)), n;
|
|
451
|
+
}
|
|
452
|
+
function T(t, e) {
|
|
453
|
+
const n = document.createElement(t);
|
|
454
|
+
return n.appendChild(e), n;
|
|
455
|
+
}
|
|
456
|
+
function qt(t, e) {
|
|
457
|
+
Array.from(t.querySelectorAll(y)).forEach((n) => {
|
|
458
|
+
if (n instanceof HTMLElement && !x(n, e)) {
|
|
459
|
+
if (n.matches("span")) {
|
|
460
|
+
if (L.forEach((r) => {
|
|
461
|
+
c(e.ignoredFormats, r) || n.style.removeProperty(B(r));
|
|
462
|
+
}), n.getAttribute("style") || n.attributes.length > 0) return;
|
|
463
|
+
k(n);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
n.matches("b,strong") && c(e.ignoredFormats, "bold") || n.matches("i,em") && c(e.ignoredFormats, "italic") || n.matches("u") && c(e.ignoredFormats, "underline") || n.matches("s,strike") && c(e.ignoredFormats, "strikethrough") || k(n);
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function x(t, e) {
|
|
471
|
+
return !!(t.matches("a") && c(e.ignoredFormats, "link") || R(t, "comment") && c(e.ignoredFormats, "comments") || R(t, "citation") && c(e.ignoredFormats, "citations") || R(t, "track") && c(e.ignoredFormats, "trackchanges"));
|
|
472
|
+
}
|
|
473
|
+
function R(t, e) {
|
|
474
|
+
const n = e.toLowerCase();
|
|
475
|
+
return t.className.toString().toLowerCase().includes(n) ? !0 : Array.from(t.attributes).some((o) => {
|
|
476
|
+
const i = A(o.name), s = o.value.toLowerCase();
|
|
477
|
+
return i.includes(n) || s.includes(n);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
function zt(t, e) {
|
|
481
|
+
t.filter((r) => r.tagName.toLowerCase() === "li").forEach((r) => {
|
|
482
|
+
const o = r.closest(_);
|
|
483
|
+
if (!o) return;
|
|
484
|
+
const i = Zt(o, e.tagName);
|
|
485
|
+
S(i, e.styles), Z(i, e.attrs), Z(r, e.itemAttrs);
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function Kt(t, e) {
|
|
489
|
+
const n = Array.from(t.querySelectorAll(w)).filter((o) => o instanceof HTMLElement && e.intersectsNode(o));
|
|
490
|
+
if (n.length > 0) return n;
|
|
491
|
+
const r = f(e.startContainer)?.closest(w);
|
|
492
|
+
return r instanceof HTMLElement && t.contains(r) ? [r] : [];
|
|
493
|
+
}
|
|
494
|
+
function S(t, e) {
|
|
495
|
+
Object.entries(e).forEach(([n, r]) => {
|
|
496
|
+
t.style.setProperty(B(n), r);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function Vt(t, e) {
|
|
500
|
+
const n = rt(t);
|
|
501
|
+
if (n === e || n === "li" || n === "td" || n === "th") return t;
|
|
502
|
+
if (e === "blockquote") {
|
|
503
|
+
const o = document.createElement("blockquote");
|
|
504
|
+
for (; t.firstChild; ) o.appendChild(t.firstChild);
|
|
505
|
+
return F(t, o), t.parentNode?.replaceChild(o, t), o;
|
|
506
|
+
}
|
|
507
|
+
if (!/^(p|div|h[1-6]|pre)$/.test(e)) return t;
|
|
508
|
+
const r = document.createElement(e);
|
|
509
|
+
for (; t.firstChild; ) r.appendChild(t.firstChild);
|
|
510
|
+
return F(t, r), t.parentNode?.replaceChild(r, t), r;
|
|
511
|
+
}
|
|
512
|
+
function Zt(t, e) {
|
|
513
|
+
if (t.tagName.toLowerCase() === e) return t;
|
|
514
|
+
const n = document.createElement(e);
|
|
515
|
+
for (; t.firstChild; ) n.appendChild(t.firstChild);
|
|
516
|
+
return F(t, n), t.parentNode?.replaceChild(n, t), n;
|
|
517
|
+
}
|
|
518
|
+
function Xt(t, e) {
|
|
519
|
+
const n = Array.from(t.querySelectorAll(N)).filter((o) => o instanceof HTMLElement && e.intersectsNode(o));
|
|
520
|
+
if (n.length > 0)
|
|
521
|
+
return n.filter((o) => !n.some((i) => i !== o && i.contains(o)));
|
|
522
|
+
const r = nt(f(e.startContainer), t);
|
|
523
|
+
return r ? [r] : [];
|
|
524
|
+
}
|
|
525
|
+
function nt(t, e) {
|
|
526
|
+
const n = t?.closest(N);
|
|
527
|
+
return n instanceof HTMLElement && e.contains(n) ? n : null;
|
|
528
|
+
}
|
|
529
|
+
function rt(t) {
|
|
530
|
+
const e = t.tagName.toLowerCase();
|
|
531
|
+
return e === "blockquote" || /^h[1-6]$/.test(e) || e === "pre" || e === "li" || e === "td" || e === "th" ? e : "p";
|
|
532
|
+
}
|
|
533
|
+
function Yt(t) {
|
|
534
|
+
return Array.from(t.childNodes).some((e) => {
|
|
535
|
+
if (e.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
536
|
+
const n = e;
|
|
537
|
+
return n.matches(N) || !!n.querySelector(N);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
function Jt(t) {
|
|
541
|
+
const e = window.getSelection();
|
|
542
|
+
if (!e || e.rangeCount === 0) return null;
|
|
543
|
+
const n = e.getRangeAt(0);
|
|
544
|
+
if (!t.contains(n.startContainer) || !t.contains(n.endContainer)) return null;
|
|
545
|
+
const r = n.collapsed, o = z("start"), i = z("end"), s = n.cloneRange();
|
|
546
|
+
if (!r) {
|
|
547
|
+
const l = s.cloneRange();
|
|
548
|
+
l.collapse(!1), l.insertNode(i);
|
|
549
|
+
}
|
|
550
|
+
const a = s.cloneRange();
|
|
551
|
+
return a.collapse(!0), a.insertNode(o), () => {
|
|
552
|
+
const l = V(t, "start"), u = V(t, "end");
|
|
553
|
+
if (!l) return;
|
|
554
|
+
const m = document.createRange();
|
|
555
|
+
r || !u ? (m.setStartAfter(l), m.collapse(!0)) : (m.setStartAfter(l), m.setEndBefore(u)), e.removeAllRanges(), e.addRange(m);
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
function z(t) {
|
|
559
|
+
return document.createComment(`${d}:selection:${t}`);
|
|
560
|
+
}
|
|
561
|
+
function K(t) {
|
|
562
|
+
return document.createComment(`${d}:inline:${t}`);
|
|
563
|
+
}
|
|
564
|
+
function ot(t) {
|
|
565
|
+
return Gt(t) || jt(t);
|
|
566
|
+
}
|
|
567
|
+
function Gt(t) {
|
|
568
|
+
return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${d}:selection:start` || t.nodeValue === `${d}:selection:end`);
|
|
569
|
+
}
|
|
570
|
+
function jt(t) {
|
|
571
|
+
return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${d}:inline:start` || t.nodeValue === `${d}:inline:end`);
|
|
572
|
+
}
|
|
573
|
+
function V(t, e) {
|
|
574
|
+
const n = `${d}:selection:${e}`, r = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT);
|
|
575
|
+
let o = r.nextNode();
|
|
576
|
+
for (; o; ) {
|
|
577
|
+
if (o.nodeValue === n) return o;
|
|
578
|
+
o = r.nextNode();
|
|
579
|
+
}
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
function Ut(t) {
|
|
583
|
+
t.querySelectorAll(`[${d}]`).forEach((o) => o.remove());
|
|
584
|
+
const e = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT), n = [];
|
|
585
|
+
let r = e.nextNode();
|
|
586
|
+
for (; r; )
|
|
587
|
+
ot(r) && n.push(r), r = e.nextNode();
|
|
588
|
+
n.forEach((o) => o.remove());
|
|
589
|
+
}
|
|
590
|
+
function Qt(t) {
|
|
591
|
+
t.querySelectorAll("span").forEach((e) => {
|
|
592
|
+
e instanceof HTMLElement && (e.attributes.length > 0 || k(e));
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
function k(t) {
|
|
596
|
+
const e = t.parentNode;
|
|
597
|
+
if (e) {
|
|
598
|
+
for (; t.firstChild; )
|
|
599
|
+
e.insertBefore(t.firstChild, t);
|
|
600
|
+
e.removeChild(t);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function b(t, e, n) {
|
|
604
|
+
const r = t.getAttribute(n);
|
|
605
|
+
r != null && (e[n] = r);
|
|
606
|
+
}
|
|
607
|
+
function Z(t, e) {
|
|
608
|
+
["data-type", "data-checked", "type"].forEach((n) => {
|
|
609
|
+
e[n] != null && t.setAttribute(n, e[n]);
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function F(t, e) {
|
|
613
|
+
Array.from(t.attributes).forEach((n) => {
|
|
614
|
+
n.name !== "style" && e.setAttribute(n.name, n.value);
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
function h(t, e) {
|
|
618
|
+
const n = g(t);
|
|
619
|
+
if (n.active === e && t.classList.contains("rte-format-painter-active") === e) {
|
|
620
|
+
M(t, e);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
n.active = e, t.classList.toggle("rte-format-painter-active", e), M(t, e);
|
|
624
|
+
}
|
|
625
|
+
function M(t, e) {
|
|
626
|
+
const n = t.closest(st) || document;
|
|
627
|
+
n.querySelectorAll(
|
|
628
|
+
'[data-command="toggleFormatPainter"], [data-command="formatPainter"]'
|
|
629
|
+
).forEach((o) => {
|
|
630
|
+
o instanceof HTMLElement && (o.classList.toggle("active", e), o.setAttribute("data-active", e ? "true" : "false"), o.setAttribute("aria-pressed", e ? "true" : "false"));
|
|
631
|
+
}), n.dispatchEvent(
|
|
632
|
+
new CustomEvent("editora:format-painter-toggle", {
|
|
633
|
+
bubbles: !0,
|
|
634
|
+
detail: { active: e }
|
|
635
|
+
})
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
function te(t, e, n) {
|
|
639
|
+
if (e === n) return;
|
|
640
|
+
const r = window.execEditorCommand || window.executeEditorCommand;
|
|
641
|
+
if (typeof r == "function")
|
|
642
|
+
try {
|
|
643
|
+
r("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n });
|
|
644
|
+
} catch {
|
|
645
|
+
try {
|
|
646
|
+
r("recordDomTransaction", t, e, n);
|
|
647
|
+
} catch {
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
function ee(t) {
|
|
652
|
+
return (t ?? O).map(A).map((e) => X[e] || e).filter(Boolean);
|
|
653
|
+
}
|
|
654
|
+
function c(t, e) {
|
|
655
|
+
const n = X[A(e)] || A(e);
|
|
656
|
+
return t.includes(n);
|
|
657
|
+
}
|
|
658
|
+
function A(t) {
|
|
659
|
+
return t.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
660
|
+
}
|
|
661
|
+
function B(t) {
|
|
662
|
+
return t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
663
|
+
}
|
|
664
|
+
export {
|
|
665
|
+
ne as FormatPainterPlugin
|
|
666
|
+
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./heading.cjs.js"),r=require("./bold.cjs.js"),o=require("./italic.cjs.js"),u=require("./underline.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./heading.cjs.js"),r=require("./bold.cjs.js"),o=require("./italic.cjs.js"),u=require("./underline.cjs.js"),a=require("./strikethrough.cjs.js"),g=require("./list.cjs.js"),s=require("./checklist.cjs.js"),P=require("./history.cjs.js"),c=require("./link.cjs.js"),m=require("./blockquote.cjs.js"),d=require("./clear-formatting.cjs.js"),C=require("./code.cjs.js"),q=require("./table.cjs.js"),p=require("./font-size.cjs.js"),h=require("./format-painter.cjs.js"),k=require("./font-family.cjs.js"),f=require("./text-alignment.cjs.js"),T=require("./text-color.cjs.js"),M=require("./background-color.cjs.js"),b=require("./line-height.cjs.js"),S=require("./indent.cjs.js"),A=require("./direction.cjs.js"),D=require("./capitalization.cjs.js"),F=require("./math.cjs.js"),y=require("./special-characters.cjs.js"),B=require("./emojis.cjs.js"),E=require("./embed-iframe.cjs.js"),I=require("./anchor.cjs.js"),v=require("./mentions.cjs.js"),L=require("./track-changes.cjs.js"),w=require("./version-diff.cjs.js"),H=require("./conditional-content.cjs.js"),z=require("./data-binding.cjs.js"),R=require("./content-rules.cjs.js"),x=require("./citations.cjs.js"),G=require("./approval-workflow.cjs.js"),W=require("./pii-redaction.cjs.js"),j=require("./smart-paste.cjs.js"),U=require("./blocks-library.cjs.js"),_=require("./doc-schema.cjs.js"),N=require("./translation-workflow.cjs.js"),V=require("./slash-commands.cjs.js"),n=require("./media-manager.cjs.js"),t=require("./index-tqLTHcO6.js"),O=require("./preview.cjs.js"),J=require("./fullscreen.cjs.js"),K=require("./print.cjs.js"),Q=require("./page-break.cjs.js"),X=require("./footnote.cjs.js"),Y=require("./code-sample.cjs.js"),Z=require("./merge-tag.cjs.js"),e=require("./template.cjs.js"),$=require("./comments.cjs.js"),ee=require("./spell-check.cjs.js"),ie=require("./a11y-checker.cjs.js"),i=require("./shared-config.cjs.js");exports.HeadingPlugin=l.HeadingPlugin;exports.BoldPlugin=r.BoldPlugin;exports.ItalicPlugin=o.ItalicPlugin;exports.UnderlinePlugin=u.UnderlinePlugin;exports.StrikethroughPlugin=a.StrikethroughPlugin;exports.ListPlugin=g.ListPlugin;exports.ChecklistPlugin=s.ChecklistPlugin;exports.HistoryPlugin=P.HistoryPlugin;exports.LinkPlugin=c.LinkPlugin;exports.BlockquotePlugin=m.BlockquotePlugin;exports.ClearFormattingPlugin=d.ClearFormattingPlugin;exports.CodePlugin=C.CodePlugin;exports.TablePlugin=q.TablePlugin;exports.FontSizePlugin=p.FontSizePlugin;exports.FormatPainterPlugin=h.FormatPainterPlugin;exports.FontFamilyPlugin=k.FontFamilyPlugin;exports.TextAlignmentPlugin=f.TextAlignmentPlugin;exports.TextColorPlugin=T.TextColorPlugin;exports.BackgroundColorPlugin=M.BackgroundColorPlugin;exports.LineHeightPlugin=b.LineHeightPlugin;exports.IndentPlugin=S.IndentPlugin;exports.DirectionPlugin=A.DirectionPlugin;exports.CapitalizationPlugin=D.CapitalizationPlugin;exports.MathPlugin=F.MathPlugin;exports.SpecialCharactersPlugin=y.SpecialCharactersPlugin;exports.EmojisPlugin=B.EmojisPlugin;exports.EmbedIframePlugin=E.EmbedIframePlugin;exports.AnchorPlugin=I.AnchorPlugin;exports.MentionPlugin=v.MentionPlugin;exports.TrackChangesPlugin=L.TrackChangesPlugin;exports.VersionDiffPlugin=w.VersionDiffPlugin;exports.ConditionalContentPlugin=H.ConditionalContentPlugin;exports.DataBindingPlugin=z.DataBindingPlugin;exports.ContentRulesPlugin=R.ContentRulesPlugin;exports.CitationsPlugin=x.CitationsPlugin;exports.ApprovalWorkflowPlugin=G.ApprovalWorkflowPlugin;exports.PIIRedactionPlugin=W.PIIRedactionPlugin;exports.SmartPastePlugin=j.SmartPastePlugin;exports.BlocksLibraryPlugin=U.BlocksLibraryPlugin;exports.DocSchemaPlugin=_.DocSchemaPlugin;exports.TranslationWorkflowPlugin=N.TranslationWorkflowPlugin;exports.SlashCommandsPlugin=V.SlashCommandsPlugin;exports.MediaManagerPlugin=n.MediaManagerPlugin;exports.getMediaManagerConfig=n.getMediaManagerConfig;exports.setMediaManagerConfig=n.setMediaManagerConfig;exports.DocumentManagerPlugin=t.DocumentManagerPlugin;exports.getDocumentManagerConfig=t.getDocumentManagerConfig;exports.setDocumentManagerConfig=t.setDocumentManagerConfig;exports.PreviewPlugin=O.PreviewPlugin;exports.FullscreenPlugin=J.FullscreenPlugin;exports.PrintPlugin=K.PrintPlugin;exports.PageBreakPlugin=Q.PageBreakPlugin;exports.FootnotePlugin=X.FootnotePlugin;exports.CodeSamplePlugin=Y.CodeSamplePlugin;exports.MergeTagPlugin=Z.MergeTagPlugin;exports.PREDEFINED_TEMPLATES=e.PREDEFINED_TEMPLATES;exports.TemplatePlugin=e.TemplatePlugin;exports.addCustomTemplate=e.addCustomTemplate;exports.getAllTemplates=e.getAllTemplates;exports.getTemplateCategories=e.getTemplateCategories;exports.getTemplatesByCategory=e.getTemplatesByCategory;exports.sanitizeTemplate=e.sanitizeTemplate;exports.searchTemplates=e.searchTemplates;exports.validateTemplate=e.validateTemplate;exports.CommentsPlugin=$.CommentsPlugin;exports.SpellCheckPlugin=ee.SpellCheckPlugin;exports.A11yCheckerPlugin=ie.A11yCheckerPlugin;exports.buildApiUrl=i.buildApiUrl;exports.getGlobalApiConfig=i.getGlobalApiConfig;exports.getGlobalApiHeaders=i.getGlobalApiHeaders;exports.setGlobalApiConfig=i.setGlobalApiConfig;
|
package/dist/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { HeadingPlugin as e } from "./heading.esm.js";
|
|
|
2
2
|
import { BoldPlugin as i } from "./bold.esm.js";
|
|
3
3
|
import { ItalicPlugin as l } from "./italic.esm.js";
|
|
4
4
|
import { UnderlinePlugin as m } from "./underline.esm.js";
|
|
5
|
-
import { StrikethroughPlugin as
|
|
5
|
+
import { StrikethroughPlugin as p } from "./strikethrough.esm.js";
|
|
6
6
|
import { ListPlugin as u } from "./list.esm.js";
|
|
7
7
|
import { ChecklistPlugin as x } from "./checklist.esm.js";
|
|
8
8
|
import { HistoryPlugin as C } from "./history.esm.js";
|
|
@@ -10,118 +10,120 @@ import { LinkPlugin as d } from "./link.esm.js";
|
|
|
10
10
|
import { BlockquotePlugin as h } from "./blockquote.esm.js";
|
|
11
11
|
import { ClearFormattingPlugin as k } from "./clear-formatting.esm.js";
|
|
12
12
|
import { CodePlugin as D } from "./code.esm.js";
|
|
13
|
-
import { TablePlugin as
|
|
14
|
-
import { FontSizePlugin as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
13
|
+
import { TablePlugin as F } from "./table.esm.js";
|
|
14
|
+
import { FontSizePlugin as B } from "./font-size.esm.js";
|
|
15
|
+
import { FormatPainterPlugin as y } from "./format-painter.esm.js";
|
|
16
|
+
import { FontFamilyPlugin as L } from "./font-family.esm.js";
|
|
17
|
+
import { TextAlignmentPlugin as v } from "./text-alignment.esm.js";
|
|
18
|
+
import { TextColorPlugin as z } from "./text-color.esm.js";
|
|
19
|
+
import { BackgroundColorPlugin as R } from "./background-color.esm.js";
|
|
20
|
+
import { LineHeightPlugin as W } from "./line-height.esm.js";
|
|
21
|
+
import { IndentPlugin as q } from "./indent.esm.js";
|
|
22
|
+
import { DirectionPlugin as V } from "./direction.esm.js";
|
|
23
|
+
import { CapitalizationPlugin as J } from "./capitalization.esm.js";
|
|
24
|
+
import { MathPlugin as O } from "./math.esm.js";
|
|
25
|
+
import { SpecialCharactersPlugin as X } from "./special-characters.esm.js";
|
|
26
|
+
import { EmojisPlugin as Z } from "./emojis.esm.js";
|
|
27
|
+
import { EmbedIframePlugin as oo } from "./embed-iframe.esm.js";
|
|
28
|
+
import { AnchorPlugin as eo } from "./anchor.esm.js";
|
|
29
|
+
import { MentionPlugin as io } from "./mentions.esm.js";
|
|
30
|
+
import { TrackChangesPlugin as lo } from "./track-changes.esm.js";
|
|
31
|
+
import { VersionDiffPlugin as mo } from "./version-diff.esm.js";
|
|
32
|
+
import { ConditionalContentPlugin as po } from "./conditional-content.esm.js";
|
|
33
|
+
import { DataBindingPlugin as uo } from "./data-binding.esm.js";
|
|
34
|
+
import { ContentRulesPlugin as xo } from "./content-rules.esm.js";
|
|
35
|
+
import { CitationsPlugin as Co } from "./citations.esm.js";
|
|
36
|
+
import { ApprovalWorkflowPlugin as To } from "./approval-workflow.esm.js";
|
|
37
|
+
import { PIIRedactionPlugin as Mo } from "./pii-redaction.esm.js";
|
|
38
|
+
import { SmartPastePlugin as Ao } from "./smart-paste.esm.js";
|
|
39
|
+
import { BlocksLibraryPlugin as So } from "./blocks-library.esm.js";
|
|
40
|
+
import { DocSchemaPlugin as bo } from "./doc-schema.esm.js";
|
|
41
|
+
import { TranslationWorkflowPlugin as Eo } from "./translation-workflow.esm.js";
|
|
42
|
+
import { SlashCommandsPlugin as Io } from "./slash-commands.esm.js";
|
|
43
|
+
import { MediaManagerPlugin as Ho, getMediaManagerConfig as vo, setMediaManagerConfig as wo } from "./media-manager.esm.js";
|
|
44
|
+
import { D as Go, g as Ro, s as Uo } from "./index-BFsKNTTj.mjs";
|
|
45
|
+
import { PreviewPlugin as jo } from "./preview.esm.js";
|
|
46
|
+
import { FullscreenPlugin as No } from "./fullscreen.esm.js";
|
|
47
|
+
import { PrintPlugin as _o } from "./print.esm.js";
|
|
48
|
+
import { PageBreakPlugin as Ko } from "./page-break.esm.js";
|
|
49
|
+
import { FootnotePlugin as Qo } from "./footnote.esm.js";
|
|
50
|
+
import { CodeSamplePlugin as Yo } from "./code-sample.esm.js";
|
|
51
|
+
import { MergeTagPlugin as $o } from "./merge-tag.esm.js";
|
|
52
|
+
import { PREDEFINED_TEMPLATES as rr, TemplatePlugin as er, addCustomTemplate as tr, getAllTemplates as ir, getTemplateCategories as nr, getTemplatesByCategory as lr, sanitizeTemplate as gr, searchTemplates as mr, validateTemplate as ar } from "./template.esm.js";
|
|
53
|
+
import { CommentsPlugin as fr } from "./comments.esm.js";
|
|
54
|
+
import { SpellCheckPlugin as Pr } from "./spell-check.esm.js";
|
|
55
|
+
import { A11yCheckerPlugin as sr } from "./a11y-checker.esm.js";
|
|
56
|
+
import { buildApiUrl as cr, getGlobalApiConfig as dr, getGlobalApiHeaders as Tr, setGlobalApiConfig as hr } from "./shared-config.esm.js";
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
sr as A11yCheckerPlugin,
|
|
59
|
+
eo as AnchorPlugin,
|
|
60
|
+
To as ApprovalWorkflowPlugin,
|
|
61
|
+
R as BackgroundColorPlugin,
|
|
61
62
|
h as BlockquotePlugin,
|
|
62
|
-
|
|
63
|
+
So as BlocksLibraryPlugin,
|
|
63
64
|
i as BoldPlugin,
|
|
64
|
-
|
|
65
|
+
J as CapitalizationPlugin,
|
|
65
66
|
x as ChecklistPlugin,
|
|
66
|
-
|
|
67
|
+
Co as CitationsPlugin,
|
|
67
68
|
k as ClearFormattingPlugin,
|
|
68
69
|
D as CodePlugin,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
Yo as CodeSamplePlugin,
|
|
71
|
+
fr as CommentsPlugin,
|
|
72
|
+
po as ConditionalContentPlugin,
|
|
73
|
+
xo as ContentRulesPlugin,
|
|
74
|
+
uo as DataBindingPlugin,
|
|
75
|
+
V as DirectionPlugin,
|
|
76
|
+
bo as DocSchemaPlugin,
|
|
77
|
+
Go as DocumentManagerPlugin,
|
|
78
|
+
oo as EmbedIframePlugin,
|
|
79
|
+
Z as EmojisPlugin,
|
|
80
|
+
L as FontFamilyPlugin,
|
|
81
|
+
B as FontSizePlugin,
|
|
82
|
+
Qo as FootnotePlugin,
|
|
83
|
+
y as FormatPainterPlugin,
|
|
84
|
+
No as FullscreenPlugin,
|
|
83
85
|
e as HeadingPlugin,
|
|
84
86
|
C as HistoryPlugin,
|
|
85
|
-
|
|
87
|
+
q as IndentPlugin,
|
|
86
88
|
l as ItalicPlugin,
|
|
87
|
-
|
|
89
|
+
W as LineHeightPlugin,
|
|
88
90
|
d as LinkPlugin,
|
|
89
91
|
u as ListPlugin,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
O as MathPlugin,
|
|
93
|
+
Ho as MediaManagerPlugin,
|
|
94
|
+
io as MentionPlugin,
|
|
95
|
+
$o as MergeTagPlugin,
|
|
96
|
+
Mo as PIIRedactionPlugin,
|
|
97
|
+
rr as PREDEFINED_TEMPLATES,
|
|
98
|
+
Ko as PageBreakPlugin,
|
|
99
|
+
jo as PreviewPlugin,
|
|
100
|
+
_o as PrintPlugin,
|
|
101
|
+
Io as SlashCommandsPlugin,
|
|
102
|
+
Ao as SmartPastePlugin,
|
|
103
|
+
X as SpecialCharactersPlugin,
|
|
104
|
+
Pr as SpellCheckPlugin,
|
|
105
|
+
p as StrikethroughPlugin,
|
|
106
|
+
F as TablePlugin,
|
|
107
|
+
er as TemplatePlugin,
|
|
108
|
+
v as TextAlignmentPlugin,
|
|
109
|
+
z as TextColorPlugin,
|
|
110
|
+
lo as TrackChangesPlugin,
|
|
111
|
+
Eo as TranslationWorkflowPlugin,
|
|
110
112
|
m as UnderlinePlugin,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
mo as VersionDiffPlugin,
|
|
114
|
+
tr as addCustomTemplate,
|
|
115
|
+
cr as buildApiUrl,
|
|
116
|
+
ir as getAllTemplates,
|
|
117
|
+
Ro as getDocumentManagerConfig,
|
|
118
|
+
dr as getGlobalApiConfig,
|
|
119
|
+
Tr as getGlobalApiHeaders,
|
|
120
|
+
vo as getMediaManagerConfig,
|
|
121
|
+
nr as getTemplateCategories,
|
|
122
|
+
lr as getTemplatesByCategory,
|
|
123
|
+
gr as sanitizeTemplate,
|
|
124
|
+
mr as searchTemplates,
|
|
125
|
+
Uo as setDocumentManagerConfig,
|
|
126
|
+
hr as setGlobalApiConfig,
|
|
127
|
+
wo as setMediaManagerConfig,
|
|
128
|
+
ar as validateTemplate
|
|
127
129
|
};
|
package/index.d.ts
CHANGED
|
@@ -834,6 +834,40 @@ export interface Template {
|
|
|
834
834
|
tags?: string[];
|
|
835
835
|
}
|
|
836
836
|
|
|
837
|
+
export interface FormatPainterPluginOptions {
|
|
838
|
+
ignoredFormats?: string[];
|
|
839
|
+
keepActiveAfterMouseApply?: boolean;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export interface FormatPainterSnapshot {
|
|
843
|
+
inline: {
|
|
844
|
+
marks: Partial<Record<"bold" | "italic" | "underline" | "strikethrough", boolean>>;
|
|
845
|
+
styles: Record<string, string>;
|
|
846
|
+
};
|
|
847
|
+
block: {
|
|
848
|
+
tagName: string;
|
|
849
|
+
styles: Record<string, string>;
|
|
850
|
+
attrs: Record<string, string>;
|
|
851
|
+
} | null;
|
|
852
|
+
list: {
|
|
853
|
+
tagName: "ul" | "ol";
|
|
854
|
+
styles: Record<string, string>;
|
|
855
|
+
attrs: Record<string, string>;
|
|
856
|
+
itemAttrs: Record<string, string>;
|
|
857
|
+
} | null;
|
|
858
|
+
table: {
|
|
859
|
+
table: {
|
|
860
|
+
styles: Record<string, string>;
|
|
861
|
+
attrs: Record<string, string>;
|
|
862
|
+
} | null;
|
|
863
|
+
cell: {
|
|
864
|
+
styles: Record<string, string>;
|
|
865
|
+
attrs: Record<string, string>;
|
|
866
|
+
} | null;
|
|
867
|
+
} | null;
|
|
868
|
+
ignoredFormats: string[];
|
|
869
|
+
}
|
|
870
|
+
|
|
837
871
|
export function HeadingPlugin(): Plugin;
|
|
838
872
|
export function BoldPlugin(): Plugin;
|
|
839
873
|
export function ItalicPlugin(): Plugin;
|
|
@@ -849,6 +883,7 @@ export function CodePlugin(): Plugin;
|
|
|
849
883
|
export function TablePlugin(): Plugin;
|
|
850
884
|
export function FontSizePlugin(): Plugin;
|
|
851
885
|
export function FontFamilyPlugin(): Plugin;
|
|
886
|
+
export function FormatPainterPlugin(options?: FormatPainterPluginOptions): Plugin;
|
|
852
887
|
export function TextAlignmentPlugin(): Plugin;
|
|
853
888
|
export function TextColorPlugin(): Plugin;
|
|
854
889
|
export function BackgroundColorPlugin(): Plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/plugins",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Enterprise plugin suite for Editora rich text editor in React and web apps, including tables, media, workflow, and compliance tooling.",
|
|
5
5
|
"author": "Ajay Kumar <ajaykr089@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -234,6 +234,12 @@
|
|
|
234
234
|
"require": "./dist/font-size.cjs.js",
|
|
235
235
|
"default": "./dist/font-size.esm.js"
|
|
236
236
|
},
|
|
237
|
+
"./format-painter": {
|
|
238
|
+
"types": "./index.d.ts",
|
|
239
|
+
"import": "./dist/format-painter.esm.js",
|
|
240
|
+
"require": "./dist/format-painter.cjs.js",
|
|
241
|
+
"default": "./dist/format-painter.esm.js"
|
|
242
|
+
},
|
|
237
243
|
"./footnote": {
|
|
238
244
|
"types": "./index.d.ts",
|
|
239
245
|
"import": "./dist/footnote.esm.js",
|
|
@@ -419,17 +425,18 @@
|
|
|
419
425
|
"test:blocks-library": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./blocks-library/src/BlocksLibraryPlugin.native.test.js",
|
|
420
426
|
"test:doc-schema": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./doc-schema/src/DocSchemaPlugin.native.test.js",
|
|
421
427
|
"test:translation-workflow": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./translation-workflow/src/TranslationWorkflowPlugin.native.test.js",
|
|
422
|
-
"
|
|
428
|
+
"test:format-painter": "node -r ../../node_modules/ts-node/register ./format-painter/src/FormatPainterPlugin.native.test.js",
|
|
429
|
+
"verify:citations": "npm run typecheck:build && npm run test:citations && npm run test:content-rules && npm run test:approval-workflow && npm run test:pii-redaction && npm run test:smart-paste && npm run test:blocks-library && npm run test:doc-schema && npm run test:translation-workflow && npm run test:format-painter && npm run build"
|
|
423
430
|
},
|
|
424
431
|
"peerDependencies": {
|
|
425
|
-
"@editora/core": "^1.0.
|
|
432
|
+
"@editora/core": "^1.0.14"
|
|
426
433
|
},
|
|
427
434
|
"dependencies": {
|
|
428
435
|
"katex": "^0.16.27",
|
|
429
436
|
"mathjax": "^3.2.2"
|
|
430
437
|
},
|
|
431
438
|
"devDependencies": {
|
|
432
|
-
"@editora/core": "^1.0.
|
|
439
|
+
"@editora/core": "^1.0.14",
|
|
433
440
|
"@types/katex": "^0.16.8",
|
|
434
441
|
"typescript": "^5.0.0",
|
|
435
442
|
"vite": "^4.5.14"
|