@editora/plugins 1.0.17 → 1.0.18
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/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
- package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
- package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +17 -15
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +11 -5
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-CJ90EVWy.mjs +0 -145
- package/dist/index-DTkvH8gX.js +0 -1
package/dist/math.esm.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
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
|
|
23
|
-
const k = '[data-theme="dark"], .dark, .editora-theme-dark',
|
|
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
|
|
30
|
-
window.katex && (clearInterval(
|
|
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
|
-
}),
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
170
|
+
}, ne = () => {
|
|
79
171
|
if (!m || !m.isConnected)
|
|
80
172
|
return h(), !1;
|
|
81
|
-
const e = m, t =
|
|
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(),
|
|
86
|
-
const
|
|
87
|
-
return
|
|
88
|
-
},
|
|
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
|
-
},
|
|
99
|
-
typeof window > "u" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0,
|
|
100
|
-
const t =
|
|
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(),
|
|
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(),
|
|
204
|
+
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), ne());
|
|
113
205
|
}
|
|
114
206
|
}, !0));
|
|
115
|
-
},
|
|
116
|
-
if ((e ||
|
|
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
|
|
120
|
-
if ((
|
|
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
|
-
},
|
|
124
|
-
|
|
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
|
|
129
|
-
|
|
221
|
+
const o = l.getRangeAt(0);
|
|
222
|
+
$ = r && r.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
|
|
130
223
|
}
|
|
131
|
-
await
|
|
132
|
-
const
|
|
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
|
-
},
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
let u = e?.format || "latex",
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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: ${
|
|
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: ${
|
|
190
|
-
<label style="cursor: pointer; color: ${
|
|
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: ${
|
|
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: ${
|
|
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: ${
|
|
205
|
-
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${
|
|
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: ${
|
|
210
|
-
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${
|
|
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 ${
|
|
215
|
-
<button class="cancel-btn" style="padding: 10px 20px; background: ${
|
|
216
|
-
<button id="insert-btn" style="padding: 10px 20px; background: ${
|
|
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
|
-
`,
|
|
219
|
-
const p =
|
|
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(
|
|
316
|
+
return decodeURIComponent(o);
|
|
222
317
|
} catch {
|
|
223
|
-
return
|
|
318
|
+
return o;
|
|
224
319
|
}
|
|
225
|
-
},
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
<button type="button" data-formula="${P(
|
|
229
|
-
<div style="font-weight: 600; font-size: 12px; color: ${
|
|
230
|
-
<div style="font-size: 10px; color: ${
|
|
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
|
-
},
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
if (
|
|
237
|
-
v.innerHTML = `<span style="color: ${
|
|
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
|
|
244
|
-
v.innerHTML =
|
|
338
|
+
const i = window.katex;
|
|
339
|
+
v.innerHTML = i.renderToString(o, { displayMode: !1, throwOnError: !1 });
|
|
245
340
|
} else
|
|
246
|
-
|
|
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: ${
|
|
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,
|
|
348
|
+
b = null, O();
|
|
254
349
|
});
|
|
255
|
-
},
|
|
256
|
-
|
|
350
|
+
}, N = (o) => {
|
|
351
|
+
o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), E());
|
|
257
352
|
}, E = () => {
|
|
258
|
-
document.removeEventListener("keydown",
|
|
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 =
|
|
356
|
+
g.style.color = "#f8fafc", g.style.background = a ? "#334155" : "#e5e7eb", g.style.borderRadius = "4px";
|
|
262
357
|
}, g.onmouseout = () => {
|
|
263
|
-
g.style.color =
|
|
358
|
+
g.style.color = n.muted, g.style.background = "none";
|
|
264
359
|
}, w.onmouseover = () => {
|
|
265
|
-
w.style.background =
|
|
360
|
+
w.style.background = a ? "#475569" : "#f3f4f6";
|
|
266
361
|
}, w.onmouseout = () => {
|
|
267
|
-
w.style.background =
|
|
362
|
+
w.style.background = n.cancelBg;
|
|
268
363
|
}, f.onmouseover = () => {
|
|
269
|
-
f.disabled || (f.style.background =
|
|
364
|
+
f.disabled || (f.style.background = n.insertHover);
|
|
270
365
|
}, f.onmouseout = () => {
|
|
271
|
-
f.style.background =
|
|
272
|
-
},
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
}),
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
}),
|
|
279
|
-
const
|
|
280
|
-
|
|
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
|
|
284
|
-
if (!
|
|
285
|
-
const
|
|
286
|
-
if (
|
|
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
|
-
|
|
290
|
-
displayMode: !
|
|
384
|
+
i.innerHTML = x.renderToString(o, {
|
|
385
|
+
displayMode: !s.inline,
|
|
291
386
|
throwOnError: !1
|
|
292
387
|
});
|
|
293
388
|
} catch {
|
|
294
|
-
|
|
389
|
+
i.textContent = s.inline ? `$${o}$` : `$$${o}$$`;
|
|
295
390
|
}
|
|
296
|
-
} else if (
|
|
297
|
-
|
|
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="${
|
|
300
|
-
|
|
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 (
|
|
303
|
-
|
|
304
|
-
else if (
|
|
305
|
-
|
|
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(
|
|
403
|
+
x.selectNodeContents(y), x.collapse(!1), x.insertNode(i);
|
|
309
404
|
}
|
|
310
|
-
(
|
|
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),
|
|
313
|
-
|
|
314
|
-
}), document.addEventListener("keydown",
|
|
315
|
-
|
|
316
|
-
u =
|
|
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
|
-
|
|
320
|
-
}), p.addEventListener("keydown", (
|
|
321
|
-
(
|
|
322
|
-
}),
|
|
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
|
|
328
|
-
if (
|
|
329
|
-
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(),
|
|
330
|
-
const
|
|
331
|
-
|
|
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
|
|
433
|
+
const ce = () => ({
|
|
339
434
|
name: "math",
|
|
340
|
-
init:
|
|
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
|
|
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
|
-
|
|
454
|
+
ce as MathPlugin
|
|
360
455
|
};
|