@editora/core 1.0.8 → 1.0.10
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 +6 -1
- package/dist/{ApprovalWorkflowPlugin.native-C3jtAYjG.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +136 -133
- package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
- package/dist/{BlocksLibraryPlugin.native-HMWKxWNs.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +90 -87
- package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
- package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
- package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
- package/dist/{CitationsPlugin.native-BnU0qCwR.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +132 -129
- package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
- package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
- package/dist/{ContentRulesPlugin.native-nBLQ8QFZ.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +105 -102
- package/dist/{DataBindingPlugin.native-jQ1JPRTp.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +49 -46
- package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
- package/dist/{DocSchemaPlugin.native-CHOge18O.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +55 -52
- package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-BF_-LjTq.mjs} +287 -115
- package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
- package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-D2wl32jV.mjs} +88 -103
- package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
- package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
- package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +204 -202
- package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
- package/dist/{PIIRedactionPlugin.native-DcsjmtV1.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +158 -155
- package/dist/{SlashCommandsPlugin.native-CmxvMEaE.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +2 -2
- package/dist/{SmartPastePlugin.native-BOKKtF07.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +127 -124
- package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +100 -76
- package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -26
- package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
- package/dist/{TranslationWorkflowPlugin.native-Bz6jDGvj.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +104 -101
- package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
- package/dist/editora.min.js +1 -1
- package/dist/editora.umd.js +1 -1
- package/dist/index-CPMGUZfB.js +10 -0
- package/dist/{index-DqC57IEH.mjs → index-DBoj6QfW.mjs} +17 -15
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
- package/dist/plugin-loader.js +37 -37
- package/dist/webcomponent-core.js +18 -16
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +139 -62
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +50 -48
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +1174 -1071
- package/package.json +11 -5
- package/LICENSE +0 -21
- package/dist/BlockquotePlugin.native-JFmOLsxN.mjs +0 -48
- package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs +0 -79
- package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +0 -309
- package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +0 -140
- package/dist/CodePlugin.native-DlpTPdkd.mjs +0 -2691
- package/dist/DirectionPlugin.native-CDnbdNyl.mjs +0 -130
- package/dist/HeadingPlugin.native-DrLYwQnQ.mjs +0 -64
- package/dist/MathPlugin.native-f_mDp8VL.mjs +0 -292
- package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +0 -559
- package/dist/TemplatePlugin.native-CrpfKRJ8.mjs +0 -602
- package/dist/index-D1LOqg5C.js +0 -10
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
const K = {
|
|
2
|
+
latex: [
|
|
3
|
+
{ name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },
|
|
4
|
+
{ name: "Square Root", formula: "\\sqrt{x}", description: "Square root" },
|
|
5
|
+
{ name: "Power", formula: "x^{2}", description: "Exponent/power" },
|
|
6
|
+
{ name: "Subscript", formula: "x_{sub}", description: "Subscript" },
|
|
7
|
+
{ name: "Integral", formula: "\\int_{a}^{b} f(x) \\, dx", description: "Definite integral" },
|
|
8
|
+
{ name: "Summation", formula: "\\sum_{i=1}^{n} x_{i}", description: "Summation" },
|
|
9
|
+
{ name: "Limit", formula: "\\lim_{x \\to 0} f(x)", description: "Limit" },
|
|
10
|
+
{ name: "Derivative", formula: "\\frac{d}{dx} f(x)", description: "Derivative" },
|
|
11
|
+
{ name: "Matrix 2x2", formula: "\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}", description: "2x2 matrix" },
|
|
12
|
+
{ name: "System", formula: "\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}", description: "System of equations" }
|
|
13
|
+
],
|
|
14
|
+
mathml: [
|
|
15
|
+
{ name: "Fraction", formula: "<mfrac><mi>a</mi><mi>b</mi></mfrac>", description: "Simple fraction" },
|
|
16
|
+
{ name: "Square Root", formula: "<msqrt><mi>x</mi></msqrt>", description: "Square root" },
|
|
17
|
+
{ name: "Power", formula: "<msup><mi>x</mi><mn>2</mn></msup>", description: "Exponent/power" },
|
|
18
|
+
{ name: "Subscript", formula: "<msub><mi>x</mi><mi>sub</mi></msub>", description: "Subscript" },
|
|
19
|
+
{ name: "Parentheses", formula: '<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>', description: "Grouped expression" }
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
let M = null, v = null, R = !1, y = null, m = null;
|
|
23
|
+
const $ = '[data-theme="dark"], .dark, .editora-theme-dark', U = () => new Promise((e, t) => {
|
|
24
|
+
if (window.katex) {
|
|
25
|
+
e(window.katex);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (R) {
|
|
29
|
+
const l = setInterval(() => {
|
|
30
|
+
window.katex && (clearInterval(l), e(window.katex));
|
|
31
|
+
}, 100);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
R = !0;
|
|
35
|
+
const r = document.createElement("link");
|
|
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 a = document.createElement("script");
|
|
38
|
+
a.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", a.onload = () => e(window.katex), a.onerror = t, document.head.appendChild(a);
|
|
39
|
+
}), j = () => {
|
|
40
|
+
const e = window.getSelection();
|
|
41
|
+
if (!e || e.rangeCount === 0) return null;
|
|
42
|
+
const t = e.getRangeAt(0).startContainer, r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
43
|
+
return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
|
|
44
|
+
}, W = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, _ = (e) => {
|
|
45
|
+
const t = W(e);
|
|
46
|
+
return (t == null ? void 0 : t.closest('.rte-content, .editora-content, [contenteditable="true"]')) || null;
|
|
47
|
+
}, G = (e, t, r) => {
|
|
48
|
+
if (t !== r) {
|
|
49
|
+
if (typeof window.execEditorCommand == "function") {
|
|
50
|
+
window.execEditorCommand("recordDomTransaction", e, t, r);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (typeof window.executeEditorCommand == "function")
|
|
54
|
+
try {
|
|
55
|
+
window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: r });
|
|
56
|
+
} catch (a) {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, X = (e) => {
|
|
60
|
+
if (!(e instanceof Element)) return null;
|
|
61
|
+
const t = e.closest(".math-formula, .math-block");
|
|
62
|
+
return t instanceof HTMLElement ? t : null;
|
|
63
|
+
}, h = () => {
|
|
64
|
+
m && (m.classList.remove("math-object-selected"), m.removeAttribute("data-rte-selected-object"), m = null);
|
|
65
|
+
}, Z = (e) => {
|
|
66
|
+
if (m === e) return;
|
|
67
|
+
h(), m = e, e.classList.add("math-object-selected"), e.setAttribute("data-rte-selected-object", "true");
|
|
68
|
+
const t = window.getSelection();
|
|
69
|
+
if (!t) return;
|
|
70
|
+
const r = document.createRange();
|
|
71
|
+
r.selectNode(e), t.removeAllRanges(), t.addRange(r);
|
|
72
|
+
}, Q = (e, t) => {
|
|
73
|
+
const r = window.getSelection();
|
|
74
|
+
if (!r) return;
|
|
75
|
+
const a = document.createRange();
|
|
76
|
+
t && t.parentNode === e ? a.setStartBefore(t) : (a.selectNodeContents(e), a.collapse(!1)), a.collapse(!0), r.removeAllRanges(), r.addRange(a);
|
|
77
|
+
}, J = (e) => {
|
|
78
|
+
if (e.childNodes.length > 0) return;
|
|
79
|
+
const t = document.createElement("p");
|
|
80
|
+
t.appendChild(document.createElement("br")), e.appendChild(t);
|
|
81
|
+
}, V = () => {
|
|
82
|
+
if (!m || !m.isConnected)
|
|
83
|
+
return h(), !1;
|
|
84
|
+
const e = m, t = _(e);
|
|
85
|
+
if (!t)
|
|
86
|
+
return h(), !1;
|
|
87
|
+
const r = t.innerHTML, a = e.nextSibling;
|
|
88
|
+
e.remove(), J(t), h(), Q(t, a);
|
|
89
|
+
const l = t.innerHTML;
|
|
90
|
+
return G(t, r, l), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== l;
|
|
91
|
+
}, Y = () => {
|
|
92
|
+
if (document.getElementById("math-object-selection-styles")) return;
|
|
93
|
+
const e = document.createElement("style");
|
|
94
|
+
e.id = "math-object-selection-styles", e.textContent = `
|
|
95
|
+
.math-object-selected {
|
|
96
|
+
outline: 2px solid #2563eb !important;
|
|
97
|
+
outline-offset: 2px;
|
|
98
|
+
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
|
|
99
|
+
}
|
|
100
|
+
`, document.head.appendChild(e);
|
|
101
|
+
}, ee = () => {
|
|
102
|
+
typeof window == "undefined" || window.__mathPluginObjectSelectionInitialized || (window.__mathPluginObjectSelectionInitialized = !0, Y(), document.addEventListener("pointerdown", (e) => {
|
|
103
|
+
var r, a;
|
|
104
|
+
const t = X(e.target);
|
|
105
|
+
if (!t) {
|
|
106
|
+
const l = e.target;
|
|
107
|
+
(r = l == null ? void 0 : l.closest) != null && r.call(l, ".math-dialog-overlay") || h();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
e.preventDefault(), (a = _(t)) == null || a.focus(), Z(t);
|
|
111
|
+
}, !0), document.addEventListener("keydown", (e) => {
|
|
112
|
+
if (m) {
|
|
113
|
+
if (e.key === "Escape") {
|
|
114
|
+
h();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), V());
|
|
118
|
+
}
|
|
119
|
+
}, !0));
|
|
120
|
+
}, te = (e) => {
|
|
121
|
+
const t = e || j();
|
|
122
|
+
if (t != null && t.closest($)) return !0;
|
|
123
|
+
const r = window.getSelection();
|
|
124
|
+
if (r && r.rangeCount > 0) {
|
|
125
|
+
const l = r.getRangeAt(0).startContainer, n = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
|
|
126
|
+
if (n != null && n.closest($)) return !0;
|
|
127
|
+
}
|
|
128
|
+
const a = document.activeElement;
|
|
129
|
+
return a != null && a.closest($) ? !0 : document.body.matches($) || document.documentElement.matches($);
|
|
130
|
+
}, z = async (e, t) => {
|
|
131
|
+
const r = t || (v == null ? void 0 : v.closest(".rte-content, .editora-content")) || j() || y;
|
|
132
|
+
y = r || null;
|
|
133
|
+
const a = window.getSelection();
|
|
134
|
+
if (a && a.rangeCount > 0) {
|
|
135
|
+
const o = a.getRangeAt(0);
|
|
136
|
+
M = r && r.contains(o.commonAncestorContainer) ? o.cloneRange() : null;
|
|
137
|
+
}
|
|
138
|
+
await U();
|
|
139
|
+
const l = te(r), n = l ? {
|
|
140
|
+
overlay: "rgba(0, 0, 0, 0.62)",
|
|
141
|
+
dialogBg: "#1f2937",
|
|
142
|
+
border: "#3b4657",
|
|
143
|
+
panelBg: "#222d3a",
|
|
144
|
+
fieldBg: "#111827",
|
|
145
|
+
fieldBorder: "#4b5563",
|
|
146
|
+
text: "#e2e8f0",
|
|
147
|
+
muted: "#94a3b8",
|
|
148
|
+
templateBtnBg: "#273244",
|
|
149
|
+
templateBtnHover: "#334155",
|
|
150
|
+
templateBtnText: "#dbe7f7",
|
|
151
|
+
templateSubText: "#9fb0c6",
|
|
152
|
+
previewBg: "#111827",
|
|
153
|
+
previewText: "#cbd5e1",
|
|
154
|
+
cancelBg: "#334155",
|
|
155
|
+
cancelText: "#e2e8f0",
|
|
156
|
+
cancelBorder: "#4b5563",
|
|
157
|
+
insertBg: "#3b82f6",
|
|
158
|
+
insertHover: "#2563eb",
|
|
159
|
+
invalid: "#f87171"
|
|
160
|
+
} : {
|
|
161
|
+
overlay: "rgba(0, 0, 0, 0.5)",
|
|
162
|
+
dialogBg: "#ffffff",
|
|
163
|
+
border: "#e1e5e9",
|
|
164
|
+
panelBg: "#f8f9fa",
|
|
165
|
+
fieldBg: "#ffffff",
|
|
166
|
+
fieldBorder: "#ced4da",
|
|
167
|
+
text: "#1f2937",
|
|
168
|
+
muted: "#6c757d",
|
|
169
|
+
templateBtnBg: "#ffffff",
|
|
170
|
+
templateBtnHover: "#f8f9fa",
|
|
171
|
+
templateBtnText: "#1f2937",
|
|
172
|
+
templateSubText: "#6c757d",
|
|
173
|
+
previewBg: "#f8f9fa",
|
|
174
|
+
previewText: "#6c757d",
|
|
175
|
+
cancelBg: "#ffffff",
|
|
176
|
+
cancelText: "#1f2937",
|
|
177
|
+
cancelBorder: "#ced4da",
|
|
178
|
+
insertBg: "#007bff",
|
|
179
|
+
insertHover: "#0069d9",
|
|
180
|
+
invalid: "#cc0000"
|
|
181
|
+
}, d = document.createElement("div");
|
|
182
|
+
d.className = "math-dialog-overlay", d.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;`;
|
|
183
|
+
const c = document.createElement("div");
|
|
184
|
+
c.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};`;
|
|
185
|
+
let u = (e == null ? void 0 : e.format) || "latex", S = (e == null ? void 0 : e.formula) || "", I = (e == null ? void 0 : e.inline) !== !1, g = null, L = "";
|
|
186
|
+
c.innerHTML = `
|
|
187
|
+
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${n.border}; background: ${n.panelBg};">
|
|
188
|
+
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${n.text};">${e ? "Edit" : "Insert"} Math Formula</h2>
|
|
189
|
+
<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>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div style="padding: 20px; overflow-y: auto; flex: 1;">
|
|
193
|
+
<div style="margin-bottom: 20px;">
|
|
194
|
+
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Format:</label>
|
|
195
|
+
<div style="display: flex; gap: 16px;">
|
|
196
|
+
<label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="latex" ${u === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
|
|
197
|
+
<label style="cursor: pointer; color: ${n.text};"><input type="radio" name="format" value="mathml" ${u === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<div style="margin-bottom: 20px;">
|
|
202
|
+
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Quick Templates:</label>
|
|
203
|
+
<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>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<div style="margin-bottom: 20px;">
|
|
207
|
+
<label style="cursor: pointer; color: ${n.text};"><input type="checkbox" id="inline-cb" ${I ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<div style="margin-bottom: 20px;">
|
|
211
|
+
<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;">${S}</textarea>
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<div style="margin-bottom: 20px;">
|
|
216
|
+
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${n.text};">Preview:</label>
|
|
217
|
+
<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>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${n.border}; background: ${n.panelBg};">
|
|
222
|
+
<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
|
+
<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
|
+
</div>
|
|
225
|
+
`, d.appendChild(c), document.body.appendChild(d);
|
|
226
|
+
const p = c.querySelector("#formula-input"), w = c.querySelector("#preview-area"), T = c.querySelector("#templates-grid"), P = c.querySelectorAll('input[name="format"]'), q = c.querySelector("#inline-cb"), f = c.querySelector("#insert-btn"), b = c.querySelector(".close-btn"), E = c.querySelector(".cancel-btn"), F = (o) => encodeURIComponent(o), D = (o) => {
|
|
227
|
+
try {
|
|
228
|
+
return decodeURIComponent(o);
|
|
229
|
+
} catch (s) {
|
|
230
|
+
return o;
|
|
231
|
+
}
|
|
232
|
+
}, A = () => {
|
|
233
|
+
const o = K[u];
|
|
234
|
+
T.innerHTML = o.map((s) => `
|
|
235
|
+
<button type="button" data-formula="${F(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
|
+
<div style="font-weight: 600; font-size: 12px; color: ${n.templateBtnText};">${s.name}</div>
|
|
237
|
+
<div style="font-size: 10px; color: ${n.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${s.formula.substring(0, 20)}...</div>
|
|
238
|
+
</button>
|
|
239
|
+
`).join("");
|
|
240
|
+
}, O = () => {
|
|
241
|
+
const o = p.value.trim(), s = `${u}:${o}`;
|
|
242
|
+
if (s !== L) {
|
|
243
|
+
if (L = s, !o) {
|
|
244
|
+
w.innerHTML = `<span style="color: ${n.previewText};">Enter a formula to see preview</span>`, f.disabled = !0;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
f.disabled = !1;
|
|
248
|
+
try {
|
|
249
|
+
if (u === "latex") {
|
|
250
|
+
const i = window.katex;
|
|
251
|
+
w.innerHTML = i.renderToString(o, { displayMode: !1, throwOnError: !1 });
|
|
252
|
+
} 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 (i) {
|
|
255
|
+
w.innerHTML = `<span style="color: ${n.invalid};">Invalid formula</span>`;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}, B = () => {
|
|
259
|
+
g !== null && cancelAnimationFrame(g), g = requestAnimationFrame(() => {
|
|
260
|
+
g = null, O();
|
|
261
|
+
});
|
|
262
|
+
}, H = (o) => {
|
|
263
|
+
o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), k());
|
|
264
|
+
}, k = () => {
|
|
265
|
+
document.removeEventListener("keydown", H, !0), g !== null && (cancelAnimationFrame(g), g = null), d.parentNode && d.parentNode.removeChild(d);
|
|
266
|
+
};
|
|
267
|
+
b.onmouseover = () => {
|
|
268
|
+
b.style.color = "#f8fafc", b.style.background = l ? "#334155" : "#e5e7eb", b.style.borderRadius = "4px";
|
|
269
|
+
}, b.onmouseout = () => {
|
|
270
|
+
b.style.color = n.muted, b.style.background = "none";
|
|
271
|
+
}, E.onmouseover = () => {
|
|
272
|
+
E.style.background = l ? "#475569" : "#f3f4f6";
|
|
273
|
+
}, E.onmouseout = () => {
|
|
274
|
+
E.style.background = n.cancelBg;
|
|
275
|
+
}, f.onmouseover = () => {
|
|
276
|
+
f.disabled || (f.style.background = n.insertHover);
|
|
277
|
+
}, f.onmouseout = () => {
|
|
278
|
+
f.style.background = n.insertBg;
|
|
279
|
+
}, T.addEventListener("mouseover", (o) => {
|
|
280
|
+
const i = o.target.closest("button[data-formula]");
|
|
281
|
+
i && (i.style.background = n.templateBtnHover);
|
|
282
|
+
}), T.addEventListener("mouseout", (o) => {
|
|
283
|
+
const i = o.target.closest("button[data-formula]");
|
|
284
|
+
i && (i.style.background = n.templateBtnBg);
|
|
285
|
+
}), T.addEventListener("click", (o) => {
|
|
286
|
+
const i = o.target.closest("button[data-formula]");
|
|
287
|
+
i && (p.value = D(i.getAttribute("data-formula") || ""), S = p.value, B());
|
|
288
|
+
});
|
|
289
|
+
const N = () => {
|
|
290
|
+
const o = p.value.trim();
|
|
291
|
+
if (!o) return;
|
|
292
|
+
const s = { formula: o, format: u, inline: q.checked }, i = s.inline ? document.createElement("span") : document.createElement("div");
|
|
293
|
+
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") {
|
|
294
|
+
const x = window.katex;
|
|
295
|
+
try {
|
|
296
|
+
i.innerHTML = x.renderToString(o, {
|
|
297
|
+
displayMode: !s.inline,
|
|
298
|
+
throwOnError: !1
|
|
299
|
+
});
|
|
300
|
+
} catch (ne) {
|
|
301
|
+
i.textContent = s.inline ? `$${o}$` : `$$${o}$$`;
|
|
302
|
+
}
|
|
303
|
+
} else if (o.trim().startsWith("<math"))
|
|
304
|
+
i.innerHTML = o;
|
|
305
|
+
else {
|
|
306
|
+
const x = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${s.inline ? "inline" : "block"}">${o}</math>`;
|
|
307
|
+
i.innerHTML = x;
|
|
308
|
+
}
|
|
309
|
+
if (v)
|
|
310
|
+
v.replaceWith(i);
|
|
311
|
+
else if (M)
|
|
312
|
+
M.deleteContents(), M.insertNode(i);
|
|
313
|
+
else if (y && y.isConnected) {
|
|
314
|
+
const x = document.createRange();
|
|
315
|
+
x.selectNodeContents(y), x.collapse(!1), x.insertNode(i);
|
|
316
|
+
}
|
|
317
|
+
const C = i.closest(".rte-content, .editora-content") || y;
|
|
318
|
+
C == null || C.dispatchEvent(new Event("input", { bubbles: !0 })), k();
|
|
319
|
+
};
|
|
320
|
+
b.addEventListener("click", k), E.addEventListener("click", k), f.addEventListener("click", N), d.addEventListener("click", (o) => {
|
|
321
|
+
o.target === d && k();
|
|
322
|
+
}), document.addEventListener("keydown", H, !0), P.forEach((o) => {
|
|
323
|
+
o.addEventListener("change", (s) => {
|
|
324
|
+
u = s.target.value, L = "", A(), B();
|
|
325
|
+
});
|
|
326
|
+
}), p.addEventListener("input", () => {
|
|
327
|
+
S = p.value, B();
|
|
328
|
+
}), p.addEventListener("keydown", (o) => {
|
|
329
|
+
(o.ctrlKey || o.metaKey) && o.key === "Enter" && (o.preventDefault(), N());
|
|
330
|
+
}), A(), B(), p.focus();
|
|
331
|
+
};
|
|
332
|
+
if (typeof window != "undefined" && !window.__mathPluginDoubleClickInitialized) {
|
|
333
|
+
window.__mathPluginDoubleClickInitialized = !0;
|
|
334
|
+
const e = (r) => {
|
|
335
|
+
const l = r.target.closest(".math-formula, .math-block");
|
|
336
|
+
if (l) {
|
|
337
|
+
r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h(), v = l;
|
|
338
|
+
const n = l.getAttribute("data-math-formula") || "", d = l.getAttribute("data-math-format") || "latex", c = l.classList.contains("math-formula");
|
|
339
|
+
z({ formula: n, format: d, inline: c });
|
|
340
|
+
}
|
|
341
|
+
}, t = () => {
|
|
342
|
+
document.addEventListener("dblclick", e, { capture: !0 });
|
|
343
|
+
};
|
|
344
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t) : setTimeout(t, 100);
|
|
345
|
+
}
|
|
346
|
+
const oe = () => ({
|
|
347
|
+
name: "math",
|
|
348
|
+
init: ee,
|
|
349
|
+
toolbar: [
|
|
350
|
+
{
|
|
351
|
+
label: "Insert Math",
|
|
352
|
+
command: "insertMath",
|
|
353
|
+
icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'
|
|
354
|
+
}
|
|
355
|
+
],
|
|
356
|
+
commands: {
|
|
357
|
+
insertMath: (e, t) => {
|
|
358
|
+
const r = (t == null ? void 0 : t.contentElement) instanceof HTMLElement ? t.contentElement : null;
|
|
359
|
+
return z(void 0, r), !0;
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
keymap: {
|
|
363
|
+
"Mod-Shift-m": "insertMath"
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
export {
|
|
367
|
+
oe as MathPlugin
|
|
368
|
+
};
|
|
369
|
+
//# sourceMappingURL=MathPlugin.native-NwWPHVmj.mjs.map
|