digi-mathchem-editor 1.0.16 → 1.0.17

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 I, 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 }) {
364
- const [n, s] = B(""), [d, p] = B("All");
363
+ function ze({ isOpen: l, onClose: o, onInsert: a, position: m }) {
364
+ const [n, s] = I(""), [d, p] = I("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]), B = 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(B).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.17", 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,
@@ -3654,7 +3659,7 @@ class ct extends Ve {
3654
3659
  class: "ck-math-widget-inner",
3655
3660
  style: "display:inline-block;vertical-align:middle;margin:0 2px;cursor:pointer;width:auto;max-width:100%;pointer-events:none;"
3656
3661
  },
3657
- (I) => {
3662
+ (B) => {
3658
3663
  const g = document.createElement("math-field");
3659
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 2px", g.style.margin = "0", g.style.pointerEvents = "none";
3660
3665
  const A = () => {
@@ -3663,30 +3668,30 @@ class ct extends Ve {
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
- customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)), I.appendChild(g);
3691
+ customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)), B.appendChild(g);
3687
3692
  const u = () => {
3688
- const E = I.parentElement;
3689
- E && Ye(o, E);
3693
+ const y = B.parentElement;
3694
+ y && Ye(o, y);
3690
3695
  };
3691
3696
  u(), requestAnimationFrame(u);
3692
3697
  }
@@ -3710,9 +3715,9 @@ class ct extends Ve {
3710
3715
  const p = d.writer, x = d.mapper.toViewElement(s.item);
3711
3716
  if (x) {
3712
3717
  p.setAttribute("data-latex", s.attributeNewValue, x);
3713
- const I = o.editing.view.domConverter.mapViewToDom(x);
3714
- if (I) {
3715
- const g = I.querySelector("math-field");
3718
+ const B = o.editing.view.domConverter.mapViewToDom(x);
3719
+ if (B) {
3720
+ const g = B.querySelector("math-field");
3716
3721
  if (g) {
3717
3722
  let A = ge(ne(X(de(s.attributeNewValue))));
3718
3723
  A.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(A.trim()) && (A = A.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")), g.removeAttribute("read-only");
@@ -3758,31 +3763,31 @@ class ct extends Ve {
3758
3763
  }
3759
3764
  }
3760
3765
  function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLeave: s }) {
3761
- 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 === "") {
3766
+ const [d, p] = I({ r: 2, c: 2 }), x = Math.max(10, parseInt(d.r, 10) || 0), B = Math.max(10, parseInt(d.c, 10) || 0), g = (k) => {
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: B }).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,24 +3840,24 @@ 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] = I(0), [x, B] = I(null), [g, A] = I(null), [u, y] = I(null), [k, E] = I(null);
3854
3859
  re(null);
3855
- 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);
3860
+ const [T, L] = I({ x: 0, y: 0 }), [q, K] = I(!1), j = re({ x: 0, y: 0 }), [_, ke] = I(!1), [Be, ue] = I(!1), [Ie, Y] = I(!1), se = re(null);
3856
3861
  O(() => {
3857
3862
  const t = (r) => {
3858
3863
  if (!q) return;
@@ -3888,7 +3893,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
3888
3893
  height: b.height
3889
3894
  };
3890
3895
  }
3891
- }, G = l === "math" ? Ge : $e, [f, ce] = B({
3896
+ }, G = l === "math" ? Ge : $e, [f, ce] = I({
3892
3897
  bold: !1,
3893
3898
  italic: !1,
3894
3899
  color: "none",
@@ -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") && B(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);
@@ -4024,7 +4029,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
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) => {
@@ -4034,8 +4039,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4034
4039
  h += "#?", w < r - 1 && (h += " & ");
4035
4040
  b < i - 1 && (h += " \\\\ ");
4036
4041
  }
4037
- h += ` \\end{${t}}`, Q(h);
4038
- }, [Q]), Ne = (t) => {
4042
+ h += ` \\end{${t}}`, z(h);
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 });
@@ -4064,11 +4069,11 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
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
  {
4071
- className: `cme-editor-popup ${_ ? "maximized" : ""} ${Ie ? "minimized" : ""}`,
4076
+ className: `cme-editor-popup ${_ ? "maximized" : ""} ${Be ? "minimized" : ""}`,
4072
4077
  style: { transform: `translate(${T.x}px, ${T.y}px)` },
4073
4078
  onPointerDown: (t) => t.stopPropagation()
4074
4079
  },
@@ -4091,7 +4096,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4091
4096
  className: `cme-group-tab${r ? " active" : ""}`,
4092
4097
  type: "button",
4093
4098
  onPointerDown: (h) => {
4094
- h.preventDefault(), p(i), I(null);
4099
+ h.preventDefault(), p(i), B(null);
4095
4100
  }
4096
4101
  },
4097
4102
  t.mathLabel ? /* @__PURE__ */ e.createElement(
@@ -4151,10 +4156,10 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4151
4156
  },
4152
4157
  onClick: (c) => {
4153
4158
  if (c.stopPropagation(), k && k.items === b.moreItems)
4154
- y(null);
4159
+ E(null);
4155
4160
  else {
4156
4161
  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 });
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
  },
