@editora/plugins 1.0.22 → 1.1.0

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 (103) hide show
  1. package/README.md +1 -1
  2. package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-BwhZsI5v.js} +11 -11
  3. package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-CojLCp6C.mjs} +61 -53
  4. package/dist/MediaManagerPlugin.native-CycfjOi4.js +1841 -0
  5. package/dist/MediaManagerPlugin.native-DZrmcmnm.mjs +4688 -0
  6. package/dist/a11y-checker.cjs.js +3 -3
  7. package/dist/a11y-checker.esm.js +6 -4
  8. package/dist/anchor.cjs.js +4 -4
  9. package/dist/anchor.esm.js +19 -18
  10. package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
  11. package/dist/anchoredPopover-Cygmit_o.js +1 -0
  12. package/dist/approval-workflow.cjs.js +7 -7
  13. package/dist/approval-workflow.esm.js +55 -54
  14. package/dist/background-color.cjs.js +2 -2
  15. package/dist/background-color.esm.js +72 -67
  16. package/dist/blocks-library.cjs.js +18 -19
  17. package/dist/blocks-library.esm.js +41 -42
  18. package/dist/citations.cjs.js +4 -4
  19. package/dist/citations.esm.js +50 -50
  20. package/dist/code-sample.cjs.js +10 -10
  21. package/dist/code-sample.esm.js +4 -4
  22. package/dist/code.cjs.js +1 -1
  23. package/dist/code.esm.js +1 -1
  24. package/dist/comments.cjs.js +23 -11
  25. package/dist/comments.esm.js +167 -149
  26. package/dist/conditional-content.cjs.js +2 -2
  27. package/dist/conditional-content.esm.js +2 -2
  28. package/dist/confirmDialog-D3S8BhIM.js +42 -0
  29. package/dist/confirmDialog-DR4c8j6S.mjs +87 -0
  30. package/dist/content-rules.cjs.js +6 -6
  31. package/dist/content-rules.esm.js +51 -51
  32. package/dist/data-binding.cjs.js +2 -2
  33. package/dist/data-binding.esm.js +2 -2
  34. package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
  35. package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
  36. package/dist/document-manager.cjs.js +1 -1
  37. package/dist/document-manager.esm.js +1 -1
  38. package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
  39. package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
  40. package/dist/embed-iframe.cjs.js +6 -6
  41. package/dist/embed-iframe.esm.js +6 -6
  42. package/dist/emojis.cjs.js +5 -5
  43. package/dist/emojis.esm.js +3 -3
  44. package/dist/enterprise.cjs.js +1 -1
  45. package/dist/enterprise.esm.js +12 -12
  46. package/dist/format-painter.cjs.js +1 -1
  47. package/dist/format-painter.esm.js +172 -151
  48. package/dist/heading.cjs.js +1 -1
  49. package/dist/heading.esm.js +96 -83
  50. package/dist/history.cjs.js +1 -1
  51. package/dist/history.esm.js +176 -97
  52. package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
  53. package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/index.esm.js +90 -83
  56. package/dist/katex-Cc3-mvOY.js +257 -0
  57. package/dist/katex-DoRnZ_sp.mjs +11682 -0
  58. package/dist/katex.min--Ws3c9be.mjs +5 -0
  59. package/dist/katex.min-Dk2VscxB.js +2 -0
  60. package/dist/link.cjs.js +3 -3
  61. package/dist/link.esm.js +3 -3
  62. package/dist/list.cjs.js +1 -1
  63. package/dist/list.esm.js +140 -52
  64. package/dist/math.cjs.js +14 -14
  65. package/dist/math.esm.js +149 -136
  66. package/dist/media-manager.cjs.js +1 -619
  67. package/dist/media-manager.esm.js +30 -1017
  68. package/dist/mentions.cjs.js +12 -12
  69. package/dist/mentions.esm.js +149 -143
  70. package/dist/merge-tag.cjs.js +5 -3
  71. package/dist/merge-tag.esm.js +5 -3
  72. package/dist/notify-BkbzMopb.js +32 -0
  73. package/dist/notify-zOp-mUOJ.mjs +59 -0
  74. package/dist/pii-redaction.cjs.js +1 -1
  75. package/dist/pii-redaction.esm.js +1 -1
  76. package/dist/preview.cjs.js +1 -1
  77. package/dist/preview.esm.js +1 -1
  78. package/dist/shared-config.cjs.js +1 -1
  79. package/dist/shared-config.esm.js +14 -14
  80. package/dist/slash-commands.cjs.js +5 -5
  81. package/dist/slash-commands.esm.js +259 -236
  82. package/dist/smart-paste.cjs.js +1 -1
  83. package/dist/smart-paste.esm.js +1 -1
  84. package/dist/special-characters.cjs.js +3 -3
  85. package/dist/special-characters.esm.js +3 -3
  86. package/dist/spell-check.cjs.js +9 -9
  87. package/dist/spell-check.esm.js +288 -251
  88. package/dist/table.cjs.js +14 -14
  89. package/dist/table.esm.js +175 -154
  90. package/dist/template.cjs.js +5 -3
  91. package/dist/template.esm.js +15 -13
  92. package/dist/text-color.cjs.js +4 -4
  93. package/dist/text-color.esm.js +38 -34
  94. package/dist/translation-workflow.cjs.js +9 -9
  95. package/dist/translation-workflow.esm.js +98 -95
  96. package/dist/version-diff.cjs.js +4 -4
  97. package/dist/version-diff.esm.js +36 -36
  98. package/index.d.ts +183 -2
  99. package/package.json +6 -5
  100. package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
  101. package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
  102. package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
  103. package/dist/dialogHelpers-zU6zpMIA.js +0 -12
