@editora/plugins 1.0.22 → 1.1.0
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/README.md +1 -1
- package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-BwhZsI5v.js} +11 -11
- package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-CojLCp6C.mjs} +61 -53
- package/dist/MediaManagerPlugin.native-CycfjOi4.js +1841 -0
- package/dist/MediaManagerPlugin.native-DZrmcmnm.mjs +4688 -0
- package/dist/a11y-checker.cjs.js +3 -3
- package/dist/a11y-checker.esm.js +6 -4
- package/dist/anchor.cjs.js +4 -4
- package/dist/anchor.esm.js +19 -18
- package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
- package/dist/anchoredPopover-Cygmit_o.js +1 -0
- package/dist/approval-workflow.cjs.js +7 -7
- package/dist/approval-workflow.esm.js +55 -54
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +72 -67
- package/dist/blocks-library.cjs.js +18 -19
- package/dist/blocks-library.esm.js +41 -42
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +50 -50
- package/dist/code-sample.cjs.js +10 -10
- package/dist/code-sample.esm.js +4 -4
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/comments.cjs.js +23 -11
- package/dist/comments.esm.js +167 -149
- package/dist/conditional-content.cjs.js +2 -2
- package/dist/conditional-content.esm.js +2 -2
- package/dist/confirmDialog-D3S8BhIM.js +42 -0
- package/dist/confirmDialog-DR4c8j6S.mjs +87 -0
- package/dist/content-rules.cjs.js +6 -6
- package/dist/content-rules.esm.js +51 -51
- package/dist/data-binding.cjs.js +2 -2
- package/dist/data-binding.esm.js +2 -2
- package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
- package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
- package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
- package/dist/embed-iframe.cjs.js +6 -6
- package/dist/embed-iframe.esm.js +6 -6
- package/dist/emojis.cjs.js +5 -5
- package/dist/emojis.esm.js +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +12 -12
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +172 -151
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +96 -83
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +176 -97
- package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
- package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +90 -83
- package/dist/katex-Cc3-mvOY.js +257 -0
- package/dist/katex-DoRnZ_sp.mjs +11682 -0
- package/dist/katex.min--Ws3c9be.mjs +5 -0
- package/dist/katex.min-Dk2VscxB.js +2 -0
- package/dist/link.cjs.js +3 -3
- package/dist/link.esm.js +3 -3
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +140 -52
- package/dist/math.cjs.js +14 -14
- package/dist/math.esm.js +149 -136
- package/dist/media-manager.cjs.js +1 -619
- package/dist/media-manager.esm.js +30 -1017
- package/dist/mentions.cjs.js +12 -12
- package/dist/mentions.esm.js +149 -143
- package/dist/merge-tag.cjs.js +5 -3
- package/dist/merge-tag.esm.js +5 -3
- package/dist/notify-BkbzMopb.js +32 -0
- package/dist/notify-zOp-mUOJ.mjs +59 -0
- package/dist/pii-redaction.cjs.js +1 -1
- package/dist/pii-redaction.esm.js +1 -1
- package/dist/preview.cjs.js +1 -1
- package/dist/preview.esm.js +1 -1
- package/dist/shared-config.cjs.js +1 -1
- package/dist/shared-config.esm.js +14 -14
- package/dist/slash-commands.cjs.js +5 -5
- package/dist/slash-commands.esm.js +259 -236
- package/dist/smart-paste.cjs.js +1 -1
- package/dist/smart-paste.esm.js +1 -1
- package/dist/special-characters.cjs.js +3 -3
- package/dist/special-characters.esm.js +3 -3
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +288 -251
- package/dist/table.cjs.js +14 -14
- package/dist/table.esm.js +175 -154
- package/dist/template.cjs.js +5 -3
- package/dist/template.esm.js +15 -13
- package/dist/text-color.cjs.js +4 -4
- package/dist/text-color.esm.js +38 -34
- package/dist/translation-workflow.cjs.js +9 -9
- package/dist/translation-workflow.esm.js +98 -95
- package/dist/version-diff.cjs.js +4 -4
- package/dist/version-diff.esm.js +36 -36
- package/index.d.ts +183 -2
- package/package.json +6 -5
- package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
- package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
- package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
- package/dist/dialogHelpers-zU6zpMIA.js +0 -12
package/dist/math.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { e as
|
|
2
|
-
import { i as
|
|
3
|
-
const
|
|
1
|
+
import { e as q } from "./escapeHtml-DyksyvcZ.mjs";
|
|
2
|
+
import { i as Q } from "./dialogHelpers-BbwpIXD9.mjs";
|
|
3
|
+
const V = {
|
|
4
4
|
latex: [
|
|
5
5
|
{ name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },
|
|
6
6
|
{ name: "Square Root", formula: "\\sqrt{x}", description: "Square root" },
|
|
@@ -21,8 +21,10 @@ const W = {
|
|
|
21
21
|
{ name: "Parentheses", formula: '<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>', description: "Grouped expression" }
|
|
22
22
|
]
|
|
23
23
|
};
|
|
24
|
-
let
|
|
25
|
-
const
|
|
24
|
+
let S = null, A = null, v = null, L = null;
|
|
25
|
+
const I = "0.16.9";
|
|
26
|
+
let y = null, m = null;
|
|
27
|
+
const T = '[data-theme="dark"], .dark, .editora-theme-dark', J = /* @__PURE__ */ new Set([
|
|
26
28
|
"math",
|
|
27
29
|
"mrow",
|
|
28
30
|
"mi",
|
|
@@ -54,7 +56,7 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
54
56
|
"none",
|
|
55
57
|
"semantics",
|
|
56
58
|
"annotation"
|
|
57
|
-
]),
|
|
59
|
+
]), Y = /* @__PURE__ */ new Set([
|
|
58
60
|
"display",
|
|
59
61
|
"displaystyle",
|
|
60
62
|
"mathvariant",
|
|
@@ -96,44 +98,54 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
96
98
|
"dir",
|
|
97
99
|
"class",
|
|
98
100
|
"id"
|
|
99
|
-
]),
|
|
101
|
+
]), B = (e) => {
|
|
100
102
|
const t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), r = (l) => {
|
|
101
|
-
Array.from(l.childNodes).forEach((
|
|
102
|
-
if (
|
|
103
|
-
const n =
|
|
104
|
-
if (!
|
|
103
|
+
Array.from(l.childNodes).forEach((i) => {
|
|
104
|
+
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
105
|
+
const n = i;
|
|
106
|
+
if (!J.has(n.localName.toLowerCase())) {
|
|
105
107
|
n.remove();
|
|
106
108
|
return;
|
|
107
109
|
}
|
|
108
110
|
Array.from(n.attributes).forEach((c) => {
|
|
109
|
-
|
|
111
|
+
Y.has(c.name.toLowerCase()) || n.removeAttribute(c.name);
|
|
110
112
|
}), r(n);
|
|
111
|
-
} else
|
|
113
|
+
} else i.nodeType !== Node.TEXT_NODE && i.parentNode?.removeChild(i);
|
|
112
114
|
});
|
|
113
115
|
};
|
|
114
116
|
return r(t.body), t.body.innerHTML;
|
|
115
|
-
},
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
}, H = () => window.katex ?? v, P = (e, t) => {
|
|
118
|
+
if (e && !document.getElementById("rte-katex-layout")) {
|
|
119
|
+
const l = document.createElement("style");
|
|
120
|
+
l.id = "rte-katex-layout", l.textContent = e.replace(/@font-face\s*\{[^}]*\}/g, ""), document.head.appendChild(l);
|
|
119
121
|
}
|
|
120
|
-
if (
|
|
121
|
-
const a = setInterval(() => {
|
|
122
|
-
window.katex && (clearInterval(a), e(window.katex));
|
|
123
|
-
}, 100);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
H = !0;
|
|
122
|
+
if (document.querySelector('link[data-rte-katex-css], link[href*="katex"][rel="stylesheet"]')) return;
|
|
127
123
|
const r = document.createElement("link");
|
|
128
|
-
r.rel = "stylesheet", r.href =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
r.rel = "stylesheet", r.href = `https://cdn.jsdelivr.net/npm/katex@${t}/dist/katex.min.css`, r.setAttribute("data-rte-katex-css", ""), document.head.appendChild(r);
|
|
125
|
+
};
|
|
126
|
+
let C = null;
|
|
127
|
+
const ee = () => {
|
|
128
|
+
const e = H();
|
|
129
|
+
return e ? (P(C, e.version ?? I), Promise.resolve(e)) : (L || (L = (async () => {
|
|
130
|
+
try {
|
|
131
|
+
const t = await import("./katex-DoRnZ_sp.mjs");
|
|
132
|
+
v = t.default ?? t;
|
|
133
|
+
} catch {
|
|
134
|
+
v = null;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
C = (await import("./katex.min--Ws3c9be.mjs")).default;
|
|
138
|
+
} catch {
|
|
139
|
+
C = null;
|
|
140
|
+
}
|
|
141
|
+
return P(C, v?.version ?? I), v || (L = null), v;
|
|
142
|
+
})()), L);
|
|
143
|
+
}, j = () => {
|
|
132
144
|
const e = window.getSelection();
|
|
133
145
|
if (!e || e.rangeCount === 0) return null;
|
|
134
146
|
const t = e.getRangeAt(0).startContainer;
|
|
135
147
|
return (t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement)?.closest(".rte-content, .editora-content") || null;
|
|
136
|
-
},
|
|
148
|
+
}, te = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, F = (e) => te(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]') || null, ne = (e, t, r) => {
|
|
137
149
|
if (t !== r) {
|
|
138
150
|
if (typeof window.execEditorCommand == "function") {
|
|
139
151
|
window.execEditorCommand("recordDomTransaction", e, t, r);
|
|
@@ -145,39 +157,39 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
145
157
|
} catch {
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
|
-
},
|
|
160
|
+
}, oe = (e) => {
|
|
149
161
|
if (!(e instanceof Element)) return null;
|
|
150
162
|
const t = e.closest(".math-formula, .math-block");
|
|
151
163
|
return t instanceof HTMLElement ? t : null;
|
|
152
164
|
}, h = () => {
|
|
153
165
|
m && (m.classList.remove("math-object-selected"), m.removeAttribute("data-rte-selected-object"), m = null);
|
|
154
|
-
},
|
|
166
|
+
}, re = (e) => {
|
|
155
167
|
if (m === e) return;
|
|
156
168
|
h(), m = e, e.classList.add("math-object-selected"), e.setAttribute("data-rte-selected-object", "true");
|
|
157
169
|
const t = window.getSelection();
|
|
158
170
|
if (!t) return;
|
|
159
171
|
const r = document.createRange();
|
|
160
172
|
r.selectNode(e), t.removeAllRanges(), t.addRange(r);
|
|
161
|
-
},
|
|
173
|
+
}, ae = (e, t) => {
|
|
162
174
|
const r = window.getSelection();
|
|
163
175
|
if (!r) return;
|
|
164
176
|
const l = document.createRange();
|
|
165
177
|
t && t.parentNode === e ? l.setStartBefore(t) : (l.selectNodeContents(e), l.collapse(!1)), l.collapse(!0), r.removeAllRanges(), r.addRange(l);
|
|
166
|
-
},
|
|
178
|
+
}, ie = (e) => {
|
|
167
179
|
if (e.childNodes.length > 0) return;
|
|
168
180
|
const t = document.createElement("p");
|
|
169
181
|
t.appendChild(document.createElement("br")), e.appendChild(t);
|
|
170
|
-
},
|
|
182
|
+
}, le = () => {
|
|
171
183
|
if (!m || !m.isConnected)
|
|
172
184
|
return h(), !1;
|
|
173
|
-
const e = m, t =
|
|
185
|
+
const e = m, t = F(e);
|
|
174
186
|
if (!t)
|
|
175
187
|
return h(), !1;
|
|
176
188
|
const r = t.innerHTML, l = e.nextSibling;
|
|
177
|
-
e.remove(),
|
|
178
|
-
const
|
|
179
|
-
return
|
|
180
|
-
},
|
|
189
|
+
e.remove(), ie(t), h(), ae(t, l);
|
|
190
|
+
const i = t.innerHTML;
|
|
191
|
+
return ne(t, r, i), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== i;
|
|
192
|
+
}, se = () => {
|
|
181
193
|
if (document.getElementById("math-object-selection-styles")) return;
|
|
182
194
|
const e = document.createElement("style");
|
|
183
195
|
e.id = "math-object-selection-styles", e.textContent = `
|
|
@@ -187,42 +199,42 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
187
199
|
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
|
|
188
200
|
}
|
|
189
201
|
`, document.head.appendChild(e);
|
|
190
|
-
},
|
|
191
|
-
typeof window > "u" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0,
|
|
192
|
-
const t =
|
|
202
|
+
}, ce = () => {
|
|
203
|
+
typeof window > "u" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, se(), document.addEventListener("pointerdown", (e) => {
|
|
204
|
+
const t = oe(e.target);
|
|
193
205
|
if (!t) {
|
|
194
206
|
e.target?.closest?.(".math-dialog-overlay") || h();
|
|
195
207
|
return;
|
|
196
208
|
}
|
|
197
|
-
e.preventDefault(),
|
|
209
|
+
e.preventDefault(), F(t)?.focus(), re(t);
|
|
198
210
|
}, !0), document.addEventListener("keydown", (e) => {
|
|
199
211
|
if (m) {
|
|
200
212
|
if (e.key === "Escape") {
|
|
201
213
|
h();
|
|
202
214
|
return;
|
|
203
215
|
}
|
|
204
|
-
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(),
|
|
216
|
+
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), le());
|
|
205
217
|
}
|
|
206
218
|
}, !0));
|
|
207
|
-
},
|
|
208
|
-
if ((e ||
|
|
219
|
+
}, de = (e) => {
|
|
220
|
+
if ((e || j())?.closest(T)) return !0;
|
|
209
221
|
const r = window.getSelection();
|
|
210
222
|
if (r && r.rangeCount > 0) {
|
|
211
|
-
const
|
|
212
|
-
if ((
|
|
223
|
+
const i = r.getRangeAt(0).startContainer;
|
|
224
|
+
if ((i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement)?.closest(T)) return !0;
|
|
213
225
|
}
|
|
214
|
-
return document.activeElement?.closest(
|
|
215
|
-
},
|
|
226
|
+
return document.activeElement?.closest(T) ? !0 : document.body.matches(T) || document.documentElement.matches(T);
|
|
227
|
+
}, O = async (e, t) => {
|
|
216
228
|
document.querySelectorAll(".math-dialog-overlay").forEach((o) => o.remove());
|
|
217
|
-
const r = t ||
|
|
229
|
+
const r = t || A?.closest(".rte-content, .editora-content") || j() || y;
|
|
218
230
|
y = r || null;
|
|
219
231
|
const l = window.getSelection();
|
|
220
232
|
if (l && l.rangeCount > 0) {
|
|
221
233
|
const o = l.getRangeAt(0);
|
|
222
|
-
|
|
234
|
+
S = r && r.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
|
|
223
235
|
}
|
|
224
|
-
await
|
|
225
|
-
const
|
|
236
|
+
await ee();
|
|
237
|
+
const i = de(r), n = i ? {
|
|
226
238
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
227
239
|
dialogBg: "#1f2937",
|
|
228
240
|
border: "#3b4657",
|
|
@@ -251,13 +263,13 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
251
263
|
fieldBg: "#ffffff",
|
|
252
264
|
fieldBorder: "#ced4da",
|
|
253
265
|
text: "#1f2937",
|
|
254
|
-
muted: "#
|
|
266
|
+
muted: "#5c636a",
|
|
255
267
|
templateBtnBg: "#ffffff",
|
|
256
268
|
templateBtnHover: "#f8f9fa",
|
|
257
269
|
templateBtnText: "#1f2937",
|
|
258
|
-
templateSubText: "#
|
|
270
|
+
templateSubText: "#5c636a",
|
|
259
271
|
previewBg: "#f8f9fa",
|
|
260
|
-
previewText: "#
|
|
272
|
+
previewText: "#5c636a",
|
|
261
273
|
cancelBg: "#ffffff",
|
|
262
274
|
cancelText: "#1f2937",
|
|
263
275
|
cancelBorder: "#ced4da",
|
|
@@ -265,12 +277,12 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
265
277
|
insertHover: "#0069d9",
|
|
266
278
|
invalid: "#cc0000"
|
|
267
279
|
}, c = document.createElement("div");
|
|
268
|
-
|
|
280
|
+
Q(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
281
|
const d = document.createElement("div");
|
|
270
282
|
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",
|
|
272
|
-
const
|
|
273
|
-
let
|
|
283
|
+
let u = e?.format || "latex", N = e?.formula || "";
|
|
284
|
+
const K = e?.inline !== !1;
|
|
285
|
+
let x = null, D = "";
|
|
274
286
|
d.innerHTML = `
|
|
275
287
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${n.border}; background: ${n.panelBg};">
|
|
276
288
|
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${n.text};">${e ? "Edit" : "Insert"} Math Formula</h2>
|
|
@@ -279,30 +291,30 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
279
291
|
|
|
280
292
|
<div style="padding: 20px; overflow-y: auto; flex: 1;">
|
|
281
293
|
<div style="margin-bottom: 20px;">
|
|
282
|
-
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Format:</
|
|
283
|
-
<div style="display: flex; gap: 16px;">
|
|
294
|
+
<span id="math-format-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Format:</span>
|
|
295
|
+
<div role="radiogroup" aria-labelledby="math-format-label" style="display: flex; gap: 16px;">
|
|
284
296
|
<label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="latex" ${u === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
|
|
285
297
|
<label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="mathml" ${u === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
|
|
286
298
|
</div>
|
|
287
299
|
</div>
|
|
288
300
|
|
|
289
301
|
<div style="margin-bottom: 20px;">
|
|
290
|
-
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Quick Templates:</
|
|
291
|
-
<div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
|
|
302
|
+
<span id="math-templates-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Quick Templates:</span>
|
|
303
|
+
<div id="templates-grid" role="group" aria-labelledby="math-templates-label" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;"></div>
|
|
292
304
|
</div>
|
|
293
305
|
|
|
294
306
|
<div style="margin-bottom: 20px;">
|
|
295
|
-
<label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${
|
|
307
|
+
<label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${K ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
|
|
296
308
|
</div>
|
|
297
309
|
|
|
298
310
|
<div style="margin-bottom: 20px;">
|
|
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;">${
|
|
311
|
+
<label for="formula-input" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Formula:</label>
|
|
312
|
+
<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;">${q(N)}</textarea>
|
|
301
313
|
</div>
|
|
302
314
|
|
|
303
315
|
<div style="margin-bottom: 20px;">
|
|
304
|
-
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Preview:</
|
|
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>
|
|
316
|
+
<span id="math-preview-label" style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Preview:</span>
|
|
317
|
+
<div id="preview-area" role="status" aria-labelledby="math-preview-label" style="min-height: 60px; padding: 15px; border: 1px solid ${n.fieldBorder}; border-radius: 4px; background: ${n.previewBg}; display: flex; align-items: center; justify-content: center; color: ${n.previewText};"></div>
|
|
306
318
|
</div>
|
|
307
319
|
</div>
|
|
308
320
|
|
|
@@ -311,128 +323,129 @@ const k = '[data-theme="dark"], .dark, .editora-theme-dark', X = /* @__PURE__ */
|
|
|
311
323
|
<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>
|
|
312
324
|
</div>
|
|
313
325
|
`, c.appendChild(d), document.body.appendChild(c);
|
|
314
|
-
const p = d.querySelector("#formula-input"),
|
|
326
|
+
const p = d.querySelector("#formula-input"), w = d.querySelector("#preview-area"), M = d.querySelector("#templates-grid"), X = d.querySelectorAll('input[name="format"]'), U = d.querySelector("#inline-cb"), f = d.querySelector("#insert-btn"), g = d.querySelector(".close-btn"), E = d.querySelector(".cancel-btn"), W = (o) => encodeURIComponent(o), G = (o) => {
|
|
315
327
|
try {
|
|
316
328
|
return decodeURIComponent(o);
|
|
317
329
|
} catch {
|
|
318
330
|
return o;
|
|
319
331
|
}
|
|
320
|
-
},
|
|
321
|
-
const o =
|
|
322
|
-
|
|
323
|
-
<button type="button" data-formula="${
|
|
332
|
+
}, _ = () => {
|
|
333
|
+
const o = V[u];
|
|
334
|
+
M.innerHTML = o.map((s) => `
|
|
335
|
+
<button type="button" data-formula="${W(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
336
|
<div style="font-weight: 600; font-size: 12px; color: ${n.templateBtnText};">${s.name}</div>
|
|
325
337
|
<div style="font-size: 10px; color: ${n.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${s.formula.substring(0, 20)}...</div>
|
|
326
338
|
</button>
|
|
327
339
|
`).join("");
|
|
328
|
-
},
|
|
340
|
+
}, Z = () => {
|
|
329
341
|
const o = p.value.trim(), s = `${u}:${o}`;
|
|
330
|
-
if (s !==
|
|
331
|
-
if (
|
|
332
|
-
|
|
342
|
+
if (s !== D) {
|
|
343
|
+
if (D = s, !o) {
|
|
344
|
+
w.innerHTML = `<span style="color: ${n.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
|
|
333
345
|
return;
|
|
334
346
|
}
|
|
335
347
|
f.disabled = !1;
|
|
336
348
|
try {
|
|
337
349
|
if (u === "latex") {
|
|
338
|
-
const
|
|
339
|
-
|
|
350
|
+
const a = H();
|
|
351
|
+
w.innerHTML = a ? a.renderToString(o, { displayMode: !1, throwOnError: !1 }) : `<code style="font-family: 'Courier New', monospace; color: ${n.previewText};">${q(o)}</code>`;
|
|
340
352
|
} else
|
|
341
|
-
o.trim().startsWith("<math") ?
|
|
353
|
+
o.trim().startsWith("<math") ? w.innerHTML = B(o) : w.innerHTML = B(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${o}</math>`);
|
|
342
354
|
} catch {
|
|
343
|
-
|
|
355
|
+
w.innerHTML = `<span style="color: ${n.invalid};">Invalid formula</span>`;
|
|
344
356
|
}
|
|
345
357
|
}
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
|
|
358
|
+
}, $ = () => {
|
|
359
|
+
x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
|
|
360
|
+
x = null, Z();
|
|
349
361
|
});
|
|
350
|
-
},
|
|
351
|
-
o.key === "Escape" && (o.preventDefault(), o.stopPropagation(),
|
|
352
|
-
},
|
|
353
|
-
document.removeEventListener("keydown",
|
|
362
|
+
}, z = (o) => {
|
|
363
|
+
o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), k());
|
|
364
|
+
}, k = () => {
|
|
365
|
+
document.removeEventListener("keydown", z, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
|
|
354
366
|
};
|
|
355
367
|
g.onmouseover = () => {
|
|
356
|
-
g.style.color = "#f8fafc", g.style.background =
|
|
368
|
+
g.style.color = "#f8fafc", g.style.background = i ? "#334155" : "#e5e7eb", g.style.borderRadius = "4px";
|
|
357
369
|
}, g.onmouseout = () => {
|
|
358
370
|
g.style.color = n.muted, g.style.background = "none";
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
},
|
|
362
|
-
|
|
371
|
+
}, E.onmouseover = () => {
|
|
372
|
+
E.style.background = i ? "#475569" : "#f3f4f6";
|
|
373
|
+
}, E.onmouseout = () => {
|
|
374
|
+
E.style.background = n.cancelBg;
|
|
363
375
|
}, f.onmouseover = () => {
|
|
364
376
|
f.disabled || (f.style.background = n.insertHover);
|
|
365
377
|
}, f.onmouseout = () => {
|
|
366
378
|
f.style.background = n.insertBg;
|
|
367
|
-
},
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
}),
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
}),
|
|
374
|
-
const
|
|
375
|
-
|
|
379
|
+
}, M.addEventListener("mouseover", (o) => {
|
|
380
|
+
const a = o.target.closest("button[data-formula]");
|
|
381
|
+
a && (a.style.background = n.templateBtnHover);
|
|
382
|
+
}), M.addEventListener("mouseout", (o) => {
|
|
383
|
+
const a = o.target.closest("button[data-formula]");
|
|
384
|
+
a && (a.style.background = n.templateBtnBg);
|
|
385
|
+
}), M.addEventListener("click", (o) => {
|
|
386
|
+
const a = o.target.closest("button[data-formula]");
|
|
387
|
+
a && (p.value = G(a.getAttribute("data-formula") || ""), N = p.value, $());
|
|
376
388
|
});
|
|
377
|
-
const
|
|
389
|
+
const R = () => {
|
|
378
390
|
const o = p.value.trim();
|
|
379
391
|
if (!o) return;
|
|
380
|
-
const s = { formula: o, format: u, inline:
|
|
381
|
-
if (
|
|
382
|
-
const
|
|
392
|
+
const s = { formula: o, format: u, inline: U.checked }, a = s.inline ? document.createElement("span") : document.createElement("div");
|
|
393
|
+
if (a.className = s.inline ? "math-formula" : "math-block", a.setAttribute("data-math-formula", o), a.setAttribute("data-math-format", u), a.contentEditable = "false", a.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") {
|
|
394
|
+
const b = H();
|
|
383
395
|
try {
|
|
384
|
-
|
|
396
|
+
if (!b) throw new Error("KaTeX is not available");
|
|
397
|
+
a.innerHTML = b.renderToString(o, {
|
|
385
398
|
displayMode: !s.inline,
|
|
386
399
|
throwOnError: !1
|
|
387
400
|
});
|
|
388
401
|
} catch {
|
|
389
|
-
|
|
402
|
+
a.textContent = s.inline ? `$${o}$` : `$$${o}$$`;
|
|
390
403
|
}
|
|
391
404
|
} else if (o.trim().startsWith("<math"))
|
|
392
|
-
|
|
405
|
+
a.innerHTML = B(o);
|
|
393
406
|
else {
|
|
394
|
-
const
|
|
395
|
-
|
|
407
|
+
const b = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${s.inline ? "inline" : "block"}">${o}</math>`;
|
|
408
|
+
a.innerHTML = B(b);
|
|
396
409
|
}
|
|
397
|
-
if (
|
|
398
|
-
|
|
399
|
-
else if (
|
|
400
|
-
|
|
410
|
+
if (A)
|
|
411
|
+
A.replaceWith(a);
|
|
412
|
+
else if (S)
|
|
413
|
+
S.deleteContents(), S.insertNode(a);
|
|
401
414
|
else if (y && y.isConnected) {
|
|
402
|
-
const
|
|
403
|
-
|
|
415
|
+
const b = document.createRange();
|
|
416
|
+
b.selectNodeContents(y), b.collapse(!1), b.insertNode(a);
|
|
404
417
|
}
|
|
405
|
-
(
|
|
418
|
+
(a.closest(".rte-content, .editora-content") || y)?.dispatchEvent(new Event("input", { bubbles: !0 })), k();
|
|
406
419
|
};
|
|
407
|
-
g.addEventListener("click",
|
|
408
|
-
o.target === c &&
|
|
409
|
-
}), document.addEventListener("keydown",
|
|
420
|
+
g.addEventListener("click", k), E.addEventListener("click", k), f.addEventListener("click", R), c.addEventListener("click", (o) => {
|
|
421
|
+
o.target === c && k();
|
|
422
|
+
}), document.addEventListener("keydown", z, !0), X.forEach((o) => {
|
|
410
423
|
o.addEventListener("change", (s) => {
|
|
411
|
-
u = s.target.value,
|
|
424
|
+
u = s.target.value, D = "", _(), $();
|
|
412
425
|
});
|
|
413
426
|
}), p.addEventListener("input", () => {
|
|
414
|
-
|
|
427
|
+
N = p.value, $();
|
|
415
428
|
}), p.addEventListener("keydown", (o) => {
|
|
416
|
-
(o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(),
|
|
417
|
-
}),
|
|
429
|
+
(o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(), R());
|
|
430
|
+
}), _(), $(), p.focus();
|
|
418
431
|
};
|
|
419
432
|
if (typeof window < "u" && !window.__mathPluginDoubleClickInitialized) {
|
|
420
433
|
window.__mathPluginDoubleClickInitialized = !0;
|
|
421
434
|
const e = (r) => {
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(),
|
|
425
|
-
const n =
|
|
426
|
-
|
|
435
|
+
const i = r.target.closest(".math-formula, .math-block");
|
|
436
|
+
if (i) {
|
|
437
|
+
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), A = i;
|
|
438
|
+
const n = i.getAttribute("data-math-formula") || "", c = i.getAttribute("data-math-format") || "latex", d = i.classList.contains("math-formula");
|
|
439
|
+
O({ formula: n, format: c, inline: d });
|
|
427
440
|
}
|
|
428
441
|
}, t = () => {
|
|
429
442
|
document.addEventListener("dblclick", e, { capture: !0 });
|
|
430
443
|
};
|
|
431
444
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : setTimeout(t, 100);
|
|
432
445
|
}
|
|
433
|
-
const
|
|
446
|
+
const fe = () => ({
|
|
434
447
|
name: "math",
|
|
435
|
-
init:
|
|
448
|
+
init: ce,
|
|
436
449
|
toolbar: [
|
|
437
450
|
{
|
|
438
451
|
label: "Insert Math",
|
|
@@ -443,7 +456,7 @@ const ce = () => ({
|
|
|
443
456
|
commands: {
|
|
444
457
|
insertMath: (e, t) => {
|
|
445
458
|
const r = t?.contentElement instanceof HTMLElement ? t.contentElement : null;
|
|
446
|
-
return
|
|
459
|
+
return O(void 0, r), !0;
|
|
447
460
|
}
|
|
448
461
|
},
|
|
449
462
|
keymap: {
|
|
@@ -451,5 +464,5 @@ const ce = () => ({
|
|
|
451
464
|
}
|
|
452
465
|
});
|
|
453
466
|
export {
|
|
454
|
-
|
|
467
|
+
fe as MathPlugin
|
|
455
468
|
};
|