@editora/core 1.0.5 → 1.0.7

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 (43) hide show
  1. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  2. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  3. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  4. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  5. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  6. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  7. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  8. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  9. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  10. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  11. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  12. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
  13. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  14. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  15. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  16. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  17. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  18. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  19. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  20. package/dist/editora.min.js +10 -10
  21. package/dist/editora.umd.js +10 -10
  22. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  23. package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
  24. package/dist/index-BslAFzmv.mjs +16544 -0
  25. package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
  26. package/dist/index.cjs.js +1 -1
  27. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  28. package/dist/index.esm.js +2 -2
  29. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  30. package/dist/plugin-loader.js +15 -15
  31. package/dist/webcomponent-core.js +241 -224
  32. package/dist/webcomponent-core.min.css +1 -1
  33. package/dist/webcomponent-core.min.js +86 -106
  34. package/dist/webcomponent.cjs.js +1 -1
  35. package/dist/webcomponent.esm.js +1 -1
  36. package/dist/webcomponent.js +205 -188
  37. package/dist/webcomponent.min.css +1 -1
  38. package/dist/webcomponent.min.js +477 -402
  39. package/package.json +16 -10
  40. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  41. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  42. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  43. package/dist/documentManager-irzj9n3V.mjs +0 -37627
@@ -1,5 +1,5 @@
1
- let a = null, p = !1, i = null;
2
- const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
1
+ let a = null, u = !1, l = null;
2
+ const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
3
3
  if (!e) return null;
4
4
  let t = e;
5
5
  for (; t; ) {
@@ -8,14 +8,14 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
8
8
  t = t.parentElement;
9
9
  }
10
10
  return null;
