@editora/core 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,676 @@
1
+ const g = '.rte-content, .editora-content, [contenteditable="true"]', st = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", b = "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", m = "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
+ var n, r;
62
+ const e = {
63
+ ignoredFormats: (n = t.ignoredFormats) != null ? n : O,
64
+ keepActiveAfterMouseApply: (r = t.keepActiveAfterMouseApply) != null ? r : !1
65
+ };
66
+ return p = e, {
67
+ name: "formatPainter",
68
+ toolbar: [
69
+ {
70
+ label: "Format Painter",
71
+ command: "toggleFormatPainter",
72
+ icon: ft,
73
+ shortcut: "Ctrl+Alt+C / Ctrl+Alt+V"
74
+ }
75
+ ],
76
+ commands: {
77
+ retrieveFormats: (o, i) => Y(i, e),
78
+ paintFormats: (o, i) => J(i, e),
79
+ toggleFormatPainter: (o, i) => dt(i, e),
80
+ cancelFormatPainter: (o, i) => G(i)
81
+ },
82
+ initialize: () => {
83
+ mt();
84
+ }
85
+ };
86
+ };
87
+ function Y(t, e = p) {
88
+ const n = C(t);
89
+ if (!n) return !1;
90
+ const r = U(n, e);
91
+ if (!r) return !1;
92
+ const o = E(n);
93
+ return o.options = e, o.snapshot = r, I = r, M(n, !1), !0;
94
+ }
95
+ function J(t, e = p) {
96
+ const n = C(t);
97
+ if (!n) return !1;
98
+ const r = E(n);
99
+ r.options = e;
100
+ const o = r.snapshot || I;
101
+ return o ? Q(n, o) : !1;
102
+ }
103
+ function dt(t, e = p) {
104
+ const n = C(t);
105
+ if (!n) return !1;
106
+ const r = E(n);
107
+ if (r.options = e, r.active)
108
+ return h(n, !1), !0;
109
+ const o = U(n, e);
110
+ return o ? (r.snapshot = o, I = o, h(n, !0), !0) : !1;
111
+ }
112
+ function G(t) {
113
+ const e = C(t);
114
+ return e ? (h(e, !1), !0) : (document.querySelectorAll(`${g}.rte-format-painter-active`).forEach((n) => {
115
+ h(n, !1);
116
+ }), !0);
117
+ }
118
+ function mt() {
119
+ P || typeof document == "undefined" || (P = !0, document.addEventListener("keydown", Et, !0), document.addEventListener("mouseup", gt, !0));
120
+ }
121
+ function Et(t) {
122
+ const e = t.key.toLowerCase(), n = t.ctrlKey || t.metaKey;
123
+ if (t.key === "Escape") {
124
+ G();
125
+ return;
126
+ }
127
+ if (!n || !t.altKey || t.shiftKey) return;
128
+ const r = j() || C();
129
+ if (r) {
130
+ if (e === "c") {
131
+ Y({ contentElement: r }, E(r).options) && t.preventDefault();
132
+ return;
133
+ }
134
+ e === "v" && J({ contentElement: r }, E(r).options) && t.preventDefault();
135
+ }
136
+ }
137
+ function gt(t) {
138
+ const e = t.target;
139
+ if (e != null && e.closest(".rte-toolbar-wrapper, .editora-toolbar-container")) return;
140
+ const n = e == null ? void 0 : e.closest(g);
141
+ if (!(n instanceof HTMLElement)) return;
142
+ const r = E(n);
143
+ if (!r.active || !r.snapshot) return;
144
+ const o = window.getSelection();
145
+ if (!o || o.rangeCount === 0 || o.getRangeAt(0).collapsed) return;
146
+ Q(n, r.snapshot) && !r.options.keepActiveAfterMouseApply && h(n, !1);
147
+ }
148
+ function E(t) {
149
+ let e = v.get(t);
150
+ return e || (e = { snapshot: null, active: !1, options: p }, v.set(t, e)), e;
151
+ }
152
+ function C(t) {
153
+ var o;
154
+ if ((t == null ? void 0 : t.contentElement) instanceof HTMLElement) return t.contentElement;
155
+ const e = D((o = t == null ? void 0 : t.editorElement) != null ? o : null);
156
+ if (e) return e;
157
+ const n = typeof window != "undefined" ? window.__editoraCommandEditorRoot : null, r = D(n);
158
+ return r || j() || ht();
159
+ }
160
+ function D(t) {
161
+ return t ? t.matches(g) ? t : t.querySelector(g) : null;
162
+ }
163
+ function j() {
164
+ const t = window.getSelection();
165
+ if (!t || t.rangeCount === 0) return null;
166
+ const e = t.getRangeAt(0), n = d(e.commonAncestorContainer), r = n == null ? void 0 : n.closest(g);
167
+ return r instanceof HTMLElement ? r : null;
168
+ }
169
+ function ht() {
170
+ const t = document.activeElement;
171
+ if (!(t instanceof HTMLElement)) return null;
172
+ const e = t.closest(g);
173
+ return e instanceof HTMLElement ? e : null;
174
+ }
175
+ function d(t) {
176
+ return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
177
+ }
178
+ function U(t, e) {
179
+ const n = window.getSelection(), r = n && n.rangeCount > 0 ? n.getRangeAt(0) : null, o = r ? r.collapsed ? r.startContainer : r.commonAncestorContainer : null, i = d(o) || t;
180
+ if (!t.contains(i)) return null;
181
+ const s = ee(e.ignoredFormats), a = nt(i, t), l = i.closest("li"), u = l == null ? void 0 : l.closest(_), f = i.closest(w), it = f == null ? void 0 : f.closest("table");
182
+ return {
183
+ inline: pt(r, i, t, s),
184
+ block: !c(s, "block") && a ? Nt(a, s) : null,
185
+ list: !c(s, "list") && u ? bt(u, l) : null,
186
+ table: c(s, "table") ? null : kt(it, f, s),
187
+ ignoredFormats: s
188
+ };
189
+ }
190
+ function pt(t, e, n, r) {
191
+ if (!t || t.collapsed)
192
+ return H(e, r);
193
+ const i = Ct(t, e, n).map((s) => H(s, r));
194
+ return Tt(i);
195
+ }
196
+ function Ct(t, e, n) {
197
+ const r = [], o = document.createTreeWalker(
198
+ t.commonAncestorContainer,
199
+ NodeFilter.SHOW_TEXT,
200
+ {
201
+ acceptNode: (s) => !n.contains(s) || !t.intersectsNode(s) ? NodeFilter.FILTER_REJECT : (s.textContent || "").trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
202
+ }
203
+ );
204
+ let i = o.nextNode();
205
+ for (; i && r.length < 64; ) {
206
+ const s = d(i);
207
+ s && !r.includes(s) && r.push(s), i = o.nextNode();
208
+ }
209
+ return r.length > 0 ? r : [e];
210
+ }
211
+ function H(t, e) {
212
+ const n = window.getComputedStyle(t), r = {};
213
+ c(e, "bold") || (r.bold = St(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"));
214
+ const o = {};
215
+ return L.forEach((i) => {
216
+ if (c(e, i)) return;
217
+ const s = n[i];
218
+ yt(i, s) && (o[i] = s);
219
+ }), { marks: r, styles: o };
220
+ }
221
+ function Tt(t) {
222
+ const e = {};
223
+ ["bold", "italic", "underline", "strikethrough"].forEach((o) => {
224
+ const i = t.map((s) => s.marks[o]).filter((s) => s != null);
225
+ i.length !== 0 && (e[o] = i.every(Boolean));
226
+ });
227
+ const r = {};
228
+ return L.forEach((o) => {
229
+ const i = t.map((s) => s.styles[o]).filter((s) => !!s);
230
+ i.length === t.length && i.every((s) => s === i[0]) && (r[o] = i[0]);
231
+ }), { marks: e, styles: r };
232
+ }
233
+ function Nt(t, e) {
234
+ const n = window.getComputedStyle(t), r = {};
235
+ at.forEach((s) => {
236
+ if (c(e, s)) return;
237
+ const l = t.style[s] || n[s];
238
+ Lt(s, l) && (r[s] = l);
239
+ });
240
+ const o = {}, i = t.getAttribute("dir") || t.style.direction;
241
+ return (i === "ltr" || i === "rtl" || i === "auto") && (o.dir = i), {
242
+ tagName: rt(t),
243
+ styles: r,
244
+ attrs: o
245
+ };
246
+ }
247
+ function bt(t, e) {
248
+ const n = {};
249
+ lt.forEach((i) => {
250
+ const s = t.style[i] || window.getComputedStyle(t)[i];
251
+ s && s !== "disc" && s !== "decimal" && (n[i] = s);
252
+ });
253
+ const r = {};
254
+ N(t, r, "data-type"), N(t, r, "type");
255
+ const o = {};
256
+ return e && (N(e, o, "data-type"), N(e, o, "data-checked")), {
257
+ tagName: t.tagName.toLowerCase() === "ol" ? "ol" : "ul",
258
+ styles: n,
259
+ attrs: r,
260
+ itemAttrs: o
261
+ };
262
+ }
263
+ function kt(t, e, n) {
264
+ return !t && !e ? null : {
265
+ table: t ? W(t, ct, n) : null,
266
+ cell: e ? W(e, ut, n) : null
267
+ };
268
+ }
269
+ function W(t, e, n) {
270
+ const r = window.getComputedStyle(t), o = {};
271
+ return e.forEach((i) => {
272
+ if (c(n, i)) return;
273
+ const a = t.style[i] || r[i];
274
+ Rt(i, a) && (o[i] = a);
275
+ }), { styles: o, attrs: {} };
276
+ }
277
+ function St(t, e) {
278
+ if (t.closest("b,strong")) return !0;
279
+ const n = e.fontWeight;
280
+ return /^(bold|bolder|[5-9]\d{2,})$/.test(n);
281
+ }
282
+ function At(t, e) {
283
+ return !!t.closest("i,em") || e.fontStyle === "italic";
284
+ }
285
+ function $(t, e, n) {
286
+ const r = n === "underline" ? "u" : "s,strike";
287
+ return !!t.closest(r) || e.textDecorationLine.includes(n);
288
+ }
289
+ function yt(t, e) {
290
+ return !(!e || t === "backgroundColor" && (e === "rgba(0, 0, 0, 0)" || e === "transparent") || t === "textTransform" && e === "none");
291
+ }
292
+ function Lt(t, e) {
293
+ return !(!e || t === "textAlign" && e === "start" || t === "lineHeight" && e === "normal" || (t === "marginLeft" || t === "marginRight") && e === "0px");
294
+ }
295
+ function Rt(t, e) {
296
+ 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");
297
+ }
298
+ function Q(t, e) {
299
+ const n = window.getSelection();
300
+ if (!n || n.rangeCount === 0) return !1;
301
+ const r = n.getRangeAt(0);
302
+ if (!t.contains(r.startContainer) || !t.contains(r.endContainer)) return !1;
303
+ const o = t.innerHTML, i = !r.collapsed, s = Jt(t);
304
+ Ft(t, r, e.table), wt(t, r, e), s == null || s();
305
+ const a = window.getSelection(), l = a && a.rangeCount > 0 ? a.getRangeAt(0) : null;
306
+ i && a && l && t.contains(l.startContainer) && t.contains(l.endContainer) && Mt(l, a, e), Ut(t), Qt(t);
307
+ const u = t.innerHTML;
308
+ return o === u ? !1 : (te(t, o, u), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0);
309
+ }
310
+ function wt(t, e, n) {
311
+ const r = Xt(t, e);
312
+ n.list && zt(r, n.list), n.block && r.forEach((o) => {
313
+ const i = o.isConnected ? o : null;
314
+ if (!i) return;
315
+ const s = Vt(i, n.block.tagName);
316
+ k(s, n.block.styles), n.block.attrs.dir ? s.setAttribute("dir", n.block.attrs.dir) : s.removeAttribute("dir");
317
+ });
318
+ }
319
+ function Ft(t, e, n) {
320
+ var i;
321
+ if (!n) return;
322
+ const r = Kt(t, e);
323
+ if (n.cell && r.forEach((s) => {
324
+ k(s, n.cell.styles);
325
+ }), !n.table) return;
326
+ const o = /* @__PURE__ */ new Set();
327
+ if (r.forEach((s) => {
328
+ const a = s.closest("table");
329
+ a instanceof HTMLElement && o.add(a);
330
+ }), o.size === 0) {
331
+ const s = (i = d(e.startContainer)) == null ? void 0 : i.closest("table");
332
+ s instanceof HTMLElement && t.contains(s) && o.add(s);
333
+ }
334
+ o.forEach((s) => {
335
+ k(s, n.table.styles);
336
+ });
337
+ }
338
+ function Mt(t, e, n) {
339
+ vt(t);
340
+ const r = n.inline, o = t.cloneContents();
341
+ if (Yt(o)) {
342
+ _t(t, e, n);
343
+ return;
344
+ }
345
+ const i = t.extractContents();
346
+ qt(i, n);
347
+ const s = document.createDocumentFragment(), a = K("start"), l = K("end");
348
+ s.appendChild(a), s.appendChild(et(i, r)), s.appendChild(l), t.insertNode(s), Dt(a, l, n);
349
+ const u = document.createRange();
350
+ u.setStartAfter(a), u.setEndBefore(l), e.removeAllRanges(), e.addRange(u);
351
+ }
352
+ function _t(t, e, n) {
353
+ const r = Ot(t), o = [];
354
+ if (r.forEach((s) => {
355
+ var u;
356
+ let a = It(s, t);
357
+ if (!a || !a.data.trim() || $t(a)) return;
358
+ a = xt(a, n);
359
+ const l = et(document.createTextNode(a.data), n.inline);
360
+ (u = a.parentNode) == null || u.replaceChild(l, a), o.push(l);
361
+ }), o.length === 0) return;
362
+ const i = document.createRange();
363
+ i.setStartBefore(o[0]), i.setEndAfter(o[o.length - 1]), e.removeAllRanges(), e.addRange(i);
364
+ }
365
+ function Ot(t) {
366
+ if (t.startContainer === t.endContainer && t.startContainer.nodeType === Node.TEXT_NODE)
367
+ return [t.startContainer];
368
+ const e = [], n = document.createTreeWalker(t.commonAncestorContainer, NodeFilter.SHOW_TEXT, {
369
+ acceptNode: (o) => !o.textContent || !o.textContent.trim() || !t.intersectsNode(o) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
370
+ });
371
+ let r = n.nextNode();
372
+ for (; r; )
373
+ e.push(r), r = n.nextNode();
374
+ return e;
375
+ }
376
+ function It(t, e) {
377
+ const n = t.data.length;
378
+ let r = 0, o = n;
379
+ 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;
380
+ let i = t;
381
+ return o < i.data.length && i.splitText(o), r > 0 && (i = i.splitText(r)), i;
382
+ }
383
+ function xt(t, e) {
384
+ let n = t, r = n.parentElement;
385
+ for (; r && r.matches(y) && !x(r, e) && tt(r, e); )
386
+ Bt(r, n), r = n.parentElement;
387
+ return n;
388
+ }
389
+ function Bt(t, e) {
390
+ const n = t.parentNode;
391
+ if (!n || e.parentNode !== t) return;
392
+ const r = t.cloneNode(!1), o = t.cloneNode(!1);
393
+ for (; t.firstChild && t.firstChild !== e; )
394
+ r.appendChild(t.firstChild);
395
+ for (; e.nextSibling; )
396
+ o.appendChild(e.nextSibling);
397
+ q(r) && n.insertBefore(r, t), n.insertBefore(e, t), q(o) && n.insertBefore(o, t), n.removeChild(t);
398
+ }
399
+ function q(t) {
400
+ return Array.from(t.childNodes).some((e) => e.nodeType !== Node.TEXT_NODE ? !0 : !!(e.textContent || "").trim());
401
+ }
402
+ function vt(t) {
403
+ let e = d(t.startContainer), n = d(t.endContainer);
404
+ for (; e && e === n && e.matches(y); ) {
405
+ if (!Pt(t, e)) return;
406
+ t.selectNode(e), e = e.parentElement, n = d(t.endContainer);
407
+ }
408
+ }
409
+ function Pt(t, e) {
410
+ const n = document.createRange();
411
+ return n.selectNodeContents(e), t.compareBoundaryPoints(Range.START_TO_START, n) === 0 && t.compareBoundaryPoints(Range.END_TO_END, n) === 0;
412
+ }
413
+ function Dt(t, e, n) {
414
+ let r = d(t.parentNode);
415
+ for (; r && r.contains(e); ) {
416
+ const o = r.parentElement;
417
+ r.matches(y) && !x(r, n) && Ht(r, t, e) && tt(r, n) && S(r), r = o;
418
+ }
419
+ }
420
+ function Ht(t, e, n) {
421
+ let r = "before";
422
+ for (const o of Array.from(t.childNodes)) {
423
+ if (o === e) {
424
+ r = "inside";
425
+ continue;
426
+ }
427
+ if (o === n) {
428
+ r = "after";
429
+ continue;
430
+ }
431
+ if (r !== "inside" && !Wt(o))
432
+ return !1;
433
+ }
434
+ return r === "after";
435
+ }
436
+ function Wt(t) {
437
+ 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(m);
438
+ }
439
+ function tt(t, e) {
440
+ 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;
441
+ }
442
+ function $t(t) {
443
+ if (t.nodeType !== Node.TEXT_NODE || (t.textContent || "").trim()) return !1;
444
+ const e = t.parentElement;
445
+ return !!(e != null && e.matches(_));
446
+ }
447
+ function et(t, e) {
448
+ let n = t;
449
+ const r = Object.entries(e.styles);
450
+ if (r.length > 0) {
451
+ const o = document.createElement("span");
452
+ o.classList.add("rte-format-painted"), r.forEach(([i, s]) => {
453
+ o.style.setProperty(B(i), s);
454
+ }), o.appendChild(n), n = o;
455
+ }
456
+ 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;
457
+ }
458
+ function T(t, e) {
459
+ const n = document.createElement(t);
460
+ return n.appendChild(e), n;
461
+ }
462
+ function qt(t, e) {
463
+ Array.from(t.querySelectorAll(y)).forEach((n) => {
464
+ if (n instanceof HTMLElement && !x(n, e)) {
465
+ if (n.matches("span")) {
466
+ if (L.forEach((r) => {
467
+ c(e.ignoredFormats, r) || n.style.removeProperty(B(r));
468
+ }), n.getAttribute("style") || n.attributes.length > 0) return;
469
+ S(n);
470
+ return;
471
+ }
472
+ 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") || S(n);
473
+ }
474
+ });
475
+ }
476
+ function x(t, e) {
477
+ 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"));
478
+ }
479
+ function R(t, e) {
480
+ const n = e.toLowerCase();
481
+ return t.className.toString().toLowerCase().includes(n) ? !0 : Array.from(t.attributes).some((o) => {
482
+ const i = A(o.name), s = o.value.toLowerCase();
483
+ return i.includes(n) || s.includes(n);
484
+ });
485
+ }
486
+ function zt(t, e) {
487
+ t.filter((r) => r.tagName.toLowerCase() === "li").forEach((r) => {
488
+ const o = r.closest(_);
489
+ if (!o) return;
490
+ const i = Zt(o, e.tagName);
491
+ k(i, e.styles), Z(i, e.attrs), Z(r, e.itemAttrs);
492
+ });
493
+ }
494
+ function Kt(t, e) {
495
+ var o;
496
+ const n = Array.from(t.querySelectorAll(w)).filter((i) => i instanceof HTMLElement && e.intersectsNode(i));
497
+ if (n.length > 0) return n;
498
+ const r = (o = d(e.startContainer)) == null ? void 0 : o.closest(w);
499
+ return r instanceof HTMLElement && t.contains(r) ? [r] : [];
500
+ }
501
+ function k(t, e) {
502
+ Object.entries(e).forEach(([n, r]) => {
503
+ t.style.setProperty(B(n), r);
504
+ });
505
+ }
506
+ function Vt(t, e) {
507
+ var o, i;
508
+ const n = rt(t);
509
+ if (n === e || n === "li" || n === "td" || n === "th") return t;
510
+ if (e === "blockquote") {
511
+ const s = document.createElement("blockquote");
512
+ for (; t.firstChild; ) s.appendChild(t.firstChild);
513
+ return F(t, s), (o = t.parentNode) == null || o.replaceChild(s, t), s;
514
+ }
515
+ if (!/^(p|div|h[1-6]|pre)$/.test(e)) return t;
516
+ const r = document.createElement(e);
517
+ for (; t.firstChild; ) r.appendChild(t.firstChild);
518
+ return F(t, r), (i = t.parentNode) == null || i.replaceChild(r, t), r;
519
+ }
520
+ function Zt(t, e) {
521
+ var r;
522
+ if (t.tagName.toLowerCase() === e) return t;
523
+ const n = document.createElement(e);
524
+ for (; t.firstChild; ) n.appendChild(t.firstChild);
525
+ return F(t, n), (r = t.parentNode) == null || r.replaceChild(n, t), n;
526
+ }
527
+ function Xt(t, e) {
528
+ const n = Array.from(t.querySelectorAll(b)).filter((o) => o instanceof HTMLElement && e.intersectsNode(o));
529
+ if (n.length > 0)
530
+ return n.filter((o) => !n.some((i) => i !== o && i.contains(o)));
531
+ const r = nt(d(e.startContainer), t);
532
+ return r ? [r] : [];
533
+ }
534
+ function nt(t, e) {
535
+ const n = t == null ? void 0 : t.closest(b);
536
+ return n instanceof HTMLElement && e.contains(n) ? n : null;
537
+ }
538
+ function rt(t) {
539
+ const e = t.tagName.toLowerCase();
540
+ return e === "blockquote" || /^h[1-6]$/.test(e) || e === "pre" || e === "li" || e === "td" || e === "th" ? e : "p";
541
+ }
542
+ function Yt(t) {
543
+ return Array.from(t.childNodes).some((e) => {
544
+ if (e.nodeType !== Node.ELEMENT_NODE) return !1;
545
+ const n = e;
546
+ return n.matches(b) || !!n.querySelector(b);
547
+ });
548
+ }
549
+ function Jt(t) {
550
+ const e = window.getSelection();
551
+ if (!e || e.rangeCount === 0) return null;
552
+ const n = e.getRangeAt(0);
553
+ if (!t.contains(n.startContainer) || !t.contains(n.endContainer)) return null;
554
+ const r = n.collapsed, o = z("start"), i = z("end"), s = n.cloneRange();
555
+ if (!r) {
556
+ const l = s.cloneRange();
557
+ l.collapse(!1), l.insertNode(i);
558
+ }
559
+ const a = s.cloneRange();
560
+ return a.collapse(!0), a.insertNode(o), () => {
561
+ const l = V(t, "start"), u = V(t, "end");
562
+ if (!l) return;
563
+ const f = document.createRange();
564
+ r || !u ? (f.setStartAfter(l), f.collapse(!0)) : (f.setStartAfter(l), f.setEndBefore(u)), e.removeAllRanges(), e.addRange(f);
565
+ };
566
+ }
567
+ function z(t) {
568
+ return document.createComment(`${m}:selection:${t}`);
569
+ }
570
+ function K(t) {
571
+ return document.createComment(`${m}:inline:${t}`);
572
+ }
573
+ function ot(t) {
574
+ return Gt(t) || jt(t);
575
+ }
576
+ function Gt(t) {
577
+ return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${m}:selection:start` || t.nodeValue === `${m}:selection:end`);
578
+ }
579
+ function jt(t) {
580
+ return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${m}:inline:start` || t.nodeValue === `${m}:inline:end`);
581
+ }
582
+ function V(t, e) {
583
+ const n = `${m}:selection:${e}`, r = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT);
584
+ let o = r.nextNode();
585
+ for (; o; ) {
586
+ if (o.nodeValue === n) return o;
587
+ o = r.nextNode();
588
+ }
589
+ return null;
590
+ }
591
+ function Ut(t) {
592
+ t.querySelectorAll(`[${m}]`).forEach((o) => o.remove());
593
+ const e = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT), n = [];
594
+ let r = e.nextNode();
595
+ for (; r; )
596
+ ot(r) && n.push(r), r = e.nextNode();
597
+ n.forEach((o) => o.remove());
598
+ }
599
+ function Qt(t) {
600
+ t.querySelectorAll("span").forEach((e) => {
601
+ e instanceof HTMLElement && (e.attributes.length > 0 || S(e));
602
+ });
603
+ }
604
+ function S(t) {
605
+ const e = t.parentNode;
606
+ if (e) {
607
+ for (; t.firstChild; )
608
+ e.insertBefore(t.firstChild, t);
609
+ e.removeChild(t);
610
+ }
611
+ }
612
+ function N(t, e, n) {
613
+ const r = t.getAttribute(n);
614
+ r != null && (e[n] = r);
615
+ }
616
+ function Z(t, e) {
617
+ ["data-type", "data-checked", "type"].forEach((n) => {
618
+ e[n] != null && t.setAttribute(n, e[n]);
619
+ });
620
+ }
621
+ function F(t, e) {
622
+ Array.from(t.attributes).forEach((n) => {
623
+ n.name !== "style" && e.setAttribute(n.name, n.value);
624
+ });
625
+ }
626
+ function h(t, e) {
627
+ const n = E(t);
628
+ if (n.active === e && t.classList.contains("rte-format-painter-active") === e) {
629
+ M(t, e);
630
+ return;
631
+ }
632
+ n.active = e, t.classList.toggle("rte-format-painter-active", e), M(t, e);
633
+ }
634
+ function M(t, e) {
635
+ const n = t.closest(st) || document;
636
+ n.querySelectorAll(
637
+ '[data-command="toggleFormatPainter"], [data-command="formatPainter"]'
638
+ ).forEach((o) => {
639
+ o instanceof HTMLElement && (o.classList.toggle("active", e), o.setAttribute("data-active", e ? "true" : "false"), o.setAttribute("aria-pressed", e ? "true" : "false"));
640
+ }), n.dispatchEvent(
641
+ new CustomEvent("editora:format-painter-toggle", {
642
+ bubbles: !0,
643
+ detail: { active: e }
644
+ })
645
+ );
646
+ }
647
+ function te(t, e, n) {
648
+ if (e === n) return;
649
+ const r = window.execEditorCommand || window.executeEditorCommand;
650
+ if (typeof r == "function")
651
+ try {
652
+ r("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n });
653
+ } catch (o) {
654
+ try {
655
+ r("recordDomTransaction", t, e, n);
656
+ } catch (i) {
657
+ }
658
+ }
659
+ }
660
+ function ee(t) {
661
+ return (t != null ? t : O).map(A).map((e) => X[e] || e).filter(Boolean);
662
+ }
663
+ function c(t, e) {
664
+ const n = X[A(e)] || A(e);
665
+ return t.includes(n);
666
+ }
667
+ function A(t) {
668
+ return t.toLowerCase().replace(/[^a-z0-9]/g, "");
669
+ }
670
+ function B(t) {
671
+ return t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
672
+ }
673
+ export {
674
+ ne as FormatPainterPlugin
675
+ };
676
+ //# sourceMappingURL=FormatPainterPlugin.native-CsMrKfFU.mjs.map