@editora/plugins 1.0.9 → 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.
@@ -1,8 +1,8 @@
1
1
  import "./shared-config.esm.js";
2
- let A = null, s = null, l = null, R = [], D = !1, I = null, V = 0, j = 0, $ = 0, C = 0, N = 1, T = null;
2
+ let A = null, p = null, s = null, R = [], D = !1, I = null, V = 0, j = 0, $ = 0, C = 0, N = 1, T = null;
3
3
  const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
4
- const r = (i) => {
5
- i.key !== "Escape" || !e.isConnected || (i.preventDefault(), i.stopPropagation(), t());
4
+ const r = (a) => {
5
+ a.key !== "Escape" || !e.isConnected || (a.preventDefault(), a.stopPropagation(), t());
6
6
  };
7
7
  return document.addEventListener("keydown", r, !0), () => {
8
8
  document.removeEventListener("keydown", r, !0);
@@ -462,10 +462,10 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
462
462
  }, F = (e, t) => {
463
463
  const r = window.getSelection();
464
464
  r && r.rangeCount > 0 && (A = r.getRangeAt(0).cloneRange());
465
- const i = _(t), a = H();
466
- let o = "upload", d = "", c = "", p = "", g = "";
465
+ const a = _(t), i = H();
466
+ let o = "upload", d = "", l = "", c = "", g = "";
467
467
  const v = () => {
468
- a.innerHTML = `
468
+ i.innerHTML = `
469
469
  <div class="rte-media-header">
470
470
  <h2 class="rte-media-title">Insert ${e === "image" ? "Image" : "Video"}</h2>
471
471
  <button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
@@ -508,11 +508,11 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
508
508
  <div class="rte-media-grid">
509
509
  <div class="rte-media-field">
510
510
  <label class="rte-media-label">Width (px)</label>
511
- <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${c}">
511
+ <input type="number" id="width-input" class="rte-media-input" placeholder="Auto" value="${l}">
512
512
  </div>
513
513
  <div class="rte-media-field">
514
514
  <label class="rte-media-label">Height (px)</label>
515
- <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${p}">
515
+ <input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${c}">
516
516
  </div>
517
517
  </div>
518
518
  ${d ? `
@@ -533,19 +533,19 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
533
533
  </div>
534
534
  `;
535
535
  };
536
- v(), i.appendChild(a), document.body.appendChild(i);
536
+ v(), a.appendChild(i), document.body.appendChild(a);
537
537
  let k = () => {
538
538
  };
539
539
  const h = () => {
540
- k(), i.parentNode && i.parentNode.removeChild(i);
540
+ k(), a.parentNode && a.parentNode.removeChild(a);
541
541
  };
542
- k = B(i, h);
542
+ k = B(a, h);
543
543
  const L = () => {
544
544
  if (!d) return;
545
545
  const n = e === "image" ? document.createElement("img") : document.createElement("video");
546
- n.src = d, n.setAttribute("data-media-type", e), e === "image" && g && (n.alt = g), c && (n.style.width = `${c}px`, n.setAttribute("width", c)), p && (n.style.height = `${p}px`, n.setAttribute("height", p)), e === "video" && (n.controls = !0), !c && !p ? n.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : n.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${c ? `width: ${c}px;` : "max-width: 100%;"} ${p ? `height: ${p}px;` : "height: auto;"}`, A && (A.deleteContents(), A.insertNode(n)), h();
546
+ n.src = d, n.setAttribute("data-media-type", e), e === "image" && g && (n.alt = g), l && (n.style.width = `${l}px`, n.setAttribute("width", l)), c && (n.style.height = `${c}px`, n.setAttribute("height", c)), e === "video" && (n.controls = !0), !l && !c ? n.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : n.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${l ? `width: ${l}px;` : "max-width: 100%;"} ${c ? `height: ${c}px;` : "height: auto;"}`, A && (A.deleteContents(), A.insertNode(n)), h();
547
547
  }, x = async (n) => {
548
- const b = a.querySelector("#upload-progress"), u = a.querySelector("#progress-bar"), y = a.querySelector("#progress-text");
548
+ const b = i.querySelector("#upload-progress"), u = i.querySelector("#progress-bar"), y = i.querySelector("#progress-text");
549
549
  if (b && u && y) {
550
550
  b.style.display = "block";
551
551
  let M = 0;
@@ -564,13 +564,13 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
564
564
  }
565
565
  }
566
566
  }, m = () => {
567
- const n = a.querySelector(".close-btn"), b = a.querySelector(".cancel-btn"), u = a.querySelector("#insert-btn"), y = a.querySelector(".tab-upload"), M = a.querySelector(".tab-url");
567
+ const n = i.querySelector(".close-btn"), b = i.querySelector(".cancel-btn"), u = i.querySelector("#insert-btn"), y = i.querySelector(".tab-upload"), M = i.querySelector(".tab-url");
568
568
  if (n?.addEventListener("click", h), b?.addEventListener("click", h), u?.addEventListener("click", L), y?.addEventListener("click", () => {
569
569
  o = "upload", v(), m();
570
570
  }), M?.addEventListener("click", () => {
571
571
  o = "url", v(), m();
572
572
  }), o === "upload") {
573
- const f = a.querySelector(".dropzone"), w = a.querySelector("#file-input");
573
+ const f = i.querySelector(".dropzone"), w = i.querySelector("#file-input");
574
574
  f?.addEventListener("click", () => w?.click()), f?.addEventListener("dragover", (S) => {
575
575
  S.preventDefault(), f.classList.add("is-dragover");
576
576
  }), f?.addEventListener("dragleave", () => {
@@ -585,20 +585,20 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
585
585
  });
586
586
  }
587
587
  if (o === "url") {
588
- const f = a.querySelector("#url-input"), w = a.querySelector("#alt-input"), S = a.querySelector("#width-input"), z = a.querySelector("#height-input");
588
+ const f = i.querySelector("#url-input"), w = i.querySelector("#alt-input"), S = i.querySelector("#width-input"), z = i.querySelector("#height-input");
589
589
  f?.addEventListener("input", () => {
590
590
  d = f.value, v(), m();
591
591
  }), w?.addEventListener("input", () => {
592
592
  g = w.value;
593
593
  }), S?.addEventListener("input", () => {
594
- c = S.value;
594
+ l = S.value;
595
595
  }), z?.addEventListener("input", () => {
596
- p = z.value;
596
+ c = z.value;
597
597
  });
598
598
  }
599
599
  };
600
- m(), i.addEventListener("click", (n) => {
601
- n.target === i && h();
600
+ m(), a.addEventListener("click", (n) => {
601
+ n.target === a && h();
602
602
  });
603
603
  }, K = () => {
604
604
  ["nw", "ne", "sw", "se"].forEach((t) => {
@@ -617,19 +617,19 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
617
617
  `, r.setAttribute("data-position", t), document.body.appendChild(r), R.push(r);
618
618
  });
619
619
  }, q = () => {
620
- if (!s) {
620
+ if (!p) {
621
621
  R.forEach((r) => r.style.display = "none");
622
622
  return;
623
623
  }
624
- const e = s.getBoundingClientRect(), t = {
624
+ const e = p.getBoundingClientRect(), t = {
625
625
  nw: { x: e.left - 5, y: e.top - 5 },
626
626
  ne: { x: e.right - 5, y: e.top - 5 },
627
627
  sw: { x: e.left - 5, y: e.bottom - 5 },
628
628
  se: { x: e.right - 5, y: e.bottom - 5 }
629
629
  };
630
630
  R.forEach((r) => {
631
- const i = r.getAttribute("data-position"), a = t[i];
632
- r.style.left = `${a.x}px`, r.style.top = `${a.y}px`, r.style.display = "block";
631
+ const a = r.getAttribute("data-position"), i = t[a];
632
+ r.style.left = `${i.x}px`, r.style.top = `${i.y}px`, r.style.display = "block";
633
633
  });
634
634
  }, J = (e) => {
635
635
  const t = _(e), r = H(!0);
@@ -648,19 +648,19 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
648
648
  <button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
649
649
  </div>
650
650
  `, t.appendChild(r), document.body.appendChild(t);
651
- const i = r.querySelector("#alt-text-input"), a = r.querySelector(".close-btn"), o = r.querySelector(".cancel-btn"), d = r.querySelector(".save-btn");
652
- let c = () => {
651
+ const a = r.querySelector("#alt-text-input"), i = r.querySelector(".close-btn"), o = r.querySelector(".cancel-btn"), d = r.querySelector(".save-btn");
652
+ let l = () => {
653
653
  };
654
- const p = () => {
655
- c(), t.parentNode && t.parentNode.removeChild(t);
654
+ const c = () => {
655
+ l(), t.parentNode && t.parentNode.removeChild(t);
656
656
  };
657
- c = B(t, p), a.addEventListener("click", p), o.addEventListener("click", p), t.addEventListener("click", (g) => {
658
- g.target === t && p();
657
+ l = B(t, c), i.addEventListener("click", c), o.addEventListener("click", c), t.addEventListener("click", (g) => {
658
+ g.target === t && c();
659
659
  }), d.addEventListener("click", () => {
660
- e.alt = i.value, p();
661
- }), i.focus(), i.select();
660
+ e.alt = a.value, c();
661
+ }), a.focus(), a.select();
662
662
  }, Q = (e) => {
663
- const t = e.closest("a"), r = t?.getAttribute("href") || "", i = t?.getAttribute("target") || "_self", a = t?.getAttribute("title") || "", o = _(e), d = H(!0);
663
+ const t = e.closest("a"), r = t?.getAttribute("href") || "", a = t?.getAttribute("target") || "_self", i = t?.getAttribute("title") || "", o = _(e), d = H(!0);
664
664
  d.innerHTML = `
665
665
  <div class="rte-media-header">
666
666
  <h2 class="rte-media-title">${t ? "Edit Link" : "Add Link"}</h2>
@@ -673,10 +673,10 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
673
673
  </div>
674
674
  <div class="rte-media-field">
675
675
  <label class="rte-media-label">Title (tooltip)</label>
676
- <input id="link-title" type="text" class="rte-media-input" value="${a}" placeholder="Optional tooltip text" />
676
+ <input id="link-title" type="text" class="rte-media-input" value="${i}" placeholder="Optional tooltip text" />
677
677
  </div>
678
678
  <label class="rte-media-checkbox-label">
679
- <input id="link-target" type="checkbox" ${i === "_blank" ? "checked" : ""} />
679
+ <input id="link-target" type="checkbox" ${a === "_blank" ? "checked" : ""} />
680
680
  Open in new window/tab
681
681
  </label>
682
682
  </div>
@@ -688,7 +688,7 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
688
688
  </div>
689
689
  </div>
690
690
  `, o.appendChild(d), document.body.appendChild(o);
691
- const c = d.querySelector("#link-url"), p = d.querySelector("#link-title"), g = d.querySelector("#link-target"), v = d.querySelector(".close-btn"), k = d.querySelector(".cancel-btn"), h = d.querySelector(".save-btn"), L = d.querySelector(".remove-link-btn");
691
+ const l = d.querySelector("#link-url"), c = d.querySelector("#link-title"), g = d.querySelector("#link-target"), v = d.querySelector(".close-btn"), k = d.querySelector(".cancel-btn"), h = d.querySelector(".save-btn"), L = d.querySelector(".remove-link-btn");
692
692
  let x = () => {
693
693
  };
694
694
  const m = () => {
@@ -697,23 +697,23 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
697
697
  x = B(o, m), v.addEventListener("click", m), k.addEventListener("click", m), o.addEventListener("click", (n) => {
698
698
  n.target === o && m();
699
699
  }), h.addEventListener("click", () => {
700
- const n = c.value.trim();
700
+ const n = l.value.trim();
701
701
  if (n) {
702
702
  const b = n.startsWith("http") ? n : `https://${n}`;
703
703
  if (t)
704
- t.setAttribute("href", b), t.setAttribute("target", g.checked ? "_blank" : "_self"), g.checked ? t.setAttribute("rel", "noopener noreferrer") : t.removeAttribute("rel"), p.value.trim() ? t.setAttribute("title", p.value.trim()) : t.removeAttribute("title");
704
+ t.setAttribute("href", b), t.setAttribute("target", g.checked ? "_blank" : "_self"), g.checked ? t.setAttribute("rel", "noopener noreferrer") : t.removeAttribute("rel"), c.value.trim() ? t.setAttribute("title", c.value.trim()) : t.removeAttribute("title");
705
705
  else {
706
706
  const u = document.createElement("a");
707
- u.href = b, u.target = g.checked ? "_blank" : "_self", g.checked && (u.rel = "noopener noreferrer"), p.value.trim() && (u.title = p.value.trim()), e.replaceWith(u), u.appendChild(e);
707
+ u.href = b, u.target = g.checked ? "_blank" : "_self", g.checked && (u.rel = "noopener noreferrer"), c.value.trim() && (u.title = c.value.trim()), e.replaceWith(u), u.appendChild(e);
708
708
  }
709
- m(), l && s && U(s);
709
+ m(), s && p && U(p);
710
710
  }
711
711
  }), L?.addEventListener("click", () => {
712
- t && confirm("Remove link from this media?") && (t.replaceWith(e), m(), l && s && U(s));
713
- }), c.focus();
712
+ t && confirm("Remove link from this media?") && (t.replaceWith(e), m(), s && p && U(p));
713
+ }), l.focus();
714
714
  }, ee = (e) => {
715
715
  const t = _(e), r = H();
716
- let i = "url", a = e.src;
716
+ let a = "url", i = e.src;
717
717
  const o = () => {
718
718
  r.innerHTML = `
719
719
  <div class="rte-media-header">
@@ -722,12 +722,12 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
722
722
  </div>
723
723
 
724
724
  <div class="rte-media-tabs">
725
- <button class="tab-upload rte-media-tab ${i === "upload" ? "active" : ""}" type="button">Upload</button>
726
- <button class="tab-url rte-media-tab ${i === "url" ? "active" : ""}" type="button">URL</button>
725
+ <button class="tab-upload rte-media-tab ${a === "upload" ? "active" : ""}" type="button">Upload</button>
726
+ <button class="tab-url rte-media-tab ${a === "url" ? "active" : ""}" type="button">URL</button>
727
727
  </div>
728
728
 
729
729
  <div class="rte-media-body">
730
- ${i === "upload" ? `
730
+ ${a === "upload" ? `
731
731
  <div id="upload-section">
732
732
  <div class="dropzone rte-media-dropzone">
733
733
  <div class="rte-media-dropzone-icon">📁</div>
@@ -746,13 +746,13 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
746
746
  <div id="url-section">
747
747
  <div class="rte-media-field">
748
748
  <label class="rte-media-label">Image URL</label>
749
- <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${a}">
749
+ <input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/image.jpg" value="${i}">
750
750
  </div>
751
- ${a ? `
751
+ ${i ? `
752
752
  <div class="rte-media-field">
753
753
  <label class="rte-media-label">Preview</label>
754
754
  <div class="rte-media-preview">
755
- <img src="${a}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
755
+ <img src="${i}" alt="Preview" onerror="this.parentElement.innerHTML='<p class=&quot;rte-media-muted&quot;>Failed to load image</p>'">
756
756
  </div>
757
757
  </div>
758
758
  ` : ""}
@@ -762,19 +762,19 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
762
762
 
763
763
  <div class="rte-media-footer">
764
764
  <button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
765
- <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!a && i === "url" ? "disabled" : ""}>Replace</button>
765
+ <button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!i && a === "url" ? "disabled" : ""}>Replace</button>
766
766
  </div>
767
767
  `;
768
768
  };
769
769
  o(), t.appendChild(r), document.body.appendChild(t);
770
770
  let d = () => {
771
771
  };
772
- const c = () => {
772
+ const l = () => {
773
773
  d(), t.parentNode && t.parentNode.removeChild(t);
774
774
  };
775
- d = B(t, c);
776
- const p = () => {
777
- a && (e.src = a, c());
775
+ d = B(t, l);
776
+ const c = () => {
777
+ i && (e.src = i, l());
778
778
  }, g = async (k) => {
779
779
  const h = r.querySelector("#upload-progress"), L = r.querySelector("#progress-bar"), x = r.querySelector("#progress-text");
780
780
  if (h && L && x) {
@@ -787,7 +787,7 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
787
787
  const b = new FileReader();
788
788
  b.onload = () => {
789
789
  clearInterval(n), L.style.width = "100%", x.textContent = "Upload complete", setTimeout(() => {
790
- a = b.result, i = "url", o(), v();
790
+ i = b.result, a = "url", o(), v();
791
791
  }, 500);
792
792
  }, b.readAsDataURL(k);
793
793
  } catch {
@@ -796,11 +796,11 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
796
796
  }
797
797
  }, v = () => {
798
798
  const k = r.querySelector(".close-btn"), h = r.querySelector(".cancel-btn"), L = r.querySelector("#replace-btn"), x = r.querySelector(".tab-upload"), m = r.querySelector(".tab-url");
799
- if (k?.addEventListener("click", c), h?.addEventListener("click", c), L?.addEventListener("click", p), x?.addEventListener("click", () => {
800
- i = "upload", o(), v();
799
+ if (k?.addEventListener("click", l), h?.addEventListener("click", l), L?.addEventListener("click", c), x?.addEventListener("click", () => {
800
+ a = "upload", o(), v();
801
801
  }), m?.addEventListener("click", () => {
802
- i = "url", o(), v();
803
- }), i === "upload") {
802
+ a = "url", o(), v();
803
+ }), a === "upload") {
804
804
  const n = r.querySelector(".dropzone"), b = r.querySelector("#file-input");
805
805
  n?.addEventListener("click", () => b?.click()), n?.addEventListener("dragover", (u) => {
806
806
  u.preventDefault(), n.classList.add("is-dragover");
@@ -815,31 +815,33 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
815
815
  y && g(y);
816
816
  });
817
817
  }
818
- if (i === "url") {
818
+ if (a === "url") {
819
819
  const n = r.querySelector("#url-input");
820
820
  n?.addEventListener("input", () => {
821
- a = n.value, o(), v();
821
+ i = n.value, o(), v();
822
822
  });
823
823
  }
824
824
  };
825
825
  v(), t.addEventListener("click", (k) => {
826
- k.target === t && c();
826
+ k.target === t && l();
827
827
  });
828
828
  }, E = () => {
829
- if (!l || !s) return;
830
- const e = l.offsetHeight || 40, t = s.offsetTop, r = s.offsetLeft, i = s.offsetWidth, a = t - e - 8, o = r + i / 2 - (l.offsetWidth || 120) / 2;
831
- l.style.top = `${a}px`, l.style.left = `${o}px`, setTimeout(() => {
832
- l && (l.style.display = "flex");
829
+ if (!s || !p) return;
830
+ const e = s.offsetHeight || 40, t = p.offsetTop, r = p.offsetLeft, a = p.offsetWidth, i = t - e - 8, o = r + a / 2 - (s.offsetWidth || 120) / 2;
831
+ s.style.top = `${i}px`, s.style.left = `${o}px`, setTimeout(() => {
832
+ s && (s.style.display = "flex");
833
833
  }, 100);
834
834
  }, U = (e) => {
835
- l && (l._cleanup && l._cleanup(), l.remove());
835
+ s && (s._cleanup && s._cleanup(), s.remove());
836
836
  const t = e.parentElement;
837
837
  if (t) {
838
- const d = t.style.position;
839
- (!d || d === "static") && (t.style.position = "relative", t._originalPosition = d), l = document.createElement("div"), l.className = "media-floating-toolbar", G(e) && l.classList.add("rte-ui-theme-dark"), t.insertBefore(l, t.firstChild), E();
838
+ const l = t.style.position;
839
+ (!l || l === "static") && (t.style.position = "relative", t._originalPosition = l), s = document.createElement("div"), s.className = "media-floating-toolbar", G(e) && s.classList.add("rte-ui-theme-dark"), t.insertBefore(s, t.firstChild), E();
840
840
  }
841
- const r = e.tagName === "IMG", i = e.closest("a");
842
- l.innerHTML = `
841
+ const r = s;
842
+ if (!r) return;
843
+ const a = e.tagName === "IMG", i = e.closest("a");
844
+ r.innerHTML = `
843
845
  <button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
844
846
  <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>
845
847
  </button>
@@ -850,14 +852,14 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
850
852
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="21" y1="10" x2="7" 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="21" y1="18" x2="7" y2="18"></line></svg>
851
853
  </button>
852
854
  <div class="media-floating-toolbar-separator" aria-hidden="true"></div>
853
- ${r ? `
855
+ ${a ? `
854
856
  <button class="media-floating-toolbar-btn btn-alt" title="Edit Alt Text" type="button">
855
857
  <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>
856
858
  </button>` : ""}
857
859
  <button class="media-floating-toolbar-btn btn-link" title="${i ? "Edit/Remove Link" : "Add Link"}" type="button">
858
860
  <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>
859
861
  </button>
860
- ${r ? `
862
+ ${a ? `
861
863
  <button class="media-floating-toolbar-btn btn-replace" title="Replace Image" type="button">
862
864
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
863
865
  </button>` : ""}
@@ -868,82 +870,82 @@ const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
868
870
  `, setTimeout(() => {
869
871
  E();
870
872
  }, 0);
871
- const a = () => E();
872
- let o = s.parentElement;
873
- for (; o; )
874
- o.addEventListener("scroll", a), o = o.parentElement;
875
- window.addEventListener("scroll", a), window.addEventListener("resize", a), l._cleanup = () => {
876
- let d = s?.parentElement;
877
- for (; d; )
878
- d.removeEventListener("scroll", a), d = d.parentElement;
879
- window.removeEventListener("scroll", a), window.removeEventListener("resize", a);
880
- }, l.querySelector(".btn-align-left")?.addEventListener("click", () => {
873
+ const o = () => E();
874
+ let d = e.parentElement;
875
+ for (; d; )
876
+ d.addEventListener("scroll", o), d = d.parentElement;
877
+ window.addEventListener("scroll", o), window.addEventListener("resize", o), r._cleanup = () => {
878
+ let l = e.parentElement;
879
+ for (; l; )
880
+ l.removeEventListener("scroll", o), l = l.parentElement;
881
+ window.removeEventListener("scroll", o), window.removeEventListener("resize", o);
882
+ }, r.querySelector(".btn-align-left")?.addEventListener("click", () => {
881
883
  e.style.display = "block", e.style.marginLeft = "0", e.style.marginRight = "auto", E();
882
- }), l.querySelector(".btn-align-center")?.addEventListener("click", () => {
884
+ }), r.querySelector(".btn-align-center")?.addEventListener("click", () => {
883
885
  e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "auto", E();
884
- }), l.querySelector(".btn-align-right")?.addEventListener("click", () => {
886
+ }), r.querySelector(".btn-align-right")?.addEventListener("click", () => {
885
887
  e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "0", E();
886
- }), l.querySelector(".btn-alt")?.addEventListener("click", () => {
888
+ }), r.querySelector(".btn-alt")?.addEventListener("click", () => {
887
889
  e.tagName === "IMG" && J(e);
888
- }), l.querySelector(".btn-link")?.addEventListener("click", () => {
890
+ }), r.querySelector(".btn-link")?.addEventListener("click", () => {
889
891
  Q(e);
890
- }), l.querySelector(".btn-replace")?.addEventListener("click", () => {
892
+ }), r.querySelector(".btn-replace")?.addEventListener("click", () => {
891
893
  e.tagName === "IMG" && ee(e);
892
- }), l.querySelector(".btn-resize")?.addEventListener("click", () => {
893
- const d = prompt("Enter width in pixels:", String(e.width || e.offsetWidth));
894
- if (d && !isNaN(parseInt(d))) {
895
- const c = parseInt(d);
894
+ }), r.querySelector(".btn-resize")?.addEventListener("click", () => {
895
+ const l = prompt("Enter width in pixels:", String(e.width || e.offsetWidth));
896
+ if (l && !isNaN(parseInt(l))) {
897
+ const c = parseInt(l);
896
898
  e.style.width = `${c}px`, e.setAttribute("width", String(c)), q(), E();
897
899
  }
898
- }), l.querySelector(".btn-remove")?.addEventListener("click", () => {
899
- confirm("Remove this media?") && (e.remove(), l && (l._cleanup && l._cleanup(), l.remove(), l = null), s = null, q());
900
- }), l._cleanup = () => {
900
+ }), r.querySelector(".btn-remove")?.addEventListener("click", () => {
901
+ confirm("Remove this media?") && (e.remove(), s && (s._cleanup && s._cleanup(), s.remove(), s = null), p = null, q());
902
+ }), r._cleanup = () => {
901
903
  window.removeEventListener("scroll", E), window.removeEventListener("resize", E);
902
904
  };
903
905
  }, O = (e) => {
904
906
  T = e || null, K(), document.addEventListener("click", (t) => {
905
907
  const r = t.target;
906
908
  if (r.tagName === "IMG" || r.tagName === "VIDEO") {
907
- const i = r;
908
- let a = !1;
909
- if (T ? a = T.contains(i) : a = !!i.closest('[contenteditable="true"]'), a) {
910
- t.preventDefault(), t.stopPropagation(), s = i, s.style.display = "block", U(i), q();
909
+ const a = r;
910
+ let i = !1;
911
+ if (T ? i = T.contains(a) : i = !!a.closest('[contenteditable="true"]'), i) {
912
+ t.preventDefault(), t.stopPropagation(), p = a, p.style.display = "block", U(a), q();
911
913
  return;
912
914
  }
913
915
  }
914
- if (!r.closest(".btn-link, .btn-resize, .btn-remove") && l && !r.closest("button")) {
915
- if (l._cleanup && l._cleanup(), l.remove(), l = null, s && s.parentElement) {
916
- const i = s.parentElement;
917
- i._originalPosition !== void 0 && (i.style.position = i._originalPosition, delete i._originalPosition);
916
+ if (!r.closest(".btn-link, .btn-resize, .btn-remove") && s && !r.closest("button")) {
917
+ if (s._cleanup && s._cleanup(), s.remove(), s = null, p && p.parentElement) {
918
+ const a = p.parentElement;
919
+ a._originalPosition !== void 0 && (a.style.position = a._originalPosition, delete a._originalPosition);
918
920
  }
919
- s = null, q();
921
+ p = null, q();
920
922
  }
921
923
  }), R.forEach((t) => {
922
924
  t.addEventListener("mousedown", (r) => {
923
- if (!s) return;
925
+ if (!p) return;
924
926
  r.preventDefault(), r.stopPropagation(), D = !0, I = t.getAttribute("data-position"), V = r.clientX, j = r.clientY;
925
- const i = s.getBoundingClientRect();
926
- $ = i.width, C = i.height, N = $ / C, document.body.style.userSelect = "none", document.body.style.cursor = `${I}-resize`;
927
+ const a = p.getBoundingClientRect();
928
+ $ = a.width, C = a.height, N = $ / C, document.body.style.userSelect = "none", document.body.style.cursor = `${I}-resize`;
927
929
  });
928
930
  }), document.addEventListener("mousemove", (t) => {
929
- if (!D || !s || !I) return;
930
- const r = t.clientX - V, i = t.clientY - j;
931
- let a = $, o = C;
931
+ if (!D || !p || !I) return;
932
+ const r = t.clientX - V, a = t.clientY - j;
933
+ let i = $, o = C;
932
934
  switch (I) {
933
935
  case "se":
934
- a = $ + r, o = C + i;
936
+ i = $ + r, o = C + a;
935
937
  break;
936
938
  case "sw":
937
- a = $ - r, o = C + i;
939
+ i = $ - r, o = C + a;
938
940
  break;
939
941
  case "ne":
940
- a = $ + r, o = C - i;
942
+ i = $ + r, o = C - a;
941
943
  break;
942
944
  case "nw":
943
- a = $ - r, o = C - i;
945
+ i = $ - r, o = C - a;
944
946
  break;
945
947
  }
946
- Math.abs(r) > Math.abs(i) ? o = a / N : a = o * N, a = Math.max(50, a), o = Math.max(50, o), s.style.width = `${a}px`, s.style.height = `${o}px`, s.setAttribute("width", String(Math.round(a))), s.setAttribute("height", String(Math.round(o))), q(), E();
948
+ Math.abs(r) > Math.abs(a) ? o = i / N : i = o * N, i = Math.max(50, i), o = Math.max(50, o), p.style.width = `${i}px`, p.style.height = `${o}px`, p.setAttribute("width", String(Math.round(i))), p.setAttribute("height", String(Math.round(o))), q(), E();
947
949
  }), document.addEventListener("mouseup", () => {
948
950
  D && (D = !1, I = null, document.body.style.userSelect = "", document.body.style.cursor = "");
949
951
  }), window.addEventListener("scroll", q), window.addEventListener("resize", q);
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function H(e,t){const r=Array.from({length:t}).map(()=>"<th><p><br></p></th>").join(""),n=Array.from({length:e}).map(()=>`<tr>${Array.from({length:t}).map(()=>"<td><p><br></p></td>").join("")}</tr>`).join("");return`<table class="rte-table"><thead><tr>${r}</tr></thead><tbody>${n}</tbody></table><p><br></p>`}function q(){return[{id:"paragraph",label:"Paragraph",description:"Switch to paragraph text",command:"paragraph",keywords:["text","normal","p"]},{id:"h1",label:"Heading 1",description:"Large section heading",command:"heading1",keywords:["title","header","h1"]},{id:"h2",label:"Heading 2",description:"Medium section heading",command:"heading2",keywords:["subtitle","header","h2"]},{id:"h3",label:"Heading 3",description:"Small section heading",command:"heading3",keywords:["header","h3"]},{id:"bulleted-list",label:"Bulleted List",description:"Create a bullet list",command:"toggleBulletList",keywords:["list","ul","bullet"]},{id:"numbered-list",label:"Numbered List",description:"Create a numbered list",command:"toggleOrderedList",keywords:["list","ol","numbered"]},{id:"blockquote",label:"Blockquote",description:"Insert a quote block",command:"toggleBlockquote",keywords:["quote","citation"]},{id:"table-3x3",label:"Table 3x3",description:"Insert a 3 x 3 table",action:({insertHTML:e})=>e(H(3,3)),keywords:["table","grid","rows","columns"]},{id:"horizontal-rule",label:"Divider",description:"Insert a horizontal rule",command:"insertHorizontalRule",keywords:["hr","separator","line"]},{id:"bold",label:"Bold",description:"Toggle bold formatting",command:"toggleBold",keywords:["strong","b"]},{id:"italic",label:"Italic",description:"Toggle italic formatting",command:"toggleItalic",keywords:["emphasis","i"]},{id:"underline",label:"Underline",description:"Toggle underline formatting",command:"toggleUnderline",keywords:["u"]},{id:"strikethrough",label:"Strikethrough",description:"Toggle strikethrough formatting",command:"toggleStrikethrough",keywords:["strike","s"]},{id:"clear-formatting",label:"Clear Formatting",description:"Remove text formatting",command:"clearFormatting",keywords:["reset","plain"]}]}function $(e){const t=[],r=new Set;return e.forEach(n=>{const o=String(n.id||"").trim(),i=String(n.label||"").trim();!o||!i||r.has(o)||(r.add(o),t.push({...n,id:o,label:i,description:n.description?String(n.description):void 0,keywords:Array.isArray(n.keywords)?n.keywords.map(a=>String(a)).filter(Boolean):void 0}))}),t}function D(e){const t=(e.triggerChar||"/")[0]||"/",r=e.includeDefaultItems!==!1,n=r?[...e.items||[],...q()]:e.items||[];return{triggerChar:t,minChars:Math.max(0,e.minChars??0),maxQueryLength:Math.max(1,e.maxQueryLength??48),maxSuggestions:Math.max(1,e.maxSuggestions??10),requireBoundary:e.requireBoundary!==!1,includeDefaultItems:r,items:$(n),itemRenderer:e.itemRenderer,emptyStateText:e.emptyStateText||"No commands found",panelLabel:e.panelLabel||"Slash commands"}}const u='[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark';let E=!1;function B(){if(E||typeof document>"u")return;E=!0;const e=document.createElement("style");e.id="rte-slash-commands-styles",e.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function H(e,t){const o=Array.from({length:t}).map(()=>"<th><p><br></p></th>").join(""),n=Array.from({length:e}).map(()=>`<tr>${Array.from({length:t}).map(()=>"<td><p><br></p></td>").join("")}</tr>`).join("");return`<table class="rte-table"><thead><tr>${o}</tr></thead><tbody>${n}</tbody></table><p><br></p>`}function q(){return[{id:"paragraph",label:"Paragraph",description:"Switch to paragraph text",command:"paragraph",keywords:["text","normal","p"]},{id:"h1",label:"Heading 1",description:"Large section heading",command:"heading1",keywords:["title","header","h1"]},{id:"h2",label:"Heading 2",description:"Medium section heading",command:"heading2",keywords:["subtitle","header","h2"]},{id:"h3",label:"Heading 3",description:"Small section heading",command:"heading3",keywords:["header","h3"]},{id:"bulleted-list",label:"Bulleted List",description:"Create a bullet list",command:"toggleBulletList",keywords:["list","ul","bullet"]},{id:"numbered-list",label:"Numbered List",description:"Create a numbered list",command:"toggleOrderedList",keywords:["list","ol","numbered"]},{id:"blockquote",label:"Blockquote",description:"Insert a quote block",command:"toggleBlockquote",keywords:["quote","citation"]},{id:"table-3x3",label:"Table 3x3",description:"Insert a 3 x 3 table",action:({insertHTML:e})=>e(H(3,3)),keywords:["table","grid","rows","columns"]},{id:"horizontal-rule",label:"Divider",description:"Insert a horizontal rule",command:"insertHorizontalRule",keywords:["hr","separator","line"]},{id:"bold",label:"Bold",description:"Toggle bold formatting",command:"toggleBold",keywords:["strong","b"]},{id:"italic",label:"Italic",description:"Toggle italic formatting",command:"toggleItalic",keywords:["emphasis","i"]},{id:"underline",label:"Underline",description:"Toggle underline formatting",command:"toggleUnderline",keywords:["u"]},{id:"strikethrough",label:"Strikethrough",description:"Toggle strikethrough formatting",command:"toggleStrikethrough",keywords:["strike","s"]},{id:"clear-formatting",label:"Clear Formatting",description:"Remove text formatting",command:"clearFormatting",keywords:["reset","plain"]}]}function $(e){const t=[],o=new Set;return e.forEach(n=>{const r=String(n.id||"").trim(),i=String(n.label||"").trim();!r||!i||o.has(r)||(o.add(r),t.push({...n,id:r,label:i,description:n.description?String(n.description):void 0,keywords:Array.isArray(n.keywords)?n.keywords.map(a=>String(a)).filter(Boolean):void 0}))}),t}function D(e){const t=(e.triggerChar||"/")[0]||"/",o=e.includeDefaultItems!==!1,n=o?[...e.items||[],...q()]:e.items||[];return{triggerChar:t,minChars:Math.max(0,e.minChars??0),maxQueryLength:Math.max(1,e.maxQueryLength??48),maxSuggestions:Math.max(1,e.maxSuggestions??10),requireBoundary:e.requireBoundary!==!1,includeDefaultItems:o,items:$(n),itemRenderer:e.itemRenderer||(r=>r.label),emptyStateText:e.emptyStateText||"No commands found",panelLabel:e.panelLabel||"Slash commands"}}const u='[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark';let E=!1;function B(){if(E||typeof document>"u")return;E=!0;const e=document.createElement("style");e.id="rte-slash-commands-styles",e.textContent=`
2
2
  .rte-slash-panel {
3
3
  width: min(225px, calc(100vw - 16px));
4
4
  max-height: min(360px, calc(100vh - 24px));
@@ -84,7 +84,7 @@
84
84
  ${u} .rte-slash-empty {
85
85
  color: #9ca3af;
86
86
  }
87
- `,document.head.appendChild(e)}const s=".rte-content, .editora-content",g=new WeakMap,p=new WeakMap;let b=!1,f=null,h=0,z=0;function P(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function I(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function _(e){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const n=e.editorElement;if(n.matches(s))return n;const o=n.querySelector(s);if(o instanceof HTMLElement)return o}const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,i=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(s);if(i)return i}const r=document.activeElement;if(r){if(r.matches(s))return r;const n=r.closest(s);if(n)return n}return document.querySelector(s)}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function F(e){return e?/\s|[([{"'`]/.test(e):!0}function v(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r.cloneRange():null}function y(e,t){const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t),e.focus({preventScroll:!0}))}function j(e){if(!e.collapsed)return null;const t=e.startContainer,r=e.startOffset;if(t.nodeType===Node.TEXT_NODE){const n=t;return{node:n,textBefore:n.data.slice(0,r),caretOffset:r}}if(t.nodeType===Node.ELEMENT_NODE){const n=t;if(r>0){const o=n.childNodes[r-1];if(o&&o.nodeType===Node.TEXT_NODE){const i=o;return{node:i,textBefore:i.data,caretOffset:i.length}}}}return null}function K(e,t,r,n){const o=e.lastIndexOf(t);if(o<0||n&&!F(e[o-1]))return null;const i=e.slice(o+1);return/\s/.test(i)||i.length>r?null:{trigger:t,query:i,startOffset:o}}function Q(e,t){const r=t.cloneRange();r.collapse(!1);const n=r.getClientRects();if(n.length>0)return n[n.length-1];const o=document.createElement("span");o.textContent="​",r.insertNode(o);const i=o.getBoundingClientRect();return o.remove(),e.normalize(),i}function A(e,t){if(!e.panel)return;const r=Q(e.editor,t),n=e.panel;n.style.display="block",n.classList.add("show"),n.style.left="0px",n.style.top="0px";const o=n.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;let l=Math.max(8,Math.min(r.left,i-o.width-8)),d=r.bottom+8;d+o.height>a-8&&(d=Math.max(8,r.top-o.height-8)),n.style.position="fixed",n.style.left=`${l}px`,n.style.top=`${d}px`}function k(e,t){if(!t)return m(e);const r=e.toLowerCase(),n=t.toLowerCase(),o=r.indexOf(n);if(o<0)return m(e);const i=m(e.slice(0,o)),a=m(e.slice(o,o+t.length)),l=m(e.slice(o+t.length));return`${i}<mark>${a}</mark>${l}`}function U(e,t){if(e.panel&&e.list)return;const r=document.createElement("div");r.className="rte-slash-panel",r.style.display="none",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false");const n=document.createElement("div");n.className="rte-slash-list",n.setAttribute("role","listbox"),n.setAttribute("aria-label",t.panelLabel),r.appendChild(n),document.body.appendChild(r),e.panel=r,e.list=n,r.addEventListener("mousedown",o=>{o.preventDefault()}),r.addEventListener("click",o=>{const i=o.target;if(!i)return;const a=i.closest(".rte-slash-item");if(!a)return;const l=Number(a.getAttribute("data-index"));Number.isFinite(l)&&M(e,l)})}function c(e){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)}function W(e,t,r){if(!t)return e.slice(0,r);const n=t.toLowerCase();return e.filter(i=>[i.id,i.label,i.description||"",i.command||"",...i.keywords||[]].join(" ").toLowerCase().includes(n)).slice(0,r)}function Z(e,t){if(!e.list)return;const r=e.list;if(r.innerHTML="",e.filteredItems.length===0){const n=document.createElement("div");n.className="rte-slash-empty",n.textContent=t.emptyStateText,r.appendChild(n),r.removeAttribute("aria-activedescendant");return}e.filteredItems.forEach((n,o)=>{const i=document.createElement("button");i.type="button",i.className="rte-slash-item",i.setAttribute("role","option"),i.setAttribute("data-index",String(o)),i.setAttribute("id",`rte-slash-item-${e.instanceId}-${o}`),i.setAttribute("aria-selected",o===e.activeIndex?"true":"false"),i.setAttribute("aria-label",n.description?`${n.label} - ${n.description}`:n.label),o===e.activeIndex&&i.classList.add("active"),t.itemRenderer?i.innerHTML=t.itemRenderer(n,e.query):i.innerHTML=`
87
+ `,document.head.appendChild(e)}const s=".rte-content, .editora-content",g=new WeakMap,p=new WeakMap;let b=!1,f=null,h=0,z=0;function P(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function I(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function _(e){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const n=e.editorElement;if(n.matches(s))return n;const r=n.querySelector(s);if(r instanceof HTMLElement)return r}const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,i=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(s);if(i)return i}const o=document.activeElement;if(o){if(o.matches(s))return o;const n=o.closest(s);if(n)return n}return document.querySelector(s)}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function F(e){return e?/\s|[([{"'`]/.test(e):!0}function v(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const o=t.getRangeAt(0);return e.contains(o.commonAncestorContainer)?o.cloneRange():null}function y(e,t){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(t),e.focus({preventScroll:!0}))}function j(e){if(!e.collapsed)return null;const t=e.startContainer,o=e.startOffset;if(t.nodeType===Node.TEXT_NODE){const n=t;return{node:n,textBefore:n.data.slice(0,o),caretOffset:o}}if(t.nodeType===Node.ELEMENT_NODE){const n=t;if(o>0){const r=n.childNodes[o-1];if(r&&r.nodeType===Node.TEXT_NODE){const i=r;return{node:i,textBefore:i.data,caretOffset:i.length}}}}return null}function K(e,t,o,n){const r=e.lastIndexOf(t);if(r<0||n&&!F(e[r-1]))return null;const i=e.slice(r+1);return/\s/.test(i)||i.length>o?null:{trigger:t,query:i,startOffset:r}}function Q(e,t){const o=t.cloneRange();o.collapse(!1);const n=o.getClientRects();if(n.length>0)return n[n.length-1];const r=document.createElement("span");r.textContent="​",o.insertNode(r);const i=r.getBoundingClientRect();return r.remove(),e.normalize(),i}function A(e,t){if(!e.panel)return;const o=Q(e.editor,t),n=e.panel;n.style.display="block",n.classList.add("show"),n.style.left="0px",n.style.top="0px";const r=n.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;let l=Math.max(8,Math.min(o.left,i-r.width-8)),d=o.bottom+8;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`}function k(e,t){if(!t)return m(e);const o=e.toLowerCase(),n=t.toLowerCase(),r=o.indexOf(n);if(r<0)return m(e);const i=m(e.slice(0,r)),a=m(e.slice(r,r+t.length)),l=m(e.slice(r+t.length));return`${i}<mark>${a}</mark>${l}`}function U(e,t){if(e.panel&&e.list)return;const o=document.createElement("div");o.className="rte-slash-panel",o.style.display="none",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false");const n=document.createElement("div");n.className="rte-slash-list",n.setAttribute("role","listbox"),n.setAttribute("aria-label",t.panelLabel),o.appendChild(n),document.body.appendChild(o),e.panel=o,e.list=n,o.addEventListener("mousedown",r=>{r.preventDefault()}),o.addEventListener("click",r=>{const i=r.target;if(!i)return;const a=i.closest(".rte-slash-item");if(!a)return;const l=Number(a.getAttribute("data-index"));Number.isFinite(l)&&M(e,l)})}function c(e){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)}function W(e,t,o){if(!t)return e.slice(0,o);const n=t.toLowerCase();return e.filter(i=>[i.id,i.label,i.description||"",i.command||"",...i.keywords||[]].join(" ").toLowerCase().includes(n)).slice(0,o)}function Z(e,t){if(!e.list)return;const o=e.list;if(o.innerHTML="",e.filteredItems.length===0){const n=document.createElement("div");n.className="rte-slash-empty",n.textContent=t.emptyStateText,o.appendChild(n),o.removeAttribute("aria-activedescendant");return}e.filteredItems.forEach((n,r)=>{const i=document.createElement("button");i.type="button",i.className="rte-slash-item",i.setAttribute("role","option"),i.setAttribute("data-index",String(r)),i.setAttribute("id",`rte-slash-item-${e.instanceId}-${r}`),i.setAttribute("aria-selected",r===e.activeIndex?"true":"false"),i.setAttribute("aria-label",n.description?`${n.label} - ${n.description}`:n.label),r===e.activeIndex&&i.classList.add("active"),t.itemRenderer?i.innerHTML=t.itemRenderer(n,e.query):i.innerHTML=`
88
88
  <span class="rte-slash-item-title">${k(n.label,e.query)}</span>
89
89
  ${n.description?`<span class="rte-slash-item-description">${k(n.description,e.query)}</span>`:""}
90
- `,r.appendChild(i)}),e.filteredItems.length>0&&r.setAttribute("aria-activedescendant",`rte-slash-item-${e.instanceId}-${e.activeIndex}`)}function G(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function V(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function L(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const o=document.createElement("template");o.innerHTML=t;const i=o.content,a=i.lastChild;if(n.insertNode(i),a){const l=document.createRange();l.setStartAfter(a),l.collapse(!0),y(e,l)}return!0}function X(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const o=document.createTextNode(t);n.insertNode(o);const i=document.createRange();return i.setStart(o,o.length),i.collapse(!0),y(e,i),!0}function J(e,t){switch(e.toLowerCase()){case"paragraph":case"p":return document.execCommand("formatBlock",!1,"<p>");case"heading1":case"h1":return document.execCommand("formatBlock",!1,"<h1>");case"heading2":case"h2":return document.execCommand("formatBlock",!1,"<h2>");case"heading3":case"h3":return document.execCommand("formatBlock",!1,"<h3>");case"blockquote":case"toggleblockquote":return document.execCommand("formatBlock",!1,"<blockquote>");case"bulletlist":case"togglebulletlist":case"insertunorderedlist":return document.execCommand("insertUnorderedList");case"numberedlist":case"toggleorderedlist":case"insertorderedlist":return document.execCommand("insertOrderedList");case"horizontalrule":case"divider":case"inserthorizontalrule":return document.execCommand("insertHorizontalRule");case"bold":case"togglebold":return document.execCommand("bold");case"italic":case"toggleitalic":return document.execCommand("italic");case"underline":case"toggleunderline":return document.execCommand("underline");case"strikethrough":case"togglestrikethrough":return document.execCommand("strikeThrough");case"clearformatting":case"removeformat":return document.execCommand("removeFormat");default:try{return document.execCommand(e,!1,t)}catch{return!1}}}function S(e,t,r){const n=I(e);if(n&&typeof n.execCommand=="function")try{if(n.execCommand(t,r)!==!1)return!0}catch{}const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{if(o(t,r,{editorElement:n,contentElement:e})!==!1)return!0}catch{}return J(t,r)}async function Y(e,t){const r=e.editor,n=I(r),o={editor:r,editorRoot:n,query:e.query,trigger:e.trigger,executeCommand:(i,a)=>S(r,i,a),insertHTML:i=>L(r,i)};return t.action?await Promise.resolve(t.action(o))!==!1:t.insertHTML?L(r,t.insertHTML):t.command?S(r,t.command,t.commandValue):!1}async function M(e,t){if(t<0||t>=e.filteredItems.length||!e.replaceRange)return;const r=e.filteredItems[t],n=e.editor,o=n.innerHTML,i=`${e.trigger}${e.query}`;if(!window.getSelection())return;const l=e.replaceRange.cloneRange();if(!n.contains(l.commonAncestorContainer))return;l.deleteContents();const d=l.cloneRange();d.collapse(!0),y(n,d);let x=!1;try{x=await Y(e,r)}catch{x=!1}c(e),x?(V(n),G(n,o)):i&&X(n,i),n.focus({preventScroll:!0})}function R(e,t){if(e.filteredItems.length===0)return;const r=e.filteredItems.length;if(e.activeIndex=((e.activeIndex+t)%r+r)%r,!e.list)return;const n=Array.from(e.list.querySelectorAll(".rte-slash-item"));n.forEach((i,a)=>{const l=a===e.activeIndex;i.classList.toggle("active",l),i.setAttribute("aria-selected",l?"true":"false")});const o=n[e.activeIndex];o&&(e.list.setAttribute("aria-activedescendant",o.id),o.scrollIntoView({block:"nearest"}))}function T(e){if(!(!e.isOpen||!e.panel||!e.anchorRange)){if(!e.editor.isConnected){c(e);return}A(e,e.anchorRange)}}function N(e,t,r,n,o,i){U(e,t),e.query=n,e.trigger=o,e.replaceRange=i.cloneRange(),e.anchorRange=r.cloneRange(),e.filteredItems=W(e.items,n,t.maxSuggestions),e.activeIndex=0,e.isOpen=!0,e.panel&&(Z(e,t),A(e,r))}function ee(e,t){const r=e.editor;if(r.getAttribute("contenteditable")==="false"){c(e);return}const n=v(r);if(!n||!n.collapsed){c(e);return}const o=j(n);if(!o){c(e);return}const i=K(o.textBefore,t.triggerChar,t.maxQueryLength,t.requireBoundary);if(!i){c(e);return}if(i.query.length<t.minChars){c(e);return}const a=n.cloneRange();a.setStart(o.node,i.startOffset),a.setEnd(o.node,o.caretOffset),N(e,t,n,i.query,i.trigger,a)}function O(e,t){const r=e.editor;if(r.getAttribute("contenteditable")==="false")return!1;let n=v(r);n||(n=document.createRange(),n.selectNodeContents(r),n.collapse(!1),y(r,n));const o=n.cloneRange();return o.collapse(!0),N(e,t,n,"",t.triggerChar,o),!0}function te(e){return!(e.metaKey||e.ctrlKey)||e.altKey?!1:e.key==="/"||e.code==="Slash"}function ne(e,t){return{editor:e,panel:null,list:null,replaceRange:null,items:t.items,filteredItems:[],activeIndex:0,query:"",trigger:t.triggerChar,isOpen:!1,instanceId:++z,anchorRange:null}}function w(e,t){const r=g.get(e);if(r)return r.items=t.items,r;const n=ne(e,t);return g.set(e,n),n}function re(e){const t=g.get(e);t&&(t.panel?.parentNode&&t.panel.parentNode.removeChild(t.panel),g.delete(e))}function C(e,t,r){if(p.has(e))return;const n={input:()=>{ee(t,r)},keydown:o=>{if(t.editor.getAttribute("contenteditable")==="false"){c(t);return}if(!t.isOpen&&te(o)){o.preventDefault(),O(t,r);return}if(t.isOpen){if(o.key==="ArrowDown"){o.preventDefault(),R(t,1);return}if(o.key==="ArrowUp"){o.preventDefault(),R(t,-1);return}if(o.key==="Enter"||o.key==="Tab"){if(t.filteredItems.length===0){o.key==="Tab"&&o.preventDefault(),c(t);return}o.preventDefault(),M(t,t.activeIndex);return}if(o.key==="Escape"){o.preventDefault(),c(t);return}}},blur:()=>{window.setTimeout(()=>{const o=document.activeElement;t.panel&&o&&t.panel.contains(o)||c(t)},0)},mousedown:o=>{if(!t.isOpen||!t.panel)return;const i=o.target;i&&!t.panel.contains(i)&&!e.contains(i)&&c(t)},selectionchange:()=>{if(!t.isOpen)return;const o=v(e);if(!o||!o.collapsed){c(t);return}t.anchorRange=o.cloneRange(),T(t)},reposition:()=>{T(t)}};e.addEventListener("input",n.input),e.addEventListener("keydown",n.keydown),e.addEventListener("blur",n.blur),document.addEventListener("mousedown",n.mousedown,!0),document.addEventListener("selectionchange",n.selectionchange),window.addEventListener("resize",n.reposition,{passive:!0}),window.addEventListener("scroll",n.reposition,!0),p.set(e,n)}function oe(e){const t=p.get(e);t&&(e.removeEventListener("input",t.input),e.removeEventListener("keydown",t.keydown),e.removeEventListener("blur",t.blur),document.removeEventListener("mousedown",t.mousedown,!0),document.removeEventListener("selectionchange",t.selectionchange),window.removeEventListener("resize",t.reposition),window.removeEventListener("scroll",t.reposition,!0),p.delete(e))}function ie(e){b||(b=!0,f=t=>{const r=t.target;if(!(r instanceof Node))return;const o=P(r)?.closest(s)||null;if(!o)return;const i=w(o,e);C(o,i,e)},document.addEventListener("focusin",f,!0))}function ae(){!b||!f||(document.removeEventListener("focusin",f,!0),b=!1,f=null)}const le=(e={})=>{B();const t=D(e);return{name:"slashCommands",toolbar:[{id:"slashCommands",label:"Slash Commands",command:"openSlashCommands",icon:'<svg width="24" height="24" focusable="false" aria-hidden="true"><path d="M8.7 20a1 1 0 0 1-.7-.3c-.4-.4-.4-1 0-1.4L15.6 5a1 1 0 0 1 1.4 1.4L9.4 19.7a1 1 0 0 1-.7.3Zm7.8 0c-.3 0-.5 0-.7-.3l-1.8-1.8a1 1 0 1 1 1.4-1.4l1.8 1.8a1 1 0 0 1-.7 1.7Zm-9-12a1 1 0 0 1-.7-1.7L8.6 4.5A1 1 0 1 1 10 6L8.2 7.8a1 1 0 0 1-.7.3Z"></path></svg>'}],commands:{openSlashCommands:(r,n)=>{const o=_(n);if(!o)return!1;const i=w(o,t);return C(o,i,t),O(i,t)}},keymap:{"Mod-/":"openSlashCommands","Mod-Shift-7":"openSlashCommands"},init:()=>{h+=1,ie(t),Array.from(document.querySelectorAll(s)).forEach(n=>{const o=w(n,t);C(n,o,t)})},destroy:()=>{h=Math.max(0,h-1),Array.from(document.querySelectorAll(s)).forEach(n=>{const o=g.get(n);o&&(c(o),oe(n),re(n))}),h===0&&ae()}}};exports.SlashCommandsPlugin=le;
90
+ `,o.appendChild(i)}),e.filteredItems.length>0&&o.setAttribute("aria-activedescendant",`rte-slash-item-${e.instanceId}-${e.activeIndex}`)}function G(e,t){if(t===e.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,t,e.innerHTML)}catch{}}function V(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function L(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const n=o.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const r=document.createElement("template");r.innerHTML=t;const i=r.content,a=i.lastChild;if(n.insertNode(i),a){const l=document.createRange();l.setStartAfter(a),l.collapse(!0),y(e,l)}return!0}function X(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const n=o.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const r=document.createTextNode(t);n.insertNode(r);const i=document.createRange();return i.setStart(r,r.length),i.collapse(!0),y(e,i),!0}function J(e,t){switch(e.toLowerCase()){case"paragraph":case"p":return document.execCommand("formatBlock",!1,"<p>");case"heading1":case"h1":return document.execCommand("formatBlock",!1,"<h1>");case"heading2":case"h2":return document.execCommand("formatBlock",!1,"<h2>");case"heading3":case"h3":return document.execCommand("formatBlock",!1,"<h3>");case"blockquote":case"toggleblockquote":return document.execCommand("formatBlock",!1,"<blockquote>");case"bulletlist":case"togglebulletlist":case"insertunorderedlist":return document.execCommand("insertUnorderedList");case"numberedlist":case"toggleorderedlist":case"insertorderedlist":return document.execCommand("insertOrderedList");case"horizontalrule":case"divider":case"inserthorizontalrule":return document.execCommand("insertHorizontalRule");case"bold":case"togglebold":return document.execCommand("bold");case"italic":case"toggleitalic":return document.execCommand("italic");case"underline":case"toggleunderline":return document.execCommand("underline");case"strikethrough":case"togglestrikethrough":return document.execCommand("strikeThrough");case"clearformatting":case"removeformat":return document.execCommand("removeFormat");default:try{return document.execCommand(e,!1,t)}catch{return!1}}}function S(e,t,o){const n=I(e);if(n&&typeof n.execCommand=="function")try{if(n.execCommand(t,o)!==!1)return!0}catch{}const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{if(r(t,o,{editorElement:n,contentElement:e})!==!1)return!0}catch{}return J(t,o)}async function Y(e,t){const o=e.editor,n=I(o),r={editor:o,editorRoot:n,query:e.query,trigger:e.trigger,executeCommand:(i,a)=>S(o,i,a),insertHTML:i=>L(o,i)};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}async function M(e,t){if(t<0||t>=e.filteredItems.length||!e.replaceRange)return;const o=e.filteredItems[t],n=e.editor,r=n.innerHTML,i=`${e.trigger}${e.query}`;if(!window.getSelection())return;const l=e.replaceRange.cloneRange();if(!n.contains(l.commonAncestorContainer))return;l.deleteContents();const d=l.cloneRange();d.collapse(!0),y(n,d);let x=!1;try{x=await Y(e,o)}catch{x=!1}c(e),x?(V(n),G(n,r)):i&&X(n,i),n.focus({preventScroll:!0})}function R(e,t){if(e.filteredItems.length===0)return;const o=e.filteredItems.length;if(e.activeIndex=((e.activeIndex+t)%o+o)%o,!e.list)return;const n=Array.from(e.list.querySelectorAll(".rte-slash-item"));n.forEach((i,a)=>{const l=a===e.activeIndex;i.classList.toggle("active",l),i.setAttribute("aria-selected",l?"true":"false")});const r=n[e.activeIndex];r&&(e.list.setAttribute("aria-activedescendant",r.id),r.scrollIntoView({block:"nearest"}))}function T(e){if(!(!e.isOpen||!e.panel||!e.anchorRange)){if(!e.editor.isConnected){c(e);return}A(e,e.anchorRange)}}function N(e,t,o,n,r,i){U(e,t),e.query=n,e.trigger=r,e.replaceRange=i.cloneRange(),e.anchorRange=o.cloneRange(),e.filteredItems=W(e.items,n,t.maxSuggestions),e.activeIndex=0,e.isOpen=!0,e.panel&&(Z(e,t),A(e,o))}function ee(e,t){const o=e.editor;if(o.getAttribute("contenteditable")==="false"){c(e);return}const n=v(o);if(!n||!n.collapsed){c(e);return}const r=j(n);if(!r){c(e);return}const i=K(r.textBefore,t.triggerChar,t.maxQueryLength,t.requireBoundary);if(!i){c(e);return}if(i.query.length<t.minChars){c(e);return}const a=n.cloneRange();a.setStart(r.node,i.startOffset),a.setEnd(r.node,r.caretOffset),N(e,t,n,i.query,i.trigger,a)}function O(e,t){const o=e.editor;if(o.getAttribute("contenteditable")==="false")return!1;let n=v(o);n||(n=document.createRange(),n.selectNodeContents(o),n.collapse(!1),y(o,n));const r=n.cloneRange();return r.collapse(!0),N(e,t,n,"",t.triggerChar,r),!0}function te(e){return!(e.metaKey||e.ctrlKey)||e.altKey?!1:e.key==="/"||e.code==="Slash"}function ne(e,t){return{editor:e,panel:null,list:null,replaceRange:null,items:t.items,filteredItems:[],activeIndex:0,query:"",trigger:t.triggerChar,isOpen:!1,instanceId:++z,anchorRange:null}}function w(e,t){const o=g.get(e);if(o)return o.items=t.items,o;const n=ne(e,t);return g.set(e,n),n}function re(e){const t=g.get(e);t&&(t.panel?.parentNode&&t.panel.parentNode.removeChild(t.panel),g.delete(e))}function C(e,t,o){if(p.has(e))return;const n={input:()=>{ee(t,o)},keydown:r=>{if(t.editor.getAttribute("contenteditable")==="false"){c(t);return}if(!t.isOpen&&te(r)){r.preventDefault(),O(t,o);return}if(t.isOpen){if(r.key==="ArrowDown"){r.preventDefault(),R(t,1);return}if(r.key==="ArrowUp"){r.preventDefault(),R(t,-1);return}if(r.key==="Enter"||r.key==="Tab"){if(t.filteredItems.length===0){r.key==="Tab"&&r.preventDefault(),c(t);return}r.preventDefault(),M(t,t.activeIndex);return}if(r.key==="Escape"){r.preventDefault(),c(t);return}}},blur:()=>{window.setTimeout(()=>{const r=document.activeElement;t.panel&&r&&t.panel.contains(r)||c(t)},0)},mousedown:r=>{if(!t.isOpen||!t.panel)return;const i=r.target;i&&!t.panel.contains(i)&&!e.contains(i)&&c(t)},selectionchange:()=>{if(!t.isOpen)return;const r=v(e);if(!r||!r.collapsed){c(t);return}t.anchorRange=r.cloneRange(),T(t)},reposition:()=>{T(t)}};e.addEventListener("input",n.input),e.addEventListener("keydown",n.keydown),e.addEventListener("blur",n.blur),document.addEventListener("mousedown",n.mousedown,!0),document.addEventListener("selectionchange",n.selectionchange),window.addEventListener("resize",n.reposition,{passive:!0}),window.addEventListener("scroll",n.reposition,!0),p.set(e,n)}function oe(e){const t=p.get(e);t&&(e.removeEventListener("input",t.input),e.removeEventListener("keydown",t.keydown),e.removeEventListener("blur",t.blur),document.removeEventListener("mousedown",t.mousedown,!0),document.removeEventListener("selectionchange",t.selectionchange),window.removeEventListener("resize",t.reposition),window.removeEventListener("scroll",t.reposition,!0),p.delete(e))}function ie(e){b||(b=!0,f=t=>{const o=t.target;if(!(o instanceof Node))return;const r=P(o)?.closest(s)||null;if(!r)return;const i=w(r,e);C(r,i,e)},document.addEventListener("focusin",f,!0))}function ae(){!b||!f||(document.removeEventListener("focusin",f,!0),b=!1,f=null)}const le=(e={})=>{B();const t=D(e);return{name:"slashCommands",toolbar:[{id:"slashCommands",label:"Slash Commands",command:"openSlashCommands",icon:'<svg width="24" height="24" focusable="false" aria-hidden="true"><path d="M8.7 20a1 1 0 0 1-.7-.3c-.4-.4-.4-1 0-1.4L15.6 5a1 1 0 0 1 1.4 1.4L9.4 19.7a1 1 0 0 1-.7.3Zm7.8 0c-.3 0-.5 0-.7-.3l-1.8-1.8a1 1 0 1 1 1.4-1.4l1.8 1.8a1 1 0 0 1-.7 1.7Zm-9-12a1 1 0 0 1-.7-1.7L8.6 4.5A1 1 0 1 1 10 6L8.2 7.8a1 1 0 0 1-.7.3Z"></path></svg>'}],commands:{openSlashCommands:(o,n)=>{const r=_(n);if(!r)return!1;const i=w(r,t);return C(r,i,t),O(i,t)}},keymap:{"Mod-/":"openSlashCommands","Mod-Shift-7":"openSlashCommands"},init:()=>{h+=1,ie(t),Array.from(document.querySelectorAll(s)).forEach(n=>{const r=w(n,t);C(n,r,t)})},destroy:()=>{h=Math.max(0,h-1),Array.from(document.querySelectorAll(s)).forEach(n=>{const r=g.get(n);r&&(c(r),oe(n),re(n))}),h===0&&ae()}}};exports.SlashCommandsPlugin=le;