digi-mathchem-editor 1.0.4 → 1.0.5

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 W, useEffect as O, useMemo as we, useRef as le, useCallback as ce } from "react";
2
- import { createPortal as Q } from "react-dom";
1
+ import e, { useState as W, useEffect as O, useMemo as we, useRef as te, useCallback as ce } from "react";
2
+ import { createPortal as le } from "react-dom";
3
3
  import { FontAwesomeIcon as ie } from "@fortawesome/react-fontawesome";
4
4
  import { faBold as fe, faItalic as ve } from "@fortawesome/free-solid-svg-icons";
5
5
  import { MathfieldElement as xe } from "mathlive";
@@ -3752,15 +3752,15 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: r, onMouseLe
3752
3752
  onMouseLeave: h
3753
3753
  },
3754
3754
  /* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length: x }).map((p, f) => /* @__PURE__ */ e.createElement("div", { key: f, className: "cme-matrix-hover-row" }, Array.from({ length: B }).map((C, M) => {
3755
- const P = parseInt(m.r, 10) || 0, X = parseInt(m.c, 10) || 0, J = f < P && M < X;
3755
+ const P = parseInt(m.r, 10) || 0, Q = parseInt(m.c, 10) || 0, J = f < P && M < Q;
3756
3756
  return /* @__PURE__ */ e.createElement(
3757
3757
  "div",
3758
3758
  {
3759
3759
  key: `${f}-${M}`,
3760
3760
  className: `cme-matrix-hover-cell${J ? " selected" : ""}`,
3761
3761
  onMouseEnter: () => k({ r: f + 1, c: M + 1 }),
3762
- onClick: (K) => {
3763
- K.preventDefault(), K.stopPropagation(), s(f + 1, M + 1);
3762
+ onClick: (X) => {
3763
+ X.preventDefault(), X.stopPropagation(), s(f + 1, M + 1);
3764
3764
  }
3765
3765
  }
3766
3766
  );
@@ -3804,9 +3804,9 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: r, onMouseLe
3804
3804
  }
3805
3805
  let Z = !1, de = null, U = null;
3806
3806
  function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r }) {
3807
- const h = le(null), [m, k] = W(0), [x, B] = W(null), [E, D] = W(null), [g, y] = W(null), [p, f] = W(null);
3808
- le(null);
3809
- const [C, M] = W({ x: 0, y: 0 }), [P, X] = W(!1), J = le({ x: 0, y: 0 }), [K, be] = W(!1), [Te, ge] = W(!1), [We, Y] = W(!1), oe = le(null);
3807
+ const h = te(null), [m, k] = W(0), [x, B] = W(null), [E, D] = W(null), [g, y] = W(null), [p, f] = W(null);
3808
+ te(null);
3809
+ const [C, M] = W({ x: 0, y: 0 }), [P, Q] = W(!1), J = te({ x: 0, y: 0 }), [X, be] = W(!1), [Te, ge] = W(!1), [We, K] = W(!1), oe = te(null);
3810
3810
  O(() => {
3811
3811
  const t = (a) => {
3812
3812
  if (!P) return;
@@ -3816,14 +3816,14 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
3816
3816
  d < c && (d = c), d > T && (d = T), b < L && (b = L), b > R && (b = R);
3817
3817
  }
3818
3818
  M({ x: d, y: b });
3819
- }, i = () => X(!1);
3819
+ }, i = () => Q(!1);
3820
3820
  return P && (window.addEventListener("mousemove", t), window.addEventListener("mouseup", i)), () => {
3821
3821
  window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", i);
3822
3822
  };
3823
3823
  }, [P]);
