@editora/plugins 1.0.17 → 1.0.19

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