@editora/plugins 1.0.17 → 1.0.18
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/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
- package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
- package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +17 -15
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +11 -5
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-CJ90EVWy.mjs +0 -145
- package/dist/index-DTkvH8gX.js +0 -1
package/dist/enterprise.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MentionPlugin as r } from "./mentions.esm.js";
|
|
2
2
|
import { TrackChangesPlugin as n } from "./track-changes.esm.js";
|
|
3
3
|
import { VersionDiffPlugin as i } from "./version-diff.esm.js";
|
|
4
|
-
import { ConditionalContentPlugin as
|
|
4
|
+
import { ConditionalContentPlugin as g } from "./conditional-content.esm.js";
|
|
5
5
|
import { DataBindingPlugin as p } from "./data-binding.esm.js";
|
|
6
6
|
import { ContentRulesPlugin as u } from "./content-rules.esm.js";
|
|
7
7
|
import { CitationsPlugin as s } from "./citations.esm.js";
|
|
@@ -13,19 +13,21 @@ import { DocSchemaPlugin as E } from "./doc-schema.esm.js";
|
|
|
13
13
|
import { TranslationWorkflowPlugin as y } from "./translation-workflow.esm.js";
|
|
14
14
|
import { SlashCommandsPlugin as B } from "./slash-commands.esm.js";
|
|
15
15
|
import { SpellCheckPlugin as R } from "./spell-check.esm.js";
|
|
16
|
-
import { A11yCheckerPlugin as
|
|
17
|
-
import { CommentsPlugin as
|
|
16
|
+
import { A11yCheckerPlugin as v } from "./a11y-checker.esm.js";
|
|
17
|
+
import { CommentsPlugin as L } from "./comments.esm.js";
|
|
18
18
|
import { MergeTagPlugin as z } from "./merge-tag.esm.js";
|
|
19
19
|
import { PREDEFINED_TEMPLATES as N, TemplatePlugin as V, addCustomTemplate as _, getAllTemplates as j, getTemplateCategories as q, getTemplatesByCategory as G, sanitizeTemplate as H, searchTemplates as J, validateTemplate as K } from "./template.esm.js";
|
|
20
20
|
import { MediaManagerPlugin as Q, getMediaManagerConfig as U, setMediaManagerConfig as X } from "./media-manager.esm.js";
|
|
21
|
-
import { D as Z, g as $, s as ee } from "./index-
|
|
21
|
+
import { D as Z, g as $, s as ee } from "./index-Bm1eqYHh.mjs";
|
|
22
|
+
import { CollaborationPlugin as re } from "./collaboration.esm.js";
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
+
v as A11yCheckerPlugin,
|
|
24
25
|
C as ApprovalWorkflowPlugin,
|
|
25
26
|
h as BlocksLibraryPlugin,
|
|
26
27
|
s as CitationsPlugin,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
re as CollaborationPlugin,
|
|
29
|
+
L as CommentsPlugin,
|
|
30
|
+
g as ConditionalContentPlugin,
|
|
29
31
|
u as ContentRulesPlugin,
|
|
30
32
|
p as DataBindingPlugin,
|
|
31
33
|
E as DocSchemaPlugin,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function t(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}exports.escapeHtml=t;
|
package/dist/font-family.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 p=require("./historyHelpers-Cu8Pk7m1.js"),g=()=>({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 id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><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"}}),h="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(h)}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 C(e){e.querySelectorAll("span").forEach(t=>{t.childElementCount>0||(t.textContent||"").trim().length>0||t.remove()})}function F(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,i=N(l);if(i&&E(t,i)){i.style.fontFamily=e,i.classList.add("rte-font-family");const a=document.createRange();a.selectNodeContents(i),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 s=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)}),s||(s=F(r,n,e)),(s||c)&&(C(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=g;
|
package/dist/font-family.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { r as p } from "./historyHelpers-BEKwNOtA.mjs";
|
|
2
|
+
const R = () => ({
|
|
2
3
|
name: "fontFamily",
|
|
3
4
|
marks: {
|
|
4
5
|
fontFamily: {
|
|
@@ -46,7 +47,7 @@ const E = () => ({
|
|
|
46
47
|
setFontFamily: (e) => {
|
|
47
48
|
if (!e) return !1;
|
|
48
49
|
try {
|
|
49
|
-
return
|
|
50
|
+
return F(e), !0;
|
|
50
51
|
} catch (n) {
|
|
51
52
|
return console.error("Failed to set font family:", n), !1;
|
|
52
53
|
}
|
|
@@ -55,32 +56,32 @@ const E = () => ({
|
|
|
55
56
|
keymap: {
|
|
56
57
|
"Mod-Shift-f": "setFontFamily"
|
|
57
58
|
}
|
|
58
|
-
}),
|
|
59
|
-
function
|
|
60
|
-
return !!e.cloneContents().querySelector(
|
|
59
|
+
}), h = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
|
|
60
|
+
function g(e) {
|
|
61
|
+
return !!e.cloneContents().querySelector(h);
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
+
function m(e) {
|
|
63
64
|
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
|
|
64
65
|
}
|
|
65
66
|
function f(e) {
|
|
66
67
|
e && e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
+
function S(e, n) {
|
|
69
70
|
const t = document.createElement("span");
|
|
70
|
-
for (const
|
|
71
|
-
|
|
71
|
+
for (const o of Array.from(e.attributes))
|
|
72
|
+
o.name === "face" || o.name === "style" || t.setAttribute(o.name, o.value);
|
|
72
73
|
const r = e.getAttribute("style");
|
|
73
74
|
for (r && t.setAttribute("style", r), t.style.fontFamily = n, t.classList.add("rte-font-family"); e.firstChild; )
|
|
74
75
|
t.appendChild(e.firstChild);
|
|
75
76
|
e.parentNode?.replaceChild(t, e);
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
+
function A(e) {
|
|
78
79
|
e.querySelectorAll("span").forEach((t) => {
|
|
79
80
|
t.childElementCount > 0 || (t.textContent || "").trim().length > 0 || t.remove();
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
if (
|
|
83
|
+
function C(e, n, t) {
|
|
84
|
+
if (g(e))
|
|
84
85
|
return !1;
|
|
85
86
|
const r = document.createElement("span");
|
|
86
87
|
r.style.fontFamily = t, r.className = "rte-font-family";
|
|
@@ -90,48 +91,54 @@ function A(e, n, t) {
|
|
|
90
91
|
const l = e.extractContents();
|
|
91
92
|
r.appendChild(l), e.insertNode(r);
|
|
92
93
|
}
|
|
93
|
-
const
|
|
94
|
-
return
|
|
94
|
+
const o = document.createRange();
|
|
95
|
+
return o.selectNodeContents(r), n.removeAllRanges(), n.addRange(o), !0;
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
+
function F(e) {
|
|
97
98
|
const n = window.getSelection();
|
|
98
99
|
if (!n || n.rangeCount === 0) return;
|
|
99
|
-
const t = n.getRangeAt(0), r = t
|
|
100
|
+
const t = m(n.getRangeAt(0).commonAncestorContainer), r = t ? t.innerHTML : null;
|
|
101
|
+
b(e), t && r !== null && p(t, r);
|
|
102
|
+
}
|
|
103
|
+
function b(e) {
|
|
104
|
+
const n = window.getSelection();
|
|
105
|
+
if (!n || n.rangeCount === 0) return;
|
|
106
|
+
const t = n.getRangeAt(0), r = t.cloneRange(), o = m(t.commonAncestorContainer);
|
|
100
107
|
if (t.collapsed)
|
|
101
108
|
return;
|
|
102
|
-
const l = t.commonAncestorContainer,
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
109
|
+
const l = t.commonAncestorContainer, i = v(l);
|
|
110
|
+
if (i && N(t, i)) {
|
|
111
|
+
i.style.fontFamily = e, i.classList.add("rte-font-family");
|
|
112
|
+
const a = document.createRange();
|
|
113
|
+
a.selectNodeContents(i), n.removeAllRanges(), n.addRange(a), f(o);
|
|
107
114
|
return;
|
|
108
115
|
}
|
|
109
|
-
if (!
|
|
110
|
-
const
|
|
111
|
-
Array.from(
|
|
112
|
-
),
|
|
116
|
+
if (!o) return;
|
|
117
|
+
const u = new Set(
|
|
118
|
+
Array.from(o.querySelectorAll("font[face]"))
|
|
119
|
+
), d = new Set(
|
|
113
120
|
Array.from(
|
|
114
|
-
|
|
121
|
+
o.querySelectorAll("span[style*='font-family']")
|
|
115
122
|
)
|
|
116
123
|
);
|
|
117
|
-
|
|
124
|
+
o.focus({ preventScroll: !0 });
|
|
118
125
|
try {
|
|
119
126
|
document.execCommand("styleWithCSS", !1, "true");
|
|
120
127
|
} catch {
|
|
121
128
|
}
|
|
122
|
-
const
|
|
123
|
-
let
|
|
129
|
+
const y = e.split(",").map((a) => a.trim().replace(/^['"]|['"]$/g, "")).filter(Boolean)[0] || "Arial";
|
|
130
|
+
let s = document.execCommand("fontName", !1, y), c = !1;
|
|
124
131
|
Array.from(
|
|
125
|
-
|
|
126
|
-
).forEach((
|
|
127
|
-
|
|
132
|
+
o.querySelectorAll("font[face]")
|
|
133
|
+
).forEach((a) => {
|
|
134
|
+
u.has(a) || (S(a, e), c = !0);
|
|
128
135
|
}), Array.from(
|
|
129
|
-
|
|
130
|
-
).forEach((
|
|
131
|
-
|
|
132
|
-
}),
|
|
136
|
+
o.querySelectorAll("span[style*='font-family']")
|
|
137
|
+
).forEach((a) => {
|
|
138
|
+
d.has(a) || (a.style.fontFamily = e, a.classList.add("rte-font-family"), c = !0);
|
|
139
|
+
}), s || (s = C(r, n, e)), (s || c) && (A(o), f(o));
|
|
133
140
|
}
|
|
134
|
-
function
|
|
141
|
+
function v(e) {
|
|
135
142
|
let n = e;
|
|
136
143
|
for (; n; ) {
|
|
137
144
|
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -143,10 +150,10 @@ function b(e) {
|
|
|
143
150
|
}
|
|
144
151
|
return null;
|
|
145
152
|
}
|
|
146
|
-
function
|
|
147
|
-
const t = e.startContainer, r = e.endContainer,
|
|
148
|
-
return
|
|
153
|
+
function N(e, n) {
|
|
154
|
+
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;
|
|
155
|
+
return o && l;
|
|
149
156
|
}
|
|
150
157
|
export {
|
|
151
|
-
|
|
158
|
+
R as FontFamilyPlugin
|
|
152
159
|
};
|
package/dist/font-size.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=require("./historyHelpers-Cu8Pk7m1.js"),N=()=>({name:"fontSize",marks:{fontSize:{attrs:{size:{default:null}},parseDOM:[{tag:'span[style*="font-size"]',getAttrs:e=>{const t=e.style.fontSize;return t?{size:t}:!1}},{tag:"font[size]",getAttrs:e=>{const t=e.getAttribute("size");return t?{size:t}:!1}}],toDOM:e=>["span",{style:`font-size: ${e.attrs?.size}`},0]}},toolbar:[{label:"Font Size",command:"fontSize",type:"group",items:[{label:"Decrease Font Size",command:"decreaseFontSize",icon:"−",type:"button"},{label:"Font Size",command:"setFontSize",type:"input",placeholder:"14"},{label:"Increase Font Size",command:"increaseFontSize",icon:"+",type:"button"}]}],commands:{decreaseFontSize:()=>{try{return g(-2),y(),!0}catch(e){return console.error("Failed to decrease font size:",e),!1}},increaseFontSize:()=>{try{return g(2),y(),!0}catch(e){return console.error("Failed to increase font size:",e),!1}},setFontSize:e=>{if(!e)return!1;try{const t=e.trim().match(/^(\d+(?:\.\d+)?)(px|em|rem)?$/i);if(!t)return!1;const n=parseFloat(t[1]),r=t[2]?.toLowerCase()||"px";return r==="px"&&(n<8||n>72)||(r==="em"||r==="rem")&&(n<.5||n>5)?!1:(F(n,r),!0)}catch(o){return console.error("Failed to set font size:",o),!1}}},keymap:{}}),w="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre",z={"xx-small":9,"x-small":10,small:13,medium:16,large:18,"x-large":24,"xx-large":32,"xxx-large":48,smaller:13,larger:18};function p(e){const o=e.trim().toLowerCase(),t=o.match(/^(\d+(?:\.\d+)?)(px|em|rem)$/i);if(t)return{value:parseFloat(t[1]),unit:t[2].toLowerCase()};const n=z[o];return n?{value:n,unit:"px"}:null}function x(e){return e.trim().toLowerCase()in z}function E(e){return!!e.cloneContents().querySelector(w)}function h(e){return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')}function m(e){e&&e.dispatchEvent(new Event("input",{bubbles:!0}))}function T(e,o){const t=document.createElement("span");for(const r of Array.from(e.attributes))r.name==="size"||r.name==="style"||t.setAttribute(r.name,r.value);const n=e.getAttribute("style");for(n&&t.setAttribute("style",n),t.style.fontSize=o;e.firstChild;)t.appendChild(e.firstChild);e.parentNode?.replaceChild(t,e)}function R(e,o,t,n){const r=Array.from(e.querySelectorAll("font[size], [style*='font-size']")),i=s=>{if(!n||!s.isConnected)return!1;try{if(typeof n.intersectsNode=="function")return n.intersectsNode(s)}catch{}const a=document.createRange();return a.selectNodeContents(s),n.compareBoundaryPoints(Range.END_TO_START,a)>0&&n.compareBoundaryPoints(Range.START_TO_END,a)<0};let c=!1;return r.forEach(s=>{const a=!o.has(s),u=s.tagName==="FONT",l=x(s.style.fontSize||""),f=i(s);if(!(!a&&!f)&&!(!a&&!u&&!l)){if(c=!0,s.tagName==="FONT"){T(s,t);return}s.style.fontSize=t}}),c}function S(e){e.querySelectorAll("span").forEach(t=>{t.childElementCount>0||(t.textContent||"").trim().length>0||t.remove()})}function v(e,o,t){if(E(e))return!1;const n=document.createElement("span");n.style.fontSize=t;try{e.surroundContents(n)}catch{const i=e.extractContents();n.appendChild(i),e.insertNode(n)}const r=document.createRange();return r.selectNodeContents(n),o.removeAllRanges(),o.addRange(r),!0}function g(e){const o=window.getSelection();if(!o||o.rangeCount===0)return;const{value:t,unit:n}=C();let r=e;(n==="em"||n==="rem")&&(r=e*.125);let i;n==="px"?i=e<0?Math.max(8,t+e):Math.min(72,t+e):i=e<0?Math.max(.5,t+r):Math.min(5,t+r),F(i,n)}function C(){const e=window.getSelection();if(!e||e.rangeCount===0)return{value:14,unit:"px"};const t=e.getRangeAt(0).startContainer,n=t.nodeType===Node.TEXT_NODE?t.parentElement:t;if(n){const r=n.style?.fontSize;if(r){const a=p(r);if(a)return a}const c=window.getComputedStyle(n).fontSize,s=p(c);if(s)return s}return{value:14,unit:"px"}}function F(e,o="px"){const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=h(t.getRangeAt(0).commonAncestorContainer),r=n?n.innerHTML:null;O(e,o),n&&r!==null&&A.recordDomHistory(n,r)}function O(e,o="px"){const t=window.getSelection();if(!t||t.rangeCount===0)return;const n=t.getRangeAt(0),r=n.cloneRange(),i=h(n.commonAncestorContainer);if(n.collapsed)return;const c=`${e}${o}`,s=n.commonAncestorContainer,a=L(s);if(a&&M(n,a)){a.style.fontSize=c,m(i);const d=document.createRange();d.selectNodeContents(a),t.removeAllRanges(),t.addRange(d);return}if(!i)return;const u=new Set(Array.from(i.querySelectorAll("font[size], [style*='font-size']")));i.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}let l=document.execCommand("fontSize",!1,"7");const f=t.rangeCount>0?t.getRangeAt(0).cloneRange():r,b=R(i,u,c,f);if(l&&b){S(i),m(i);return}l=v(r,t,c),l&&(S(i),m(i))}function L(e){let o=e;for(;o&&o!==document.body;){if(o.nodeType===Node.ELEMENT_NODE){const t=o;if(t.tagName==="SPAN"&&t.style.fontSize)return t}o=o.parentNode}return null}function M(e,o){const t=e.startContainer,n=e.endContainer;return o.contains(t)&&o.contains(n)}function y(){setTimeout(()=>{const{value:e,unit:o}=C(),t=window.getSelection();if(!t||t.rangeCount===0)return;let n=null,i=t.getRangeAt(0).startContainer;for(;i;){if(i instanceof HTMLElement&&(i.classList.contains("rte-editor")||i.classList.contains("editora-editor")||i.hasAttribute("data-editora-editor"))){n=i;break}i=i.parentNode}if(!n)return;const c=n.querySelector(".rte-toolbar-wrapper, .editora-toolbar-container")||n,s=Array.from(c.querySelectorAll('input[data-command="setFontSize"], input.editora-toolbar-input.font-size, input.rte-toolbar-input.font-size, input[title="Font Size"]'));if(s.length===0)return;const u=`${e%1===0?e.toString():e.toFixed(2).replace(/\.?0+$/,"")}${o}`;s.forEach(l=>{l.value=u})},10)}exports.FontSizePlugin=N;
|
package/dist/font-size.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { r as b } from "./historyHelpers-BEKwNOtA.mjs";
|
|
2
|
+
const _ = () => ({
|
|
2
3
|
name: "fontSize",
|
|
3
4
|
marks: {
|
|
4
5
|
fontSize: {
|
|
@@ -54,14 +55,14 @@ const O = () => ({
|
|
|
54
55
|
commands: {
|
|
55
56
|
decreaseFontSize: () => {
|
|
56
57
|
try {
|
|
57
|
-
return
|
|
58
|
+
return g(-2), y(), !0;
|
|
58
59
|
} catch (e) {
|
|
59
60
|
return console.error("Failed to decrease font size:", e), !1;
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
increaseFontSize: () => {
|
|
63
64
|
try {
|
|
64
|
-
return
|
|
65
|
+
return g(2), y(), !0;
|
|
65
66
|
} catch (e) {
|
|
66
67
|
return console.error("Failed to increase font size:", e), !1;
|
|
67
68
|
}
|
|
@@ -71,15 +72,15 @@ const O = () => ({
|
|
|
71
72
|
try {
|
|
72
73
|
const t = e.trim().match(/^(\d+(?:\.\d+)?)(px|em|rem)?$/i);
|
|
73
74
|
if (!t) return !1;
|
|
74
|
-
const n = parseFloat(t[1]),
|
|
75
|
-
return
|
|
75
|
+
const n = parseFloat(t[1]), r = t[2]?.toLowerCase() || "px";
|
|
76
|
+
return r === "px" && (n < 8 || n > 72) || (r === "em" || r === "rem") && (n < 0.5 || n > 5) ? !1 : (F(n, r), !0);
|
|
76
77
|
} catch (o) {
|
|
77
78
|
return console.error("Failed to set font size:", o), !1;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
},
|
|
81
82
|
keymap: {}
|
|
82
|
-
}),
|
|
83
|
+
}), N = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre", z = {
|
|
83
84
|
"xx-small": 9,
|
|
84
85
|
"x-small": 10,
|
|
85
86
|
small: 13,
|
|
@@ -98,34 +99,34 @@ function p(e) {
|
|
|
98
99
|
value: parseFloat(t[1]),
|
|
99
100
|
unit: t[2].toLowerCase()
|
|
100
101
|
};
|
|
101
|
-
const n =
|
|
102
|
+
const n = z[o];
|
|
102
103
|
return n ? { value: n, unit: "px" } : null;
|
|
103
104
|
}
|
|
104
|
-
function
|
|
105
|
-
return e.trim().toLowerCase() in
|
|
105
|
+
function x(e) {
|
|
106
|
+
return e.trim().toLowerCase() in z;
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
-
return !!e.cloneContents().querySelector(
|
|
108
|
+
function w(e) {
|
|
109
|
+
return !!e.cloneContents().querySelector(N);
|
|
109
110
|
}
|
|
110
|
-
function
|
|
111
|
+
function h(e) {
|
|
111
112
|
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
|
|
112
113
|
}
|
|
113
114
|
function m(e) {
|
|
114
115
|
e && e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function E(e, o) {
|
|
117
118
|
const t = document.createElement("span");
|
|
118
|
-
for (const
|
|
119
|
-
|
|
119
|
+
for (const r of Array.from(e.attributes))
|
|
120
|
+
r.name === "size" || r.name === "style" || t.setAttribute(r.name, r.value);
|
|
120
121
|
const n = e.getAttribute("style");
|
|
121
122
|
for (n && t.setAttribute("style", n), t.style.fontSize = o; e.firstChild; )
|
|
122
123
|
t.appendChild(e.firstChild);
|
|
123
124
|
e.parentNode?.replaceChild(t, e);
|
|
124
125
|
}
|
|
125
|
-
function
|
|
126
|
-
const
|
|
126
|
+
function T(e, o, t, n) {
|
|
127
|
+
const r = Array.from(
|
|
127
128
|
e.querySelectorAll("font[size], [style*='font-size']")
|
|
128
|
-
),
|
|
129
|
+
), i = (s) => {
|
|
129
130
|
if (!n || !s.isConnected) return !1;
|
|
130
131
|
try {
|
|
131
132
|
if (typeof n.intersectsNode == "function")
|
|
@@ -136,11 +137,11 @@ function E(e, o, t, n) {
|
|
|
136
137
|
return a.selectNodeContents(s), n.compareBoundaryPoints(Range.END_TO_START, a) > 0 && n.compareBoundaryPoints(Range.START_TO_END, a) < 0;
|
|
137
138
|
};
|
|
138
139
|
let c = !1;
|
|
139
|
-
return
|
|
140
|
-
const a = !o.has(s), u = s.tagName === "FONT", l =
|
|
140
|
+
return r.forEach((s) => {
|
|
141
|
+
const a = !o.has(s), u = s.tagName === "FONT", l = x(s.style.fontSize || ""), f = i(s);
|
|
141
142
|
if (!(!a && !f) && !(!a && !u && !l)) {
|
|
142
143
|
if (c = !0, s.tagName === "FONT") {
|
|
143
|
-
|
|
144
|
+
E(s, t);
|
|
144
145
|
return;
|
|
145
146
|
}
|
|
146
147
|
s.style.fontSize = t;
|
|
@@ -152,38 +153,38 @@ function S(e) {
|
|
|
152
153
|
t.childElementCount > 0 || (t.textContent || "").trim().length > 0 || t.remove();
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
-
if (
|
|
156
|
+
function R(e, o, t) {
|
|
157
|
+
if (w(e))
|
|
157
158
|
return !1;
|
|
158
159
|
const n = document.createElement("span");
|
|
159
160
|
n.style.fontSize = t;
|
|
160
161
|
try {
|
|
161
162
|
e.surroundContents(n);
|
|
162
163
|
} catch {
|
|
163
|
-
const
|
|
164
|
-
n.appendChild(
|
|
164
|
+
const i = e.extractContents();
|
|
165
|
+
n.appendChild(i), e.insertNode(n);
|
|
165
166
|
}
|
|
166
|
-
const
|
|
167
|
-
return
|
|
167
|
+
const r = document.createRange();
|
|
168
|
+
return r.selectNodeContents(n), o.removeAllRanges(), o.addRange(r), !0;
|
|
168
169
|
}
|
|
169
|
-
function
|
|
170
|
+
function g(e) {
|
|
170
171
|
const o = window.getSelection();
|
|
171
172
|
if (!o || o.rangeCount === 0) return;
|
|
172
|
-
const { value: t, unit: n } =
|
|
173
|
-
let
|
|
174
|
-
(n === "em" || n === "rem") && (
|
|
175
|
-
let
|
|
176
|
-
n === "px" ?
|
|
173
|
+
const { value: t, unit: n } = C();
|
|
174
|
+
let r = e;
|
|
175
|
+
(n === "em" || n === "rem") && (r = e * 0.125);
|
|
176
|
+
let i;
|
|
177
|
+
n === "px" ? i = e < 0 ? Math.max(8, t + e) : Math.min(72, t + e) : i = e < 0 ? Math.max(0.5, t + r) : Math.min(5, t + r), F(i, n);
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
+
function C() {
|
|
179
180
|
const e = window.getSelection();
|
|
180
181
|
if (!e || e.rangeCount === 0)
|
|
181
182
|
return { value: 14, unit: "px" };
|
|
182
183
|
const t = e.getRangeAt(0).startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t;
|
|
183
184
|
if (n) {
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
const a = p(
|
|
185
|
+
const r = n.style?.fontSize;
|
|
186
|
+
if (r) {
|
|
187
|
+
const a = p(r);
|
|
187
188
|
if (a)
|
|
188
189
|
return a;
|
|
189
190
|
}
|
|
@@ -193,44 +194,50 @@ function h() {
|
|
|
193
194
|
}
|
|
194
195
|
return { value: 14, unit: "px" };
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
+
function F(e, o = "px") {
|
|
198
|
+
const t = window.getSelection();
|
|
199
|
+
if (!t || t.rangeCount === 0) return;
|
|
200
|
+
const n = h(t.getRangeAt(0).commonAncestorContainer), r = n ? n.innerHTML : null;
|
|
201
|
+
v(e, o), n && r !== null && b(n, r);
|
|
202
|
+
}
|
|
203
|
+
function v(e, o = "px") {
|
|
197
204
|
const t = window.getSelection();
|
|
198
205
|
if (!t || t.rangeCount === 0) return;
|
|
199
|
-
const n = t.getRangeAt(0),
|
|
206
|
+
const n = t.getRangeAt(0), r = n.cloneRange(), i = h(n.commonAncestorContainer);
|
|
200
207
|
if (n.collapsed)
|
|
201
208
|
return;
|
|
202
|
-
const c = `${e}${o}`, s = n.commonAncestorContainer, a =
|
|
203
|
-
if (a &&
|
|
204
|
-
a.style.fontSize = c, m(
|
|
209
|
+
const c = `${e}${o}`, s = n.commonAncestorContainer, a = L(s);
|
|
210
|
+
if (a && O(n, a)) {
|
|
211
|
+
a.style.fontSize = c, m(i);
|
|
205
212
|
const d = document.createRange();
|
|
206
213
|
d.selectNodeContents(a), t.removeAllRanges(), t.addRange(d);
|
|
207
214
|
return;
|
|
208
215
|
}
|
|
209
|
-
if (!
|
|
216
|
+
if (!i) return;
|
|
210
217
|
const u = new Set(
|
|
211
218
|
Array.from(
|
|
212
|
-
|
|
219
|
+
i.querySelectorAll("font[size], [style*='font-size']")
|
|
213
220
|
)
|
|
214
221
|
);
|
|
215
|
-
|
|
222
|
+
i.focus({ preventScroll: !0 });
|
|
216
223
|
try {
|
|
217
224
|
document.execCommand("styleWithCSS", !1, "true");
|
|
218
225
|
} catch {
|
|
219
226
|
}
|
|
220
227
|
let l = document.execCommand("fontSize", !1, "7");
|
|
221
|
-
const f = t.rangeCount > 0 ? t.getRangeAt(0).cloneRange() :
|
|
222
|
-
|
|
228
|
+
const f = t.rangeCount > 0 ? t.getRangeAt(0).cloneRange() : r, A = T(
|
|
229
|
+
i,
|
|
223
230
|
u,
|
|
224
231
|
c,
|
|
225
232
|
f
|
|
226
233
|
);
|
|
227
|
-
if (l &&
|
|
228
|
-
S(
|
|
234
|
+
if (l && A) {
|
|
235
|
+
S(i), m(i);
|
|
229
236
|
return;
|
|
230
237
|
}
|
|
231
|
-
l =
|
|
238
|
+
l = R(r, t, c), l && (S(i), m(i));
|
|
232
239
|
}
|
|
233
|
-
function
|
|
240
|
+
function L(e) {
|
|
234
241
|
let o = e;
|
|
235
242
|
for (; o && o !== document.body; ) {
|
|
236
243
|
if (o.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -242,21 +249,21 @@ function R(e) {
|
|
|
242
249
|
}
|
|
243
250
|
return null;
|
|
244
251
|
}
|
|
245
|
-
function
|
|
252
|
+
function O(e, o) {
|
|
246
253
|
const t = e.startContainer, n = e.endContainer;
|
|
247
254
|
return o.contains(t) && o.contains(n);
|
|
248
255
|
}
|
|
249
|
-
function
|
|
256
|
+
function y() {
|
|
250
257
|
setTimeout(() => {
|
|
251
|
-
const { value: e, unit: o } =
|
|
258
|
+
const { value: e, unit: o } = C(), t = window.getSelection();
|
|
252
259
|
if (!t || t.rangeCount === 0) return;
|
|
253
|
-
let n = null,
|
|
254
|
-
for (;
|
|
255
|
-
if (
|
|
256
|
-
n =
|
|
260
|
+
let n = null, i = t.getRangeAt(0).startContainer;
|
|
261
|
+
for (; i; ) {
|
|
262
|
+
if (i instanceof HTMLElement && (i.classList.contains("rte-editor") || i.classList.contains("editora-editor") || i.hasAttribute("data-editora-editor"))) {
|
|
263
|
+
n = i;
|
|
257
264
|
break;
|
|
258
265
|
}
|
|
259
|
-
|
|
266
|
+
i = i.parentNode;
|
|
260
267
|
}
|
|
261
268
|
if (!n) return;
|
|
262
269
|
const c = n.querySelector(
|
|
@@ -274,5 +281,5 @@ function z() {
|
|
|
274
281
|
}, 10);
|
|
275
282
|
}
|
|
276
283
|
export {
|
|
277
|
-
|
|
284
|
+
_ as FontSizePlugin
|
|
278
285
|
};
|
|
@@ -1 +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;
|
|
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){const n=t;let 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;
|