digi-mathchem-editor 1.0.35 → 1.0.36
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.
|
@@ -7400,10 +7400,10 @@ function ot(s) {
|
|
|
7400
7400
|
s[e] === "[" ? r++ : s[e] === "]" && r--, e++;
|
|
7401
7401
|
}
|
|
7402
7402
|
if (s[e] === "{") {
|
|
7403
|
-
let r = 1,
|
|
7403
|
+
let r = 1, o = e + 1;
|
|
7404
7404
|
for (e++; e < s.length && r > 0; )
|
|
7405
7405
|
s[e] === "{" ? r++ : s[e] === "}" && r--, e++;
|
|
7406
|
-
let i = s.slice(
|
|
7406
|
+
let i = s.slice(o, e - 1);
|
|
7407
7407
|
i.trim() === "" ? t += "\\quad " : t += i;
|
|
7408
7408
|
}
|
|
7409
7409
|
}
|
|
@@ -7420,11 +7420,11 @@ function at(s) {
|
|
|
7420
7420
|
break;
|
|
7421
7421
|
}
|
|
7422
7422
|
t += s.slice(e, r);
|
|
7423
|
-
let
|
|
7424
|
-
for (; i < s.length &&
|
|
7425
|
-
s[i] === "{" ?
|
|
7426
|
-
const
|
|
7427
|
-
/^['"/]+$/.test(
|
|
7423
|
+
let o = 1, i = r + l.length;
|
|
7424
|
+
for (; i < s.length && o > 0; )
|
|
7425
|
+
s[i] === "{" ? o++ : s[i] === "}" && o--, i++;
|
|
7426
|
+
const a = s.slice(r + l.length, i - 1);
|
|
7427
|
+
/^['"/]+$/.test(a) || a.includes("\\textquotedbl") || a.includes("\\textquotesingle") ? t += "\\text{" + a + "}" : t += a, e = i;
|
|
7428
7428
|
}
|
|
7429
7429
|
return t;
|
|
7430
7430
|
}
|
|
@@ -7458,19 +7458,19 @@ function X(s) {
|
|
|
7458
7458
|
let l = !0, r = 0;
|
|
7459
7459
|
for (; l && r < 10; ) {
|
|
7460
7460
|
l = !1, r++;
|
|
7461
|
-
for (const
|
|
7461
|
+
for (const o of e) {
|
|
7462
7462
|
let i = 0;
|
|
7463
7463
|
for (; i < t.length; ) {
|
|
7464
|
-
const
|
|
7465
|
-
if (
|
|
7466
|
-
let c = 1, d =
|
|
7464
|
+
const a = t.indexOf(o, i);
|
|
7465
|
+
if (a === -1) break;
|
|
7466
|
+
let c = 1, d = a + o.length;
|
|
7467
7467
|
for (; d < t.length && c > 0; )
|
|
7468
7468
|
t[d] === "{" && !Q(t, d) ? c++ : t[d] === "}" && !Q(t, d) && c--, d++;
|
|
7469
7469
|
if (c === 0) {
|
|
7470
|
-
const m = t.slice(
|
|
7471
|
-
t = t.slice(0,
|
|
7470
|
+
const m = t.slice(a + o.length, d - 1);
|
|
7471
|
+
t = t.slice(0, a) + m + t.slice(d), l = !0, i = a;
|
|
7472
7472
|
} else
|
|
7473
|
-
i =
|
|
7473
|
+
i = a + o.length;
|
|
7474
7474
|
}
|
|
7475
7475
|
}
|
|
7476
7476
|
}
|
|
@@ -7524,21 +7524,21 @@ function K(s, t, e, l) {
|
|
|
7524
7524
|
if (!s) return "";
|
|
7525
7525
|
if (!t && !e)
|
|
7526
7526
|
return ht(s, { fontFamily: l });
|
|
7527
|
-
const r = l === "sans-serif",
|
|
7528
|
-
return t && e ? r ? `\\boldsymbol{\\mathsf{${s}}}` :
|
|
7527
|
+
const r = l === "sans-serif", o = l === "monospace", i = l === "roman";
|
|
7528
|
+
return t && e ? r ? `\\boldsymbol{\\mathsf{${s}}}` : o ? `\\boldsymbol{\\mathtt{${s}}}` : i ? `\\mathbfit{\\mathrm{${s}}}` : `\\mathbfit{${s}}` : t ? r ? `\\boldsymbol{\\mathsf{${s}}}` : o ? `\\boldsymbol{\\mathtt{${s}}}` : i ? `\\mathbf{\\mathrm{${s}}}` : `\\mathbf{${s}}` : e ? r ? `\\mathsf{${s}}` : o ? `\\mathtt{${s}}` : i ? `\\mathit{\\mathrm{${s}}}` : `\\mathit{${s}}` : s;
|
|
7529
7529
|
}
|
|
7530
7530
|
function U(s, t, e, l) {
|
|
7531
7531
|
if (!s) return "";
|
|
7532
7532
|
let r = s.trim();
|
|
7533
|
-
const
|
|
7534
|
-
if (
|
|
7533
|
+
const o = r.match(/^\\displaylines\s*\{([\s\S]*)\}$/i);
|
|
7534
|
+
if (o && (r = o[1].trim()), r.match(/^\\begin\{(array|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|align|aligned|gather|cases)\}([\s\S]*)\\end\{\1\}$/i))
|
|
7535
7535
|
return r;
|
|
7536
|
-
const
|
|
7537
|
-
if (
|
|
7536
|
+
const a = r.match(/^\\begin\{(array|gather)\}(\{[\s\S]*?\})?([\s\S]*?)\\end\{\1\}$/i);
|
|
7537
|
+
if (a && (r = a[3].trim()), /\\\\|\\cr|\\newline|\\par|\n/.test(r)) {
|
|
7538
7538
|
const c = /\\\\(?:\[[^\]]*\])?|\\cr|\\newline|\\par|\n/;
|
|
7539
7539
|
return `\\displaylines{${r.split(c).map((w) => {
|
|
7540
|
-
const
|
|
7541
|
-
return
|
|
7540
|
+
const C = w.trim();
|
|
7541
|
+
return C ? K(C, t, e, l) : "";
|
|
7542
7542
|
}).filter((w) => w.length > 0).join(" \\\\ ")}}`;
|
|
7543
7543
|
}
|
|
7544
7544
|
return K(r, t, e, l);
|
|
@@ -7546,20 +7546,57 @@ function U(s, t, e, l) {
|
|
|
7546
7546
|
function ct(s) {
|
|
7547
7547
|
return s ? s.replace(/\\enclose\{([^}]*)\}\s*\[.*?\]/g, "\\enclose{$1}") : "";
|
|
7548
7548
|
}
|
|
7549
|
+
function dt(s, t) {
|
|
7550
|
+
if (typeof s != "string" || !s.includes("\\ce{")) return s;
|
|
7551
|
+
let e = "", l = 0;
|
|
7552
|
+
for (; l < s.length; ) {
|
|
7553
|
+
const r = s.indexOf("\\ce{", l);
|
|
7554
|
+
if (r === -1) {
|
|
7555
|
+
e += s.slice(l);
|
|
7556
|
+
break;
|
|
7557
|
+
}
|
|
7558
|
+
e += s.slice(l, r);
|
|
7559
|
+
let o = 1, i = r + 4;
|
|
7560
|
+
for (; i < s.length && o > 0; ) {
|
|
7561
|
+
if (s[i] === "\\") {
|
|
7562
|
+
i += 2;
|
|
7563
|
+
continue;
|
|
7564
|
+
}
|
|
7565
|
+
s[i] === "{" ? o++ : s[i] === "}" && o--, i++;
|
|
7566
|
+
}
|
|
7567
|
+
if (o === 0) {
|
|
7568
|
+
const a = s.slice(r + 4, i - 1), c = s.slice(r, i);
|
|
7569
|
+
e += t(c, a), l = i;
|
|
7570
|
+
} else
|
|
7571
|
+
e += s.slice(r, i), l = i;
|
|
7572
|
+
}
|
|
7573
|
+
return e;
|
|
7574
|
+
}
|
|
7549
7575
|
function P(s = "") {
|
|
7550
7576
|
if (typeof s != "string") return s;
|
|
7551
7577
|
let t = s.replace(/\\textasciitilde/g, "\\text{~}").replace(/\\textasciicircum/g, "\\text{^}").replace(/\\textasteriskcentered/g, "*").replace(/\\char96/g, "`");
|
|
7552
|
-
return t.includes("\\ce{") && (t = t
|
|
7553
|
-
if (l.includes("\\{") || l.includes("\\}") || l.includes("\\lbrace") || l.includes("\\rbrace"))
|
|
7578
|
+
return t.includes("\\ce{") && (t = dt(t, (e, l) => {
|
|
7579
|
+
if (l.includes("\\{") || l.includes("\\}") || l.includes("\\lbrace") || l.includes("\\rbrace") || l.includes("\\xrightarrow") || l.includes("\\xrightleftharpoons") || l.includes("\\xleftrightharpoons") || l.includes("\\xleftrightarrows") || l.includes("\\xleftarrow") || l.includes("\\xleftrightarrow") || l.includes("\\xtofrom") || l.includes("\\enclose") || l.includes("\\class{cme-"))
|
|
7554
7580
|
return l;
|
|
7555
7581
|
let r = l.replace(/\\left\[/g, "[").replace(/\\right\]/g, "]").replace(/\\lbrack\b/g, "[").replace(/\\rbrack\b/g, "]").replace(/\\left\(/g, "(").replace(/\\right\)/g, ")").replace(/\\left\|/g, "|").replace(/\\right\|/g, "|").replace(/\\left\./g, "").replace(/\\right\./g, "").replace(/\\enspace(?:\s|{})?/g, "~");
|
|
7556
7582
|
return r = r.replace(
|
|
7557
7583
|
new RegExp("(?<!\\{)\\\\(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|vartheta|iota|kappa|lambda|mu|nu|xi|pi|varpi|rho|varrho|varsigma|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)\\b(?!\\})", "g"),
|
|
7558
7584
|
"{\\$1}"
|
|
7559
|
-
),
|
|
7585
|
+
), r = r.replace(/(?:[\s~]*\+[\s~]*)/g, (o, i, a) => {
|
|
7586
|
+
const c = a.slice(0, i);
|
|
7587
|
+
if (/\^(\d*|[a-zA-Z]*)$/.test(c))
|
|
7588
|
+
return o.trim();
|
|
7589
|
+
const d = c.lastIndexOf("^{");
|
|
7590
|
+
if (d !== -1) {
|
|
7591
|
+
const m = c.slice(d), w = (m.match(/\{/g) || []).length, C = (m.match(/\}/g) || []).length;
|
|
7592
|
+
if (w > C)
|
|
7593
|
+
return o.trim();
|
|
7594
|
+
}
|
|
7595
|
+
return " + ";
|
|
7596
|
+
}).replace(/\s{2,}/g, " "), `\\ce{${r}}`;
|
|
7560
7597
|
})), t;
|
|
7561
7598
|
}
|
|
7562
|
-
function
|
|
7599
|
+
function Mt(s) {
|
|
7563
7600
|
if (!s) return "";
|
|
7564
7601
|
let t = s;
|
|
7565
7602
|
const e = t.match(/^\\ce\{([\s\S]*)\}/);
|
|
@@ -7685,27 +7722,27 @@ function vt(s) {
|
|
|
7685
7722
|
["\\cdots", "⋯"],
|
|
7686
7723
|
["\\ldots", "…"]
|
|
7687
7724
|
];
|
|
7688
|
-
for (const [i,
|
|
7725
|
+
for (const [i, a] of l) {
|
|
7689
7726
|
const c = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7690
|
-
t = t.replace(new RegExp(c, "g"),
|
|
7727
|
+
t = t.replace(new RegExp(c, "g"), a);
|
|
7691
7728
|
}
|
|
7692
7729
|
t = t.replace(/\\frac\{([^}]*)\}\{([^}]*)\}/g, "$1/$2"), t = t.replace(/\\sqrt\[([^\]]*)\]\{([^}]*)\}/g, "$1√($2)"), t = t.replace(/\\sqrt\{([^}]*)\}/g, "√($1)"), t = t.replace(/\\vec\{([^}]*)\}/g, "$1⃗"), t = t.replace(/\\hat\{([^}]*)\}/g, "$1̂"), t = t.replace(/\\bar\{([^}]*)\}/g, "$1̄"), t = t.replace(/\\ddot\{([^}]*)\}/g, "$1̈"), t = t.replace(/\\dot\{([^}]*)\}/g, "$1̇"), t = t.replace(/\\text\{([^}]*)\}/g, "$1"), t = t.replace(
|
|
7693
7730
|
/\\begin\{pmatrix\}([\s\S]*?)\\end\{pmatrix\}/g,
|
|
7694
|
-
(i,
|
|
7731
|
+
(i, a) => "[" + a.replace(/\\\\/g, "; ").replace(/&/g, ", ").trim() + "]"
|
|
7695
7732
|
);
|
|
7696
7733
|
const r = { 0: "⁰", 1: "¹", 2: "²", 3: "³", 4: "⁴", 5: "⁵", 6: "⁶", 7: "⁷", 8: "⁸", 9: "⁹", "+": "⁺", "-": "⁻", "=": "⁼", "(": "⁽", ")": "⁾", n: "ⁿ", i: "ⁱ" };
|
|
7697
7734
|
t = t.replace(
|
|
7698
7735
|
/\^\{([^}]*)\}/g,
|
|
7699
|
-
(i,
|
|
7700
|
-
), t = t.replace(/\^([a-zA-Z0-9])/g, (i,
|
|
7701
|
-
const
|
|
7736
|
+
(i, a) => a.split("").map((c) => r[c] || c).join("")
|
|
7737
|
+
), t = t.replace(/\^([a-zA-Z0-9])/g, (i, a) => r[a] || a);
|
|
7738
|
+
const o = { 0: "₀", 1: "₁", 2: "₂", 3: "₃", 4: "₄", 5: "₅", 6: "₆", 7: "₇", 8: "₈", 9: "₉", "+": "₊", "-": "₋", "=": "₌", "(": "₍", ")": "₎", a: "ₐ", e: "ₑ", o: "ₒ", x: "ₓ", i: "ᵢ", j: "ⱼ", n: "ₙ" };
|
|
7702
7739
|
return t = t.replace(
|
|
7703
7740
|
/_\{([^}]*)\}/g,
|
|
7704
|
-
(i,
|
|
7705
|
-
), t = t.replace(/_([a-zA-Z0-9])/g, (i,
|
|
7741
|
+
(i, a) => a.split("").map((c) => o[c] || c).join("")
|
|
7742
|
+
), t = t.replace(/_([a-zA-Z0-9])/g, (i, a) => o[a] || a), t = t.replace(/->/g, "→"), t = t.replace(/<=>/g, "⇌"), t = t.replace(/\\[a-zA-Z]+/g, ""), t = t.replace(/[{}]/g, ""), t = t.replace(/\s+/g, " "), t = t.replace(/\\\\/g, `
|
|
7706
7743
|
`), t.trim();
|
|
7707
7744
|
}
|
|
7708
|
-
const W = "data-mathfield-shadow-styles",
|
|
7745
|
+
const W = "data-mathfield-shadow-styles", mt = `
|
|
7709
7746
|
:host {
|
|
7710
7747
|
touch-action: pan-x pan-y !important;
|
|
7711
7748
|
-webkit-overflow-scrolling: touch !important;
|
|
@@ -8047,25 +8084,25 @@ function $(s, t = null) {
|
|
|
8047
8084
|
const r = l.getBoundingClientRect();
|
|
8048
8085
|
if (r.top === 0 && r.left === 0 && r.width === 0 && r.height === 0)
|
|
8049
8086
|
return;
|
|
8050
|
-
const
|
|
8051
|
-
t && t.isConnected &&
|
|
8087
|
+
const o = [];
|
|
8088
|
+
t && t.isConnected && o.push(t);
|
|
8052
8089
|
let i = s;
|
|
8053
8090
|
for (; i && i !== document.body && i !== document.documentElement; ) {
|
|
8054
|
-
if (!
|
|
8091
|
+
if (!o.includes(i)) {
|
|
8055
8092
|
const d = window.getComputedStyle(i);
|
|
8056
|
-
(d.overflow === "auto" || d.overflow === "scroll" || d.overflowX === "auto" || d.overflowX === "scroll" || d.overflowY === "auto" || d.overflowY === "scroll") &&
|
|
8093
|
+
(d.overflow === "auto" || d.overflow === "scroll" || d.overflowX === "auto" || d.overflowX === "scroll" || d.overflowY === "auto" || d.overflowY === "scroll") && o.push(i);
|
|
8057
8094
|
}
|
|
8058
8095
|
i = i.parentElement;
|
|
8059
8096
|
}
|
|
8060
|
-
|
|
8061
|
-
const
|
|
8062
|
-
for (const d of
|
|
8097
|
+
o.length === 0 && s.parentElement && o.push(s.parentElement);
|
|
8098
|
+
const a = 40, c = 20;
|
|
8099
|
+
for (const d of o) {
|
|
8063
8100
|
const m = d.getBoundingClientRect();
|
|
8064
|
-
if (r.right +
|
|
8065
|
-
const w = r.right +
|
|
8101
|
+
if (r.right + a > m.right) {
|
|
8102
|
+
const w = r.right + a - m.right;
|
|
8066
8103
|
d.scrollLeft += w;
|
|
8067
|
-
} else if (r.left -
|
|
8068
|
-
const w = m.left - (r.left -
|
|
8104
|
+
} else if (r.left - a < m.left) {
|
|
8105
|
+
const w = m.left - (r.left - a);
|
|
8069
8106
|
d.scrollLeft -= w;
|
|
8070
8107
|
}
|
|
8071
8108
|
if (r.bottom + c > m.bottom) {
|
|
@@ -8080,7 +8117,7 @@ function $(s, t = null) {
|
|
|
8080
8117
|
}
|
|
8081
8118
|
});
|
|
8082
8119
|
}
|
|
8083
|
-
function
|
|
8120
|
+
function pt(s) {
|
|
8084
8121
|
if (!s || s._cmeCaretTrackingAttached || s.hasAttribute("read-only") || s.hasAttribute("readonly")) return;
|
|
8085
8122
|
s._cmeCaretTrackingAttached = !0;
|
|
8086
8123
|
const e = () => $(s);
|
|
@@ -8090,22 +8127,22 @@ function V(s) {
|
|
|
8090
8127
|
const t = s == null ? void 0 : s.shadowRoot;
|
|
8091
8128
|
if (!t) return;
|
|
8092
8129
|
const e = s.hasAttribute("read-only") || s.hasAttribute("readonly"), l = e ? "readonly" : "editable";
|
|
8093
|
-
e ||
|
|
8130
|
+
e || pt(s);
|
|
8094
8131
|
let r = t.querySelector(`[${W}]`);
|
|
8095
8132
|
r && r.getAttribute("data-cache") === l || (r || (r = document.createElement("style"), r.setAttribute(W, "true"), t.appendChild(r)), r.setAttribute("data-cache", l), r.textContent = `
|
|
8096
8133
|
${e ? `
|
|
8097
8134
|
:host, :host * { cursor: pointer !important; }
|
|
8098
8135
|
.ML__latex, .ML__content, .ML__container, .ML__virtual-keyboard-toggle { cursor: pointer !important; }
|
|
8099
8136
|
` : ""}
|
|
8100
|
-
${
|
|
8137
|
+
${mt}
|
|
8101
8138
|
`);
|
|
8102
8139
|
}
|
|
8103
|
-
function
|
|
8140
|
+
function gt() {
|
|
8104
8141
|
document.querySelectorAll("math-field").forEach(V);
|
|
8105
8142
|
}
|
|
8106
8143
|
let F = null;
|
|
8107
8144
|
function bt() {
|
|
8108
|
-
F || (
|
|
8145
|
+
F || (gt(), F = new MutationObserver((s) => {
|
|
8109
8146
|
var t, e, l;
|
|
8110
8147
|
for (const r of s) {
|
|
8111
8148
|
if (r.type === "attributes" && ((t = r.target.tagName) == null ? void 0 : t.toLowerCase()) === "math-field") {
|
|
@@ -8113,8 +8150,8 @@ function bt() {
|
|
|
8113
8150
|
continue;
|
|
8114
8151
|
}
|
|
8115
8152
|
if (r.addedNodes)
|
|
8116
|
-
for (const
|
|
8117
|
-
|
|
8153
|
+
for (const o of r.addedNodes)
|
|
8154
|
+
o instanceof Element && (((e = o.tagName) == null ? void 0 : e.toLowerCase()) === "math-field" && requestAnimationFrame(() => V(o)), (l = o.querySelectorAll) == null || l.call(o, "math-field").forEach(
|
|
8118
8155
|
(i) => requestAnimationFrame(() => V(i))
|
|
8119
8156
|
));
|
|
8120
8157
|
}
|
|
@@ -8134,7 +8171,7 @@ const tt = [
|
|
|
8134
8171
|
{ id: "Number", name: "Number", ranges: [[48, 57], [8304, 8351], [8528, 8591], [9312, 9471], [10102, 10131], [65296, 65305], [120782, 120831]] },
|
|
8135
8172
|
{ id: "Phonetic", name: "Phonetic", ranges: [[592, 687], [688, 767], [7424, 7551], [7552, 7615], [43824, 43887]] },
|
|
8136
8173
|
{ id: "Other", name: "Other", ranges: [[8352, 8399], [8448, 8527], [8960, 9215], [9472, 9599], [9600, 9631], [9632, 9727], [10240, 10495], [11008, 11263]] }
|
|
8137
|
-
],
|
|
8174
|
+
], wt = () => {
|
|
8138
8175
|
const s = [];
|
|
8139
8176
|
return tt.slice(1).forEach((t) => {
|
|
8140
8177
|
t.ranges.forEach((e) => {
|
|
@@ -8149,8 +8186,8 @@ const tt = [
|
|
|
8149
8186
|
}
|
|
8150
8187
|
});
|
|
8151
8188
|
}), s;
|
|
8152
|
-
},
|
|
8153
|
-
class
|
|
8189
|
+
}, kt = wt();
|
|
8190
|
+
class ut {
|
|
8154
8191
|
constructor(t = {}) {
|
|
8155
8192
|
this.onInsert = t.onInsert || (() => {
|
|
8156
8193
|
}), this.onClose = t.onClose || (() => {
|
|
@@ -8166,7 +8203,7 @@ class kt {
|
|
|
8166
8203
|
t.key === "Escape" && this.close();
|
|
8167
8204
|
}
|
|
8168
8205
|
getFilteredCharacters() {
|
|
8169
|
-
let t =
|
|
8206
|
+
let t = kt;
|
|
8170
8207
|
if (this.selectedCategory !== "All" && (t = t.filter((e) => e.category === this.selectedCategory)), this.searchCode.trim()) {
|
|
8171
8208
|
const e = this.searchCode.trim().toUpperCase();
|
|
8172
8209
|
t = t.filter((l) => l.code.includes(e));
|
|
@@ -8185,8 +8222,8 @@ class kt {
|
|
|
8185
8222
|
if (this.overlay && this.overlay.parentNode && this.overlay.parentNode.removeChild(this.overlay), this.overlay = document.createElement("div"), this.overlay.className = "scm-overlay", this.overlay.addEventListener("mousedown", (i) => {
|
|
8186
8223
|
i.stopPropagation(), this.close();
|
|
8187
8224
|
}), this.modal = document.createElement("div"), this.modal.className = "scm-modal", this.modal.addEventListener("mousedown", (i) => i.stopPropagation()), t) {
|
|
8188
|
-
let i = t.x - 120,
|
|
8189
|
-
i < 10 && (i = 10), i + 230 > window.innerWidth && (i = window.innerWidth - 240),
|
|
8225
|
+
let i = t.x - 120, a = t.y;
|
|
8226
|
+
i < 10 && (i = 10), i + 230 > window.innerWidth && (i = window.innerWidth - 240), a + 200 > window.innerHeight && (a = window.innerHeight - 210), this.modal.style.top = `${a}px`, this.modal.style.left = `${i}px`, this.modal.style.transform = "none";
|
|
8190
8227
|
} else
|
|
8191
8228
|
this.modal.style.top = "50%", this.modal.style.left = "50%", this.modal.style.transform = "translate(-50%, -50%)";
|
|
8192
8229
|
const e = document.createElement("div");
|
|
@@ -8197,13 +8234,13 @@ class kt {
|
|
|
8197
8234
|
});
|
|
8198
8235
|
const r = document.createElement("select");
|
|
8199
8236
|
r.className = "scm-category-select", tt.forEach((i) => {
|
|
8200
|
-
const
|
|
8201
|
-
|
|
8237
|
+
const a = document.createElement("option");
|
|
8238
|
+
a.value = i.id, a.textContent = i.name, r.appendChild(a);
|
|
8202
8239
|
}), r.value = this.selectedCategory, r.addEventListener("change", (i) => {
|
|
8203
8240
|
this.selectedCategory = i.target.value, this.updateGrid();
|
|
8204
8241
|
}), e.appendChild(l), e.appendChild(r), this.modal.appendChild(e);
|
|
8205
|
-
const
|
|
8206
|
-
|
|
8242
|
+
const o = document.createElement("div");
|
|
8243
|
+
o.className = "scm-body", this.bodyContainer = document.createElement("div"), this.bodyContainer.className = "scm-grid-container", o.appendChild(this.bodyContainer), this.modal.appendChild(o), this.updateGrid(), this.overlay.appendChild(this.modal), document.body.appendChild(this.overlay), setTimeout(() => l.focus(), 50);
|
|
8207
8244
|
}
|
|
8208
8245
|
updateGrid() {
|
|
8209
8246
|
if (!this.bodyContainer) return;
|
|
@@ -8214,24 +8251,24 @@ class kt {
|
|
|
8214
8251
|
r.className = "scm-no-results", r.textContent = "No characters found.", this.bodyContainer.appendChild(r);
|
|
8215
8252
|
return;
|
|
8216
8253
|
}
|
|
8217
|
-
l.forEach(([r,
|
|
8254
|
+
l.forEach(([r, o]) => {
|
|
8218
8255
|
const i = document.createElement("div");
|
|
8219
8256
|
i.className = "scm-category-group";
|
|
8220
|
-
const
|
|
8221
|
-
|
|
8257
|
+
const a = document.createElement("div");
|
|
8258
|
+
a.className = "scm-char-grid", o.forEach((c) => {
|
|
8222
8259
|
const d = document.createElement("button");
|
|
8223
8260
|
d.type = "button", d.className = "scm-char-btn", d.title = `U+${c.code}`, d.textContent = c.char, d.addEventListener("click", (m) => {
|
|
8224
8261
|
m.preventDefault(), this.onInsert(c.char), this.close();
|
|
8225
|
-
}),
|
|
8226
|
-
}), i.appendChild(
|
|
8262
|
+
}), a.appendChild(d);
|
|
8263
|
+
}), i.appendChild(a), this.bodyContainer.appendChild(i);
|
|
8227
8264
|
});
|
|
8228
8265
|
}
|
|
8229
8266
|
destroy() {
|
|
8230
8267
|
this.close();
|
|
8231
8268
|
}
|
|
8232
8269
|
}
|
|
8233
|
-
const
|
|
8234
|
-
version:
|
|
8270
|
+
const xt = "1.0.36", H = {
|
|
8271
|
+
version: xt
|
|
8235
8272
|
};
|
|
8236
8273
|
typeof window < "u" && (window.MathfieldElement ? window.MathfieldElement.fontsDirectory = "https://cdn.jsdelivr.net/npm/mathlive/dist/fonts" : j && (j.fontsDirectory = "https://cdn.jsdelivr.net/npm/mathlive/dist/fonts"));
|
|
8237
8274
|
const q = class q {
|
|
@@ -8313,7 +8350,7 @@ const q = class q {
|
|
|
8313
8350
|
}
|
|
8314
8351
|
handleInsert() {
|
|
8315
8352
|
let t = this.getValue();
|
|
8316
|
-
t = ot(t), t = at(t), t = ct(t), this.mode === "chem" && (t = t.replace(/\\enspace(?:\s|{})?/g, "~"), t.includes("\\displaylines") || t.includes("\\\\") || t.includes("\\class{cme-") || t.includes("\\xleftrightarrows") || t.includes("\\xleftrightharpoons") || t.includes("\\enclose") || t.includes("\\{") || t.includes("\\}") || t.includes("\\lbrace") || t.includes("\\rbrace") ? /^\\ce\{[\s\S]*\}$/i.test(t.trim()) && (t = t.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")) : t.trim() && !t.trim().startsWith("\\ce{") && !t.includes("\\ce{") && (t = `\\ce{${t}}`), t = P(t)), this.onInsert(t), this.close();
|
|
8353
|
+
t = ot(t), t = at(t), t = ct(t), this.mode === "chem" && (t = t.replace(/\\enspace(?:\s|{})?/g, "~"), t.includes("\\displaylines") || t.includes("\\\\") || t.includes("\\class{cme-") || t.includes("\\xleftrightarrows") || t.includes("\\xleftrightharpoons") || t.includes("\\xrightarrow") || t.includes("\\xrightleftharpoons") || t.includes("\\xleftarrow") || t.includes("\\xleftrightarrow") || t.includes("\\xtofrom") || t.includes("\\enclose") || t.includes("\\{") || t.includes("\\}") || t.includes("\\lbrace") || t.includes("\\rbrace") ? /^\\ce\{[\s\S]*\}$/i.test(t.trim()) && (t = t.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")) : t.trim() && !t.trim().startsWith("\\ce{") && !t.includes("\\ce{") && (t = `\\ce{${t}}`), t = P(t)), this.onInsert(t), this.close();
|
|
8317
8354
|
}
|
|
8318
8355
|
insertAtCursor(t) {
|
|
8319
8356
|
if (this.closeAllPopups(), !this.mathField) return;
|
|
@@ -8356,11 +8393,11 @@ const q = class q {
|
|
|
8356
8393
|
if (l) {
|
|
8357
8394
|
const r = l.ranges || (Array.isArray(l) ? [l] : []);
|
|
8358
8395
|
if (r.length > 0) {
|
|
8359
|
-
let
|
|
8396
|
+
let o = 1 / 0, i = -1 / 0;
|
|
8360
8397
|
for (const c of r)
|
|
8361
|
-
Array.isArray(c) && (
|
|
8362
|
-
const
|
|
8363
|
-
if (
|
|
8398
|
+
Array.isArray(c) && (o = Math.min(o, c[0], c[1]), i = Math.max(i, c[0], c[1]));
|
|
8399
|
+
const a = (e == null ? void 0 : e.lastOffset) || 1;
|
|
8400
|
+
if (o <= 1 && i >= a)
|
|
8364
8401
|
return !0;
|
|
8365
8402
|
}
|
|
8366
8403
|
}
|
|
@@ -8416,8 +8453,8 @@ const q = class q {
|
|
|
8416
8453
|
const l = e.selection || t.selection, r = e.getAtoms(l, { includeChildren: !0 });
|
|
8417
8454
|
if (r && r.length > 0 && r.some((i) => {
|
|
8418
8455
|
if (!i || i.type === "first") return !1;
|
|
8419
|
-
const
|
|
8420
|
-
return
|
|
8456
|
+
const a = i.style;
|
|
8457
|
+
return a ? a.variantStyle === "bold" || a.variantStyle === "bolditalic" || a.fontSeries === "b" || a.variant === "bold" : !1;
|
|
8421
8458
|
}))
|
|
8422
8459
|
return !0;
|
|
8423
8460
|
}
|
|
@@ -8448,8 +8485,8 @@ const q = class q {
|
|
|
8448
8485
|
const l = e.selection || t.selection, r = e.getAtoms(l, { includeChildren: !0 });
|
|
8449
8486
|
if (r && r.length > 0 && r.some((i) => {
|
|
8450
8487
|
if (!i || i.type === "first") return !1;
|
|
8451
|
-
const
|
|
8452
|
-
return
|
|
8488
|
+
const a = i.style;
|
|
8489
|
+
return a ? a.variantStyle === "italic" || a.variantStyle === "bolditalic" || a.fontShape === "it" : !1;
|
|
8453
8490
|
}))
|
|
8454
8491
|
return !0;
|
|
8455
8492
|
}
|
|
@@ -8472,10 +8509,10 @@ const q = class q {
|
|
|
8472
8509
|
}
|
|
8473
8510
|
}
|
|
8474
8511
|
render() {
|
|
8475
|
-
this.popup = document.createElement("div"), this.popup.className = "cme-editor-popup" + (this.isMaximized ? " maximized" : "") + (this.isMinimized ? " minimized" : ""), this.popup.addEventListener("mousedown", (
|
|
8476
|
-
this.handleDocumentClick(
|
|
8477
|
-
}), this.popup.addEventListener("pointerdown", (
|
|
8478
|
-
this.handleDocumentClick(
|
|
8512
|
+
this.popup = document.createElement("div"), this.popup.className = "cme-editor-popup" + (this.isMaximized ? " maximized" : "") + (this.isMinimized ? " minimized" : ""), this.popup.addEventListener("mousedown", (n) => {
|
|
8513
|
+
this.handleDocumentClick(n), n.stopPropagation();
|
|
8514
|
+
}), this.popup.addEventListener("pointerdown", (n) => {
|
|
8515
|
+
this.handleDocumentClick(n);
|
|
8479
8516
|
});
|
|
8480
8517
|
const t = document.createElement("div");
|
|
8481
8518
|
t.className = "cme-popup-topbar";
|
|
@@ -8483,56 +8520,56 @@ const q = class q {
|
|
|
8483
8520
|
e.className = "cme-popup-header", e.style.cursor = "grab";
|
|
8484
8521
|
const l = this.title || (this.isEditing ? this.mode === "chem" ? "Edit Chemistry Formula" : "Edit Math Formula" : this.mode === "chem" ? "Chemistry Editor" : "Math Editor");
|
|
8485
8522
|
e.innerHTML = `<span>${l}</span>`;
|
|
8486
|
-
const r = (
|
|
8487
|
-
|
|
8488
|
-
x:
|
|
8523
|
+
const r = (n, p, b) => {
|
|
8524
|
+
b && b.closest && b.closest(".cme-popup-btn") || (this.closeAllPopups(), this.specCharModal && this.specCharModal.close(), this.isDragging = !0, this.dragStart = {
|
|
8525
|
+
x: n - this.position.x,
|
|
8489
8526
|
y: p - this.position.y
|
|
8490
8527
|
}, e.style.cursor = "grabbing");
|
|
8491
8528
|
};
|
|
8492
|
-
e.addEventListener("mousedown", (
|
|
8493
|
-
r(
|
|
8529
|
+
e.addEventListener("mousedown", (n) => {
|
|
8530
|
+
r(n.clientX, n.clientY, n.target);
|
|
8494
8531
|
}), e.addEventListener(
|
|
8495
8532
|
"touchstart",
|
|
8496
|
-
(
|
|
8497
|
-
|
|
8533
|
+
(n) => {
|
|
8534
|
+
n.touches && n.touches.length > 0 && r(n.touches[0].clientX, n.touches[0].clientY, n.target);
|
|
8498
8535
|
},
|
|
8499
8536
|
{ passive: !0 }
|
|
8500
8537
|
);
|
|
8501
|
-
const
|
|
8502
|
-
|
|
8538
|
+
const o = document.createElement("div");
|
|
8539
|
+
o.className = "cme-popup-controls";
|
|
8503
8540
|
const i = document.createElement("button");
|
|
8504
8541
|
i.type = "button", i.className = "cme-popup-btn", i.textContent = "—", i.title = "Minimize", i.addEventListener("click", () => this.toggleMinimize());
|
|
8505
|
-
const
|
|
8506
|
-
|
|
8542
|
+
const a = document.createElement("button");
|
|
8543
|
+
a.type = "button", a.className = "cme-popup-btn", a.textContent = "⤢", a.title = "Maximize", a.addEventListener("click", () => this.toggleMaximize()), this.minBtn = i, this.maxBtn = a;
|
|
8507
8544
|
const c = document.createElement("button");
|
|
8508
|
-
c.type = "button", c.className = "cme-popup-btn", c.textContent = "✕", c.title = "Close", c.addEventListener("click", () => this.close()),
|
|
8545
|
+
c.type = "button", c.className = "cme-popup-btn", c.textContent = "✕", c.title = "Close", c.addEventListener("click", () => this.close()), o.appendChild(i), o.appendChild(a), o.appendChild(c), t.appendChild(e), t.appendChild(o), this.popup.appendChild(t);
|
|
8509
8546
|
const d = document.createElement("div");
|
|
8510
8547
|
d.className = "cme-toolbar", d.setAttribute("role", "toolbar"), d.setAttribute("aria-label", "Symbol palette"), this.tabsWrapper = document.createElement("div"), this.tabsWrapper.className = "cme-toolbar-groups", this.renderTabs(), d.appendChild(this.tabsWrapper), this.itemsWrapper = document.createElement("div"), this.itemsWrapper.className = "cme-toolbar-items", this.renderToolbarItems(), d.appendChild(this.itemsWrapper), this.popup.appendChild(d);
|
|
8511
8548
|
const m = document.createElement("div");
|
|
8512
|
-
m.className = "cme-mathfield-container", this.mathFieldContainer = m, m.addEventListener("mousedown", (
|
|
8513
|
-
var p,
|
|
8514
|
-
this.explicitToggle = !1, this.closeAllPopups(), !(this.mathField && (
|
|
8549
|
+
m.className = "cme-mathfield-container", this.mathFieldContainer = m, m.addEventListener("mousedown", (n) => {
|
|
8550
|
+
var p, b;
|
|
8551
|
+
this.explicitToggle = !1, this.closeAllPopups(), !(this.mathField && (n.target === this.mathField || this.mathField.contains(n.target))) && (n.preventDefault(), (b = (p = this.mathField) == null ? void 0 : p.focus) == null || b.call(p));
|
|
8515
8552
|
});
|
|
8516
|
-
let w = !1,
|
|
8553
|
+
let w = !1, C = 0, T = 0, u = 0, y = 0, h = 0, v = 0, f = 0, k = 0, E = 0, g = null;
|
|
8517
8554
|
const B = () => {
|
|
8518
|
-
|
|
8555
|
+
g && (cancelAnimationFrame(g), g = null);
|
|
8519
8556
|
};
|
|
8520
8557
|
m.addEventListener(
|
|
8521
8558
|
"touchstart",
|
|
8522
|
-
(
|
|
8523
|
-
if (B(), !
|
|
8524
|
-
const p =
|
|
8525
|
-
|
|
8559
|
+
(n) => {
|
|
8560
|
+
if (B(), !n.touches || n.touches.length !== 1) return;
|
|
8561
|
+
const p = n.touches[0];
|
|
8562
|
+
C = p.clientX, T = p.clientY, h = p.clientX, v = p.clientY, f = Date.now(), u = m.scrollLeft, y = m.scrollTop, k = 0, E = 0, w = !1;
|
|
8526
8563
|
},
|
|
8527
8564
|
{ passive: !0 }
|
|
8528
8565
|
), m.addEventListener(
|
|
8529
8566
|
"touchmove",
|
|
8530
|
-
(
|
|
8531
|
-
if (!
|
|
8532
|
-
const p =
|
|
8533
|
-
if (!w && (Math.abs(
|
|
8567
|
+
(n) => {
|
|
8568
|
+
if (!n.touches || n.touches.length !== 1) return;
|
|
8569
|
+
const p = n.touches[0], b = p.clientX - C, x = p.clientY - T;
|
|
8570
|
+
if (!w && (Math.abs(b) > 4 || Math.abs(x) > 4) && (w = !0), w) {
|
|
8534
8571
|
const I = Date.now(), O = Math.max(I - f, 1);
|
|
8535
|
-
k = (p.clientX - h) / O * 16, E = (p.clientY - v) / O * 16, h = p.clientX, v = p.clientY, f = I, m.scrollLeft = u -
|
|
8572
|
+
k = (p.clientX - h) / O * 16, E = (p.clientY - v) / O * 16, h = p.clientX, v = p.clientY, f = I, m.scrollLeft = u - b, m.scrollTop = y - x;
|
|
8536
8573
|
}
|
|
8537
8574
|
},
|
|
8538
8575
|
{ passive: !0 }
|
|
@@ -8541,15 +8578,15 @@ const q = class q {
|
|
|
8541
8578
|
() => {
|
|
8542
8579
|
if (!w) return;
|
|
8543
8580
|
w = !1;
|
|
8544
|
-
let
|
|
8545
|
-
const
|
|
8546
|
-
if (Math.abs(
|
|
8547
|
-
|
|
8581
|
+
let n = k, p = E;
|
|
8582
|
+
const b = () => {
|
|
8583
|
+
if (Math.abs(n) < 0.2 && Math.abs(p) < 0.2) {
|
|
8584
|
+
g = null;
|
|
8548
8585
|
return;
|
|
8549
8586
|
}
|
|
8550
|
-
m.scrollLeft -=
|
|
8587
|
+
m.scrollLeft -= n, m.scrollTop -= p, n *= 0.92, p *= 0.92, g = requestAnimationFrame(b);
|
|
8551
8588
|
};
|
|
8552
|
-
B(), (Math.abs(
|
|
8589
|
+
B(), (Math.abs(n) > 0.5 || Math.abs(p) > 0.5) && (g = requestAnimationFrame(b));
|
|
8553
8590
|
},
|
|
8554
8591
|
{ passive: !0 }
|
|
8555
8592
|
), m.addEventListener(
|
|
@@ -8559,22 +8596,22 @@ const q = class q {
|
|
|
8559
8596
|
},
|
|
8560
8597
|
{ passive: !0 }
|
|
8561
8598
|
), this.mathField = document.createElement("math-field"), this.mathField.className = "cme-mathfield", this.mathField.setAttribute("tabindex", "0"), this.mathField.setAttribute("math-virtual-keyboard-policy", "manual"), this.mathField.setAttribute("smart-superscript", "false"), this.mathField.smartSuperscript = !1, this.mathField.setAttribute("math-mode-space", "\\enspace"), this.mathField.mathModeSpace = "\\enspace", this.mathField.onInsertStyle = () => this.getInsertStyle();
|
|
8562
|
-
const A = (
|
|
8599
|
+
const A = (n) => {
|
|
8563
8600
|
const p = Date.now();
|
|
8564
8601
|
if (this._lastEnterTimestamp && p - this._lastEnterTimestamp < 120) {
|
|
8565
|
-
|
|
8602
|
+
n && typeof n.preventDefault == "function" && (n.preventDefault(), n.stopPropagation(), typeof n.stopImmediatePropagation == "function" && n.stopImmediatePropagation());
|
|
8566
8603
|
return;
|
|
8567
8604
|
}
|
|
8568
|
-
this._lastEnterTimestamp = p,
|
|
8569
|
-
const
|
|
8570
|
-
|
|
8571
|
-
},
|
|
8572
|
-
var
|
|
8605
|
+
this._lastEnterTimestamp = p, n && typeof n.preventDefault == "function" && (n.preventDefault(), n.stopPropagation(), typeof n.stopImmediatePropagation == "function" && n.stopImmediatePropagation()), this.activeStyles.bold || this.activeStyles.italic || this.activeStyles.fontFamily && this.activeStyles.fontFamily !== "none" ? this.explicitToggle = !0 : this.explicitToggle = !1;
|
|
8606
|
+
const b = this.mathField;
|
|
8607
|
+
b != null && b.executeCommand && b.executeCommand("addRowAfter"), this.scrollToCaret();
|
|
8608
|
+
}, S = () => {
|
|
8609
|
+
var n;
|
|
8573
8610
|
try {
|
|
8574
|
-
const p = (
|
|
8611
|
+
const p = (n = this.mathField) == null ? void 0 : n.shadowRoot;
|
|
8575
8612
|
if (!p) return;
|
|
8576
|
-
const
|
|
8577
|
-
|
|
8613
|
+
const b = p.querySelector(".ML__keyboard-sink") || p.querySelector("[contenteditable]");
|
|
8614
|
+
b && !b._cmeEnterAttached && (b._cmeEnterAttached = !0, b.addEventListener(
|
|
8578
8615
|
"beforeinput",
|
|
8579
8616
|
(x) => {
|
|
8580
8617
|
const I = x.inputType || "", O = x.data;
|
|
@@ -8585,7 +8622,7 @@ const q = class q {
|
|
|
8585
8622
|
`) && A(x);
|
|
8586
8623
|
},
|
|
8587
8624
|
{ capture: !0 }
|
|
8588
|
-
),
|
|
8625
|
+
), b.addEventListener(
|
|
8589
8626
|
"keydown",
|
|
8590
8627
|
(x) => {
|
|
8591
8628
|
(x.key === "Enter" || x.key === "Return" || x.code === "Enter" || x.code === "NumpadEnter" || x.keyCode === 13 || x.which === 13) && !x.ctrlKey && !x.metaKey && !x.altKey && A(x);
|
|
@@ -8595,45 +8632,45 @@ const q = class q {
|
|
|
8595
8632
|
} catch {
|
|
8596
8633
|
}
|
|
8597
8634
|
};
|
|
8598
|
-
this.mathField.addEventListener("keydown", (
|
|
8599
|
-
if ((
|
|
8600
|
-
A(
|
|
8635
|
+
this.mathField.addEventListener("keydown", (n) => {
|
|
8636
|
+
if ((n.key === "Enter" || n.key === "Return" || n.code === "Enter" || n.code === "NumpadEnter" || n.keyCode === 13 || n.which === 13) && !n.ctrlKey && !n.metaKey && !n.altKey) {
|
|
8637
|
+
A(n);
|
|
8601
8638
|
return;
|
|
8602
8639
|
}
|
|
8603
|
-
if (
|
|
8604
|
-
|
|
8640
|
+
if (n.key === " " || n.code === "Space") {
|
|
8641
|
+
n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation();
|
|
8605
8642
|
const I = this.mathField;
|
|
8606
8643
|
I.executeCommand ? I.executeCommand(["insert", "\\enspace ", { selectionMode: "after" }]) : I.insert && I.insert("\\enspace "), this.scrollToCaret();
|
|
8607
8644
|
return;
|
|
8608
8645
|
}
|
|
8609
|
-
if (
|
|
8646
|
+
if (n.key === "ArrowLeft" || n.key === "ArrowRight" || n.key === "ArrowUp" || n.key === "ArrowDown" || n.key === "Home" || n.key === "End") {
|
|
8610
8647
|
this.explicitToggle = !1, this.scrollToCaret();
|
|
8611
8648
|
return;
|
|
8612
8649
|
}
|
|
8613
|
-
if (!this.activeStyles.bold && !this.activeStyles.italic && this.activeStyles.fontFamily === "none" ||
|
|
8614
|
-
|
|
8615
|
-
const
|
|
8616
|
-
|
|
8650
|
+
if (!this.activeStyles.bold && !this.activeStyles.italic && this.activeStyles.fontFamily === "none" || n.key.length !== 1 || n.ctrlKey || n.metaKey || n.altKey) return;
|
|
8651
|
+
n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation();
|
|
8652
|
+
const b = U(
|
|
8653
|
+
n.key,
|
|
8617
8654
|
this.activeStyles.bold,
|
|
8618
8655
|
this.activeStyles.italic,
|
|
8619
8656
|
this.activeStyles.fontFamily
|
|
8620
8657
|
), x = this.mathField;
|
|
8621
|
-
x.executeCommand ? x.executeCommand(["insert",
|
|
8658
|
+
x.executeCommand ? x.executeCommand(["insert", b, { selectionMode: "after" }]) : x.insert && x.insert(b), this.scrollToCaret();
|
|
8622
8659
|
}, { capture: !0 }), this.mathField.addEventListener(
|
|
8623
8660
|
"beforeinput",
|
|
8624
|
-
(
|
|
8625
|
-
const p =
|
|
8626
|
-
(p === "insertParagraph" || p === "insertLineBreak" || p === "insertText" && (
|
|
8627
|
-
` ||
|
|
8628
|
-
`) ||
|
|
8629
|
-
` ||
|
|
8630
|
-
`) && A(
|
|
8661
|
+
(n) => {
|
|
8662
|
+
const p = n.inputType || "", b = n.data;
|
|
8663
|
+
(p === "insertParagraph" || p === "insertLineBreak" || p === "insertText" && (b === `
|
|
8664
|
+
` || b === "\r" || b === `\r
|
|
8665
|
+
`) || b === `
|
|
8666
|
+
` || b === "\r" || b === `\r
|
|
8667
|
+
`) && A(n);
|
|
8631
8668
|
},
|
|
8632
8669
|
{ capture: !0 }
|
|
8633
8670
|
), this.mathField.addEventListener(
|
|
8634
8671
|
"keypress",
|
|
8635
|
-
(
|
|
8636
|
-
(
|
|
8672
|
+
(n) => {
|
|
8673
|
+
(n.key === "Enter" || n.key === "Return" || n.keyCode === 13 || n.which === 13 || n.charCode === 13) && !n.ctrlKey && !n.metaKey && !n.altKey && A(n);
|
|
8637
8674
|
},
|
|
8638
8675
|
{ capture: !0 }
|
|
8639
8676
|
);
|
|
@@ -8643,7 +8680,7 @@ const q = class q {
|
|
|
8643
8680
|
this.mathField.addEventListener("input", () => this.scrollToCaret()), this.mathField.addEventListener("selection-change", L), this.mathField.addEventListener("pointerup", L), this.mathField.addEventListener("keyup", L), this.mathField.addEventListener("pointerdown", () => {
|
|
8644
8681
|
this.explicitToggle = !1, this.closeAllPopups();
|
|
8645
8682
|
}), this.mathField.addEventListener("focus", () => {
|
|
8646
|
-
this.closeAllPopups(),
|
|
8683
|
+
this.closeAllPopups(), S(), this.scrollToCaret();
|
|
8647
8684
|
}), m.appendChild(this.mathField), this.popup.appendChild(m);
|
|
8648
8685
|
const D = document.createElement("div");
|
|
8649
8686
|
D.className = "cme-popup-footer";
|
|
@@ -8653,12 +8690,12 @@ const q = class q {
|
|
|
8653
8690
|
N.type = "button", N.className = "cme-cancel-btn", N.textContent = "Cancel", N.addEventListener("click", () => this.close()), D.appendChild(M), D.appendChild(N);
|
|
8654
8691
|
const R = `v${H.version}`;
|
|
8655
8692
|
if (R) {
|
|
8656
|
-
const
|
|
8657
|
-
|
|
8693
|
+
const n = document.createElement("span");
|
|
8694
|
+
n.className = "cme-popup-version", n.textContent = R, n.title = `Version ${H.version}`, D.appendChild(n);
|
|
8658
8695
|
}
|
|
8659
8696
|
this.popup.appendChild(D), document.body.appendChild(this.popup), setTimeout(() => {
|
|
8660
8697
|
if (this.mathField) {
|
|
8661
|
-
bt(),
|
|
8698
|
+
bt(), S();
|
|
8662
8699
|
try {
|
|
8663
8700
|
this.mathField.smartSuperscript = !1, this.mathField.inlineShortcuts = Object.assign(
|
|
8664
8701
|
{},
|
|
@@ -8682,22 +8719,22 @@ const q = class q {
|
|
|
8682
8719
|
...Y
|
|
8683
8720
|
}
|
|
8684
8721
|
}), this.mathField.menuItems && Array.isArray(this.mathField.menuItems) && (this.mathField.menuItems = this.mathField.menuItems.filter(
|
|
8685
|
-
(
|
|
8722
|
+
(b) => b && b.id !== "insert-matrix" && b.submenuClass !== "insert-matrix-submenu"
|
|
8686
8723
|
));
|
|
8687
8724
|
} catch {
|
|
8688
8725
|
}
|
|
8689
|
-
let
|
|
8690
|
-
this.mode === "chem" &&
|
|
8726
|
+
let n = this.initialLatex || "";
|
|
8727
|
+
this.mode === "chem" && n.startsWith("\\ce{") && n.endsWith("}") && (n = n.slice(4, -1)), this.mode === "chem" && (n = n.replace(/~/g, "\\enspace ")), this.setValue(n), this.mathField.focus(), this.scrollToCaret();
|
|
8691
8728
|
}
|
|
8692
8729
|
}, 50);
|
|
8693
8730
|
}
|
|
8694
8731
|
clampPosition(t = this.position.x, e = this.position.y) {
|
|
8695
8732
|
if (!this.popup) return { x: t, y: e };
|
|
8696
|
-
const l = this.popup.getBoundingClientRect(), r = l.left - this.position.x,
|
|
8697
|
-
let m = -r, w = c - r - i,
|
|
8698
|
-
m > w ?
|
|
8699
|
-
let T = -
|
|
8700
|
-
return T > u ? y = T : y = Math.max(T, Math.min(e, u)), { x:
|
|
8733
|
+
const l = this.popup.getBoundingClientRect(), r = l.left - this.position.x, o = l.top - this.position.y, i = l.width, a = l.height, c = window.innerWidth, d = window.innerHeight;
|
|
8734
|
+
let m = -r, w = c - r - i, C = t;
|
|
8735
|
+
m > w ? C = m : C = Math.max(m, Math.min(t, w));
|
|
8736
|
+
let T = -o, u = d - o - a, y = e;
|
|
8737
|
+
return T > u ? y = T : y = Math.max(T, Math.min(e, u)), { x: C, y };
|
|
8701
8738
|
}
|
|
8702
8739
|
handleMouseMove(t) {
|
|
8703
8740
|
if (!this.isDragging || !this.popup) return;
|
|
@@ -8733,20 +8770,20 @@ const q = class q {
|
|
|
8733
8770
|
renderTabs() {
|
|
8734
8771
|
if (!this.tabsWrapper) return;
|
|
8735
8772
|
this.tabsWrapper.innerHTML = "", this.getGroups().forEach((e, l) => {
|
|
8736
|
-
const r = this.activeGroup === l,
|
|
8737
|
-
if (
|
|
8773
|
+
const r = this.activeGroup === l, o = document.createElement("button");
|
|
8774
|
+
if (o.type = "button", o.className = "cme-group-tab" + (r ? " active" : ""), e.mathLabel) {
|
|
8738
8775
|
const i = document.createElement("math-field");
|
|
8739
|
-
i.setAttribute("read-only", "true"), i.setAttribute("tabindex", "-1"), i.style.pointerEvents = "none", i.style.background = "transparent", i.style.border = "none", i.style.outline = "none", i.style.fontSize = e.fontSize || (e.isMatrix ? "8px" : "11px"), i.style.display = "inline-block", i.style.width = "auto", i.style.padding = "0", i.style.margin = "0", i.style.boxShadow = "none", i.style.color = r ? "#333333" : "#ffffff", i.textContent = e.mathLabel,
|
|
8740
|
-
} else typeof e.label == "string" && e.label.includes("<svg") ?
|
|
8741
|
-
|
|
8776
|
+
i.setAttribute("read-only", "true"), i.setAttribute("tabindex", "-1"), i.style.pointerEvents = "none", i.style.background = "transparent", i.style.border = "none", i.style.outline = "none", i.style.fontSize = e.fontSize || (e.isMatrix ? "8px" : "11px"), i.style.display = "inline-block", i.style.width = "auto", i.style.padding = "0", i.style.margin = "0", i.style.boxShadow = "none", i.style.color = r ? "#333333" : "#ffffff", i.textContent = e.mathLabel, o.appendChild(i);
|
|
8777
|
+
} else typeof e.label == "string" && e.label.includes("<svg") ? o.innerHTML = e.label : o.textContent = e.label;
|
|
8778
|
+
o.addEventListener("mousedown", (i) => {
|
|
8742
8779
|
i.preventDefault(), this.activeGroup = l, this.closeAllPopups(), this.renderTabs(), this.renderToolbarItems();
|
|
8743
|
-
}), this.tabsWrapper.appendChild(
|
|
8780
|
+
}), this.tabsWrapper.appendChild(o);
|
|
8744
8781
|
});
|
|
8745
8782
|
}
|
|
8746
8783
|
renderToolbarItems() {
|
|
8747
8784
|
if (!this.itemsWrapper) return;
|
|
8748
8785
|
this.itemsWrapper.innerHTML = "";
|
|
8749
|
-
const e = this.getGroups()[this.activeGroup] || { items: [] }, l = e.items || [], r = l.some((i) => i.type === "sep"),
|
|
8786
|
+
const e = this.getGroups()[this.activeGroup] || { items: [] }, l = e.items || [], r = l.some((i) => i.type === "sep"), o = [];
|
|
8750
8787
|
if (r) {
|
|
8751
8788
|
let i = {
|
|
8752
8789
|
cols: 2,
|
|
@@ -8756,27 +8793,27 @@ const q = class q {
|
|
|
8756
8793
|
moreItems: null,
|
|
8757
8794
|
moreCols: 1
|
|
8758
8795
|
};
|
|
8759
|
-
for (const
|
|
8760
|
-
|
|
8761
|
-
cols:
|
|
8762
|
-
small: !!
|
|
8763
|
-
cls:
|
|
8796
|
+
for (const a of l)
|
|
8797
|
+
a.type === "sep" ? (i.items.length > 0 && o.push(i), i = {
|
|
8798
|
+
cols: a.cols || 2,
|
|
8799
|
+
small: !!a.small,
|
|
8800
|
+
cls: a.cls || "",
|
|
8764
8801
|
items: [],
|
|
8765
|
-
moreItems:
|
|
8766
|
-
moreCols:
|
|
8767
|
-
}) : i.items.push(
|
|
8768
|
-
i.items.length > 0 &&
|
|
8802
|
+
moreItems: a.moreItems || null,
|
|
8803
|
+
moreCols: a.moreCols || 1
|
|
8804
|
+
}) : i.items.push(a);
|
|
8805
|
+
i.items.length > 0 && o.push(i);
|
|
8769
8806
|
} else
|
|
8770
|
-
for (let
|
|
8771
|
-
|
|
8807
|
+
for (let a = 0; a < l.length; a += 4)
|
|
8808
|
+
o.push({
|
|
8772
8809
|
cols: 2,
|
|
8773
8810
|
small: !1,
|
|
8774
8811
|
cls: "",
|
|
8775
|
-
items: l.slice(
|
|
8812
|
+
items: l.slice(a, a + 4)
|
|
8776
8813
|
});
|
|
8777
|
-
|
|
8778
|
-
const
|
|
8779
|
-
if (
|
|
8814
|
+
o.forEach((i) => {
|
|
8815
|
+
const a = document.createElement("div");
|
|
8816
|
+
if (a.className = "cme-symbol-subgroup" + (i.small ? " cme-symbol-subgroup--small" : "") + (i.cls ? ` ${i.cls}` : "") + (i.moreItems ? " cme-subgroup-has-more" : ""), a.style.gridTemplateColumns = `repeat(${i.cols}, auto)`, a.style.position = "relative", i.moreItems) {
|
|
8780
8817
|
const c = document.createElement("button");
|
|
8781
8818
|
c.type = "button", c.className = "cme-more-trigger-btn", c.title = "More", c.textContent = "▶", c.addEventListener("mousedown", (d) => d.preventDefault()), c.addEventListener("click", (d) => {
|
|
8782
8819
|
if (d.stopPropagation(), this.activeDropdown && this.activeDropdownBtn === c)
|
|
@@ -8785,7 +8822,7 @@ const q = class q {
|
|
|
8785
8822
|
const m = c.getBoundingClientRect();
|
|
8786
8823
|
this.openDropdown(i.moreItems, m, i.moreCols || 4, c);
|
|
8787
8824
|
}
|
|
8788
|
-
}),
|
|
8825
|
+
}), a.appendChild(c);
|
|
8789
8826
|
}
|
|
8790
8827
|
i.items.forEach((c) => {
|
|
8791
8828
|
if (c.type === "dropdown") {
|
|
@@ -8820,15 +8857,15 @@ const q = class q {
|
|
|
8820
8857
|
this.mathField.applyStyle({ fontSize: E });
|
|
8821
8858
|
}
|
|
8822
8859
|
this.renderToolbarItems();
|
|
8823
|
-
})),
|
|
8860
|
+
})), a.appendChild(v);
|
|
8824
8861
|
return;
|
|
8825
8862
|
}
|
|
8826
|
-
const d = c.action === "BOLD", m = c.action === "ITALIC", w = c.action === "TEXT_COLOR",
|
|
8863
|
+
const d = c.action === "BOLD", m = c.action === "ITALIC", w = c.action === "TEXT_COLOR", C = c.action === "SPECIAL_CHARS", T = d && this.activeStyles.bold || m && this.activeStyles.italic || w && this.activeStyles.color !== "none", u = document.createElement("button");
|
|
8827
8864
|
u.type = "button", u.className = "cme-btn" + (e.isTemplate ? " template" : "") + (c.cls ? ` ${c.cls}` : "") + (T ? " active" : ""), u.title = c.title || c.label || c.insert || "", typeof c.label == "string" && (c.label.includes("<svg") || c.label.includes("<img") || c.label.includes("<strong") || c.label.includes("<em")) ? u.innerHTML = c.label : typeof c.label == "string" && (u.textContent = c.label), u.addEventListener("mousedown", (y) => {
|
|
8828
|
-
var v, f, k, E,
|
|
8865
|
+
var v, f, k, E, g, B, A, S, L, D;
|
|
8829
8866
|
y.preventDefault();
|
|
8830
8867
|
const h = this.mathField;
|
|
8831
|
-
if (
|
|
8868
|
+
if (C) {
|
|
8832
8869
|
this.closeAllPopups();
|
|
8833
8870
|
const M = u.getBoundingClientRect();
|
|
8834
8871
|
this.openSpecialCharacters(M);
|
|
@@ -8910,9 +8947,9 @@ const q = class q {
|
|
|
8910
8947
|
else if (c.action === "REDO")
|
|
8911
8948
|
this.closeAllPopups(), (E = h == null ? void 0 : h.executeCommand) == null || E.call(h, "redo");
|
|
8912
8949
|
else if (c.action === "CUT")
|
|
8913
|
-
this.closeAllPopups(), (
|
|
8950
|
+
this.closeAllPopups(), (g = h == null ? void 0 : h.focus) == null || g.call(h), (B = h == null ? void 0 : h.executeCommand) == null || B.call(h, "cutToClipboard");
|
|
8914
8951
|
else if (c.action === "COPY")
|
|
8915
|
-
this.closeAllPopups(), (A = h == null ? void 0 : h.focus) == null || A.call(h), (
|
|
8952
|
+
this.closeAllPopups(), (A = h == null ? void 0 : h.focus) == null || A.call(h), (S = h == null ? void 0 : h.executeCommand) == null || S.call(h, "copyToClipboard");
|
|
8916
8953
|
else if (c.action === "PASTE")
|
|
8917
8954
|
this.closeAllPopups(), (L = h == null ? void 0 : h.focus) == null || L.call(h), (D = h == null ? void 0 : h.executeCommand) == null || D.call(h, "pasteFromClipboard");
|
|
8918
8955
|
else if (c.action === "MATRIX_HOVER")
|
|
@@ -8924,21 +8961,21 @@ const q = class q {
|
|
|
8924
8961
|
}
|
|
8925
8962
|
else
|
|
8926
8963
|
this.insertAtCursor(c);
|
|
8927
|
-
}),
|
|
8928
|
-
}), this.itemsWrapper.appendChild(
|
|
8964
|
+
}), a.appendChild(u);
|
|
8965
|
+
}), this.itemsWrapper.appendChild(a);
|
|
8929
8966
|
});
|
|
8930
8967
|
}
|
|
8931
8968
|
openDropdown(t, e, l, r = null) {
|
|
8932
8969
|
this.closeAllPopups(), this.activeDropdownBtn = r, this.activeDropdown = document.createElement("div"), this.activeDropdown.className = "cme-more-popup", this.activeDropdown.style.gridTemplateColumns = `repeat(${l}, auto)`, this.activeDropdown.style.left = `${e.left + e.width / 2}px`, this.activeDropdown.style.top = `${e.bottom + 4}px`, this.activeDropdown.style.transform = "translateX(-50%)", this.activeDropdown.addEventListener(
|
|
8933
8970
|
"mousedown",
|
|
8934
|
-
(
|
|
8971
|
+
(o) => o.stopPropagation()
|
|
8935
8972
|
), this.activeDropdown.addEventListener(
|
|
8936
8973
|
"pointerdown",
|
|
8937
|
-
(
|
|
8938
|
-
), t.forEach((
|
|
8974
|
+
(o) => o.stopPropagation()
|
|
8975
|
+
), t.forEach((o) => {
|
|
8939
8976
|
const i = document.createElement("button");
|
|
8940
|
-
i.type = "button", i.className = "cme-more-popup-btn " + (
|
|
8941
|
-
|
|
8977
|
+
i.type = "button", i.className = "cme-more-popup-btn " + (o.cls || ""), i.title = o.title || o.label || o.insert || "", typeof o.label == "string" && (o.label.includes("<svg") || o.label.includes("<img")) ? i.innerHTML = o.label : i.textContent = o.label, i.addEventListener("mousedown", (a) => {
|
|
8978
|
+
a.preventDefault(), this.insertAtCursor(o.insert || o), this.closeDropdown();
|
|
8942
8979
|
}), this.activeDropdown.appendChild(i);
|
|
8943
8980
|
}), document.body.appendChild(this.activeDropdown);
|
|
8944
8981
|
}
|
|
@@ -8948,16 +8985,16 @@ const q = class q {
|
|
|
8948
8985
|
openMatrixGrid(t, e, l = null) {
|
|
8949
8986
|
this.closeAllPopups(), this.activeMatrixBtn = l, this.activeMatrixPopup = document.createElement("div"), this.activeMatrixPopup.className = "cme-matrix-hover-popover ck-only", this.activeMatrixPopup.style.left = `${e.left + e.width / 2}px`, this.activeMatrixPopup.style.top = `${e.bottom + 6}px`, this.activeMatrixPopup.style.minHeight = "auto", this.activeMatrixPopup.addEventListener(
|
|
8950
8987
|
"mousedown",
|
|
8951
|
-
(
|
|
8988
|
+
(g) => g.stopPropagation()
|
|
8952
8989
|
), this.activeMatrixPopup.addEventListener(
|
|
8953
8990
|
"pointerdown",
|
|
8954
|
-
(
|
|
8991
|
+
(g) => g.stopPropagation()
|
|
8955
8992
|
);
|
|
8956
8993
|
const r = document.createElement("div");
|
|
8957
8994
|
r.className = "cme-matrix-hover-title", r.textContent = t === "matrix" ? "MATRIX" : `${t.toUpperCase()} MATRIX`;
|
|
8958
|
-
const
|
|
8959
|
-
|
|
8960
|
-
let i = 2,
|
|
8995
|
+
const o = document.createElement("div");
|
|
8996
|
+
o.className = "cme-matrix-hover-grid", o.style.flex = "none";
|
|
8997
|
+
let i = 2, a = 2;
|
|
8961
8998
|
const c = document.createElement("div");
|
|
8962
8999
|
c.className = "cme-matrix-hover-footer";
|
|
8963
9000
|
const d = document.createElement("div");
|
|
@@ -8966,14 +9003,14 @@ const q = class q {
|
|
|
8966
9003
|
m.type = "number", m.className = "cme-counter-val", m.min = "1", m.max = "10", m.value = i;
|
|
8967
9004
|
const w = document.createElement("div");
|
|
8968
9005
|
w.className = "cme-counter-btns";
|
|
8969
|
-
const
|
|
8970
|
-
|
|
9006
|
+
const C = document.createElement("button");
|
|
9007
|
+
C.type = "button", C.textContent = "▲";
|
|
8971
9008
|
const T = document.createElement("button");
|
|
8972
|
-
T.type = "button", T.textContent = "▼", w.appendChild(
|
|
9009
|
+
T.type = "button", T.textContent = "▼", w.appendChild(C), w.appendChild(T);
|
|
8973
9010
|
const u = document.createElement("span");
|
|
8974
9011
|
u.textContent = "×";
|
|
8975
9012
|
const y = document.createElement("input");
|
|
8976
|
-
y.type = "number", y.className = "cme-counter-val", y.min = "1", y.max = "10", y.value =
|
|
9013
|
+
y.type = "number", y.className = "cme-counter-val", y.min = "1", y.max = "10", y.value = a;
|
|
8977
9014
|
const h = document.createElement("div");
|
|
8978
9015
|
h.className = "cme-counter-btns";
|
|
8979
9016
|
const v = document.createElement("button");
|
|
@@ -8982,52 +9019,52 @@ const q = class q {
|
|
|
8982
9019
|
f.type = "button", f.textContent = "▼", h.appendChild(v), h.appendChild(f), d.appendChild(m), d.appendChild(w), d.appendChild(u), d.appendChild(y), d.appendChild(h);
|
|
8983
9020
|
const k = document.createElement("button");
|
|
8984
9021
|
k.type = "button", k.className = "cme-matrix-insert-btn", k.textContent = "INSERT", c.appendChild(d), c.appendChild(k);
|
|
8985
|
-
const E = (
|
|
8986
|
-
i = Math.max(1, Math.min(10,
|
|
8987
|
-
const L = parseInt(
|
|
8988
|
-
L <= i && D <=
|
|
9022
|
+
const E = (g, B) => {
|
|
9023
|
+
i = Math.max(1, Math.min(10, g)), a = Math.max(1, Math.min(10, B)), m.value = i, y.value = a, o.querySelectorAll(".cme-matrix-hover-cell").forEach((S) => {
|
|
9024
|
+
const L = parseInt(S.dataset.row, 10), D = parseInt(S.dataset.col, 10);
|
|
9025
|
+
L <= i && D <= a ? S.classList.add("selected") : S.classList.remove("selected");
|
|
8989
9026
|
});
|
|
8990
9027
|
};
|
|
8991
|
-
for (let
|
|
9028
|
+
for (let g = 1; g <= 5; g++) {
|
|
8992
9029
|
const B = document.createElement("div");
|
|
8993
9030
|
B.className = "cme-matrix-hover-row";
|
|
8994
9031
|
for (let A = 1; A <= 10; A++) {
|
|
8995
|
-
const
|
|
8996
|
-
|
|
8997
|
-
E(
|
|
8998
|
-
}),
|
|
8999
|
-
L.stopPropagation(), this.insertMatrix(t,
|
|
9000
|
-
}), B.appendChild(
|
|
9032
|
+
const S = document.createElement("div");
|
|
9033
|
+
S.className = "cme-matrix-hover-cell" + (g <= i && A <= a ? " selected" : ""), S.dataset.row = g, S.dataset.col = A, S.addEventListener("mouseenter", () => {
|
|
9034
|
+
E(g, A);
|
|
9035
|
+
}), S.addEventListener("click", (L) => {
|
|
9036
|
+
L.stopPropagation(), this.insertMatrix(t, g, A), this.closeMatrixPopup();
|
|
9037
|
+
}), B.appendChild(S);
|
|
9001
9038
|
}
|
|
9002
|
-
|
|
9039
|
+
o.appendChild(B);
|
|
9003
9040
|
}
|
|
9004
9041
|
m.addEventListener("input", () => {
|
|
9005
|
-
const
|
|
9006
|
-
E(
|
|
9042
|
+
const g = parseInt(m.value, 10) || 1;
|
|
9043
|
+
E(g, a);
|
|
9007
9044
|
}), y.addEventListener("input", () => {
|
|
9008
|
-
const
|
|
9009
|
-
E(i,
|
|
9010
|
-
}),
|
|
9011
|
-
|
|
9012
|
-
}), T.addEventListener("click", (
|
|
9013
|
-
|
|
9014
|
-
}), v.addEventListener("click", (
|
|
9015
|
-
|
|
9016
|
-
}), f.addEventListener("click", (
|
|
9017
|
-
|
|
9018
|
-
}), k.addEventListener("click", (
|
|
9019
|
-
|
|
9020
|
-
}), this.activeMatrixPopup.appendChild(r), this.activeMatrixPopup.appendChild(
|
|
9045
|
+
const g = parseInt(y.value, 10) || 1;
|
|
9046
|
+
E(i, g);
|
|
9047
|
+
}), C.addEventListener("click", (g) => {
|
|
9048
|
+
g.preventDefault(), g.stopPropagation(), E(i + 1, a);
|
|
9049
|
+
}), T.addEventListener("click", (g) => {
|
|
9050
|
+
g.preventDefault(), g.stopPropagation(), E(i - 1, a);
|
|
9051
|
+
}), v.addEventListener("click", (g) => {
|
|
9052
|
+
g.preventDefault(), g.stopPropagation(), E(i, a + 1);
|
|
9053
|
+
}), f.addEventListener("click", (g) => {
|
|
9054
|
+
g.preventDefault(), g.stopPropagation(), E(i, a - 1);
|
|
9055
|
+
}), k.addEventListener("click", (g) => {
|
|
9056
|
+
g.stopPropagation(), this.insertMatrix(t, i, a), this.closeMatrixPopup();
|
|
9057
|
+
}), this.activeMatrixPopup.appendChild(r), this.activeMatrixPopup.appendChild(o), this.activeMatrixPopup.appendChild(c), document.body.appendChild(this.activeMatrixPopup);
|
|
9021
9058
|
}
|
|
9022
9059
|
insertMatrix(t, e, l) {
|
|
9023
9060
|
let r = [];
|
|
9024
|
-
for (let
|
|
9061
|
+
for (let a = 0; a < e; a++) {
|
|
9025
9062
|
let c = [];
|
|
9026
9063
|
for (let d = 0; d < l; d++)
|
|
9027
9064
|
c.push("{#?}");
|
|
9028
9065
|
r.push(c.join(" & "));
|
|
9029
9066
|
}
|
|
9030
|
-
const
|
|
9067
|
+
const o = t || "matrix", i = `\\begin{${o}}${r.join(" \\\\ ")}\\end{${o}}`;
|
|
9031
9068
|
this.insertAtCursor(i);
|
|
9032
9069
|
}
|
|
9033
9070
|
closeMatrixPopup() {
|
|
@@ -9050,18 +9087,18 @@ const q = class q {
|
|
|
9050
9087
|
"#3949ab",
|
|
9051
9088
|
"#00acc1"
|
|
9052
9089
|
].forEach((r) => {
|
|
9053
|
-
const
|
|
9054
|
-
|
|
9055
|
-
var
|
|
9056
|
-
i.preventDefault(), this.activeStyles.color = r, (
|
|
9057
|
-
}), this.colorPickerPopup.appendChild(
|
|
9090
|
+
const o = document.createElement("div");
|
|
9091
|
+
o.style.width = "18px", o.style.height = "18px", o.style.borderRadius = "50%", o.style.margin = "4px", o.style.cursor = "pointer", o.style.backgroundColor = r, o.style.border = this.activeStyles.color === r ? "2px solid #222" : "1px solid #ddd", o.addEventListener("mousedown", (i) => {
|
|
9092
|
+
var a;
|
|
9093
|
+
i.preventDefault(), this.activeStyles.color = r, (a = this.mathField) != null && a.applyStyle && this.mathField.applyStyle({ color: r === "black" ? "none" : r }), this.closeColorPicker(), this.renderToolbarItems();
|
|
9094
|
+
}), this.colorPickerPopup.appendChild(o);
|
|
9058
9095
|
}), document.body.appendChild(this.colorPickerPopup);
|
|
9059
9096
|
}
|
|
9060
9097
|
closeColorPicker() {
|
|
9061
9098
|
this.colorPickerPopup && this.colorPickerPopup.parentNode && this.colorPickerPopup.parentNode.removeChild(this.colorPickerPopup), this.colorPickerPopup = null, this.activeColorBtn = null;
|
|
9062
9099
|
}
|
|
9063
9100
|
openSpecialCharacters(t) {
|
|
9064
|
-
this.specCharModal || (this.specCharModal = new
|
|
9101
|
+
this.specCharModal || (this.specCharModal = new ut({
|
|
9065
9102
|
onInsert: (e) => {
|
|
9066
9103
|
this.insertAtCursor(e);
|
|
9067
9104
|
}
|
|
@@ -9076,13 +9113,13 @@ const q = class q {
|
|
|
9076
9113
|
};
|
|
9077
9114
|
J(q, "VERSION", H == null ? void 0 : H.version);
|
|
9078
9115
|
let z = q, Z = null;
|
|
9079
|
-
function
|
|
9116
|
+
function yt() {
|
|
9080
9117
|
return Z || (Z = new z()), Z;
|
|
9081
9118
|
}
|
|
9082
9119
|
class et {
|
|
9083
9120
|
constructor(t = {}) {
|
|
9084
9121
|
this.container = t.container || null, this.latex = t.latex || "", this.editable = t.editable !== !1, this.mode = t.mode || "math", this.onUpdate = t.onUpdate || (() => {
|
|
9085
|
-
}), this.editor = t.editor ||
|
|
9122
|
+
}), this.editor = t.editor || yt(), this.element = null, this.mathField = null, this.container && this.mount(this.container);
|
|
9086
9123
|
}
|
|
9087
9124
|
mount(t) {
|
|
9088
9125
|
this.container = t, this.element = document.createElement("span"), this.element.className = "digi-math-widget" + (this.editable ? "" : " readonly"), this.element.setAttribute("data-latex", this.latex), this.element.title = this.editable ? "Click to edit formula" : "";
|
|
@@ -9113,7 +9150,7 @@ class et {
|
|
|
9113
9150
|
this.element && this.element.parentNode && this.element.parentNode.removeChild(this.element);
|
|
9114
9151
|
}
|
|
9115
9152
|
}
|
|
9116
|
-
function
|
|
9153
|
+
function Ct(s) {
|
|
9117
9154
|
return new et(s);
|
|
9118
9155
|
}
|
|
9119
9156
|
if (typeof customElements < "u" && !customElements.get("digi-math-widget")) {
|
|
@@ -9128,8 +9165,8 @@ if (typeof customElements < "u" && !customElements.get("digi-math-widget")) {
|
|
|
9128
9165
|
latex: e,
|
|
9129
9166
|
editable: l,
|
|
9130
9167
|
mode: r,
|
|
9131
|
-
onUpdate: (
|
|
9132
|
-
this.setAttribute("latex",
|
|
9168
|
+
onUpdate: (o) => {
|
|
9169
|
+
this.setAttribute("latex", o), this.dispatchEvent(new CustomEvent("latexChange", { detail: { latex: o }, bubbles: !0 }));
|
|
9133
9170
|
}
|
|
9134
9171
|
});
|
|
9135
9172
|
}
|
|
@@ -9142,18 +9179,18 @@ if (typeof customElements < "u" && !customElements.get("digi-math-widget")) {
|
|
|
9142
9179
|
}
|
|
9143
9180
|
customElements.define("digi-math-widget", s);
|
|
9144
9181
|
}
|
|
9145
|
-
const
|
|
9182
|
+
const St = H == null ? void 0 : H.version;
|
|
9146
9183
|
export {
|
|
9147
|
-
|
|
9184
|
+
mt as CME_SHADOW_DOM_CSS,
|
|
9148
9185
|
z as DigiMathChemEditor,
|
|
9149
9186
|
et as DigiMathWidget,
|
|
9150
|
-
|
|
9151
|
-
|
|
9187
|
+
ut as SpecialCharacterModal,
|
|
9188
|
+
St as VERSION,
|
|
9152
9189
|
P as cleanMathLiveExportedLatex,
|
|
9153
|
-
|
|
9190
|
+
Ct as createMathWidget,
|
|
9154
9191
|
z as default,
|
|
9155
9192
|
bt as initMathFieldCursorFix,
|
|
9156
|
-
|
|
9193
|
+
Mt as latexToPlainText,
|
|
9157
9194
|
$ as scrollMathFieldCaretIntoView,
|
|
9158
9195
|
ct as stripEncloseOptions,
|
|
9159
9196
|
ot as stripPlaceholders,
|