11
- }, w = (e) => {
11
+ }, C = (e) => {
12
12
  if (e) {
13
13
  const o = e.startContainer, n = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement;
14
- if (n != null && n.closest(c)) return !0;
14
+ if (n != null && n.closest(p)) return !0;
15
15
  }
16
16
  const t = document.activeElement;
17
- return t != null && t.closest(c) ? !0 : document.body.matches(c) || document.documentElement.matches(c);
18
- }, C = () => {
17
+ return t != null && t.closest(p) ? !0 : document.body.matches(p) || document.documentElement.matches(p);
18
+ }, T = () => {
19
19
  if (document.getElementById("rte-link-dialog-theme-styles")) return;
20
20
  const e = document.createElement("style");
21
21
  e.id = "rte-link-dialog-theme-styles", e.textContent = `
@@ -82,29 +82,29 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
82
82
  background: #2563eb !important;
83
83
  }
84
84
  `, document.head.appendChild(e);
85
- }, T = (e) => {
85
+ }, A = (e) => {
86
86
  if (!a) {
87
87
  console.warn("No selection range stored");
88
88
  return;
89
89
  }
90
- const t = a.startContainer, o = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, n = L(o);
90
+ const t = a.startContainer, o = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, n = w(o);
91
91
  if (n) {
92
- if (p && i) {
93
- i.href = e.url, i.textContent = e.text, i.target = e.target, e.target === "_blank" ? i.setAttribute("rel", "noopener noreferrer") : i.removeAttribute("rel"), e.title ? i.title = e.title : i.removeAttribute("title");
92
+ if (u && l) {
93
+ l.href = e.url, l.textContent = e.text, l.target = e.target, e.target === "_blank" ? l.setAttribute("rel", "noopener noreferrer") : l.removeAttribute("rel"), e.title ? l.title = e.title : l.removeAttribute("title");
94
94
  const r = document.createRange();
95
- r.selectNodeContents(i);
96
- const l = window.getSelection();
97
- l && (l.removeAllRanges(), l.addRange(r));
95
+ r.selectNodeContents(l);
96
+ const i = window.getSelection();
97
+ i && (i.removeAllRanges(), i.addRange(r));
98
98
  } else {
99
99
  const r = document.createElement("a");
100
100
  r.href = e.url, r.textContent = e.text, r.target = e.target, e.target === "_blank" && r.setAttribute("rel", "noopener noreferrer"), e.title && (r.title = e.title), a.deleteContents(), a.insertNode(r), a.setStartAfter(r), a.setEndAfter(r);
101
- const l = window.getSelection();
102
- l && (l.removeAllRanges(), l.addRange(a));
101
+ const i = window.getSelection();
102
+ i && (i.removeAllRanges(), i.addRange(a));
103
103
  }
104
- n.focus(), a = null, p = !1, i = null;
104
+ n.focus(), a = null, u = !1, l = null;
105
105
  }
106
- }, b = (e, t) => {
107
- C();
106
+ }, k = (e, t) => {
107
+ T();
108
108
  const o = document.createElement("div");
109
109
  o.className = "link-dialog-overlay", t && o.classList.add("rte-theme-dark"), o.style.cssText = `
110
110
  position: fixed;
@@ -139,7 +139,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
139
139
  type="text"
140
140
  value="${e.text || ""}"
141
141
  placeholder="Enter link text"
142
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
142
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
143
143
  />
144
144
  </div>
145
145
  <div class="form-group" style="margin-bottom: 16px;">
@@ -150,7 +150,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
150
150
  value="${e.url || ""}"
151
151
  placeholder="https://example.com"
152
152
  required
153
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
153
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
154
154
  />
155
155
  </div>
156
156
  <div class="form-group" style="margin-bottom: 16px;">
@@ -160,7 +160,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
160
160
  type="text"
161
161
  value="${e.title || ""}"
162
162
  placeholder="Link tooltip text"
163
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
163
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
164
164
  />
165
165
  </div>
166
166
  <div class="form-group" style="margin-bottom: 0;">
@@ -183,34 +183,36 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
183
183
  </div>
184
184
  </form>
185
185
  `, o.appendChild(n), document.body.appendChild(o);
186
- const r = n.querySelector("#link-form"), l = n.querySelector("#link-text"), d = n.querySelector("#link-url"), x = n.querySelector("#link-title"), y = n.querySelector("#link-target"), v = n.querySelector(".link-dialog-close"), E = n.querySelector(".btn-cancel"), s = () => {
187
- document.body.removeChild(o);
186
+ const r = n.querySelector("#link-form"), i = n.querySelector("#link-text"), d = n.querySelector("#link-url"), y = n.querySelector("#link-title"), v = n.querySelector("#link-target"), E = n.querySelector(".link-dialog-close"), L = n.querySelector(".btn-cancel"), b = (s) => {
187
+ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), c());
188
+ }, c = () => {
189
+ document.removeEventListener("keydown", b, !0), o.remove();
188
190
  };
189
- v.addEventListener("click", s), E.addEventListener("click", s), o.addEventListener("click", (u) => {
190
- u.target === o && s();
191
- }), r.addEventListener("submit", (u) => {
192
- u.preventDefault();
191
+ E.addEventListener("click", c), L.addEventListener("click", c), o.addEventListener("click", (s) => {
192
+ s.target === o && c();
193
+ }), document.addEventListener("keydown", b, !0), r.addEventListener("submit", (s) => {
194
+ s.preventDefault();
193
195
  const g = d.value.trim();
194
- g && (T({
195
- text: l.value.trim() || g,
196
+ g && (A({
197
+ text: i.value.trim() || g,
196
198
  url: g,
197
- target: y.checked ? "_blank" : "_self",
198
- title: x.value.trim() || void 0
199
- }), s());
200
- }), setTimeout(() => l.focus(), 100);
201
- }, f = () => {
199
+ target: v.checked ? "_blank" : "_self",
200
+ title: y.value.trim() || void 0
201
+ }), c());
202
+ }), setTimeout(() => i.focus(), 100);
203
+ }, x = () => {
202
204
  const e = window.getSelection();
203
205
  if (!e || e.rangeCount === 0) return !1;
204
206
  const t = e.getRangeAt(0).cloneRange();
205
207
  a = t;
206
- const o = w(t), n = e.toString() || "", r = t.startContainer, l = r.nodeType === Node.TEXT_NODE ? r.parentElement : r, d = l == null ? void 0 : l.closest("a");
207
- return d ? (p = !0, i = d, b({
208
+ const o = C(t), n = e.toString() || "", r = t.startContainer, i = r.nodeType === Node.TEXT_NODE ? r.parentElement : r, d = i == null ? void 0 : i.closest("a");
209
+ return d ? (u = !0, l = d, k({
208
210
  text: d.textContent || "",
209
211
  url: d.href,
210
212
  target: d.target || "_self",
211
213
  title: d.title || "",
212
214
  isEditing: !0
213
- }, o)) : (p = !1, i = null, b({
215
+ }, o)) : (u = !1, l = null, k({
214
216
  text: n,
215
217
  url: "",
216
218
  target: "_self",
@@ -219,13 +221,13 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
219
221
  }, h = () => (document.execCommand("unlink", !1), !0), m = (e, t) => {
220
222
  var o;
221
223
  typeof window != "undefined" && ((o = window.registerEditorCommand) == null || o.call(window, e, t));
222
- }, k = () => {
223
- m("openLinkDialog", f), m("removeLink", h), m("createLink", (e) => {
224
+ }, f = () => {
225
+ m("openLinkDialog", x), m("removeLink", h), m("createLink", (e) => {
224
226
  e && document.execCommand("createLink", !1, e);
225
227
  });
226
228
  };
227
- typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", k) : k());
228
- const A = () => ({
229
+ typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", f) : f());
230
+ const S = () => ({
229
231
  name: "link",
230
232
  marks: {
231
233
  link: {
@@ -266,7 +268,7 @@ const A = () => ({
266
268
  }
267
269
  ],
268
270
  commands: {
269
- openLinkDialog: f,
271
+ openLinkDialog: x,
270
272
  removeLink: h
271
273
  },
272
274
  keymap: {
@@ -274,8 +276,8 @@ const A = () => ({
274
276
  }
275
277
  });
276
278
  export {
277
- A as LinkPlugin,
278
- f as openLinkDialog,
279
+ S as LinkPlugin,
280
+ x as openLinkDialog,
279
281
  h as removeLink
280
282
  };
281
- //# sourceMappingURL=LinkPlugin.native-CS2g-G18.mjs.map
283
+ //# sourceMappingURL=LinkPlugin.native-DYCIcdTm.mjs.map
@@ -1,4 +1,4 @@
1
- const C = {
1
+ const j = {
2
2
  latex: [
3
3
  { name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },
4
4
  { name: "Square Root", formula: "\\sqrt{x}", description: "Square root" },
@@ -19,35 +19,48 @@ const C = {
19
19
  { name: "Parentheses", formula: '<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>', description: "Grouped expression" }
20
20
  ]
21
21
  };
22
- let h = null, w = null, E = !1;
23
- const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promise((o, d) => {
22
+ let B = null, h = null, H = !1, g = null;
23
+ const k = '[data-theme="dark"], .dark, .editora-theme-dark', O = () => new Promise((o, i) => {
24
24
  if (window.katex) {
25
25
  o(window.katex);
26
26
  return;
27
27
  }
28
- if (E) {
29
- const i = setInterval(() => {
30
- window.katex && (clearInterval(i), o(window.katex));
28
+ if (H) {
29
+ const l = setInterval(() => {
30
+ window.katex && (clearInterval(l), o(window.katex));
31
31
  }, 100);
32
32
  return;
33
33
  }
34
- E = !0;
34
+ H = !0;
35
35
  const r = document.createElement("link");
36
36
  r.rel = "stylesheet", r.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(r);
37
- const e = document.createElement("script");
38
- e.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", e.onload = () => o(window.katex), e.onerror = d, document.head.appendChild(e);
39
- }), H = () => {
37
+ const s = document.createElement("script");
38
+ s.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", s.onload = () => o(window.katex), s.onerror = i, document.head.appendChild(s);
39
+ }), q = () => {
40
40
  const o = window.getSelection();
41
- if (o && o.rangeCount > 0) {
42
- const r = o.getRangeAt(0).startContainer, e = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
43
- if (e != null && e.closest(y)) return !0;
41
+ if (!o || o.rangeCount === 0) return null;
42
+ const i = o.getRangeAt(0).startContainer, r = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement;
43
+ return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
44
+ }, K = (o) => {
45
+ const i = o || q();
46
+ if (i != null && i.closest(k)) return !0;
47
+ const r = window.getSelection();
48
+ if (r && r.rangeCount > 0) {
49
+ const l = r.getRangeAt(0).startContainer, e = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
50
+ if (e != null && e.closest(k)) return !0;
44
51
  }
45
- const d = document.activeElement;
46
- return d != null && d.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
47
- }, T = async (o) => {
48
- const d = window.getSelection();
49
- d && d.rangeCount > 0 && (h = d.getRangeAt(0).cloneRange()), await q();
50
- const r = H(), e = r ? {
52
+ const s = document.activeElement;
53
+ return s != null && s.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
54
+ }, z = async (o, i) => {
55
+ const r = i || (h == null ? void 0 : h.closest(".rte-content, .editora-content")) || q() || g;
56
+ g = r || null;
57
+ const s = window.getSelection();
58
+ if (s && s.rangeCount > 0) {
59
+ const t = s.getRangeAt(0);
60
+ B = r && r.contains(t.commonAncestorContainer) ? t.cloneRange() : null;
61
+ }
62
+ await O();
63
+ const l = K(r), e = l ? {
51
64
  overlay: "rgba(0, 0, 0, 0.62)",
52
65
  dialogBg: "#1f2937",
53
66
  border: "#3b4657",
@@ -89,12 +102,12 @@ const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promi
89
102
  insertBg: "#007bff",
90
103
  insertHover: "#0069d9",
91
104
  invalid: "#cc0000"
92
- }, i = document.createElement("div");
93
- i.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${e.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
94
- const l = document.createElement("div");
95
- l.style.cssText = `background: ${e.dialogBg}; border: 1px solid ${e.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: ${e.text};`;
96
- let s = (o == null ? void 0 : o.format) || "latex", u = (o == null ? void 0 : o.formula) || "", M = (o == null ? void 0 : o.inline) !== !1;
97
- l.innerHTML = `
105
+ }, c = document.createElement("div");
106
+ c.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${e.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
107
+ const d = document.createElement("div");
108
+ d.style.cssText = `background: ${e.dialogBg}; border: 1px solid ${e.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: ${e.text};`;
109
+ let m = (o == null ? void 0 : o.format) || "latex", T = (o == null ? void 0 : o.formula) || "", I = (o == null ? void 0 : o.inline) !== !1, x = null, L = "";
110
+ d.innerHTML = `
98
111
  <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${e.border}; background: ${e.panelBg};">
99
112
  <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">${o ? "Edit" : "Insert"} Math Formula</h2>
100
113
  <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${e.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
@@ -104,8 +117,8 @@ const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promi
104
117
  <div style="margin-bottom: 20px;">
105
118
  <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
106
119
  <div style="display: flex; gap: 16px;">
107
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${s === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
108
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${s === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
120
+ <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${m === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
121
+ <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${m === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
109
122
  </div>
110
123
  </div>
111
124
 
@@ -115,12 +128,12 @@ const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promi
115
128
  </div>
116
129
 
117
130
  <div style="margin-bottom: 20px;">
118
- <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${M ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
131
+ <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${I ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
119
132
  </div>
120
133
 
121
134
  <div style="margin-bottom: 20px;">
122
135
  <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Formula:</label>
123
- <textarea id="formula-input" rows="4" style="width: 100%; padding: 10px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 14px; background: ${e.fieldBg}; color: ${e.text};">${u}</textarea>
136
+ <textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${e.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${e.fieldBg}; color: ${e.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${T}</textarea>
124
137
  </div>
125
138
 
126
139
  <div style="margin-bottom: 20px;">
@@ -133,103 +146,128 @@ const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promi
133
146
  <button class="cancel-btn" style="padding: 10px 20px; background: ${e.cancelBg}; color: ${e.cancelText}; border: 1px solid ${e.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
134
147
  <button id="insert-btn" style="padding: 10px 20px; background: ${e.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${o ? "Update" : "Insert"}</button>
135
148
  </div>
136
- `, i.appendChild(l), document.body.appendChild(i);
137
- const c = l.querySelector("#formula-input"), f = l.querySelector("#preview-area"), k = l.querySelector("#templates-grid"), L = l.querySelectorAll('input[name="format"]'), S = l.querySelector("#inline-cb"), m = l.querySelector("#insert-btn"), p = l.querySelector(".close-btn"), x = l.querySelector(".cancel-btn"), $ = () => {
138
- const t = C[s];
139
- k.innerHTML = t.map((n) => `
140
- <button type="button" data-formula="${n.formula.replace(/"/g, "&quot;")}" title="${n.description}" style="padding: 8px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.templateBtnBg}; cursor: pointer; text-align: left;">
141
- <div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${n.name}</div>
142
- <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${n.formula.substring(0, 20)}...</div>
143
- </button>
144
- `).join(""), k.querySelectorAll("button").forEach((n) => {
145
- const a = n;
146
- a.onmouseover = () => {
147
- a.style.background = e.templateBtnHover;
148
- }, a.onmouseout = () => {
149
- a.style.background = e.templateBtnBg;
150
- }, n.addEventListener("click", () => {
151
- c.value = n.getAttribute("data-formula") || "", u = c.value, b();
152
- });
153
- });
154
- }, b = () => {
155
- const t = c.value.trim();
156
- if (!t) {
157
- f.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, m.disabled = !0;
158
- return;
159
- }
160
- m.disabled = !1;
149
+ `, c.appendChild(d), document.body.appendChild(c);
150
+ const u = d.querySelector("#formula-input"), v = d.querySelector("#preview-area"), E = d.querySelector("#templates-grid"), P = d.querySelectorAll('input[name="format"]'), R = d.querySelector("#inline-cb"), p = d.querySelector("#insert-btn"), f = d.querySelector(".close-btn"), y = d.querySelector(".cancel-btn"), _ = (t) => encodeURIComponent(t), F = (t) => {
161
151
  try {
162
- if (s === "latex") {
163
- const n = window.katex;
164
- f.innerHTML = n.renderToString(t, { displayMode: !1, throwOnError: !1 });
165
- } else
166
- t.trim().startsWith("<math") ? f.innerHTML = t : f.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
167
- } catch (n) {
168
- f.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
152
+ return decodeURIComponent(t);
153
+ } catch (a) {
154
+ return t;
169
155
  }
170
- }, g = () => document.body.removeChild(i);
171
- p.onmouseover = () => {
172
- p.style.color = "#f8fafc", p.style.background = r ? "#334155" : "#e5e7eb", p.style.borderRadius = "4px";
173
- }, p.onmouseout = () => {
174
- p.style.color = e.muted, p.style.background = "none";
175
- }, x.onmouseover = () => {
176
- x.style.background = r ? "#475569" : "#f3f4f6";
177
- }, x.onmouseout = () => {
178
- x.style.background = e.cancelBg;
179
- }, m.onmouseover = () => {
180
- m.disabled || (m.style.background = e.insertHover);
181
- }, m.onmouseout = () => {
182
- m.style.background = e.insertBg;
156
+ }, S = () => {
157
+ const t = j[m];
158
+ E.innerHTML = t.map((a) => `
159
+ <button type="button" data-formula="${_(a.formula)}" title="${a.description}" style="padding: 8px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
160
+ <div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${a.name}</div>
161
+ <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${a.formula.substring(0, 20)}...</div>
162
+ </button>
163
+ `).join("");
164
+ }, N = () => {
165
+ const t = u.value.trim(), a = `${m}:${t}`;
166
+ if (a !== L) {
167
+ if (L = a, !t) {
168
+ v.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, p.disabled = !0;
169
+ return;
170
+ }
171
+ p.disabled = !1;
172
+ try {
173
+ if (m === "latex") {
174
+ const n = window.katex;
175
+ v.innerHTML = n.renderToString(t, { displayMode: !1, throwOnError: !1 });
176
+ } else
177
+ t.trim().startsWith("<math") ? v.innerHTML = t : v.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
178
+ } catch (n) {
179
+ v.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
180
+ }
181
+ }
182
+ }, $ = () => {
183
+ x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
184
+ x = null, N();
185
+ });
186
+ }, C = (t) => {
187
+ t.key === "Escape" && (t.preventDefault(), t.stopPropagation(), w());
188
+ }, w = () => {
189
+ document.removeEventListener("keydown", C, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
183
190
  };
184
- const B = () => {
185
- const t = c.value.trim();
191
+ f.onmouseover = () => {
192
+ f.style.color = "#f8fafc", f.style.background = l ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
193
+ }, f.onmouseout = () => {
194
+ f.style.color = e.muted, f.style.background = "none";
195
+ }, y.onmouseover = () => {
196
+ y.style.background = l ? "#475569" : "#f3f4f6";
197
+ }, y.onmouseout = () => {
198
+ y.style.background = e.cancelBg;
199
+ }, p.onmouseover = () => {
200
+ p.disabled || (p.style.background = e.insertHover);
201
+ }, p.onmouseout = () => {
202
+ p.style.background = e.insertBg;
203
+ }, E.addEventListener("mouseover", (t) => {
204
+ const n = t.target.closest("button[data-formula]");
205
+ n && (n.style.background = e.templateBtnHover);
206
+ }), E.addEventListener("mouseout", (t) => {
207
+ const n = t.target.closest("button[data-formula]");
208
+ n && (n.style.background = e.templateBtnBg);
209
+ }), E.addEventListener("click", (t) => {
210
+ const n = t.target.closest("button[data-formula]");
211
+ n && (u.value = F(n.getAttribute("data-formula") || ""), T = u.value, $());
212
+ });
213
+ const A = () => {
214
+ const t = u.value.trim();
186
215
  if (!t) return;
187
- const n = { formula: t, format: s, inline: S.checked }, a = n.inline ? document.createElement("span") : document.createElement("div");
188
- if (a.className = n.inline ? "math-formula" : "math-block", a.setAttribute("data-math-formula", t), a.setAttribute("data-math-format", s), a.contentEditable = "false", a.style.cssText = n.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;", s === "latex") {
189
- const v = window.katex;
216
+ const a = { formula: t, format: m, inline: R.checked }, n = a.inline ? document.createElement("span") : document.createElement("div");
217
+ if (n.className = a.inline ? "math-formula" : "math-block", n.setAttribute("data-math-formula", t), n.setAttribute("data-math-format", m), n.contentEditable = "false", n.style.cssText = a.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;", m === "latex") {
218
+ const b = window.katex;
190
219
  try {
191
- a.innerHTML = v.renderToString(t, {
192
- displayMode: !n.inline,
220
+ n.innerHTML = b.renderToString(t, {
221
+ displayMode: !a.inline,
193
222
  throwOnError: !1
194
223
  });
195
- } catch (z) {
196
- a.textContent = n.inline ? `$${t}$` : `$$${t}$$`;
224
+ } catch (D) {
225
+ n.textContent = a.inline ? `$${t}$` : `$$${t}$$`;
197
226
  }
198
227
  } else if (t.trim().startsWith("<math"))
199
- a.innerHTML = t;
228
+ n.innerHTML = t;
200
229
  else {
201
- const v = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${n.inline ? "inline" : "block"}">${t}</math>`;
202
- a.innerHTML = v;
230
+ const b = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${a.inline ? "inline" : "block"}">${t}</math>`;
231
+ n.innerHTML = b;
232
+ }
233
+ if (h)
234
+ h.replaceWith(n);
235
+ else if (B)
236
+ B.deleteContents(), B.insertNode(n);
237
+ else if (g && g.isConnected) {
238
+ const b = document.createRange();
239
+ b.selectNodeContents(g), b.collapse(!1), b.insertNode(n);
203
240
  }
204
- w ? w.replaceWith(a) : h && (h.deleteContents(), h.insertNode(a)), g();
241
+ const M = n.closest(".rte-content, .editora-content") || g;
242
+ M == null || M.dispatchEvent(new Event("input", { bubbles: !0 })), w();
205
243
  };
206
- p.addEventListener("click", g), x.addEventListener("click", g), m.addEventListener("click", B), i.addEventListener("click", (t) => {
207
- t.target === i && g();
208
- }), L.forEach((t) => {
209
- t.addEventListener("change", (n) => {
210
- s = n.target.value, $(), b();
244
+ f.addEventListener("click", w), y.addEventListener("click", w), p.addEventListener("click", A), c.addEventListener("click", (t) => {
245
+ t.target === c && w();
246
+ }), document.addEventListener("keydown", C, !0), P.forEach((t) => {
247
+ t.addEventListener("change", (a) => {
248
+ m = a.target.value, L = "", S(), $();
211
249
  });
212
- }), c.addEventListener("input", () => {
213
- u = c.value, b();
214
- }), c.addEventListener("keydown", (t) => {
215
- (t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(), B());
216
- }), $(), b(), c.focus();
250
+ }), u.addEventListener("input", () => {
251
+ T = u.value, $();
252
+ }), u.addEventListener("keydown", (t) => {
253
+ (t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(), A());
254
+ }), S(), $(), u.focus();
217
255
  };
218
256
  if (typeof window != "undefined" && !window.__mathPluginDoubleClickInitialized) {
219
257
  window.__mathPluginDoubleClickInitialized = !0;
220
258
  const o = (r) => {
221
- const i = r.target.closest(".math-formula, .math-block");
222
- if (i) {
223
- r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), w = i;
224
- const l = i.getAttribute("data-math-formula") || "", s = i.getAttribute("data-math-format") || "latex", u = i.classList.contains("math-formula");
225
- T({ formula: l, format: s, inline: u });
259
+ const l = r.target.closest(".math-formula, .math-block");
260
+ if (l) {
261
+ r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h = l;
262
+ const e = l.getAttribute("data-math-formula") || "", c = l.getAttribute("data-math-format") || "latex", d = l.classList.contains("math-formula");
263
+ z({ formula: e, format: c, inline: d });
226
264
  }
227
- }, d = () => {
265
+ }, i = () => {
228
266
  document.addEventListener("dblclick", o, { capture: !0 });
229
267
  };
230
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", d) : setTimeout(d, 100);
268
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", i) : setTimeout(i, 100);
231
269
  }
232
- const I = () => ({
270
+ const U = () => ({
233
271
  name: "math",
234
272
  toolbar: [
235
273
  {
@@ -239,13 +277,16 @@ const I = () => ({
239
277
  }
240
278
  ],
241
279
  commands: {
242
- insertMath: () => (T(), !0)
280
+ insertMath: (o, i) => {
281
+ const r = (i == null ? void 0 : i.contentElement) instanceof HTMLElement ? i.contentElement : null;
282
+ return z(void 0, r), !0;
283
+ }
243
284
  },
244
285
  keymap: {
245
286
  "Mod-Shift-m": "insertMath"
246
287
  }
247
288
  });
248
289
  export {
249
- I as MathPlugin
290
+ U as MathPlugin
250
291
  };
251
- //# sourceMappingURL=MathPlugin.native-KUxz0o8C.mjs.map
292
+ //# sourceMappingURL=MathPlugin.native-f_mDp8VL.mjs.map