@editora/plugins 1.0.13 → 1.0.15

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,666 @@
1
+ const E = '.rte-content, .editora-content, [contenteditable="true"]', st = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", N = "p,div,li,h1,h2,h3,h4,h5,h6,blockquote,pre,td,th", _ = "ul,ol", y = "b,strong,i,em,u,s,strike,font,span", w = "td,th", d = "data-editora-format-painter-bookmark", O = ["link", "address", "comments", "citations", "track-changes"], L = [
2
+ "fontFamily",
3
+ "fontSize",
4
+ "color",
5
+ "backgroundColor",
6
+ "textTransform"
7
+ ], at = [
8
+ "textAlign",
9
+ "lineHeight",
10
+ "marginLeft",
11
+ "marginRight"
12
+ ], lt = ["listStyleType"], ct = [
13
+ "borderCollapse",
14
+ "borderSpacing",
15
+ "width"
16
+ ], ut = [
17
+ "backgroundColor",
18
+ "textAlign",
19
+ "verticalAlign",
20
+ "borderTopColor",
21
+ "borderRightColor",
22
+ "borderBottomColor",
23
+ "borderLeftColor",
24
+ "borderTopStyle",
25
+ "borderRightStyle",
26
+ "borderBottomStyle",
27
+ "borderLeftStyle",
28
+ "borderTopWidth",
29
+ "borderRightWidth",
30
+ "borderBottomWidth",
31
+ "borderLeftWidth",
32
+ "paddingTop",
33
+ "paddingRight",
34
+ "paddingBottom",
35
+ "paddingLeft"
36
+ ], X = {
37
+ background: "backgroundcolor",
38
+ bgcolor: "backgroundcolor",
39
+ blockquote: "block",
40
+ blocks: "block",
41
+ font: "fontfamily",
42
+ fontname: "fontfamily",
43
+ fontsize: "fontsize",
44
+ foreground: "color",
45
+ forecolor: "color",
46
+ heading: "block",
47
+ headings: "block",
48
+ liststyle: "list",
49
+ lists: "list",
50
+ strike: "strikethrough",
51
+ tablecell: "table",
52
+ tablecells: "table",
53
+ textcolor: "color",
54
+ texttransform: "texttransform"
55
+ }, ft = '<svg width="24" height="24" focusable="false" viewBox="0 0 24 24"><path d="M17.8 3.2a2.8 2.8 0 0 1 4 4L14 15l-4-4 7.8-7.8Zm-1.4 4.2L19 10l1.4-1.4-2.6-2.6-1.4 1.4Zm-7.8 5 3 3-1.4 1.4c-.5.5-1.2.8-1.9.8H7.2l-1.6 1.6a2.7 2.7 0 0 1-3.8 0 1 1 0 0 1 0-1.4l6.8-5.4Zm-.2 3.2H9l-4.6 3.7c.2 0 .5-.2.7-.4l1.9-1.9c.2-.2.4-.3.7-.3h1.1c.2 0 .5-.1.6-.3l.2-.2-1.2-1.3ZM5.5 3l.7 1.8L8 5.5l-1.8.7L5.5 8l-.7-1.8L3 5.5l1.8-.7L5.5 3Zm3.8 4.4.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2-1.2-.5 1.2-.5.5-1.2Z" fill-rule="evenodd"></path></svg>', v = /* @__PURE__ */ new WeakMap();
56
+ let I = null, P = !1, p = {
57
+ ignoredFormats: O,
58
+ keepActiveAfterMouseApply: !1
59
+ };
60
+ const ne = (t = {}) => {
61
+ const e = {
62
+ ignoredFormats: t.ignoredFormats ?? O,
63
+ keepActiveAfterMouseApply: t.keepActiveAfterMouseApply ?? !1
64
+ };
65
+ return p = e, {
66
+ name: "formatPainter",
67
+ toolbar: [
68
+ {
69
+ label: "Format Painter",
70
+ command: "toggleFormatPainter",
71
+ icon: ft,
72
+ shortcut: "Ctrl+Alt+C / Ctrl+Alt+V"
73
+ }
74
+ ],
75
+ commands: {
76
+ retrieveFormats: (n, r) => Y(r, e),
77
+ paintFormats: (n, r) => J(r, e),
78
+ toggleFormatPainter: (n, r) => dt(r, e),
79
+ cancelFormatPainter: (n, r) => G(r)
80
+ },
81
+ initialize: () => {
82
+ mt();
83
+ }
84
+ };
85
+ };
86
+ function Y(t, e = p) {
87
+ const n = C(t);
88
+ if (!n) return !1;
89
+ const r = U(n, e);
90
+ if (!r) return !1;
91
+ const o = g(n);
92
+ return o.options = e, o.snapshot = r, I = r, M(n, !1), !0;
93
+ }
94
+ function J(t, e = p) {
95
+ const n = C(t);
96
+ if (!n) return !1;
97
+ const r = g(n);
98
+ r.options = e;
99
+ const o = r.snapshot || I;
100
+ return o ? Q(n, o) : !1;
101
+ }
102
+ function dt(t, e = p) {
103
+ const n = C(t);
104
+ if (!n) return !1;
105
+ const r = g(n);
106
+ if (r.options = e, r.active)
107
+ return h(n, !1), !0;
108
+ const o = U(n, e);
109
+ return o ? (r.snapshot = o, I = o, h(n, !0), !0) : !1;
110
+ }
111
+ function G(t) {
112
+ const e = C(t);
113
+ return e ? (h(e, !1), !0) : (document.querySelectorAll(`${E}.rte-format-painter-active`).forEach((n) => {
114
+ h(n, !1);
115
+ }), !0);
116
+ }
117
+ function mt() {
118
+ P || typeof document > "u" || (P = !0, document.addEventListener("keydown", gt, !0), document.addEventListener("mouseup", Et, !0));
119
+ }
120
+ function gt(t) {
121
+ const e = t.key.toLowerCase(), n = t.ctrlKey || t.metaKey;
122
+ if (t.key === "Escape") {
123
+ G();
124
+ return;
125
+ }
126
+ if (!n || !t.altKey || t.shiftKey) return;
127
+ const r = j() || C();
128
+ if (r) {
129
+ if (e === "c") {
130
+ Y({ contentElement: r }, g(r).options) && t.preventDefault();
131
+ return;
132
+ }
133
+ e === "v" && J({ contentElement: r }, g(r).options) && t.preventDefault();
134
+ }
135
+ }
136
+ function Et(t) {
137
+ const e = t.target;
138
+ if (e?.closest(".rte-toolbar-wrapper, .editora-toolbar-container")) return;
139
+ const n = e?.closest(E);
140
+ if (!(n instanceof HTMLElement)) return;
141
+ const r = g(n);
142
+ if (!r.active || !r.snapshot) return;
143
+ const o = window.getSelection();
144
+ if (!o || o.rangeCount === 0 || o.getRangeAt(0).collapsed) return;
145
+ Q(n, r.snapshot) && !r.options.keepActiveAfterMouseApply && h(n, !1);
146
+ }
147
+ function g(t) {
148
+ let e = v.get(t);
149
+ return e || (e = { snapshot: null, active: !1, options: p }, v.set(t, e)), e;
150
+ }
151
+ function C(t) {
152
+ if (t?.contentElement instanceof HTMLElement) return t.contentElement;
153
+ const e = D(t?.editorElement ?? null);
154
+ if (e) return e;
155
+ const n = typeof window < "u" ? window.__editoraCommandEditorRoot : null, r = D(n);
156
+ return r || j() || ht();
157
+ }
158
+ function D(t) {
159
+ return t ? t.matches(E) ? t : t.querySelector(E) : null;
160
+ }
161
+ function j() {
162
+ const t = window.getSelection();
163
+ if (!t || t.rangeCount === 0) return null;
164
+ const e = t.getRangeAt(0), r = f(e.commonAncestorContainer)?.closest(E);
165
+ return r instanceof HTMLElement ? r : null;
166
+ }
167
+ function ht() {
168
+ const t = document.activeElement;
169
+ if (!(t instanceof HTMLElement)) return null;
170
+ const e = t.closest(E);
171
+ return e instanceof HTMLElement ? e : null;
172
+ }
173
+ function f(t) {
174
+ return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
175
+ }
176
+ function U(t, e) {
177
+ const n = window.getSelection(), r = n && n.rangeCount > 0 ? n.getRangeAt(0) : null, o = r ? r.collapsed ? r.startContainer : r.commonAncestorContainer : null, i = f(o) || t;
178
+ if (!t.contains(i)) return null;
179
+ const s = ee(e.ignoredFormats), a = nt(i, t), l = i.closest("li"), u = l?.closest(_), m = i.closest(w), it = m?.closest("table");
180
+ return {
181
+ inline: pt(r, i, t, s),
182
+ block: !c(s, "block") && a ? bt(a, s) : null,
183
+ list: !c(s, "list") && u ? Nt(u, l) : null,
184
+ table: c(s, "table") ? null : St(it, m, s),
185
+ ignoredFormats: s
186
+ };
187
+ }
188
+ function pt(t, e, n, r) {
189
+ if (!t || t.collapsed)
190
+ return H(e, r);
191
+ const i = Ct(t, e, n).map((s) => H(s, r));
192
+ return Tt(i);
193
+ }
194
+ function Ct(t, e, n) {
195
+ const r = [], o = document.createTreeWalker(
196
+ t.commonAncestorContainer,
197
+ NodeFilter.SHOW_TEXT,
198
+ {
199
+ acceptNode: (s) => !n.contains(s) || !t.intersectsNode(s) ? NodeFilter.FILTER_REJECT : (s.textContent || "").trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
200
+ }
201
+ );
202
+ let i = o.nextNode();
203
+ for (; i && r.length < 64; ) {
204
+ const s = f(i);
205
+ s && !r.includes(s) && r.push(s), i = o.nextNode();
206
+ }
207
+ return r.length > 0 ? r : [e];
208
+ }
209
+ function H(t, e) {
210
+ const n = window.getComputedStyle(t), r = {};
211
+ c(e, "bold") || (r.bold = kt(t, n)), c(e, "italic") || (r.italic = At(t, n)), c(e, "underline") || (r.underline = $(t, n, "underline")), c(e, "strikethrough") || (r.strikethrough = $(t, n, "line-through"));
212
+ const o = {};
213
+ return L.forEach((i) => {
214
+ if (c(e, i)) return;
215
+ const s = n[i];
216
+ yt(i, s) && (o[i] = s);
217
+ }), { marks: r, styles: o };
218
+ }
219
+ function Tt(t) {
220
+ const e = {};
221
+ ["bold", "italic", "underline", "strikethrough"].forEach((o) => {
222
+ const i = t.map((s) => s.marks[o]).filter((s) => s != null);
223
+ i.length !== 0 && (e[o] = i.every(Boolean));
224
+ });
225
+ const r = {};
226
+ return L.forEach((o) => {
227
+ const i = t.map((s) => s.styles[o]).filter((s) => !!s);
228
+ i.length === t.length && i.every((s) => s === i[0]) && (r[o] = i[0]);
229
+ }), { marks: e, styles: r };
230
+ }
231
+ function bt(t, e) {
232
+ const n = window.getComputedStyle(t), r = {};
233
+ at.forEach((s) => {
234
+ if (c(e, s)) return;
235
+ const l = t.style[s] || n[s];
236
+ Lt(s, l) && (r[s] = l);
237
+ });
238
+ const o = {}, i = t.getAttribute("dir") || t.style.direction;
239
+ return (i === "ltr" || i === "rtl" || i === "auto") && (o.dir = i), {
240
+ tagName: rt(t),
241
+ styles: r,
242
+ attrs: o
243
+ };
244
+ }
245
+ function Nt(t, e) {
246
+ const n = {};
247
+ lt.forEach((i) => {
248
+ const s = t.style[i] || window.getComputedStyle(t)[i];
249
+ s && s !== "disc" && s !== "decimal" && (n[i] = s);
250
+ });
251
+ const r = {};
252
+ b(t, r, "data-type"), b(t, r, "type");
253
+ const o = {};
254
+ return e && (b(e, o, "data-type"), b(e, o, "data-checked")), {
255
+ tagName: t.tagName.toLowerCase() === "ol" ? "ol" : "ul",
256
+ styles: n,
257
+ attrs: r,
258
+ itemAttrs: o
259
+ };
260
+ }
261
+ function St(t, e, n) {
262
+ return !t && !e ? null : {
263
+ table: t ? W(t, ct, n) : null,
264
+ cell: e ? W(e, ut, n) : null
265
+ };
266
+ }
267
+ function W(t, e, n) {
268
+ const r = window.getComputedStyle(t), o = {};
269
+ return e.forEach((i) => {
270
+ if (c(n, i)) return;
271
+ const a = t.style[i] || r[i];
272
+ Rt(i, a) && (o[i] = a);
273
+ }), { styles: o, attrs: {} };
274
+ }
275
+ function kt(t, e) {
276
+ if (t.closest("b,strong")) return !0;
277
+ const n = e.fontWeight;
278
+ return /^(bold|bolder|[5-9]\d{2,})$/.test(n);
279
+ }
280
+ function At(t, e) {
281
+ return !!t.closest("i,em") || e.fontStyle === "italic";
282
+ }
283
+ function $(t, e, n) {
284
+ const r = n === "underline" ? "u" : "s,strike";
285
+ return !!t.closest(r) || e.textDecorationLine.includes(n);
286
+ }
287
+ function yt(t, e) {
288
+ return !(!e || t === "backgroundColor" && (e === "rgba(0, 0, 0, 0)" || e === "transparent") || t === "textTransform" && e === "none");
289
+ }
290
+ function Lt(t, e) {
291
+ return !(!e || t === "textAlign" && e === "start" || t === "lineHeight" && e === "normal" || (t === "marginLeft" || t === "marginRight") && e === "0px");
292
+ }
293
+ function Rt(t, e) {
294
+ return !(!e || (t === "backgroundColor" || t.endsWith("Color")) && (e === "rgba(0, 0, 0, 0)" || e === "transparent") || t === "textAlign" && e === "start" || t === "verticalAlign" && e === "middle" || t.endsWith("Width") && e === "0px" || t.endsWith("Style") && e === "none" || t.startsWith("padding") && e === "0px" || t === "borderSpacing" && e === "0px" || t === "width" && e === "auto");
295
+ }
296
+ function Q(t, e) {
297
+ const n = window.getSelection();
298
+ if (!n || n.rangeCount === 0) return !1;
299
+ const r = n.getRangeAt(0);
300
+ if (!t.contains(r.startContainer) || !t.contains(r.endContainer)) return !1;
301
+ const o = t.innerHTML, i = !r.collapsed, s = Jt(t);
302
+ Ft(t, r, e.table), wt(t, r, e), s?.();
303
+ const a = window.getSelection(), l = a && a.rangeCount > 0 ? a.getRangeAt(0) : null;
304
+ i && a && l && t.contains(l.startContainer) && t.contains(l.endContainer) && Mt(l, a, e), Ut(t), Qt(t);
305
+ const u = t.innerHTML;
306
+ return o === u ? !1 : (te(t, o, u), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0);
307
+ }
308
+ function wt(t, e, n) {
309
+ const r = Xt(t, e);
310
+ n.list && zt(r, n.list), n.block && r.forEach((o) => {
311
+ const i = o.isConnected ? o : null;
312
+ if (!i) return;
313
+ const s = Vt(i, n.block.tagName);
314
+ S(s, n.block.styles), n.block.attrs.dir ? s.setAttribute("dir", n.block.attrs.dir) : s.removeAttribute("dir");
315
+ });
316
+ }
317
+ function Ft(t, e, n) {
318
+ if (!n) return;
319
+ const r = Kt(t, e);
320
+ if (n.cell && r.forEach((i) => {
321
+ S(i, n.cell.styles);
322
+ }), !n.table) return;
323
+ const o = /* @__PURE__ */ new Set();
324
+ if (r.forEach((i) => {
325
+ const s = i.closest("table");
326
+ s instanceof HTMLElement && o.add(s);
327
+ }), o.size === 0) {
328
+ const i = f(e.startContainer)?.closest("table");
329
+ i instanceof HTMLElement && t.contains(i) && o.add(i);
330
+ }
331
+ o.forEach((i) => {
332
+ S(i, n.table.styles);
333
+ });
334
+ }
335
+ function Mt(t, e, n) {
336
+ vt(t);
337
+ const r = n.inline, o = t.cloneContents();
338
+ if (Yt(o)) {
339
+ _t(t, e, n);
340
+ return;
341
+ }
342
+ const i = t.extractContents();
343
+ qt(i, n);
344
+ const s = document.createDocumentFragment(), a = K("start"), l = K("end");
345
+ s.appendChild(a), s.appendChild(et(i, r)), s.appendChild(l), t.insertNode(s), Dt(a, l, n);
346
+ const u = document.createRange();
347
+ u.setStartAfter(a), u.setEndBefore(l), e.removeAllRanges(), e.addRange(u);
348
+ }
349
+ function _t(t, e, n) {
350
+ const r = Ot(t), o = [];
351
+ if (r.forEach((s) => {
352
+ let a = It(s, t);
353
+ if (!a || !a.data.trim() || $t(a)) return;
354
+ a = xt(a, n);
355
+ const l = et(document.createTextNode(a.data), n.inline);
356
+ a.parentNode?.replaceChild(l, a), o.push(l);
357
+ }), o.length === 0) return;
358
+ const i = document.createRange();
359
+ i.setStartBefore(o[0]), i.setEndAfter(o[o.length - 1]), e.removeAllRanges(), e.addRange(i);
360
+ }
361
+ function Ot(t) {
362
+ if (t.startContainer === t.endContainer && t.startContainer.nodeType === Node.TEXT_NODE)
363
+ return [t.startContainer];
364
+ const e = [], n = document.createTreeWalker(t.commonAncestorContainer, NodeFilter.SHOW_TEXT, {
365
+ acceptNode: (o) => !o.textContent || !o.textContent.trim() || !t.intersectsNode(o) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
366
+ });
367
+ let r = n.nextNode();
368
+ for (; r; )
369
+ e.push(r), r = n.nextNode();
370
+ return e;
371
+ }
372
+ function It(t, e) {
373
+ const n = t.data.length;
374
+ let r = 0, o = n;
375
+ if (t === e.startContainer && (r = Math.max(0, Math.min(e.startOffset, n))), t === e.endContainer && (o = Math.max(0, Math.min(e.endOffset, n))), r >= o) return null;
376
+ let i = t;
377
+ return o < i.data.length && i.splitText(o), r > 0 && (i = i.splitText(r)), i;
378
+ }
379
+ function xt(t, e) {
380
+ let n = t, r = n.parentElement;
381
+ for (; r && r.matches(y) && !x(r, e) && tt(r, e); )
382
+ Bt(r, n), r = n.parentElement;
383
+ return n;
384
+ }
385
+ function Bt(t, e) {
386
+ const n = t.parentNode;
387
+ if (!n || e.parentNode !== t) return;
388
+ const r = t.cloneNode(!1), o = t.cloneNode(!1);
389
+ for (; t.firstChild && t.firstChild !== e; )
390
+ r.appendChild(t.firstChild);
391
+ for (; e.nextSibling; )
392
+ o.appendChild(e.nextSibling);
393
+ q(r) && n.insertBefore(r, t), n.insertBefore(e, t), q(o) && n.insertBefore(o, t), n.removeChild(t);
394
+ }
395
+ function q(t) {
396
+ return Array.from(t.childNodes).some((e) => e.nodeType !== Node.TEXT_NODE ? !0 : !!(e.textContent || "").trim());
397
+ }
398
+ function vt(t) {
399
+ let e = f(t.startContainer), n = f(t.endContainer);
400
+ for (; e && e === n && e.matches(y); ) {
401
+ if (!Pt(t, e)) return;
402
+ t.selectNode(e), e = e.parentElement, n = f(t.endContainer);
403
+ }
404
+ }
405
+ function Pt(t, e) {
406
+ const n = document.createRange();
407
+ return n.selectNodeContents(e), t.compareBoundaryPoints(Range.START_TO_START, n) === 0 && t.compareBoundaryPoints(Range.END_TO_END, n) === 0;
408
+ }
409
+ function Dt(t, e, n) {
410
+ let r = f(t.parentNode);
411
+ for (; r && r.contains(e); ) {
412
+ const o = r.parentElement;
413
+ r.matches(y) && !x(r, n) && Ht(r, t, e) && tt(r, n) && k(r), r = o;
414
+ }
415
+ }
416
+ function Ht(t, e, n) {
417
+ let r = "before";
418
+ for (const o of Array.from(t.childNodes)) {
419
+ if (o === e) {
420
+ r = "inside";
421
+ continue;
422
+ }
423
+ if (o === n) {
424
+ r = "after";
425
+ continue;
426
+ }
427
+ if (r !== "inside" && !Wt(o))
428
+ return !1;
429
+ }
430
+ return r === "after";
431
+ }
432
+ function Wt(t) {
433
+ return t.nodeType === Node.TEXT_NODE ? !(t.textContent || "").replace(/\uFEFF/g, "").trim() : t.nodeType === Node.COMMENT_NODE ? ot(t) : t.nodeType !== Node.ELEMENT_NODE ? !0 : t.hasAttribute(d);
434
+ }
435
+ function tt(t, e) {
436
+ return t.matches("span") ? L.some((n) => !c(e.ignoredFormats, n)) : t.matches("b,strong") ? !c(e.ignoredFormats, "bold") : t.matches("i,em") ? !c(e.ignoredFormats, "italic") : t.matches("u") ? !c(e.ignoredFormats, "underline") : t.matches("s,strike") ? !c(e.ignoredFormats, "strikethrough") : !0;
437
+ }
438
+ function $t(t) {
439
+ return t.nodeType !== Node.TEXT_NODE || (t.textContent || "").trim() ? !1 : !!t.parentElement?.matches(_);
440
+ }
441
+ function et(t, e) {
442
+ let n = t;
443
+ const r = Object.entries(e.styles);
444
+ if (r.length > 0) {
445
+ const o = document.createElement("span");
446
+ o.classList.add("rte-format-painted"), r.forEach(([i, s]) => {
447
+ o.style.setProperty(B(i), s);
448
+ }), o.appendChild(n), n = o;
449
+ }
450
+ return e.marks.strikethrough && (n = T("s", n)), e.marks.underline && (n = T("u", n)), e.marks.italic && (n = T("i", n)), e.marks.bold && (n = T("b", n)), n;
451
+ }
452
+ function T(t, e) {
453
+ const n = document.createElement(t);
454
+ return n.appendChild(e), n;
455
+ }
456
+ function qt(t, e) {
457
+ Array.from(t.querySelectorAll(y)).forEach((n) => {
458
+ if (n instanceof HTMLElement && !x(n, e)) {
459
+ if (n.matches("span")) {
460
+ if (L.forEach((r) => {
461
+ c(e.ignoredFormats, r) || n.style.removeProperty(B(r));
462
+ }), n.getAttribute("style") || n.attributes.length > 0) return;
463
+ k(n);
464
+ return;
465
+ }
466
+ n.matches("b,strong") && c(e.ignoredFormats, "bold") || n.matches("i,em") && c(e.ignoredFormats, "italic") || n.matches("u") && c(e.ignoredFormats, "underline") || n.matches("s,strike") && c(e.ignoredFormats, "strikethrough") || k(n);
467
+ }
468
+ });
469
+ }
470
+ function x(t, e) {
471
+ return !!(t.matches("a") && c(e.ignoredFormats, "link") || R(t, "comment") && c(e.ignoredFormats, "comments") || R(t, "citation") && c(e.ignoredFormats, "citations") || R(t, "track") && c(e.ignoredFormats, "trackchanges"));
472
+ }
473
+ function R(t, e) {
474
+ const n = e.toLowerCase();
475
+ return t.className.toString().toLowerCase().includes(n) ? !0 : Array.from(t.attributes).some((o) => {
476
+ const i = A(o.name), s = o.value.toLowerCase();
477
+ return i.includes(n) || s.includes(n);
478
+ });
479
+ }
480
+ function zt(t, e) {
481
+ t.filter((r) => r.tagName.toLowerCase() === "li").forEach((r) => {
482
+ const o = r.closest(_);
483
+ if (!o) return;
484
+ const i = Zt(o, e.tagName);
485
+ S(i, e.styles), Z(i, e.attrs), Z(r, e.itemAttrs);
486
+ });
487
+ }
488
+ function Kt(t, e) {
489
+ const n = Array.from(t.querySelectorAll(w)).filter((o) => o instanceof HTMLElement && e.intersectsNode(o));
490
+ if (n.length > 0) return n;
491
+ const r = f(e.startContainer)?.closest(w);
492
+ return r instanceof HTMLElement && t.contains(r) ? [r] : [];
493
+ }
494
+ function S(t, e) {
495
+ Object.entries(e).forEach(([n, r]) => {
496
+ t.style.setProperty(B(n), r);
497
+ });
498
+ }
499
+ function Vt(t, e) {
500
+ const n = rt(t);
501
+ if (n === e || n === "li" || n === "td" || n === "th") return t;
502
+ if (e === "blockquote") {
503
+ const o = document.createElement("blockquote");
504
+ for (; t.firstChild; ) o.appendChild(t.firstChild);
505
+ return F(t, o), t.parentNode?.replaceChild(o, t), o;
506
+ }
507
+ if (!/^(p|div|h[1-6]|pre)$/.test(e)) return t;
508
+ const r = document.createElement(e);
509
+ for (; t.firstChild; ) r.appendChild(t.firstChild);
510
+ return F(t, r), t.parentNode?.replaceChild(r, t), r;
511
+ }
512
+ function Zt(t, e) {
513
+ if (t.tagName.toLowerCase() === e) return t;
514
+ const n = document.createElement(e);
515
+ for (; t.firstChild; ) n.appendChild(t.firstChild);
516
+ return F(t, n), t.parentNode?.replaceChild(n, t), n;
517
+ }
518
+ function Xt(t, e) {
519
+ const n = Array.from(t.querySelectorAll(N)).filter((o) => o instanceof HTMLElement && e.intersectsNode(o));
520
+ if (n.length > 0)
521
+ return n.filter((o) => !n.some((i) => i !== o && i.contains(o)));
522
+ const r = nt(f(e.startContainer), t);
523
+ return r ? [r] : [];
524
+ }
525
+ function nt(t, e) {
526
+ const n = t?.closest(N);
527
+ return n instanceof HTMLElement && e.contains(n) ? n : null;
528
+ }
529
+ function rt(t) {
530
+ const e = t.tagName.toLowerCase();
531
+ return e === "blockquote" || /^h[1-6]$/.test(e) || e === "pre" || e === "li" || e === "td" || e === "th" ? e : "p";
532
+ }
533
+ function Yt(t) {
534
+ return Array.from(t.childNodes).some((e) => {
535
+ if (e.nodeType !== Node.ELEMENT_NODE) return !1;
536
+ const n = e;
537
+ return n.matches(N) || !!n.querySelector(N);
538
+ });
539
+ }
540
+ function Jt(t) {
541
+ const e = window.getSelection();
542
+ if (!e || e.rangeCount === 0) return null;
543
+ const n = e.getRangeAt(0);
544
+ if (!t.contains(n.startContainer) || !t.contains(n.endContainer)) return null;
545
+ const r = n.collapsed, o = z("start"), i = z("end"), s = n.cloneRange();
546
+ if (!r) {
547
+ const l = s.cloneRange();
548
+ l.collapse(!1), l.insertNode(i);
549
+ }
550
+ const a = s.cloneRange();
551
+ return a.collapse(!0), a.insertNode(o), () => {
552
+ const l = V(t, "start"), u = V(t, "end");
553
+ if (!l) return;
554
+ const m = document.createRange();
555
+ r || !u ? (m.setStartAfter(l), m.collapse(!0)) : (m.setStartAfter(l), m.setEndBefore(u)), e.removeAllRanges(), e.addRange(m);
556
+ };
557
+ }
558
+ function z(t) {
559
+ return document.createComment(`${d}:selection:${t}`);
560
+ }
561
+ function K(t) {
562
+ return document.createComment(`${d}:inline:${t}`);
563
+ }
564
+ function ot(t) {
565
+ return Gt(t) || jt(t);
566
+ }
567
+ function Gt(t) {
568
+ return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${d}:selection:start` || t.nodeValue === `${d}:selection:end`);
569
+ }
570
+ function jt(t) {
571
+ return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${d}:inline:start` || t.nodeValue === `${d}:inline:end`);
572
+ }
573
+ function V(t, e) {
574
+ const n = `${d}:selection:${e}`, r = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT);
575
+ let o = r.nextNode();
576
+ for (; o; ) {
577
+ if (o.nodeValue === n) return o;
578
+ o = r.nextNode();
579
+ }
580
+ return null;
581
+ }
582
+ function Ut(t) {
583
+ t.querySelectorAll(`[${d}]`).forEach((o) => o.remove());
584
+ const e = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT), n = [];
585
+ let r = e.nextNode();
586
+ for (; r; )
587
+ ot(r) && n.push(r), r = e.nextNode();
588
+ n.forEach((o) => o.remove());
589
+ }
590
+ function Qt(t) {
591
+ t.querySelectorAll("span").forEach((e) => {
592
+ e instanceof HTMLElement && (e.attributes.length > 0 || k(e));
593
+ });
594
+ }
595
+ function k(t) {
596
+ const e = t.parentNode;
597
+ if (e) {
598
+ for (; t.firstChild; )
599
+ e.insertBefore(t.firstChild, t);
600
+ e.removeChild(t);
601
+ }
602
+ }
603
+ function b(t, e, n) {
604
+ const r = t.getAttribute(n);
605
+ r != null && (e[n] = r);
606
+ }
607
+ function Z(t, e) {
608
+ ["data-type", "data-checked", "type"].forEach((n) => {
609
+ e[n] != null && t.setAttribute(n, e[n]);
610
+ });
611
+ }
612
+ function F(t, e) {
613
+ Array.from(t.attributes).forEach((n) => {
614
+ n.name !== "style" && e.setAttribute(n.name, n.value);
615
+ });
616
+ }
617
+ function h(t, e) {
618
+ const n = g(t);
619
+ if (n.active === e && t.classList.contains("rte-format-painter-active") === e) {
620
+ M(t, e);
621
+ return;
622
+ }
623
+ n.active = e, t.classList.toggle("rte-format-painter-active", e), M(t, e);
624
+ }
625
+ function M(t, e) {
626
+ const n = t.closest(st) || document;
627
+ n.querySelectorAll(
628
+ '[data-command="toggleFormatPainter"], [data-command="formatPainter"]'
629
+ ).forEach((o) => {
630
+ o instanceof HTMLElement && (o.classList.toggle("active", e), o.setAttribute("data-active", e ? "true" : "false"), o.setAttribute("aria-pressed", e ? "true" : "false"));
631
+ }), n.dispatchEvent(
632
+ new CustomEvent("editora:format-painter-toggle", {
633
+ bubbles: !0,
634
+ detail: { active: e }
635
+ })
636
+ );
637
+ }
638
+ function te(t, e, n) {
639
+ if (e === n) return;
640
+ const r = window.execEditorCommand || window.executeEditorCommand;
641
+ if (typeof r == "function")
642
+ try {
643
+ r("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n });
644
+ } catch {
645
+ try {
646
+ r("recordDomTransaction", t, e, n);
647
+ } catch {
648
+ }
649
+ }
650
+ }
651
+ function ee(t) {
652
+ return (t ?? O).map(A).map((e) => X[e] || e).filter(Boolean);
653
+ }
654
+ function c(t, e) {
655
+ const n = X[A(e)] || A(e);
656
+ return t.includes(n);
657
+ }
658
+ function A(t) {
659
+ return t.toLowerCase().replace(/[^a-z0-9]/g, "");
660
+ }
661
+ function B(t) {
662
+ return t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
663
+ }
664
+ export {
665
+ ne as FormatPainterPlugin
666
+ };
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./heading.cjs.js"),r=require("./bold.cjs.js"),o=require("./italic.cjs.js"),u=require("./underline.cjs.js"),g=require("./strikethrough.cjs.js"),a=require("./list.cjs.js"),s=require("./checklist.cjs.js"),P=require("./history.cjs.js"),c=require("./link.cjs.js"),m=require("./blockquote.cjs.js"),d=require("./clear-formatting.cjs.js"),C=require("./code.cjs.js"),q=require("./table.cjs.js"),p=require("./font-size.cjs.js"),h=require("./font-family.cjs.js"),k=require("./text-alignment.cjs.js"),T=require("./text-color.cjs.js"),f=require("./background-color.cjs.js"),M=require("./line-height.cjs.js"),b=require("./indent.cjs.js"),S=require("./direction.cjs.js"),A=require("./capitalization.cjs.js"),D=require("./math.cjs.js"),y=require("./special-characters.cjs.js"),B=require("./emojis.cjs.js"),F=require("./embed-iframe.cjs.js"),E=require("./anchor.cjs.js"),I=require("./mentions.cjs.js"),v=require("./track-changes.cjs.js"),L=require("./version-diff.cjs.js"),w=require("./conditional-content.cjs.js"),H=require("./data-binding.cjs.js"),z=require("./content-rules.cjs.js"),R=require("./citations.cjs.js"),x=require("./approval-workflow.cjs.js"),G=require("./pii-redaction.cjs.js"),W=require("./smart-paste.cjs.js"),j=require("./blocks-library.cjs.js"),U=require("./doc-schema.cjs.js"),_=require("./translation-workflow.cjs.js"),N=require("./slash-commands.cjs.js"),n=require("./media-manager.cjs.js"),t=require("./index-tqLTHcO6.js"),V=require("./preview.cjs.js"),O=require("./fullscreen.cjs.js"),J=require("./print.cjs.js"),K=require("./page-break.cjs.js"),Q=require("./footnote.cjs.js"),X=require("./code-sample.cjs.js"),Y=require("./merge-tag.cjs.js"),e=require("./template.cjs.js"),Z=require("./comments.cjs.js"),$=require("./spell-check.cjs.js"),ee=require("./a11y-checker.cjs.js"),i=require("./shared-config.cjs.js");exports.HeadingPlugin=l.HeadingPlugin;exports.BoldPlugin=r.BoldPlugin;exports.ItalicPlugin=o.ItalicPlugin;exports.UnderlinePlugin=u.UnderlinePlugin;exports.StrikethroughPlugin=g.StrikethroughPlugin;exports.ListPlugin=a.ListPlugin;exports.ChecklistPlugin=s.ChecklistPlugin;exports.HistoryPlugin=P.HistoryPlugin;exports.LinkPlugin=c.LinkPlugin;exports.BlockquotePlugin=m.BlockquotePlugin;exports.ClearFormattingPlugin=d.ClearFormattingPlugin;exports.CodePlugin=C.CodePlugin;exports.TablePlugin=q.TablePlugin;exports.FontSizePlugin=p.FontSizePlugin;exports.FontFamilyPlugin=h.FontFamilyPlugin;exports.TextAlignmentPlugin=k.TextAlignmentPlugin;exports.TextColorPlugin=T.TextColorPlugin;exports.BackgroundColorPlugin=f.BackgroundColorPlugin;exports.LineHeightPlugin=M.LineHeightPlugin;exports.IndentPlugin=b.IndentPlugin;exports.DirectionPlugin=S.DirectionPlugin;exports.CapitalizationPlugin=A.CapitalizationPlugin;exports.MathPlugin=D.MathPlugin;exports.SpecialCharactersPlugin=y.SpecialCharactersPlugin;exports.EmojisPlugin=B.EmojisPlugin;exports.EmbedIframePlugin=F.EmbedIframePlugin;exports.AnchorPlugin=E.AnchorPlugin;exports.MentionPlugin=I.MentionPlugin;exports.TrackChangesPlugin=v.TrackChangesPlugin;exports.VersionDiffPlugin=L.VersionDiffPlugin;exports.ConditionalContentPlugin=w.ConditionalContentPlugin;exports.DataBindingPlugin=H.DataBindingPlugin;exports.ContentRulesPlugin=z.ContentRulesPlugin;exports.CitationsPlugin=R.CitationsPlugin;exports.ApprovalWorkflowPlugin=x.ApprovalWorkflowPlugin;exports.PIIRedactionPlugin=G.PIIRedactionPlugin;exports.SmartPastePlugin=W.SmartPastePlugin;exports.BlocksLibraryPlugin=j.BlocksLibraryPlugin;exports.DocSchemaPlugin=U.DocSchemaPlugin;exports.TranslationWorkflowPlugin=_.TranslationWorkflowPlugin;exports.SlashCommandsPlugin=N.SlashCommandsPlugin;exports.MediaManagerPlugin=n.MediaManagerPlugin;exports.getMediaManagerConfig=n.getMediaManagerConfig;exports.setMediaManagerConfig=n.setMediaManagerConfig;exports.DocumentManagerPlugin=t.DocumentManagerPlugin;exports.getDocumentManagerConfig=t.getDocumentManagerConfig;exports.setDocumentManagerConfig=t.setDocumentManagerConfig;exports.PreviewPlugin=V.PreviewPlugin;exports.FullscreenPlugin=O.FullscreenPlugin;exports.PrintPlugin=J.PrintPlugin;exports.PageBreakPlugin=K.PageBreakPlugin;exports.FootnotePlugin=Q.FootnotePlugin;exports.CodeSamplePlugin=X.CodeSamplePlugin;exports.MergeTagPlugin=Y.MergeTagPlugin;exports.PREDEFINED_TEMPLATES=e.PREDEFINED_TEMPLATES;exports.TemplatePlugin=e.TemplatePlugin;exports.addCustomTemplate=e.addCustomTemplate;exports.getAllTemplates=e.getAllTemplates;exports.getTemplateCategories=e.getTemplateCategories;exports.getTemplatesByCategory=e.getTemplatesByCategory;exports.sanitizeTemplate=e.sanitizeTemplate;exports.searchTemplates=e.searchTemplates;exports.validateTemplate=e.validateTemplate;exports.CommentsPlugin=Z.CommentsPlugin;exports.SpellCheckPlugin=$.SpellCheckPlugin;exports.A11yCheckerPlugin=ee.A11yCheckerPlugin;exports.buildApiUrl=i.buildApiUrl;exports.getGlobalApiConfig=i.getGlobalApiConfig;exports.getGlobalApiHeaders=i.getGlobalApiHeaders;exports.setGlobalApiConfig=i.setGlobalApiConfig;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./heading.cjs.js"),r=require("./bold.cjs.js"),o=require("./italic.cjs.js"),u=require("./underline.cjs.js"),a=require("./strikethrough.cjs.js"),g=require("./list.cjs.js"),s=require("./checklist.cjs.js"),P=require("./history.cjs.js"),c=require("./link.cjs.js"),m=require("./blockquote.cjs.js"),d=require("./clear-formatting.cjs.js"),C=require("./code.cjs.js"),q=require("./table.cjs.js"),p=require("./font-size.cjs.js"),h=require("./format-painter.cjs.js"),k=require("./font-family.cjs.js"),f=require("./text-alignment.cjs.js"),T=require("./text-color.cjs.js"),M=require("./background-color.cjs.js"),b=require("./line-height.cjs.js"),S=require("./indent.cjs.js"),A=require("./direction.cjs.js"),D=require("./capitalization.cjs.js"),F=require("./math.cjs.js"),y=require("./special-characters.cjs.js"),B=require("./emojis.cjs.js"),E=require("./embed-iframe.cjs.js"),I=require("./anchor.cjs.js"),v=require("./mentions.cjs.js"),L=require("./track-changes.cjs.js"),w=require("./version-diff.cjs.js"),H=require("./conditional-content.cjs.js"),z=require("./data-binding.cjs.js"),R=require("./content-rules.cjs.js"),x=require("./citations.cjs.js"),G=require("./approval-workflow.cjs.js"),W=require("./pii-redaction.cjs.js"),j=require("./smart-paste.cjs.js"),U=require("./blocks-library.cjs.js"),_=require("./doc-schema.cjs.js"),N=require("./translation-workflow.cjs.js"),V=require("./slash-commands.cjs.js"),n=require("./media-manager.cjs.js"),t=require("./index-tqLTHcO6.js"),O=require("./preview.cjs.js"),J=require("./fullscreen.cjs.js"),K=require("./print.cjs.js"),Q=require("./page-break.cjs.js"),X=require("./footnote.cjs.js"),Y=require("./code-sample.cjs.js"),Z=require("./merge-tag.cjs.js"),e=require("./template.cjs.js"),$=require("./comments.cjs.js"),ee=require("./spell-check.cjs.js"),ie=require("./a11y-checker.cjs.js"),i=require("./shared-config.cjs.js");exports.HeadingPlugin=l.HeadingPlugin;exports.BoldPlugin=r.BoldPlugin;exports.ItalicPlugin=o.ItalicPlugin;exports.UnderlinePlugin=u.UnderlinePlugin;exports.StrikethroughPlugin=a.StrikethroughPlugin;exports.ListPlugin=g.ListPlugin;exports.ChecklistPlugin=s.ChecklistPlugin;exports.HistoryPlugin=P.HistoryPlugin;exports.LinkPlugin=c.LinkPlugin;exports.BlockquotePlugin=m.BlockquotePlugin;exports.ClearFormattingPlugin=d.ClearFormattingPlugin;exports.CodePlugin=C.CodePlugin;exports.TablePlugin=q.TablePlugin;exports.FontSizePlugin=p.FontSizePlugin;exports.FormatPainterPlugin=h.FormatPainterPlugin;exports.FontFamilyPlugin=k.FontFamilyPlugin;exports.TextAlignmentPlugin=f.TextAlignmentPlugin;exports.TextColorPlugin=T.TextColorPlugin;exports.BackgroundColorPlugin=M.BackgroundColorPlugin;exports.LineHeightPlugin=b.LineHeightPlugin;exports.IndentPlugin=S.IndentPlugin;exports.DirectionPlugin=A.DirectionPlugin;exports.CapitalizationPlugin=D.CapitalizationPlugin;exports.MathPlugin=F.MathPlugin;exports.SpecialCharactersPlugin=y.SpecialCharactersPlugin;exports.EmojisPlugin=B.EmojisPlugin;exports.EmbedIframePlugin=E.EmbedIframePlugin;exports.AnchorPlugin=I.AnchorPlugin;exports.MentionPlugin=v.MentionPlugin;exports.TrackChangesPlugin=L.TrackChangesPlugin;exports.VersionDiffPlugin=w.VersionDiffPlugin;exports.ConditionalContentPlugin=H.ConditionalContentPlugin;exports.DataBindingPlugin=z.DataBindingPlugin;exports.ContentRulesPlugin=R.ContentRulesPlugin;exports.CitationsPlugin=x.CitationsPlugin;exports.ApprovalWorkflowPlugin=G.ApprovalWorkflowPlugin;exports.PIIRedactionPlugin=W.PIIRedactionPlugin;exports.SmartPastePlugin=j.SmartPastePlugin;exports.BlocksLibraryPlugin=U.BlocksLibraryPlugin;exports.DocSchemaPlugin=_.DocSchemaPlugin;exports.TranslationWorkflowPlugin=N.TranslationWorkflowPlugin;exports.SlashCommandsPlugin=V.SlashCommandsPlugin;exports.MediaManagerPlugin=n.MediaManagerPlugin;exports.getMediaManagerConfig=n.getMediaManagerConfig;exports.setMediaManagerConfig=n.setMediaManagerConfig;exports.DocumentManagerPlugin=t.DocumentManagerPlugin;exports.getDocumentManagerConfig=t.getDocumentManagerConfig;exports.setDocumentManagerConfig=t.setDocumentManagerConfig;exports.PreviewPlugin=O.PreviewPlugin;exports.FullscreenPlugin=J.FullscreenPlugin;exports.PrintPlugin=K.PrintPlugin;exports.PageBreakPlugin=Q.PageBreakPlugin;exports.FootnotePlugin=X.FootnotePlugin;exports.CodeSamplePlugin=Y.CodeSamplePlugin;exports.MergeTagPlugin=Z.MergeTagPlugin;exports.PREDEFINED_TEMPLATES=e.PREDEFINED_TEMPLATES;exports.TemplatePlugin=e.TemplatePlugin;exports.addCustomTemplate=e.addCustomTemplate;exports.getAllTemplates=e.getAllTemplates;exports.getTemplateCategories=e.getTemplateCategories;exports.getTemplatesByCategory=e.getTemplatesByCategory;exports.sanitizeTemplate=e.sanitizeTemplate;exports.searchTemplates=e.searchTemplates;exports.validateTemplate=e.validateTemplate;exports.CommentsPlugin=$.CommentsPlugin;exports.SpellCheckPlugin=ee.SpellCheckPlugin;exports.A11yCheckerPlugin=ie.A11yCheckerPlugin;exports.buildApiUrl=i.buildApiUrl;exports.getGlobalApiConfig=i.getGlobalApiConfig;exports.getGlobalApiHeaders=i.getGlobalApiHeaders;exports.setGlobalApiConfig=i.setGlobalApiConfig;