@editora/core 1.0.8 → 1.0.10

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 (58) hide show
  1. package/README.md +6 -1
  2. package/dist/{ApprovalWorkflowPlugin.native-C3jtAYjG.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +136 -133
  3. package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
  4. package/dist/{BlocksLibraryPlugin.native-HMWKxWNs.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +90 -87
  5. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
  6. package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
  7. package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
  8. package/dist/{CitationsPlugin.native-BnU0qCwR.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +132 -129
  9. package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
  10. package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
  11. package/dist/{ContentRulesPlugin.native-nBLQ8QFZ.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +105 -102
  12. package/dist/{DataBindingPlugin.native-jQ1JPRTp.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +49 -46
  13. package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
  14. package/dist/{DocSchemaPlugin.native-CHOge18O.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +55 -52
  15. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-BF_-LjTq.mjs} +287 -115
  16. package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
  17. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-D2wl32jV.mjs} +88 -103
  18. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
  19. package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
  20. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +204 -202
  21. package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
  22. package/dist/{PIIRedactionPlugin.native-DcsjmtV1.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +158 -155
  23. package/dist/{SlashCommandsPlugin.native-CmxvMEaE.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +2 -2
  24. package/dist/{SmartPastePlugin.native-BOKKtF07.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +127 -124
  25. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +100 -76
  26. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -26
  27. package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
  28. package/dist/{TranslationWorkflowPlugin.native-Bz6jDGvj.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +104 -101
  29. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
  30. package/dist/editora.min.js +1 -1
  31. package/dist/editora.umd.js +1 -1
  32. package/dist/index-CPMGUZfB.js +10 -0
  33. package/dist/{index-DqC57IEH.mjs → index-DBoj6QfW.mjs} +17 -15
  34. package/dist/index.cjs.js +1 -1
  35. package/dist/index.esm.js +2 -2
  36. package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
  37. package/dist/plugin-loader.js +37 -37
  38. package/dist/webcomponent-core.js +18 -16
  39. package/dist/webcomponent-core.min.css +1 -1
  40. package/dist/webcomponent-core.min.js +139 -62
  41. package/dist/webcomponent.cjs.js +1 -1
  42. package/dist/webcomponent.esm.js +1 -1
  43. package/dist/webcomponent.js +50 -48
  44. package/dist/webcomponent.min.css +1 -1
  45. package/dist/webcomponent.min.js +1174 -1071
  46. package/package.json +11 -5
  47. package/LICENSE +0 -21
  48. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs +0 -48
  49. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs +0 -79
  50. package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +0 -309
  51. package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +0 -140
  52. package/dist/CodePlugin.native-DlpTPdkd.mjs +0 -2691
  53. package/dist/DirectionPlugin.native-CDnbdNyl.mjs +0 -130
  54. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs +0 -64
  55. package/dist/MathPlugin.native-f_mDp8VL.mjs +0 -292
  56. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +0 -559
  57. package/dist/TemplatePlugin.native-CrpfKRJ8.mjs +0 -602
  58. package/dist/index-D1LOqg5C.js +0 -10
@@ -1,4 +1,4 @@
1
- const S = ".rte-content, .editora-content", P = '.rte-data-binding[data-binding="true"]', ot = "rte-data-binding-styles", p = "rte-data-binding-dialog-overlay", b = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', pt = {
1
+ const S = ".rte-content, .editora-content", P = '.rte-data-binding[data-binding="true"]', ot = "rte-data-binding-styles", p = "rte-data-binding-dialog-overlay", b = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', yt = {
2
2
  dialogTitleInsert: "Insert Data Binding",
3
3
  dialogTitleEdit: "Edit Data Binding",
4
4
  keyLabel: "Data Key",
@@ -13,11 +13,11 @@ const S = ".rte-content, .editora-content", P = '.rte-data-binding[data-binding=
13
13
  previewOnText: "Preview On",
14
14
  previewOffText: "Preview Off",
15
15
  tokenAriaPrefix: "Data binding token"
16
- }, v = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap();
17
- let K = null, k = null, z = 0, O = null, M = null, B = null, V = null;
18
- function yt(t) {
16
+ }, v = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap();
17
+ let R = null, k = null, z = 0, O = null, M = null, B = null, V = null;
18
+ function ht(t) {
19
19
  return {
20
- ...pt,
20
+ ...yt,
21
21
  ...t || {}
22
22
  };
23
23
  }
@@ -29,7 +29,7 @@ function dt(t = {}) {
29
29
  getData: t.getData,
30
30
  api: t.api,
31
31
  cacheTtlMs: Math.max(0, Number((e = t.cacheTtlMs) != null ? e : 3e4)),
32
- labels: yt(t.labels),
32
+ labels: ht(t.labels),
33
33
  defaultFormat: t.defaultFormat || "text",
34
34
  defaultFallback: t.defaultFallback || "",
35
35
  locale: a,
@@ -49,7 +49,7 @@ function q(t) {
49
49
  function _(t) {
50
50
  return t ? (t.getAttribute("data-theme") || t.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : t.classList.contains("dark") || t.classList.contains("editora-theme-dark") || t.classList.contains("rte-theme-dark") : !1;
51
51
  }
52
- function ht(t) {
52
+ function kt(t) {
53
53
  const a = q(t);
54
54
  if (_(a)) return !0;
55
55
  const e = a.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
@@ -89,7 +89,7 @@ function ct(t, a) {
89
89
  const e = window.getSelection();
90
90
  e && (e.removeAllRanges(), e.addRange(a), t.focus({ preventScroll: !0 }));
91
91
  }
92
- function kt(t, a) {
92
+ function vt(t, a) {
93
93
  const e = (a || "").trim();
94
94
  if (e)
95
95
  return e.split(".").filter(Boolean).reduce((r, n) => {
@@ -97,7 +97,7 @@ function kt(t, a) {
97
97
  return r[n];
98
98
  }, t);
99
99
  }
100
- function vt() {
100
+ function xt() {
101
101
  if (typeof document == "undefined" || document.getElementById(ot)) return;
102
102
  const t = document.createElement("style");
103
103
  t.id = ot, t.textContent = `
@@ -447,7 +447,7 @@ function X(t) {
447
447
  return r && t.contains(r) ? r : null;
448
448
  }
449
449
  function bt() {
450
- K && (K.cleanup(), K = null);
450
+ R && (R.cleanup(), R = null);
451
451
  }
452
452
  function et(t, a, e) {
453
453
  const r = q(t);
@@ -458,7 +458,7 @@ function et(t, a, e) {
458
458
  }
459
459
  });
460
460
  }
461
- function xt(t, a, e) {
461
+ function wt(t, a, e) {
462
462
  const r = a.format || "text";
463
463
  if (t == null) return a.fallback || "";
464
464
  if (r === "json") {
@@ -500,19 +500,19 @@ function C(t, a, e, r) {
500
500
  t.textContent = ut(n), t.setAttribute("aria-label", `${a.labels.tokenAriaPrefix}: ${i}. Press Enter to edit.`);
501
501
  return;
502
502
  }
503
- const o = kt(r, i), l = o == null, d = l ? n.fallback || "" : xt(o, n, a);
503
+ const o = vt(r, i), l = o == null, d = l ? n.fallback || "" : wt(o, n, a);
504
504
  t.textContent = d || n.fallback || "", t.classList.add("rte-data-binding-preview"), l && !(n.fallback || "").trim() && t.classList.add("rte-data-binding-missing"), t.setAttribute("aria-label", `${a.labels.tokenAriaPrefix}: ${i} = ${t.textContent || ""}. Press Enter to edit.`);
505
505
  }
506
506
  function w(t) {
507
507
  return typeof t == "object" && t !== null && !Array.isArray(t);
508
508
  }
509
- function wt(t, a) {
509
+ function Et(t, a) {
510
510
  return a ? a.split(".").filter(Boolean).reduce((e, r) => {
511
511
  if (!(!w(e) && !Array.isArray(e)))
512
512
  return e[r];
513
513
  }, t) : t;
514
514
  }
515
- function Et(t, a, e) {
515
+ function Dt(t, a, e) {
516
516
  const r = a.api, n = q(t), i = { editor: t, editorRoot: n, signal: e };
517
517
  if (r.buildRequest) {
518
518
  const m = r.buildRequest(i);
@@ -542,7 +542,7 @@ function Et(t, a, e) {
542
542
  }
543
543
  return { url: u.toString(), init: s };
544
544
  }
545
- async function Dt(t, a) {
545
+ async function At(t, a) {
546
546
  var d, u;
547
547
  const e = a.api;
548
548
  if (!e) return {};
@@ -550,7 +550,7 @@ async function Dt(t, a) {
550
550
  let l = null;
551
551
  o > 0 && (l = window.setTimeout(() => r.abort(), o));
552
552
  try {
553
- const { url: s, init: m } = Et(t, a, r.signal), f = await fetch(s, { ...m, signal: r.signal });
553
+ const { url: s, init: m } = Dt(t, a, r.signal), f = await fetch(s, { ...m, signal: r.signal });
554
554
  if (!f.ok)
555
555
  throw new Error(`Data binding API request failed: ${f.status}`);
556
556
  const $ = (e.responseType || "json") === "text" ? await f.text() : await f.json();
@@ -558,7 +558,7 @@ async function Dt(t, a) {
558
558
  const F = e.transformResponse($, i);
559
559
  return w(F) ? F : {};
560
560
  }
561
- const x = wt($, e.responsePath);
561
+ const x = Et($, e.responsePath);
562
562
  return w(x) ? x : w($) ? $ : { value: x };
563
563
  } catch (s) {
564
564
  return (s == null ? void 0 : s.name) !== "AbortError" && ((u = e.onError) == null || u.call(e, s, i)), {};
@@ -569,7 +569,7 @@ async function Dt(t, a) {
569
569
  async function U(t, a) {
570
570
  const e = J.get(t);
571
571
  if (e) return e;
572
- const r = R.get(t), n = Date.now();
572
+ const r = N.get(t), n = Date.now();
573
573
  if (r && n - r.timestamp <= a.cacheTtlMs)
574
574
  return r.data;
575
575
  const i = I.get(t);
@@ -581,7 +581,7 @@ async function U(t, a) {
581
581
  if (w(d)) return d;
582
582
  }
583
583
  if (a.api) {
584
- const d = await Dt(t, a);
584
+ const d = await At(t, a);
585
585
  if (w(d)) return d;
586
586
  }
587
587
  if (typeof a.data == "function") {
@@ -595,7 +595,7 @@ async function U(t, a) {
595
595
  })();
596
596
  I.set(t, o);
597
597
  const l = await o;
598
- return R.set(t, { timestamp: n, data: l }), l;
598
+ return N.set(t, { timestamp: n, data: l }), l;
599
599
  }
600
600
  async function Z(t, a, e) {
601
601
  const r = G(t, a);
@@ -614,18 +614,21 @@ function gt(t, a) {
614
614
  const n = document.createRange();
615
615
  n.setStart(r, 1), n.collapse(!0), ct(t, n), t.normalize();
616
616
  }
617
- function At(t) {
618
- const a = t.metaKey || t.ctrlKey, e = t.key.toLowerCase(), r = a && t.altKey && t.shiftKey && e === "d", n = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && e === "f7";
619
- return r || n;
617
+ function mt(t) {
618
+ return typeof t.key == "string" ? t.key.toLowerCase() : "";
620
619
  }
621
620
  function St(t) {
622
- const a = t.metaKey || t.ctrlKey, e = t.key.toLowerCase(), r = a && t.altKey && t.shiftKey && e === "b", n = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && e === "f8";
621
+ const a = t.metaKey || t.ctrlKey, e = mt(t), r = a && t.altKey && t.shiftKey && e === "d", n = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && e === "f7";
622
+ return r || n;
623
+ }
624
+ function Tt(t) {
625
+ const a = t.metaKey || t.ctrlKey, e = mt(t), r = a && t.altKey && t.shiftKey && e === "b", n = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && e === "f8";
623
626
  return r || n;
624
627
  }
625
628
  function L(t, a, e, r, n) {
626
629
  bt();
627
630
  const i = e === "insert" ? st(t) : null, o = a.labels, l = n ? W(n, a) : j(r || {}, a), d = document.createElement("div");
628
- d.className = p, ht(t) && d.classList.add("rte-data-binding-theme-dark");
631
+ d.className = p, kt(t) && d.classList.add("rte-data-binding-theme-dark");
629
632
  const u = document.createElement("section");
630
633
  u.className = "rte-data-binding-dialog", u.setAttribute("role", "dialog"), u.setAttribute("aria-modal", "true"), u.setAttribute("aria-labelledby", "rte-data-binding-dialog-title"), u.innerHTML = `
631
634
  <header class="rte-data-binding-header">
@@ -676,23 +679,23 @@ function L(t, a, e, r, n) {
676
679
  };
677
680
  $(), f == null || f.addEventListener("change", $);
678
681
  const x = () => {
679
- d.removeEventListener("click", nt), d.removeEventListener("keydown", rt, !0), document.removeEventListener("keydown", F, !0), d.parentNode && d.parentNode.removeChild(d), K = null, t.focus({ preventScroll: !0 });
682
+ d.removeEventListener("click", nt), d.removeEventListener("keydown", rt, !0), document.removeEventListener("keydown", F, !0), d.parentNode && d.parentNode.removeChild(d), R = null, t.focus({ preventScroll: !0 });
680
683
  }, F = (c) => {
681
684
  c.key === "Escape" && (c.preventDefault(), c.stopPropagation(), x());
682
685
  }, nt = (c) => {
683
686
  c.target === d && x();
684
- }, mt = (c) => {
687
+ }, pt = (c) => {
685
688
  if (c.key !== "Tab") return;
686
689
  const y = Array.from(
687
690
  u.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')
688
691
  );
689
692
  if (y.length === 0) return;
690
- const E = y[0], D = y[y.length - 1], N = document.activeElement;
691
- if (c.shiftKey && N === E) {
693
+ const E = y[0], D = y[y.length - 1], K = document.activeElement;
694
+ if (c.shiftKey && K === E) {
692
695
  c.preventDefault(), D.focus();
693
696
  return;
694
697
  }
695
- !c.shiftKey && N === D && (c.preventDefault(), E.focus());
698
+ !c.shiftKey && K === D && (c.preventDefault(), E.focus());
696
699
  }, at = async () => {
697
700
  const c = ((s == null ? void 0 : s.value) || "").trim();
698
701
  if (!c) {
@@ -710,8 +713,8 @@ function L(t, a, e, r, n) {
710
713
  ), E = t.innerHTML;
711
714
  if (n) {
712
715
  tt(n, y, o);
713
- const D = v.get(t) === !0, N = D ? await U(t, a) : void 0;
714
- C(n, a, D, N);
716
+ const D = v.get(t) === !0, K = D ? await U(t, a) : void 0;
717
+ C(n, a, D, K);
715
718
  } else {
716
719
  if (i)
717
720
  try {
@@ -730,7 +733,7 @@ function L(t, a, e, r, n) {
730
733
  c.preventDefault(), x();
731
734
  return;
732
735
  }
733
- mt(c), c.key === "Enter" && !c.shiftKey && c.target instanceof HTMLInputElement && (c.preventDefault(), at());
736
+ pt(c), c.key === "Enter" && !c.shiftKey && c.target instanceof HTMLInputElement && (c.preventDefault(), at());
734
737
  };
735
738
  u.addEventListener("click", (c) => {
736
739
  const y = c.target, E = y == null ? void 0 : y.getAttribute("data-action");
@@ -741,9 +744,9 @@ function L(t, a, e, r, n) {
741
744
  }
742
745
  E === "save" && at();
743
746
  }
744
- }), d.addEventListener("click", nt), d.addEventListener("keydown", rt, !0), document.addEventListener("keydown", F, !0), K = { cleanup: x }, s == null || s.focus();
747
+ }), d.addEventListener("click", nt), d.addEventListener("keydown", rt, !0), document.addEventListener("keydown", F, !0), R = { cleanup: x }, s == null || s.focus();
745
748
  }
746
- function Tt(t) {
749
+ function $t(t) {
747
750
  V = t, M || (M = (a) => {
748
751
  const e = a.target, r = e == null ? void 0 : e.closest(S);
749
752
  if (!r) return;
@@ -763,13 +766,13 @@ function Tt(t) {
763
766
  a.preventDefault(), a.stopPropagation(), k = r, L(r, n, "edit", void 0, i);
764
767
  return;
765
768
  }
766
- if (At(a)) {
769
+ if (St(a)) {
767
770
  a.preventDefault(), a.stopPropagation();
768
771
  const o = X(r);
769
772
  o ? L(r, n, "edit", void 0, o) : L(r, n, "insert");
770
773
  return;
771
774
  }
772
- if (St(a)) {
775
+ if (Tt(a)) {
773
776
  a.preventDefault(), a.stopPropagation();
774
777
  const o = v.get(r) !== !0;
775
778
  Z(r, n, o);
@@ -784,12 +787,12 @@ function Tt(t) {
784
787
  g.set(n, i), k = n, a.preventDefault(), a.stopPropagation(), r.focus({ preventScroll: !0 }), L(n, i, "edit", void 0, r);
785
788
  }, document.addEventListener("click", B, !0));
786
789
  }
787
- function $t() {
790
+ function Lt() {
788
791
  M && (document.removeEventListener("focusin", M, !0), M = null), O && (document.removeEventListener("keydown", O, !0), O = null), B && (document.removeEventListener("click", B, !0), B = null), V = null, k = null;
789
792
  }
790
- const Lt = (t = {}) => {
793
+ const Ct = (t = {}) => {
791
794
  const a = dt(t);
792
- return vt(), {
795
+ return xt(), {
793
796
  name: "dataBinding",
794
797
  toolbar: [
795
798
  {
@@ -868,7 +871,7 @@ const Lt = (t = {}) => {
868
871
  setDataBindingData: async (e, r) => {
869
872
  const n = A(r);
870
873
  if (!n) return !1;
871
- if (k = n, e && typeof e == "object" ? (J.set(n, e), R.set(n, { timestamp: Date.now(), data: e })) : (J.delete(n), R.delete(n)), v.get(n) === !0) {
874
+ if (k = n, e && typeof e == "object" ? (J.set(n, e), N.set(n, { timestamp: Date.now(), data: e })) : (J.delete(n), N.delete(n)), v.get(n) === !0) {
872
875
  const i = g.get(n) || a;
873
876
  await Z(n, i, !0);
874
877
  }
@@ -877,7 +880,7 @@ const Lt = (t = {}) => {
877
880
  refreshDataBindings: async (e, r) => {
878
881
  const n = A(r);
879
882
  if (!n) return !1;
880
- k = n, R.delete(n);
883
+ k = n, N.delete(n);
881
884
  const i = g.get(n) || a;
882
885
  g.set(n, i);
883
886
  const o = v.get(n) === !0;
@@ -895,7 +898,7 @@ const Lt = (t = {}) => {
895
898
  init: function(r) {
896
899
  z += 1;
897
900
  const n = this && typeof this.__pluginConfig == "object" ? dt({ ...a, ...this.__pluginConfig }) : a;
898
- Tt(n);
901
+ $t(n);
899
902
  const i = A(
900
903
  r && r.editorElement ? { editorElement: r.editorElement } : void 0,
901
904
  !1
@@ -907,11 +910,11 @@ const Lt = (t = {}) => {
907
910
  }
908
911
  },
909
912
  destroy: () => {
910
- z = Math.max(0, z - 1), z === 0 && (bt(), $t());
913
+ z = Math.max(0, z - 1), z === 0 && (bt(), Lt());
911
914
  }
912
915
  };
913
916
  };
914
917
  export {
915
- Lt as DataBindingPlugin
918
+ Ct as DataBindingPlugin
916
919
  };
917
- //# sourceMappingURL=DataBindingPlugin.native-jQ1JPRTp.mjs.map
920
+ //# sourceMappingURL=DataBindingPlugin.native-BoXwghTz.mjs.map
@@ -0,0 +1,153 @@
1
+ const l = '.rte-content, .editora-content, [contenteditable="true"]', C = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", g = /* @__PURE__ */ new Set([
2
+ "P",
3
+ "DIV",
4
+ "H1",
5
+ "H2",
6
+ "H3",
7
+ "H4",
8
+ "H5",
9
+ "H6",
10
+ "LI",
11
+ "BLOCKQUOTE",
12
+ "PRE",
13
+ "TABLE",
14
+ "FIGURE",
15
+ "UL",
16
+ "OL"
17
+ ]), d = (e) => g.has(e.tagName) && e.getAttribute("contenteditable") !== "true", T = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, L = (e) => {
18
+ const n = e == null ? void 0 : e.contentElement;
19
+ if (n instanceof HTMLElement) return n;
20
+ const t = e == null ? void 0 : e.editorElement;
21
+ if (t instanceof HTMLElement) {
22
+ const r = t.querySelector(l);
23
+ if (r instanceof HTMLElement) return r;
24
+ if (t.getAttribute("contenteditable") === "true") return t;
25
+ }
26
+ const o = window.__editoraCommandEditorRoot;
27
+ if (o instanceof HTMLElement) {
28
+ const r = o.querySelector(l);
29
+ if (r instanceof HTMLElement) return r;
30
+ if (o.getAttribute("contenteditable") === "true") return o;
31
+ }
32
+ const i = window.getSelection();
33
+ if (i && i.rangeCount > 0) {
34
+ const r = T(i.getRangeAt(0).startContainer), c = r == null ? void 0 : r.closest(l);
35
+ if (c instanceof HTMLElement) return c;
36
+ const f = r == null ? void 0 : r.closest(C), E = f == null ? void 0 : f.querySelector(l);
37
+ if (E instanceof HTMLElement) return E;
38
+ }
39
+ const a = document.activeElement, s = a instanceof HTMLElement ? a.closest(l) : null;
40
+ return s instanceof HTMLElement ? s : document.querySelector(l);
41
+ }, h = (e) => {
42
+ const n = window.getSelection();
43
+ if (!n || n.rangeCount === 0) return null;
44
+ const t = n.getRangeAt(0);
45
+ return !e.contains(t.startContainer) || !e.contains(t.endContainer) ? null : t;
46
+ }, w = (e, n) => {
47
+ let t = T(n);
48
+ for (; t && t !== e && e.contains(t); ) {
49
+ if (d(t)) return t;
50
+ t = t.parentElement;
51
+ }
52
+ return d(e) ? e : null;
53
+ }, u = (e, n) => {
54
+ const t = w(e, n);
55
+ if (!t || t === e) return null;
56
+ const o = t.closest("li");
57
+ return o instanceof HTMLElement && e.contains(o) ? o : t;
58
+ }, R = (e, n) => {
59
+ if (typeof e.intersectsNode == "function")
60
+ try {
61
+ return e.intersectsNode(n);
62
+ } catch (o) {
63
+ return !1;
64
+ }
65
+ const t = document.createRange();
66
+ return t.selectNode(n), e.compareBoundaryPoints(Range.END_TO_START, t) < 0 && e.compareBoundaryPoints(Range.START_TO_END, t) > 0;
67
+ }, p = (e, n) => {
68
+ const t = [], o = /* @__PURE__ */ new Set(), i = (r) => {
69
+ !r || o.has(r) || r === n || !n.contains(r) || d(r) && (o.add(r), t.push(r));
70
+ };
71
+ if (e.collapsed)
72
+ return i(u(n, e.startContainer)), t;
73
+ i(u(n, e.startContainer)), i(u(n, e.endContainer));
74
+ const a = document.createTreeWalker(
75
+ n,
76
+ NodeFilter.SHOW_ELEMENT,
77
+ {
78
+ acceptNode: (r) => {
79
+ const c = r;
80
+ return !d(c) || c.closest("li") && c.tagName !== "LI" ? NodeFilter.FILTER_SKIP : R(e, c) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
81
+ }
82
+ }
83
+ );
84
+ let s = a.nextNode();
85
+ for (; s; )
86
+ i(s), s = a.nextNode();
87
+ return t.length === 0 && i(u(n, e.commonAncestorContainer)), t.filter((r) => !t.some((c) => c !== r && r.contains(c)));
88
+ }, S = (e, n, t) => {
89
+ if (n !== t) {
90
+ if (typeof window.execEditorCommand == "function") {
91
+ window.execEditorCommand("recordDomTransaction", e, n, t);
92
+ return;
93
+ }
94
+ if (typeof window.executeEditorCommand == "function")
95
+ try {
96
+ window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: n, afterHTML: t });
97
+ } catch (o) {
98
+ }
99
+ }
100
+ }, m = (e, n) => {
101
+ const t = L(n);
102
+ if (!t) return !1;
103
+ const o = h(t);
104
+ if (!o) return !1;
105
+ const i = p(o, t);
106
+ if (i.length === 0) return !1;
107
+ const a = t.innerHTML;
108
+ i.forEach((r) => {
109
+ r.setAttribute("dir", e);
110
+ });
111
+ const s = t.innerHTML;
112
+ return a === s ? !1 : (S(t, a, s), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), !0);
113
+ }, M = () => ({
114
+ name: "direction",
115
+ toolbar: [
116
+ {
117
+ label: "Left to Right",
118
+ command: "setDirectionLTR",
119
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
120
+ shortcut: "Mod-Shift-l"
121
+ },
122
+ {
123
+ label: "Right to Left",
124
+ command: "setDirectionRTL",
125
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
126
+ shortcut: "Mod-Shift-r"
127
+ }
128
+ ],
129
+ commands: {
130
+ setDirectionLTR: (e, n) => {
131
+ try {
132
+ return m("ltr", n);
133
+ } catch (t) {
134
+ return console.error("Failed to set LTR direction:", t), !1;
135
+ }
136
+ },
137
+ setDirectionRTL: (e, n) => {
138
+ try {
139
+ return m("rtl", n);
140
+ } catch (t) {
141
+ return console.error("Failed to set RTL direction:", t), !1;
142
+ }
143
+ }
144
+ },
145
+ keymap: {
146
+ "Mod-Shift-l": "setDirectionLTR",
147
+ "Mod-Shift-r": "setDirectionRTL"
148
+ }
149
+ });
150
+ export {
151
+ M as DirectionPlugin
152
+ };
153
+ //# sourceMappingURL=DirectionPlugin.native-Bl-QLFzO.mjs.map