@editora/plugins 1.0.10 → 1.0.11
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/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +80 -98
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +115 -128
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +208 -249
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +55 -68
- package/dist/blockquote.esm.js +1 -2
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +178 -245
- package/dist/capitalization.esm.js +1 -2
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +58 -82
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +439 -512
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +27 -33
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +82 -93
- package/dist/code.cjs.js +32 -32
- package/dist/code.esm.js +501 -506
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +116 -158
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +371 -432
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +105 -159
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +328 -368
- package/dist/direction.esm.js +9 -18
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +240 -308
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +4 -5
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +73 -81
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +65 -77
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +54 -56
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +39 -47
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +37 -53
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +76 -117
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +70 -92
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +12 -24
- package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-CE_A4QSm.js +5 -0
- package/dist/index.es-DQ78mYYo.mjs +6665 -0
- package/dist/index.esm.js +125 -128
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +8 -9
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +11 -24
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +24 -30
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +20 -25
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +59 -61
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +139 -146
- package/dist/media-manager.cjs.js +31 -31
- package/dist/media-manager.esm.js +285 -300
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +238 -286
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +177 -216
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +33 -49
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +393 -463
- package/dist/plugins.css +1 -0
- package/dist/preview.esm.js +5 -10
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +17 -20
- package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
- package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
- package/dist/slash-commands.cjs.js +2 -2
- package/dist/slash-commands.esm.js +39 -75
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +280 -336
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +61 -69
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +97 -123
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +14 -19
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +191 -225
- package/dist/template.cjs.js +21 -20
- package/dist/template.esm.js +715 -196
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +21 -27
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +70 -87
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +100 -162
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +602 -678
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +128 -157
- package/package.json +1 -1
- package/dist/_commonjsHelpers-6763f629.js +0 -1
- package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
- package/dist/anchoredPopover-33f1358d.mjs +0 -109
- package/dist/anchoredPopover-8151d535.js +0 -1
- package/dist/documentManager-25b6203c.mjs +0 -9122
- package/dist/documentManager-b69e7054.js +0 -17
- package/dist/html2canvas.esm-09133e29.js +0 -22
- package/dist/index-656d224b.js +0 -231
- package/dist/index-6a8c48bb.js +0 -1
- package/dist/index-d027b7e2.mjs +0 -16859
- package/dist/index.es-730f2d98.mjs +0 -5775
- package/dist/index.es-dd40173b.js +0 -18
- package/dist/jspdf.es.min-90db2c97.js +0 -243
- package/dist/style.css +0 -1
- /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
|
@@ -137,8 +137,7 @@ function D(e) {
|
|
|
137
137
|
const u = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark';
|
|
138
138
|
let v = !1;
|
|
139
139
|
function B() {
|
|
140
|
-
if (v || typeof document > "u")
|
|
141
|
-
return;
|
|
140
|
+
if (v || typeof document > "u") return;
|
|
142
141
|
v = !0;
|
|
143
142
|
const e = document.createElement("style");
|
|
144
143
|
e.id = "rte-slash-commands-styles", e.textContent = `
|
|
@@ -238,29 +237,23 @@ function I(e) {
|
|
|
238
237
|
return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
|
|
239
238
|
}
|
|
240
239
|
function F(e) {
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
|
|
240
|
+
if (e?.contentElement instanceof HTMLElement) return e.contentElement;
|
|
241
|
+
if (e?.editorElement instanceof HTMLElement) {
|
|
244
242
|
const n = e.editorElement;
|
|
245
|
-
if (n.matches(s))
|
|
246
|
-
return n;
|
|
243
|
+
if (n.matches(s)) return n;
|
|
247
244
|
const r = n.querySelector(s);
|
|
248
|
-
if (r instanceof HTMLElement)
|
|
249
|
-
return r;
|
|
245
|
+
if (r instanceof HTMLElement) return r;
|
|
250
246
|
}
|
|
251
247
|
const t = window.getSelection();
|
|
252
248
|
if (t && t.rangeCount > 0) {
|
|
253
|
-
const n = t.getRangeAt(0).startContainer,
|
|
254
|
-
if (i)
|
|
255
|
-
return i;
|
|
249
|
+
const n = t.getRangeAt(0).startContainer, i = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(s);
|
|
250
|
+
if (i) return i;
|
|
256
251
|
}
|
|
257
252
|
const o = document.activeElement;
|
|
258
253
|
if (o) {
|
|
259
|
-
if (o.matches(s))
|
|
260
|
-
return o;
|
|
254
|
+
if (o.matches(s)) return o;
|
|
261
255
|
const n = o.closest(s);
|
|
262
|
-
if (n)
|
|
263
|
-
return n;
|
|
256
|
+
if (n) return n;
|
|
264
257
|
}
|
|
265
258
|
return document.querySelector(s);
|
|
266
259
|
}
|
|
@@ -272,8 +265,7 @@ function _(e) {
|
|
|
272
265
|
}
|
|
273
266
|
function E(e) {
|
|
274
267
|
const t = window.getSelection();
|
|
275
|
-
if (!t || t.rangeCount === 0)
|
|
276
|
-
return null;
|
|
268
|
+
if (!t || t.rangeCount === 0) return null;
|
|
277
269
|
const o = t.getRangeAt(0);
|
|
278
270
|
return e.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
|
|
279
271
|
}
|
|
@@ -282,8 +274,7 @@ function y(e, t) {
|
|
|
282
274
|
o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
|
|
283
275
|
}
|
|
284
276
|
function j(e) {
|
|
285
|
-
if (!e.collapsed)
|
|
286
|
-
return null;
|
|
277
|
+
if (!e.collapsed) return null;
|
|
287
278
|
const t = e.startContainer, o = e.startOffset;
|
|
288
279
|
if (t.nodeType === Node.TEXT_NODE) {
|
|
289
280
|
const n = t;
|
|
@@ -332,8 +323,7 @@ function Q(e, t) {
|
|
|
332
323
|
return r.remove(), e.normalize(), i;
|
|
333
324
|
}
|
|
334
325
|
function A(e, t) {
|
|
335
|
-
if (!e.panel)
|
|
336
|
-
return;
|
|
326
|
+
if (!e.panel) return;
|
|
337
327
|
const o = Q(e.editor, t), n = e.panel;
|
|
338
328
|
n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
|
|
339
329
|
const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
|
|
@@ -341,17 +331,14 @@ function A(e, t) {
|
|
|
341
331
|
d + r.height > a - 8 && (d = Math.max(8, o.top - r.height - 8)), n.style.position = "fixed", n.style.left = `${l}px`, n.style.top = `${d}px`;
|
|
342
332
|
}
|
|
343
333
|
function k(e, t) {
|
|
344
|
-
if (!t)
|
|
345
|
-
return m(e);
|
|
334
|
+
if (!t) return m(e);
|
|
346
335
|
const o = e.toLowerCase(), n = t.toLowerCase(), r = o.indexOf(n);
|
|
347
|
-
if (r < 0)
|
|
348
|
-
return m(e);
|
|
336
|
+
if (r < 0) return m(e);
|
|
349
337
|
const i = m(e.slice(0, r)), a = m(e.slice(r, r + t.length)), l = m(e.slice(r + t.length));
|
|
350
338
|
return `${i}<mark>${a}</mark>${l}`;
|
|
351
339
|
}
|
|
352
340
|
function U(e, t) {
|
|
353
|
-
if (e.panel && e.list)
|
|
354
|
-
return;
|
|
341
|
+
if (e.panel && e.list) return;
|
|
355
342
|
const o = document.createElement("div");
|
|
356
343
|
o.className = "rte-slash-panel", o.style.display = "none", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false");
|
|
357
344
|
const n = document.createElement("div");
|
|
@@ -359,11 +346,9 @@ function U(e, t) {
|
|
|
359
346
|
r.preventDefault();
|
|
360
347
|
}), o.addEventListener("click", (r) => {
|
|
361
348
|
const i = r.target;
|
|
362
|
-
if (!i)
|
|
363
|
-
return;
|
|
349
|
+
if (!i) return;
|
|
364
350
|
const a = i.closest(".rte-slash-item");
|
|
365
|
-
if (!a)
|
|
366
|
-
return;
|
|
351
|
+
if (!a) return;
|
|
367
352
|
const l = Number(a.getAttribute("data-index"));
|
|
368
353
|
Number.isFinite(l) && M(e, l);
|
|
369
354
|
});
|
|
@@ -372,8 +357,7 @@ function c(e) {
|
|
|
372
357
|
e.panel && (e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.filteredItems = [], e.activeIndex = 0, e.query = "", e.replaceRange = null, e.anchorRange = null);
|
|
373
358
|
}
|
|
374
359
|
function W(e, t, o) {
|
|
375
|
-
if (!t)
|
|
376
|
-
return e.slice(0, o);
|
|
360
|
+
if (!t) return e.slice(0, o);
|
|
377
361
|
const n = t.toLowerCase();
|
|
378
362
|
return e.filter((i) => [
|
|
379
363
|
i.id,
|
|
@@ -384,8 +368,7 @@ function W(e, t, o) {
|
|
|
384
368
|
].join(" ").toLowerCase().includes(n)).slice(0, o);
|
|
385
369
|
}
|
|
386
370
|
function Z(e, t) {
|
|
387
|
-
if (!e.list)
|
|
388
|
-
return;
|
|
371
|
+
if (!e.list) return;
|
|
389
372
|
const o = e.list;
|
|
390
373
|
if (o.innerHTML = "", e.filteredItems.length === 0) {
|
|
391
374
|
const n = document.createElement("div");
|
|
@@ -401,8 +384,7 @@ function Z(e, t) {
|
|
|
401
384
|
}), e.filteredItems.length > 0 && o.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
|
|
402
385
|
}
|
|
403
386
|
function G(e, t) {
|
|
404
|
-
if (t === e.innerHTML)
|
|
405
|
-
return;
|
|
387
|
+
if (t === e.innerHTML) return;
|
|
406
388
|
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
407
389
|
if (typeof o == "function")
|
|
408
390
|
try {
|
|
@@ -421,11 +403,9 @@ function L(e, t) {
|
|
|
421
403
|
} catch {
|
|
422
404
|
}
|
|
423
405
|
const o = window.getSelection();
|
|
424
|
-
if (!o || o.rangeCount === 0)
|
|
425
|
-
return !1;
|
|
406
|
+
if (!o || o.rangeCount === 0) return !1;
|
|
426
407
|
const n = o.getRangeAt(0);
|
|
427
|
-
if (!e.contains(n.commonAncestorContainer))
|
|
428
|
-
return !1;
|
|
408
|
+
if (!e.contains(n.commonAncestorContainer)) return !1;
|
|
429
409
|
n.deleteContents();
|
|
430
410
|
const r = document.createElement("template");
|
|
431
411
|
r.innerHTML = t;
|
|
@@ -444,11 +424,9 @@ function X(e, t) {
|
|
|
444
424
|
} catch {
|
|
445
425
|
}
|
|
446
426
|
const o = window.getSelection();
|
|
447
|
-
if (!o || o.rangeCount === 0)
|
|
448
|
-
return !1;
|
|
427
|
+
if (!o || o.rangeCount === 0) return !1;
|
|
449
428
|
const n = o.getRangeAt(0);
|
|
450
|
-
if (!e.contains(n.commonAncestorContainer))
|
|
451
|
-
return !1;
|
|
429
|
+
if (!e.contains(n.commonAncestorContainer)) return !1;
|
|
452
430
|
n.deleteContents();
|
|
453
431
|
const r = document.createTextNode(t);
|
|
454
432
|
n.insertNode(r);
|
|
@@ -511,8 +489,7 @@ function S(e, t, o) {
|
|
|
511
489
|
const n = I(e);
|
|
512
490
|
if (n && typeof n.execCommand == "function")
|
|
513
491
|
try {
|
|
514
|
-
if (n.execCommand(t, o) !== !1)
|
|
515
|
-
return !0;
|
|
492
|
+
if (n.execCommand(t, o) !== !1) return !0;
|
|
516
493
|
} catch {
|
|
517
494
|
}
|
|
518
495
|
const r = window.execEditorCommand || window.executeEditorCommand;
|
|
@@ -521,8 +498,7 @@ function S(e, t, o) {
|
|
|
521
498
|
if (r(t, o, {
|
|
522
499
|
editorElement: n,
|
|
523
500
|
contentElement: e
|
|
524
|
-
}) !== !1)
|
|
525
|
-
return !0;
|
|
501
|
+
}) !== !1) return !0;
|
|
526
502
|
} catch {
|
|
527
503
|
}
|
|
528
504
|
return J(t, o);
|
|
@@ -539,14 +515,11 @@ async function Y(e, t) {
|
|
|
539
515
|
return t.action ? await Promise.resolve(t.action(r)) !== !1 : t.insertHTML ? L(o, t.insertHTML) : t.command ? S(o, t.command, t.commandValue) : !1;
|
|
540
516
|
}
|
|
541
517
|
async function M(e, t) {
|
|
542
|
-
if (t < 0 || t >= e.filteredItems.length || !e.replaceRange)
|
|
543
|
-
return;
|
|
518
|
+
if (t < 0 || t >= e.filteredItems.length || !e.replaceRange) return;
|
|
544
519
|
const o = e.filteredItems[t], n = e.editor, r = n.innerHTML, i = `${e.trigger}${e.query}`;
|
|
545
|
-
if (!window.getSelection())
|
|
546
|
-
return;
|
|
520
|
+
if (!window.getSelection()) return;
|
|
547
521
|
const l = e.replaceRange.cloneRange();
|
|
548
|
-
if (!n.contains(l.commonAncestorContainer))
|
|
549
|
-
return;
|
|
522
|
+
if (!n.contains(l.commonAncestorContainer)) return;
|
|
550
523
|
l.deleteContents();
|
|
551
524
|
const d = l.cloneRange();
|
|
552
525
|
d.collapse(!0), y(n, d);
|
|
@@ -559,11 +532,9 @@ async function M(e, t) {
|
|
|
559
532
|
c(e), x ? (V(n), G(n, r)) : i && X(n, i), n.focus({ preventScroll: !0 });
|
|
560
533
|
}
|
|
561
534
|
function R(e, t) {
|
|
562
|
-
if (e.filteredItems.length === 0)
|
|
563
|
-
return;
|
|
535
|
+
if (e.filteredItems.length === 0) return;
|
|
564
536
|
const o = e.filteredItems.length;
|
|
565
|
-
if (e.activeIndex = ((e.activeIndex + t) % o + o) % o, !e.list)
|
|
566
|
-
return;
|
|
537
|
+
if (e.activeIndex = ((e.activeIndex + t) % o + o) % o, !e.list) return;
|
|
567
538
|
const n = Array.from(e.list.querySelectorAll(".rte-slash-item"));
|
|
568
539
|
n.forEach((i, a) => {
|
|
569
540
|
const l = a === e.activeIndex;
|
|
@@ -653,13 +624,11 @@ function w(e, t) {
|
|
|
653
624
|
return g.set(e, n), n;
|
|
654
625
|
}
|
|
655
626
|
function re(e) {
|
|
656
|
-
var o;
|
|
657
627
|
const t = g.get(e);
|
|
658
|
-
t && (
|
|
628
|
+
t && (t.panel?.parentNode && t.panel.parentNode.removeChild(t.panel), g.delete(e));
|
|
659
629
|
}
|
|
660
630
|
function C(e, t, o) {
|
|
661
|
-
if (p.has(e))
|
|
662
|
-
return;
|
|
631
|
+
if (p.has(e)) return;
|
|
663
632
|
const n = {
|
|
664
633
|
input: () => {
|
|
665
634
|
ee(t, o);
|
|
@@ -703,14 +672,12 @@ function C(e, t, o) {
|
|
|
703
672
|
}, 0);
|
|
704
673
|
},
|
|
705
674
|
mousedown: (r) => {
|
|
706
|
-
if (!t.isOpen || !t.panel)
|
|
707
|
-
return;
|
|
675
|
+
if (!t.isOpen || !t.panel) return;
|
|
708
676
|
const i = r.target;
|
|
709
677
|
i && !t.panel.contains(i) && !e.contains(i) && c(t);
|
|
710
678
|
},
|
|
711
679
|
selectionchange: () => {
|
|
712
|
-
if (!t.isOpen)
|
|
713
|
-
return;
|
|
680
|
+
if (!t.isOpen) return;
|
|
714
681
|
const r = E(e);
|
|
715
682
|
if (!r || !r.collapsed) {
|
|
716
683
|
c(t);
|
|
@@ -731,11 +698,9 @@ function oe(e) {
|
|
|
731
698
|
function ie(e) {
|
|
732
699
|
b || (b = !0, f = (t) => {
|
|
733
700
|
const o = t.target;
|
|
734
|
-
if (!(o instanceof Node))
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
if (!r)
|
|
738
|
-
return;
|
|
701
|
+
if (!(o instanceof Node)) return;
|
|
702
|
+
const r = P(o)?.closest(s) || null;
|
|
703
|
+
if (!r) return;
|
|
739
704
|
const i = w(r, e);
|
|
740
705
|
C(r, i, e);
|
|
741
706
|
}, document.addEventListener("focusin", f, !0));
|
|
@@ -759,8 +724,7 @@ const le = (e = {}) => {
|
|
|
759
724
|
commands: {
|
|
760
725
|
openSlashCommands: (o, n) => {
|
|
761
726
|
const r = F(n);
|
|
762
|
-
if (!r)
|
|
763
|
-
return !1;
|
|
727
|
+
if (!r) return !1;
|
|
764
728
|
const i = w(r, t);
|
|
765
729
|
return C(r, i, t), H(i, t);
|
|
766
730
|
}
|
package/dist/smart-paste.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
`)}function
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",se="__editoraCommandEditorRoot",le="rte-smart-paste-styles",u="rte-smart-paste-panel",h="smart-paste",S="smartPaste",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ee=typeof NodeFilter<"u"?NodeFilter.SHOW_COMMENT:128,ie="__editoraSmartPasteHandled",ke=new Set(["script","style","meta","link","object","embed","iframe","svg","canvas","math","form","input","button","textarea","select","option"]),Ce=new Set(["table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),Te=new Set(["span","font"]),Pe=/^(https?:|mailto:|tel:|#|\/)/i,Ae=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,we=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","font-size","font-family","line-height","letter-spacing","word-spacing","white-space","vertical-align","margin-left","margin-right","margin-top","margin-bottom","padding-left","padding-right","padding-top","padding-bottom","text-indent","border","border-top","border-right","border-bottom","border-left","border-color","border-width","border-style","list-style-type"]),Le={panelTitle:"Smart Paste",panelAriaLabel:"Smart paste panel",enabledText:"Smart paste is enabled",disabledText:"Smart paste is disabled",toggleOnText:"Disable Smart Paste",toggleOffText:"Enable Smart Paste",cycleProfileText:"Cycle Profile",profileLabel:"Profile",fidelityText:"Fidelity",balancedText:"Balanced",plainText:"Plain Text",lastPasteHeading:"Last Paste Result",lastPasteEmptyText:"Paste content to see cleanup metrics.",lastPasteSourceLabel:"Source",lastPasteProfileLabel:"Profile",lastPasteRemovedLabel:"Removed",lastPasteCharsLabel:"Output Chars",closeText:"Close",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+S/V/G",readonlyMessage:"Editor is read-only. Smart paste was skipped."},Y={fidelity:{keepStyles:!0,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},balanced:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},plain:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!1}},d=new WeakMap,L=new WeakMap,g=new Map,q=new WeakMap,j=new WeakMap,_=new Set;let I=0,$e=0,$=null,m=null,P=null,A=null,T=null,w=null;function X(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Me(e){return e.replace(/\u00A0/g," ").replace(/\r\n?/g,`
|
|
2
|
+
`)}function z(e){return e==="balanced"||e==="plain"?e:"fidelity"}function Z(e,t){return{keepStyles:e?.keepStyles??t.keepStyles,keepClasses:e?.keepClasses??t.keepClasses,keepDataAttributes:e?.keepDataAttributes??t.keepDataAttributes,preserveTables:e?.preserveTables??t.preserveTables}}function K(e={}){const t=e.profileOptions||{};return{enabled:e.enabled!==!1,defaultProfile:z(e.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number(e.maxHtmlLength??22e4))),removeComments:e.removeComments!==!1,normalizeWhitespace:e.normalizeWhitespace!==!1,labels:{...Le,...e.labels||{}},normalizeText:e.normalizeText||Me,profileOptions:{fidelity:Z(t.fidelity,Y.fidelity),balanced:Z(t.balanced,Y.balanced),plain:Z(t.plain,Y.plain)}}}function ce(e){return{enabled:e.enabled,defaultProfile:e.defaultProfile,maxHtmlLength:e.maxHtmlLength,removeComments:e.removeComments,normalizeWhitespace:e.normalizeWhitespace,labels:{...e.labels},normalizeText:e.normalizeText,profileOptions:{fidelity:{...e.profileOptions.fidelity},balanced:{...e.profileOptions.balanced},plain:{...e.profileOptions.plain}}}}function te(e){return e.closest(ee)||e}function H(e){if(!e)return null;if(e.matches(y))return e;const t=e.querySelector(y);return t instanceof HTMLElement?t:null}function Oe(){if(typeof window>"u")return null;const e=window[se];if(!(e instanceof HTMLElement))return null;window[se]=null;const t=H(e);if(t)return t;const a=e.closest(ee);if(a){const n=H(a);if(n)return n}const r=e.closest(y);return r instanceof HTMLElement?r:null}function Re(e){const t=e.closest("[data-editora-editor]");if(t&&H(t)===e)return t;let a=e;for(;a;){if(a.matches(ee)&&(a===e||H(a)===e))return a;a=a.parentElement}return te(e)}function pe(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function C(e,t=!0,a=!0){if(V(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=H(e.editorElement);if(s)return s}const r=Oe();if(r)return r;const n=window.getSelection();if(n&&n.rangeCount>0){const l=pe(n.getRangeAt(0).startContainer)?.closest(y);if(l)return l}const o=document.activeElement;if(o){if(o.matches(y))return o;const s=o.closest(y);if(s)return s}if(a){if(m&&m.isConnected)return m;m&&!m.isConnected&&(m=null)}return t?document.querySelector(y):null}function _e(e){const t=e.target;if(t){const r=t.closest(y);if(r)return r}const a=window.getSelection();if(a&&a.rangeCount>0){const n=pe(a.getRangeAt(0).startContainer)?.closest(y);if(n)return n}return null}function B(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function ze(e){const t=te(e);if(B(t))return!0;const a=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return B(a)?!0:B(document.documentElement)||B(document.body)}function F(e,t){e.classList.remove("rte-smart-paste-theme-dark"),ze(t)&&e.classList.add("rte-smart-paste-theme-dark")}function de(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function D(e,t,a){const r=Re(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",a),o.setAttribute("data-active",a?"true":"false"),o.setAttribute("aria-pressed",a?"true":"false")})}function p(e,t){d.has(e)||d.set(e,t);let a=L.get(e);return a||(a={enabled:t.enabled,profile:t.defaultProfile,lastReport:null},L.set(e,a)),Qe(e),_.add(e),a}function me(e){const t=j.get(e);t&&(e.removeEventListener("paste",t,!0),j.delete(e))}function be(e){me(e),g.get(e)?.remove(),g.delete(e),q.delete(e),d.delete(e),L.delete(e),_.delete(e),m===e&&(m=null)}function V(){Array.from(_).forEach(t=>{t.isConnected||be(t)})}function He(e){for(let t=0;t<e.length;t+=1){const a=e[t];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let r=0;r<a.removedNodes.length;r+=1){const n=a.removedNodes[r];if(n.nodeType!==Node.ELEMENT_NODE)continue;const o=n;if(o.matches?.(y)||o.matches?.(`.${u}`)||o.querySelector?.(y)||o.querySelector?.(`.${u}`))return!0}}return!1}function re(e){return q.get(e)===!0}function O(e,t){const a=e.querySelector(".rte-smart-paste-live");a&&(a.textContent=t)}function J(e,t){const a=t.normalizeText(e);return t.normalizeWhitespace?a.split(`
|
|
3
3
|
`).map(n=>n.replace(/[\t ]+/g," ").trimEnd()).join(`
|
|
4
4
|
`).replace(/\n{3,}/g,`
|
|
5
5
|
|
|
6
|
-
`).trim():a}function De(e){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e)}function Ne(e){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e)}function qe(e,t){return e?De(e)?"word":Ne(e)?"google-docs":"html":t?"plain":"html"}function Ie(e){return e.split(/\s+/).map(a=>a.trim()).filter(Boolean).filter(a=>!/^mso/i.test(a)).filter(a=>!/^docs-/i.test(a)).filter(a=>!/^c\d+$/i.test(a)).join(" ")}function
|
|
6
|
+
`).trim():a}function De(e){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e)}function Ne(e){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e)}function qe(e,t){return e?De(e)?"word":Ne(e)?"google-docs":"html":t?"plain":"html"}function Ie(e){return e.split(/\s+/).map(a=>a.trim()).filter(Boolean).filter(a=>!/^mso/i.test(a)).filter(a=>!/^docs-/i.test(a)).filter(a=>!/^c\d+$/i.test(a)).join(" ")}function Be(e){if(!e)return{value:"",changed:!1};const t=e.split(";"),a=[];let r=!1;return t.forEach(n=>{const o=n.indexOf(":");if(o<=0){n.trim()&&(r=!0);return}const s=n.slice(0,o).trim().toLowerCase(),l=n.slice(o+1).trim();if(!s||!l){r=!0;return}if(!we.has(s)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)){r=!0;return}a.push(`${s}: ${l}`)}),{value:a.join("; "),changed:r}}function ue(e){const t=e.trim();return t&&(Pe.test(t)||Ae.test(t))?t:""}function fe(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function We(e,t,a,r){const n=e.tagName.toLowerCase();if(ke.has(n)){r.removedElements+=1,e.remove();return}if(!t.preserveTables&&Ce.has(n)){const s=e.textContent||"",l=document.createTextNode(s);e.replaceWith(l),r.removedElements+=1;return}if(Array.from(e.attributes).forEach(s=>{const l=s.name.toLowerCase(),i=s.value;if(l.startsWith("on")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="style"){if(!t.keepStyles){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Be(i);if(!c.value){e.removeAttribute(s.name),r.removedAttributes+=1,c.changed&&(r.normalizedStyles+=1);return}(c.changed||c.value!==i)&&(e.setAttribute("style",c.value),r.normalizedStyles+=1);return}if(l==="class"){if(!t.keepClasses){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Ie(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&(e.setAttribute("class",c),r.removedAttributes+=1);return}if(l.startsWith("data-")&&!t.keepDataAttributes){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="id"||l==="xmlns"||l.startsWith("xml")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if((a==="word"||a==="google-docs")&&(l==="lang"||l==="dir")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="href"||l==="src"||l==="xlink:href"){const c=ue(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&e.setAttribute(s.name,c)}}),n==="a"){if(!e.getAttribute("href")){fe(e),r.removedElements+=1;return}e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")}if(n==="img"){const s=e.getAttribute("src");if(!s||!ue(s)){r.removedElements+=1,e.remove();return}}if(Te.has(n)&&!e.attributes.length&&!e.className&&!e.style.cssText){const s=e.children.length>0,l=(e.textContent||"").trim().length>0;if(!s&&!l){e.remove(),r.removedElements+=1;return}!s&&l&&(fe(e),r.removedElements+=1)}}function Ke(e,t,a,r,n){const o=document.createElement("template");o.innerHTML=e;const s={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const f=document.createTreeWalker(o.content,Ee,null),b=[];let k=f.nextNode();for(;k;)b.push(k),k=f.nextNode();b.forEach(v=>{v.remove(),s.removedComments+=1})}catch{}Array.from(o.content.querySelectorAll("*")).forEach(f=>{f.isConnected&&We(f,t,a,s)});let i=o.innerHTML;r.normalizeWhitespace&&n!=="fidelity"?i=i.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(i=i.trim());const c=(o.content.textContent||"").trim().length;return{html:i,textLength:c,counters:s}}function ge(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const a=t.getRangeAt(0);return e.contains(a.commonAncestorContainer)?a:null}function he(e,t){if(!e.isConnected)return;const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(t))}function Ve(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const a=ge(e);if(!a)return!1;a.deleteContents();const r=document.createElement("template");r.innerHTML=t;const n=r.content,o=n.lastChild;if(a.insertNode(n),o){const s=document.createRange();s.setStartAfter(o),s.collapse(!0),he(e,s)}return!0}function je(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const a=ge(e);if(!a)return!1;a.deleteContents();const r=document.createTextNode(t);a.insertNode(r);const n=document.createRange();return n.setStart(r,r.length),n.collapse(!0),he(e,n),!0}function Fe(e,t){if(t===e.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Ge(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function W(e,t,a,r,n,o){return{source:e,profile:t,inputHtmlLength:a,outputHtmlLength:r,outputTextLength:n,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Ue(e,t,a,r){const n=qe(e,t);if(a==="plain"){const l=t||e.replace(/<[^>]*>/g," "),i=J(l,r);return{mode:"text",value:i,report:W(n,a,e.length,0,i.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!e||e.length>r.maxHtmlLength){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[a],s=Ke(e,o,n,r,a);if(!s.html){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,s.counters)}}return{mode:"html",value:s.html,report:W(n,a,e.length,s.html.length,s.textLength,s.counters)}}function G(e,t){return e==="balanced"?t.balancedText:e==="plain"?t.plainText:t.fidelityText}function ae(e){return e==="fidelity"?"balanced":e==="balanced"?"plain":"fidelity"}function Ye(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const a=e.querySelector(".rte-smart-paste-title");a&&(a.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const n=e.querySelector('[data-action="toggle-enabled"]');if(n){const Se=n.getAttribute("data-enabled")==="true";n.textContent=Se?t.labels.toggleOnText:t.labels.toggleOffText}const o=e.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=t.labels.cycleProfileText);const s=e.querySelector(".rte-smart-paste-profile-heading");s&&(s.textContent=t.labels.profileLabel);const l=e.querySelector('.rte-smart-paste-profile[role="group"]');l&&l.setAttribute("aria-label",t.labels.profileLabel);const i=e.querySelector('[data-action="set-profile"][data-profile="fidelity"]');i&&(i.textContent=t.labels.fidelityText);const c=e.querySelector('[data-action="set-profile"][data-profile="balanced"]');c&&(c.textContent=t.labels.balancedText);const f=e.querySelector('[data-action="set-profile"][data-profile="plain"]');f&&(f.textContent=t.labels.plainText);const b=e.querySelector(".rte-smart-paste-report-title");b&&(b.textContent=t.labels.lastPasteHeading);const k=e.querySelector(".rte-smart-paste-empty");k&&(k.textContent=t.labels.lastPasteEmptyText);const v=e.querySelector('[data-key="source-label"]');v&&(v.textContent=t.labels.lastPasteSourceLabel);const U=e.querySelector('[data-key="profile-label"]');U&&(U.textContent=t.labels.lastPasteProfileLabel);const M=e.querySelector('[data-key="removed-label"]');M&&(M.textContent=t.labels.lastPasteRemovedLabel);const oe=e.querySelector('[data-key="chars-label"]');oe&&(oe.textContent=t.labels.lastPasteCharsLabel);const ne=e.querySelector(".rte-smart-paste-shortcut");ne&&(ne.textContent=t.labels.shortcutText)}function x(e){const t=g.get(e),a=d.get(e)||$,r=L.get(e);if(!t||!a||!r)return;Ye(t,a);const n=t.querySelector(".rte-smart-paste-status");n&&(n.textContent=r.enabled?a.labels.enabledText:a.labels.disabledText);const o=t.querySelector('[data-action="toggle-enabled"]');o&&(o.setAttribute("data-enabled",r.enabled?"true":"false"),o.textContent=r.enabled?a.labels.toggleOnText:a.labels.toggleOffText,o.setAttribute("aria-pressed",r.enabled?"true":"false")),Array.from(t.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(v=>{const M=z(v.getAttribute("data-profile"))===r.profile;v.classList.toggle("active",M),v.setAttribute("aria-pressed",M?"true":"false")});const l=t.querySelector(".rte-smart-paste-empty"),i=t.querySelector(".rte-smart-paste-report"),c=t.querySelector('[data-key="source-value"]'),f=t.querySelector('[data-key="profile-value"]'),b=t.querySelector('[data-key="removed-value"]'),k=t.querySelector('[data-key="chars-value"]');if(!r.lastReport){l&&(l.hidden=!1),i&&(i.hidden=!0);return}if(l&&(l.hidden=!0),i&&(i.hidden=!1),c&&(c.textContent=r.lastReport.source),f&&(f.textContent=G(r.lastReport.profile,a.labels)),b){const v=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;b.textContent=String(v)}k&&(k.textContent=String(r.lastReport.outputTextLength))}function Q(e,t){if(!t.classList.contains("show"))return;const a=te(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360),n=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,a.right-r),n),s=Math.max(10,Math.min(window.innerHeight-10,a.top+12));t.style.width=`${r}px`,t.style.left=`${o}px`,t.style.top=`${s}px`,t.style.maxHeight=`${Math.max(240,window.innerHeight-20)}px`}function N(e,t=!1){const a=g.get(e);a&&(a.classList.remove("show"),q.set(e,!1),D(e,"toggleSmartPastePanel",!1),t&&e.focus({preventScroll:!0}))}function Xe(e){const t=g.get(e);if(t)return t;const a=d.get(e)||$||K(),r=`rte-smart-paste-panel-${$e++}`,n=document.createElement("section");return n.className=u,n.id=r,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false"),n.setAttribute("aria-label",a.labels.panelAriaLabel),n.innerHTML=`
|
|
7
7
|
<header class="rte-smart-paste-header">
|
|
8
8
|
<h2 class="rte-smart-paste-title">${X(a.labels.panelTitle)}</h2>
|
|
9
9
|
<button type="button" class="rte-smart-paste-icon-btn" data-action="close" aria-label="${X(a.labels.closeText)}">✕</button>
|
|
@@ -35,30 +35,30 @@
|
|
|
35
35
|
<p class="rte-smart-paste-shortcut"></p>
|
|
36
36
|
</div>
|
|
37
37
|
<div class="rte-smart-paste-live" aria-live="polite" aria-atomic="true"></div>
|
|
38
|
-
`,n.addEventListener("click",o=>{const
|
|
39
|
-
.rte-toolbar-group-items.${
|
|
40
|
-
.editora-toolbar-group-items.${
|
|
41
|
-
.rte-toolbar-group-items.${
|
|
42
|
-
.editora-toolbar-group-items.${
|
|
38
|
+
`,n.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const i=l.getAttribute("data-action");if(i){if(i==="close"){N(e,!0);return}if(i==="toggle-enabled"){const c=p(e,d.get(e)||a);c.enabled=!c.enabled,D(e,"toggleSmartPasteEnabled",c.enabled),x(e),O(n,c.enabled?a.labels.enabledText:a.labels.disabledText);return}if(i==="cycle-profile"){const c=p(e,d.get(e)||a);c.profile=ae(c.profile),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`);return}if(i==="set-profile"){const c=p(e,d.get(e)||a);c.profile=z(l.getAttribute("data-profile")),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`)}}}),n.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),N(e,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const s=Array.from(n.querySelectorAll('[data-action="set-profile"][data-profile]'));if(s.length===0)return;const l=s.findIndex(f=>f===document.activeElement);if(l<0)return;const i=o.key==="ArrowRight"?1:-1,c=(l+i+s.length)%s.length;o.preventDefault(),s[c].focus()}),F(n,e),document.body.appendChild(n),g.set(e,n),q.set(e,!1),x(e),n}function ye(e){const t=Xe(e);g.forEach((r,n)=>{n!==e&&N(n,!1)}),t.classList.add("show"),q.set(e,!0),D(e,"toggleSmartPastePanel",!0),F(t,e),Q(e,t),t.querySelector('[data-action="toggle-enabled"]')?.focus()}function xe(e,t){const a=re(e);return(typeof t=="boolean"?t:!a)?ye(e):N(e,!1),!0}function ve(e){return{enabled:e.enabled,profile:e.profile,lastReport:e.lastReport?{...e.lastReport}:null}}function Ze(e,t){const a=d.get(e)||$;if(!a)return!1;const r=p(e,a);if(!r.enabled||de(e)){const b=g.get(e);return b&&de(e)&&O(b,a.labels.readonlyMessage),!1}const n=t.clipboardData;if(!n)return!1;const o=n.getData("text/html")||"",s=n.getData("text/plain")||"";if(!o&&!s)return!1;const l=Ue(o,s,r.profile,a);if(!l.value)return!1;const i=e.innerHTML;if(!(l.mode==="html"?Ve(e,l.value):je(e,l.value)))return!1;r.lastReport={...l.report},L.set(e,r),Fe(e,i),Ge(e),e.dispatchEvent(new CustomEvent("editora:smart-paste",{bubbles:!0,detail:ve(r)})),x(e);const f=g.get(e);if(f){const b=l.report.removedElements+l.report.removedAttributes+l.report.removedComments+l.report.normalizedStyles;O(f,`${a.labels.panelTitle}: ${G(r.profile,a.labels)}. ${a.labels.lastPasteRemovedLabel}: ${b}.`)}return!0}function Je(e){return t=>{t.defaultPrevented||t[ie]===!0||(m=e,!Ze(e,t))||(t[ie]=!0,t.preventDefault(),typeof t.stopImmediatePropagation=="function"?t.stopImmediatePropagation():t.stopPropagation())}}function Qe(e){if(j.has(e))return;const t=Je(e);e.addEventListener("paste",t,!0),j.set(e,t)}function R(e){const t=L.get(e);D(e,"toggleSmartPastePanel",re(e)),D(e,"toggleSmartPasteEnabled",t?.enabled===!0)}function et(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="s"}function tt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function rt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function at(e){$=e,P||(P=t=>{V();const r=t.target?.closest(y);if(!r)return;const n=d.get(r)||e;p(r,n),d.set(r,n),m=r,R(r);const o=g.get(r);o&&(F(o,r),Q(r,o),x(r))},document.addEventListener("focusin",P,!0)),A||(A=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=_e(t);if(!r)return;const n=d.get(r)||$||e;if(p(r,n),d.set(r,n),m=r,t.key==="Escape"&&re(r)){t.preventDefault(),N(r,!0);return}if(et(t)){t.preventDefault(),t.stopPropagation(),xe(r);return}if(tt(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.profile=ae(o.profile),x(r);return}if(rt(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.enabled=!o.enabled,R(r),x(r)}},document.addEventListener("keydown",A,!0)),T||(T=()=>{V(),g.forEach((t,a)=>{!a.isConnected||!t.isConnected||(F(t,a),Q(a,t))})},window.addEventListener("scroll",T,!0),window.addEventListener("resize",T)),!w&&typeof MutationObserver<"u"&&document.body&&(w=new MutationObserver(t=>{He(t)&&V()}),w.observe(document.body,{childList:!0,subtree:!0}))}function ot(){P&&(document.removeEventListener("focusin",P,!0),P=null),A&&(document.removeEventListener("keydown",A,!0),A=null),T&&(window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T),T=null),w&&(w.disconnect(),w=null),g.forEach(e=>e.remove()),g.clear(),_.forEach(e=>me(e)),_.clear(),$=null,m=null}function nt(){if(typeof document>"u"||document.getElementById(le))return;const e=document.createElement("style");e.id=le,e.textContent=`
|
|
39
|
+
.rte-toolbar-group-items.${h},
|
|
40
|
+
.editora-toolbar-group-items.${h},
|
|
41
|
+
.rte-toolbar-group-items.${S},
|
|
42
|
+
.editora-toolbar-group-items.${S} {
|
|
43
43
|
display: flex;
|
|
44
44
|
border: 1px solid #ccc;
|
|
45
45
|
border-radius: 3px;
|
|
46
46
|
background: #fff;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.rte-toolbar-group-items.${
|
|
50
|
-
.editora-toolbar-group-items.${
|
|
51
|
-
.rte-toolbar-group-items.${
|
|
52
|
-
.editora-toolbar-group-items.${
|
|
49
|
+
.rte-toolbar-group-items.${h} .rte-toolbar-button,
|
|
50
|
+
.editora-toolbar-group-items.${h} .editora-toolbar-button,
|
|
51
|
+
.rte-toolbar-group-items.${S} .rte-toolbar-button,
|
|
52
|
+
.editora-toolbar-group-items.${S} .editora-toolbar-button {
|
|
53
53
|
border: none;
|
|
54
54
|
border-right: 1px solid #ccc;
|
|
55
55
|
border-radius: 0;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
.rte-toolbar-group-items.${
|
|
59
|
-
.editora-toolbar-group-items.${
|
|
60
|
-
.rte-toolbar-group-items.${
|
|
61
|
-
.editora-toolbar-group-items.${
|
|
58
|
+
.rte-toolbar-group-items.${h} .rte-toolbar-item:last-child .rte-toolbar-button,
|
|
59
|
+
.editora-toolbar-group-items.${h} .editora-toolbar-item:last-child .editora-toolbar-button,
|
|
60
|
+
.rte-toolbar-group-items.${S} .rte-toolbar-item:last-child .rte-toolbar-button,
|
|
61
|
+
.editora-toolbar-group-items.${S} .editora-toolbar-item:last-child .editora-toolbar-button {
|
|
62
62
|
border-right: none;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -67,23 +67,23 @@
|
|
|
67
67
|
background-color: #ccc;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
${
|
|
71
|
-
${
|
|
72
|
-
${
|
|
73
|
-
${
|
|
70
|
+
${E} .rte-toolbar-group-items.${h},
|
|
71
|
+
${E} .editora-toolbar-group-items.${h},
|
|
72
|
+
${E} .rte-toolbar-group-items.${S},
|
|
73
|
+
${E} .editora-toolbar-group-items.${S},
|
|
74
74
|
.${u}.rte-smart-paste-theme-dark {
|
|
75
75
|
border-color: #566275;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
${
|
|
79
|
-
${
|
|
80
|
-
${
|
|
81
|
-
${
|
|
78
|
+
${E} .rte-toolbar-group-items.${h} .rte-toolbar-button svg,
|
|
79
|
+
${E} .editora-toolbar-group-items.${h} .editora-toolbar-button svg,
|
|
80
|
+
${E} .rte-toolbar-group-items.${S} .rte-toolbar-button svg,
|
|
81
|
+
${E} .editora-toolbar-group-items.${S} .editora-toolbar-button svg {
|
|
82
82
|
fill: none;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
${
|
|
86
|
-
${
|
|
85
|
+
${E} .rte-toolbar-group-items.${h} .rte-toolbar-button,
|
|
86
|
+
${E} .editora-toolbar-group-items.${h} .editora-toolbar-button
|
|
87
87
|
{
|
|
88
88
|
border-color: #566275;
|
|
89
89
|
}
|
|
@@ -395,4 +395,4 @@
|
|
|
395
395
|
grid-template-columns: 1fr;
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
`,document.head.appendChild(e)}const st=(e={})=>{const t=
|
|
398
|
+
`,document.head.appendChild(e)}const st=(e={})=>{const t=K(e),a=new Set;return nt(),{name:"smartPaste",toolbar:[{id:"smartPasteGroup",label:"Smart Paste",type:"group",command:"smartPaste",items:[{id:"smartPaste",label:"Smart Paste Panel",command:"toggleSmartPastePanel",shortcut:"Mod-Alt-Shift-s",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8.5 4.5h7l3 3V18a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 6.5 18V7a2.5 2.5 0 0 1 2-2.45Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M15.5 4.5V8h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.3 12h5.4M9.3 15h5.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"smartPasteProfile",label:"Cycle Smart Paste Profile",command:"cycleSmartPasteProfile",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 7.5h10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="17.5" cy="7.5" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 12h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12.5" cy="12" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 16.5h12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="9.5" cy="16.5" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"smartPasteToggle",label:"Toggle Smart Paste",command:"toggleSmartPasteEnabled",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="8" width="17" height="8" rx="4" stroke="currentColor" stroke-width="1.6"/><circle cx="8" cy="12" r="2.6" fill="currentColor"/><path d="M14.5 12h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{smartPaste:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,ye(o),!0},toggleSmartPastePanel:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,xe(o,typeof r=="boolean"?r:void 0)},cycleSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=ae(l.profile),x(o),!0},setSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=z(r),x(o),!0},toggleSmartPasteEnabled:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.enabled=typeof r=="boolean"?r:!l.enabled,R(o),x(o),!0},setSmartPasteOptions:(r,n)=>{const o=C(n,!1,!1);if(!o||!r||typeof r!="object")return!1;const s=d.get(o)||t,l=ce(s),i=K({...l,...r,labels:{...s.labels,...r.labels||{}},profileOptions:{...l.profileOptions,...r.profileOptions||{},fidelity:{...l.profileOptions?.fidelity||{},...r.profileOptions?.fidelity||{}},balanced:{...l.profileOptions?.balanced||{},...r.profileOptions?.balanced||{}},plain:{...l.profileOptions?.plain||{},...r.profileOptions?.plain||{}}},normalizeText:r.normalizeText||s.normalizeText});d.set(o,i);const c=p(o,i);return typeof r.enabled=="boolean"&&(c.enabled=r.enabled),r.defaultProfile&&(c.profile=z(r.defaultProfile)),x(o),R(o),!0},getSmartPasteState:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s),i=ve(l);if(typeof r=="function")try{r(i)}catch{}return o.__smartPasteState=i,o.dispatchEvent(new CustomEvent("editora:smart-paste-state",{bubbles:!0,detail:i})),!0}},keymap:{"Mod-Alt-Shift-s":"toggleSmartPastePanel","Mod-Alt-Shift-S":"toggleSmartPastePanel","Mod-Alt-Shift-v":"cycleSmartPasteProfile","Mod-Alt-Shift-V":"cycleSmartPasteProfile","Mod-Alt-Shift-g":"toggleSmartPasteEnabled","Mod-Alt-Shift-G":"toggleSmartPasteEnabled"},init:function(n){I+=1;const o=this&&typeof this.__pluginConfig=="object"?K({...ce(t),...this.__pluginConfig}):t;at(o);const s=C(n?.editorElement?{editorElement:n.editorElement}:void 0,!1,!1);if(!s)return;m=s,a.add(s);const l=p(s,o);l.enabled=o.enabled,l.profile=o.defaultProfile,d.set(s,o),R(s)},destroy:()=>{a.forEach(r=>be(r)),a.clear(),I=Math.max(0,I-1),!(I>0)&&ot()}}};exports.SmartPastePlugin=st;
|