@editora/core 1.0.6 → 1.0.7

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.
Files changed (43) hide show
  1. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  2. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  3. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  4. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  5. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  6. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  7. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  8. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  9. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  10. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  11. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  12. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
  13. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  14. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  15. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  16. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  17. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  18. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  19. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  20. package/dist/editora.min.js +10 -10
  21. package/dist/editora.umd.js +10 -10
  22. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  23. package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
  24. package/dist/index-BslAFzmv.mjs +16544 -0
  25. package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
  26. package/dist/index.cjs.js +1 -1
  27. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  28. package/dist/index.esm.js +2 -2
  29. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  30. package/dist/plugin-loader.js +15 -15
  31. package/dist/webcomponent-core.js +241 -224
  32. package/dist/webcomponent-core.min.css +1 -1
  33. package/dist/webcomponent-core.min.js +86 -106
  34. package/dist/webcomponent.cjs.js +1 -1
  35. package/dist/webcomponent.esm.js +1 -1
  36. package/dist/webcomponent.js +205 -188
  37. package/dist/webcomponent.min.css +1 -1
  38. package/dist/webcomponent.min.js +477 -402
  39. package/package.json +1 -1
  40. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  41. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  42. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  43. package/dist/documentManager-irzj9n3V.mjs +0 -37627
