@editora/core 1.0.6 → 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.
- package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
- package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
- package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
- package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
- package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
- package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
- package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
- package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
- package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
- package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
- package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
- package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
- package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
- package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
- package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
- package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
- package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
- package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
- package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
- package/dist/editora.min.js +10 -10
- package/dist/editora.umd.js +10 -10
- package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
- package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
- package/dist/index-BslAFzmv.mjs +16544 -0
- package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
- package/dist/index.esm.js +2 -2
- package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
- package/dist/plugin-loader.js +15 -15
- package/dist/webcomponent-core.js +241 -224
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +86 -106
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +205 -188
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +477 -402
- package/package.json +1 -1
- package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
- package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
- package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
- package/dist/documentManager-irzj9n3V.mjs +0 -37627
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
let a = null,
|
|
2
|
-
const
|
|
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
|
-
},
|
|
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(
|
|
14
|
+
if (n != null && n.closest(p)) return !0;
|
|
15
15
|
}
|
|
16
16
|
const t = document.activeElement;
|
|
17
|
-
return t != null && t.closest(
|
|
18
|
-
},
|
|
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
|
-
},
|
|
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 =
|
|
90
|
+
const t = a.startContainer, o = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, n = w(o);
|
|
91
91
|
if (n) {
|
|
92
|
-
if (
|
|
93
|
-
|
|
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(
|
|
96
|
-
const
|
|
97
|
-
|
|
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
|
|
102
|
-
|
|
101
|
+
const i = window.getSelection();
|
|
102
|
+
i && (i.removeAllRanges(), i.addRange(a));
|
|
103
103
|
}
|
|
104
|
-
n.focus(), a = null,
|
|
104
|
+
n.focus(), a = null, u = !1, l = null;
|
|
105
105
|
}
|
|
106
|
-
},
|
|
107
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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"),
|
|
187
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
}), r.addEventListener("submit", (
|
|
192
|
-
|
|
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 && (
|
|
195
|
-
text:
|
|
196
|
+
g && (A({
|
|
197
|
+
text: i.value.trim() || g,
|
|
196
198
|
url: g,
|
|
197
|
-
target:
|
|
198
|
-
title:
|
|
199
|
-
}),
|
|
200
|
-
}), setTimeout(() =>
|
|
201
|
-
},
|
|
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 =
|
|
207
|
-
return d ? (
|
|
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)) : (
|
|
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
|
-
},
|
|
223
|
-
m("openLinkDialog",
|
|
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",
|
|
228
|
-
const
|
|
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:
|
|
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
|
-
|
|
278
|
-
|
|
279
|
+
S as LinkPlugin,
|
|
280
|
+
x as openLinkDialog,
|
|
279
281
|
h as removeLink
|
|
280
282
|
};
|
|
281
|
-
//# sourceMappingURL=LinkPlugin.native-
|
|
283
|
+
//# sourceMappingURL=LinkPlugin.native-DYCIcdTm.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
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
|
|
23
|
-
const
|
|
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 (
|
|
29
|
-
const
|
|
30
|
-
window.katex && (clearInterval(
|
|
28
|
+
if (H) {
|
|
29
|
+
const l = setInterval(() => {
|
|
30
|
+
window.katex && (clearInterval(l), o(window.katex));
|
|
31
31
|
}, 100);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
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
|
|
38
|
-
|
|
39
|
-
}),
|
|
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
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
46
|
-
return
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
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
|
-
},
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
let
|
|
97
|
-
|
|
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" ${
|
|
108
|
-
<label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${
|
|
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" ${
|
|
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:
|
|
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
|
-
`,
|
|
137
|
-
const
|
|
138
|
-
const t = C[s];
|
|
139
|
-
k.innerHTML = t.map((n) => `
|
|
140
|
-
<button type="button" data-formula="${n.formula.replace(/"/g, """)}" 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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
},
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
185
|
-
|
|
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
|
|
188
|
-
if (
|
|
189
|
-
const
|
|
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
|
-
|
|
192
|
-
displayMode: !
|
|
220
|
+
n.innerHTML = b.renderToString(t, {
|
|
221
|
+
displayMode: !a.inline,
|
|
193
222
|
throwOnError: !1
|
|
194
223
|
});
|
|
195
|
-
} catch (
|
|
196
|
-
|
|
224
|
+
} catch (D) {
|
|
225
|
+
n.textContent = a.inline ? `$${t}$` : `$$${t}$$`;
|
|
197
226
|
}
|
|
198
227
|
} else if (t.trim().startsWith("<math"))
|
|
199
|
-
|
|
228
|
+
n.innerHTML = t;
|
|
200
229
|
else {
|
|
201
|
-
const
|
|
202
|
-
|
|
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
|
-
|
|
241
|
+
const M = n.closest(".rte-content, .editora-content") || g;
|
|
242
|
+
M == null || M.dispatchEvent(new Event("input", { bubbles: !0 })), w();
|
|
205
243
|
};
|
|
206
|
-
|
|
207
|
-
t.target ===
|
|
208
|
-
}),
|
|
209
|
-
t.addEventListener("change", (
|
|
210
|
-
|
|
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
|
-
}),
|
|
213
|
-
|
|
214
|
-
}),
|
|
215
|
-
(t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(),
|
|
216
|
-
}),
|
|
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
|
|
222
|
-
if (
|
|
223
|
-
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(),
|
|
224
|
-
const
|
|
225
|
-
|
|
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
|
-
},
|
|
265
|
+
}, i = () => {
|
|
228
266
|
document.addEventListener("dblclick", o, { capture: !0 });
|
|
229
267
|
};
|
|
230
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
268
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", i) : setTimeout(i, 100);
|
|
231
269
|
}
|
|
232
|
-
const
|
|
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: () =>
|
|
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
|
-
|
|
290
|
+
U as MathPlugin
|
|
250
291
|
};
|
|
251
|
-
//# sourceMappingURL=MathPlugin.native-
|
|
292
|
+
//# sourceMappingURL=MathPlugin.native-f_mDp8VL.mjs.map
|