@editora/core 1.0.22 → 1.0.24

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 (65) hide show
  1. package/README.md +247 -243
  2. package/dist/{A11yCheckerPlugin.native-qW_njhLY.mjs → A11yCheckerPlugin.native-BBCsR5Ur.mjs} +7 -5
  3. package/dist/{AnchorPlugin.native-Drmxhy98.mjs → AnchorPlugin.native-Dk9R26cF.mjs} +20 -19
  4. package/dist/{ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs → ApprovalWorkflowPlugin.native-AeJsehXM.mjs} +56 -55
  5. package/dist/{BackgroundColorPlugin.native-H3XyYD7_.mjs → BackgroundColorPlugin.native-DCAd94kp.mjs} +103 -98
  6. package/dist/{BlocksLibraryPlugin.native-CownM6Rk.mjs → BlocksLibraryPlugin.native-D9OPcnQV.mjs} +42 -43
  7. package/dist/{CitationsPlugin.native-C_7wWQ-k.mjs → CitationsPlugin.native-BFChgCSV.mjs} +51 -51
  8. package/dist/{CodePlugin.native-CAHk9ecG.mjs → CodePlugin.native-BRBEIqY7.mjs} +167 -113
  9. package/dist/{CodePlugin.native-DZgIez08.mjs → CodePlugin.native-CPfKDrkr.mjs} +1383 -1094
  10. package/dist/{CodeSamplePlugin.native-svbAFWh_.mjs → CodeSamplePlugin.native-Bai8bgl3.mjs} +5 -5
  11. package/dist/{CommentsPlugin.native-DncTHiEe.mjs → CommentsPlugin.native-DHCDUm9f.mjs} +161 -141
  12. package/dist/{ConditionalContentPlugin.native-Bf7XgRSW.mjs → ConditionalContentPlugin.native-B3R6xcqn.mjs} +3 -3
  13. package/dist/{ContentRulesPlugin.native-vPx5nC73.mjs → ContentRulesPlugin.native-BISqhQKJ.mjs} +52 -52
  14. package/dist/{DataBindingPlugin.native-B7lpI_0c.mjs → DataBindingPlugin.native-DbaDeXNp.mjs} +37 -37
  15. package/dist/{DocumentManagerPlugin.native-B8K-Oqom.mjs → DocumentManagerPlugin.native-tZqIa9o5.mjs} +21 -20
  16. package/dist/{EmbedIframePlugin.native-BfZ_HGlV.mjs → EmbedIframePlugin.native-qHMf1Jtg.mjs} +7 -7
  17. package/dist/{EmojisPlugin.native-D92aaOKi.mjs → EmojisPlugin.native-B64efKg5.mjs} +4 -4
  18. package/dist/{FormatPainterPlugin.native-BhjzsiVq.mjs → FormatPainterPlugin.native-CAc1N6xU.mjs} +183 -161
  19. package/dist/{HeadingPlugin.native-DZdvubrQ.mjs → HeadingPlugin.native-C3YiGERx.mjs} +85 -72
  20. package/dist/HistoryPlugin.native-C8GyxsgC.mjs +330 -0
  21. package/dist/{LinkPlugin.native-BsQXYsK6.mjs → LinkPlugin.native-Dt_p6Ukb.mjs} +4 -4
  22. package/dist/ListPlugin.native-UYaoRiub.mjs +239 -0
  23. package/dist/{MathPlugin.native-Byo3WL0f.mjs → MathPlugin.native-Cq9WQ7cq.mjs} +148 -130
  24. package/dist/MediaManagerPlugin.native-BjrEarV6.mjs +1161 -0
  25. package/dist/{MediaManagerPlugin.native-BT1NZIJS.mjs → MediaManagerPlugin.native-CRi24Mrb.mjs} +340 -281
  26. package/dist/{MentionPlugin.native-S_lwGZQO.mjs → MentionPlugin.native-Zb1dwdxU.mjs} +304 -300
  27. package/dist/{MergeTagPlugin.native-7-6F3S1Y.mjs → MergeTagPlugin.native-BXkVPvCo.mjs} +6 -4
  28. package/dist/{PIIRedactionPlugin.native-g7j4jOmm.mjs → PIIRedactionPlugin.native-Cm0bpzQb.mjs} +2 -2
  29. package/dist/{PreviewPlugin.native-Dv5OsffK.mjs → PreviewPlugin.native-CrfiwP2J.mjs} +2 -2
  30. package/dist/{SlashCommandsPlugin.native-BDIIwGNs.mjs → SlashCommandsPlugin.native-BzGTRmMB.mjs} +264 -240
  31. package/dist/{SmartPastePlugin.native-BATLCds5.mjs → SmartPastePlugin.native-DnOJhDsf.mjs} +2 -2
  32. package/dist/{SpecialCharactersPlugin.native-CdZoc1GB.mjs → SpecialCharactersPlugin.native-B0XaCfjZ.mjs} +4 -4
  33. package/dist/{SpellCheckPlugin.native-BGm2qPfn.mjs → SpellCheckPlugin.native-BE7os1Xj.mjs} +302 -265
  34. package/dist/{TablePlugin.native-C1YZ372P.mjs → TablePlugin.native-CWxEFpV8.mjs} +159 -136
  35. package/dist/{TemplatePlugin.native-Dwk8TgxI.mjs → TemplatePlugin.native-OD8Wc1R7.mjs} +6 -4
  36. package/dist/{TextColorPlugin.native-KMZ2uzlq.mjs → TextColorPlugin.native-C2IjioNM.mjs} +75 -71
  37. package/dist/{TranslationWorkflowPlugin.native-CZtG--06.mjs → TranslationWorkflowPlugin.native-BGXVJD9f.mjs} +101 -98
  38. package/dist/{VersionDiffPlugin.native-Ca1fMWUJ.mjs → VersionDiffPlugin.native-DJZIzFSK.mjs} +11 -11
  39. package/dist/anchoredPopover-QN4jNbW1.mjs +134 -0
  40. package/dist/confirmDialog-BP8hZPpX.mjs +112 -0
  41. package/dist/dialogHelpers-Dzn8DHoF.mjs +194 -0
  42. package/dist/{documentManager-BWK_-KJp.mjs → documentManager-8gnG-uG_.mjs} +1728 -1715
  43. package/dist/editora.min.js +21 -21
  44. package/dist/editora.umd.js +10 -10
  45. package/dist/{index-C1sO7DAC.js → index--wO0CZVN.js} +6 -6
  46. package/dist/{index-DGMYWPLx.mjs → index-BICrB5kg.mjs} +397 -326
  47. package/dist/index.cjs.js +1 -1
  48. package/dist/index.esm.js +2 -2
  49. package/dist/katex-DLIObQUm.mjs +11683 -0
  50. package/dist/katex.min--Ws3c9be.mjs +6 -0
  51. package/dist/notify-DCQGpmq-.mjs +60 -0
  52. package/dist/plugin-loader.js +54 -54
  53. package/dist/webcomponent-core.js +305 -234
  54. package/dist/webcomponent-core.min.css +1 -1
  55. package/dist/webcomponent-core.min.js +153 -80
  56. package/dist/webcomponent.cjs.js +1 -1
  57. package/dist/webcomponent.esm.js +1 -1
  58. package/dist/webcomponent.js +631 -560
  59. package/dist/webcomponent.min.css +1 -1
  60. package/dist/webcomponent.min.js +1677 -1328
  61. package/package.json +1 -1
  62. package/dist/HistoryPlugin.native-DPvhks6h.mjs +0 -246
  63. package/dist/ListPlugin.native-Bt0LANbO.mjs +0 -139
  64. package/dist/anchoredPopover-DJFD2oAP.mjs +0 -116
  65. package/dist/dialogHelpers-DBf7WqYH.mjs +0 -40