@@ -4208,11 +4213,11 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4208
4213
  title: c.title || c.label || c.insert,
4209
4214
  onPointerDown: (N) => {
4210
4215
  if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === c.insert)
4211
- I(null);
4216
+ B(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
- I({
4220
+ B({
4216
4221
  type: c.insert,
4217
4222
  x: v.left + v.width / 2,
4218
4223
  y: v.bottom
@@ -4252,7 +4257,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4252
4257
  className: `cme-btn${M.isTemplate ? " template" : ""}${c.cls ? ` ${c.cls}` : ""}${He ? " active" : ""}`,
4253
4258
  title: c.title || c.label || c.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
4263
  if (c.action === "SPECIAL_CHARS") {
@@ -4260,7 +4265,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4260
4265
  A({ x: S.left, y: S.bottom + 4 });
4261
4266
  } else if (c.action === "TEXT_COLOR") {
4262
4267
  const S = N.currentTarget.getBoundingClientRect();
4263
- E({ x: S.left, y: S.bottom + 4 });
4268
+ y({ x: S.left, y: S.bottom + 4 });
4264
4269
  } else if (c.action === "BOLD") {
4265
4270
  if (v) {
4266
4271
  v.focus();
@@ -4285,13 +4290,13 @@ 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 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" ? ((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(c.insert);
4295
4300
  }
4296
4301
  },
4297
4302
  (M.isTemplate || M.label === "√(□)" || M.isMatrix || c.isWidget) && c.insert && !c.action && !c.forceLabel ? /* @__PURE__ */ e.createElement(
@@ -4319,7 +4324,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
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) => {
@@ -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(
@@ -4404,14 +4409,14 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4404
4409
  )
4405
4410
  ),
4406
4411
  /* @__PURE__ */ e.createElement("div", { className: "cme-popup-footer" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-insert-btn", onClick: Oe }, n ? "Update" : "Insert"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-cancel-btn", onClick: xe }, "Cancel"), /* @__PURE__ */ e.createElement("span", { style: { marginLeft: "auto", fontSize: "11px", color: "#888", alignSelf: "center", marginRight: "10px" } }, "v", Xe.version)),
4407
- Be && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onPointerDown: (t) => {
4412
+ Ie && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onPointerDown: (t) => {
4408
4413
  t.stopPropagation(), Y(!1);
4409
4414
  } }, /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-modal", onPointerDown: (t) => t.stopPropagation() }, /* @__PURE__ */ e.createElement("p", null, "Are you sure you want to leave? The changes you made will be lost."), /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-actions" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-close-btn", onClick: (t) => {
4410
4415
  t.stopPropagation(), Y(!1), a && a();
4411
4416
  } }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
4412
4417
  t.stopPropagation(), Y(!1);
4413
4418
  } }, "Cancel")))),
4414
- x && z(
4419
+ x && Q(
4415
4420
  /* @__PURE__ */ e.createElement(
4416
4421
  tt,
4417
4422
  {
@@ -4419,7 +4424,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4419
4424
  x: x.x,
4420
4425
  y: x.y,
4421
4426
  onSelect: (t, i) => {
4422
- De(x.type, t, i), I(null);
4427
+ De(x.type, t, i), B(null);
4423
4428
  },
4424
4429
  onMouseEnter: () => {
4425
4430
  },
@@ -4429,21 +4434,21 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4429
4434
  ),
4430
4435
  document.body
4431
4436
  ),
4432
- g && z(
4437
+ g && Q(
4433
4438
  /* @__PURE__ */ e.createElement(
4434
- Qe,
4439
+ ze,
4435
4440
  {
4436
4441
  isOpen: !!g,
4437
4442
  position: g,
4438
4443
  onClose: () => A(null),
4439
4444
  onInsert: (t) => {
4440
- Q(t), A(null);
4445
+ z(t), A(null);
4441
4446
  }
4442
4447
  }
4443
4448
  ),
4444
4449
  document.body
4445
4450
  ),
4446
- u && z(
4451
+ u && Q(
4447
4452
  /* @__PURE__ */ e.createElement(
4448
4453
  "div",
4449
4454
  {
@@ -4506,7 +4511,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n })
4506
4511
  onPointerDown: (r) => {
4507
4512
  r.preventDefault(), r.stopPropagation();
4508
4513
  const h = s.current;
4509
- h && typeof h.applyStyle == "function" && (h.focus(), h.applyStyle({ color: t === "black" ? "none" : t }), F()), E(null);
4514
+ h && typeof h.applyStyle == "function" && (h.focus(), h.applyStyle({ color: t === "black" ? "none" : t }), F()), y(null);
4510
4515
  }
4511
4516
  }
4512
4517
  );