@editora/core 1.0.15 → 1.0.16
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/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
- package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
- package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
- package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
- package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
- package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
- package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
- package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
- package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
- package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
- package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
- package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
- package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
- package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
- package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
- package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
- package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
- package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
- package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
- package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
- package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
- package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
- package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
- package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
- package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
- package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
- package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
- package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
- package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
- package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
- package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
- package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
- package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
- package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
- package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
- package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
- package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
- package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
- package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
- package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
- package/dist/core.css +1 -1
- package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
- package/dist/editora.min.js +26 -24
- package/dist/editora.umd.js +26 -24
- package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
- package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
- package/dist/index-B1_vtXRz.mjs +3910 -0
- package/dist/index-C6BoNR2t.js +12 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +17 -14
- package/dist/plugin-loader.js +53 -52
- package/dist/webcomponent-core.js +2039 -473
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +96 -66
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +2208 -641
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +1564 -1198
- package/index.d.ts +32 -0
- package/package.json +10 -3
- package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
- package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
- package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
- package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
- package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
- package/dist/index-BLm1MtzH.js +0 -10
- package/dist/index-Cd9jEuZP.mjs +0 -2341
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { e as U } from "./escapeHtml-CX8RelZ1.mjs";
|
|
2
|
+
import { i as W } from "./dialogHelpers-DBf7WqYH.mjs";
|
|
3
|
+
const X = {
|
|
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,32 +21,123 @@ const K = {
|
|
|
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
|
|
24
|
+
let L = null, v = null, z = !1, y = null, m = null;
|
|
25
|
+
const T = '[data-theme="dark"], .dark, .editora-theme-dark', G = /* @__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
|
+
]), Z = /* @__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
|
+
]), S = (e) => {
|
|
100
|
+
const t = new DOMParser().parseFromString(`<body>${e}</body>`, "text/html"), r = (i) => {
|
|
101
|
+
Array.from(i.childNodes).forEach((a) => {
|
|
102
|
+
var n;
|
|
103
|
+
if (a.nodeType === Node.ELEMENT_NODE) {
|
|
104
|
+
const c = a;
|
|
105
|
+
if (!G.has(c.localName.toLowerCase())) {
|
|
106
|
+
c.remove();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
Array.from(c.attributes).forEach((d) => {
|
|
110
|
+
Z.has(d.name.toLowerCase()) || c.removeAttribute(d.name);
|
|
111
|
+
}), r(c);
|
|
112
|
+
} else a.nodeType !== Node.TEXT_NODE && ((n = a.parentNode) == null || n.removeChild(a));
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
return r(t.body), t.body.innerHTML;
|
|
116
|
+
}, Q = () => new Promise((e, t) => {
|
|
24
117
|
if (window.katex) {
|
|
25
118
|
e(window.katex);
|
|
26
119
|
return;
|
|
27
120
|
}
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
window.katex && (clearInterval(
|
|
121
|
+
if (z) {
|
|
122
|
+
const a = setInterval(() => {
|
|
123
|
+
window.katex && (clearInterval(a), e(window.katex));
|
|
31
124
|
}, 100);
|
|
32
125
|
return;
|
|
33
126
|
}
|
|
34
|
-
|
|
127
|
+
z = !0;
|
|
35
128
|
const r = document.createElement("link");
|
|
36
129
|
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
|
-
}),
|
|
130
|
+
const i = document.createElement("script");
|
|
131
|
+
i.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", i.onload = () => e(window.katex), i.onerror = t, document.head.appendChild(i);
|
|
132
|
+
}), R = () => {
|
|
40
133
|
const e = window.getSelection();
|
|
41
134
|
if (!e || e.rangeCount === 0) return null;
|
|
42
135
|
const t = e.getRangeAt(0).startContainer, r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
43
136
|
return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
|
|
44
|
-
},
|
|
45
|
-
const t =
|
|
137
|
+
}, J = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, j = (e) => {
|
|
138
|
+
const t = J(e);
|
|
46
139
|
return (t == null ? void 0 : t.closest('.rte-content, .editora-content, [contenteditable="true"]')) || null;
|
|
47
|
-
},
|
|
140
|
+
}, V = (e, t, r) => {
|
|
48
141
|
if (t !== r) {
|
|
49
142
|
if (typeof window.execEditorCommand == "function") {
|
|
50
143
|
window.execEditorCommand("recordDomTransaction", e, t, r);
|
|
@@ -53,42 +146,42 @@ const $ = '[data-theme="dark"], .dark, .editora-theme-dark', U = () => new Promi
|
|
|
53
146
|
if (typeof window.executeEditorCommand == "function")
|
|
54
147
|
try {
|
|
55
148
|
window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: r });
|
|
56
|
-
} catch (
|
|
149
|
+
} catch (i) {
|
|
57
150
|
}
|
|
58
151
|
}
|
|
59
|
-
},
|
|
152
|
+
}, Y = (e) => {
|
|
60
153
|
if (!(e instanceof Element)) return null;
|
|
61
154
|
const t = e.closest(".math-formula, .math-block");
|
|
62
155
|
return t instanceof HTMLElement ? t : null;
|
|
63
156
|
}, h = () => {
|
|
64
157
|
m && (m.classList.remove("math-object-selected"), m.removeAttribute("data-rte-selected-object"), m = null);
|
|
65
|
-
},
|
|
158
|
+
}, ee = (e) => {
|
|
66
159
|
if (m === e) return;
|
|
67
160
|
h(), m = e, e.classList.add("math-object-selected"), e.setAttribute("data-rte-selected-object", "true");
|
|
68
161
|
const t = window.getSelection();
|
|
69
162
|
if (!t) return;
|
|
70
163
|
const r = document.createRange();
|
|
71
164
|
r.selectNode(e), t.removeAllRanges(), t.addRange(r);
|
|
72
|
-
},
|
|
165
|
+
}, te = (e, t) => {
|
|
73
166
|
const r = window.getSelection();
|
|
74
167
|
if (!r) return;
|
|
75
|
-
const
|
|
76
|
-
t && t.parentNode === e ?
|
|
77
|
-
},
|
|
168
|
+
const i = document.createRange();
|
|
169
|
+
t && t.parentNode === e ? i.setStartBefore(t) : (i.selectNodeContents(e), i.collapse(!1)), i.collapse(!0), r.removeAllRanges(), r.addRange(i);
|
|
170
|
+
}, ne = (e) => {
|
|
78
171
|
if (e.childNodes.length > 0) return;
|
|
79
172
|
const t = document.createElement("p");
|
|
80
173
|
t.appendChild(document.createElement("br")), e.appendChild(t);
|
|
81
|
-
},
|
|
174
|
+
}, oe = () => {
|
|
82
175
|
if (!m || !m.isConnected)
|
|
83
176
|
return h(), !1;
|
|
84
|
-
const e = m, t =
|
|
177
|
+
const e = m, t = j(e);
|
|
85
178
|
if (!t)
|
|
86
179
|
return h(), !1;
|
|
87
|
-
const r = t.innerHTML,
|
|
88
|
-
e.remove(),
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
},
|
|
180
|
+
const r = t.innerHTML, i = e.nextSibling;
|
|
181
|
+
e.remove(), ne(t), h(), te(t, i);
|
|
182
|
+
const a = t.innerHTML;
|
|
183
|
+
return V(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
|
|
184
|
+
}, re = () => {
|
|
92
185
|
if (document.getElementById("math-object-selection-styles")) return;
|
|
93
186
|
const e = document.createElement("style");
|
|
94
187
|
e.id = "math-object-selection-styles", e.textContent = `
|
|
@@ -98,45 +191,46 @@ const $ = '[data-theme="dark"], .dark, .editora-theme-dark', U = () => new Promi
|
|
|
98
191
|
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
|
|
99
192
|
}
|
|
100
193
|
`, document.head.appendChild(e);
|
|
101
|
-
},
|
|
102
|
-
typeof window == "undefined" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0,
|
|
103
|
-
var r,
|
|
104
|
-
const t =
|
|
194
|
+
}, ae = () => {
|
|
195
|
+
typeof window == "undefined" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, re(), document.addEventListener("pointerdown", (e) => {
|
|
196
|
+
var r, i;
|
|
197
|
+
const t = Y(e.target);
|
|
105
198
|
if (!t) {
|
|
106
|
-
const
|
|
107
|
-
(r =
|
|
199
|
+
const a = e.target;
|
|
200
|
+
(r = a == null ? void 0 : a.closest) != null && r.call(a, ".math-dialog-overlay") || h();
|
|
108
201
|
return;
|
|
109
202
|
}
|
|
110
|
-
e.preventDefault(), (
|
|
203
|
+
e.preventDefault(), (i = j(t)) == null || i.focus(), ee(t);
|
|
111
204
|
}, !0), document.addEventListener("keydown", (e) => {
|
|
112
205
|
if (m) {
|
|
113
206
|
if (e.key === "Escape") {
|
|
114
207
|
h();
|
|
115
208
|
return;
|
|
116
209
|
}
|
|
117
|
-
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(),
|
|
210
|
+
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), oe());
|
|
118
211
|
}
|
|
119
212
|
}, !0));
|
|
120
|
-
},
|
|
121
|
-
const t = e ||
|
|
122
|
-
if (t != null && t.closest(
|
|
213
|
+
}, ie = (e) => {
|
|
214
|
+
const t = e || R();
|
|
215
|
+
if (t != null && t.closest(T)) return !0;
|
|
123
216
|
const r = window.getSelection();
|
|
124
217
|
if (r && r.rangeCount > 0) {
|
|
125
|
-
const
|
|
126
|
-
if (n != null && n.closest(
|
|
218
|
+
const a = r.getRangeAt(0).startContainer, n = a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement;
|
|
219
|
+
if (n != null && n.closest(T)) return !0;
|
|
127
220
|
}
|
|
128
|
-
const
|
|
129
|
-
return
|
|
130
|
-
},
|
|
131
|
-
|
|
221
|
+
const i = document.activeElement;
|
|
222
|
+
return i != null && i.closest(T) ? !0 : document.body.matches(T) || document.documentElement.matches(T);
|
|
223
|
+
}, I = async (e, t) => {
|
|
224
|
+
document.querySelectorAll(".math-dialog-overlay").forEach((o) => o.remove());
|
|
225
|
+
const r = t || (v == null ? void 0 : v.closest(".rte-content, .editora-content")) || R() || y;
|
|
132
226
|
y = r || null;
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
const o =
|
|
136
|
-
|
|
227
|
+
const i = window.getSelection();
|
|
228
|
+
if (i && i.rangeCount > 0) {
|
|
229
|
+
const o = i.getRangeAt(0);
|
|
230
|
+
L = r && r.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
|
|
137
231
|
}
|
|
138
|
-
await
|
|
139
|
-
const
|
|
232
|
+
await Q();
|
|
233
|
+
const a = ie(r), n = a ? {
|
|
140
234
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
141
235
|
dialogBg: "#1f2937",
|
|
142
236
|
border: "#3b4657",
|
|
@@ -178,12 +272,14 @@ const $ = '[data-theme="dark"], .dark, .editora-theme-dark', U = () => new Promi
|
|
|
178
272
|
insertBg: "#007bff",
|
|
179
273
|
insertHover: "#0069d9",
|
|
180
274
|
invalid: "#cc0000"
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
let u = (e == null ? void 0 : e.format) || "latex",
|
|
186
|
-
|
|
275
|
+
}, c = document.createElement("div");
|
|
276
|
+
W(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;`;
|
|
277
|
+
const d = document.createElement("div");
|
|
278
|
+
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};`;
|
|
279
|
+
let u = (e == null ? void 0 : e.format) || "latex", B = (e == null ? void 0 : e.formula) || "";
|
|
280
|
+
const q = (e == null ? void 0 : e.inline) !== !1;
|
|
281
|
+
let g = null, C = "";
|
|
282
|
+
d.innerHTML = `
|
|
187
283
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${n.border}; background: ${n.panelBg};">
|
|
188
284
|
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${n.text};">${e ? "Edit" : "Insert"} Math Formula</h2>
|
|
189
285
|
<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>
|
|
@@ -204,12 +300,12 @@ const $ = '[data-theme="dark"], .dark, .editora-theme-dark', U = () => new Promi
|
|
|
204
300
|
</div>
|
|
205
301
|
|
|
206
302
|
<div style="margin-bottom: 20px;">
|
|
207
|
-
<label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${
|
|
303
|
+
<label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${q ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
|
|
208
304
|
</div>
|
|
209
305
|
|
|
210
306
|
<div style="margin-bottom: 20px;">
|
|
211
307
|
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Formula:</label>
|
|
212
|
-
<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;">${
|
|
308
|
+
<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;">${U(B)}</textarea>
|
|
213
309
|
</div>
|
|
214
310
|
|
|
215
311
|
<div style="margin-bottom: 20px;">
|
|
@@ -222,130 +318,130 @@ const $ = '[data-theme="dark"], .dark, .editora-theme-dark', U = () => new Promi
|
|
|
222
318
|
<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>
|
|
223
319
|
<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>
|
|
224
320
|
</div>
|
|
225
|
-
`,
|
|
226
|
-
const p =
|
|
321
|
+
`, c.appendChild(d), document.body.appendChild(c);
|
|
322
|
+
const p = d.querySelector("#formula-input"), w = d.querySelector("#preview-area"), M = d.querySelector("#templates-grid"), P = d.querySelectorAll('input[name="format"]'), F = d.querySelector("#inline-cb"), f = d.querySelector("#insert-btn"), b = d.querySelector(".close-btn"), E = d.querySelector(".cancel-btn"), D = (o) => encodeURIComponent(o), O = (o) => {
|
|
227
323
|
try {
|
|
228
324
|
return decodeURIComponent(o);
|
|
229
325
|
} catch (s) {
|
|
230
326
|
return o;
|
|
231
327
|
}
|
|
232
|
-
},
|
|
233
|
-
const o =
|
|
234
|
-
|
|
235
|
-
<button type="button" data-formula="${
|
|
328
|
+
}, N = () => {
|
|
329
|
+
const o = X[u];
|
|
330
|
+
M.innerHTML = o.map((s) => `
|
|
331
|
+
<button type="button" data-formula="${D(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;">
|
|
236
332
|
<div style="font-weight: 600; font-size: 12px; color: ${n.templateBtnText};">${s.name}</div>
|
|
237
333
|
<div style="font-size: 10px; color: ${n.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${s.formula.substring(0, 20)}...</div>
|
|
238
334
|
</button>
|
|
239
335
|
`).join("");
|
|
240
|
-
},
|
|
336
|
+
}, K = () => {
|
|
241
337
|
const o = p.value.trim(), s = `${u}:${o}`;
|
|
242
|
-
if (s !==
|
|
243
|
-
if (
|
|
338
|
+
if (s !== C) {
|
|
339
|
+
if (C = s, !o) {
|
|
244
340
|
w.innerHTML = `<span style="color: ${n.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
|
|
245
341
|
return;
|
|
246
342
|
}
|
|
247
343
|
f.disabled = !1;
|
|
248
344
|
try {
|
|
249
345
|
if (u === "latex") {
|
|
250
|
-
const
|
|
251
|
-
w.innerHTML =
|
|
346
|
+
const l = window.katex;
|
|
347
|
+
w.innerHTML = l.renderToString(o, { displayMode: !1, throwOnError: !1 });
|
|
252
348
|
} else
|
|
253
|
-
o.trim().startsWith("<math") ? w.innerHTML = o : w.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${o}</math
|
|
254
|
-
} catch (
|
|
349
|
+
o.trim().startsWith("<math") ? w.innerHTML = S(o) : w.innerHTML = S(`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${o}</math>`);
|
|
350
|
+
} catch (l) {
|
|
255
351
|
w.innerHTML = `<span style="color: ${n.invalid};">Invalid formula</span>`;
|
|
256
352
|
}
|
|
257
353
|
}
|
|
258
|
-
},
|
|
354
|
+
}, $ = () => {
|
|
259
355
|
g !== null && cancelAnimationFrame(g), g = requestAnimationFrame(() => {
|
|
260
|
-
g = null,
|
|
356
|
+
g = null, K();
|
|
261
357
|
});
|
|
262
358
|
}, H = (o) => {
|
|
263
359
|
o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), k());
|
|
264
360
|
}, k = () => {
|
|
265
|
-
document.removeEventListener("keydown", H, !0), g !== null && (cancelAnimationFrame(g), g = null),
|
|
361
|
+
document.removeEventListener("keydown", H, !0), g !== null && (cancelAnimationFrame(g), g = null), c.parentNode && c.parentNode.removeChild(c);
|
|
266
362
|
};
|
|
267
363
|
b.onmouseover = () => {
|
|
268
|
-
b.style.color = "#f8fafc", b.style.background =
|
|
364
|
+
b.style.color = "#f8fafc", b.style.background = a ? "#334155" : "#e5e7eb", b.style.borderRadius = "4px";
|
|
269
365
|
}, b.onmouseout = () => {
|
|
270
366
|
b.style.color = n.muted, b.style.background = "none";
|
|
271
367
|
}, E.onmouseover = () => {
|
|
272
|
-
E.style.background =
|
|
368
|
+
E.style.background = a ? "#475569" : "#f3f4f6";
|
|
273
369
|
}, E.onmouseout = () => {
|
|
274
370
|
E.style.background = n.cancelBg;
|
|
275
371
|
}, f.onmouseover = () => {
|
|
276
372
|
f.disabled || (f.style.background = n.insertHover);
|
|
277
373
|
}, f.onmouseout = () => {
|
|
278
374
|
f.style.background = n.insertBg;
|
|
279
|
-
},
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
}),
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
}),
|
|
286
|
-
const
|
|
287
|
-
|
|
375
|
+
}, M.addEventListener("mouseover", (o) => {
|
|
376
|
+
const l = o.target.closest("button[data-formula]");
|
|
377
|
+
l && (l.style.background = n.templateBtnHover);
|
|
378
|
+
}), M.addEventListener("mouseout", (o) => {
|
|
379
|
+
const l = o.target.closest("button[data-formula]");
|
|
380
|
+
l && (l.style.background = n.templateBtnBg);
|
|
381
|
+
}), M.addEventListener("click", (o) => {
|
|
382
|
+
const l = o.target.closest("button[data-formula]");
|
|
383
|
+
l && (p.value = O(l.getAttribute("data-formula") || ""), B = p.value, $());
|
|
288
384
|
});
|
|
289
|
-
const
|
|
385
|
+
const _ = () => {
|
|
290
386
|
const o = p.value.trim();
|
|
291
387
|
if (!o) return;
|
|
292
|
-
const s = { formula: o, format: u, inline:
|
|
293
|
-
if (
|
|
388
|
+
const s = { formula: o, format: u, inline: F.checked }, l = s.inline ? document.createElement("span") : document.createElement("div");
|
|
389
|
+
if (l.className = s.inline ? "math-formula" : "math-block", l.setAttribute("data-math-formula", o), l.setAttribute("data-math-format", u), l.contentEditable = "false", l.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") {
|
|
294
390
|
const x = window.katex;
|
|
295
391
|
try {
|
|
296
|
-
|
|
392
|
+
l.innerHTML = x.renderToString(o, {
|
|
297
393
|
displayMode: !s.inline,
|
|
298
394
|
throwOnError: !1
|
|
299
395
|
});
|
|
300
|
-
} catch (
|
|
301
|
-
|
|
396
|
+
} catch (le) {
|
|
397
|
+
l.textContent = s.inline ? `$${o}$` : `$$${o}$$`;
|
|
302
398
|
}
|
|
303
399
|
} else if (o.trim().startsWith("<math"))
|
|
304
|
-
|
|
400
|
+
l.innerHTML = S(o);
|
|
305
401
|
else {
|
|
306
402
|
const x = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${s.inline ? "inline" : "block"}">${o}</math>`;
|
|
307
|
-
|
|
403
|
+
l.innerHTML = S(x);
|
|
308
404
|
}
|
|
309
405
|
if (v)
|
|
310
|
-
v.replaceWith(
|
|
311
|
-
else if (
|
|
312
|
-
|
|
406
|
+
v.replaceWith(l);
|
|
407
|
+
else if (L)
|
|
408
|
+
L.deleteContents(), L.insertNode(l);
|
|
313
409
|
else if (y && y.isConnected) {
|
|
314
410
|
const x = document.createRange();
|
|
315
|
-
x.selectNodeContents(y), x.collapse(!1), x.insertNode(
|
|
411
|
+
x.selectNodeContents(y), x.collapse(!1), x.insertNode(l);
|
|
316
412
|
}
|
|
317
|
-
const
|
|
318
|
-
|
|
413
|
+
const A = l.closest(".rte-content, .editora-content") || y;
|
|
414
|
+
A == null || A.dispatchEvent(new Event("input", { bubbles: !0 })), k();
|
|
319
415
|
};
|
|
320
|
-
b.addEventListener("click", k), E.addEventListener("click", k), f.addEventListener("click",
|
|
321
|
-
o.target ===
|
|
416
|
+
b.addEventListener("click", k), E.addEventListener("click", k), f.addEventListener("click", _), c.addEventListener("click", (o) => {
|
|
417
|
+
o.target === c && k();
|
|
322
418
|
}), document.addEventListener("keydown", H, !0), P.forEach((o) => {
|
|
323
419
|
o.addEventListener("change", (s) => {
|
|
324
|
-
u = s.target.value,
|
|
420
|
+
u = s.target.value, C = "", N(), $();
|
|
325
421
|
});
|
|
326
422
|
}), p.addEventListener("input", () => {
|
|
327
|
-
|
|
423
|
+
B = p.value, $();
|
|
328
424
|
}), p.addEventListener("keydown", (o) => {
|
|
329
|
-
(o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(),
|
|
330
|
-
}),
|
|
425
|
+
(o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(), _());
|
|
426
|
+
}), N(), $(), p.focus();
|
|
331
427
|
};
|
|
332
428
|
if (typeof window != "undefined" && !window.__mathPluginDoubleClickInitialized) {
|
|
333
429
|
window.__mathPluginDoubleClickInitialized = !0;
|
|
334
430
|
const e = (r) => {
|
|
335
|
-
const
|
|
336
|
-
if (
|
|
337
|
-
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), v =
|
|
338
|
-
const n =
|
|
339
|
-
|
|
431
|
+
const a = r.target.closest(".math-formula, .math-block");
|
|
432
|
+
if (a) {
|
|
433
|
+
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), v = a;
|
|
434
|
+
const n = a.getAttribute("data-math-formula") || "", c = a.getAttribute("data-math-format") || "latex", d = a.classList.contains("math-formula");
|
|
435
|
+
I({ formula: n, format: c, inline: d });
|
|
340
436
|
}
|
|
341
437
|
}, t = () => {
|
|
342
438
|
document.addEventListener("dblclick", e, { capture: !0 });
|
|
343
439
|
};
|
|
344
440
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : setTimeout(t, 100);
|
|
345
441
|
}
|
|
346
|
-
const
|
|
442
|
+
const de = () => ({
|
|
347
443
|
name: "math",
|
|
348
|
-
init:
|
|
444
|
+
init: ae,
|
|
349
445
|
toolbar: [
|
|
350
446
|
{
|
|
351
447
|
label: "Insert Math",
|
|
@@ -356,7 +452,7 @@ const oe = () => ({
|
|
|
356
452
|
commands: {
|
|
357
453
|
insertMath: (e, t) => {
|
|
358
454
|
const r = (t == null ? void 0 : t.contentElement) instanceof HTMLElement ? t.contentElement : null;
|
|
359
|
-
return
|
|
455
|
+
return I(void 0, r), !0;
|
|
360
456
|
}
|
|
361
457
|
},
|
|
362
458
|
keymap: {
|
|
@@ -364,6 +460,6 @@ const oe = () => ({
|
|
|
364
460
|
}
|
|
365
461
|
});
|
|
366
462
|
export {
|
|
367
|
-
|
|
463
|
+
de as MathPlugin
|
|
368
464
|
};
|
|
369
|
-
//# sourceMappingURL=MathPlugin.native-
|
|
465
|
+
//# sourceMappingURL=MathPlugin.native-Byo3WL0f.mjs.map
|