@@ -1,6 +1,6 @@
1
- import { e as U } from "./escapeHtml-CX8RelZ1.mjs";
2
- import { i as W } from "./dialogHelpers-DBf7WqYH.mjs";
3
- const X = {
1
+ import { e as j } from "./escapeHtml-CX8RelZ1.mjs";
2
+ import { i as V } from "./dialogHelpers-Dzn8DHoF.mjs";
3
+ const J = {
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 X = {
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 L = null, v = null, z = !1, y = null, m = null;
25
- const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */ new Set([
24
+ let L = null, w = null, x = null, B = null;
25
+ const F = "0.16.9";
26
+ let v = null, m = null;
27
+ const M = '[data-theme="dark"], .dark, .editora-theme-dark', Y = /* @__PURE__ */ new Set([
26
28
  "math",
27
29
  "mrow",
28
30
  "mi",
@@ -54,7 +56,7 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
54
56
  "none",
55
57
  "semantics",
56
58
  "annotation"
57
- ]), Z = /* @__PURE__ */ new Set([
59
+ ]), ee = /* @__PURE__ */ new Set([
58
60
  "display",
59
61
  "displaystyle",
60
62
  "mathvariant",
@@ -96,48 +98,63 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
96
98
  "dir",
97
99
  "class",
98
100
  "id"
99
- ]), S = (e) => {
101
+ ]), C = (e) => {
100
102
  const t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), r = (i) => {
101
103
  Array.from(i.childNodes).forEach((a) => {
102
104
  var n;
103
105
  if (a.nodeType === Node.ELEMENT_NODE) {
104
106
  const c = a;
105
- if (!G.has(c.localName.toLowerCase())) {
107
+ if (!Y.has(c.localName.toLowerCase())) {
106
108
  c.remove();
107
109
  return;
108
110
  }
109
111
  Array.from(c.attributes).forEach((d) => {
110
- Z.has(d.name.toLowerCase()) || c.removeAttribute(d.name);
112
+ ee.has(d.name.toLowerCase()) || c.removeAttribute(d.name);
111
113
  }), r(c);
112
114
  } else a.nodeType !== Node.TEXT_NODE && ((n = a.parentNode) == null || n.removeChild(a));
113
115
  });
114
116
  };
115
117
  return r(t.body), t.body.innerHTML;
116
- }, Q = () => new Promise((e, t) => {
117
- if (window.katex) {
118
- e(window.katex);
119
- return;
118
+ }, z = () => {
119
+ var e;
120
+ return (e = window.katex) != null ? e : x;
121
+ }, I = (e, t) => {
122
+ if (e && !document.getElementById("rte-katex-layout")) {
123
+ const i = document.createElement("style");
124
+ i.id = "rte-katex-layout", i.textContent = e.replace(/@font-face\s*\{[^}]*\}/g, ""), document.head.appendChild(i);
120
125
  }
121
- if (z) {
122
- const a = setInterval(() => {
123
- window.katex && (clearInterval(a), e(window.katex));
124
- }, 100);
125
- return;
126
- }
127
- z = !0;
126
+ if (document.querySelector('link[data-rte-katex-css], link[href*="katex"][rel="stylesheet"]')) return;
128
127
  const r = document.createElement("link");
129
- r.rel = "stylesheet", r.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(r);
130
- const i = document.createElement("script");
131
- i.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", i.onload = () => e(window.katex), i.onerror = t, document.head.appendChild(i);
132
- }), R = () => {
128
+ 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);
129
+ };
130
+ let A = null;
131
+ const te = () => {
132
+ var t;
133
+ const e = z();
134
+ return e ? (I(A, (t = e.version) != null ? t : F), Promise.resolve(e)) : (B || (B = (async () => {
135
+ var r, i;
136
+ try {
137
+ const a = await import("./katex-DLIObQUm.mjs");
138
+ x = (r = a.default) != null ? r : a;
139
+ } catch (a) {
140
+ x = null;
141
+ }
142
+ try {
143
+ A = (await import("./katex.min--Ws3c9be.mjs")).default;
144
+ } catch (a) {
145
+ A = null;
146
+ }
147
+ return I(A, (i = x == null ? void 0 : x.version) != null ? i : F), x || (B = null), x;
148
+ })()), B);
149
+ }, O = () => {
133
150
  const e = window.getSelection();
134
151
  if (!e || e.rangeCount === 0) return null;
135
152
  const t = e.getRangeAt(0).startContainer, r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
136
153
  return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
137
- }, J = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, j = (e) => {
138
- const t = J(e);
154
+ }, ne = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, D = (e) => {
155
+ const t = ne(e);
139
156
  return (t == null ? void 0 : t.closest('.rte-content, .editora-content, [contenteditable="true"]')) || null;
140
- }, V = (e, t, r) => {
157
+ }, oe = (e, t, r) => {
141
158
  if (t !== r) {
142
159
  if (typeof window.execEditorCommand == "function") {
143
160
  window.execEditorCommand("recordDomTransaction", e, t, r);
@@ -149,39 +166,39 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
149
166
  } catch (i) {
150
167
  }
151
168
  }
152
- }, Y = (e) => {
169
+ }, re = (e) => {
153
170
  if (!(e instanceof Element)) return null;
154
171
  const t = e.closest(".math-formula, .math-block");
155
172
  return t instanceof HTMLElement ? t : null;
156
- }, h = () => {
173
+ }, y = () => {
157
174
  m && (m.classList.remove("math-object-selected"), m.removeAttribute("data-rte-selected-object"), m = null);
158
- }, ee = (e) => {
175
+ }, ae = (e) => {
159
176
  if (m === e) return;
160
- h(), m = e, e.classList.add("math-object-selected"), e.setAttribute("data-rte-selected-object", "true");
177
+ y(), m = e, e.classList.add("math-object-selected"), e.setAttribute("data-rte-selected-object", "true");
161
178
  const t = window.getSelection();
162
179
  if (!t) return;
163
180
  const r = document.createRange();
164
181
  r.selectNode(e), t.removeAllRanges(), t.addRange(r);
165
- }, te = (e, t) => {
182
+ }, ie = (e, t) => {
166
183
  const r = window.getSelection();
167
184
  if (!r) return;
168
185
  const i = document.createRange();
169
186
  t && t.parentNode === e ? i.setStartBefore(t) : (i.selectNodeContents(e), i.collapse(!1)), i.collapse(!0), r.removeAllRanges(), r.addRange(i);
170
- }, ne = (e) => {
187
+ }, le = (e) => {
171
188
  if (e.childNodes.length > 0) return;
172
189
  const t = document.createElement("p");
173
190
  t.appendChild(document.createElement("br")), e.appendChild(t);
174
- }, oe = () => {
191
+ }, se = () => {
175
192
  if (!m || !m.isConnected)
176
- return h(), !1;
177
- const e = m, t = j(e);
193
+ return y(), !1;
194
+ const e = m, t = D(e);
178
195
  if (!t)
179
- return h(), !1;
196
+ return y(), !1;
180
197
  const r = t.innerHTML, i = e.nextSibling;
181
- e.remove(), ne(t), h(), te(t, i);
198
+ e.remove(), le(t), y(), ie(t, i);
182
199
  const a = t.innerHTML;
183
- return V(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
184
- }, re = () => {
200
+ return oe(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
201
+ }, ce = () => {
185
202
  if (document.getElementById("math-object-selection-styles")) return;
186
203
  const e = document.createElement("style");
187
204
  e.id = "math-object-selection-styles", e.textContent = `
@@ -191,46 +208,46 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
191
208
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
192
209
  }
193
210
  `, document.head.appendChild(e);
194
- }, ae = () => {
195
- typeof window == "undefined" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, re(), document.addEventListener("pointerdown", (e) => {
211
+ }, de = () => {
212
+ typeof window == "undefined" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, ce(), document.addEventListener("pointerdown", (e) => {
196
213
  var r, i;
197
- const t = Y(e.target);
214
+ const t = re(e.target);
198
215
  if (!t) {
199
216
  const a = e.target;
200
- (r = a == null ? void 0 : a.closest) != null && r.call(a, ".math-dialog-overlay") || h();
217
+ (r = a == null ? void 0 : a.closest) != null && r.call(a, ".math-dialog-overlay") || y();
201
218
  return;
202
219
  }
203
- e.preventDefault(), (i = j(t)) == null || i.focus(), ee(t);
220
+ e.preventDefault(), (i = D(t)) == null || i.focus(), ae(t);
204
221
  }, !0), document.addEventListener("keydown", (e) => {
205
222
  if (m) {
206
223
  if (e.key === "Escape") {
207
- h();
224
+ y();
208
225
  return;
209
226
  }
210
- e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), oe());
227
+ e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), se());
211
228
  }
212
229
  }, !0));
213
- }, ie = (e) => {
214
- const t = e || R();
215
- if (t != null && t.closest(T)) return !0;
230
+ }, me = (e) => {
231
+ const t = e || O();
232
+ if (t != null && t.closest(M)) return !0;
216
233
  const r = window.getSelection();
217
234
  if (r && r.rangeCount > 0) {
218
235
  const a = r.getRangeAt(0).startContainer, n = a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement;
219
- if (n != null && n.closest(T)) return !0;
236
+ if (n != null && n.closest(M)) return !0;
220
237
  }
221
238
  const i = document.activeElement;
222
- return i != null && i.closest(T) ? !0 : document.body.matches(T) || document.documentElement.matches(T);
223
- }, I = async (e, t) => {
239
+ return i != null && i.closest(M) ? !0 : document.body.matches(M) || document.documentElement.matches(M);
240
+ }, K = async (e, t) => {
224
241
  document.querySelectorAll(".math-dialog-overlay").forEach((o) => o.remove());
225
- const r = t || (v == null ? void 0 : v.closest(".rte-content, .editora-content")) || R() || y;
226
- y = r || null;
242
+ const r = t || (w == null ? void 0 : w.closest(".rte-content, .editora-content")) || O() || v;
243
+ v = r || null;
227
244
  const i = window.getSelection();
228
245
  if (i && i.rangeCount > 0) {
229
246
  const o = i.getRangeAt(0);
230
247
  L = r && r.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
231
248
  }
232
- await Q();
233
- const a = ie(r), n = a ? {
249
+ await te();
250
+ const a = me(r), n = a ? {
234
251
  overlay: "rgba(0, 0, 0, 0.62)",
235
252
  dialogBg: "#1f2937",
236
253
  border: "#3b4657",
@@ -259,13 +276,13 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
259
276
  fieldBg: "#ffffff",
260
277
  fieldBorder: "#ced4da",
261
278
  text: "#1f2937",
262
- muted: "#6c757d",
279
+ muted: "#5c636a",
263
280
  templateBtnBg: "#ffffff",
264
281
  templateBtnHover: "#f8f9fa",
265
282
  templateBtnText: "#1f2937",
266
- templateSubText: "#6c757d",
283
+ templateSubText: "#5c636a",
267
284
  previewBg: "#f8f9fa",
268
- previewText: "#6c757d",
285
+ previewText: "#5c636a",
269
286
  cancelBg: "#ffffff",
270
287
  cancelText: "#1f2937",
271
288
  cancelBorder: "#ced4da",
@@ -273,12 +290,12 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
273
290
  insertHover: "#0069d9",
274
291
  invalid: "#cc0000"
275
292
  }, c = document.createElement("div");
276
- W(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;`;
293
+ V(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;`;
277
294
  const d = document.createElement("div");
278
295
  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};`;
279
- let u = (e == null ? void 0 : e.format) || "latex", B = (e == null ? void 0 : e.formula) || "";
280
- const q = (e == null ? void 0 : e.inline) !== !1;
281
- let g = null, C = "";
296
+ let u = (e == null ? void 0 : e.format) || "latex", N = (e == null ? void 0 : e.formula) || "";
297
+ const X = (e == null ? void 0 : e.inline) !== !1;
298
+ let h = null, H = "";
282
299
  d.innerHTML = `
283
300
  <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${n.border}; background: ${n.panelBg};">
284
301
  <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${n.text};">${e ? "Edit" : "Insert"} Math Formula</h2>
@@ -287,30 +304,30 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
287
304
 
288
305
  <div style="padding: 20px; overflow-y: auto; flex: 1;">
289
306
  <div style="margin-bottom: 20px;">
290
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Format:</label>
291
- <div style="display: flex; gap: 16px;">
307
+ <span id="math-format-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Format:</span>
308
+ <div role="radiogroup" aria-labelledby="math-format-label" style="display: flex; gap: 16px;">
292
309
  <label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="latex" ${u === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
293
310
  <label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="mathml" ${u === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
294
311
  </div>
295
312
  </div>
296
313
 
297
314
  <div style="margin-bottom: 20px;">
298
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Quick Templates:</label>
299
- <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>
315
+ <span id="math-templates-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Quick Templates:</span>
316
+ <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>
300
317
  </div>
301
318
 
302
319
  <div style="margin-bottom: 20px;">
303
- <label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${q ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
320
+ <label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${X ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
304
321
  </div>
305
322
 
306
323
  <div style="margin-bottom: 20px;">
307
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Formula:</label>
308
- <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;">${U(B)}</textarea>
324
+ <label for="formula-input" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Formula:</label>
325
+ <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;">${j(N)}</textarea>
309
326
  </div>
310
327
 
311
328
  <div style="margin-bottom: 20px;">
312
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Preview:</label>
313
- <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>
329
+ <span id="math-preview-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Preview:</span>
330
+ <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>
314
331
  </div>
315
332
  </div>
316
333
 
@@ -319,129 +336,130 @@ const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__PURE__ */
319
336
  <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>
320
337
  </div>
321
338
  `, c.appendChild(d), document.body.appendChild(c);
322
- const p = d.querySelector("#formula-input"), w = d.querySelector("#preview-area"), M = d.querySelector("#templates-grid"), P = d.querySelectorAll('input[name="format"]'), F = d.querySelector("#inline-cb"), f = d.querySelector("#insert-btn"), b = d.querySelector(".close-btn"), E = d.querySelector(".cancel-btn"), D = (o) => encodeURIComponent(o), O = (o) => {
339
+ const p = d.querySelector("#formula-input"), E = d.querySelector("#preview-area"), $ = d.querySelector("#templates-grid"), U = d.querySelectorAll('input[name="format"]'), W = d.querySelector("#inline-cb"), f = d.querySelector("#insert-btn"), b = d.querySelector(".close-btn"), k = d.querySelector(".cancel-btn"), G = (o) => encodeURIComponent(o), Z = (o) => {
323
340
  try {
324
341
  return decodeURIComponent(o);
325
342
  } catch (s) {
326
343
  return o;
327
344
  }
328
- }, N = () => {
329
- const o = X[u];
330
- M.innerHTML = o.map((s) => `
331
- <button type="button" data-formula="${D(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;">
345
+ }, R = () => {
346
+ const o = J[u];
347
+ $.innerHTML = o.map((s) => `
348
+ <button type="button" data-formula="${G(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
349
  <div style="font-weight: 600; font-size: 12px; color: ${n.templateBtnText};">${s.name}</div>
333
350
  <div style="font-size: 10px; color: ${n.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${s.formula.substring(0, 20)}...</div>
334
351
  </button>
335
352
  `).join("");
336
- }, K = () => {
353
+ }, Q = () => {
337
354
  const o = p.value.trim(), s = `${u}:${o}`;
338
- if (s !== C) {
339
- if (C = s, !o) {
340
- w.innerHTML = `<span style="color: ${n.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
355
+ if (s !== H) {
356
+ if (H = s, !o) {
357
+ E.innerHTML = `<span style="color: ${n.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
341
358
  return;
342
359
  }
343
360
  f.disabled = !1;
344
361
  try {
345
362
  if (u === "latex") {
346
- const l = window.katex;
347
- w.innerHTML = l.renderToString(o, { displayMode: !1, throwOnError: !1 });
363
+ const l = z();
364
+ E.innerHTML = l ? l.renderToString(o, { displayMode: !1, throwOnError: !1 }) : `<code style="font-family: 'Courier New', monospace; color: ${n.previewText};">${j(o)}</code>`;
348
365
  } else
349
- o.trim().startsWith("<math") ? w.innerHTML = S(o) : w.innerHTML = S(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${o}</math>`);
366
+ o.trim().startsWith("<math") ? E.innerHTML = C(o) : E.innerHTML = C(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${o}</math>`);
350
367
  } catch (l) {
351
- w.innerHTML = `<span style="color: ${n.invalid};">Invalid formula</span>`;
368
+ E.innerHTML = `<span style="color: ${n.invalid};">Invalid formula</span>`;
352
369
  }
353
370
  }
354
- }, $ = () => {
355
- g !== null && cancelAnimationFrame(g), g = requestAnimationFrame(() => {
356
- g = null, K();
371
+ }, S = () => {
372
+ h !== null && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
373
+ h = null, Q();
357
374
  });
358
- }, H = (o) => {
359
- o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), k());
360
- }, k = () => {
361
- document.removeEventListener("keydown", H, !0), g !== null && (cancelAnimationFrame(g), g = null), c.parentNode && c.parentNode.removeChild(c);
375
+ }, q = (o) => {
376
+ o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), T());
377
+ }, T = () => {
378
+ document.removeEventListener("keydown", q, !0), h !== null && (cancelAnimationFrame(h), h = null), c.parentNode && c.parentNode.removeChild(c);
362
379
  };
363
380
  b.onmouseover = () => {
364
381
  b.style.color = "#f8fafc", b.style.background = a ? "#334155" : "#e5e7eb", b.style.borderRadius = "4px";
365
382
  }, b.onmouseout = () => {
366
383
  b.style.color = n.muted, b.style.background = "none";
367
- }, E.onmouseover = () => {
368
- E.style.background = a ? "#475569" : "#f3f4f6";
369
- }, E.onmouseout = () => {
370
- E.style.background = n.cancelBg;
384
+ }, k.onmouseover = () => {
385
+ k.style.background = a ? "#475569" : "#f3f4f6";
386
+ }, k.onmouseout = () => {
387
+ k.style.background = n.cancelBg;
371
388
  }, f.onmouseover = () => {
372
389
  f.disabled || (f.style.background = n.insertHover);
373
390
  }, f.onmouseout = () => {
374
391
  f.style.background = n.insertBg;
375
- }, M.addEventListener("mouseover", (o) => {
392
+ }, $.addEventListener("mouseover", (o) => {
376
393
  const l = o.target.closest("button[data-formula]");
377
394
  l && (l.style.background = n.templateBtnHover);
378
- }), M.addEventListener("mouseout", (o) => {
395
+ }), $.addEventListener("mouseout", (o) => {
379
396
  const l = o.target.closest("button[data-formula]");
380
397
  l && (l.style.background = n.templateBtnBg);
381
- }), M.addEventListener("click", (o) => {
398
+ }), $.addEventListener("click", (o) => {
382
399
  const l = o.target.closest("button[data-formula]");
383
- l && (p.value = O(l.getAttribute("data-formula") || ""), B = p.value, $());
400
+ l && (p.value = Z(l.getAttribute("data-formula") || ""), N = p.value, S());
384
401
  });
385
- const _ = () => {
402
+ const P = () => {
386
403
  const o = p.value.trim();
387
404
  if (!o) return;
388
- const s = { formula: o, format: u, inline: F.checked }, l = s.inline ? document.createElement("span") : document.createElement("div");
405
+ const s = { formula: o, format: u, inline: W.checked }, l = s.inline ? document.createElement("span") : document.createElement("div");
389
406
  if (l.className = s.inline ? "math-formula" : "math-block", l.setAttribute("data-math-formula", o), l.setAttribute("data-math-format", u), l.contentEditable = "false", l.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") {
390
- const x = window.katex;
407
+ const g = z();
391
408
  try {
392
- l.innerHTML = x.renderToString(o, {
409
+ if (!g) throw new Error("KaTeX is not available");
410
+ l.innerHTML = g.renderToString(o, {
393
411
  displayMode: !s.inline,
394
412
  throwOnError: !1
395
413
  });
396
- } catch (le) {
414
+ } catch (ue) {
397
415
  l.textContent = s.inline ? `$${o}$` : `$$${o}$$`;
398
416
  }
399
417
  } else if (o.trim().startsWith("<math"))
400
- l.innerHTML = S(o);
418
+ l.innerHTML = C(o);
401
419
  else {
402
- const x = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${s.inline ? "inline" : "block"}">${o}</math>`;
403
- l.innerHTML = S(x);
420
+ const g = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${s.inline ? "inline" : "block"}">${o}</math>`;
421
+ l.innerHTML = C(g);
404
422
  }
405
- if (v)
406
- v.replaceWith(l);
423
+ if (w)
424
+ w.replaceWith(l);
407
425
  else if (L)
408
426
  L.deleteContents(), L.insertNode(l);
409
- else if (y && y.isConnected) {
410
- const x = document.createRange();
411
- x.selectNodeContents(y), x.collapse(!1), x.insertNode(l);
427
+ else if (v && v.isConnected) {
428
+ const g = document.createRange();
429
+ g.selectNodeContents(v), g.collapse(!1), g.insertNode(l);
412
430
  }
413
- const A = l.closest(".rte-content, .editora-content") || y;
414
- A == null || A.dispatchEvent(new Event("input", { bubbles: !0 })), k();
431
+ const _ = l.closest(".rte-content, .editora-content") || v;
432
+ _ == null || _.dispatchEvent(new Event("input", { bubbles: !0 })), T();
415
433
  };
416
- b.addEventListener("click", k), E.addEventListener("click", k), f.addEventListener("click", _), c.addEventListener("click", (o) => {
417
- o.target === c && k();
418
- }), document.addEventListener("keydown", H, !0), P.forEach((o) => {
434
+ b.addEventListener("click", T), k.addEventListener("click", T), f.addEventListener("click", P), c.addEventListener("click", (o) => {
435
+ o.target === c && T();
436
+ }), document.addEventListener("keydown", q, !0), U.forEach((o) => {
419
437
  o.addEventListener("change", (s) => {
420
- u = s.target.value, C = "", N(), $();
438
+ u = s.target.value, H = "", R(), S();
421
439
  });
422
440
  }), p.addEventListener("input", () => {
423
- B = p.value, $();
441
+ N = p.value, S();
424
442
  }), p.addEventListener("keydown", (o) => {
425
- (o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(), _());
426
- }), N(), $(), p.focus();
443
+ (o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(), P());
444
+ }), R(), S(), p.focus();
427
445
  };
428
446
  if (typeof window != "undefined" && !window.__mathPluginDoubleClickInitialized) {
429
447
  window.__mathPluginDoubleClickInitialized = !0;
430
448
  const e = (r) => {
431
449
  const a = r.target.closest(".math-formula, .math-block");
432
450
  if (a) {
433
- r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), v = a;
451
+ r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), y(), w = a;
434
452
  const n = a.getAttribute("data-math-formula") || "", c = a.getAttribute("data-math-format") || "latex", d = a.classList.contains("math-formula");
435
- I({ formula: n, format: c, inline: d });
453
+ K({ formula: n, format: c, inline: d });
436
454
  }
437
455
  }, t = () => {
438
456
  document.addEventListener("dblclick", e, { capture: !0 });
439
457
  };
440
458
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : setTimeout(t, 100);
441
459
  }
442
- const de = () => ({
460
+ const be = () => ({
443
461
  name: "math",
444
- init: ae,
462
+ init: de,
445
463
  toolbar: [
446
464
  {
447
465
  label: "Insert Math",
@@ -452,7 +470,7 @@ const de = () => ({
452
470
  commands: {
453
471
  insertMath: (e, t) => {
454
472
  const r = (t == null ? void 0 : t.contentElement) instanceof HTMLElement ? t.contentElement : null;
455
- return I(void 0, r), !0;
473
+ return K(void 0, r), !0;
456
474
  }
457
475
  },
458
476
  keymap: {
@@ -460,6 +478,6 @@ const de = () => ({
460
478
  }
461
479
  });
462
480
  export {
463
- de as MathPlugin
481
+ be as MathPlugin
464
482
  };
465
- //# sourceMappingURL=MathPlugin.native-Byo3WL0f.mjs.map
483
+ //# sourceMappingURL=MathPlugin.native-Cq9WQ7cq.mjs.map