@editora/plugins 1.0.22 → 1.0.23

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 (99) hide show
  1. package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-DESvGCrJ.mjs} +61 -53
  2. package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-DJqwsRPZ.js} +11 -11
  3. package/dist/a11y-checker.cjs.js +3 -3
  4. package/dist/a11y-checker.esm.js +6 -4
  5. package/dist/anchor.cjs.js +4 -4
  6. package/dist/anchor.esm.js +19 -18
  7. package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
  8. package/dist/anchoredPopover-Cygmit_o.js +1 -0
  9. package/dist/approval-workflow.cjs.js +7 -7
  10. package/dist/approval-workflow.esm.js +55 -54
  11. package/dist/background-color.cjs.js +2 -2
  12. package/dist/background-color.esm.js +72 -67
  13. package/dist/blocks-library.cjs.js +18 -19
  14. package/dist/blocks-library.esm.js +41 -42
  15. package/dist/citations.cjs.js +4 -4
  16. package/dist/citations.esm.js +50 -50
  17. package/dist/code-sample.cjs.js +10 -10
  18. package/dist/code-sample.esm.js +4 -4
  19. package/dist/code.cjs.js +1 -1
  20. package/dist/code.esm.js +1 -1
  21. package/dist/comments.cjs.js +23 -11
  22. package/dist/comments.esm.js +167 -149
  23. package/dist/conditional-content.cjs.js +2 -2
  24. package/dist/conditional-content.esm.js +2 -2
  25. package/dist/confirmDialog-6BPaNPis.mjs +106 -0
  26. package/dist/confirmDialog-C4UWENes.js +46 -0
  27. package/dist/content-rules.cjs.js +6 -6
  28. package/dist/content-rules.esm.js +51 -51
  29. package/dist/data-binding.cjs.js +2 -2
  30. package/dist/data-binding.esm.js +2 -2
  31. package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
  32. package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
  33. package/dist/document-manager.cjs.js +1 -1
  34. package/dist/document-manager.esm.js +1 -1
  35. package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
  36. package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
  37. package/dist/embed-iframe.cjs.js +6 -6
  38. package/dist/embed-iframe.esm.js +6 -6
  39. package/dist/emojis.cjs.js +5 -5
  40. package/dist/emojis.esm.js +3 -3
  41. package/dist/enterprise.cjs.js +1 -1
  42. package/dist/enterprise.esm.js +1 -1
  43. package/dist/format-painter.cjs.js +1 -1
  44. package/dist/format-painter.esm.js +172 -151
  45. package/dist/heading.cjs.js +1 -1
  46. package/dist/heading.esm.js +96 -83
  47. package/dist/history.cjs.js +1 -1
  48. package/dist/history.esm.js +176 -97
  49. package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
  50. package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
  51. package/dist/index.cjs.js +1 -1
  52. package/dist/index.esm.js +2 -2
  53. package/dist/katex-Cc3-mvOY.js +257 -0
  54. package/dist/katex-DoRnZ_sp.mjs +11682 -0
  55. package/dist/katex.min--Ws3c9be.mjs +5 -0
  56. package/dist/katex.min-Dk2VscxB.js +2 -0
  57. package/dist/link.cjs.js +3 -3
  58. package/dist/link.esm.js +3 -3
  59. package/dist/list.cjs.js +1 -1
  60. package/dist/list.esm.js +140 -52
  61. package/dist/math.cjs.js +14 -14
  62. package/dist/math.esm.js +149 -136
  63. package/dist/media-manager.cjs.js +46 -46
  64. package/dist/media-manager.esm.js +320 -264
  65. package/dist/mentions.cjs.js +12 -12
  66. package/dist/mentions.esm.js +149 -143
  67. package/dist/merge-tag.cjs.js +5 -3
  68. package/dist/merge-tag.esm.js +5 -3
  69. package/dist/notify-BkbzMopb.js +32 -0
  70. package/dist/notify-zOp-mUOJ.mjs +59 -0
  71. package/dist/pii-redaction.cjs.js +1 -1
  72. package/dist/pii-redaction.esm.js +1 -1
  73. package/dist/preview.cjs.js +1 -1
  74. package/dist/preview.esm.js +1 -1
  75. package/dist/shared-config.cjs.js +1 -1
  76. package/dist/shared-config.esm.js +14 -14
  77. package/dist/slash-commands.cjs.js +5 -5
  78. package/dist/slash-commands.esm.js +259 -236
  79. package/dist/smart-paste.cjs.js +1 -1
  80. package/dist/smart-paste.esm.js +1 -1
  81. package/dist/special-characters.cjs.js +3 -3
  82. package/dist/special-characters.esm.js +3 -3
  83. package/dist/spell-check.cjs.js +9 -9
  84. package/dist/spell-check.esm.js +288 -251
  85. package/dist/table.cjs.js +14 -14
  86. package/dist/table.esm.js +175 -154
  87. package/dist/template.cjs.js +5 -3
  88. package/dist/template.esm.js +15 -13
  89. package/dist/text-color.cjs.js +4 -4
  90. package/dist/text-color.esm.js +38 -34
  91. package/dist/translation-workflow.cjs.js +9 -9
  92. package/dist/translation-workflow.esm.js +98 -95
  93. package/dist/version-diff.cjs.js +4 -4
  94. package/dist/version-diff.esm.js +36 -36
  95. package/package.json +6 -5
  96. package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
  97. package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
  98. package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
  99. package/dist/dialogHelpers-zU6zpMIA.js +0 -12
