digi-mathchem-editor 1.0.15 → 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";
@@ -302,9 +302,9 @@ const Ce = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AA
302
302
  function ie(l) {
303
303
  const o = l == null ? void 0 : l.shadowRoot;
304
304
  if (!o) return;
305
- const a = l.hasAttribute("read-only") || l.hasAttribute("readonly"), h = a ? "readonly" : "editable";
305
+ const a = l.hasAttribute("read-only") || l.hasAttribute("readonly"), m = a ? "readonly" : "editable";
306
306
  let n = o.querySelector(`[${ve}]`);
307
- n && n.getAttribute("data-cache") === h || (n || (n = document.createElement("style"), n.setAttribute(ve, "true"), o.appendChild(n)), n.setAttribute("data-cache", h), n.textContent = `
307
+ n && n.getAttribute("data-cache") === m || (n || (n = document.createElement("style"), n.setAttribute(ve, "true"), o.appendChild(n)), n.setAttribute("data-cache", m), n.textContent = `
308
308
  ${a ? `
309
309
  :host, :host * { cursor: pointer !important; }
310
310
  .ML__latex, .ML__content, .ML__container, .ML__virtual-keyboard-toggle { cursor: pointer !important; }
@@ -318,15 +318,15 @@ function Fe() {
318
318
  let me = null;
319
319
  function Ze() {
320
320
  me || (Fe(), me = new MutationObserver((l) => {
321
- var o, a, h;
321
+ var o, a, m;
322
322
  for (const n of l) {
323
323
  if (n.type === "attributes" && ((o = n.target.tagName) == null ? void 0 : o.toLowerCase()) === "math-field") {
324
324
  ie(n.target);
325
325
  continue;
326
326
  }
327
327
  if (n.addedNodes)
328
- for (const m of n.addedNodes)
329
- m instanceof Element && (((a = m.tagName) == null ? void 0 : a.toLowerCase()) === "math-field" && requestAnimationFrame(() => ie(m)), (h = m.querySelectorAll) == null || h.call(m, "math-field").forEach((d) => requestAnimationFrame(() => ie(d))));
328
+ for (const s of n.addedNodes)
329
+ s instanceof Element && (((a = s.tagName) == null ? void 0 : a.toLowerCase()) === "math-field" && requestAnimationFrame(() => ie(s)), (m = s.querySelectorAll) == null || m.call(s, "math-field").forEach((d) => requestAnimationFrame(() => ie(d))));
330
330
  }
331
331
  }), me.observe(document.body, {
332
332
  childList: !0,
@@ -348,11 +348,11 @@ const Se = [
348
348
  const l = [];
349
349
  return Se.slice(1).forEach((o) => {
350
350
  o.ranges.forEach((a) => {
351
- for (let h = a[0]; h <= a[1]; h++) {
352
- if (h >= 127 && h <= 159) continue;
353
- const n = String.fromCodePoint(h);
351
+ for (let m = a[0]; m <= a[1]; m++) {
352
+ if (m >= 127 && m <= 159) continue;
353
+ const n = String.fromCodePoint(m);
354
354
  new RegExp("\\p{C}", "u").test(n) || l.push({
355
- code: h.toString(16).toUpperCase().padStart(4, "0"),
355
+ code: m.toString(16).toUpperCase().padStart(4, "0"),
356
356
  char: n,
357
357
  category: o.id
358
358
  });
@@ -360,33 +360,33 @@ const Se = [
360
360
  });
361
361
  }), l;
362
362
  }, je = Je();
363
- function Qe({ isOpen: l, onClose: o, onInsert: a, position: h }) {
364
- const [n, m] = 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
- l && (m(""), p("All"));
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();
384
384
  };
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
- if (h) {
388
- let u = h.x - 120, E = h.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` };
387
+ if (m) {
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();
@@ -396,7 +396,7 @@ function Qe({ isOpen: l, onClose: o, onInsert: a, position: h }) {
396
396
  type: "text",
397
397
  placeholder: "Code",
398
398
  value: n,
399
- onChange: (u) => m(u.target.value),
399
+ onChange: (u) => s(u.target.value),
400
400
  className: "scm-code-input"
401
401
  }
402
402
  ), /* @__PURE__ */ e.createElement(
@@ -407,7 +407,7 @@ function Qe({ isOpen: l, onClose: o, onInsert: a, position: h }) {
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: h }) {
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.15", 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,
@@ -452,11 +452,11 @@ typeof window < "u" && (window.MathfieldElement ? window.MathfieldElement.fontsD
452
452
  window.__ckMathWidgets = window.__ckMathWidgets || /* @__PURE__ */ new Map();
453
453
  window.__ckMathWidgetClickHandler = null;
454
454
  function Ke(l) {
455
- var a, h, n, m, d;
455
+ var a, m, n, s, d;
456
456
  if (!l) return null;
457
457
  const o = typeof l.composedPath == "function" ? l.composedPath() : [l];
458
458
  for (const p of o)
459
- if (p instanceof HTMLElement && ((a = p.classList) != null && a.contains("ck-math-widget") || (h = p.dataset) != null && h.mathId || (n = p.classList) != null && n.contains("ck-widget") && ((m = p.querySelector) != null && m.call(p, ".ck-math-widget-inner"))))
459
+ if (p instanceof HTMLElement && ((a = p.classList) != null && a.contains("ck-math-widget") || (m = p.dataset) != null && m.mathId || (n = p.classList) != null && n.contains("ck-widget") && ((s = p.querySelector) != null && s.call(p, ".ck-math-widget-inner"))))
460
460
  return p;
461
461
  return l instanceof Element ? (d = l.closest) == null ? void 0 : d.call(l, ".ck-math-widget, [data-math-id]") : null;
462
462
  }
@@ -464,21 +464,21 @@ function de(l) {
464
464
  if (!l) return "";
465
465
  let o = "", a = 0;
466
466
  for (; a < l.length; ) {
467
- let h = l.indexOf("\\placeholder", a);
468
- if (h === -1) {
467
+ let m = l.indexOf("\\placeholder", a);
468
+ if (m === -1) {
469
469
  o += l.slice(a);
470
470
  break;
471
471
  }
472
- if (o += l.slice(a, h), a = h + 12, l[a] === "[") {
472
+ if (o += l.slice(a, m), a = m + 12, l[a] === "[") {
473
473
  let n = 1;
474
474
  for (a++; a < l.length && n > 0; )
475
475
  l[a] === "[" ? n++ : l[a] === "]" && n--, a++;
476
476
  }
477
477
  if (l[a] === "{") {
478
- let n = 1, m = a + 1;
478
+ let n = 1, s = a + 1;
479
479
  for (a++; a < l.length && n > 0; )
480
480
  l[a] === "{" ? n++ : l[a] === "}" && n--, a++;
481
- let d = l.slice(m, a - 1);
481
+ let d = l.slice(s, a - 1);
482
482
  d.trim() === "" ? o += "\\quad " : o += d;
483
483
  }
484
484
  }
@@ -486,18 +486,18 @@ function de(l) {
486
486
  }
487
487
  function X(l) {
488
488
  let o = "", a = 0;
489
- const h = "\\text{";
489
+ const m = "\\text{";
490
490
  for (; a < l.length; ) {
491
- const n = l.indexOf(h, a);
491
+ const n = l.indexOf(m, a);
492
492
  if (n === -1) {
493
493
  o += l.slice(a);
494
494
  break;
495
495
  }
496
496
  o += l.slice(a, n);
497
- let m = 1, d = n + h.length;
498
- for (; d < l.length && m > 0; )
499
- l[d] === "{" ? m++ : l[d] === "}" && m--, d++;
500
- const p = l.slice(n + h.length, d - 1);
497
+ let s = 1, d = n + m.length;
498
+ for (; d < l.length && s > 0; )
499
+ l[d] === "{" ? s++ : l[d] === "}" && s--, d++;
500
+ const p = l.slice(n + m.length, d - 1);
501
501
  /^['"/]+$/.test(p) || p.includes("\\textquotedbl") || p.includes("\\textquotesingle") ? o += "\\text{" + p + "}" : o += p, a = d;
502
502
  }
503
503
  return o;
@@ -528,9 +528,9 @@ function _e(l, o) {
528
528
  if (!l || !o) return null;
529
529
  const a = l.model.document.selection.getSelectedElement();
530
530
  if ((a == null ? void 0 : a.name) === "mathInline") return a;
531
- const h = o.getAttribute("data-math-id");
532
- if (h) {
533
- const x = window.__ckMathWidgets.get(h);
531
+ const m = o.getAttribute("data-math-id");
532
+ if (m) {
533
+ const x = window.__ckMathWidgets.get(m);
534
534
  if (Te(l, x)) return x;
535
535
  }
536
536
  const n = l.editing.view.domConverter.mapDomToView(o);
@@ -538,39 +538,39 @@ function _e(l, o) {
538
538
  const x = l.editing.mapper.toModelElement(n);
539
539
  if ((x == null ? void 0 : x.name) === "mathInline") return x;
540
540
  }
541
- const m = oe(o);
542
- if (!m) return null;
541
+ const s = oe(o);
542
+ if (!s) return null;
543
543
  const d = l.model.document.getRoot();
544
544
  for (const { item: x } of l.model.createRangeIn(d))
545
- if ((p = x.is) != null && p.call(x, "element", "mathInline") && x.getAttribute("latex") === m)
545
+ if ((p = x.is) != null && p.call(x, "element", "mathInline") && x.getAttribute("latex") === s)
546
546
  return x;
547
547
  return null;
548
548
  }
549
- function We(l, o, a, h) {
549
+ function We(l, o, a, m) {
550
550
  if (!l || l._mathWidgetOpening) return;
551
551
  l._mathWidgetOpening = !0, queueMicrotask(() => {
552
552
  l._mathWidgetOpening = !1;
553
553
  });
554
- const n = Te(l, o) ? o : _e(l, h), m = (n == null ? void 0 : n.getAttribute("latex")) || a || oe(h);
555
- if (!m) return;
554
+ const n = Te(l, o) ? o : _e(l, m), s = (n == null ? void 0 : n.getAttribute("latex")) || a || oe(m);
555
+ if (!s) return;
556
556
  n && l.model.change((p) => {
557
557
  p.setSelection(n, "on");
558
558
  });
559
559
  const d = l.mathWidgetClickHandler || window.__ckMathWidgetClickHandler;
560
- d && d(n, m), window.dispatchEvent(new CustomEvent("editAneesWidget", {
560
+ d && d(n, s), window.dispatchEvent(new CustomEvent("editAneesWidget", {
561
561
  detail: {
562
562
  editor: l,
563
563
  modelElement: n,
564
- latex: m
564
+ latex: s
565
565
  }
566
566
  }));
567
567
  }
568
568
  function Ye(l, o) {
569
569
  if (!o || o._ckMathClickBound) return;
570
570
  o._ckMathClickBound = !0;
571
- const a = (h) => {
571
+ const a = (m) => {
572
572
  var n;
573
- h.button === 0 && (h.preventDefault(), h.stopPropagation(), (n = h.stopImmediatePropagation) == null || n.call(h), We(l, null, oe(o), o));
573
+ m.button === 0 && (m.preventDefault(), m.stopPropagation(), (n = m.stopImmediatePropagation) == null || n.call(m), We(l, null, oe(o), o));
574
574
  };
575
575
  o.addEventListener("mousedown", a, !0), o.addEventListener("click", a, !0);
576
576
  }
@@ -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,
@@ -3635,26 +3640,26 @@ class ct extends Ve {
3635
3640
  isObject: !0,
3636
3641
  allowWhere: "$text",
3637
3642
  allowAttributes: ["latex"]
3638
- }), o.model.schema.addChildCheck((h, n) => {
3643
+ }), o.model.schema.addChildCheck((m, n) => {
3639
3644
  if (n.name === "mathInline")
3640
3645
  return !0;
3641
3646
  }), o.conversion.for("editingDowncast").elementToElement({
3642
3647
  model: "mathInline",
3643
- view: (h, { writer: n }) => {
3644
- const m = h.getAttribute("latex") || "", d = "math-" + Math.random().toString(36).substr(2, 9);
3645
- window.__ckMathWidgets.set(d, h);
3648
+ view: (m, { writer: n }) => {
3649
+ const s = m.getAttribute("latex") || "", d = "math-" + Math.random().toString(36).substr(2, 9);
3650
+ window.__ckMathWidgets.set(d, m);
3646
3651
  const p = n.createContainerElement("span", {
3647
3652
  class: "ck-math-widget ck-math-inline-word",
3648
3653
  contenteditable: "false",
3649
3654
  "data-math-id": d,
3650
- "data-latex": m
3655
+ "data-latex": s
3651
3656
  }), x = n.createRawElement(
3652
3657
  "span",
3653
3658
  {
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
- de(m)
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
  }
@@ -3695,26 +3700,26 @@ class ct extends Ve {
3695
3700
  }
3696
3701
  });
3697
3702
  const a = o.editing.view.document;
3698
- this.listenTo(a, "mousedown", (h, n) => {
3699
- const m = Ke(n.domTarget);
3700
- m && n.domEvent.button === 0 && (h.stop(), n.preventDefault(), We(
3703
+ this.listenTo(a, "mousedown", (m, n) => {
3704
+ const s = Ke(n.domTarget);
3705
+ s && n.domEvent.button === 0 && (m.stop(), n.preventDefault(), We(
3701
3706
  o,
3702
3707
  null,
3703
- oe(m),
3704
- m
3708
+ oe(s),
3709
+ s
3705
3710
  ));
3706
- }, { priority: "high" }), o.conversion.for("editingDowncast").add((h) => {
3707
- h.on("attribute:latex:mathInline", (n, m, d) => {
3708
- if (!d.consumable.consume(m.item, n.name))
3711
+ }, { priority: "high" }), o.conversion.for("editingDowncast").add((m) => {
3712
+ m.on("attribute:latex:mathInline", (n, s, d) => {
3713
+ if (!d.consumable.consume(s.item, n.name))
3709
3714
  return;
3710
- const p = d.writer, x = d.mapper.toViewElement(m.item);
3715
+ const p = d.writer, x = d.mapper.toViewElement(s.item);
3711
3716
  if (x) {
3712
- p.setAttribute("data-latex", m.attributeNewValue, x);
3713
- const I = o.editing.view.domConverter.mapViewToDom(x);
3714
- if (I) {
3715
- const g = I.querySelector("math-field");
3717
+ p.setAttribute("data-latex", s.attributeNewValue, x);
3718
+ const B = o.editing.view.domConverter.mapViewToDom(x);
3719
+ if (B) {
3720
+ const g = B.querySelector("math-field");
3716
3721
  if (g) {
3717
- let A = ge(ne(X(de(m.attributeNewValue))));
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");
3719
3724
  try {
3720
3725
  g.setValue ? g.setValue("", { silenceNotifications: !0 }) : g.value = "", g.executeCommand(["insert", A, { insertionMode: "replaceAll" }]);
@@ -3729,16 +3734,16 @@ class ct extends Ve {
3729
3734
  });
3730
3735
  }), o.conversion.for("dataDowncast").elementToElement({
3731
3736
  model: "mathInline",
3732
- view: (h, { writer: n }) => {
3733
- const m = h.getAttribute("latex") || "", d = n.createContainerElement("span", {
3737
+ view: (m, { writer: n }) => {
3738
+ const s = m.getAttribute("latex") || "", d = n.createContainerElement("span", {
3734
3739
  class: "math-tex",
3735
- "data-latex": m,
3740
+ "data-latex": s,
3736
3741
  // Keep raw latex in data-latex for restoring
3737
3742
  style: "display:inline;"
3738
3743
  });
3739
3744
  let p = ne(
3740
3745
  X(
3741
- de(m)
3746
+ de(s)
3742
3747
  )
3743
3748
  );
3744
3749
  p.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(p.trim()) && (p = p.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1"));
@@ -3750,63 +3755,63 @@ class ct extends Ve {
3750
3755
  name: "span",
3751
3756
  classes: "math-tex"
3752
3757
  },
3753
- model: (h, { writer: n }) => {
3754
- const m = h.getAttribute("data-latex") || "";
3755
- return n.createElement("mathInline", { latex: m });
3758
+ model: (m, { writer: n }) => {
3759
+ const s = m.getAttribute("data-latex") || "";
3760
+ return n.createElement("mathInline", { latex: s });
3756
3761
  }
3757
3762
  });
3758
3763
  }
3759
3764
  }
3760
- function tt({ matrixType: l, x: o, y: a, onSelect: h, onMouseEnter: n, onMouseLeave: m }) {
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 === "") {
3765
+ function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLeave: s }) {
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
- h(T, L);
3792
+ m(T, L);
3788
3793
  }
3789
3794
  };
3790
3795
  return window.addEventListener("keydown", k, !0), () => window.removeEventListener("keydown", k, !0);
3791
- }, [d.r, d.c, h]), /* @__PURE__ */ e.createElement(
3796
+ }, [d.r, d.c, m]), /* @__PURE__ */ e.createElement(
3792
3797
  "div",
3793
3798
  {
3794
3799
  className: "cme-matrix-hover-popover ck-only",
3795
3800
  style: { top: `${a}px`, left: `${o}px` },
3796
- onMouseDown: (k) => k.stopPropagation(),
3801
+ onPointerDown: (k) => k.stopPropagation(),
3797
3802
  onMouseEnter: n,
3798
- onMouseLeave: m
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(), h(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: h, 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: h, 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
- function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n }) {
3853
- const m = re(null), [d, p] = B(0), [x, I] = B(null), [g, A] = B(null), [u, E] = B(null), [k, y] = B(null);
3857
+ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: m, isEditing: n }) {
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;
3859
- 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;
3860
- let w = c - j.current.x, s = b - j.current.y;
3864
+ 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;
3865
+ let w = h - j.current.x, c = 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), s < H && (s = H), s > P && (s = P);
3868
+ w < M && (w = M), w > R && (w = R), c < H && (c = H), c > P && (c = P);
3864
3869
  }
3865
- L({ x: w, y: s });
3870
+ L({ x: w, y: c });
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: h, isEditing: n })
3876
3881
  x: i - T.x,
3877
3882
  y: r - T.y
3878
3883
  };
3879
- const c = document.querySelector(".cme-editor-popup");
3880
- if (c) {
3881
- const b = c.getBoundingClientRect();
3884
+ const h = document.querySelector(".cme-editor-popup");
3885
+ if (h) {
3886
+ const b = h.getBoundingClientRect();
3882
3887
  se.current = {
3883
3888
  left: b.left - T.x,
3884
3889
  top: b.top - T.y,
@@ -3888,7 +3893,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, 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",
@@ -3896,13 +3901,13 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
3896
3901
  fontSize: "auto"
3897
3902
  }), F = he(() => {
3898
3903
  if (J || window.__cmeIgnoreStyleUpdate && Date.now() - window.__cmeIgnoreStyleUpdate < 150) return;
3899
- const t = m.current;
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", c = window.__cmeManualFontFamily !== void 0 ? window.__cmeManualFontFamily : ["roman", "sans-serif", "monospace"].find(
3903
- (s) => t.queryStyle({ fontFamily: s }) === "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", h = window.__cmeManualFontFamily !== void 0 ? window.__cmeManualFontFamily : ["roman", "sans-serif", "monospace"].find(
3908
+ (c) => t.queryStyle({ fontFamily: c }) === "all"
3904
3909
  ) || "none", b = window.__cmeManualFontSize !== void 0 ? window.__cmeManualFontSize : [5, 7, 9].find(
3905
- (s) => t.queryStyle({ fontSize: s }) === "all"
3910
+ (c) => t.queryStyle({ fontSize: c }) === "all"
3906
3911
  ) || "auto", w = [
3907
3912
  "black",
3908
3913
  "dimgray",
@@ -3929,12 +3934,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
3929
3934
  "violet",
3930
3935
  "gold"
3931
3936
  ].find(
3932
- (s) => t.queryStyle({ color: s }) === "all"
3937
+ (c) => t.queryStyle({ color: c }) === "all"
3933
3938
  ) || "none";
3934
- ce((s) => ({
3939
+ ce((c) => ({
3935
3940
  bold: i,
3936
3941
  italic: r,
3937
- fontFamily: c,
3942
+ fontFamily: h,
3938
3943
  fontSize: String(b),
3939
3944
  color: w
3940
3945
  }));
@@ -3945,7 +3950,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, 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: h, 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);
@@ -3967,18 +3972,18 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
3967
3972
  if (!t) return;
3968
3973
  t.macros = { ...t.macros, ...window.__cme_macros || {} }, t.defaultMode = "math";
3969
3974
  const i = () => {
3970
- if (typeof t.applyStyle == "function" && t.applyStyle({ variantStyle: "up" }), h) {
3971
- let r = ge(h);
3975
+ if (typeof t.applyStyle == "function" && t.applyStyle({ variantStyle: "up" }), m) {
3976
+ let r = ge(m);
3972
3977
  if (l === "chem") {
3973
- const c = r.match(/^\\ce\{([\s\S]*)\}$/i);
3974
- c && (r = c[1]);
3978
+ const h = r.match(/^\\ce\{([\s\S]*)\}$/i);
3979
+ h && (r = h[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
  }
3978
3983
  requestAnimationFrame(() => t.focus());
3979
3984
  };
3980
3985
  customElements.get("math-field") ? requestAnimationFrame(i) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(i));
3981
- }, [l, h]), O(() => {
3986
+ }, [l, m]), O(() => {
3982
3987
  const t = U;
3983
3988
  if (!t) return;
3984
3989
  const i = (r) => {
@@ -3986,17 +3991,17 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, 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 c = "";
3990
- 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]);
3994
+ let h = "";
3995
+ 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]);
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 c = f.fontFamily === "sans-serif", b = f.fontFamily === "monospace", w = f.bold, s = f.italic;
4000
+ const h = f.fontFamily === "sans-serif", b = f.fontFamily === "monospace", w = f.bold, c = f.italic;
3996
4001
  let C = "\\mathrm";
3997
- c ? C = "\\mathsf" : b ? C = "\\mathtt" : s && !w ? C = "\\mathit" : w && !s && (C = "\\mathbf");
4002
+ h ? C = "\\mathsf" : b ? C = "\\mathtt" : c && !w ? C = "\\mathit" : w && !c && (C = "\\mathbf");
3998
4003
  let M = `${C}{${r.key}}`;
3999
- w && s ? (M = `\\mathbfit{${r.key}}`, c && (M = `\\boldsymbol{\\mathsf{${r.key}}}`), b && (M = `\\boldsymbol{\\mathtt{${r.key}}}`)) : w && (c || b) && (M = `\\boldsymbol{${M}}`);
4004
+ w && c ? (M = `\\mathbfit{${r.key}}`, h && (M = `\\boldsymbol{\\mathsf{${r.key}}}`), b && (M = `\\boldsymbol{\\mathtt{${r.key}}}`)) : w && (h || 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: h, isEditing: n })
4016
4021
  setTimeout(() => {
4017
4022
  const r = t.shadowRoot;
4018
4023
  if (!r) return;
4019
- const c = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
4020
- c && c.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }), F();
4024
+ const h = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
4025
+ h && h.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 c = `\\begin{${t}} `;
4036
+ let h = `\\begin{${t}} `;
4032
4037
  for (let b = 0; b < i; b++) {
4033
4038
  for (let w = 0; w < r; w++)
4034
- c += "#?", w < r - 1 && (c += " & ");
4035
- b < i - 1 && (c += " \\\\ ");
4039
+ h += "#?", w < r - 1 && (h += " & ");
4040
+ b < i - 1 && (h += " \\\\ ");
4036
4041
  }
4037
- c += ` \\end{${t}}`, Q(c);
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 });
@@ -4046,8 +4051,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4046
4051
  a && a();
4047
4052
  return;
4048
4053
  }
4049
- const r = i.getValue ? i.getValue("latex") : i.value, c = h || "";
4050
- !r || r.trim() === "" || r === c ? a && a() : Y(!0);
4054
+ const r = i.getValue ? i.getValue("latex") : i.value, h = m || "";
4055
+ !r || r.trim() === "" || r === h ? a && a() : Y(!0);
4051
4056
  }, Oe = () => {
4052
4057
  const t = U;
4053
4058
  if (!t) return;
@@ -4059,24 +4064,24 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, 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 c = r[1];
4063
- i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${c}{${C.trim()}}`).join(" \\\\ ")}}`;
4067
+ const h = r[1];
4068
+ i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${h}{${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
  {
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
- onMouseDown: (t) => t.stopPropagation()
4078
+ onPointerDown: (t) => t.stopPropagation()
4074
4079
  },
4075
4080
  /* @__PURE__ */ e.createElement("div", { className: "cme-popup-topbar" }, /* @__PURE__ */ e.createElement(
4076
4081
  "div",
4077
4082
  {
4078
4083
  className: "cme-popup-header",
4079
- onMouseDown: we,
4084
+ onPointerDown: we,
4080
4085
  onTouchStart: we,
4081
4086
  style: { cursor: q ? "grabbing" : "grab", touchAction: "none" }
4082
4087
  },
@@ -4090,8 +4095,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4090
4095
  key: t.isMatrix ? "matrix-tab" : t.label,
4091
4096
  className: `cme-group-tab${r ? " active" : ""}`,
4092
4097
  type: "button",
4093
- onMouseDown: (c) => {
4094
- c.preventDefault(), p(i), I(null);
4098
+ onPointerDown: (h) => {
4099
+ h.preventDefault(), p(i), B(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: h, isEditing: n })
4118
4123
  ) : t.label
4119
4124
  );
4120
4125
  })), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
4121
- var c;
4122
- const t = ((c = G[d]) == null ? void 0 : c.items) || [], i = t.some((b) => b.type === "sep"), r = [];
4126
+ var h;
4127
+ const t = ((h = G[d]) == null ? void 0 : h.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: h, isEditing: n })
4146
4151
  type: "button",
4147
4152
  className: "cme-more-trigger-btn",
4148
4153
  title: "more",
4149
- onMouseDown: (s) => {
4150
- s.preventDefault();
4154
+ onPointerDown: (c) => {
4155
+ c.preventDefault();
4151
4156
  },
4152
- onClick: (s) => {
4153
- if (s.stopPropagation(), k && k.items === b.moreItems)
4154
- y(null);
4157
+ onClick: (c) => {
4158
+ if (c.stopPropagation(), k && k.items === b.moreItems)
4159
+ E(null);
4155
4160
  else {
4156
- const C = s.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 = c.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((s, C) => {
4168
+ b.items.map((c, C) => {
4164
4169
  const M = G[d];
4165
- if (s.type === "dropdown") {
4166
- const N = s.label === "Font...", v = s.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 (c.type === "dropdown") {
4171
+ 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 : "";
4167
4172
  return /* @__PURE__ */ e.createElement(
4168
4173
  "select",
4169
4174
  {
@@ -4171,7 +4176,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4171
4176
  className: `cme-btn template${$ || ee ? " active" : ""}`,
4172
4177
  value: te,
4173
4178
  style: {
4174
- width: s.width || "60px",
4179
+ width: c.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: h, 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: "" }, s.label),
4196
+ /* @__PURE__ */ e.createElement("option", { value: "" }, c.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 && !s.directInsert)
4201
+ if (M.isMatrix && !c.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: h, isEditing: n })
4204
4209
  "button",
4205
4210
  {
4206
4211
  type: "button",
4207
- className: `cme-btn template${s.cls ? ` ${s.cls}` : ""}${M.isMatrix ? " cme-matrix-btn-small" : ""}`,
4208
- title: s.title || s.label || s.insert,
4209
- onMouseDown: (N) => {
4210
- if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === s.insert)
4211
- I(null);
4212
+ className: `cme-btn template${c.cls ? ` ${c.cls}` : ""}${M.isMatrix ? " cme-matrix-btn-small" : ""}`,
4213
+ title: c.title || c.label || c.insert,
4214
+ onPointerDown: (N) => {
4215
+ if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === c.insert)
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({
4216
- type: s.insert,
4220
+ B({
4221
+ type: c.insert,
4217
4222
  x: v.left + v.width / 2,
4218
4223
  y: v.bottom
4219
4224
  });
4220
4225
  }
4221
4226
  }
4222
4227
  },
4223
- typeof s.label == "object" ? s.label : /* @__PURE__ */ e.createElement(
4228
+ typeof c.label == "object" ? c.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: h, isEditing: n })
4239
4244
  cursor: "pointer"
4240
4245
  }
4241
4246
  },
4242
- pe(s.mathLabel != null ? s.mathLabel : s.insert)
4247
+ pe(c.mathLabel != null ? c.mathLabel : c.insert)
4243
4248
  )
4244
4249
  )
4245
4250
  );
4246
- const R = s.action === "BOLD", H = s.action === "ITALIC", P = s.action === "TEXT_COLOR", He = R && f.bold || H && f.italic || P && f.color !== "none" && f.color !== "black";
4251
+ 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";
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" : ""}${s.cls ? ` ${s.cls}` : ""}${He ? " active" : ""}`,
4253
- title: s.title || s.label || s.insert,
4254
- onMouseDown: (N) => {
4255
- var $, ee, te, le, Z, V, Ee;
4257
+ className: `cme-btn${M.isTemplate ? " template" : ""}${c.cls ? ` ${c.cls}` : ""}${He ? " active" : ""}`,
4258
+ title: c.title || c.label || c.insert,
4259
+ onPointerDown: (N) => {
4260
+ var $, ee, te, le, Z, V, ye;
4256
4261
  N.preventDefault();
4257
- const v = m.current;
4258
- if (s.action === "SPECIAL_CHARS") {
4262
+ const v = s.current;
4263
+ if (c.action === "SPECIAL_CHARS") {
4259
4264
  const S = N.currentTarget.getBoundingClientRect();
4260
4265
  A({ x: S.left, y: S.bottom + 4 });
4261
- } else if (s.action === "TEXT_COLOR") {
4266
+ } else if (c.action === "TEXT_COLOR") {
4262
4267
  const S = N.currentTarget.getBoundingClientRect();
4263
- E({ x: S.left, y: S.bottom + 4 });
4264
- } else if (s.action === "BOLD") {
4268
+ y({ x: S.left, y: S.bottom + 4 });
4269
+ } else if (c.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: h, isEditing: n })
4273
4278
  }
4274
4279
  ce((W) => ({ ...W, bold: S }));
4275
4280
  }
4276
- } else if (s.action === "ITALIC") {
4281
+ } else if (c.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: h, isEditing: n })
4285
4290
  }
4286
4291
  ce((W) => ({ ...W, italic: S }));
4287
4292
  }
4288
- } else s.action === "UNDO" ? ($ = m.current) == null || $.executeCommand("undo") : s.action === "REDO" ? (ee = m.current) == null || ee.executeCommand("redo") : s.action === "CUT" ? ((te = m.current) == null || te.focus(), (le = m.current) == null || le.executeCommand("cutToClipboard")) : s.action === "COPY" ? ((Z = m.current) == null || Z.focus(), (V = m.current) == null || V.executeCommand("copyToClipboard")) : s.action === "PASTE" ? ((Ee = m.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
- (D = m.current) == null || D.executeCommand(["insert", S]);
4295
+ (D = s.current) == null || D.executeCommand(["insert", S]);
4291
4296
  }).catch((S) => {
4292
4297
  var D;
4293
- (D = m.current) == null || D.executeCommand("pasteFromClipboard");
4294
- })) : Q(s.insert);
4298
+ (D = s.current) == null || D.executeCommand("pasteFromClipboard");
4299
+ })) : z(c.insert);
4295
4300
  }
4296
4301
  },
4297
- (M.isTemplate || M.label === "√(□)" || M.isMatrix || s.isWidget) && s.insert && !s.action && !s.forceLabel ? /* @__PURE__ */ e.createElement(
4302
+ (M.isTemplate || M.label === "√(□)" || M.isMatrix || c.isWidget) && c.insert && !c.action && !c.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: h, isEditing: n })
4313
4318
  cursor: "pointer"
4314
4319
  }
4315
4320
  },
4316
- pe(s.insert)
4317
- ) : s.label
4321
+ pe(c.insert)
4322
+ ) : c.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 c = k.cx - i.width / 2, b = k.y;
4333
+ let h = k.cx - i.width / 2, b = k.y;
4329
4334
  if (r) {
4330
4335
  const w = r.getBoundingClientRect();
4331
- 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);
4336
+ 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);
4332
4337
  }
4333
- 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";
4338
+ 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";
4334
4339
  });
4335
4340
  },
4336
4341
  className: "cme-more-popup",
@@ -4350,8 +4355,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4350
4355
  type: "button",
4351
4356
  className: `cme-more-popup-btn ${t.cls || ""}`,
4352
4357
  title: t.title || t.label || t.insert,
4353
- onMouseDown: (r) => {
4354
- r.preventDefault(), Q(t.insert), y(null);
4358
+ onPointerDown: (r) => {
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(
@@ -4381,18 +4386,20 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4381
4386
  "div",
4382
4387
  {
4383
4388
  className: "cme-mathfield-container",
4384
- onMouseDown: (t) => {
4385
- m.current && (t.target === m.current || m.current.contains(t.target)) || (t.preventDefault(), requestAnimationFrame(() => {
4386
- var i, r;
4387
- (r = (i = m.current) == null ? void 0 : i.focus) == null || r.call(i);
4388
- }));
4389
+ onPointerDown: (t) => {
4390
+ var i, r;
4391
+ s.current && (t.target === s.current || s.current.contains(t.target)) || (t.preventDefault(), (r = (i = s.current) == null ? void 0 : i.focus) == null || r.call(i));
4392
+ },
4393
+ onTouchStart: (t) => {
4394
+ var i, r;
4395
+ s.current && (t.target === s.current || s.current.contains(t.target)) || (t.preventDefault(), (r = (i = s.current) == null ? void 0 : i.focus) == null || r.call(i));
4389
4396
  }
4390
4397
  },
4391
4398
  /* @__PURE__ */ e.createElement(
4392
4399
  "math-field",
4393
4400
  {
4394
4401
  ref: (t) => {
4395
- m.current = t, U = t, t && (t.inlineShortcuts = Object.assign({}, t.inlineShortcuts, { "*": "*" }));
4402
+ s.current = t, U = t, t && (t.inlineShortcuts = Object.assign({}, t.inlineShortcuts, { "*": "*" }), window.mathVirtualKeyboard && (window.mathVirtualKeyboard.policy = "manual"));
4396
4403
  },
4397
4404
  class: "cme-mathfield",
4398
4405
  tabIndex: 0,
@@ -4402,14 +4409,14 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4402
4409
  )
4403
4410
  ),
4404
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)),
4405
- Be && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
4412
+ Ie && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onPointerDown: (t) => {
4406
4413
  t.stopPropagation(), Y(!1);
4407
- } }, /* @__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) => {
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) => {
4408
4415
  t.stopPropagation(), Y(!1), a && a();
4409
4416
  } }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
4410
4417
  t.stopPropagation(), Y(!1);
4411
4418
  } }, "Cancel")))),
4412
- x && z(
4419
+ x && Q(
4413
4420
  /* @__PURE__ */ e.createElement(
4414
4421
  tt,
4415
4422
  {
@@ -4417,7 +4424,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4417
4424
  x: x.x,
4418
4425
  y: x.y,
4419
4426
  onSelect: (t, i) => {
4420
- De(x.type, t, i), I(null);
4427
+ De(x.type, t, i), B(null);
4421
4428
  },
4422
4429
  onMouseEnter: () => {
4423
4430
  },
@@ -4427,21 +4434,21 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4427
4434
  ),
4428
4435
  document.body
4429
4436
  ),
4430
- g && z(
4437
+ g && Q(
4431
4438
  /* @__PURE__ */ e.createElement(
4432
- Qe,
4439
+ ze,
4433
4440
  {
4434
4441
  isOpen: !!g,
4435
4442
  position: g,
4436
4443
  onClose: () => A(null),
4437
4444
  onInsert: (t) => {
4438
- Q(t), A(null);
4445
+ z(t), A(null);
4439
4446
  }
4440
4447
  }
4441
4448
  ),
4442
4449
  document.body
4443
4450
  ),
4444
- u && z(
4451
+ u && Q(
4445
4452
  /* @__PURE__ */ e.createElement(
4446
4453
  "div",
4447
4454
  {
@@ -4501,10 +4508,10 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4501
4508
  border: i ? "2px solid #e6c229" : "1px solid #000",
4502
4509
  boxSizing: "border-box"
4503
4510
  },
4504
- onMouseDown: (r) => {
4511
+ onPointerDown: (r) => {
4505
4512
  r.preventDefault(), r.stopPropagation();
4506
- const c = m.current;
4507
- c && typeof c.applyStyle == "function" && (c.focus(), c.applyStyle({ color: t === "black" ? "none" : t }), F()), E(null);
4513
+ const h = s.current;
4514
+ h && typeof h.applyStyle == "function" && (h.focus(), h.applyStyle({ color: t === "black" ? "none" : t }), F()), y(null);
4508
4515
  }
4509
4516
  }
4510
4517
  );
@@ -4516,11 +4523,11 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
4516
4523
  document.body
4517
4524
  );
4518
4525
  }
4519
- const ht = ({ isOpen: l, mode: o, initialValue: a, onInsert: h, onClose: n }) => l ? /* @__PURE__ */ e.createElement(
4526
+ const ht = ({ isOpen: l, mode: o, initialValue: a, onInsert: m, onClose: n }) => l ? /* @__PURE__ */ e.createElement(
4520
4527
  lt,
4521
4528
  {
4522
4529
  mode: o,
4523
- onInsert: h,
4530
+ onInsert: m,
4524
4531
  onClose: n,
4525
4532
  initialLatex: a || "",
4526
4533
  isEditing: !!a