@@ -1,5 +1,12 @@
1
- let R = null, c = null, l = null, _ = [], D = !1, T = null, V = 0, P = 0, q = 0, C = 0, N = 1, A = null;
2
- const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
1
+ let D = null, d = null, l = null, _ = [], H = !1, A = null, U = 0, j = 0, q = 0, z = 0, P = 1, R = null;
2
+ const F = '[data-theme="dark"], .dark, .editora-theme-dark', I = (t, e) => {
3
+ const r = (i) => {
4
+ i.key !== "Escape" || !t.isConnected || (i.preventDefault(), i.stopPropagation(), e());
5
+ };
6
+ return document.addEventListener("keydown", r, !0), () => {
7
+ document.removeEventListener("keydown", r, !0);
8
+ };
9
+ }, X = () => {
3
10
  if (typeof document == "undefined" || document.getElementById("rte-media-dialog-styles")) return;
4
11
  const t = document.createElement("style");
5
12
  t.id = "rte-media-dialog-styles", t.textContent = `
@@ -380,7 +387,7 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
380
387
  }
381
388
 
382
389
  .media-floating-toolbar.rte-ui-theme-dark,
383
- ${j} .media-floating-toolbar {
390
+ ${F} .media-floating-toolbar {
384
391
  --rte-media-toolbar-bg: #24303f;
385
392
  --rte-media-toolbar-border: #4a5a71;
386
393
  --rte-media-toolbar-text: #d9e6fb;
@@ -429,34 +436,34 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
429
436
  background: var(--rte-media-toolbar-separator);
430
437
  }
431
438
  `, document.head.appendChild(t);
432
- }, O = () => {
439
+ }, Y = () => {
433
440
  const t = window.getSelection();
434
441
  if (!t || t.rangeCount === 0) return null;
435
442
  const e = t.anchorNode, r = e instanceof HTMLElement ? e : e == null ? void 0 : e.parentElement;
436
443
  return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
437
- }, X = (t) => {
444
+ }, Z = (t) => {
438
445
  if (t) return t;
439
- const e = O();
446
+ const e = Y();
440
447
  if (e) return e;
441
- if (A) return A;
448
+ if (R) return R;
442
449
  const r = document.activeElement;
443
450
  return r ? r.closest(".rte-content, .editora-content") || r : null;
444
- }, W = (t) => {
445
- const e = X(t);
446
- return e ? !!e.closest(j) : !1;
447
- }, H = (t) => {
448
- G();
451
+ }, G = (t) => {
452
+ const e = Z(t);
453
+ return e ? !!e.closest(F) : !1;
454
+ }, N = (t) => {
455
+ X();
449
456
  const e = document.createElement("div");
450
- return e.className = "rte-media-overlay", W(t) && e.classList.add("rte-ui-theme-dark"), e;
451
- }, I = (t = !1) => {
457
+ return e.className = "rte-media-overlay", G(t) && e.classList.add("rte-ui-theme-dark"), e;
458
+ }, B = (t = !1) => {
452
459
  const e = document.createElement("div");
453
460
  return e.className = t ? "rte-media-dialog rte-media-dialog-compact" : "rte-media-dialog", e.setAttribute("role", "dialog"), e.setAttribute("aria-modal", "true"), e;
454
- }, U = (t, e) => {
461
+ }, W = (t, e) => {
455
462
  const r = window.getSelection();
456
- r && r.rangeCount > 0 && (R = r.getRangeAt(0).cloneRange());
457
- const o = H(e), a = I();
458
- let n = "upload", s = "", b = "", p = "", g = "";
459
- const f = () => {
463
+ r && r.rangeCount > 0 && (D = r.getRangeAt(0).cloneRange());
464
+ const i = N(e), a = B();
465
+ let n = "upload", s = "", b = "", m = "", f = "";
466
+ const y = () => {
460
467
  a.innerHTML = `
461
468
  <div class="rte-media-header">
462
469
  <h2 class="rte-media-title">Insert ${t === "image" ? "Image" : "Video"}</h2>
@@ -494,7 +501,7 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
494
501
  ${t === "image" ? `
495
502
  <div class="rte-media-field">
496
503
  <label class="rte-media-label">Alt Text (for accessibility)</label>
497
- <input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${g}">
504
+ <input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${f}">
498
505
  </div>
499
506
  ` : ""}
500
507
  <div class="rte-media-grid">
@@ -504,7 +511,7 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
504
511
  </div>
505
512
  <div class="rte-media-field">
506
513
  <label class="rte-media-label">Height (px)</label>
507
- <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${p}">
514
+ <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${m}">
508
515
  </div>
509
516
  </div>
510
517
  ${s ? `
@@ -525,72 +532,76 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
525
532
  </div>
526
533
  `;
527
534
  };
528
- f(), o.appendChild(a), document.body.appendChild(o);
529
- const y = () => {
530
- o.parentNode && o.parentNode.removeChild(o);
531
- }, k = () => {
535
+ y(), i.appendChild(a), document.body.appendChild(i);
536
+ let w = () => {
537
+ };
538
+ const h = () => {
539
+ w(), i.parentNode && i.parentNode.removeChild(i);
540
+ };
541
+ w = I(i, h);
542
+ const x = () => {
532
543
  if (!s) return;
533
- const i = t === "image" ? document.createElement("img") : document.createElement("video");
534
- i.src = s, i.setAttribute("data-media-type", t), t === "image" && g && (i.alt = g), b && (i.style.width = `${b}px`, i.setAttribute("width", b)), p && (i.style.height = `${p}px`, i.setAttribute("height", p)), t === "video" && (i.controls = !0), !b && !p ? i.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : i.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${b ? `width: ${b}px;` : "max-width: 100%;"} ${p ? `height: ${p}px;` : "height: auto;"}`, R && (R.deleteContents(), R.insertNode(i)), y();
535
- }, h = async (i) => {
536
- const u = a.querySelector("#upload-progress"), v = a.querySelector("#progress-bar"), E = a.querySelector("#progress-text");
537
- if (u && v && E) {
538
- u.style.display = "block";
539
- let w = 0;
540
- const m = setInterval(() => {
541
- w += Math.random() * 30, w > 90 && (w = 90), v.style.width = `${w}%`;
544
+ const o = t === "image" ? document.createElement("img") : document.createElement("video");
545
+ o.src = s, o.setAttribute("data-media-type", t), t === "image" && f && (o.alt = f), b && (o.style.width = `${b}px`, o.setAttribute("width", b)), m && (o.style.height = `${m}px`, o.setAttribute("height", m)), t === "video" && (o.controls = !0), !b && !m ? o.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : o.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${b ? `width: ${b}px;` : "max-width: 100%;"} ${m ? `height: ${m}px;` : "height: auto;"}`, D && (D.deleteContents(), D.insertNode(o)), h();
546
+ }, c = async (o) => {
547
+ const v = a.querySelector("#upload-progress"), g = a.querySelector("#progress-bar"), L = a.querySelector("#progress-text");
548
+ if (v && g && L) {
549
+ v.style.display = "block";
550
+ let E = 0;
551
+ const u = setInterval(() => {
552
+ E += Math.random() * 30, E > 90 && (E = 90), g.style.width = `${E}%`;
542
553
  }, 200);
543
554
  try {
544
- const x = new FileReader();
545
- x.onload = () => {
546
- clearInterval(m), v.style.width = "100%", E.textContent = "Upload complete", setTimeout(() => {
547
- s = x.result, n = "url", f(), d();
555
+ const k = new FileReader();
556
+ k.onload = () => {
557
+ clearInterval(u), g.style.width = "100%", L.textContent = "Upload complete", setTimeout(() => {
558
+ s = k.result, n = "url", y(), p();
548
559
  }, 500);
549
- }, x.readAsDataURL(i);
550
- } catch (x) {
551
- clearInterval(m), E.textContent = "Upload failed";
560
+ }, k.readAsDataURL(o);
561
+ } catch (k) {
562
+ clearInterval(u), L.textContent = "Upload failed";
552
563
  }
553
564
  }
554
- }, d = () => {
555
- const i = a.querySelector(".close-btn"), u = a.querySelector(".cancel-btn"), v = a.querySelector("#insert-btn"), E = a.querySelector(".tab-upload"), w = a.querySelector(".tab-url");
556
- if (i == null || i.addEventListener("click", y), u == null || u.addEventListener("click", y), v == null || v.addEventListener("click", k), E == null || E.addEventListener("click", () => {
557
- n = "upload", f(), d();
558
- }), w == null || w.addEventListener("click", () => {
559
- n = "url", f(), d();
565
+ }, p = () => {
566
+ const o = a.querySelector(".close-btn"), v = a.querySelector(".cancel-btn"), g = a.querySelector("#insert-btn"), L = a.querySelector(".tab-upload"), E = a.querySelector(".tab-url");
567
+ if (o == null || o.addEventListener("click", h), v == null || v.addEventListener("click", h), g == null || g.addEventListener("click", x), L == null || L.addEventListener("click", () => {
568
+ n = "upload", y(), p();
569
+ }), E == null || E.addEventListener("click", () => {
570
+ n = "url", y(), p();
560
571
  }), n === "upload") {
561
- const m = a.querySelector(".dropzone"), x = a.querySelector("#file-input");
562
- m == null || m.addEventListener("click", () => x == null ? void 0 : x.click()), m == null || m.addEventListener("dragover", (L) => {
563
- L.preventDefault(), m.classList.add("is-dragover");
564
- }), m == null || m.addEventListener("dragleave", () => {
565
- m.classList.remove("is-dragover");
566
- }), m == null || m.addEventListener("drop", (L) => {
567
- var M;
568
- L.preventDefault(), m.classList.remove("is-dragover");
569
- const S = (M = L.dataTransfer) == null ? void 0 : M.files[0];
570
- S && h(S);
571
- }), x == null || x.addEventListener("change", (L) => {
572
- var M;
573
- const S = (M = L.target.files) == null ? void 0 : M[0];
574
- S && h(S);
572
+ const u = a.querySelector(".dropzone"), k = a.querySelector("#file-input");
573
+ u == null || u.addEventListener("click", () => k == null ? void 0 : k.click()), u == null || u.addEventListener("dragover", (S) => {
574
+ S.preventDefault(), u.classList.add("is-dragover");
575
+ }), u == null || u.addEventListener("dragleave", () => {
576
+ u.classList.remove("is-dragover");
577
+ }), u == null || u.addEventListener("drop", (S) => {
578
+ var T;
579
+ S.preventDefault(), u.classList.remove("is-dragover");
580
+ const $ = (T = S.dataTransfer) == null ? void 0 : T.files[0];
581
+ $ && c($);
582
+ }), k == null || k.addEventListener("change", (S) => {
583
+ var T;
584
+ const $ = (T = S.target.files) == null ? void 0 : T[0];
585
+ $ && c($);
575
586
  });
576
587
  }
577
588
  if (n === "url") {
578
- const m = a.querySelector("#url-input"), x = a.querySelector("#alt-input"), L = a.querySelector("#width-input"), S = a.querySelector("#height-input");
579
- m == null || m.addEventListener("input", () => {
580
- s = m.value, f(), d();
581
- }), x == null || x.addEventListener("input", () => {
582
- g = x.value;
583
- }), L == null || L.addEventListener("input", () => {
584
- b = L.value;
589
+ const u = a.querySelector("#url-input"), k = a.querySelector("#alt-input"), S = a.querySelector("#width-input"), $ = a.querySelector("#height-input");
590
+ u == null || u.addEventListener("input", () => {
591
+ s = u.value, y(), p();
592
+ }), k == null || k.addEventListener("input", () => {
593
+ f = k.value;
585
594
  }), S == null || S.addEventListener("input", () => {
586
- p = S.value;
595
+ b = S.value;
596
+ }), $ == null || $.addEventListener("input", () => {
597
+ m = $.value;
587
598
  });
588
599
  }
589
600
  };
590
- d(), o.addEventListener("click", (i) => {
591
- i.target === o && y();
601
+ p(), i.addEventListener("click", (o) => {
602
+ o.target === i && h();
592
603
  });
593
- }, Y = () => {
604
+ }, K = () => {
594
605
  ["nw", "ne", "sw", "se"].forEach((e) => {
595
606
  const r = document.createElement("div");
596
607
  r.className = `media-resize-handle-${e}`, r.style.cssText = `
@@ -606,23 +617,23 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
606
617
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
607
618
  `, r.setAttribute("data-position", e), document.body.appendChild(r), _.push(r);
608
619
  });
609
- }, z = () => {
610
- if (!c) {
620
+ }, M = () => {
621
+ if (!d) {
611
622
  _.forEach((r) => r.style.display = "none");
612
623
  return;
613
624
  }
614
- const t = c.getBoundingClientRect(), e = {
625
+ const t = d.getBoundingClientRect(), e = {
615
626
  nw: { x: t.left - 5, y: t.top - 5 },
616
627
  ne: { x: t.right - 5, y: t.top - 5 },
617
628
  sw: { x: t.left - 5, y: t.bottom - 5 },
618
629
  se: { x: t.right - 5, y: t.bottom - 5 }
619
630
  };
620
631
  _.forEach((r) => {
621
- const o = r.getAttribute("data-position"), a = e[o];
632
+ const i = r.getAttribute("data-position"), a = e[i];
622
633
  r.style.left = `${a.x}px`, r.style.top = `${a.y}px`, r.style.display = "block";
623
634
  });
624
- }, Z = (t) => {
625
- const e = H(t), r = I(!0);
635
+ }, J = (t) => {
636
+ const e = N(t), r = B(!0);
626
637
  r.innerHTML = `
627
638
  <div class="rte-media-header">
628
639
  <h2 class="rte-media-title">Edit Alt Text</h2>
@@ -638,16 +649,19 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
638
649
  <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
639
650
  </div>
640
651
  `, e.appendChild(r), document.body.appendChild(e);
641
- const o = r.querySelector("#alt-text-input"), a = r.querySelector(".close-btn"), n = r.querySelector(".cancel-btn"), s = r.querySelector(".save-btn"), b = () => {
642
- e.parentNode && e.parentNode.removeChild(e);
652
+ const i = r.querySelector("#alt-text-input"), a = r.querySelector(".close-btn"), n = r.querySelector(".cancel-btn"), s = r.querySelector(".save-btn");
653
+ let b = () => {
654
+ };
655
+ const m = () => {
656
+ b(), e.parentNode && e.parentNode.removeChild(e);
643
657
  };
644
- a.addEventListener("click", b), n.addEventListener("click", b), e.addEventListener("click", (p) => {
645
- p.target === e && b();
658
+ b = I(e, m), a.addEventListener("click", m), n.addEventListener("click", m), e.addEventListener("click", (f) => {
659
+ f.target === e && m();
646
660
  }), s.addEventListener("click", () => {
647
- t.alt = o.value, b();
648
- }), o.focus(), o.select();
649
- }, K = (t) => {
650
- const e = t.closest("a"), r = (e == null ? void 0 : e.getAttribute("href")) || "", o = (e == null ? void 0 : e.getAttribute("target")) || "_self", a = (e == null ? void 0 : e.getAttribute("title")) || "", n = H(t), s = I(!0);
661
+ t.alt = i.value, m();
662
+ }), i.focus(), i.select();
663
+ }, Q = (t) => {
664
+ const e = t.closest("a"), r = (e == null ? void 0 : e.getAttribute("href")) || "", i = (e == null ? void 0 : e.getAttribute("target")) || "_self", a = (e == null ? void 0 : e.getAttribute("title")) || "", n = N(t), s = B(!0);
651
665
  s.innerHTML = `
652
666
  <div class="rte-media-header">
653
667
  <h2 class="rte-media-title">${e ? "Edit Link" : "Add Link"}</h2>
@@ -663,7 +677,7 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
663
677
  <input id="link-title" type="text" class="rte-media-input" value="${a}" placeholder="Optional tooltip text" />
664
678
  </div>
665
679
  <label class="rte-media-checkbox-label">
666
- <input id="link-target" type="checkbox" ${o === "_blank" ? "checked" : ""} />
680
+ <input id="link-target" type="checkbox" ${i === "_blank" ? "checked" : ""} />
667
681
  Open in new window/tab
668
682
  </label>
669
683
  </div>
@@ -675,29 +689,32 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
675
689
  </div>
676
690
  </div>
677
691
  `, n.appendChild(s), document.body.appendChild(n);
678
- const b = s.querySelector("#link-url"), p = s.querySelector("#link-title"), g = s.querySelector("#link-target"), f = s.querySelector(".close-btn"), y = s.querySelector(".cancel-btn"), k = s.querySelector(".save-btn"), h = s.querySelector(".remove-link-btn"), d = () => {
679
- n.parentNode && n.parentNode.removeChild(n);
692
+ const b = s.querySelector("#link-url"), m = s.querySelector("#link-title"), f = s.querySelector("#link-target"), y = s.querySelector(".close-btn"), w = s.querySelector(".cancel-btn"), h = s.querySelector(".save-btn"), x = s.querySelector(".remove-link-btn");
693
+ let c = () => {
680
694
  };
681
- f.addEventListener("click", d), y.addEventListener("click", d), n.addEventListener("click", (i) => {
682
- i.target === n && d();
683
- }), k.addEventListener("click", () => {
684
- const i = b.value.trim();
685
- if (i) {
686
- const u = i.startsWith("http") ? i : `https://${i}`;
695
+ const p = () => {
696
+ c(), n.parentNode && n.parentNode.removeChild(n);
697
+ };
698
+ c = I(n, p), y.addEventListener("click", p), w.addEventListener("click", p), n.addEventListener("click", (o) => {
699
+ o.target === n && p();
700
+ }), h.addEventListener("click", () => {
701
+ const o = b.value.trim();
702
+ if (o) {
703
+ const v = o.startsWith("http") ? o : `https://${o}`;
687
704
  if (e)
688
- e.setAttribute("href", u), e.setAttribute("target", g.checked ? "_blank" : "_self"), g.checked ? e.setAttribute("rel", "noopener noreferrer") : e.removeAttribute("rel"), p.value.trim() ? e.setAttribute("title", p.value.trim()) : e.removeAttribute("title");
705
+ e.setAttribute("href", v), e.setAttribute("target", f.checked ? "_blank" : "_self"), f.checked ? e.setAttribute("rel", "noopener noreferrer") : e.removeAttribute("rel"), m.value.trim() ? e.setAttribute("title", m.value.trim()) : e.removeAttribute("title");
689
706
  else {
690
- const v = document.createElement("a");
691
- v.href = u, v.target = g.checked ? "_blank" : "_self", g.checked && (v.rel = "noopener noreferrer"), p.value.trim() && (v.title = p.value.trim()), t.replaceWith(v), v.appendChild(t);
707
+ const g = document.createElement("a");
708
+ g.href = v, g.target = f.checked ? "_blank" : "_self", f.checked && (g.rel = "noopener noreferrer"), m.value.trim() && (g.title = m.value.trim()), t.replaceWith(g), g.appendChild(t);
692
709
  }
693
- d(), l && c && B(c);
710
+ p(), l && d && V(d);
694
711
  }
695
- }), h == null || h.addEventListener("click", () => {
696
- e && confirm("Remove link from this media?") && (e.replaceWith(t), d(), l && c && B(c));
712
+ }), x == null || x.addEventListener("click", () => {
713
+ e && confirm("Remove link from this media?") && (e.replaceWith(t), p(), l && d && V(d));
697
714
  }), b.focus();
698
- }, J = (t) => {
699
- const e = H(t), r = I();
700
- let o = "url", a = t.src;
715
+ }, ee = (t) => {
716
+ const e = N(t), r = B();
717
+ let i = "url", a = t.src;
701
718
  const n = () => {
702
719
  r.innerHTML = `
703
720
  <div class="rte-media-header">
@@ -706,12 +723,12 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
706
723
  </div>
707
724
 
708
725
  <div class="rte-media-tabs">
709
- <button class="tab-upload rte-media-tab ${o === "upload" ? "active" : ""}" type="button">Upload</button>
710
- <button class="tab-url rte-media-tab ${o === "url" ? "active" : ""}" type="button">URL</button>
726
+ <button class="tab-upload rte-media-tab ${i === "upload" ? "active" : ""}" type="button">Upload</button>
727
+ <button class="tab-url rte-media-tab ${i === "url" ? "active" : ""}" type="button">URL</button>
711
728
  </div>
712
729
 
713
730
  <div class="rte-media-body">
714
- ${o === "upload" ? `
731
+ ${i === "upload" ? `
715
732
  <div id="upload-section">
716
733
  <div class="dropzone rte-media-dropzone">
717
734
  <div class="rte-media-dropzone-icon">📁</div>
@@ -746,82 +763,86 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
746
763
 
747
764
  <div class="rte-media-footer">
748
765
  <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
749
- <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!a && o === "url" ? "disabled" : ""}>Replace</button>
766
+ <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!a && i === "url" ? "disabled" : ""}>Replace</button>
750
767
  </div>
751
768
  `;
752
769
  };
753
770
  n(), e.appendChild(r), document.body.appendChild(e);
754
- const s = () => {
755
- e.parentNode && e.parentNode.removeChild(e);
756
- }, b = () => {
757
- a && (t.src = a, s());
758
- }, p = async (f) => {
759
- const y = r.querySelector("#upload-progress"), k = r.querySelector("#progress-bar"), h = r.querySelector("#progress-text");
760
- if (y && k && h) {
761
- y.style.display = "block";
762
- let d = 0;
763
- const i = setInterval(() => {
764
- d += Math.random() * 30, d > 90 && (d = 90), k.style.width = `${d}%`;
771
+ let s = () => {
772
+ };
773
+ const b = () => {
774
+ s(), e.parentNode && e.parentNode.removeChild(e);
775
+ };
776
+ s = I(e, b);
777
+ const m = () => {
778
+ a && (t.src = a, b());
779
+ }, f = async (w) => {
780
+ const h = r.querySelector("#upload-progress"), x = r.querySelector("#progress-bar"), c = r.querySelector("#progress-text");
781
+ if (h && x && c) {
782
+ h.style.display = "block";
783
+ let p = 0;
784
+ const o = setInterval(() => {
785
+ p += Math.random() * 30, p > 90 && (p = 90), x.style.width = `${p}%`;
765
786
  }, 200);
766
787
  try {
767
- const u = new FileReader();
768
- u.onload = () => {
769
- clearInterval(i), k.style.width = "100%", h.textContent = "Upload complete", setTimeout(() => {
770
- a = u.result, o = "url", n(), g();
788
+ const v = new FileReader();
789
+ v.onload = () => {
790
+ clearInterval(o), x.style.width = "100%", c.textContent = "Upload complete", setTimeout(() => {
791
+ a = v.result, i = "url", n(), y();
771
792
  }, 500);
772
- }, u.readAsDataURL(f);
773
- } catch (u) {
774
- clearInterval(i), h.textContent = "Upload failed";
793
+ }, v.readAsDataURL(w);
794
+ } catch (v) {
795
+ clearInterval(o), c.textContent = "Upload failed";
775
796
  }
776
797
  }
777
- }, g = () => {
778
- const f = r.querySelector(".close-btn"), y = r.querySelector(".cancel-btn"), k = r.querySelector("#replace-btn"), h = r.querySelector(".tab-upload"), d = r.querySelector(".tab-url");
779
- if (f == null || f.addEventListener("click", s), y == null || y.addEventListener("click", s), k == null || k.addEventListener("click", b), h == null || h.addEventListener("click", () => {
780
- o = "upload", n(), g();
781
- }), d == null || d.addEventListener("click", () => {
782
- o = "url", n(), g();
783
- }), o === "upload") {
784
- const i = r.querySelector(".dropzone"), u = r.querySelector("#file-input");
785
- i == null || i.addEventListener("click", () => u == null ? void 0 : u.click()), i == null || i.addEventListener("dragover", (v) => {
786
- v.preventDefault(), i.classList.add("is-dragover");
787
- }), i == null || i.addEventListener("dragleave", () => {
788
- i.classList.remove("is-dragover");
789
- }), i == null || i.addEventListener("drop", (v) => {
790
- var w;
791
- v.preventDefault(), i.classList.remove("is-dragover");
792
- const E = (w = v.dataTransfer) == null ? void 0 : w.files[0];
793
- E && p(E);
794
- }), u == null || u.addEventListener("change", (v) => {
795
- var w;
796
- const E = (w = v.target.files) == null ? void 0 : w[0];
797
- E && p(E);
798
+ }, y = () => {
799
+ const w = r.querySelector(".close-btn"), h = r.querySelector(".cancel-btn"), x = r.querySelector("#replace-btn"), c = r.querySelector(".tab-upload"), p = r.querySelector(".tab-url");
800
+ if (w == null || w.addEventListener("click", b), h == null || h.addEventListener("click", b), x == null || x.addEventListener("click", m), c == null || c.addEventListener("click", () => {
801
+ i = "upload", n(), y();
802
+ }), p == null || p.addEventListener("click", () => {
803
+ i = "url", n(), y();
804
+ }), i === "upload") {
805
+ const o = r.querySelector(".dropzone"), v = r.querySelector("#file-input");
806
+ o == null || o.addEventListener("click", () => v == null ? void 0 : v.click()), o == null || o.addEventListener("dragover", (g) => {
807
+ g.preventDefault(), o.classList.add("is-dragover");
808
+ }), o == null || o.addEventListener("dragleave", () => {
809
+ o.classList.remove("is-dragover");
810
+ }), o == null || o.addEventListener("drop", (g) => {
811
+ var E;
812
+ g.preventDefault(), o.classList.remove("is-dragover");
813
+ const L = (E = g.dataTransfer) == null ? void 0 : E.files[0];
814
+ L && f(L);
815
+ }), v == null || v.addEventListener("change", (g) => {
816
+ var E;
817
+ const L = (E = g.target.files) == null ? void 0 : E[0];
818
+ L && f(L);
798
819
  });
799
820
  }
800
- if (o === "url") {
801
- const i = r.querySelector("#url-input");
802
- i == null || i.addEventListener("input", () => {
803
- a = i.value, n(), g();
821
+ if (i === "url") {
822
+ const o = r.querySelector("#url-input");
823
+ o == null || o.addEventListener("input", () => {
824
+ a = o.value, n(), y();
804
825
  });
805
826
  }
806
827
  };
807
- g(), e.addEventListener("click", (f) => {
808
- f.target === e && s();
828
+ y(), e.addEventListener("click", (w) => {
829
+ w.target === e && b();
809
830
  });
810
- }, $ = () => {
811
- if (!l || !c) return;
812
- const t = l.offsetHeight || 40, e = c.offsetTop, r = c.offsetLeft, o = c.offsetWidth, a = e - t - 8, n = r + o / 2 - (l.offsetWidth || 120) / 2;
831
+ }, C = () => {
832
+ if (!l || !d) return;
833
+ const t = l.offsetHeight || 40, e = d.offsetTop, r = d.offsetLeft, i = d.offsetWidth, a = e - t - 8, n = r + i / 2 - (l.offsetWidth || 120) / 2;
813
834
  l.style.top = `${a}px`, l.style.left = `${n}px`, setTimeout(() => {
814
835
  l && (l.style.display = "flex");
815
836
  }, 100);
816
- }, B = (t) => {
817
- var s, b, p, g, f, y, k, h;
837
+ }, V = (t) => {
838
+ var s, b, m, f, y, w, h, x;
818
839
  l && (l._cleanup && l._cleanup(), l.remove());
819
840
  const e = t.parentElement;
820
841
  if (e) {
821
- const d = e.style.position;
822
- (!d || d === "static") && (e.style.position = "relative", e._originalPosition = d), l = document.createElement("div"), l.className = "media-floating-toolbar", W(t) && l.classList.add("rte-ui-theme-dark"), e.insertBefore(l, e.firstChild), $();
842
+ const c = e.style.position;
843
+ (!c || c === "static") && (e.style.position = "relative", e._originalPosition = c), l = document.createElement("div"), l.className = "media-floating-toolbar", G(t) && l.classList.add("rte-ui-theme-dark"), e.insertBefore(l, e.firstChild), C();
823
844
  }
824
- const r = t.tagName === "IMG", o = t.closest("a");
845
+ const r = t.tagName === "IMG", i = t.closest("a");
825
846
  l.innerHTML = `
826
847
  <button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
827
848
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>
@@ -837,7 +858,7 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
837
858
  <button class="media-floating-toolbar-btn btn-alt" title="Edit Alt Text" type="button">
838
859
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
839
860
  </button>` : ""}
840
- <button class="media-floating-toolbar-btn btn-link" title="${o ? "Edit/Remove Link" : "Add Link"}" type="button">
861
+ <button class="media-floating-toolbar-btn btn-link" title="${i ? "Edit/Remove Link" : "Add Link"}" type="button">
841
862
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
842
863
  </button>
843
864
  ${r ? `
@@ -849,94 +870,94 @@ const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
849
870
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
850
871
  </button>
851
872
  `, setTimeout(() => {
852
- $();
873
+ C();
853
874
  }, 0);
854
- const a = () => $();
855
- let n = c.parentElement;
875
+ const a = () => C();
876
+ let n = d.parentElement;
856
877
  for (; n; )
857
878
  n.addEventListener("scroll", a), n = n.parentElement;
858
879
  window.addEventListener("scroll", a), window.addEventListener("resize", a), l._cleanup = () => {
859
- let d = c == null ? void 0 : c.parentElement;
860
- for (; d; )
861
- d.removeEventListener("scroll", a), d = d.parentElement;
880
+ let c = d == null ? void 0 : d.parentElement;
881
+ for (; c; )
882
+ c.removeEventListener("scroll", a), c = c.parentElement;
862
883
  window.removeEventListener("scroll", a), window.removeEventListener("resize", a);
863
884
  }, (s = l.querySelector(".btn-align-left")) == null || s.addEventListener("click", () => {
864
- t.style.display = "block", t.style.marginLeft = "0", t.style.marginRight = "auto", $();
885
+ t.style.display = "block", t.style.marginLeft = "0", t.style.marginRight = "auto", C();
865
886
  }), (b = l.querySelector(".btn-align-center")) == null || b.addEventListener("click", () => {
866
- t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "auto", $();
867
- }), (p = l.querySelector(".btn-align-right")) == null || p.addEventListener("click", () => {
868
- t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "0", $();
869
- }), (g = l.querySelector(".btn-alt")) == null || g.addEventListener("click", () => {
870
- t.tagName === "IMG" && Z(t);
871
- }), (f = l.querySelector(".btn-link")) == null || f.addEventListener("click", () => {
872
- K(t);
873
- }), (y = l.querySelector(".btn-replace")) == null || y.addEventListener("click", () => {
887
+ t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "auto", C();
888
+ }), (m = l.querySelector(".btn-align-right")) == null || m.addEventListener("click", () => {
889
+ t.style.display = "block", t.style.marginLeft = "auto", t.style.marginRight = "0", C();
890
+ }), (f = l.querySelector(".btn-alt")) == null || f.addEventListener("click", () => {
874
891
  t.tagName === "IMG" && J(t);
875
- }), (k = l.querySelector(".btn-resize")) == null || k.addEventListener("click", () => {
876
- const d = prompt("Enter width in pixels:", String(t.width || t.offsetWidth));
877
- if (d && !isNaN(parseInt(d))) {
878
- const i = parseInt(d);
879
- t.style.width = `${i}px`, t.setAttribute("width", String(i)), z(), $();
880
- }
881
- }), (h = l.querySelector(".btn-remove")) == null || h.addEventListener("click", () => {
882
- confirm("Remove this media?") && (t.remove(), l && (l._cleanup && l._cleanup(), l.remove(), l = null), c = null, z());
892
+ }), (y = l.querySelector(".btn-link")) == null || y.addEventListener("click", () => {
893
+ Q(t);
894
+ }), (w = l.querySelector(".btn-replace")) == null || w.addEventListener("click", () => {
895
+ t.tagName === "IMG" && ee(t);
896
+ }), (h = l.querySelector(".btn-resize")) == null || h.addEventListener("click", () => {
897
+ const c = prompt("Enter width in pixels:", String(t.width || t.offsetWidth));
898
+ if (c && !isNaN(parseInt(c))) {
899
+ const p = parseInt(c);
900
+ t.style.width = `${p}px`, t.setAttribute("width", String(p)), M(), C();
901
+ }
902
+ }), (x = l.querySelector(".btn-remove")) == null || x.addEventListener("click", () => {
903
+ confirm("Remove this media?") && (t.remove(), l && (l._cleanup && l._cleanup(), l.remove(), l = null), d = null, M());
883
904
  }), l._cleanup = () => {
884
- window.removeEventListener("scroll", $), window.removeEventListener("resize", $);
905
+ window.removeEventListener("scroll", C), window.removeEventListener("resize", C);
885
906
  };
886
- }, F = (t) => {
887
- A = t || null, Y(), document.addEventListener("click", (e) => {
907
+ }, O = (t) => {
908
+ R = t || null, K(), document.addEventListener("click", (e) => {
888
909
  const r = e.target;
889
910
  if (r.tagName === "IMG" || r.tagName === "VIDEO") {
890
- const o = r;
911
+ const i = r;
891
912
  let a = !1;
892
- if (A ? a = A.contains(o) : a = !!o.closest('[contenteditable="true"]'), a) {
893
- e.preventDefault(), e.stopPropagation(), c = o, c.style.display = "block", B(o), z();
913
+ if (R ? a = R.contains(i) : a = !!i.closest('[contenteditable="true"]'), a) {
914
+ e.preventDefault(), e.stopPropagation(), d = i, d.style.display = "block", V(i), M();
894
915
  return;
895
916
  }
896
917
  }
897
918
  if (!r.closest(".btn-link, .btn-resize, .btn-remove") && l && !r.closest("button")) {
898
- if (l._cleanup && l._cleanup(), l.remove(), l = null, c && c.parentElement) {
899
- const o = c.parentElement;
900
- o._originalPosition !== void 0 && (o.style.position = o._originalPosition, delete o._originalPosition);
919
+ if (l._cleanup && l._cleanup(), l.remove(), l = null, d && d.parentElement) {
920
+ const i = d.parentElement;
921
+ i._originalPosition !== void 0 && (i.style.position = i._originalPosition, delete i._originalPosition);
901
922
  }
902
- c = null, z();
923
+ d = null, M();
903
924
  }
904
925
  }), _.forEach((e) => {
905
926
  e.addEventListener("mousedown", (r) => {
906
- if (!c) return;
907
- r.preventDefault(), r.stopPropagation(), D = !0, T = e.getAttribute("data-position"), V = r.clientX, P = r.clientY;
908
- const o = c.getBoundingClientRect();
909
- q = o.width, C = o.height, N = q / C, document.body.style.userSelect = "none", document.body.style.cursor = `${T}-resize`;
927
+ if (!d) return;
928
+ r.preventDefault(), r.stopPropagation(), H = !0, A = e.getAttribute("data-position"), U = r.clientX, j = r.clientY;
929
+ const i = d.getBoundingClientRect();
930
+ q = i.width, z = i.height, P = q / z, document.body.style.userSelect = "none", document.body.style.cursor = `${A}-resize`;
910
931
  });
911
932
  }), document.addEventListener("mousemove", (e) => {
912
- if (!D || !c || !T) return;
913
- const r = e.clientX - V, o = e.clientY - P;
914
- let a = q, n = C;
915
- switch (T) {
933
+ if (!H || !d || !A) return;
934
+ const r = e.clientX - U, i = e.clientY - j;
935
+ let a = q, n = z;
936
+ switch (A) {
916
937
  case "se":
917
- a = q + r, n = C + o;
938
+ a = q + r, n = z + i;
918
939
  break;
919
940
  case "sw":
920
- a = q - r, n = C + o;
941
+ a = q - r, n = z + i;
921
942
  break;
922
943
  case "ne":
923
- a = q + r, n = C - o;
944
+ a = q + r, n = z - i;
924
945
  break;
925
946
  case "nw":
926
- a = q - r, n = C - o;
947
+ a = q - r, n = z - i;
927
948
  break;
928
949
  }
929
- Math.abs(r) > Math.abs(o) ? n = a / N : a = n * N, a = Math.max(50, a), n = Math.max(50, n), c.style.width = `${a}px`, c.style.height = `${n}px`, c.setAttribute("width", String(Math.round(a))), c.setAttribute("height", String(Math.round(n))), z(), $();
950
+ Math.abs(r) > Math.abs(i) ? n = a / P : a = n * P, a = Math.max(50, a), n = Math.max(50, n), d.style.width = `${a}px`, d.style.height = `${n}px`, d.setAttribute("width", String(Math.round(a))), d.setAttribute("height", String(Math.round(n))), M(), C();
930
951
  }), document.addEventListener("mouseup", () => {
931
- D && (D = !1, T = null, document.body.style.userSelect = "", document.body.style.cursor = "");
932
- }), window.addEventListener("scroll", z), window.addEventListener("resize", z);
952
+ H && (H = !1, A = null, document.body.style.userSelect = "", document.body.style.cursor = "");
953
+ }), window.addEventListener("scroll", M), window.addEventListener("resize", M);
933
954
  };
934
- typeof window != "undefined" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, F());
935
- const Q = () => ({
955
+ typeof window != "undefined" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, O());
956
+ const te = () => ({
936
957
  name: "image",
937
958
  initialize: (t) => {
938
959
  const e = t == null ? void 0 : t.editorElement;
939
- F(e);
960
+ O(e);
940
961
  },
941
962
  toolbar: [
942
963
  {
@@ -953,11 +974,11 @@ const Q = () => ({
953
974
  commands: {
954
975
  insertImage: (t, e) => {
955
976
  const r = (e == null ? void 0 : e.contentElement) instanceof HTMLElement ? e.contentElement : void 0;
956
- return U("image", r), !0;
977
+ return W("image", r), !0;
957
978
  },
958
979
  insertVideo: (t, e) => {
959
980
  const r = (e == null ? void 0 : e.contentElement) instanceof HTMLElement ? e.contentElement : void 0;
960
- return U("video", r), !0;
981
+ return W("video", r), !0;
961
982
  }
962
983
  },
963
984
  keymap: {
@@ -965,6 +986,6 @@ const Q = () => ({
965
986
  }
966
987
  });
967
988
  export {
968
- Q as MediaManagerPlugin
989
+ te as MediaManagerPlugin
969
990
  };
970
- //# sourceMappingURL=MediaManagerPlugin.native-CgP5iInD.mjs.map
991
+ //# sourceMappingURL=MediaManagerPlugin.native-BiXiK8FC.mjs.map