package/dist/math.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import { e as K } from "./escapeHtml-DyksyvcZ.mjs";
2
- import { i as U } from "./dialogHelpers-5d5BuOCW.mjs";
3
- const W = {
1
+ import { e as q } from "./escapeHtml-DyksyvcZ.mjs";
2
+ import { i as Q } from "./dialogHelpers-BbwpIXD9.mjs";
3
+ const V = {
4
4
  latex: [
5
5
  { name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },
6
6
  { name: "Square Root", formula: "\\sqrt{x}", description: "Square root" },
@@ -21,8 +21,10 @@ const W = {
21
21
  { name: "Parentheses", formula: '<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>', description: "Grouped expression" }
22
22
  ]
23
23
  };
24
- let $ = null, S = null, H = !1, y = null, m = null;
25
- const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */ new Set([
24
+ let S = null, A = null, v = null, L = null;
25
+ const I = "0.16.9";
26
+ let y = null, m = null;
27
+ const T = '[data-theme="dark"], .dark, .editora-theme-dark', J = /* @__PURE__ */ new Set([
26
28
  "math",
27
29
  "mrow",
28
30
  "mi",
@@ -54,7 +56,7 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
54
56
  "none",
55
57
  "semantics",
56
58
  "annotation"
57
- ]), G = /* @__PURE__ */ new Set([
59
+ ]), Y = /* @__PURE__ */ new Set([
58
60
  "display",
59
61
  "displaystyle",
60
62
  "mathvariant",
@@ -96,44 +98,54 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
96
98
  "dir",
97
99
  "class",
98
100
  "id"
99
- ]), L = (e) => {
101
+ ]), B = (e) => {
100
102
  const t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), r = (l) => {
101
- Array.from(l.childNodes).forEach((a) => {
102
- if (a.nodeType === Node.ELEMENT_NODE) {
103
- const n = a;
104
- if (!X.has(n.localName.toLowerCase())) {
103
+ Array.from(l.childNodes).forEach((i) => {
104
+ if (i.nodeType === Node.ELEMENT_NODE) {
105
+ const n = i;
106
+ if (!J.has(n.localName.toLowerCase())) {
105
107
  n.remove();
106
108
  return;
107
109
  }
108
110
  Array.from(n.attributes).forEach((c) => {
109
- G.has(c.name.toLowerCase()) || n.removeAttribute(c.name);
111
+ Y.has(c.name.toLowerCase()) || n.removeAttribute(c.name);
110
112
  }), r(n);
111
- } else a.nodeType !== Node.TEXT_NODE && a.parentNode?.removeChild(a);
113
+ } else i.nodeType !== Node.TEXT_NODE && i.parentNode?.removeChild(i);
112
114
  });
113
115
  };
114
116
  return r(t.body), t.body.innerHTML;
115
- }, Z = () => new Promise((e, t) => {
116
- if (window.katex) {
117
- e(window.katex);
118
- return;
117
+ }, H = () => window.katex ?? v, P = (e, t) => {
118
+ if (e && !document.getElementById("rte-katex-layout")) {
119
+ const l = document.createElement("style");
120
+ l.id = "rte-katex-layout", l.textContent = e.replace(/@font-face\s*\{[^}]*\}/g, ""), document.head.appendChild(l);
119
121
  }
120
- if (H) {
121
- const a = setInterval(() => {
122
- window.katex && (clearInterval(a), e(window.katex));
123
- }, 100);
124
- return;
125
- }
126
- H = !0;
122
+ if (document.querySelector('link[data-rte-katex-css], link[href*="katex"][rel="stylesheet"]')) return;
127
123
  const r = document.createElement("link");
128
- r.rel = "stylesheet", r.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(r);
129
- const l = document.createElement("script");
130
- l.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", l.onload = () => e(window.katex), l.onerror = t, document.head.appendChild(l);
131
- }), _ = () => {
124
+ r.rel = "stylesheet", r.href = `https://cdn.jsdelivr.net/npm/katex@${t}/dist/katex.min.css`, r.setAttribute("data-rte-katex-css", ""), document.head.appendChild(r);
125
+ };
126
+ let C = null;
127
+ const ee = () => {
128
+ const e = H();
129
+ return e ? (P(C, e.version ?? I), Promise.resolve(e)) : (L || (L = (async () => {
130
+ try {
131
+ const t = await import("./katex-DoRnZ_sp.mjs");
132
+ v = t.default ?? t;
133
+ } catch {
134
+ v = null;
135
+ }
136
+ try {
137
+ C = (await import("./katex.min--Ws3c9be.mjs")).default;
138
+ } catch {
139
+ C = null;
140
+ }
141
+ return P(C, v?.version ?? I), v || (L = null), v;
142
+ })()), L);
143
+ }, j = () => {
132
144
  const e = window.getSelection();
133
145
  if (!e || e.rangeCount === 0) return null;
134
146
  const t = e.getRangeAt(0).startContainer;
135
147
  return (t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement)?.closest(".rte-content, .editora-content") || null;
136
- }, Q = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, z = (e) => Q(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]') || null, J = (e, t, r) => {
148
+ }, te = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, F = (e) => te(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]') || null, ne = (e, t, r) => {
137
149
  if (t !== r) {
138
150
  if (typeof window.execEditorCommand == "function") {
139
151
  window.execEditorCommand("recordDomTransaction", e, t, r);
@@ -145,39 +157,39 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
145
157
  } catch {
146
158
  }
147
159
  }
148
- }, V = (e) => {
160
+ }, oe = (e) => {
149
161
  if (!(e instanceof Element)) return null;
150
162
  const t = e.closest(".math-formula, .math-block");
151
163
  return t instanceof HTMLElement ? t : null;
152
164
  }, h = () => {
153
165
  m && (m.classList.remove("math-object-selected"), m.removeAttribute("data-rte-selected-object"), m = null);
154
- }, Y = (e) => {
166
+ }, re = (e) => {
155
167
  if (m === e) return;
156
168
  h(), m = e, e.classList.add("math-object-selected"), e.setAttribute("data-rte-selected-object", "true");
157
169
  const t = window.getSelection();
158
170
  if (!t) return;
159
171
  const r = document.createRange();
160
172
  r.selectNode(e), t.removeAllRanges(), t.addRange(r);
161
- }, ee = (e, t) => {
173
+ }, ae = (e, t) => {
162
174
  const r = window.getSelection();
163
175
  if (!r) return;
164
176
  const l = document.createRange();
165
177
  t && t.parentNode === e ? l.setStartBefore(t) : (l.selectNodeContents(e), l.collapse(!1)), l.collapse(!0), r.removeAllRanges(), r.addRange(l);
166
- }, te = (e) => {
178
+ }, ie = (e) => {
167
179
  if (e.childNodes.length > 0) return;
168
180
  const t = document.createElement("p");
169
181
  t.appendChild(document.createElement("br")), e.appendChild(t);
170
- }, ne = () => {
182
+ }, le = () => {
171
183
  if (!m || !m.isConnected)
172
184
  return h(), !1;
173
- const e = m, t = z(e);
185
+ const e = m, t = F(e);
174
186
  if (!t)
175
187
  return h(), !1;
176
188
  const r = t.innerHTML, l = e.nextSibling;
177
- e.remove(), te(t), h(), ee(t, l);
178
- const a = t.innerHTML;
179
- return J(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
180
- }, oe = () => {
189
+ e.remove(), ie(t), h(), ae(t, l);
190
+ const i = t.innerHTML;
191
+ return ne(t, r, i), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== i;
192
+ }, se = () => {
181
193
  if (document.getElementById("math-object-selection-styles")) return;
182
194
  const e = document.createElement("style");
183
195
  e.id = "math-object-selection-styles", e.textContent = `
@@ -187,42 +199,42 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
187
199
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
188
200
  }
189
201
  `, document.head.appendChild(e);
190
- }, re = () => {
191
- typeof window > "u" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, oe(), document.addEventListener("pointerdown", (e) => {
192
- const t = V(e.target);
202
+ }, ce = () => {
203
+ typeof window > "u" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, se(), document.addEventListener("pointerdown", (e) => {
204
+ const t = oe(e.target);
193
205
  if (!t) {
194
206
  e.target?.closest?.(".math-dialog-overlay") || h();
195
207
  return;
196
208
  }
197
- e.preventDefault(), z(t)?.focus(), Y(t);
209
+ e.preventDefault(), F(t)?.focus(), re(t);
198
210
  }, !0), document.addEventListener("keydown", (e) => {
199
211
  if (m) {
200
212
  if (e.key === "Escape") {
201
213
  h();
202
214
  return;
203
215
  }
204
- e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), ne());
216
+ e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), le());
205
217
  }
206
218
  }, !0));
207
- }, ae = (e) => {
208
- if ((e || _())?.closest(k)) return !0;
219
+ }, de = (e) => {
220
+ if ((e || j())?.closest(T)) return !0;
209
221
  const r = window.getSelection();
210
222
  if (r && r.rangeCount > 0) {
211
- const a = r.getRangeAt(0).startContainer;
212
- if ((a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement)?.closest(k)) return !0;
223
+ const i = r.getRangeAt(0).startContainer;
224
+ if ((i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement)?.closest(T)) return !0;
213
225
  }
214
- return document.activeElement?.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
215
- }, R = async (e, t) => {
226
+ return document.activeElement?.closest(T) ? !0 : document.body.matches(T) || document.documentElement.matches(T);
227
+ }, O = async (e, t) => {
216
228
  document.querySelectorAll(".math-dialog-overlay").forEach((o) => o.remove());
217
- const r = t || S?.closest(".rte-content, .editora-content") || _() || y;
229
+ const r = t || A?.closest(".rte-content, .editora-content") || j() || y;
218
230
  y = r || null;
219
231
  const l = window.getSelection();
220
232
  if (l && l.rangeCount > 0) {
221
233
  const o = l.getRangeAt(0);
222
- $ = r && r.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
234
+ S = r && r.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
223
235
  }
224
- await Z();
225
- const a = ae(r), n = a ? {
236
+ await ee();
237
+ const i = de(r), n = i ? {
226
238
  overlay: "rgba(0, 0, 0, 0.62)",
227
239
  dialogBg: "#1f2937",
228
240
  border: "#3b4657",
@@ -251,13 +263,13 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
251
263
  fieldBg: "#ffffff",
252
264
  fieldBorder: "#ced4da",
253
265
  text: "#1f2937",
254
- muted: "#6c757d",
266
+ muted: "#5c636a",
255
267
  templateBtnBg: "#ffffff",
256
268
  templateBtnHover: "#f8f9fa",
257
269
  templateBtnText: "#1f2937",
258
- templateSubText: "#6c757d",
270
+ templateSubText: "#5c636a",
259
271
  previewBg: "#f8f9fa",
260
- previewText: "#6c757d",
272
+ previewText: "#5c636a",
261
273
  cancelBg: "#ffffff",
262
274
  cancelText: "#1f2937",
263
275
  cancelBorder: "#ced4da",
@@ -265,12 +277,12 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
265
277
  insertHover: "#0069d9",
266
278
  invalid: "#cc0000"
267
279
  }, c = document.createElement("div");
268
- U(c), c.className = "math-dialog-overlay", c.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${n.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
280
+ Q(c), c.className = "math-dialog-overlay", c.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${n.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
269
281
  const d = document.createElement("div");
270
282
  d.style.cssText = `background: ${n.dialogBg}; border: 1px solid ${n.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${n.text};`;
271
- let u = e?.format || "latex", B = e?.formula || "";
272
- const j = e?.inline !== !1;
273
- let b = null, C = "";
283
+ let u = e?.format || "latex", N = e?.formula || "";
284
+ const K = e?.inline !== !1;
285
+ let x = null, D = "";
274
286
  d.innerHTML = `
275
287
  <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${n.border}; background: ${n.panelBg};">
276
288
  <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${n.text};">${e ? "Edit" : "Insert"} Math Formula</h2>
@@ -279,30 +291,30 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
279
291
 
280
292
  <div style="padding: 20px; overflow-y: auto; flex: 1;">
281
293
  <div style="margin-bottom: 20px;">
282
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Format:</label>
283
- <div style="display: flex; gap: 16px;">
294
+ <span id="math-format-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Format:</span>
295
+ <div role="radiogroup" aria-labelledby="math-format-label" style="display: flex; gap: 16px;">
284
296
  <label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="latex" ${u === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
285
297
  <label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="mathml" ${u === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
286
298
  </div>
287
299
  </div>
288
300
 
289
301
  <div style="margin-bottom: 20px;">
290
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Quick Templates:</label>
291
- <div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto;"></div>
302
+ <span id="math-templates-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Quick Templates:</span>
303
+ <div id="templates-grid" role="group" aria-labelledby="math-templates-label" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;"></div>
292
304
  </div>
293
305
 
294
306
  <div style="margin-bottom: 20px;">
295
- <label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${j ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
307
+ <label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${K ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
296
308
  </div>
297
309
 
298
310
  <div style="margin-bottom: 20px;">
299
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Formula:</label>
300
- <textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${n.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${n.fieldBg}; color: ${n.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${K(B)}</textarea>
311
+ <label for="formula-input" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Formula:</label>
312
+ <textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${n.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${n.fieldBg}; color: ${n.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${q(N)}</textarea>
301
313
  </div>
302
314
 
303
315
  <div style="margin-bottom: 20px;">
304
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Preview:</label>
305
- <div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${n.fieldBorder}; border-radius: 4px; background: ${n.previewBg}; display: flex; align-items: center; justify-content: center; color: ${n.previewText};"></div>
316
+ <span id="math-preview-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Preview:</span>
317
+ <div id="preview-area" role="status" aria-labelledby="math-preview-label" style="min-height: 60px; padding: 15px; border: 1px solid ${n.fieldBorder}; border-radius: 4px; background: ${n.previewBg}; display: flex; align-items: center; justify-content: center; color: ${n.previewText};"></div>
306
318
  </div>
307
319
  </div>
308
320
 
@@ -311,128 +323,129 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
311
323
  <button id="insert-btn" style="padding: 10px 20px; background: ${n.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${e ? "Update" : "Insert"}</button>
312
324
  </div>
313
325
  `, c.appendChild(d), document.body.appendChild(c);
314
- const p = d.querySelector("#formula-input"), v = d.querySelector("#preview-area"), T = d.querySelector("#templates-grid"), I = d.querySelectorAll('input[name="format"]'), q = d.querySelector("#inline-cb"), f = d.querySelector("#insert-btn"), g = d.querySelector(".close-btn"), w = d.querySelector(".cancel-btn"), P = (o) => encodeURIComponent(o), F = (o) => {
326
+ const p = d.querySelector("#formula-input"), w = d.querySelector("#preview-area"), M = d.querySelector("#templates-grid"), X = d.querySelectorAll('input[name="format"]'), U = d.querySelector("#inline-cb"), f = d.querySelector("#insert-btn"), g = d.querySelector(".close-btn"), E = d.querySelector(".cancel-btn"), W = (o) => encodeURIComponent(o), G = (o) => {
315
327
  try {
316
328
  return decodeURIComponent(o);
317
329
  } catch {
318
330
  return o;
319
331
  }
320
- }, A = () => {
321
- const o = W[u];
322
- T.innerHTML = o.map((s) => `
323
- <button type="button" data-formula="${P(s.formula)}" title="${s.description}" style="padding: 8px; border: 1px solid ${n.fieldBorder}; border-radius: 4px; background: ${n.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
332
+ }, _ = () => {
333
+ const o = V[u];
334
+ M.innerHTML = o.map((s) => `
335
+ <button type="button" data-formula="${W(s.formula)}" title="${s.description}" style="padding: 8px; border: 1px solid ${n.fieldBorder}; border-radius: 4px; background: ${n.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
324
336
  <div style="font-weight: 600; font-size: 12px; color: ${n.templateBtnText};">${s.name}</div>
325
337
  <div style="font-size: 10px; color: ${n.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${s.formula.substring(0, 20)}...</div>
326
338
  </button>
327
339
  `).join("");
328
- }, O = () => {
340
+ }, Z = () => {
329
341
  const o = p.value.trim(), s = `${u}:${o}`;
330
- if (s !== C) {
331
- if (C = s, !o) {
332
- v.innerHTML = `<span style="color: ${n.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
342
+ if (s !== D) {
343
+ if (D = s, !o) {
344
+ w.innerHTML = `<span style="color: ${n.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
333
345
  return;
334
346
  }
335
347
  f.disabled = !1;
336
348
  try {
337
349
  if (u === "latex") {
338
- const i = window.katex;
339
- v.innerHTML = i.renderToString(o, { displayMode: !1, throwOnError: !1 });
350
+ const a = H();
351
+ w.innerHTML = a ? a.renderToString(o, { displayMode: !1, throwOnError: !1 }) : `<code style="font-family: 'Courier New', monospace; color: ${n.previewText};">${q(o)}</code>`;
340
352
  } else
341
- o.trim().startsWith("<math") ? v.innerHTML = L(o) : v.innerHTML = L(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${o}</math>`);
353
+ o.trim().startsWith("<math") ? w.innerHTML = B(o) : w.innerHTML = B(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${o}</math>`);
342
354
  } catch {
343
- v.innerHTML = `<span style="color: ${n.invalid};">Invalid formula</span>`;
355
+ w.innerHTML = `<span style="color: ${n.invalid};">Invalid formula</span>`;
344
356
  }
345
357
  }
346
- }, M = () => {
347
- b !== null && cancelAnimationFrame(b), b = requestAnimationFrame(() => {
348
- b = null, O();
358
+ }, $ = () => {
359
+ x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
360
+ x = null, Z();
349
361
  });
350
- }, N = (o) => {
351
- o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), E());
352
- }, E = () => {
353
- document.removeEventListener("keydown", N, !0), b !== null && (cancelAnimationFrame(b), b = null), c.parentNode && c.parentNode.removeChild(c);
362
+ }, z = (o) => {
363
+ o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), k());
364
+ }, k = () => {
365
+ document.removeEventListener("keydown", z, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
354
366
  };
355
367
  g.onmouseover = () => {
356
- g.style.color = "#f8fafc", g.style.background = a ? "#334155" : "#e5e7eb", g.style.borderRadius = "4px";
368
+ g.style.color = "#f8fafc", g.style.background = i ? "#334155" : "#e5e7eb", g.style.borderRadius = "4px";
357
369
  }, g.onmouseout = () => {
358
370
  g.style.color = n.muted, g.style.background = "none";
359
- }, w.onmouseover = () => {
360
- w.style.background = a ? "#475569" : "#f3f4f6";
361
- }, w.onmouseout = () => {
362
- w.style.background = n.cancelBg;
371
+ }, E.onmouseover = () => {
372
+ E.style.background = i ? "#475569" : "#f3f4f6";
373
+ }, E.onmouseout = () => {
374
+ E.style.background = n.cancelBg;
363
375
  }, f.onmouseover = () => {
364
376
  f.disabled || (f.style.background = n.insertHover);
365
377
  }, f.onmouseout = () => {
366
378
  f.style.background = n.insertBg;
367
- }, T.addEventListener("mouseover", (o) => {
368
- const i = o.target.closest("button[data-formula]");
369
- i && (i.style.background = n.templateBtnHover);
370
- }), T.addEventListener("mouseout", (o) => {
371
- const i = o.target.closest("button[data-formula]");
372
- i && (i.style.background = n.templateBtnBg);
373
- }), T.addEventListener("click", (o) => {
374
- const i = o.target.closest("button[data-formula]");
375
- i && (p.value = F(i.getAttribute("data-formula") || ""), B = p.value, M());
379
+ }, M.addEventListener("mouseover", (o) => {
380
+ const a = o.target.closest("button[data-formula]");
381
+ a && (a.style.background = n.templateBtnHover);
382
+ }), M.addEventListener("mouseout", (o) => {
383
+ const a = o.target.closest("button[data-formula]");
384
+ a && (a.style.background = n.templateBtnBg);
385
+ }), M.addEventListener("click", (o) => {
386
+ const a = o.target.closest("button[data-formula]");
387
+ a && (p.value = G(a.getAttribute("data-formula") || ""), N = p.value, $());
376
388
  });
377
- const D = () => {
389
+ const R = () => {
378
390
  const o = p.value.trim();
379
391
  if (!o) return;
380
- const s = { formula: o, format: u, inline: q.checked }, i = s.inline ? document.createElement("span") : document.createElement("div");
381
- if (i.className = s.inline ? "math-formula" : "math-block", i.setAttribute("data-math-formula", o), i.setAttribute("data-math-format", u), i.contentEditable = "false", i.style.cssText = s.inline ? "background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;" : "background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;", u === "latex") {
382
- const x = window.katex;
392
+ const s = { formula: o, format: u, inline: U.checked }, a = s.inline ? document.createElement("span") : document.createElement("div");
393
+ if (a.className = s.inline ? "math-formula" : "math-block", a.setAttribute("data-math-formula", o), a.setAttribute("data-math-format", u), a.contentEditable = "false", a.style.cssText = s.inline ? "background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;" : "background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;", u === "latex") {
394
+ const b = H();
383
395
  try {
384
- i.innerHTML = x.renderToString(o, {
396
+ if (!b) throw new Error("KaTeX is not available");
397
+ a.innerHTML = b.renderToString(o, {
385
398
  displayMode: !s.inline,
386
399
  throwOnError: !1
387
400
  });
388
401
  } catch {
389
- i.textContent = s.inline ? `$${o}$` : `$$${o}$$`;
402
+ a.textContent = s.inline ? `$${o}$` : `$$${o}$$`;
390
403
  }
391
404
  } else if (o.trim().startsWith("<math"))
392
- i.innerHTML = L(o);
405
+ a.innerHTML = B(o);
393
406
  else {
394
- const x = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${s.inline ? "inline" : "block"}">${o}</math>`;
395
- i.innerHTML = L(x);
407
+ const b = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${s.inline ? "inline" : "block"}">${o}</math>`;
408
+ a.innerHTML = B(b);
396
409
  }
397
- if (S)
398
- S.replaceWith(i);
399
- else if ($)
400
- $.deleteContents(), $.insertNode(i);
410
+ if (A)
411
+ A.replaceWith(a);
412
+ else if (S)
413
+ S.deleteContents(), S.insertNode(a);
401
414
  else if (y && y.isConnected) {
402
- const x = document.createRange();
403
- x.selectNodeContents(y), x.collapse(!1), x.insertNode(i);
415
+ const b = document.createRange();
416
+ b.selectNodeContents(y), b.collapse(!1), b.insertNode(a);
404
417
  }
405
- (i.closest(".rte-content, .editora-content") || y)?.dispatchEvent(new Event("input", { bubbles: !0 })), E();
418
+ (a.closest(".rte-content, .editora-content") || y)?.dispatchEvent(new Event("input", { bubbles: !0 })), k();
406
419
  };
407
- g.addEventListener("click", E), w.addEventListener("click", E), f.addEventListener("click", D), c.addEventListener("click", (o) => {
408
- o.target === c && E();
409
- }), document.addEventListener("keydown", N, !0), I.forEach((o) => {
420
+ g.addEventListener("click", k), E.addEventListener("click", k), f.addEventListener("click", R), c.addEventListener("click", (o) => {
421
+ o.target === c && k();
422
+ }), document.addEventListener("keydown", z, !0), X.forEach((o) => {
410
423
  o.addEventListener("change", (s) => {
411
- u = s.target.value, C = "", A(), M();
424
+ u = s.target.value, D = "", _(), $();
412
425
  });
413
426
  }), p.addEventListener("input", () => {
414
- B = p.value, M();
427
+ N = p.value, $();
415
428
  }), p.addEventListener("keydown", (o) => {
416
- (o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(), D());
417
- }), A(), M(), p.focus();
429
+ (o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(), R());
430
+ }), _(), $(), p.focus();
418
431
  };
419
432
  if (typeof window < "u" && !window.__mathPluginDoubleClickInitialized) {
420
433
  window.__mathPluginDoubleClickInitialized = !0;
421
434
  const e = (r) => {
422
- const a = r.target.closest(".math-formula, .math-block");
423
- if (a) {
424
- r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), S = a;
425
- const n = a.getAttribute("data-math-formula") || "", c = a.getAttribute("data-math-format") || "latex", d = a.classList.contains("math-formula");
426
- R({ formula: n, format: c, inline: d });
435
+ const i = r.target.closest(".math-formula, .math-block");
436
+ if (i) {
437
+ r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), A = i;
438
+ const n = i.getAttribute("data-math-formula") || "", c = i.getAttribute("data-math-format") || "latex", d = i.classList.contains("math-formula");
439
+ O({ formula: n, format: c, inline: d });
427
440
  }
428
441
  }, t = () => {
429
442
  document.addEventListener("dblclick", e, { capture: !0 });
430
443
  };
431
444
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : setTimeout(t, 100);
432
445
  }
433
- const ce = () => ({
446
+ const fe = () => ({
434
447
  name: "math",
435
- init: re,
448
+ init: ce,
436
449
  toolbar: [
437
450
  {
438
451
  label: "Insert Math",
@@ -443,7 +456,7 @@ const ce = () => ({
443
456
  commands: {
444
457
  insertMath: (e, t) => {
445
458
  const r = t?.contentElement instanceof HTMLElement ? t.contentElement : null;
446
- return R(void 0, r), !0;
459
+ return O(void 0, r), !0;
447
460
  }
448
461
  },
449
462
  keymap: {
@@ -451,5 +464,5 @@ const ce = () => ({
451
464
  }
452
465
  });
453
466
  export {
454
- ce as MathPlugin
467
+ fe as MathPlugin
455
468
  };