digi-mathchem-editor 1.0.16 → 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,5 +1,5 @@
1
- import e, { useState as B, useEffect as O, useMemo as ye, useRef as re, useCallback as he } from "react";
2
- import { createPortal as z } from "react-dom";
1
+ import e, { useState as B, useEffect as O, useMemo as Ee, useRef as re, useCallback as he } from "react";
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";
5
5
  import { MathfieldElement as fe } from "mathlive";
@@ -360,24 +360,24 @@ const Se = [
360
360
  });
361
361
  }), l;
362
362
  }, je = Je();
363
- function Qe({ isOpen: l, onClose: o, onInsert: a, position: m }) {
363
+ function ze({ isOpen: l, onClose: o, onInsert: a, position: m }) {
364
364
  const [n, s] = B(""), [d, p] = B("All");
365
365
  O(() => {
366
366
  l && (s(""), p("All"));
367
367
  }, [l]);
368
- const x = ye(() => {
368
+ const x = Ee(() => {
369
369
  let u = je;
370
- if (d !== "All" && (u = u.filter((E) => E.category === d)), n.trim()) {
371
- const E = n.trim().toUpperCase();
372
- u = u.filter((k) => k.code.includes(E));
370
+ if (d !== "All" && (u = u.filter((y) => y.category === d)), n.trim()) {
371
+ const y = n.trim().toUpperCase();
372
+ u = u.filter((k) => k.code.includes(y));
373
373
  }
374
374
  return u;
375
- }, [d, n]), I = ye(() => {
375
+ }, [d, n]), I = Ee(() => {
376
376
  if (d !== "All" && !n.trim())
377
377
  return { [d]: x };
378
378
  const u = {};
379
- return x.forEach((E) => {
380
- u[E.category] || (u[E.category] = []), u[E.category].push(E);
379
+ return x.forEach((y) => {
380
+ u[y.category] || (u[y.category] = []), u[y.category].push(y);
381
381
  }), u;
382
382
  }, [x, d, n]), g = (u) => {
383
383
  u.key === "Escape" && o();
@@ -385,8 +385,8 @@ function Qe({ isOpen: l, onClose: o, onInsert: a, position: m }) {
385
385
  if (O(() => (l && window.addEventListener("keydown", g), () => window.removeEventListener("keydown", g)), [l]), !l) return null;
386
386
  let A = { top: "50%", left: "50%", transform: "translate(-50%, -50%)" };
387
387
  if (m) {
388
- let u = m.x - 120, E = m.y;
389
- u < 10 && (u = 10), u + 230 > window.innerWidth && (u = window.innerWidth - 240), E + 200 > window.innerHeight && (E = window.innerHeight - 210), A = { top: `${E}px`, left: `${u}px` };
388
+ let u = m.x - 120, y = m.y;
389
+ u < 10 && (u = 10), u + 230 > window.innerWidth && (u = window.innerWidth - 240), y + 200 > window.innerHeight && (y = window.innerHeight - 210), A = { top: `${y}px`, left: `${u}px` };
390
390
  }
391
391
  return /* @__PURE__ */ e.createElement("div", { className: "scm-overlay", onMouseDown: (u) => {
392
392
  u.stopPropagation(), o();
@@ -407,7 +407,7 @@ function Qe({ 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(I).map(([u, E]) => /* @__PURE__ */ e.createElement("div", { key: u, className: "scm-category-group" }, /* @__PURE__ */ e.createElement("div", { className: "scm-char-grid" }, E.map((k) => /* @__PURE__ */ e.createElement(
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,8 +420,8 @@ function Qe({ 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 ze = "1.0.16", Xe = {
424
- version: ze
423
+ const Qe = "1.0.18", Xe = {
424
+ version: Qe
425
425
  };
426
426
  window.__cme_macros = {
427
427
  ...window.__cme_macros,
@@ -1951,11 +1951,11 @@ const Ge = [
1951
1951
  { label: "∰", insert: "\\mathop{{\\style{font-size:1em;}{\\iiint}}\\mkern-28mu\\class{wider-circle}{\\bigcirc}\\mkern18mu}", title: "Closed volume integral" }
1952
1952
  ]
1953
1953
  },
1954
- { label: "∫", insert: "\\int", title: "Integral" },
1955
- { label: "∬", insert: "\\iint", title: "Double integral" },
1956
- { label: "∮", insert: "\\oint", title: "Contour integral" },
1957
- // { label: '', insert: '\\oiint', title: 'surface integral' },
1958
- { label: "∯", insert: "\\mathop{{\\style{font-size:1em;}{\\iint}}\\mkern-23mu\\class{wide-circle}{\\bigcirc}\\mkern14mu}", title: "Custom surface integral" },
1954
+ { 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: "\\int", title: "Integral" },
1955
+ { 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" },
1956
+ { 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" },
1957
+ // { 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' },
1958
+ { 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: "\\mathop{{\\style{font-size:1em;}{\\iint}}\\mkern-23mu\\class{wide-circle}{\\bigcirc}\\mkern14mu}", title: "Custom surface integral" },
1959
1959
  {
1960
1960
  type: "sep",
1961
1961
  cols: 3,
@@ -3552,11 +3552,16 @@ const Ge = [
3552
3552
  { label: "∰", insert: "\\mathop{{\\style{font-size:1em;}{\\iiint}}\\mkern-28mu\\class{wider-circle}{\\bigcirc}\\mkern18mu}", title: "Closed volume integral" }
3553
3553
  ]
3554
3554
  },
3555
- { label: "", insert: "\\int", title: "Integral" },
3556
- { label: "", insert: "\\iint", title: "Double integral" },
3557
- { label: "", insert: "\\oint", title: "Contour integral" },
3558
- // { label: '∯', insert: '\\oiint', title: 'surface integral' },
3559
- { label: "", insert: "\\mathop{{\\style{font-size:1em;}{\\iint}}\\mkern-23mu\\class{wide-circle}{\\bigcirc}\\mkern14mu}", title: "Custom surface integral" },
3555
+ // { label: '', insert: '\\int', title: 'Integral' },
3556
+ // { label: '', insert: '\\iint', title: 'Double integral' },
3557
+ // { label: '', insert: '\\oint', title: 'Contour integral' },
3558
+ // // { label: '∯', insert: '\\oiint', title: 'surface integral' },
3559
+ // { label: '', insert: '\\mathop{{\\style{font-size:1em;}{\\iint}}\\mkern-23mu\\class{wide-circle}{\\bigcirc}\\mkern14mu}', title: 'Custom surface integral' },
3560
+ { 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: "\\int", title: "Integral" },
3561
+ { 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" },
3562
+ { 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" },
3563
+ // { 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' },
3564
+ { 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: "\\mathop{{\\style{font-size:1em;}{\\iint}}\\mkern-23mu\\class{wide-circle}{\\bigcirc}\\mkern14mu}", title: "Custom surface integral" },
3560
3565
  {
3561
3566
  type: "sep",
3562
3567
  cols: 3,
@@ -3652,41 +3657,41 @@ class ct extends Ve {
3652
3657
  "span",
3653
3658
  {
3654
3659
  class: "ck-math-widget-inner",
3655
- style: "display:inline-block;vertical-align:middle;margin:0 2px;cursor:pointer;width:auto;max-width:100%;pointer-events:none;"
3660
+ style: "display:inline-block;vertical-align:middle;margin:0;cursor:pointer;width:auto;max-width:100%;pointer-events:none;"
3656
3661
  },
3657
3662
  (I) => {
3658
3663
  const g = document.createElement("math-field");
3659
- 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 2px", g.style.margin = "0", g.style.pointerEvents = "none";
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";
3660
3665
  const A = () => {
3661
3666
  if (!g.isConnected) {
3662
3667
  requestAnimationFrame(A);
3663
3668
  return;
3664
3669
  }
3665
3670
  window.__cme_macros && (g.macros = { ...g.macros, ...window.__cme_macros });
3666
- let E = ge(
3671
+ let y = ge(
3667
3672
  ne(
3668
3673
  X(
3669
3674
  de(s)
3670
3675
  )
3671
3676
  )
3672
3677
  );
3673
- E.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(E.trim()) && (E = E.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1"));
3678
+ y.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(y.trim()) && (y = y.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1"));
3674
3679
  try {
3675
- g.setValue ? g.setValue("", { silenceNotifications: !0 }) : g.value = "", g.executeCommand(["insert", E, { insertionMode: "replaceAll" }]);
3680
+ g.setValue ? g.setValue("", { silenceNotifications: !0 }) : g.value = "", g.executeCommand(["insert", y, { insertionMode: "replaceAll" }]);
3676
3681
  } catch (k) {
3677
3682
  console.error("[CKMathWidget] executeCommand failed, falling back to setValue:", k);
3678
3683
  try {
3679
- g.setValue ? g.setValue(E, { silenceNotifications: !0 }) : g.value = E;
3680
- } catch (y) {
3681
- console.error("[CKMathWidget] setValue also failed:", y);
3684
+ g.setValue ? g.setValue(y, { silenceNotifications: !0 }) : g.value = y;
3685
+ } catch (E) {
3686
+ console.error("[CKMathWidget] setValue also failed:", E);
3682
3687
  }
3683
3688
  }
3684
3689
  g.setAttribute("read-only", "");
3685
3690
  };
3686
3691
  customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)), I.appendChild(g);
3687
3692
  const u = () => {
3688
- const E = I.parentElement;
3689
- E && Ye(o, E);
3693
+ const y = I.parentElement;
3694
+ y && Ye(o, y);
3690
3695
  };
3691
3696
  u(), requestAnimationFrame(u);
3692
3697
  }
@@ -3759,30 +3764,30 @@ class ct extends Ve {
3759
3764
  }
3760
3765
  function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLeave: s }) {
3761
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) => {
3762
- const y = k.target.value;
3763
- if (y === "") {
3767
+ const E = k.target.value;
3768
+ if (E === "") {
3764
3769
  p((L) => ({ ...L, r: "" }));
3765
3770
  return;
3766
3771
  }
3767
- const T = parseInt(y, 10);
3772
+ const T = parseInt(E, 10);
3768
3773
  isNaN(T) || p((L) => ({ ...L, r: Math.max(1, Math.min(10, T)) }));
3769
3774
  }, A = () => {
3770
3775
  (d.r === "" || isNaN(parseInt(d.r, 10))) && p((k) => ({ ...k, r: 1 }));
3771
3776
  }, u = (k) => {
3772
- const y = k.target.value;
3773
- if (y === "") {
3777
+ const E = k.target.value;
3778
+ if (E === "") {
3774
3779
  p((L) => ({ ...L, c: "" }));
3775
3780
  return;
3776
3781
  }
3777
- const T = parseInt(y, 10);
3782
+ const T = parseInt(E, 10);
3778
3783
  isNaN(T) || p((L) => ({ ...L, c: Math.max(1, Math.min(10, T)) }));
3779
- }, E = () => {
3784
+ }, y = () => {
3780
3785
  (d.c === "" || isNaN(parseInt(d.c, 10))) && p((k) => ({ ...k, c: 1 }));
3781
3786
  };
3782
3787
  return O(() => {
3783
- const k = (y) => {
3784
- if (y.key === "Enter") {
3785
- y.preventDefault(), y.stopPropagation();
3788
+ const k = (E) => {
3789
+ if (E.key === "Enter") {
3790
+ E.preventDefault(), E.stopPropagation();
3786
3791
  const T = parseInt(d.r, 10) || 1, L = parseInt(d.c, 10) || 1;
3787
3792
  m(T, L);
3788
3793
  }
@@ -3797,16 +3802,16 @@ function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLe
3797
3802
  onMouseEnter: n,
3798
3803
  onMouseLeave: s
3799
3804
  },
3800
- /* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length: x }).map((k, y) => /* @__PURE__ */ e.createElement("div", { key: y, className: "cme-matrix-hover-row" }, Array.from({ length: I }).map((T, L) => {
3801
- const q = parseInt(d.r, 10) || 0, K = parseInt(d.c, 10) || 0, j = y < q && L < K;
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
+ const q = parseInt(d.r, 10) || 0, K = parseInt(d.c, 10) || 0, j = E < q && L < K;
3802
3807
  return /* @__PURE__ */ e.createElement(
3803
3808
  "div",
3804
3809
  {
3805
- key: `${y}-${L}`,
3810
+ key: `${E}-${L}`,
3806
3811
  className: `cme-matrix-hover-cell${j ? " selected" : ""}`,
3807
- onMouseEnter: () => p({ r: y + 1, c: L + 1 }),
3812
+ onMouseEnter: () => p({ r: E + 1, c: L + 1 }),
3808
3813
  onClick: (_) => {
3809
- _.preventDefault(), _.stopPropagation(), m(y + 1, L + 1);
3814
+ _.preventDefault(), _.stopPropagation(), m(E + 1, L + 1);
3810
3815
  }
3811
3816
  }
3812
3817
  );
@@ -3823,11 +3828,11 @@ function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLe
3823
3828
  max: "10"
3824
3829
  }
3825
3830
  ), /* @__PURE__ */ e.createElement("div", { className: "cme-counter-btns" }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => p((k) => {
3826
- const y = parseInt(k.r, 10) || 1;
3827
- return { ...k, r: Math.min(10, y + 1) };
3831
+ const E = parseInt(k.r, 10) || 1;
3832
+ return { ...k, r: Math.min(10, E + 1) };
3828
3833
  }) }, "▲"), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => p((k) => {
3829
- const y = parseInt(k.r, 10) || 1;
3830
- return { ...k, r: Math.max(1, y - 1) };
3834
+ const E = parseInt(k.r, 10) || 1;
3835
+ return { ...k, r: Math.max(1, E - 1) };
3831
3836
  }) }, "▼"))), /* @__PURE__ */ e.createElement("div", { className: "cme-matrix-counter" }, /* @__PURE__ */ e.createElement("span", null, "C"), /* @__PURE__ */ e.createElement(
3832
3837
  "input",
3833
3838
  {
@@ -3835,34 +3840,34 @@ function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLe
3835
3840
  className: "cme-counter-val",
3836
3841
  value: d.c,
3837
3842
  onChange: u,
3838
- onBlur: E,
3843
+ onBlur: y,
3839
3844
  min: "1",
3840
3845
  max: "10"
3841
3846
  }
3842
3847
  ), /* @__PURE__ */ e.createElement("div", { className: "cme-counter-btns" }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => p((k) => {
3843
- const y = parseInt(k.c, 10) || 1;
3844
- return { ...k, c: Math.min(10, y + 1) };
3848
+ const E = parseInt(k.c, 10) || 1;
3849
+ return { ...k, c: Math.min(10, E + 1) };
3845
3850
  }) }, "▲"), /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => p((k) => {
3846
- const y = parseInt(k.c, 10) || 1;
3847
- return { ...k, c: Math.max(1, y - 1) };
3851
+ const E = parseInt(k.c, 10) || 1;
3852
+ return { ...k, c: Math.max(1, E - 1) };
3848
3853
  }) }, "▼"))))
3849
3854
  );
3850
3855
  }
3851
3856
  let J = !1, be = null, U = null;
3852
3857
  function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n }) {
3853
- const s = re(null), [d, p] = B(0), [x, I] = B(null), [g, A] = B(null), [u, E] = B(null), [k, y] = B(null);
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);
3854
3859
  re(null);
3855
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);
3856
3861
  O(() => {
3857
3862
  const t = (r) => {
3858
3863
  if (!q) return;
3859
- const h = 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;
3860
- let w = h - j.current.x, c = b - j.current.y;
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;
3861
3866
  if (se.current) {
3862
3867
  const C = se.current, M = -C.left, R = window.innerWidth - C.right, H = -C.top, P = window.innerHeight - C.bottom;
3863
- w < M && (w = M), w > R && (w = R), c < H && (c = H), c > P && (c = P);
3868
+ w < M && (w = M), w > R && (w = R), h < H && (h = H), h > P && (h = P);
3864
3869
  }
3865
- L({ x: w, y: c });
3870
+ L({ x: w, y: h });
3866
3871
  }, i = () => K(!1);
3867
3872
  return q && (window.addEventListener("mousemove", t, { passive: !1 }), window.addEventListener("mouseup", i), window.addEventListener("touchmove", t, { passive: !1 }), window.addEventListener("touchend", i)), () => {
3868
3873
  window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", i), window.removeEventListener("touchmove", t), window.removeEventListener("touchend", i);
@@ -3876,9 +3881,9 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3876
3881
  x: i - T.x,
3877
3882
  y: r - T.y
3878
3883
  };
3879
- const h = document.querySelector(".cme-editor-popup");
3880
- if (h) {
3881
- const b = h.getBoundingClientRect();
3884
+ const c = document.querySelector(".cme-editor-popup");
3885
+ if (c) {
3886
+ const b = c.getBoundingClientRect();
3882
3887
  se.current = {
3883
3888
  left: b.left - T.x,
3884
3889
  top: b.top - T.y,
@@ -3899,10 +3904,10 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3899
3904
  const t = s.current;
3900
3905
  if (!(!t || typeof t.queryStyle != "function"))
3901
3906
  try {
3902
- 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", h = window.__cmeManualFontFamily !== void 0 ? window.__cmeManualFontFamily : ["roman", "sans-serif", "monospace"].find(
3903
- (c) => t.queryStyle({ fontFamily: c }) === "all"
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"
3904
3909
  ) || "none", b = window.__cmeManualFontSize !== void 0 ? window.__cmeManualFontSize : [5, 7, 9].find(
3905
- (c) => t.queryStyle({ fontSize: c }) === "all"
3910
+ (h) => t.queryStyle({ fontSize: h }) === "all"
3906
3911
  ) || "auto", w = [
3907
3912
  "black",
3908
3913
  "dimgray",
@@ -3929,12 +3934,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3929
3934
  "violet",
3930
3935
  "gold"
3931
3936
  ].find(
3932
- (c) => t.queryStyle({ color: c }) === "all"
3937
+ (h) => t.queryStyle({ color: h }) === "all"
3933
3938
  ) || "none";
3934
- ce((c) => ({
3939
+ ce((h) => ({
3935
3940
  bold: i,
3936
3941
  italic: r,
3937
- fontFamily: h,
3942
+ fontFamily: c,
3938
3943
  fontSize: String(b),
3939
3944
  color: w
3940
3945
  }));
@@ -3945,7 +3950,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3945
3950
  O(() => {
3946
3951
  if (!x && !u) return;
3947
3952
  const t = (i) => {
3948
- !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"]') && E(null);
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);
3949
3954
  };
3950
3955
  return window.addEventListener("mousedown", t, !0), window.addEventListener("pointerdown", t, !0), () => {
3951
3956
  window.removeEventListener("mousedown", t, !0), window.removeEventListener("pointerdown", t, !0);
@@ -3953,7 +3958,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3953
3958
  }, [x, u]), O(() => {
3954
3959
  if (!k) return;
3955
3960
  const t = (i) => {
3956
- !i.target.closest(".cme-more-popup") && !i.target.closest(".cme-more-trigger-btn") && y(null);
3961
+ !i.target.closest(".cme-more-popup") && !i.target.closest(".cme-more-trigger-btn") && E(null);
3957
3962
  };
3958
3963
  return window.addEventListener("mousedown", t, !0), window.addEventListener("pointerdown", t, !0), () => {
3959
3964
  window.removeEventListener("mousedown", t, !0), window.removeEventListener("pointerdown", t, !0);
@@ -3970,8 +3975,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3970
3975
  if (typeof t.applyStyle == "function" && t.applyStyle({ variantStyle: "up" }), m) {
3971
3976
  let r = ge(m);
3972
3977
  if (l === "chem") {
3973
- const h = r.match(/^\\ce\{([\s\S]*)\}$/i);
3974
- h && (r = h[1]);
3978
+ const c = r.match(/^\\ce\{([\s\S]*)\}$/i);
3979
+ c && (r = c[1]);
3975
3980
  }
3976
3981
  r = X(r), r = ne(r), t.setValue ? t.setValue("", { silenceNotifications: !0 }) : t.value = "", t.executeCommand(["insert", r, { insertionMode: "replaceAll" }]);
3977
3982
  }
@@ -3986,17 +3991,17 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3986
3991
  J = !1;
3987
3992
  }, 500)), ["`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "_", '"', "'", "/", "\\", "|"].includes(r.key) && !r.ctrlKey && !r.metaKey && !r.altKey) {
3988
3993
  r.preventDefault(), r.stopPropagation();
3989
- let h = "";
3990
- r.key === "`" ? h = "\\grave{\\ }" : r.key === "~" ? h = "\\sim" : r.key === "!" ? h = "!" : r.key === "@" ? h = "@" : r.key === "#" ? h = "\\#" : r.key === "$" ? h = "\\$" : r.key === "%" ? h = "\\%" : r.key === "^" ? h = "\\wedge" : r.key === "&" ? h = "\\&" : r.key === "*" ? h = "\\ast" : r.key === "_" ? h = "\\_" : r.key === '"' ? h = '\\text{"}' : r.key === "'" ? h = "\\text{'}" : r.key === "/" ? h = "\\mathord{/}" : r.key === "\\" ? h = "\\backslash" : r.key === "|" && (h = "|"), t.executeCommand(["insert", h]);
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]);
3991
3996
  return;
3992
3997
  }
3993
3998
  if (r.key.length === 1 && !r.ctrlKey && !r.metaKey && !r.altKey && /[a-zA-Z0-9]/.test(r.key)) {
3994
3999
  r.preventDefault(), r.stopPropagation();
3995
- const h = f.fontFamily === "sans-serif", b = f.fontFamily === "monospace", w = f.bold, c = f.italic;
4000
+ const c = f.fontFamily === "sans-serif", b = f.fontFamily === "monospace", w = f.bold, h = f.italic;
3996
4001
  let C = "\\mathrm";
3997
- h ? C = "\\mathsf" : b ? C = "\\mathtt" : c && !w ? C = "\\mathit" : w && !c && (C = "\\mathbf");
4002
+ c ? C = "\\mathsf" : b ? C = "\\mathtt" : h && !w ? C = "\\mathit" : w && !h && (C = "\\mathbf");
3998
4003
  let M = `${C}{${r.key}}`;
3999
- w && c ? (M = `\\mathbfit{${r.key}}`, h && (M = `\\boldsymbol{\\mathsf{${r.key}}}`), b && (M = `\\boldsymbol{\\mathtt{${r.key}}}`)) : w && (h || b) && (M = `\\boldsymbol{${M}}`);
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}}`);
4000
4005
  let R = M;
4001
4006
  const H = f.fontSize === "auto" ? 5 : parseInt(f.fontSize, 10);
4002
4007
  if (H !== 5) {
@@ -4016,26 +4021,26 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4016
4021
  setTimeout(() => {
4017
4022
  const r = t.shadowRoot;
4018
4023
  if (!r) return;
4019
- const h = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
4020
- h && h.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }), F();
4024
+ const c = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
4025
+ c && c.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }), F();
4021
4026
  }, 0);
4022
4027
  };
4023
4028
  return t.addEventListener("selection-change", i), t.addEventListener("input", i), t.addEventListener("keydown", i), setTimeout(F, 50), () => {
4024
4029
  t.removeEventListener("selection-change", i), t.removeEventListener("input", i), t.removeEventListener("keydown", i);
4025
4030
  };
4026
4031
  }, [F]);
4027
- const Q = he((t) => {
4032
+ const z = he((t) => {
4028
4033
  const i = U;
4029
4034
  i && (i.focus(), i.executeCommand(["insert", t]));
4030
4035
  }, []), De = he((t, i, r) => {
4031
- let h = `\\begin{${t}} `;
4036
+ let c = `\\begin{${t}} `;
4032
4037
  for (let b = 0; b < i; b++) {
4033
4038
  for (let w = 0; w < r; w++)
4034
- h += "#?", w < r - 1 && (h += " & ");
4035
- b < i - 1 && (h += " \\\\ ");
4039
+ c += "#?", w < r - 1 && (c += " & ");
4040
+ b < i - 1 && (c += " \\\\ ");
4036
4041
  }
4037
- h += ` \\end{${t}}`, Q(h);
4038
- }, [Q]), Ne = (t) => {
4042
+ c += ` \\end{${t}}`, z(c);
4043
+ }, [z]), Ne = (t) => {
4039
4044
  t.stopPropagation(), ke((i) => !i), ue(!1), L({ x: 0, y: 0 });
4040
4045
  }, Re = (t) => {
4041
4046
  t.stopPropagation(), ue((i) => !i), ke(!1), L({ x: 0, y: 0 });
@@ -4046,8 +4051,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4046
4051
  a && a();
4047
4052
  return;
4048
4053
  }
4049
- const r = i.getValue ? i.getValue("latex") : i.value, h = m || "";
4050
- !r || r.trim() === "" || r === h ? a && a() : Y(!0);
4054
+ const r = i.getValue ? i.getValue("latex") : i.value, c = m || "";
4055
+ !r || r.trim() === "" || r === c ? a && a() : Y(!0);
4051
4056
  }, Oe = () => {
4052
4057
  const t = U;
4053
4058
  if (!t) return;
@@ -4059,12 +4064,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4059
4064
  l === "chem" && (i = et(i)), i = X(i);
4060
4065
  const r = i.match(/^\\(mathrm|mathit|mathbf|mathsf|text)\{\\displaylines\{([\s\S]*)\}\}$/);
4061
4066
  if (r) {
4062
- const h = r[1];
4063
- i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${h}{${C.trim()}}`).join(" \\\\ ")}}`;
4067
+ const c = r[1];
4068
+ i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${c}{${C.trim()}}`).join(" \\\\ ")}}`;
4064
4069
  }
4065
4070
  i = i.replace(/[\r\n]+/g, " "), o && o(i), t.setValue ? t.setValue("") : t.value = "", a && a();
4066
4071
  };
4067
- return z(
4072
+ return Q(
4068
4073
  /* @__PURE__ */ e.createElement(
4069
4074
  "div",
4070
4075
  {
@@ -4090,8 +4095,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4090
4095
  key: t.isMatrix ? "matrix-tab" : t.label,
4091
4096
  className: `cme-group-tab${r ? " active" : ""}`,
4092
4097
  type: "button",
4093
- onPointerDown: (h) => {
4094
- h.preventDefault(), p(i), I(null);
4098
+ onPointerDown: (c) => {
4099
+ c.preventDefault(), p(i), I(null);
4095
4100
  }
4096
4101
  },
4097
4102
  t.mathLabel ? /* @__PURE__ */ e.createElement(
@@ -4118,8 +4123,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4118
4123
  ) : t.label
4119
4124
  );
4120
4125
  })), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
4121
- var h;
4122
- const t = ((h = G[d]) == null ? void 0 : h.items) || [], i = t.some((b) => b.type === "sep"), r = [];
4126
+ var c;
4127
+ const t = ((c = G[d]) == null ? void 0 : c.items) || [], i = t.some((b) => b.type === "sep"), r = [];
4123
4128
  if (i) {
4124
4129
  let b = { cols: 2, small: !1, cls: "", items: [], moreItems: null };
4125
4130
  for (const w of t)
@@ -4146,24 +4151,24 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4146
4151
  type: "button",
4147
4152
  className: "cme-more-trigger-btn",
4148
4153
  title: "more",
4149
- onPointerDown: (c) => {
4150
- c.preventDefault();
4154
+ onPointerDown: (h) => {
4155
+ h.preventDefault();
4151
4156
  },
4152
- onClick: (c) => {
4153
- if (c.stopPropagation(), k && k.items === b.moreItems)
4154
- y(null);
4157
+ onClick: (h) => {
4158
+ if (h.stopPropagation(), k && k.items === b.moreItems)
4159
+ E(null);
4155
4160
  else {
4156
- const C = c.currentTarget.getBoundingClientRect(), M = G[d] || {};
4157
- y({ cx: C.left + C.width / 2, y: C.bottom, items: b.moreItems, cols: b.moreCols, isTemplate: M.isTemplate || M.label === "√(□)" || M.isMatrix });
4161
+ const C = h.currentTarget.getBoundingClientRect(), M = G[d] || {};
4162
+ E({ cx: C.left + C.width / 2, y: C.bottom, items: b.moreItems, cols: b.moreCols, isTemplate: M.isTemplate || M.label === "√(□)" || M.isMatrix });
4158
4163
  }
4159
4164
  }
4160
4165
  },
4161
4166
  "▶"
4162
4167
  ),
4163
- b.items.map((c, C) => {
4168
+ b.items.map((h, C) => {
4164
4169
  const M = G[d];
4165
- if (c.type === "dropdown") {
4166
- const N = c.label === "Font...", v = c.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 : "";
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 : "";
4167
4172
  return /* @__PURE__ */ e.createElement(
4168
4173
  "select",
4169
4174
  {
@@ -4171,7 +4176,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4171
4176
  className: `cme-btn template${$ || ee ? " active" : ""}`,
4172
4177
  value: te,
4173
4178
  style: {
4174
- width: c.width || "60px",
4179
+ width: h.width || "60px",
4175
4180
  height: "18px",
4176
4181
  minHeight: "18px",
4177
4182
  maxHeight: "18px",
@@ -4188,12 +4193,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4188
4193
  !V || typeof V.applyStyle != "function" || (V.focus(), N ? V.applyStyle({ fontFamily: Z || "none" }) : v && V.applyStyle({ fontSize: Z ? parseInt(Z, 10) : "auto" }), F());
4189
4194
  }
4190
4195
  },
4191
- /* @__PURE__ */ e.createElement("option", { value: "" }, c.label),
4196
+ /* @__PURE__ */ e.createElement("option", { value: "" }, h.label),
4192
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")),
4193
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"))
4194
4199
  );
4195
4200
  }
4196
- if (M.isMatrix && !c.directInsert)
4201
+ if (M.isMatrix && !h.directInsert)
4197
4202
  return /* @__PURE__ */ e.createElement(
4198
4203
  "div",
4199
4204
  {
@@ -4204,23 +4209,23 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4204
4209
  "button",
4205
4210
  {
4206
4211
  type: "button",
4207
- className: `cme-btn template${c.cls ? ` ${c.cls}` : ""}${M.isMatrix ? " cme-matrix-btn-small" : ""}`,
4208
- title: c.title || c.label || c.insert,
4212
+ className: `cme-btn template${h.cls ? ` ${h.cls}` : ""}${M.isMatrix ? " cme-matrix-btn-small" : ""}`,
4213
+ title: h.title || h.label || h.insert,
4209
4214
  onPointerDown: (N) => {
4210
- if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === c.insert)
4215
+ if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === h.insert)
4211
4216
  I(null);
4212
4217
  else {
4213
4218
  J || (window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0);
4214
4219
  const v = N.currentTarget.getBoundingClientRect();
4215
4220
  I({
4216
- type: c.insert,
4221
+ type: h.insert,
4217
4222
  x: v.left + v.width / 2,
4218
4223
  y: v.bottom
4219
4224
  });
4220
4225
  }
4221
4226
  }
4222
4227
  },
4223
- typeof c.label == "object" ? c.label : /* @__PURE__ */ e.createElement(
4228
+ typeof h.label == "object" ? h.label : /* @__PURE__ */ e.createElement(
4224
4229
  "math-field",
4225
4230
  {
4226
4231
  "read-only": !0,
@@ -4239,29 +4244,29 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4239
4244
  cursor: "pointer"
4240
4245
  }
4241
4246
  },
4242
- pe(c.mathLabel != null ? c.mathLabel : c.insert)
4247
+ pe(h.mathLabel != null ? h.mathLabel : h.insert)
4243
4248
  )
4244
4249
  )
4245
4250
  );
4246
- const R = c.action === "BOLD", H = c.action === "ITALIC", P = c.action === "TEXT_COLOR", He = R && f.bold || H && f.italic || P && f.color !== "none" && f.color !== "black";
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";
4247
4252
  return /* @__PURE__ */ e.createElement(
4248
4253
  "button",
4249
4254
  {
4250
4255
  key: `${M.label}-${w * 4 + C}`,
4251
4256
  type: "button",
4252
- className: `cme-btn${M.isTemplate ? " template" : ""}${c.cls ? ` ${c.cls}` : ""}${He ? " active" : ""}`,
4253
- title: c.title || c.label || c.insert,
4257
+ className: `cme-btn${M.isTemplate ? " template" : ""}${h.cls ? ` ${h.cls}` : ""}${He ? " active" : ""}`,
4258
+ title: h.title || h.label || h.insert,
4254
4259
  onPointerDown: (N) => {
4255
- var $, ee, te, le, Z, V, Ee;
4260
+ var $, ee, te, le, Z, V, ye;
4256
4261
  N.preventDefault();
4257
4262
  const v = s.current;
4258
- if (c.action === "SPECIAL_CHARS") {
4263
+ if (h.action === "SPECIAL_CHARS") {
4259
4264
  const S = N.currentTarget.getBoundingClientRect();
4260
4265
  A({ x: S.left, y: S.bottom + 4 });
4261
- } else if (c.action === "TEXT_COLOR") {
4266
+ } else if (h.action === "TEXT_COLOR") {
4262
4267
  const S = N.currentTarget.getBoundingClientRect();
4263
- E({ x: S.left, y: S.bottom + 4 });
4264
- } else if (c.action === "BOLD") {
4268
+ y({ x: S.left, y: S.bottom + 4 });
4269
+ } else if (h.action === "BOLD") {
4265
4270
  if (v) {
4266
4271
  v.focus();
4267
4272
  const S = !f.bold;
@@ -4273,7 +4278,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4273
4278
  }
4274
4279
  ce((W) => ({ ...W, bold: S }));
4275
4280
  }
4276
- } else if (c.action === "ITALIC") {
4281
+ } else if (h.action === "ITALIC") {
4277
4282
  if (v) {
4278
4283
  v.focus();
4279
4284
  const S = !f.italic;
@@ -4285,16 +4290,16 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4285
4290
  }
4286
4291
  ce((W) => ({ ...W, italic: S }));
4287
4292
  }
4288
- } else c.action === "UNDO" ? ($ = s.current) == null || $.executeCommand("undo") : c.action === "REDO" ? (ee = s.current) == null || ee.executeCommand("redo") : c.action === "CUT" ? ((te = s.current) == null || te.focus(), (le = s.current) == null || le.executeCommand("cutToClipboard")) : c.action === "COPY" ? ((Z = s.current) == null || Z.focus(), (V = s.current) == null || V.executeCommand("copyToClipboard")) : c.action === "PASTE" ? ((Ee = s.current) == null || Ee.focus(), navigator.clipboard.readText().then((S) => {
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) => {
4289
4294
  var D;
4290
4295
  (D = s.current) == null || D.executeCommand(["insert", S]);
4291
4296
  }).catch((S) => {
4292
4297
  var D;
4293
4298
  (D = s.current) == null || D.executeCommand("pasteFromClipboard");
4294
- })) : Q(c.insert);
4299
+ })) : z(h.insert);
4295
4300
  }
4296
4301
  },
4297
- (M.isTemplate || M.label === "√(□)" || M.isMatrix || c.isWidget) && c.insert && !c.action && !c.forceLabel ? /* @__PURE__ */ e.createElement(
4302
+ (M.isTemplate || M.label === "√(□)" || M.isMatrix || h.isWidget) && h.insert && !h.action && !h.forceLabel ? /* @__PURE__ */ e.createElement(
4298
4303
  "math-field",
4299
4304
  {
4300
4305
  "read-only": !0,
@@ -4313,24 +4318,24 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4313
4318
  cursor: "pointer"
4314
4319
  }
4315
4320
  },
4316
- pe(c.insert)
4317
- ) : c.label
4321
+ pe(h.insert)
4322
+ ) : h.label
4318
4323
  );
4319
4324
  })
4320
4325
  ));
4321
4326
  })())),
4322
- k && z(/* @__PURE__ */ e.createElement(
4327
+ k && Q(/* @__PURE__ */ e.createElement(
4323
4328
  "div",
4324
4329
  {
4325
4330
  ref: (t) => {
4326
4331
  t && requestAnimationFrame(() => {
4327
4332
  const i = t.getBoundingClientRect(), r = document.querySelector(".cme-editor-popup");
4328
- let h = k.cx - i.width / 2, b = k.y;
4333
+ let c = k.cx - i.width / 2, b = k.y;
4329
4334
  if (r) {
4330
4335
  const w = r.getBoundingClientRect();
4331
- h + i.width > w.right - 4 && (h = w.right - i.width - 4), h < w.left + 4 && (h = w.left + 4), b + i.height > w.bottom - 4 && (b = w.bottom - i.height - 4);
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);
4332
4337
  }
4333
- h + i.width > window.innerWidth - 4 && (h = window.innerWidth - i.width - 4), b + i.height > window.innerHeight - 4 && (b = window.innerHeight - i.height - 4), h < 4 && (h = 4), t.style.left = `${h}px`, t.style.top = `${b}px`, t.style.transform = "none";
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";
4334
4339
  });
4335
4340
  },
4336
4341
  className: "cme-more-popup",
@@ -4351,7 +4356,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4351
4356
  className: `cme-more-popup-btn ${t.cls || ""}`,
4352
4357
  title: t.title || t.label || t.insert,
4353
4358
  onPointerDown: (r) => {
4354
- r.preventDefault(), Q(t.insert), y(null);
4359
+ r.preventDefault(), z(t.insert), E(null);
4355
4360
  }
4356
4361
  },
4357
4362
  t.insert && !t.action && (t.cls === "template" || t.isWidget) ? /* @__PURE__ */ e.createElement(
@@ -4394,7 +4399,10 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4394
4399
  "math-field",
4395
4400
  {
4396
4401
  ref: (t) => {
4397
- 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
+ })));
4398
4406
  },
4399
4407
  class: "cme-mathfield",
4400
4408
  tabIndex: 0,
@@ -4411,7 +4419,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4411
4419
  } }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
4412
4420
  t.stopPropagation(), Y(!1);
4413
4421
  } }, "Cancel")))),
4414
- x && z(
4422
+ x && Q(
4415
4423
  /* @__PURE__ */ e.createElement(
4416
4424
  tt,
4417
4425
  {
@@ -4429,21 +4437,21 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4429
4437
  ),
4430
4438
  document.body
4431
4439
  ),
4432
- g && z(
4440
+ g && Q(
4433
4441
  /* @__PURE__ */ e.createElement(
4434
- Qe,
4442
+ ze,
4435
4443
  {
4436
4444
  isOpen: !!g,
4437
4445
  position: g,
4438
4446
  onClose: () => A(null),
4439
4447
  onInsert: (t) => {
4440
- Q(t), A(null);
4448
+ z(t), A(null);
4441
4449
  }
4442
4450
  }
4443
4451
  ),
4444
4452
  document.body
4445
4453
  ),
4446
- u && z(
4454
+ u && Q(
4447
4455
  /* @__PURE__ */ e.createElement(
4448
4456
  "div",
4449
4457
  {
@@ -4505,8 +4513,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4505
4513
  },
4506
4514
  onPointerDown: (r) => {
4507
4515
  r.preventDefault(), r.stopPropagation();
4508
- const h = s.current;
4509
- h && typeof h.applyStyle == "function" && (h.focus(), h.applyStyle({ color: t === "black" ? "none" : t }), F()), E(null);
4516
+ const c = s.current;
4517
+ c && typeof c.applyStyle == "function" && (c.focus(), c.applyStyle({ color: t === "black" ? "none" : t }), F()), y(null);
4510
4518
  }
4511
4519
  }
4512
4520
  );