digi-mathchem-editor 1.0.20 → 1.0.21
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.
|
@@ -365,32 +365,32 @@ function it({ isOpen: l, onClose: n, onInsert: o, position: c }) {
|
|
|
365
365
|
O(() => {
|
|
366
366
|
l && (h(""), d("All"));
|
|
367
367
|
}, [l]);
|
|
368
|
-
const
|
|
368
|
+
const u = Te(() => {
|
|
369
369
|
let k = rt;
|
|
370
370
|
if (m !== "All" && (k = k.filter((f) => f.category === m)), a.trim()) {
|
|
371
371
|
const f = a.trim().toUpperCase();
|
|
372
372
|
k = k.filter((x) => x.code.includes(f));
|
|
373
373
|
}
|
|
374
374
|
return k;
|
|
375
|
-
}, [m, a]),
|
|
375
|
+
}, [m, a]), C = Te(() => {
|
|
376
376
|
if (m !== "All" && !a.trim())
|
|
377
|
-
return { [m]:
|
|
377
|
+
return { [m]: u };
|
|
378
378
|
const k = {};
|
|
379
|
-
return
|
|
379
|
+
return u.forEach((f) => {
|
|
380
380
|
k[f.category] || (k[f.category] = []), k[f.category].push(f);
|
|
381
381
|
}), k;
|
|
382
|
-
}, [
|
|
382
|
+
}, [u, m, a]), p = (k) => {
|
|
383
383
|
k.key === "Escape" && n();
|
|
384
384
|
};
|
|
385
385
|
if (O(() => (l && window.addEventListener("keydown", p), () => window.removeEventListener("keydown", p)), [l]), !l) return null;
|
|
386
|
-
let
|
|
386
|
+
let A = { top: "50%", left: "50%", transform: "translate(-50%, -50%)" };
|
|
387
387
|
if (c) {
|
|
388
388
|
let k = c.x - 120, f = c.y;
|
|
389
|
-
k < 10 && (k = 10), k + 230 > window.innerWidth && (k = window.innerWidth - 240), f + 200 > window.innerHeight && (f = window.innerHeight - 210),
|
|
389
|
+
k < 10 && (k = 10), k + 230 > window.innerWidth && (k = window.innerWidth - 240), f + 200 > window.innerHeight && (f = window.innerHeight - 210), A = { top: `${f}px`, left: `${k}px` };
|
|
390
390
|
}
|
|
391
391
|
return /* @__PURE__ */ e.createElement("div", { className: "scm-overlay", onMouseDown: (k) => {
|
|
392
392
|
k.stopPropagation(), n();
|
|
393
|
-
} }, /* @__PURE__ */ e.createElement("div", { className: "scm-modal", style:
|
|
393
|
+
} }, /* @__PURE__ */ e.createElement("div", { className: "scm-modal", style: A, onMouseDown: (k) => k.stopPropagation() }, /* @__PURE__ */ e.createElement("div", { className: "scm-toolbar" }, /* @__PURE__ */ e.createElement(
|
|
394
394
|
"input",
|
|
395
395
|
{
|
|
396
396
|
type: "text",
|
|
@@ -407,7 +407,7 @@ function it({ isOpen: l, onClose: n, onInsert: o, position: c }) {
|
|
|
407
407
|
className: "scm-category-select"
|
|
408
408
|
},
|
|
409
409
|
Ue.map((k) => /* @__PURE__ */ e.createElement("option", { key: k.id, value: k.id }, k.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(C).map(([k, f]) => /* @__PURE__ */ e.createElement("div", { key: k, className: "scm-category-group" }, /* @__PURE__ */ e.createElement("div", { className: "scm-char-grid" }, f.map((x) => /* @__PURE__ */ e.createElement(
|
|
411
411
|
"button",
|
|
412
412
|
{
|
|
413
413
|
key: x.code,
|
|
@@ -418,9 +418,9 @@ function it({ isOpen: l, onClose: n, onInsert: o, position: c }) {
|
|
|
418
418
|
title: `U+${x.code}`
|
|
419
419
|
},
|
|
420
420
|
x.char
|
|
421
|
-
))))),
|
|
421
|
+
))))), u.length === 0 && /* @__PURE__ */ e.createElement("div", { className: "scm-no-results" }, "No characters found.")))));
|
|
422
422
|
}
|
|
423
|
-
const nt = "1.0.
|
|
423
|
+
const nt = "1.0.21", at = {
|
|
424
424
|
version: nt
|
|
425
425
|
};
|
|
426
426
|
window.__cme_macros = {
|
|
@@ -537,12 +537,12 @@ function De(l) {
|
|
|
537
537
|
for (; m < n.length; ) {
|
|
538
538
|
const d = n.indexOf(h, m);
|
|
539
539
|
if (d === -1) break;
|
|
540
|
-
let
|
|
541
|
-
for (;
|
|
542
|
-
n[
|
|
543
|
-
if (
|
|
544
|
-
const p = n.slice(d + h.length,
|
|
545
|
-
n = n.slice(0, d) + p + n.slice(
|
|
540
|
+
let u = 1, C = d + h.length;
|
|
541
|
+
for (; C < n.length && u > 0; )
|
|
542
|
+
n[C] === "{" && !Be(n, C) ? u++ : n[C] === "}" && !Be(n, C) && u--, C++;
|
|
543
|
+
if (u === 0) {
|
|
544
|
+
const p = n.slice(d + h.length, C - 1);
|
|
545
|
+
n = n.slice(0, d) + p + n.slice(C), c = !0, m = d;
|
|
546
546
|
} else
|
|
547
547
|
m = d + h.length;
|
|
548
548
|
}
|
|
@@ -605,14 +605,15 @@ function ae(l, n, o, c) {
|
|
|
605
605
|
if (!l) return "";
|
|
606
606
|
let a = l.trim();
|
|
607
607
|
const h = a.match(/^\\displaylines\s*\{([\s\S]*)\}$/i);
|
|
608
|
-
h && (a = h[1].trim())
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
608
|
+
if (h && (a = h[1].trim()), a.match(/^\\begin\{(array|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|align|aligned|gather|cases)\}([\s\S]*)\\end\{\1\}$/i))
|
|
609
|
+
return a;
|
|
610
|
+
const d = a.match(/^\\begin\{(array|gather)\}(\{[\s\S]*?\})?([\s\S]*?)\\end\{\1\}$/i);
|
|
611
|
+
if (d && (a = d[3].trim()), /\\\\|\\cr|\\newline|\\par|\n/.test(a)) {
|
|
612
|
+
const u = /\\\\(?:\[[^\]]*\])?|\\cr|\\newline|\\par|\n/;
|
|
613
|
+
return a.split(u).map((p) => {
|
|
614
|
+
const A = p.trim();
|
|
615
|
+
return A ? Ne(A, n, o, c) : "";
|
|
616
|
+
}).filter((p) => p.length > 0).join(" \\\\ ");
|
|
616
617
|
}
|
|
617
618
|
return Ne(a, n, o, c);
|
|
618
619
|
}
|
|
@@ -644,20 +645,20 @@ function ht(l, n) {
|
|
|
644
645
|
if ((o == null ? void 0 : o.name) === "mathInline") return o;
|
|
645
646
|
const c = n.getAttribute("data-math-id");
|
|
646
647
|
if (c) {
|
|
647
|
-
const
|
|
648
|
-
if (Pe(l,
|
|
648
|
+
const u = window.__ckMathWidgets.get(c);
|
|
649
|
+
if (Pe(l, u)) return u;
|
|
649
650
|
}
|
|
650
651
|
const a = l.editing.view.domConverter.mapDomToView(n);
|
|
651
652
|
if (a) {
|
|
652
|
-
const
|
|
653
|
-
if ((
|
|
653
|
+
const u = l.editing.mapper.toModelElement(a);
|
|
654
|
+
if ((u == null ? void 0 : u.name) === "mathInline") return u;
|
|
654
655
|
}
|
|
655
656
|
const h = he(n);
|
|
656
657
|
if (!h) return null;
|
|
657
658
|
const m = l.model.document.getRoot();
|
|
658
|
-
for (const { item:
|
|
659
|
-
if ((d =
|
|
660
|
-
return
|
|
659
|
+
for (const { item: u } of l.model.createRangeIn(m))
|
|
660
|
+
if ((d = u.is) != null && d.call(u, "element", "mathInline") && u.getAttribute("latex") === h)
|
|
661
|
+
return u;
|
|
661
662
|
return null;
|
|
662
663
|
}
|
|
663
664
|
function qe(l, n, o, c) {
|
|
@@ -2065,7 +2066,7 @@ const dt = [
|
|
|
2065
2066
|
{ label: "∰", insert: "\\mathop{{\\style{font-size:1em;}{\\iiint}}\\mkern-28mu\\class{wider-circle}{\\bigcirc}\\mkern18mu}", title: "Closed volume integral" }
|
|
2066
2067
|
]
|
|
2067
2068
|
},
|
|
2068
|
-
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "
|
|
2069
|
+
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "22", y: "54", transform: "skewX(-15)", fontFamily: "serif", fontSize: "58", fontWeight: "normal", fill: "#222", stroke: "none", textAnchor: "middle" }, "∫")), forceLabel: !0, insert: "\\int", title: "Integral" },
|
|
2069
2070
|
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "16", y: "54", fontFamily: "serif", fontSize: "58", fontWeight: "normal", fill: "#222", stroke: "none", textAnchor: "middle" }, "∬")), forceLabel: !0, insert: "\\iint", title: "Double integral" },
|
|
2070
2071
|
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "16", y: "54", fontFamily: "serif", fontSize: "58", fontWeight: "normal", fill: "#222", stroke: "none", textAnchor: "middle" }, "∮")), forceLabel: !0, insert: "\\oint", title: "Contour integral" },
|
|
2071
2072
|
// { label: (<svg width="14" height="26" viewBox="0 0 32 64" fill="none" style={{ display: 'inline-block', verticalAlign: 'middle', overflow: 'visible' }}><text x="16" y="54" fontFamily="serif" fontSize="58" fontWeight="normal" fill="#222" stroke="none" textAnchor="middle">∯</text></svg>), forceLabel: true, insert: '\\oiint', title: 'surface integral' },
|
|
@@ -3671,7 +3672,7 @@ const dt = [
|
|
|
3671
3672
|
// { label: '∮', insert: '\\oint', title: 'Contour integral' },
|
|
3672
3673
|
// // { label: '∯', insert: '\\oiint', title: 'surface integral' },
|
|
3673
3674
|
// { label: '∯', insert: '\\mathop{{\\style{font-size:1em;}{\\iint}}\\mkern-23mu\\class{wide-circle}{\\bigcirc}\\mkern14mu}', title: 'Custom surface integral' },
|
|
3674
|
-
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "
|
|
3675
|
+
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "22", y: "54", transform: "skewX(-15)", fontFamily: "serif", fontSize: "58", fontWeight: "normal", fill: "#222", stroke: "none", textAnchor: "middle" }, "∫")), forceLabel: !0, insert: "\\int", title: "Integral" },
|
|
3675
3676
|
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "16", y: "54", fontFamily: "serif", fontSize: "58", fontWeight: "normal", fill: "#222", stroke: "none", textAnchor: "middle" }, "∬")), forceLabel: !0, insert: "\\iint", title: "Double integral" },
|
|
3676
3677
|
{ label: /* @__PURE__ */ e.createElement("svg", { width: "14", height: "26", viewBox: "0 0 32 64", fill: "none", style: { display: "inline-block", verticalAlign: "middle", overflow: "visible" } }, /* @__PURE__ */ e.createElement("text", { x: "16", y: "54", fontFamily: "serif", fontSize: "58", fontWeight: "normal", fill: "#222", stroke: "none", textAnchor: "middle" }, "∮")), forceLabel: !0, insert: "\\oint", title: "Contour integral" },
|
|
3677
3678
|
// { label: (<svg width="14" height="26" viewBox="0 0 32 64" fill="none" style={{ display: 'inline-block', verticalAlign: 'middle', overflow: 'visible' }}><text x="16" y="54" fontFamily="serif" fontSize="58" fontWeight="normal" fill="#222" stroke="none" textAnchor="middle">∯</text></svg>), forceLabel: true, insert: '\\oiint', title: 'surface integral' },
|
|
@@ -3767,18 +3768,18 @@ class vt extends Ke {
|
|
|
3767
3768
|
contenteditable: "false",
|
|
3768
3769
|
"data-math-id": m,
|
|
3769
3770
|
"data-latex": h
|
|
3770
|
-
}),
|
|
3771
|
+
}), u = a.createRawElement(
|
|
3771
3772
|
"span",
|
|
3772
3773
|
{
|
|
3773
3774
|
class: "ck-math-widget-inner",
|
|
3774
3775
|
style: "display:inline-block;vertical-align:middle;margin:0;cursor:pointer;width:auto;max-width:100%;pointer-events:none;"
|
|
3775
3776
|
},
|
|
3776
|
-
(
|
|
3777
|
+
(C) => {
|
|
3777
3778
|
const p = document.createElement("math-field");
|
|
3778
3779
|
p.setAttribute("math-virtual-keyboard-policy", "manual"), p.setAttribute("tabindex", "-1"), p.style.display = "inline-block", p.style.width = "auto", p.style.maxWidth = "100%", p.style.verticalAlign = "middle", p.style.border = "none", p.style.background = "transparent", p.style.outline = "none", p.style.fontSize = "inherit", p.style.minHeight = "auto", p.style.padding = "0", p.style.margin = "0", p.style.pointerEvents = "none";
|
|
3779
|
-
const
|
|
3780
|
+
const A = () => {
|
|
3780
3781
|
if (!p.isConnected) {
|
|
3781
|
-
requestAnimationFrame(
|
|
3782
|
+
requestAnimationFrame(A);
|
|
3782
3783
|
return;
|
|
3783
3784
|
}
|
|
3784
3785
|
window.__cme_macros && (p.macros = { ...p.macros, ...window.__cme_macros });
|
|
@@ -3802,15 +3803,15 @@ class vt extends Ke {
|
|
|
3802
3803
|
}
|
|
3803
3804
|
p.setAttribute("read-only", "");
|
|
3804
3805
|
};
|
|
3805
|
-
customElements.get("math-field") ? requestAnimationFrame(
|
|
3806
|
+
customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)), C.appendChild(p);
|
|
3806
3807
|
const k = () => {
|
|
3807
|
-
const f =
|
|
3808
|
+
const f = C.parentElement;
|
|
3808
3809
|
f && mt(n, f);
|
|
3809
3810
|
};
|
|
3810
3811
|
k(), requestAnimationFrame(k);
|
|
3811
3812
|
}
|
|
3812
3813
|
);
|
|
3813
|
-
return a.insert(a.createPositionAt(d, 0),
|
|
3814
|
+
return a.insert(a.createPositionAt(d, 0), u), Ge(d, a, { label: "math formula" });
|
|
3814
3815
|
}
|
|
3815
3816
|
});
|
|
3816
3817
|
const o = n.editing.view.document;
|
|
@@ -3826,19 +3827,19 @@ class vt extends Ke {
|
|
|
3826
3827
|
c.on("attribute:latex:mathInline", (a, h, m) => {
|
|
3827
3828
|
if (!m.consumable.consume(h.item, a.name))
|
|
3828
3829
|
return;
|
|
3829
|
-
const d = m.writer,
|
|
3830
|
-
if (
|
|
3831
|
-
d.setAttribute("data-latex", h.attributeNewValue,
|
|
3832
|
-
const
|
|
3833
|
-
if (
|
|
3834
|
-
const p =
|
|
3830
|
+
const d = m.writer, u = m.mapper.toViewElement(h.item);
|
|
3831
|
+
if (u) {
|
|
3832
|
+
d.setAttribute("data-latex", h.attributeNewValue, u);
|
|
3833
|
+
const C = n.editing.view.domConverter.mapViewToDom(u);
|
|
3834
|
+
if (C) {
|
|
3835
|
+
const p = C.querySelector("math-field");
|
|
3835
3836
|
if (p) {
|
|
3836
|
-
let
|
|
3837
|
-
|
|
3837
|
+
let A = Ee(se(G(we(h.attributeNewValue))));
|
|
3838
|
+
A.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(A.trim()) && (A = A.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")), p.removeAttribute("read-only");
|
|
3838
3839
|
try {
|
|
3839
|
-
p.setValue ? p.setValue("", { silenceNotifications: !0 }) : p.value = "", p.executeCommand(["insert",
|
|
3840
|
+
p.setValue ? p.setValue("", { silenceNotifications: !0 }) : p.value = "", p.executeCommand(["insert", A, { insertionMode: "replaceAll" }]);
|
|
3840
3841
|
} catch {
|
|
3841
|
-
p.setValue ? p.setValue(
|
|
3842
|
+
p.setValue ? p.setValue(A, { silenceNotifications: !0 }) : p.value = A;
|
|
3842
3843
|
}
|
|
3843
3844
|
p.setAttribute("read-only", "");
|
|
3844
3845
|
}
|
|
@@ -3861,8 +3862,8 @@ class vt extends Ke {
|
|
|
3861
3862
|
)
|
|
3862
3863
|
);
|
|
3863
3864
|
d.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(d.trim()) && (d = d.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1"));
|
|
3864
|
-
let
|
|
3865
|
-
return a.insert(a.createPositionAt(m, 0), a.createText(
|
|
3865
|
+
let u = d.replace(/\\textasciitilde/g, "~").replace(/\\textasciicircum/g, "^").replace(/\\textasteriskcentered/g, "*").replace(/\\char96/g, "`").replace(/\\sim/g, "~").replace(/\\!/g, "!").replace(/\\@/g, "@").replace(/\\#/g, "#").replace(/\\$/g, "$").replace(/\\%/g, "%").replace(/\\&/g, "&").replace(/\\_/g, "_").replace(/\\\{/g, "{").replace(/\\\}/g, "}").replace(/\\ce\{([^}]*)\}/g, "$1").trim();
|
|
3866
|
+
return a.insert(a.createPositionAt(m, 0), a.createText(u)), m;
|
|
3866
3867
|
}
|
|
3867
3868
|
}), n.conversion.for("upcast").elementToElement({
|
|
3868
3869
|
view: {
|
|
@@ -3877,7 +3878,7 @@ class vt extends Ke {
|
|
|
3877
3878
|
}
|
|
3878
3879
|
}
|
|
3879
3880
|
function gt({ matrixType: l, x: n, y: o, onSelect: c, onMouseEnter: a, onMouseLeave: h }) {
|
|
3880
|
-
const [m, d] = I({ r: 2, c: 2 }),
|
|
3881
|
+
const [m, d] = I({ r: 2, c: 2 }), u = Math.max(10, parseInt(m.r, 10) || 0), C = Math.max(10, parseInt(m.c, 10) || 0), p = (x) => {
|
|
3881
3882
|
const v = x.target.value;
|
|
3882
3883
|
if (v === "") {
|
|
3883
3884
|
d((T) => ({ ...T, r: "" }));
|
|
@@ -3885,7 +3886,7 @@ function gt({ matrixType: l, x: n, y: o, onSelect: c, onMouseEnter: a, onMouseLe
|
|
|
3885
3886
|
}
|
|
3886
3887
|
const S = parseInt(v, 10);
|
|
3887
3888
|
isNaN(S) || d((T) => ({ ...T, r: Math.max(1, Math.min(10, S)) }));
|
|
3888
|
-
},
|
|
3889
|
+
}, A = () => {
|
|
3889
3890
|
(m.r === "" || isNaN(parseInt(m.r, 10))) && d((x) => ({ ...x, r: 1 }));
|
|
3890
3891
|
}, k = (x) => {
|
|
3891
3892
|
const v = x.target.value;
|
|
@@ -3916,7 +3917,7 @@ function gt({ matrixType: l, x: n, y: o, onSelect: c, onMouseEnter: a, onMouseLe
|
|
|
3916
3917
|
onMouseEnter: a,
|
|
3917
3918
|
onMouseLeave: h
|
|
3918
3919
|
},
|
|
3919
|
-
/* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length:
|
|
3920
|
+
/* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length: u }).map((x, v) => /* @__PURE__ */ e.createElement("div", { key: v, className: "cme-matrix-hover-row" }, Array.from({ length: C }).map((S, T) => {
|
|
3920
3921
|
const N = parseInt(m.r, 10) || 0, Q = parseInt(m.c, 10) || 0, F = v < N && T < Q;
|
|
3921
3922
|
return /* @__PURE__ */ e.createElement(
|
|
3922
3923
|
"div",
|
|
@@ -3937,7 +3938,7 @@ function gt({ matrixType: l, x: n, y: o, onSelect: c, onMouseEnter: a, onMouseLe
|
|
|
3937
3938
|
className: "cme-counter-val",
|
|
3938
3939
|
value: m.r,
|
|
3939
3940
|
onChange: p,
|
|
3940
|
-
onBlur:
|
|
3941
|
+
onBlur: A,
|
|
3941
3942
|
min: "1",
|
|
3942
3943
|
max: "10"
|
|
3943
3944
|
}
|
|
@@ -3969,19 +3970,19 @@ function gt({ matrixType: l, x: n, y: o, onSelect: c, onMouseEnter: a, onMouseLe
|
|
|
3969
3970
|
}
|
|
3970
3971
|
let j = !1, ye = null, Y = null;
|
|
3971
3972
|
function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a }) {
|
|
3972
|
-
const h = ne(null), [m, d] = I(null), [
|
|
3973
|
+
const h = ne(null), [m, d] = I(null), [u, C] = I(0), [p, A] = I(null), [k, f] = I(null), [x, v] = I(null), [S, T] = I(null);
|
|
3973
3974
|
ne(null);
|
|
3974
3975
|
const [N, Q] = I({ x: 0, y: 0 }), [F, X] = I(!1), me = ne({ x: 0, y: 0 }), [Fe, fe] = I(!1), [Ze, ve] = I(!1), [Je, $] = I(!1), de = ne(null);
|
|
3975
3976
|
O(() => {
|
|
3976
3977
|
const t = (i) => {
|
|
3977
3978
|
if (!F) return;
|
|
3978
3979
|
const s = i.touches && i.touches.length > 0 ? i.touches[0].clientX : i.clientX, b = i.touches && i.touches.length > 0 ? i.touches[0].clientY : i.clientY;
|
|
3979
|
-
let
|
|
3980
|
+
let w = s - me.current.x, g = b - me.current.y;
|
|
3980
3981
|
if (de.current) {
|
|
3981
3982
|
const L = de.current, M = -L.left, q = window.innerWidth - L.right, J = -L.top, D = window.innerHeight - L.bottom;
|
|
3982
|
-
|
|
3983
|
+
w < M && (w = M), w > q && (w = q), g < J && (g = J), g > D && (g = D);
|
|
3983
3984
|
}
|
|
3984
|
-
Q({ x:
|
|
3985
|
+
Q({ x: w, y: g });
|
|
3985
3986
|
}, r = () => X(!1);
|
|
3986
3987
|
return F && (window.addEventListener("mousemove", t, { passive: !1 }), window.addEventListener("mouseup", r), window.addEventListener("touchmove", t, { passive: !1 }), window.addEventListener("touchend", r)), () => {
|
|
3987
3988
|
window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", r), window.removeEventListener("touchmove", t), window.removeEventListener("touchend", r);
|
|
@@ -4064,7 +4065,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4064
4065
|
if (!(!t || typeof t.queryStyle != "function"))
|
|
4065
4066
|
try {
|
|
4066
4067
|
const r = Z(t);
|
|
4067
|
-
let i = Ae(t), s = Ce(t), b = "none",
|
|
4068
|
+
let i = Ae(t), s = Ce(t), b = "none", w = "auto", g = "none";
|
|
4068
4069
|
const L = (M) => ["all", "some", !0].includes(M);
|
|
4069
4070
|
if (r) {
|
|
4070
4071
|
window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0;
|
|
@@ -4076,7 +4077,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4076
4077
|
const q = ["roman", "sans-serif", "monospace"].find((D) => L(t.queryStyle({ fontFamily: D }))) || "none";
|
|
4077
4078
|
q !== "none" ? b = q : /\\mathsf\b/.test(M) ? b = "sans-serif" : /\\mathtt\b/.test(M) ? b = "monospace" : /\\mathrm\b/.test(M) ? b = "roman" : b = "none";
|
|
4078
4079
|
const J = [5, 7, 9].find((D) => L(t.queryStyle({ fontSize: D }))) || "auto";
|
|
4079
|
-
|
|
4080
|
+
w = String(J), g = [
|
|
4080
4081
|
"black",
|
|
4081
4082
|
"dimgray",
|
|
4082
4083
|
"gray",
|
|
@@ -4105,7 +4106,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4105
4106
|
} else
|
|
4106
4107
|
window.__cmeManualBold !== void 0 && (i = window.__cmeManualBold), window.__cmeManualItalic !== void 0 && (s = window.__cmeManualItalic), console.log("CME: updateActiveStyles else-branch bold=", i, "manual=", window.__cmeManualBold), b = window.__cmeManualFontFamily !== void 0 ? window.__cmeManualFontFamily : ["roman", "sans-serif", "monospace"].find(
|
|
4107
4108
|
(M) => L(t.queryStyle({ fontFamily: M }))
|
|
4108
|
-
) || "none",
|
|
4109
|
+
) || "none", w = window.__cmeManualFontSize !== void 0 ? window.__cmeManualFontSize : [5, 7, 9].find(
|
|
4109
4110
|
(M) => L(t.queryStyle({ fontSize: M }))
|
|
4110
4111
|
) || "auto", g = [
|
|
4111
4112
|
"black",
|
|
@@ -4139,7 +4140,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4139
4140
|
bold: i,
|
|
4140
4141
|
italic: s,
|
|
4141
4142
|
fontFamily: b,
|
|
4142
|
-
fontSize: String(
|
|
4143
|
+
fontSize: String(w),
|
|
4143
4144
|
color: g
|
|
4144
4145
|
});
|
|
4145
4146
|
} catch (r) {
|
|
@@ -4149,7 +4150,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4149
4150
|
O(() => {
|
|
4150
4151
|
if (!p && !x) return;
|
|
4151
4152
|
const t = (r) => {
|
|
4152
|
-
!r.target.closest(".cme-matrix-hover-popover") && !r.target.closest(".cme-matrix-btn-wrapper") &&
|
|
4153
|
+
!r.target.closest(".cme-matrix-hover-popover") && !r.target.closest(".cme-matrix-btn-wrapper") && A(null), !r.target.closest(".cme-color-picker-popup") && !r.target.closest('[title="Text Color"]') && v(null);
|
|
4153
4154
|
};
|
|
4154
4155
|
return window.addEventListener("mousedown", t, !0), window.addEventListener("pointerdown", t, !0), () => {
|
|
4155
4156
|
window.removeEventListener("mousedown", t, !0), window.removeEventListener("pointerdown", t, !0);
|
|
@@ -4165,7 +4166,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4165
4166
|
}, [S]), O(() => {
|
|
4166
4167
|
const t = setTimeout(() => tt(), 50);
|
|
4167
4168
|
return () => clearTimeout(t);
|
|
4168
|
-
}, [
|
|
4169
|
+
}, [u]), O(() => {
|
|
4169
4170
|
if (j) return;
|
|
4170
4171
|
const t = m;
|
|
4171
4172
|
if (!t) return;
|
|
@@ -4210,8 +4211,8 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4210
4211
|
);
|
|
4211
4212
|
const b = y.fontSize === "auto" ? 5 : parseInt(y.fontSize, 10);
|
|
4212
4213
|
if (b !== 5) {
|
|
4213
|
-
const
|
|
4214
|
-
|
|
4214
|
+
const w = { 1: "\\tiny", 2: "\\scriptsize", 3: "\\footnotesize", 4: "\\small", 5: "\\normalsize", 6: "\\large", 7: "\\Large", 8: "\\LARGE", 9: "\\huge", 10: "\\Huge" };
|
|
4215
|
+
w[b] && (s = `{${w[b]} ${s}}`);
|
|
4215
4216
|
}
|
|
4216
4217
|
y.color !== "none" && (s = `\\textcolor{${y.color}}{${s}}`), t.executeCommand(["insert", s]);
|
|
4217
4218
|
return;
|
|
@@ -4248,8 +4249,8 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4248
4249
|
}, [y]), ze = ke((t, r, i) => {
|
|
4249
4250
|
let s = `\\begin{${t}} `;
|
|
4250
4251
|
for (let b = 0; b < r; b++) {
|
|
4251
|
-
for (let
|
|
4252
|
-
s += "#?",
|
|
4252
|
+
for (let w = 0; w < i; w++)
|
|
4253
|
+
s += "#?", w < i - 1 && (s += " & ");
|
|
4253
4254
|
b < r - 1 && (s += " \\\\ ");
|
|
4254
4255
|
}
|
|
4255
4256
|
s += ` \\end{${t}}`, _(s);
|
|
@@ -4301,7 +4302,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4301
4302
|
/* @__PURE__ */ e.createElement("span", null, a ? l === "math" ? "Edit Math Formula" : "Edit Chemistry Formula" : l === "math" ? "Math Editor" : "Chemistry Editor")
|
|
4302
4303
|
), /* @__PURE__ */ e.createElement("div", { className: "cme-popup-controls" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-popup-btn", onClick: Qe, title: "Minimize" }, "—"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-popup-btn", onClick: je, title: "Maximize" }, "⤢"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-popup-btn", onClick: Le, title: "Close" }, "✕"))),
|
|
4303
4304
|
/* @__PURE__ */ e.createElement("div", { className: "cme-toolbar", role: "toolbar", "aria-label": "Symbol palette" }, /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-groups" }, ee.map((t, r) => {
|
|
4304
|
-
const i =
|
|
4305
|
+
const i = u === r;
|
|
4305
4306
|
return /* @__PURE__ */ e.createElement(
|
|
4306
4307
|
"button",
|
|
4307
4308
|
{
|
|
@@ -4309,7 +4310,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4309
4310
|
className: `cme-group-tab${i ? " active" : ""}`,
|
|
4310
4311
|
type: "button",
|
|
4311
4312
|
onPointerDown: (s) => {
|
|
4312
|
-
s.preventDefault(),
|
|
4313
|
+
s.preventDefault(), C(r), A(null);
|
|
4313
4314
|
}
|
|
4314
4315
|
},
|
|
4315
4316
|
t.mathLabel ? /* @__PURE__ */ e.createElement(
|
|
@@ -4337,24 +4338,24 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4337
4338
|
);
|
|
4338
4339
|
})), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
|
|
4339
4340
|
var s;
|
|
4340
|
-
const t = ((s = ee[
|
|
4341
|
+
const t = ((s = ee[u]) == null ? void 0 : s.items) || [], r = t.some((b) => b.type === "sep"), i = [];
|
|
4341
4342
|
if (r) {
|
|
4342
4343
|
let b = { cols: 2, small: !1, cls: "", items: [], moreItems: null };
|
|
4343
|
-
for (const
|
|
4344
|
-
|
|
4344
|
+
for (const w of t)
|
|
4345
|
+
w.type === "sep" ? (b.items.length > 0 && i.push(b), b = { cols: w.cols || 2, small: !!w.small, cls: w.cls || "", items: [], moreItems: w.moreItems || null, moreCols: w.moreCols || 1 }) : b.items.push(w);
|
|
4345
4346
|
b.items.length > 0 && i.push(b);
|
|
4346
4347
|
} else
|
|
4347
|
-
for (let
|
|
4348
|
+
for (let w = 0; w < t.length; w += 4)
|
|
4348
4349
|
i.push({
|
|
4349
4350
|
cols: 2,
|
|
4350
4351
|
small: !1,
|
|
4351
4352
|
cls: "",
|
|
4352
|
-
items: t.slice(
|
|
4353
|
+
items: t.slice(w, w + 4)
|
|
4353
4354
|
});
|
|
4354
|
-
return i.map((b,
|
|
4355
|
+
return i.map((b, w) => /* @__PURE__ */ e.createElement(
|
|
4355
4356
|
"div",
|
|
4356
4357
|
{
|
|
4357
|
-
key:
|
|
4358
|
+
key: w,
|
|
4358
4359
|
className: `cme-symbol-subgroup${b.small ? " cme-symbol-subgroup--small" : ""}${b.cls ? ` ${b.cls}` : ""}${b.moreItems ? " cme-subgroup-has-more" : ""}`,
|
|
4359
4360
|
style: { gridTemplateColumns: `repeat(${b.cols}, auto)`, position: "relative" }
|
|
4360
4361
|
},
|
|
@@ -4371,7 +4372,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4371
4372
|
if (g.stopPropagation(), S && S.items === b.moreItems)
|
|
4372
4373
|
T(null);
|
|
4373
4374
|
else {
|
|
4374
|
-
const L = g.currentTarget.getBoundingClientRect(), M = ee[
|
|
4375
|
+
const L = g.currentTarget.getBoundingClientRect(), M = ee[u] || {};
|
|
4375
4376
|
T({ cx: L.left + L.width / 2, y: L.bottom, items: b.moreItems, cols: b.moreCols, isTemplate: M.isTemplate || M.label === "√(□)" || M.isMatrix });
|
|
4376
4377
|
}
|
|
4377
4378
|
}
|
|
@@ -4379,7 +4380,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4379
4380
|
"▶"
|
|
4380
4381
|
),
|
|
4381
4382
|
b.items.map((g, L) => {
|
|
4382
|
-
const M = ee[
|
|
4383
|
+
const M = ee[u];
|
|
4383
4384
|
if (g.type === "dropdown") {
|
|
4384
4385
|
const B = g.label === "Font...", E = g.label === "Size", te = B && y.fontFamily !== "none", le = E && y.fontSize !== "auto" && y.fontSize !== "5", re = B ? y.fontFamily === "none" ? "" : y.fontFamily : E ? y.fontSize === "auto" || y.fontSize === "5" ? "" : y.fontSize : "";
|
|
4385
4386
|
return /* @__PURE__ */ e.createElement(
|
|
@@ -4426,11 +4427,11 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4426
4427
|
title: g.title || g.label || g.insert,
|
|
4427
4428
|
onPointerDown: (B) => {
|
|
4428
4429
|
if (B.preventDefault(), B.stopPropagation(), (p == null ? void 0 : p.type) === g.insert)
|
|
4429
|
-
|
|
4430
|
+
A(null);
|
|
4430
4431
|
else {
|
|
4431
4432
|
j || (window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0);
|
|
4432
4433
|
const E = B.currentTarget.getBoundingClientRect();
|
|
4433
|
-
|
|
4434
|
+
A({
|
|
4434
4435
|
type: g.insert,
|
|
4435
4436
|
x: E.left + E.width / 2,
|
|
4436
4437
|
y: E.bottom
|
|
@@ -4465,7 +4466,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4465
4466
|
return /* @__PURE__ */ e.createElement(
|
|
4466
4467
|
"button",
|
|
4467
4468
|
{
|
|
4468
|
-
key: `${M.label}-${
|
|
4469
|
+
key: `${M.label}-${w * 4 + L}`,
|
|
4469
4470
|
type: "button",
|
|
4470
4471
|
className: `cme-btn${M.isTemplate ? " template" : ""}${g.cls ? ` ${g.cls}` : ""}${_e ? " active" : ""}`,
|
|
4471
4472
|
title: g.title || g.label || g.insert,
|
|
@@ -4563,8 +4564,8 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4563
4564
|
const r = t.getBoundingClientRect(), i = document.querySelector(".cme-editor-popup");
|
|
4564
4565
|
let s = S.cx - r.width / 2, b = S.y;
|
|
4565
4566
|
if (i) {
|
|
4566
|
-
const
|
|
4567
|
-
s + r.width >
|
|
4567
|
+
const w = i.getBoundingClientRect();
|
|
4568
|
+
s + r.width > w.right - 4 && (s = w.right - r.width - 4), s < w.left + 4 && (s = w.left + 4), b + r.height > w.bottom - 4 && (b = w.bottom - r.height - 4);
|
|
4568
4569
|
}
|
|
4569
4570
|
s + r.width > window.innerWidth - 4 && (s = window.innerWidth - r.width - 4), b + r.height > window.innerHeight - 4 && (b = window.innerHeight - r.height - 4), s < 4 && (s = 4), t.style.left = `${s}px`, t.style.top = `${b}px`, t.style.transform = "none";
|
|
4570
4571
|
});
|
|
@@ -4658,7 +4659,7 @@ function kt({ mode: l, onInsert: n, onClose: o, initialLatex: c, isEditing: a })
|
|
|
4658
4659
|
x: p.x,
|
|
4659
4660
|
y: p.y,
|
|
4660
4661
|
onSelect: (t, r) => {
|
|
4661
|
-
ze(p.type, t, r),
|
|
4662
|
+
ze(p.type, t, r), A(null);
|
|
4662
4663
|
},
|
|
4663
4664
|
onMouseEnter: () => {
|
|
4664
4665
|
},
|