@@ -1,4 +1,4 @@
1
- import { i as ae } from "./dialogHelpers-5d5BuOCW.mjs";
1
+ import { i as ae } from "./dialogHelpers-BbwpIXD9.mjs";
2
2
  const $ = ".rte-content, .editora-content", d = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark', l = "rte-version-diff-overlay", U = "rte-version-diff-styles", le = {
3
3
  title: "Version Diff",
4
4
  baseline: "Baseline",
@@ -14,7 +14,7 @@ const $ = ".rte-content, .editora-content", d = '[data-theme="dark"], .dark, .ed
14
14
  ignoreWhitespace: "Ignore whitespace",
15
15
  largeDocFallback: "Large document fallback mode applied for performance."
16
16
  }, w = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap();
17
- let j = 0, H = null, z = null, V = null, S = null, M = null, D = null;
17
+ let P = 0, H = null, z = null, V = null, S = null, M = null, D = null;
18
18
  function u(e) {
19
19
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
20
20
  }
@@ -48,7 +48,7 @@ function N(e, i = !0) {
48
48
  function O(e) {
49
49
  return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || e;
50
50
  }
51
- function P(e) {
51
+ function j(e) {
52
52
  if (!e) return !1;
53
53
  const i = e.getAttribute("data-theme") || e.getAttribute("theme");
54
54
  if (i && i.toLowerCase() === "dark") return !0;
@@ -57,9 +57,9 @@ function P(e) {
57
57
  }
58
58
  function Y(e) {
59
59
  const i = O(e);
60
- if (P(i)) return !0;
60
+ if (j(i)) return !0;
61
61
  const n = i.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
62
- return !!(P(n) || P(document.documentElement) || P(document.body));
62
+ return !!(j(n) || j(document.documentElement) || j(document.body));
63
63
  }
64
64
  function de(e) {
65
65
  const i = document.createElement("textarea");
@@ -148,11 +148,11 @@ function pe(e, i) {
148
148
  function be(e, i, n, r, t, o) {
149
149
  if (e.length === 0 && i.length === 0)
150
150
  return { segments: [], insertedCount: 0, deletedCount: 0, equalCount: 0, usedFallback: !1 };
151
- const { prefix: f, suffix: g, aMiddle: c, bMiddle: b } = pe(e, i), v = [];
152
- f.forEach((a) => v.push({ type: "equal", token: a }));
151
+ const { prefix: f, suffix: g, aMiddle: c, bMiddle: b } = pe(e, i), m = [];
152
+ f.forEach((a) => m.push({ type: "equal", token: a }));
153
153
  const F = c.length * b.length, T = c.length > o || b.length > o || F > t;
154
154
  if (T)
155
- c.forEach((a) => v.push({ type: "delete", token: a })), b.forEach((a) => v.push({ type: "insert", token: a }));
155
+ c.forEach((a) => m.push({ type: "delete", token: a })), b.forEach((a) => m.push({ type: "insert", token: a }));
156
156
  else {
157
157
  const a = Array.from({ length: c.length + 1 }, () => new Uint32Array(b.length + 1));
158
158
  for (let y = c.length - 1; y >= 0; y -= 1) {
@@ -162,14 +162,14 @@ function be(e, i, n, r, t, o) {
162
162
  }
163
163
  let h = 0, p = 0;
164
164
  for (; h < c.length && p < b.length; )
165
- c[h] === b[p] ? (v.push({ type: "equal", token: c[h] }), h += 1, p += 1) : a[h + 1][p] >= a[h][p + 1] ? (v.push({ type: "delete", token: c[h] }), h += 1) : (v.push({ type: "insert", token: b[p] }), p += 1);
165
+ c[h] === b[p] ? (m.push({ type: "equal", token: c[h] }), h += 1, p += 1) : a[h + 1][p] >= a[h][p + 1] ? (m.push({ type: "delete", token: c[h] }), h += 1) : (m.push({ type: "insert", token: b[p] }), p += 1);
166
166
  for (; h < c.length; )
167
- v.push({ type: "delete", token: c[h] }), h += 1;
167
+ m.push({ type: "delete", token: c[h] }), h += 1;
168
168
  for (; p < b.length; )
169
- v.push({ type: "insert", token: b[p] }), p += 1;
169
+ m.push({ type: "insert", token: b[p] }), p += 1;
170
170
  }
171
- g.forEach((a) => v.push({ type: "equal", token: a }));
172
- const q = ue(v, n, r);
171
+ g.forEach((a) => m.push({ type: "equal", token: a }));
172
+ const q = ue(m, n, r);
173
173
  let A = 0, L = 0, K = 0;
174
174
  return q.forEach((a) => {
175
175
  a.type === "insert" && (A += a.count), a.type === "delete" && (L += a.count), a.type === "equal" && (K += a.count);
@@ -188,7 +188,7 @@ function ee(e) {
188
188
  function he(e, i) {
189
189
  return e.length === 0 ? `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>` : e.map((n) => `<span class="${n.type === "equal" ? "rte-version-diff-equal" : n.type === "insert" ? "rte-version-diff-insert" : "rte-version-diff-delete"}">${ee(n)}</span>`).join("");
190
190
  }
191
- function me(e, i) {
191
+ function ve(e, i) {
192
192
  if (e.length === 0) {
193
193
  const t = `<p class="rte-version-diff-empty">${u(i.noChanges)}</p>`;
194
194
  return { baselineHtml: t, currentHtml: t };
@@ -210,7 +210,7 @@ function me(e, i) {
210
210
  currentHtml: r.join("")
211
211
  };
212
212
  }
213
- function ve(e) {
213
+ function me(e) {
214
214
  const i = e.metaKey || e.ctrlKey, r = (typeof e.key == "string" ? e.key : "").toLowerCase(), t = typeof e.code == "string" ? e.code.toLowerCase() : "", o = i && e.altKey && !e.shiftKey && (r === "d" || t === "keyd"), f = !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && (r === "f8" || t === "f8");
215
215
  return o || f;
216
216
  }
@@ -534,7 +534,7 @@ function xe(e) {
534
534
  )?.focus();
535
535
  }
536
536
  function ke(e, i) {
537
- if (e.key !== "Tab") return;
537
+ if (e.key !== "Tab" || e.defaultPrevented) return;
538
538
  const n = Array.from(i.querySelectorAll(
539
539
  'button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
540
540
  )).filter((f) => !f.hasAttribute("disabled"));
@@ -593,7 +593,7 @@ function re(e, i, n) {
593
593
  <button type="button" role="tab" class="rte-version-diff-tab" data-tab="side" aria-selected="false">${u(o.tabSideBySide)}</button>
594
594
  </div>
595
595
 
596
- <main class="rte-version-diff-body">
596
+ <div class="rte-version-diff-body">
597
597
  <div class="rte-version-diff-summary" aria-live="polite"></div>
598
598
  <section class="rte-version-diff-panel active" data-panel="inline" role="tabpanel">
599
599
  <div class="rte-version-diff-inline" aria-label="Inline diff result"></div>
@@ -610,7 +610,7 @@ function re(e, i, n) {
610
610
  </div>
611
611
  </div>
612
612
  </section>
613
- </main>
613
+ </div>
614
614
 
615
615
  <footer class="rte-version-diff-footer">
616
616
  <small>Shortcut: Ctrl/Cmd + Alt + D (fallback: F8)</small>
@@ -619,14 +619,14 @@ function re(e, i, n) {
619
619
  `, r.appendChild(t), document.body.appendChild(r);
620
620
  const b = t.querySelector(".rte-version-diff-select");
621
621
  b.value = f;
622
- const v = t.querySelector(".rte-version-diff-ignore-ws"), F = t.querySelector(".rte-version-diff-summary"), T = t.querySelector(".rte-version-diff-inline"), q = t.querySelector('[data-side="baseline"]'), A = t.querySelector('[data-side="current"]');
622
+ const m = t.querySelector(".rte-version-diff-ignore-ws"), F = t.querySelector(".rte-version-diff-summary"), T = t.querySelector(".rte-version-diff-inline"), q = t.querySelector('[data-side="baseline"]'), A = t.querySelector('[data-side="current"]');
623
623
  let L = 0;
624
624
  const K = () => {
625
625
  const s = `<p class="rte-version-diff-empty">${u(o.loading)}</p>`;
626
626
  T.innerHTML = s, q.innerHTML = s, A.innerHTML = s, F.textContent = "";
627
627
  }, a = async (s) => {
628
628
  L += 1;
629
- const m = L;
629
+ const v = L;
630
630
  r.classList.toggle("rte-version-diff-theme-dark", Y(e)), K();
631
631
  const k = e.innerHTML;
632
632
  let E = "";
@@ -635,7 +635,7 @@ function re(e, i, n) {
635
635
  } catch {
636
636
  E = w.get(e) ?? W(e);
637
637
  }
638
- if (m !== L || !r.isConnected) return;
638
+ if (v !== L || !r.isConnected) return;
639
639
  const ne = J(E), ie = J(k), oe = Q(ne, f, g), se = Q(ie, f, g), C = be(
640
640
  oe,
641
641
  se,
@@ -643,7 +643,7 @@ function re(e, i, n) {
643
643
  g,
644
644
  i.maxMatrixSize,
645
645
  i.maxTokens
646
- ), _ = me(C.segments, o);
646
+ ), _ = ve(C.segments, o);
647
647
  T.innerHTML = he(C.segments, o), q.innerHTML = _.baselineHtml, A.innerHTML = _.currentHtml;
648
648
  const G = [
649
649
  `+${C.insertedCount} inserted`,
@@ -652,11 +652,11 @@ function re(e, i, n) {
652
652
  ];
653
653
  C.usedFallback && G.push(o.largeDocFallback), F.textContent = G.join(" | ");
654
654
  }, h = (s) => {
655
- c = s, t.querySelectorAll(".rte-version-diff-tab").forEach((m) => {
656
- const k = m.getAttribute("data-tab") === s;
657
- m.setAttribute("aria-selected", k ? "true" : "false"), m.tabIndex = k ? 0 : -1;
658
- }), t.querySelectorAll(".rte-version-diff-panel").forEach((m) => {
659
- m.classList.toggle("active", m.getAttribute("data-panel") === s);
655
+ c = s, t.querySelectorAll(".rte-version-diff-tab").forEach((v) => {
656
+ const k = v.getAttribute("data-tab") === s;
657
+ v.setAttribute("aria-selected", k ? "true" : "false"), v.tabIndex = k ? 0 : -1;
658
+ }), t.querySelectorAll(".rte-version-diff-panel").forEach((v) => {
659
+ v.classList.toggle("active", v.getAttribute("data-panel") === s);
660
660
  });
661
661
  }, p = () => {
662
662
  r.removeEventListener("keydown", I, !0), r.removeEventListener("click", B), document.removeEventListener("keydown", y, !0), r.parentNode && r.parentNode.removeChild(r), z = null, e.focus({ preventScroll: !0 });
@@ -671,12 +671,12 @@ function re(e, i, n) {
671
671
  }
672
672
  if (ke(s, t), s.target && s.target.classList.contains("rte-version-diff-tab") && (s.key === "ArrowRight" || s.key === "ArrowLeft")) {
673
673
  s.preventDefault();
674
- const m = c === "inline" ? "side" : "inline";
675
- h(m), t.querySelector(`.rte-version-diff-tab[data-tab="${m}"]`)?.focus();
674
+ const v = c === "inline" ? "side" : "inline";
675
+ h(v), t.querySelector(`.rte-version-diff-tab[data-tab="${v}"]`)?.focus();
676
676
  }
677
677
  };
678
678
  t.addEventListener("click", (s) => {
679
- const m = s.target, k = m.getAttribute("data-action");
679
+ const v = s.target, k = v.getAttribute("data-action");
680
680
  if (k === "close") {
681
681
  p();
682
682
  return;
@@ -685,19 +685,19 @@ function re(e, i, n) {
685
685
  a();
686
686
  return;
687
687
  }
688
- const E = m.getAttribute("data-tab");
688
+ const E = v.getAttribute("data-tab");
689
689
  (E === "inline" || E === "side") && h(E);
690
690
  }), b.addEventListener("change", () => {
691
691
  f = b.value === "line" ? "line" : "word", a();
692
- }), v.addEventListener("change", () => {
693
- g = v.checked, a();
692
+ }), m.addEventListener("change", () => {
693
+ g = m.checked, a();
694
694
  }), t.querySelector(".rte-version-diff-set-baseline").addEventListener("click", () => {
695
695
  w.set(e, e.innerHTML), a(e.innerHTML);
696
696
  }), r.addEventListener("keydown", I, !0), r.addEventListener("click", B), document.addEventListener("keydown", y, !0), z = p, xe(t), a();
697
697
  }
698
698
  function Ee(e) {
699
699
  V = e, !H && (H = (i) => {
700
- if (!ve(i)) return;
700
+ if (!me(i)) return;
701
701
  if (document.querySelector(`.${l}`)) {
702
702
  i.preventDefault();
703
703
  return;
@@ -756,10 +756,10 @@ const Se = (e = {}) => {
756
756
  F8: "openVersionDiff"
757
757
  },
758
758
  init: () => {
759
- j += 1, Ee(i), Le();
759
+ P += 1, Ee(i), Le();
760
760
  },
761
761
  destroy: () => {
762
- j = Math.max(0, j - 1), j === 0 && (te(), we(), Ce());
762
+ P = Math.max(0, P - 1), P === 0 && (te(), we(), Ce());
763
763
  }
764
764
  };
765
765
  };
package/index.d.ts CHANGED
@@ -5,7 +5,6 @@ export interface ApiConfig {
5
5
  headers?: Record<string, string>;
6
6
  }
7
7
 
8
- export type MediaManagerConfig = Record<string, unknown>;
9
8
  export type DocumentManagerConfig = Record<string, unknown>;
10
9
 
11
10
  export interface MergeTagItem {
@@ -911,9 +910,191 @@ export function DocSchemaPlugin(options?: DocSchemaPluginOptions): Plugin;
911
910
  export function TranslationWorkflowPlugin(options?: TranslationWorkflowPluginOptions): Plugin;
912
911
  export function SlashCommandsPlugin(options?: SlashCommandsPluginOptions): Plugin;
913
912
 
914
- export function MediaManagerPlugin(): Plugin;
913
+ // ── Media manager ────────────────────────────────────────────────────────────────────────────
914
+ /** What an upload reports while it runs. `fraction` is 0..1. */
915
+ export interface UploadProgress {
916
+ loaded: number;
917
+ total: number;
918
+ fraction: number;
919
+ }
920
+
921
+ export interface UploadContext {
922
+ /** Aborted when the person cancels or closes the dialog; stop, and reject with an AbortError. */
923
+ signal?: AbortSignal;
924
+ onProgress?: (progress: UploadProgress) => void;
925
+ }
926
+
927
+ export interface MediaItem {
928
+ id: string;
929
+ name: string;
930
+ type: 'image' | 'video' | 'audio' | 'file';
931
+ /** The address the document will point at: an https URL, or a data URL when nothing is configured. */
932
+ src: string;
933
+ size: number;
934
+ width?: number;
935
+ height?: number;
936
+ duration?: number;
937
+ mime: string;
938
+ createdAt: number;
939
+ metadata: Record<string, any>;
940
+ thumbnailUrl?: string;
941
+ /** The description kept with the file in the library, offered as the alt text when it is inserted. */
942
+ alt?: string;
943
+ }
944
+
945
+ export interface MediaQuery {
946
+ page?: number;
947
+ limit?: number;
948
+ /** Free-text search over names and alt text. */
949
+ search?: string;
950
+ type?: MediaItem['type'];
951
+ folderId?: string | null;
952
+ /** The order of the listing (default `newest`). A provider that cannot sort may ignore it. */
953
+ sort?: 'newest' | 'oldest' | 'name';
954
+ }
955
+
956
+ export interface MediaPage {
957
+ items: MediaItem[];
958
+ total: number;
959
+ }
960
+
961
+ /** What can be changed about a file that is already in the library. */
962
+ export interface MediaUpdate {
963
+ name?: string;
964
+ alt?: string;
965
+ }
966
+
967
+ /**
968
+ * Where media goes and where the library comes from. Only `upload` is required; with `list` the picker has a library.
969
+ */
970
+ export interface MediaProvider {
971
+ readonly name?: string;
972
+ upload(file: File, context: UploadContext): Promise<MediaItem>;
973
+ list?(query?: MediaQuery, context?: { signal?: AbortSignal }): Promise<MediaPage>;
974
+ update?(id: string, updates: MediaUpdate): Promise<void>;
975
+ delete?(id: string): Promise<void>;
976
+ }
977
+
978
+ /** The shortest way to plug in a backend: receive the file, report progress, resolve with the URL. */
979
+ export type MediaUploadHandler = (
980
+ file: File,
981
+ context: UploadContext,
982
+ ) => Promise<string | { url: string; thumbnailUrl?: string; width?: number; height?: number; id?: string; name?: string }>;
983
+
984
+ /** A photo from a stock service, as the picker shows it. */
985
+ export interface StockPhoto {
986
+ id: string;
987
+ thumbnailUrl: string;
988
+ url: string;
989
+ width?: number;
990
+ height?: number;
991
+ /** What it shows, offered as the alt text. */
992
+ description?: string;
993
+ author?: string;
994
+ authorUrl?: string;
995
+ sourceUrl?: string;
996
+ }
997
+
998
+ /** Photos from a service such as Unsplash: you write `search` (calling your own backend); the picker shows a Stock tab. */
999
+ export interface StockProvider {
1000
+ name: string;
1001
+ search(
1002
+ query: { search: string; page: number; limit: number },
1003
+ context: { signal?: AbortSignal },
1004
+ ): Promise<{ items: StockPhoto[]; total?: number }>;
1005
+ /** The credit put under an inserted photo; by default "Photo by <author> on <name>". `false` for none. */
1006
+ caption?: false | ((photo: StockPhoto) => string | null);
1007
+ }
1008
+
1009
+ /** Describe a picture for people who cannot see it. The result fills the alt text field; it is never inserted on its own. */
1010
+ export type AltTextGenerator = (
1011
+ image: { src: string; name?: string },
1012
+ context: { signal?: AbortSignal },
1013
+ ) => Promise<string>;
1014
+
1015
+ /** What a link embeds as a player. */
1016
+ export interface EmbedSpec {
1017
+ provider: string;
1018
+ label: string;
1019
+ /** Always https. */
1020
+ src: string;
1021
+ /** Width over height. */
1022
+ aspectRatio: number;
1023
+ id: string;
1024
+ }
1025
+
1026
+ /** A service whose links can be embedded (YouTube and Vimeo are built in). `parse` must return an https address. */
1027
+ export interface EmbedProvider {
1028
+ id: string;
1029
+ label: string;
1030
+ parse(url: URL): { src: string; id: string; aspectRatio?: number } | null;
1031
+ }
1032
+
1033
+ export interface MediaManagerConfig {
1034
+ /** A complete provider. Wins over everything below. */
1035
+ provider?: MediaProvider;
1036
+ /** Upload callback; wrapped into a provider. Wins over `apiUrl`. */
1037
+ uploadHandler?: MediaUploadHandler;
1038
+ /** Base URL of a REST backend. Without it, and without a provider, files become data URLs. */
1039
+ apiUrl?: string;
1040
+ apiEndpoints?: { upload: string; library: string; delete: string };
1041
+ /** Extra request headers (authentication). */
1042
+ headers?: Record<string, string>;
1043
+ /** Send cookies with the upload request. */
1044
+ withCredentials?: boolean;
1045
+ /** Name of the multipart field that carries the file. Default `file`. */
1046
+ uploadFieldName?: string;
1047
+ /** Insert a data URL when an upload fails, instead of showing the error. Off by default. */
1048
+ fallbackToBase64?: boolean;
1049
+ /** More links that can be embedded as a player. */
1050
+ embedProviders?: EmbedProvider[];
1051
+ /** Photos from a stock service: adds a Stock tab to the image picker. */
1052
+ stockProvider?: StockProvider;
1053
+ /** Adds a Suggest button next to the alt text field. */
1054
+ generateAltText?: AltTextGenerator;
1055
+ /** Insert media as `<figure>` that can be aligned and captioned (default). `false` inserts a bare `<img>`/`<video>`. */
1056
+ wrapInFigure?: boolean;
1057
+ /** Put an Audio button in the toolbar. Off by default. */
1058
+ audio?: boolean;
1059
+ /** Upload images, videos and audio that are pasted or dropped into the editor (default `true`). */
1060
+ uploadOnPaste?: boolean;
1061
+ /** Keep a library of what is uploaded from this browser (IndexedDB) for providers that cannot list. Default `true`. */
1062
+ localLibrary?: boolean;
1063
+ /** Scale down and re-encode large JPEG, PNG and WebP files before they are stored. Off by default. */
1064
+ optimizeImages?: boolean | { maxWidth?: number; quality?: number; format?: 'keep' | 'webp' | 'jpeg' };
1065
+ /** Maximum file size in bytes (checked on the result when `optimizeImages` is on). */
1066
+ maxFileSize?: number;
1067
+ /** Allowed MIME types; `image/*` style wildcards work. */
1068
+ allowedTypes?: string[];
1069
+ }
1070
+
1071
+ export class MediaUploadError extends Error {
1072
+ readonly code: 'too-large' | 'type-not-allowed' | 'aborted' | 'network' | 'server' | 'invalid-response';
1073
+ readonly status?: number;
1074
+ constructor(code: MediaUploadError['code'], message: string, status?: number);
1075
+ }
1076
+
1077
+ export function createBase64Provider(): MediaProvider;
1078
+ export function createCallbackProvider(handler: MediaUploadHandler): MediaProvider;
1079
+ export function createRestProvider(options: {
1080
+ uploadUrl: string;
1081
+ libraryUrl?: string;
1082
+ deleteUrl?: string;
1083
+ headers?: () => Record<string, string>;
1084
+ withCredentials?: boolean;
1085
+ fieldName?: string;
1086
+ }): MediaProvider;
1087
+
1088
+ /** What a pasted link or iframe snippet embeds, or `null` when no provider knows it. */
1089
+ export function parseEmbedUrl(input: string, extra?: EmbedProvider[]): EmbedSpec | null;
1090
+
1091
+ /** Entries for `SlashCommandsPlugin({ items })`: `/image`, `/audio`, `/video`. */
1092
+ export const mediaSlashItems: Array<{ id: string; label: string; description?: string; command: string; keywords?: string[] }>;
1093
+
1094
+ export function MediaManagerPlugin(config?: Partial<MediaManagerConfig>): Plugin;
915
1095
  export function setMediaManagerConfig(config: Partial<MediaManagerConfig>): void;
916
1096
  export function getMediaManagerConfig(): MediaManagerConfig;
1097
+ // ─────────────────────────────────────────────────────────────────────────────────────────────
917
1098
 
918
1099
  export function DocumentManagerPlugin(): Plugin;
919
1100
  export function setDocumentManagerConfig(config: Partial<DocumentManagerConfig>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editora/plugins",
3
- "version": "1.0.22",
3
+ "version": "1.1.0",
4
4
  "description": "Enterprise plugin suite for Editora rich text editor in React and web apps, including tables, media, workflow, and compliance tooling.",
5
5
  "author": "Ajay Kumar <ajaykr089@gmail.com>",
6
6
  "license": "MIT",
@@ -423,6 +423,7 @@
423
423
  "dev": "vite build --watch",
424
424
  "clean": "rm -rf dist",
425
425
  "prepublishOnly": "npm run typecheck:build && npm run build",
426
+ "test:dom": "vitest run",
426
427
  "test:content-rules": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./content-rules/src/ContentRulesPlugin.native.test.js",
427
428
  "test:citations": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./citations/src/CitationsPlugin.native.test.js",
428
429
  "test:approval-workflow": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./approval-workflow/src/ApprovalWorkflowPlugin.native.test.js",
@@ -433,18 +434,18 @@
433
434
  "test:doc-schema": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./doc-schema/src/DocSchemaPlugin.native.test.js",
434
435
  "test:translation-workflow": "node ../../node_modules/jest/bin/jest.js -c ./jest.config.cjs --watchman=false --runTestsByPath ./translation-workflow/src/TranslationWorkflowPlugin.native.test.js",
435
436
  "test:format-painter": "node -r ../../node_modules/ts-node/register ./format-painter/src/FormatPainterPlugin.native.test.js",
436
- "verify:citations": "npm run typecheck:build && npm run test:citations && npm run test:content-rules && npm run test:approval-workflow && npm run test:pii-redaction && npm run test:smart-paste && npm run test:blocks-library && npm run test:doc-schema && npm run test:translation-workflow && npm run test:format-painter && npm run test:toolbar-icons && npm run build"
437
+ "verify:citations": "npm run typecheck:build && npm run test:citations && npm run test:content-rules && npm run test:approval-workflow && npm run test:pii-redaction && npm run test:smart-paste && npm run test:blocks-library && npm run test:doc-schema && npm run test:translation-workflow && npm run test:format-painter && npm run test:toolbar-icons && npm run test:dom && npm run build"
437
438
  },
438
439
  "peerDependencies": {
439
- "@editora/core": "^1.0.23"
440
+ "@editora/core": "^1.0.25"
440
441
  },
441
442
  "dependencies": {
442
- "@editora/light-code-editor": "^1.0.18",
443
+ "@editora/light-code-editor": "^1.0.19",
443
444
  "katex": "^0.16.27",
444
445
  "mathjax": "^3.2.2"
445
446
  },
446
447
  "devDependencies": {
447
- "@editora/core": "^1.0.23",
448
+ "@editora/core": "^1.0.25",
448
449
  "@types/katex": "^0.16.8",
449
450
  "dompurify": "^3.4.16",
450
451
  "typescript": "^5.0.0",
@@ -1 +0,0 @@
1
- "use strict";const b=require("./historyHelpers-Cu8Pk7m1.js"),p="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";function A(e){return!!e.cloneContents().querySelector(p)}function m(e,t){return(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest('[contenteditable="true"]')||t()?.querySelector('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')}function v(e,t){const n=m(e,t);n&&n.dispatchEvent(new Event("input",{bubbles:!0}))}function S(e,t){let o=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentElement:e.startContainer;for(;o&&o!==document.body;){if(o.classList.contains(t)){const r=document.createRange();if(r.selectNodeContents(o),r.compareBoundaryPoints(Range.START_TO_START,e)<=0&&r.compareBoundaryPoints(Range.END_TO_END,e)>=0)return o}o=o.parentElement}return null}function T(e){const t=window.getSelection(),n=e.savedRange?.commonAncestorContainer??(t&&t.rangeCount>0?t.getRangeAt(0).commonAncestorContainer:null),o=m(n,e.getActiveEditorRoot),r=o?o.innerHTML:null,l=L(e);return l&&o&&r!==null&&b.recordDomHistory(o,r),l}function L(e){try{if(e.savedRange){const c=window.getSelection();c&&(c.removeAllRanges(),c.addRange(e.savedRange.cloneRange()))}const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return!1;const n=t.getRangeAt(0);if(n.collapsed)return!1;const o=S(n,e.className);if(o)return e.styleProperty==="backgroundColor"?o.style.backgroundColor=e.color:o.style.color=e.color,v(o,e.getActiveEditorRoot),!0;m(n.commonAncestorContainer,e.getActiveEditorRoot)?.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}let l=!1;if(e.commands.forEach(c=>{l||(l=document.execCommand(c,!1,e.color))}),!l&&!A(n)){const c=document.createElement("span");e.styleProperty==="backgroundColor"?c.style.backgroundColor=e.color:c.style.color=e.color,c.className=e.className;const i=n.extractContents();c.appendChild(i),n.insertNode(c),n.setStartAfter(c),n.collapse(!0),t.removeAllRanges(),t.addRange(n),l=!0}return l?(v(n.commonAncestorContainer,e.getActiveEditorRoot),!0):(e.warnMessage&&console.warn(e.warnMessage),!1)}catch(t){return e.warnMessage?console.error(e.warnMessage,t):console.error("[ColorApply] Failed to apply color",t),!1}}function N({popover:e,anchor:t,onClose:n,gap:o=6,margin:r=8,zIndex:l=1e4}){e.style.position="fixed",e.style.zIndex=`${l}`,e.style.visibility="hidden";const c=()=>{if(!e.isConnected||!t.isConnected){n();return}const s=t.getBoundingClientRect();if(s.width===0&&s.height===0){n();return}const a=e.getBoundingClientRect(),g=a.width||e.offsetWidth||220,f=a.height||e.offsetHeight||260,w=window.innerWidth,E=window.innerHeight;let u=s.left,d=s.bottom+o;if(u+g>w-r&&(u=w-g-r),u=Math.max(r,u),d+f>E-r){const C=s.top-f-o;C>=r?d=C:d=Math.max(r,E-f-r)}d<r&&(d=r),e.style.left=`${Math.round(u)}px`,e.style.top=`${Math.round(d)}px`,e.style.visibility="visible"},i=()=>{c()},h=s=>{const a=s.target;a&&(e.contains(a)||t.contains(a)||n())},y=s=>{s.key==="Escape"&&n()};window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),document.addEventListener("keydown",y);const R=window.requestAnimationFrame(()=>{document.addEventListener("mousedown",h,!0)});return c(),{reposition:c,destroy:()=>{window.cancelAnimationFrame(R),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0),document.removeEventListener("keydown",y),document.removeEventListener("mousedown",h,!0)}}}exports.applyColorToSelection=T;exports.attachAnchoredPopover=N;
@@ -1,111 +0,0 @@
1
- import { r as b } from "./historyHelpers-BEKwNOtA.mjs";
2
- const A = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
3
- function p(e) {
4
- return !!e.cloneContents().querySelector(A);
5
- }
6
- function m(e, t) {
7
- return (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest('[contenteditable="true"]') || t()?.querySelector('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
8
- }
9
- function v(e, t) {
10
- const n = m(e, t);
11
- n && n.dispatchEvent(new Event("input", { bubbles: !0 }));
12
- }
13
- function S(e, t) {
14
- let o = e.startContainer.nodeType === Node.TEXT_NODE ? e.startContainer.parentElement : e.startContainer;
15
- for (; o && o !== document.body; ) {
16
- if (o.classList.contains(t)) {
17
- const r = document.createRange();
18
- if (r.selectNodeContents(o), r.compareBoundaryPoints(Range.START_TO_START, e) <= 0 && r.compareBoundaryPoints(Range.END_TO_END, e) >= 0)
19
- return o;
20
- }
21
- o = o.parentElement;
22
- }
23
- return null;
24
- }
25
- function M(e) {
26
- const t = window.getSelection(), n = e.savedRange?.commonAncestorContainer ?? (t && t.rangeCount > 0 ? t.getRangeAt(0).commonAncestorContainer : null), o = m(n, e.getActiveEditorRoot), r = o ? o.innerHTML : null, s = T(e);
27
- return s && o && r !== null && b(o, r), s;
28
- }
29
- function T(e) {
30
- try {
31
- if (e.savedRange) {
32
- const c = window.getSelection();
33
- c && (c.removeAllRanges(), c.addRange(e.savedRange.cloneRange()));
34
- }
35
- const t = window.getSelection();
36
- if (!t || t.rangeCount === 0 || t.isCollapsed)
37
- return !1;
38
- const n = t.getRangeAt(0);
39
- if (n.collapsed)
40
- return !1;
41
- const o = S(n, e.className);
42
- if (o)
43
- return e.styleProperty === "backgroundColor" ? o.style.backgroundColor = e.color : o.style.color = e.color, v(o, e.getActiveEditorRoot), !0;
44
- m(
45
- n.commonAncestorContainer,
46
- e.getActiveEditorRoot
47
- )?.focus({ preventScroll: !0 });
48
- try {
49
- document.execCommand("styleWithCSS", !1, "true");
50
- } catch {
51
- }
52
- let s = !1;
53
- if (e.commands.forEach((c) => {
54
- s || (s = document.execCommand(c, !1, e.color));
55
- }), !s && !p(n)) {
56
- const c = document.createElement("span");
57
- e.styleProperty === "backgroundColor" ? c.style.backgroundColor = e.color : c.style.color = e.color, c.className = e.className;
58
- const i = n.extractContents();
59
- c.appendChild(i), n.insertNode(c), n.setStartAfter(c), n.collapse(!0), t.removeAllRanges(), t.addRange(n), s = !0;
60
- }
61
- return s ? (v(n.commonAncestorContainer, e.getActiveEditorRoot), !0) : (e.warnMessage && console.warn(e.warnMessage), !1);
62
- } catch (t) {
63
- return e.warnMessage ? console.error(e.warnMessage, t) : console.error("[ColorApply] Failed to apply color", t), !1;
64
- }
65
- }
66
- function k({
67
- popover: e,
68
- anchor: t,
69
- onClose: n,
70
- gap: o = 6,
71
- margin: r = 8,
72
- zIndex: s = 1e4
73
- }) {
74
- e.style.position = "fixed", e.style.zIndex = `${s}`, e.style.visibility = "hidden";
75
- const c = () => {
76
- if (!e.isConnected || !t.isConnected) {
77
- n();
78
- return;
79
- }
80
- const l = t.getBoundingClientRect();
81
- if (l.width === 0 && l.height === 0) {
82
- n();
83
- return;
84
- }
85
- const a = e.getBoundingClientRect(), w = a.width || e.offsetWidth || 220, f = a.height || e.offsetHeight || 260, y = window.innerWidth, E = window.innerHeight;
86
- let u = l.left, d = l.bottom + o;
87
- if (u + w > y - r && (u = y - w - r), u = Math.max(r, u), d + f > E - r) {
88
- const C = l.top - f - o;
89
- C >= r ? d = C : d = Math.max(r, E - f - r);
90
- }
91
- d < r && (d = r), e.style.left = `${Math.round(u)}px`, e.style.top = `${Math.round(d)}px`, e.style.visibility = "visible";
92
- }, i = () => {
93
- c();
94
- }, h = (l) => {
95
- const a = l.target;
96
- a && (e.contains(a) || t.contains(a) || n());
97
- }, g = (l) => {
98
- l.key === "Escape" && n();
99
- };
100
- window.addEventListener("resize", i), window.addEventListener("scroll", i, !0), document.addEventListener("keydown", g);
101
- const R = window.requestAnimationFrame(() => {
102
- document.addEventListener("mousedown", h, !0);
103
- });
104
- return c(), { reposition: c, destroy: () => {
105
- window.cancelAnimationFrame(R), window.removeEventListener("resize", i), window.removeEventListener("scroll", i, !0), document.removeEventListener("keydown", g), document.removeEventListener("mousedown", h, !0);
106
- } };
107
- }
108
- export {
109
- M as a,
110
- k as b
111
- };
@@ -1,39 +0,0 @@
1
- function n(e) {
2
- let i = !1;
3
- e.addEventListener(
4
- "pointerdown",
5
- (t) => {
6
- i = t.target !== e;
7
- },
8
- !0
9
- ), e.addEventListener(
10
- "click",
11
- (t) => {
12
- t.target === e && i && t.stopImmediatePropagation(), i = !1;
13
- },
14
- !0
15
- );
16
- }
17
- const a = "rte-dialog-base-styles";
18
- function o() {
19
- if (typeof document > "u" || document.getElementById(a)) return;
20
- const e = document.createElement("style");
21
- e.id = a, e.textContent = `
22
- [data-rte-dialog] {
23
- font-family: var(--rte-font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
24
- }
25
-
26
- /* Form controls ignore inherited fonts (browsers default them to Arial /
27
- system-ui). :where() keeps this at zero specificity so any control a plugin
28
- styles explicitly - e.g. a monospace formula field - keeps its own font. */
29
- :where([data-rte-dialog]) :where(button, input, select, textarea) {
30
- font-family: inherit;
31
- }
32
- `, document.head.appendChild(e);
33
- }
34
- function s(e) {
35
- e.setAttribute("data-rte-dialog", ""), o(), n(e);
36
- }
37
- export {
38
- s as i
39
- };
@@ -1,12 +0,0 @@
1
- "use strict";function n(e){let i=!1;e.addEventListener("pointerdown",t=>{i=t.target!==e},!0),e.addEventListener("click",t=>{t.target===e&&i&&t.stopImmediatePropagation(),i=!1},!0)}const a="rte-dialog-base-styles";function o(){if(typeof document>"u"||document.getElementById(a))return;const e=document.createElement("style");e.id=a,e.textContent=`
2
- [data-rte-dialog] {
3
- font-family: var(--rte-font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
4
- }
5
-
6
- /* Form controls ignore inherited fonts (browsers default them to Arial /
7
- system-ui). :where() keeps this at zero specificity so any control a plugin
8
- styles explicitly - e.g. a monospace formula field - keeps its own font. */
9
- :where([data-rte-dialog]) :where(button, input, select, textarea) {
10
- font-family: inherit;
11
- }
12
- `,document.head.appendChild(e)}function s(e){e.setAttribute("data-rte-dialog",""),o(),n(e)}exports.initDialogOverlay=s;