digi-mathchem-editor 1.0.12 → 1.0.13

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.
@@ -420,6 +420,9 @@ function Qe({ isOpen: l, onClose: o, onInsert: a, position: c }) {
420
420
  g.char
421
421
  ))))), w.length === 0 && /* @__PURE__ */ e.createElement("div", { className: "scm-no-results" }, "No characters found.")))));
422
422
  }
423
+ const ze = "1.0.13", Xe = {
424
+ version: ze
425
+ };
423
426
  window.__cme_macros = {
424
427
  ...window.__cme_macros,
425
428
  cmeLeftRightAbove: {
@@ -448,7 +451,7 @@ window.__cme_macros = {
448
451
  typeof window < "u" && (window.MathfieldElement ? window.MathfieldElement.fontsDirectory = "https://cdn.jsdelivr.net/npm/mathlive/dist/fonts" : ye && (ye.fontsDirectory = "https://cdn.jsdelivr.net/npm/mathlive/dist/fonts"));
449
452
  window.__ckMathWidgets = window.__ckMathWidgets || /* @__PURE__ */ new Map();
450
453
  window.__ckMathWidgetClickHandler = null;
451
- function ze(l) {
454
+ function Ke(l) {
452
455
  var a, c, n, h, d;
453
456
  if (!l) return null;
454
457
  const o = typeof l.composedPath == "function" ? l.composedPath() : [l];
@@ -520,7 +523,7 @@ function Se(l, o) {
520
523
  return !1;
521
524
  }
522
525
  }
523
- function Xe(l, o) {
526
+ function _e(l, o) {
524
527
  var p;
525
528
  if (!l || !o) return null;
526
529
  const a = l.model.document.selection.getSelectedElement();
@@ -548,7 +551,7 @@ function Te(l, o, a, c) {
548
551
  l._mathWidgetOpening = !0, queueMicrotask(() => {
549
552
  l._mathWidgetOpening = !1;
550
553
  });
551
- const n = Se(l, o) ? o : Xe(l, c), h = (n == null ? void 0 : n.getAttribute("latex")) || a || oe(c);
554
+ const n = Se(l, o) ? o : _e(l, c), h = (n == null ? void 0 : n.getAttribute("latex")) || a || oe(c);
552
555
  if (!h) return;
553
556
  n && l.model.change((p) => {
554
557
  p.setSelection(n, "on");
@@ -562,7 +565,7 @@ function Te(l, o, a, c) {
562
565
  }
563
566
  }));
564
567
  }
565
- function Ke(l, o) {
568
+ function Ye(l, o) {
566
569
  if (!o || o._ckMathClickBound) return;
567
570
  o._ckMathClickBound = !0;
568
571
  const a = (c) => {
@@ -571,7 +574,7 @@ function Ke(l, o) {
571
574
  };
572
575
  o.addEventListener("mousedown", a, !0), o.addEventListener("click", a, !0);
573
576
  }
574
- const _e = [
577
+ const Ge = [
575
578
  {
576
579
  label: "√(□)",
577
580
  fontSize: "9px",
@@ -2007,7 +2010,7 @@ const _e = [
2007
2010
  // { type: 'sep', cols: 2, cls: 'cme-trig-subgroup' }
2008
2011
  // ]
2009
2012
  // },
2010
- ], Ye = [
2013
+ ], $e = [
2011
2014
  {
2012
2015
  label: "H₂O",
2013
2016
  isChem: !0,
@@ -3609,7 +3612,7 @@ const _e = [
3609
3612
  // ]
3610
3613
  // },
3611
3614
  ];
3612
- function Ge(l = "") {
3615
+ function et(l = "") {
3613
3616
  if (String(l).match(/^\\ce\{([\s\S]*)\}$/) || l.includes("\\class{cme-"))
3614
3617
  return l;
3615
3618
  const a = l.replace(/\\text\{([^}]*)\}/g, "$1").replace(/\$/g, "").trim();
@@ -3618,7 +3621,7 @@ function Ge(l = "") {
3618
3621
  function pe(l) {
3619
3622
  return l === "matrix" ? "\\begin{matrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{matrix}" : l === "bmatrix" ? "\\begin{bmatrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{bmatrix}" : l === "pmatrix" ? "\\begin{pmatrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{pmatrix}" : l === "vmatrix" ? "\\begin{vmatrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{vmatrix}" : l.replace(/#0|#\?/g, "\\placeholder{}");
3620
3623
  }
3621
- class ot extends Ve {
3624
+ class ct extends Ve {
3622
3625
  static get pluginName() {
3623
3626
  return "MathInlinePlugin";
3624
3627
  }
@@ -3683,7 +3686,7 @@ class ot extends Ve {
3683
3686
  customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)), I.appendChild(b);
3684
3687
  const u = () => {
3685
3688
  const E = I.parentElement;
3686
- E && Ke(o, E);
3689
+ E && Ye(o, E);
3687
3690
  };
3688
3691
  u(), requestAnimationFrame(u);
3689
3692
  }
@@ -3693,7 +3696,7 @@ class ot extends Ve {
3693
3696
  });
3694
3697
  const a = o.editing.view.document;
3695
3698
  this.listenTo(a, "mousedown", (c, n) => {
3696
- const h = ze(n.domTarget);
3699
+ const h = Ke(n.domTarget);
3697
3700
  h && n.domEvent.button === 0 && (c.stop(), n.preventDefault(), Te(
3698
3701
  o,
3699
3702
  null,
@@ -3754,7 +3757,7 @@ class ot extends Ve {
3754
3757
  });
3755
3758
  }
3756
3759
  }
3757
- function $e({ matrixType: l, x: o, y: a, onSelect: c, onMouseEnter: n, onMouseLeave: h }) {
3760
+ function tt({ matrixType: l, x: o, y: a, onSelect: c, onMouseEnter: n, onMouseLeave: h }) {
3758
3761
  const [d, p] = B({ r: 2, c: 2 }), w = Math.max(10, parseInt(d.r, 10) || 0), I = Math.max(10, parseInt(d.c, 10) || 0), b = (g) => {
3759
3762
  const y = g.target.value;
3760
3763
  if (y === "") {
@@ -3846,7 +3849,7 @@ function $e({ matrixType: l, x: o, y: a, onSelect: c, onMouseEnter: n, onMouseLe
3846
3849
  );
3847
3850
  }
3848
3851
  let F = !1, be = null, V = null;
3849
- function et({ mode: l, onInsert: o, onClose: a, initialLatex: c, isEditing: n }) {
3852
+ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: c, isEditing: n }) {
3850
3853
  const h = re(null), [d, p] = B(0), [w, I] = B(null), [b, A] = B(null), [u, E] = B(null), [g, y] = B(null);
3851
3854
  re(null);
3852
3855
  const [T, C] = B({ x: 0, y: 0 }), [U, X] = B(!1), Z = re({ x: 0, y: 0 }), [K, ke] = B(!1), [We, ue] = B(!1), [Ie, _] = B(!1), se = re(null);
@@ -3882,7 +3885,7 @@ function et({ mode: l, onInsert: o, onClose: a, initialLatex: c, isEditing: n })
3882
3885
  height: r.height
3883
3886
  };
3884
3887
  }
3885
- }, Y = l === "math" ? _e : Ye, [f, ce] = B({
3888
+ }, Y = l === "math" ? Ge : $e, [f, ce] = B({
3886
3889
  bold: !1,
3887
3890
  italic: !1,
3888
3891
  color: "none",
@@ -4050,7 +4053,7 @@ function et({ mode: l, onInsert: o, onClose: a, initialLatex: c, isEditing: n })
4050
4053
  a && a();
4051
4054
  return;
4052
4055
  }
4053
- l === "chem" && (i = Ge(i)), i = z(i);
4056
+ l === "chem" && (i = et(i)), i = z(i);
4054
4057
  const r = i.match(/^\\(mathrm|mathit|mathbf|mathsf|text)\{\\displaylines\{([\s\S]*)\}\}$/);
4055
4058
  if (r) {
4056
4059
  const s = r[1];
@@ -4394,7 +4397,7 @@ function et({ mode: l, onInsert: o, onClose: a, initialLatex: c, isEditing: n })
4394
4397
  }
4395
4398
  )
4396
4399
  ),
4397
- /* @__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: we }, "Cancel"), /* @__PURE__ */ e.createElement("span", { style: { marginLeft: "auto", fontSize: "11px", color: "#888", alignSelf: "center", marginRight: "10px" } }, "v1.0.12")),
4400
+ /* @__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: we }, "Cancel"), /* @__PURE__ */ e.createElement("span", { style: { marginLeft: "auto", fontSize: "11px", color: "#888", alignSelf: "center", marginRight: "10px" } }, "v", Xe.version)),
4398
4401
  Ie && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
4399
4402
  t.stopPropagation(), _(!1);
4400
4403
  } }, /* @__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) => {
@@ -4404,7 +4407,7 @@ function et({ mode: l, onInsert: o, onClose: a, initialLatex: c, isEditing: n })
4404
4407
  } }, "Cancel")))),
4405
4408
  w && Q(
4406
4409
  /* @__PURE__ */ e.createElement(
4407
- $e,
4410
+ tt,
4408
4411
  {
4409
4412
  matrixType: w.type,
4410
4413
  x: w.x,
@@ -4509,8 +4512,8 @@ function et({ mode: l, onInsert: o, onClose: a, initialLatex: c, isEditing: n })
4509
4512
  document.body
4510
4513
  );
4511
4514
  }
4512
- const st = ({ isOpen: l, mode: o, initialValue: a, onInsert: c, onClose: n }) => l ? /* @__PURE__ */ e.createElement(
4513
- et,
4515
+ const ht = ({ isOpen: l, mode: o, initialValue: a, onInsert: c, onClose: n }) => l ? /* @__PURE__ */ e.createElement(
4516
+ lt,
4514
4517
  {
4515
4518
  mode: o,
4516
4519
  onInsert: c,
@@ -4521,7 +4524,7 @@ const st = ({ isOpen: l, mode: o, initialValue: a, onInsert: c, onClose: n }) =>
4521
4524
  ) : null;
4522
4525
  export {
4523
4526
  qe as CME_SHADOW_DOM_CSS,
4524
- st as CustomMathEditor,
4525
- ot as MathInlinePlugin,
4526
- st as default
4527
+ ht as CustomMathEditor,
4528
+ ct as MathInlinePlugin,
4529
+ ht as default
4527
4530
  };