3824
3824
  const Ie = (t) => {
3825
3825
  if (t.target.closest(".cme-popup-controls")) return;
3826
- X(!0), J.current = {
3826
+ Q(!0), J.current = {
3827
3827
  x: t.clientX - C.x,
3828
3828
  y: t.clientY - C.y
3829
3829
  };
@@ -3945,8 +3945,8 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
3945
3945
  let R = L;
3946
3946
  const z = u.fontSize === "auto" ? 5 : parseInt(u.fontSize, 10);
3947
3947
  if (z !== 5) {
3948
- const _ = { 1: "\\tiny", 2: "\\scriptsize", 3: "\\footnotesize", 4: "\\small", 5: "\\normalsize", 6: "\\large", 7: "\\Large", 8: "\\LARGE", 9: "\\huge", 10: "\\Huge" };
3949
- _[z] && (R = `{${_[z]} ${R}}`);
3948
+ const Y = { 1: "\\tiny", 2: "\\scriptsize", 3: "\\footnotesize", 4: "\\small", 5: "\\normalsize", 6: "\\large", 7: "\\Large", 8: "\\LARGE", 9: "\\huge", 10: "\\Huge" };
3949
+ Y[z] && (R = `{${Y[z]} ${R}}`);
3950
3950
  }
3951
3951
  u.color !== "none" && (R = `\\textcolor{${u.color}}{${R}}`), t.executeCommand(["insert", R]);
3952
3952
  return;
@@ -4000,7 +4000,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4000
4000
  return;
4001
4001
  }
4002
4002
  const a = i.getValue ? i.getValue("latex") : i.value, d = s || "";
4003
- !a || a.trim() === "" || a === d ? n && n() : Y(!0);
4003
+ !a || a.trim() === "" || a === d ? n && n() : K(!0);
4004
4004
  }, Re = () => {
4005
4005
  const t = U;
4006
4006
  if (!t) return;
@@ -4014,7 +4014,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4014
4014
  return /* @__PURE__ */ e.createElement(
4015
4015
  "div",
4016
4016
  {
4017
- className: `cme-editor-popup ${K ? "maximized" : ""} ${Te ? "minimized" : ""}`,
4017
+ className: `cme-editor-popup ${X ? "maximized" : ""} ${Te ? "minimized" : ""}`,
4018
4018
  style: { transform: `translate(${C.x}px, ${C.y}px)` },
4019
4019
  onMouseDown: (t) => t.stopPropagation()
4020
4020
  },
@@ -4105,13 +4105,13 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4105
4105
  b.items.map((c, T) => {
4106
4106
  const L = q[m];
4107
4107
  if (c.type === "dropdown") {
4108
- const N = c.label === "Font...", v = c.label === "Size", G = N && u.fontFamily !== "none", $ = v && u.fontSize !== "auto" && u.fontSize !== "5", ee = N ? u.fontFamily === "none" ? "" : u.fontFamily : v ? u.fontSize === "auto" || u.fontSize === "5" ? "" : u.fontSize : "";
4108
+ const N = c.label === "Font...", v = c.label === "Size", _ = N && u.fontFamily !== "none", G = v && u.fontSize !== "auto" && u.fontSize !== "5", $ = N ? u.fontFamily === "none" ? "" : u.fontFamily : v ? u.fontSize === "auto" || u.fontSize === "5" ? "" : u.fontSize : "";
4109
4109
  return /* @__PURE__ */ e.createElement(
4110
4110
  "select",
4111
4111
  {
4112
4112
  key: T,
4113
- className: `cme-btn template${G || $ ? " active" : ""}`,
4114
- value: ee,
4113
+ className: `cme-btn template${_ || G ? " active" : ""}`,
4114
+ value: $,
4115
4115
  style: {
4116
4116
  width: c.width || "60px",
4117
4117
  height: "18px",
@@ -4125,8 +4125,8 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4125
4125
  margin: "2px 0",
4126
4126
  gridColumn: b.cols === 3 || b.cols === 1 ? "span 1" : "span 2"
4127
4127
  },
4128
- onChange: (te) => {
4129
- const F = te.target.value, H = U;
4128
+ onChange: (ee) => {
4129
+ const F = ee.target.value, H = U;
4130
4130
  !H || typeof H.applyStyle != "function" || (H.focus(), N ? H.applyStyle({ fontFamily: F || "none" }) : v && H.applyStyle({ fontSize: F ? parseInt(F, 10) : "auto" }), V());
4131
4131
  }
4132
4132
  },
@@ -4185,7 +4185,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4185
4185
  )
4186
4186
  )
4187
4187
  );
4188
- const R = c.action === "BOLD", z = c.action === "ITALIC", _ = c.action === "TEXT_COLOR", Oe = R && u.bold || z && u.italic || _ && u.color !== "none" && u.color !== "black";
4188
+ const R = c.action === "BOLD", z = c.action === "ITALIC", Y = c.action === "TEXT_COLOR", Oe = R && u.bold || z && u.italic || Y && u.color !== "none" && u.color !== "black";
4189
4189
  return /* @__PURE__ */ e.createElement(
4190
4190
  "button",
4191
4191
  {
@@ -4194,7 +4194,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4194
4194
  className: `cme-btn${L.isTemplate ? " template" : ""}${c.cls ? ` ${c.cls}` : ""}${Oe ? " active" : ""}`,
4195
4195
  title: c.title || c.label || c.insert,
4196
4196
  onMouseDown: (N) => {
4197
- var G, $, ee, te, F, H, ue;
4197
+ var _, G, $, ee, F, H, ue;
4198
4198
  N.preventDefault();
4199
4199
  const v = h.current;
4200
4200
  if (c.action === "SPECIAL_CHARS") {
@@ -4227,7 +4227,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4227
4227
  }
4228
4228
  se((S) => ({ ...S, italic: A }));
4229
4229
  }
4230
- } else c.action === "UNDO" ? (G = h.current) == null || G.executeCommand("undo") : c.action === "REDO" ? ($ = h.current) == null || $.executeCommand("redo") : c.action === "CUT" ? ((ee = h.current) == null || ee.focus(), (te = h.current) == null || te.executeCommand("cutToClipboard")) : c.action === "COPY" ? ((F = h.current) == null || F.focus(), (H = h.current) == null || H.executeCommand("copyToClipboard")) : c.action === "PASTE" ? ((ue = h.current) == null || ue.focus(), navigator.clipboard.readText().then((A) => {
4230
+ } else c.action === "UNDO" ? (_ = h.current) == null || _.executeCommand("undo") : c.action === "REDO" ? (G = h.current) == null || G.executeCommand("redo") : c.action === "CUT" ? (($ = h.current) == null || $.focus(), (ee = h.current) == null || ee.executeCommand("cutToClipboard")) : c.action === "COPY" ? ((F = h.current) == null || F.focus(), (H = h.current) == null || H.executeCommand("copyToClipboard")) : c.action === "PASTE" ? ((ue = h.current) == null || ue.focus(), navigator.clipboard.readText().then((A) => {
4231
4231
  var I;
4232
4232
  (I = h.current) == null || I.executeCommand(["insert", A]);
4233
4233
  }).catch((A) => {
@@ -4261,7 +4261,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4261
4261
  })
4262
4262
  ));
4263
4263
  })())),
4264
- p && Q(/* @__PURE__ */ e.createElement(
4264
+ p && le(/* @__PURE__ */ e.createElement(
4265
4265
  "div",
4266
4266
  {
4267
4267
  ref: (t) => {
@@ -4345,17 +4345,14 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4345
4345
  )
4346
4346
  ),
4347
4347
  /* @__PURE__ */ e.createElement("div", { className: "cme-popup-footer" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-insert-btn", onClick: Re }, r ? "Update" : "Insert"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-cancel-btn", onClick: ke }, "Cancel")),
4348
- We && Q(
4349
- /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
4350
- t.stopPropagation(), Y(!1);
4351
- } }, /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-modal", onMouseDown: (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) => {
4352
- t.stopPropagation(), Y(!1), n && n();
4353
- } }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
4354
- t.stopPropagation(), Y(!1);
4355
- } }, "Cancel")))),
4356
- document.body
4357
- ),
4358
- x && Q(
4348
+ We && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
4349
+ t.stopPropagation(), K(!1);
4350
+ } }, /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-modal", onMouseDown: (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) => {
4351
+ t.stopPropagation(), K(!1), n && n();
4352
+ } }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
4353
+ t.stopPropagation(), K(!1);
4354
+ } }, "Cancel")))),
4355
+ x && le(
4359
4356
  /* @__PURE__ */ e.createElement(
4360
4357
  Ge,
4361
4358
  {
@@ -4373,7 +4370,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4373
4370
  ),
4374
4371
  document.body
4375
4372
  ),
4376
- E && Q(
4373
+ E && le(
4377
4374
  /* @__PURE__ */ e.createElement(
4378
4375
  je,
4379
4376
  {
@@ -4387,7 +4384,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
4387
4384
  ),
4388
4385
  document.body
4389
4386
  ),
4390
- g && Q(
4387
+ g && le(
4391
4388
  /* @__PURE__ */ e.createElement(
4392
4389
  "div",
4393
4390
  {