digi-mathchem-editor 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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e, { useState as
|
|
1
|
+
import e, { useState as B, useEffect as O, useMemo as Ee, useRef as re, useCallback as he } from "react";
|
|
2
2
|
import { createPortal as Q } from "react-dom";
|
|
3
3
|
import { FontAwesomeIcon as ae } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { faBold as Me, faItalic as Ae } from "@fortawesome/free-solid-svg-icons";
|
|
@@ -361,7 +361,7 @@ const Se = [
|
|
|
361
361
|
}), l;
|
|
362
362
|
}, je = Je();
|
|
363
363
|
function ze({ isOpen: l, onClose: o, onInsert: a, position: m }) {
|
|
364
|
-
const [n, s] =
|
|
364
|
+
const [n, s] = B(""), [d, p] = B("All");
|
|
365
365
|
O(() => {
|
|
366
366
|
l && (s(""), p("All"));
|
|
367
367
|
}, [l]);
|
|
@@ -372,7 +372,7 @@ function ze({ isOpen: l, onClose: o, onInsert: a, position: m }) {
|
|
|
372
372
|
u = u.filter((k) => k.code.includes(y));
|
|
373
373
|
}
|
|
374
374
|
return u;
|
|
375
|
-
}, [d, n]),
|
|
375
|
+
}, [d, n]), I = Ee(() => {
|
|
376
376
|
if (d !== "All" && !n.trim())
|
|
377
377
|
return { [d]: x };
|
|
378
378
|
const u = {};
|
|
@@ -407,7 +407,7 @@ function ze({ isOpen: l, onClose: o, onInsert: a, position: m }) {
|
|
|
407
407
|
className: "scm-category-select"
|
|
408
408
|
},
|
|
409
409
|
Se.map((u) => /* @__PURE__ */ e.createElement("option", { key: u.id, value: u.id }, u.name))
|
|
410
|
-
)), /* @__PURE__ */ e.createElement("div", { className: "scm-body" }, /* @__PURE__ */ e.createElement("div", { className: "scm-grid-container" }, Object.entries(
|
|
410
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "scm-body" }, /* @__PURE__ */ e.createElement("div", { className: "scm-grid-container" }, Object.entries(I).map(([u, y]) => /* @__PURE__ */ e.createElement("div", { key: u, className: "scm-category-group" }, /* @__PURE__ */ e.createElement("div", { className: "scm-char-grid" }, y.map((k) => /* @__PURE__ */ e.createElement(
|
|
411
411
|
"button",
|
|
412
412
|
{
|
|
413
413
|
key: k.code,
|
|
@@ -420,7 +420,7 @@ function ze({ isOpen: l, onClose: o, onInsert: a, position: m }) {
|
|
|
420
420
|
k.char
|
|
421
421
|
))))), x.length === 0 && /* @__PURE__ */ e.createElement("div", { className: "scm-no-results" }, "No characters found.")))));
|
|
422
422
|
}
|
|
423
|
-
const Qe = "1.0.
|
|
423
|
+
const Qe = "1.0.18", Xe = {
|
|
424
424
|
version: Qe
|
|
425
425
|
};
|
|
426
426
|
window.__cme_macros = {
|
|
@@ -3657,11 +3657,11 @@ class ct extends Ve {
|
|
|
3657
3657
|
"span",
|
|
3658
3658
|
{
|
|
3659
3659
|
class: "ck-math-widget-inner",
|
|
3660
|
-
style: "display:inline-block;vertical-align:middle;margin:0
|
|
3660
|
+
style: "display:inline-block;vertical-align:middle;margin:0;cursor:pointer;width:auto;max-width:100%;pointer-events:none;"
|
|
3661
3661
|
},
|
|
3662
|
-
(
|
|
3662
|
+
(I) => {
|
|
3663
3663
|
const g = document.createElement("math-field");
|
|
3664
|
-
g.setAttribute("math-virtual-keyboard-policy", "manual"), g.setAttribute("tabindex", "-1"), g.style.display = "inline-block", g.style.width = "auto", g.style.maxWidth = "100%", g.style.verticalAlign = "middle", g.style.border = "none", g.style.background = "transparent", g.style.outline = "none", g.style.fontSize = "inherit", g.style.minHeight = "auto", g.style.padding = "0
|
|
3664
|
+
g.setAttribute("math-virtual-keyboard-policy", "manual"), g.setAttribute("tabindex", "-1"), g.style.display = "inline-block", g.style.width = "auto", g.style.maxWidth = "100%", g.style.verticalAlign = "middle", g.style.border = "none", g.style.background = "transparent", g.style.outline = "none", g.style.fontSize = "inherit", g.style.minHeight = "auto", g.style.padding = "0", g.style.margin = "0", g.style.pointerEvents = "none";
|
|
3665
3665
|
const A = () => {
|
|
3666
3666
|
if (!g.isConnected) {
|
|
3667
3667
|
requestAnimationFrame(A);
|
|
@@ -3688,9 +3688,9 @@ class ct extends Ve {
|
|
|
3688
3688
|
}
|
|
3689
3689
|
g.setAttribute("read-only", "");
|
|
3690
3690
|
};
|
|
3691
|
-
customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)),
|
|
3691
|
+
customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)), I.appendChild(g);
|
|
3692
3692
|
const u = () => {
|
|
3693
|
-
const y =
|
|
3693
|
+
const y = I.parentElement;
|
|
3694
3694
|
y && Ye(o, y);
|
|
3695
3695
|
};
|
|
3696
3696
|
u(), requestAnimationFrame(u);
|
|
@@ -3715,9 +3715,9 @@ class ct extends Ve {
|
|
|
3715
3715
|
const p = d.writer, x = d.mapper.toViewElement(s.item);
|
|
3716
3716
|
if (x) {
|
|
3717
3717
|
p.setAttribute("data-latex", s.attributeNewValue, x);
|
|
3718
|
-
const
|
|
3719
|
-
if (
|
|
3720
|
-
const g =
|
|
3718
|
+
const I = o.editing.view.domConverter.mapViewToDom(x);
|
|
3719
|
+
if (I) {
|
|
3720
|
+
const g = I.querySelector("math-field");
|
|
3721
3721
|
if (g) {
|
|
3722
3722
|
let A = ge(ne(X(de(s.attributeNewValue))));
|
|
3723
3723
|
A.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(A.trim()) && (A = A.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")), g.removeAttribute("read-only");
|
|
@@ -3763,7 +3763,7 @@ class ct extends Ve {
|
|
|
3763
3763
|
}
|
|
3764
3764
|
}
|
|
3765
3765
|
function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLeave: s }) {
|
|
3766
|
-
const [d, p] =
|
|
3766
|
+
const [d, p] = B({ r: 2, c: 2 }), x = Math.max(10, parseInt(d.r, 10) || 0), I = Math.max(10, parseInt(d.c, 10) || 0), g = (k) => {
|
|
3767
3767
|
const E = k.target.value;
|
|
3768
3768
|
if (E === "") {
|
|
3769
3769
|
p((L) => ({ ...L, r: "" }));
|
|
@@ -3802,7 +3802,7 @@ function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLe
|
|
|
3802
3802
|
onMouseEnter: n,
|
|
3803
3803
|
onMouseLeave: s
|
|
3804
3804
|
},
|
|
3805
|
-
/* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length: x }).map((k, E) => /* @__PURE__ */ e.createElement("div", { key: E, className: "cme-matrix-hover-row" }, Array.from({ length:
|
|
3805
|
+
/* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length: x }).map((k, E) => /* @__PURE__ */ e.createElement("div", { key: E, className: "cme-matrix-hover-row" }, Array.from({ length: I }).map((T, L) => {
|
|
3806
3806
|
const q = parseInt(d.r, 10) || 0, K = parseInt(d.c, 10) || 0, j = E < q && L < K;
|
|
3807
3807
|
return /* @__PURE__ */ e.createElement(
|
|
3808
3808
|
"div",
|
|
@@ -3855,19 +3855,19 @@ function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLe
|
|
|
3855
3855
|
}
|
|
3856
3856
|
let J = !1, be = null, U = null;
|
|
3857
3857
|
function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n }) {
|
|
3858
|
-
const s = re(null), [d, p] =
|
|
3858
|
+
const s = re(null), [d, p] = B(0), [x, I] = B(null), [g, A] = B(null), [u, y] = B(null), [k, E] = B(null);
|
|
3859
3859
|
re(null);
|
|
3860
|
-
const [T, L] =
|
|
3860
|
+
const [T, L] = B({ x: 0, y: 0 }), [q, K] = B(!1), j = re({ x: 0, y: 0 }), [_, ke] = B(!1), [Ie, ue] = B(!1), [Be, Y] = B(!1), se = re(null);
|
|
3861
3861
|
O(() => {
|
|
3862
3862
|
const t = (r) => {
|
|
3863
3863
|
if (!q) return;
|
|
3864
|
-
const
|
|
3865
|
-
let w =
|
|
3864
|
+
const c = r.touches && r.touches.length > 0 ? r.touches[0].clientX : r.clientX, b = r.touches && r.touches.length > 0 ? r.touches[0].clientY : r.clientY;
|
|
3865
|
+
let w = c - j.current.x, h = b - j.current.y;
|
|
3866
3866
|
if (se.current) {
|
|
3867
3867
|
const C = se.current, M = -C.left, R = window.innerWidth - C.right, H = -C.top, P = window.innerHeight - C.bottom;
|
|
3868
|
-
w < M && (w = M), w > R && (w = R),
|
|
3868
|
+
w < M && (w = M), w > R && (w = R), h < H && (h = H), h > P && (h = P);
|
|
3869
3869
|
}
|
|
3870
|
-
L({ x: w, y:
|
|
3870
|
+
L({ x: w, y: h });
|
|
3871
3871
|
}, i = () => K(!1);
|
|
3872
3872
|
return q && (window.addEventListener("mousemove", t, { passive: !1 }), window.addEventListener("mouseup", i), window.addEventListener("touchmove", t, { passive: !1 }), window.addEventListener("touchend", i)), () => {
|
|
3873
3873
|
window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", i), window.removeEventListener("touchmove", t), window.removeEventListener("touchend", i);
|
|
@@ -3881,9 +3881,9 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
3881
3881
|
x: i - T.x,
|
|
3882
3882
|
y: r - T.y
|
|
3883
3883
|
};
|
|
3884
|
-
const
|
|
3885
|
-
if (
|
|
3886
|
-
const b =
|
|
3884
|
+
const c = document.querySelector(".cme-editor-popup");
|
|
3885
|
+
if (c) {
|
|
3886
|
+
const b = c.getBoundingClientRect();
|
|
3887
3887
|
se.current = {
|
|
3888
3888
|
left: b.left - T.x,
|
|
3889
3889
|
top: b.top - T.y,
|
|
@@ -3893,7 +3893,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
3893
3893
|
height: b.height
|
|
3894
3894
|
};
|
|
3895
3895
|
}
|
|
3896
|
-
}, G = l === "math" ? Ge : $e, [f, ce] =
|
|
3896
|
+
}, G = l === "math" ? Ge : $e, [f, ce] = B({
|
|
3897
3897
|
bold: !1,
|
|
3898
3898
|
italic: !1,
|
|
3899
3899
|
color: "none",
|
|
@@ -3904,10 +3904,10 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
3904
3904
|
const t = s.current;
|
|
3905
3905
|
if (!(!t || typeof t.queryStyle != "function"))
|
|
3906
3906
|
try {
|
|
3907
|
-
const i = window.__cmeManualBold !== void 0 ? window.__cmeManualBold : t.queryStyle({ fontSeries: "b" }) === "all" || t.queryStyle({ variantStyle: "bold" }) === "all", r = window.__cmeManualItalic !== void 0 ? window.__cmeManualItalic : t.queryStyle({ variantStyle: "italic" }) === "all" || t.queryStyle({ shape: "it" }) === "all",
|
|
3908
|
-
(
|
|
3907
|
+
const i = window.__cmeManualBold !== void 0 ? window.__cmeManualBold : t.queryStyle({ fontSeries: "b" }) === "all" || t.queryStyle({ variantStyle: "bold" }) === "all", r = window.__cmeManualItalic !== void 0 ? window.__cmeManualItalic : t.queryStyle({ variantStyle: "italic" }) === "all" || t.queryStyle({ shape: "it" }) === "all", c = window.__cmeManualFontFamily !== void 0 ? window.__cmeManualFontFamily : ["roman", "sans-serif", "monospace"].find(
|
|
3908
|
+
(h) => t.queryStyle({ fontFamily: h }) === "all"
|
|
3909
3909
|
) || "none", b = window.__cmeManualFontSize !== void 0 ? window.__cmeManualFontSize : [5, 7, 9].find(
|
|
3910
|
-
(
|
|
3910
|
+
(h) => t.queryStyle({ fontSize: h }) === "all"
|
|
3911
3911
|
) || "auto", w = [
|
|
3912
3912
|
"black",
|
|
3913
3913
|
"dimgray",
|
|
@@ -3934,12 +3934,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
3934
3934
|
"violet",
|
|
3935
3935
|
"gold"
|
|
3936
3936
|
].find(
|
|
3937
|
-
(
|
|
3937
|
+
(h) => t.queryStyle({ color: h }) === "all"
|
|
3938
3938
|
) || "none";
|
|
3939
|
-
ce((
|
|
3939
|
+
ce((h) => ({
|
|
3940
3940
|
bold: i,
|
|
3941
3941
|
italic: r,
|
|
3942
|
-
fontFamily:
|
|
3942
|
+
fontFamily: c,
|
|
3943
3943
|
fontSize: String(b),
|
|
3944
3944
|
color: w
|
|
3945
3945
|
}));
|
|
@@ -3950,7 +3950,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
3950
3950
|
O(() => {
|
|
3951
3951
|
if (!x && !u) return;
|
|
3952
3952
|
const t = (i) => {
|
|
3953
|
-
!i.target.closest(".cme-matrix-hover-popover") && !i.target.closest(".cme-matrix-btn-wrapper") &&
|
|
3953
|
+
!i.target.closest(".cme-matrix-hover-popover") && !i.target.closest(".cme-matrix-btn-wrapper") && I(null), !i.target.closest(".cme-color-picker-popup") && !i.target.closest('[title="Text Color"]') && y(null);
|
|
3954
3954
|
};
|
|
3955
3955
|
return window.addEventListener("mousedown", t, !0), window.addEventListener("pointerdown", t, !0), () => {
|
|
3956
3956
|
window.removeEventListener("mousedown", t, !0), window.removeEventListener("pointerdown", t, !0);
|
|
@@ -3975,8 +3975,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
3975
3975
|
if (typeof t.applyStyle == "function" && t.applyStyle({ variantStyle: "up" }), m) {
|
|
3976
3976
|
let r = ge(m);
|
|
3977
3977
|
if (l === "chem") {
|
|
3978
|
-
const
|
|
3979
|
-
|
|
3978
|
+
const c = r.match(/^\\ce\{([\s\S]*)\}$/i);
|
|
3979
|
+
c && (r = c[1]);
|
|
3980
3980
|
}
|
|
3981
3981
|
r = X(r), r = ne(r), t.setValue ? t.setValue("", { silenceNotifications: !0 }) : t.value = "", t.executeCommand(["insert", r, { insertionMode: "replaceAll" }]);
|
|
3982
3982
|
}
|
|
@@ -3991,17 +3991,17 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
3991
3991
|
J = !1;
|
|
3992
3992
|
}, 500)), ["`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "_", '"', "'", "/", "\\", "|"].includes(r.key) && !r.ctrlKey && !r.metaKey && !r.altKey) {
|
|
3993
3993
|
r.preventDefault(), r.stopPropagation();
|
|
3994
|
-
let
|
|
3995
|
-
r.key === "`" ?
|
|
3994
|
+
let c = "";
|
|
3995
|
+
r.key === "`" ? c = "\\grave{\\ }" : r.key === "~" ? c = "\\sim" : r.key === "!" ? c = "!" : r.key === "@" ? c = "@" : r.key === "#" ? c = "\\#" : r.key === "$" ? c = "\\$" : r.key === "%" ? c = "\\%" : r.key === "^" ? c = "\\wedge" : r.key === "&" ? c = "\\&" : r.key === "*" ? c = "\\ast" : r.key === "_" ? c = "\\_" : r.key === '"' ? c = '\\text{"}' : r.key === "'" ? c = "\\text{'}" : r.key === "/" ? c = "\\mathord{/}" : r.key === "\\" ? c = "\\backslash" : r.key === "|" && (c = "|"), t.executeCommand(["insert", c]);
|
|
3996
3996
|
return;
|
|
3997
3997
|
}
|
|
3998
3998
|
if (r.key.length === 1 && !r.ctrlKey && !r.metaKey && !r.altKey && /[a-zA-Z0-9]/.test(r.key)) {
|
|
3999
3999
|
r.preventDefault(), r.stopPropagation();
|
|
4000
|
-
const
|
|
4000
|
+
const c = f.fontFamily === "sans-serif", b = f.fontFamily === "monospace", w = f.bold, h = f.italic;
|
|
4001
4001
|
let C = "\\mathrm";
|
|
4002
|
-
|
|
4002
|
+
c ? C = "\\mathsf" : b ? C = "\\mathtt" : h && !w ? C = "\\mathit" : w && !h && (C = "\\mathbf");
|
|
4003
4003
|
let M = `${C}{${r.key}}`;
|
|
4004
|
-
w &&
|
|
4004
|
+
w && h ? (M = `\\mathbfit{${r.key}}`, c && (M = `\\boldsymbol{\\mathsf{${r.key}}}`), b && (M = `\\boldsymbol{\\mathtt{${r.key}}}`)) : w && (c || b) && (M = `\\boldsymbol{${M}}`);
|
|
4005
4005
|
let R = M;
|
|
4006
4006
|
const H = f.fontSize === "auto" ? 5 : parseInt(f.fontSize, 10);
|
|
4007
4007
|
if (H !== 5) {
|
|
@@ -4021,8 +4021,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4021
4021
|
setTimeout(() => {
|
|
4022
4022
|
const r = t.shadowRoot;
|
|
4023
4023
|
if (!r) return;
|
|
4024
|
-
const
|
|
4025
|
-
|
|
4024
|
+
const c = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
|
|
4025
|
+
c && c.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }), F();
|
|
4026
4026
|
}, 0);
|
|
4027
4027
|
};
|
|
4028
4028
|
return t.addEventListener("selection-change", i), t.addEventListener("input", i), t.addEventListener("keydown", i), setTimeout(F, 50), () => {
|
|
@@ -4033,13 +4033,13 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4033
4033
|
const i = U;
|
|
4034
4034
|
i && (i.focus(), i.executeCommand(["insert", t]));
|
|
4035
4035
|
}, []), De = he((t, i, r) => {
|
|
4036
|
-
let
|
|
4036
|
+
let c = `\\begin{${t}} `;
|
|
4037
4037
|
for (let b = 0; b < i; b++) {
|
|
4038
4038
|
for (let w = 0; w < r; w++)
|
|
4039
|
-
|
|
4040
|
-
b < i - 1 && (
|
|
4039
|
+
c += "#?", w < r - 1 && (c += " & ");
|
|
4040
|
+
b < i - 1 && (c += " \\\\ ");
|
|
4041
4041
|
}
|
|
4042
|
-
|
|
4042
|
+
c += ` \\end{${t}}`, z(c);
|
|
4043
4043
|
}, [z]), Ne = (t) => {
|
|
4044
4044
|
t.stopPropagation(), ke((i) => !i), ue(!1), L({ x: 0, y: 0 });
|
|
4045
4045
|
}, Re = (t) => {
|
|
@@ -4051,8 +4051,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4051
4051
|
a && a();
|
|
4052
4052
|
return;
|
|
4053
4053
|
}
|
|
4054
|
-
const r = i.getValue ? i.getValue("latex") : i.value,
|
|
4055
|
-
!r || r.trim() === "" || r ===
|
|
4054
|
+
const r = i.getValue ? i.getValue("latex") : i.value, c = m || "";
|
|
4055
|
+
!r || r.trim() === "" || r === c ? a && a() : Y(!0);
|
|
4056
4056
|
}, Oe = () => {
|
|
4057
4057
|
const t = U;
|
|
4058
4058
|
if (!t) return;
|
|
@@ -4064,8 +4064,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4064
4064
|
l === "chem" && (i = et(i)), i = X(i);
|
|
4065
4065
|
const r = i.match(/^\\(mathrm|mathit|mathbf|mathsf|text)\{\\displaylines\{([\s\S]*)\}\}$/);
|
|
4066
4066
|
if (r) {
|
|
4067
|
-
const
|
|
4068
|
-
i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${
|
|
4067
|
+
const c = r[1];
|
|
4068
|
+
i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${c}{${C.trim()}}`).join(" \\\\ ")}}`;
|
|
4069
4069
|
}
|
|
4070
4070
|
i = i.replace(/[\r\n]+/g, " "), o && o(i), t.setValue ? t.setValue("") : t.value = "", a && a();
|
|
4071
4071
|
};
|
|
@@ -4073,7 +4073,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4073
4073
|
/* @__PURE__ */ e.createElement(
|
|
4074
4074
|
"div",
|
|
4075
4075
|
{
|
|
4076
|
-
className: `cme-editor-popup ${_ ? "maximized" : ""} ${
|
|
4076
|
+
className: `cme-editor-popup ${_ ? "maximized" : ""} ${Ie ? "minimized" : ""}`,
|
|
4077
4077
|
style: { transform: `translate(${T.x}px, ${T.y}px)` },
|
|
4078
4078
|
onPointerDown: (t) => t.stopPropagation()
|
|
4079
4079
|
},
|
|
@@ -4095,8 +4095,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4095
4095
|
key: t.isMatrix ? "matrix-tab" : t.label,
|
|
4096
4096
|
className: `cme-group-tab${r ? " active" : ""}`,
|
|
4097
4097
|
type: "button",
|
|
4098
|
-
onPointerDown: (
|
|
4099
|
-
|
|
4098
|
+
onPointerDown: (c) => {
|
|
4099
|
+
c.preventDefault(), p(i), I(null);
|
|
4100
4100
|
}
|
|
4101
4101
|
},
|
|
4102
4102
|
t.mathLabel ? /* @__PURE__ */ e.createElement(
|
|
@@ -4123,8 +4123,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4123
4123
|
) : t.label
|
|
4124
4124
|
);
|
|
4125
4125
|
})), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
|
|
4126
|
-
var
|
|
4127
|
-
const t = ((
|
|
4126
|
+
var c;
|
|
4127
|
+
const t = ((c = G[d]) == null ? void 0 : c.items) || [], i = t.some((b) => b.type === "sep"), r = [];
|
|
4128
4128
|
if (i) {
|
|
4129
4129
|
let b = { cols: 2, small: !1, cls: "", items: [], moreItems: null };
|
|
4130
4130
|
for (const w of t)
|
|
@@ -4151,24 +4151,24 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4151
4151
|
type: "button",
|
|
4152
4152
|
className: "cme-more-trigger-btn",
|
|
4153
4153
|
title: "more",
|
|
4154
|
-
onPointerDown: (
|
|
4155
|
-
|
|
4154
|
+
onPointerDown: (h) => {
|
|
4155
|
+
h.preventDefault();
|
|
4156
4156
|
},
|
|
4157
|
-
onClick: (
|
|
4158
|
-
if (
|
|
4157
|
+
onClick: (h) => {
|
|
4158
|
+
if (h.stopPropagation(), k && k.items === b.moreItems)
|
|
4159
4159
|
E(null);
|
|
4160
4160
|
else {
|
|
4161
|
-
const C =
|
|
4161
|
+
const C = h.currentTarget.getBoundingClientRect(), M = G[d] || {};
|
|
4162
4162
|
E({ cx: C.left + C.width / 2, y: C.bottom, items: b.moreItems, cols: b.moreCols, isTemplate: M.isTemplate || M.label === "√(□)" || M.isMatrix });
|
|
4163
4163
|
}
|
|
4164
4164
|
}
|
|
4165
4165
|
},
|
|
4166
4166
|
"▶"
|
|
4167
4167
|
),
|
|
4168
|
-
b.items.map((
|
|
4168
|
+
b.items.map((h, C) => {
|
|
4169
4169
|
const M = G[d];
|
|
4170
|
-
if (
|
|
4171
|
-
const N =
|
|
4170
|
+
if (h.type === "dropdown") {
|
|
4171
|
+
const N = h.label === "Font...", v = h.label === "Size", $ = N && f.fontFamily !== "none", ee = v && f.fontSize !== "auto" && f.fontSize !== "5", te = N ? f.fontFamily === "none" ? "" : f.fontFamily : v ? f.fontSize === "auto" || f.fontSize === "5" ? "" : f.fontSize : "";
|
|
4172
4172
|
return /* @__PURE__ */ e.createElement(
|
|
4173
4173
|
"select",
|
|
4174
4174
|
{
|
|
@@ -4176,7 +4176,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4176
4176
|
className: `cme-btn template${$ || ee ? " active" : ""}`,
|
|
4177
4177
|
value: te,
|
|
4178
4178
|
style: {
|
|
4179
|
-
width:
|
|
4179
|
+
width: h.width || "60px",
|
|
4180
4180
|
height: "18px",
|
|
4181
4181
|
minHeight: "18px",
|
|
4182
4182
|
maxHeight: "18px",
|
|
@@ -4193,12 +4193,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4193
4193
|
!V || typeof V.applyStyle != "function" || (V.focus(), N ? V.applyStyle({ fontFamily: Z || "none" }) : v && V.applyStyle({ fontSize: Z ? parseInt(Z, 10) : "auto" }), F());
|
|
4194
4194
|
}
|
|
4195
4195
|
},
|
|
4196
|
-
/* @__PURE__ */ e.createElement("option", { value: "" },
|
|
4196
|
+
/* @__PURE__ */ e.createElement("option", { value: "" }, h.label),
|
|
4197
4197
|
N && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("option", { value: "roman" }, "Times"), /* @__PURE__ */ e.createElement("option", { value: "sans-serif" }, "Helvetica"), /* @__PURE__ */ e.createElement("option", { value: "monospace" }, "Courier")),
|
|
4198
4198
|
v && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("option", { value: "5" }, "12px"), /* @__PURE__ */ e.createElement("option", { value: "7" }, "16px"), /* @__PURE__ */ e.createElement("option", { value: "9" }, "20px"))
|
|
4199
4199
|
);
|
|
4200
4200
|
}
|
|
4201
|
-
if (M.isMatrix && !
|
|
4201
|
+
if (M.isMatrix && !h.directInsert)
|
|
4202
4202
|
return /* @__PURE__ */ e.createElement(
|
|
4203
4203
|
"div",
|
|
4204
4204
|
{
|
|
@@ -4209,23 +4209,23 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4209
4209
|
"button",
|
|
4210
4210
|
{
|
|
4211
4211
|
type: "button",
|
|
4212
|
-
className: `cme-btn template${
|
|
4213
|
-
title:
|
|
4212
|
+
className: `cme-btn template${h.cls ? ` ${h.cls}` : ""}${M.isMatrix ? " cme-matrix-btn-small" : ""}`,
|
|
4213
|
+
title: h.title || h.label || h.insert,
|
|
4214
4214
|
onPointerDown: (N) => {
|
|
4215
|
-
if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) ===
|
|
4216
|
-
|
|
4215
|
+
if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === h.insert)
|
|
4216
|
+
I(null);
|
|
4217
4217
|
else {
|
|
4218
4218
|
J || (window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0);
|
|
4219
4219
|
const v = N.currentTarget.getBoundingClientRect();
|
|
4220
|
-
|
|
4221
|
-
type:
|
|
4220
|
+
I({
|
|
4221
|
+
type: h.insert,
|
|
4222
4222
|
x: v.left + v.width / 2,
|
|
4223
4223
|
y: v.bottom
|
|
4224
4224
|
});
|
|
4225
4225
|
}
|
|
4226
4226
|
}
|
|
4227
4227
|
},
|
|
4228
|
-
typeof
|
|
4228
|
+
typeof h.label == "object" ? h.label : /* @__PURE__ */ e.createElement(
|
|
4229
4229
|
"math-field",
|
|
4230
4230
|
{
|
|
4231
4231
|
"read-only": !0,
|
|
@@ -4244,29 +4244,29 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4244
4244
|
cursor: "pointer"
|
|
4245
4245
|
}
|
|
4246
4246
|
},
|
|
4247
|
-
pe(
|
|
4247
|
+
pe(h.mathLabel != null ? h.mathLabel : h.insert)
|
|
4248
4248
|
)
|
|
4249
4249
|
)
|
|
4250
4250
|
);
|
|
4251
|
-
const R =
|
|
4251
|
+
const R = h.action === "BOLD", H = h.action === "ITALIC", P = h.action === "TEXT_COLOR", He = R && f.bold || H && f.italic || P && f.color !== "none" && f.color !== "black";
|
|
4252
4252
|
return /* @__PURE__ */ e.createElement(
|
|
4253
4253
|
"button",
|
|
4254
4254
|
{
|
|
4255
4255
|
key: `${M.label}-${w * 4 + C}`,
|
|
4256
4256
|
type: "button",
|
|
4257
|
-
className: `cme-btn${M.isTemplate ? " template" : ""}${
|
|
4258
|
-
title:
|
|
4257
|
+
className: `cme-btn${M.isTemplate ? " template" : ""}${h.cls ? ` ${h.cls}` : ""}${He ? " active" : ""}`,
|
|
4258
|
+
title: h.title || h.label || h.insert,
|
|
4259
4259
|
onPointerDown: (N) => {
|
|
4260
4260
|
var $, ee, te, le, Z, V, ye;
|
|
4261
4261
|
N.preventDefault();
|
|
4262
4262
|
const v = s.current;
|
|
4263
|
-
if (
|
|
4263
|
+
if (h.action === "SPECIAL_CHARS") {
|
|
4264
4264
|
const S = N.currentTarget.getBoundingClientRect();
|
|
4265
4265
|
A({ x: S.left, y: S.bottom + 4 });
|
|
4266
|
-
} else if (
|
|
4266
|
+
} else if (h.action === "TEXT_COLOR") {
|
|
4267
4267
|
const S = N.currentTarget.getBoundingClientRect();
|
|
4268
4268
|
y({ x: S.left, y: S.bottom + 4 });
|
|
4269
|
-
} else if (
|
|
4269
|
+
} else if (h.action === "BOLD") {
|
|
4270
4270
|
if (v) {
|
|
4271
4271
|
v.focus();
|
|
4272
4272
|
const S = !f.bold;
|
|
@@ -4278,7 +4278,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4278
4278
|
}
|
|
4279
4279
|
ce((W) => ({ ...W, bold: S }));
|
|
4280
4280
|
}
|
|
4281
|
-
} else if (
|
|
4281
|
+
} else if (h.action === "ITALIC") {
|
|
4282
4282
|
if (v) {
|
|
4283
4283
|
v.focus();
|
|
4284
4284
|
const S = !f.italic;
|
|
@@ -4290,16 +4290,16 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4290
4290
|
}
|
|
4291
4291
|
ce((W) => ({ ...W, italic: S }));
|
|
4292
4292
|
}
|
|
4293
|
-
} else
|
|
4293
|
+
} else h.action === "UNDO" ? ($ = s.current) == null || $.executeCommand("undo") : h.action === "REDO" ? (ee = s.current) == null || ee.executeCommand("redo") : h.action === "CUT" ? ((te = s.current) == null || te.focus(), (le = s.current) == null || le.executeCommand("cutToClipboard")) : h.action === "COPY" ? ((Z = s.current) == null || Z.focus(), (V = s.current) == null || V.executeCommand("copyToClipboard")) : h.action === "PASTE" ? ((ye = s.current) == null || ye.focus(), navigator.clipboard.readText().then((S) => {
|
|
4294
4294
|
var D;
|
|
4295
4295
|
(D = s.current) == null || D.executeCommand(["insert", S]);
|
|
4296
4296
|
}).catch((S) => {
|
|
4297
4297
|
var D;
|
|
4298
4298
|
(D = s.current) == null || D.executeCommand("pasteFromClipboard");
|
|
4299
|
-
})) : z(
|
|
4299
|
+
})) : z(h.insert);
|
|
4300
4300
|
}
|
|
4301
4301
|
},
|
|
4302
|
-
(M.isTemplate || M.label === "√(□)" || M.isMatrix ||
|
|
4302
|
+
(M.isTemplate || M.label === "√(□)" || M.isMatrix || h.isWidget) && h.insert && !h.action && !h.forceLabel ? /* @__PURE__ */ e.createElement(
|
|
4303
4303
|
"math-field",
|
|
4304
4304
|
{
|
|
4305
4305
|
"read-only": !0,
|
|
@@ -4318,8 +4318,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4318
4318
|
cursor: "pointer"
|
|
4319
4319
|
}
|
|
4320
4320
|
},
|
|
4321
|
-
pe(
|
|
4322
|
-
) :
|
|
4321
|
+
pe(h.insert)
|
|
4322
|
+
) : h.label
|
|
4323
4323
|
);
|
|
4324
4324
|
})
|
|
4325
4325
|
));
|
|
@@ -4330,12 +4330,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4330
4330
|
ref: (t) => {
|
|
4331
4331
|
t && requestAnimationFrame(() => {
|
|
4332
4332
|
const i = t.getBoundingClientRect(), r = document.querySelector(".cme-editor-popup");
|
|
4333
|
-
let
|
|
4333
|
+
let c = k.cx - i.width / 2, b = k.y;
|
|
4334
4334
|
if (r) {
|
|
4335
4335
|
const w = r.getBoundingClientRect();
|
|
4336
|
-
|
|
4336
|
+
c + i.width > w.right - 4 && (c = w.right - i.width - 4), c < w.left + 4 && (c = w.left + 4), b + i.height > w.bottom - 4 && (b = w.bottom - i.height - 4);
|
|
4337
4337
|
}
|
|
4338
|
-
|
|
4338
|
+
c + i.width > window.innerWidth - 4 && (c = window.innerWidth - i.width - 4), b + i.height > window.innerHeight - 4 && (b = window.innerHeight - i.height - 4), c < 4 && (c = 4), t.style.left = `${c}px`, t.style.top = `${b}px`, t.style.transform = "none";
|
|
4339
4339
|
});
|
|
4340
4340
|
},
|
|
4341
4341
|
className: "cme-more-popup",
|
|
@@ -4399,7 +4399,10 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4399
4399
|
"math-field",
|
|
4400
4400
|
{
|
|
4401
4401
|
ref: (t) => {
|
|
4402
|
-
s.current = t, U = t, t && (t.inlineShortcuts = Object.assign({}, t.inlineShortcuts, { "*": "*" }), window.mathVirtualKeyboard && (window.mathVirtualKeyboard.policy = "manual"))
|
|
4402
|
+
s.current = t, U = t, t && (t.inlineShortcuts = Object.assign({}, t.inlineShortcuts, { "*": "*" }), window.mathVirtualKeyboard && (window.mathVirtualKeyboard.policy = "manual"), t.menuItems && (t.menuItems = t.menuItems.filter((i) => {
|
|
4403
|
+
const r = typeof i.label == "string" ? i.label.toLowerCase() : "", c = typeof i.id == "string" ? i.id.toLowerCase() : "";
|
|
4404
|
+
return !r.includes("matrix") && !c.includes("matrix");
|
|
4405
|
+
})));
|
|
4403
4406
|
},
|
|
4404
4407
|
class: "cme-mathfield",
|
|
4405
4408
|
tabIndex: 0,
|
|
@@ -4409,7 +4412,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4409
4412
|
)
|
|
4410
4413
|
),
|
|
4411
4414
|
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-footer" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-insert-btn", onClick: Oe }, n ? "Update" : "Insert"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-cancel-btn", onClick: xe }, "Cancel"), /* @__PURE__ */ e.createElement("span", { style: { marginLeft: "auto", fontSize: "11px", color: "#888", alignSelf: "center", marginRight: "10px" } }, "v", Xe.version)),
|
|
4412
|
-
|
|
4415
|
+
Be && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onPointerDown: (t) => {
|
|
4413
4416
|
t.stopPropagation(), Y(!1);
|
|
4414
4417
|
} }, /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-modal", onPointerDown: (t) => t.stopPropagation() }, /* @__PURE__ */ e.createElement("p", null, "Are you sure you want to leave? The changes you made will be lost."), /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-actions" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-close-btn", onClick: (t) => {
|
|
4415
4418
|
t.stopPropagation(), Y(!1), a && a();
|
|
@@ -4424,7 +4427,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4424
4427
|
x: x.x,
|
|
4425
4428
|
y: x.y,
|
|
4426
4429
|
onSelect: (t, i) => {
|
|
4427
|
-
De(x.type, t, i),
|
|
4430
|
+
De(x.type, t, i), I(null);
|
|
4428
4431
|
},
|
|
4429
4432
|
onMouseEnter: () => {
|
|
4430
4433
|
},
|
|
@@ -4510,8 +4513,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
|
|
|
4510
4513
|
},
|
|
4511
4514
|
onPointerDown: (r) => {
|
|
4512
4515
|
r.preventDefault(), r.stopPropagation();
|
|
4513
|
-
const
|
|
4514
|
-
|
|
4516
|
+
const c = s.current;
|
|
4517
|
+
c && typeof c.applyStyle == "function" && (c.focus(), c.applyStyle({ color: t === "black" ? "none" : t }), F()), y(null);
|
|
4515
4518
|
}
|
|
4516
4519
|
}
|
|
4517
4520
|
);
|