digi-mathchem-editor 1.0.15 → 1.0.16
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.
- package/dist/digi-mathchem-editor.es.js +167 -165
- package/dist/digi-mathchem-editor.umd.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -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"),
|
|
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") ===
|
|
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,
|
|
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
|
|
329
|
-
|
|
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
|
|
352
|
-
if (
|
|
353
|
-
const n = String.fromCodePoint(
|
|
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:
|
|
355
|
+
code: m.toString(16).toUpperCase().padStart(4, "0"),
|
|
356
356
|
char: n,
|
|
357
357
|
category: o.id
|
|
358
358
|
});
|
|
@@ -360,10 +360,10 @@ const Se = [
|
|
|
360
360
|
});
|
|
361
361
|
}), l;
|
|
362
362
|
}, je = Je();
|
|
363
|
-
function Qe({ isOpen: l, onClose: o, onInsert: a, position:
|
|
364
|
-
const [n,
|
|
363
|
+
function Qe({ isOpen: l, onClose: o, onInsert: a, position: m }) {
|
|
364
|
+
const [n, s] = B(""), [d, p] = B("All");
|
|
365
365
|
O(() => {
|
|
366
|
-
l && (
|
|
366
|
+
l && (s(""), p("All"));
|
|
367
367
|
}, [l]);
|
|
368
368
|
const x = ye(() => {
|
|
369
369
|
let u = je;
|
|
@@ -384,8 +384,8 @@ function Qe({ isOpen: l, onClose: o, onInsert: a, position: h }) {
|
|
|
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 (
|
|
388
|
-
let u =
|
|
387
|
+
if (m) {
|
|
388
|
+
let u = m.x - 120, E = m.y;
|
|
389
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` };
|
|
390
390
|
}
|
|
391
391
|
return /* @__PURE__ */ e.createElement("div", { className: "scm-overlay", onMouseDown: (u) => {
|
|
@@ -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) =>
|
|
399
|
+
onChange: (u) => s(u.target.value),
|
|
400
400
|
className: "scm-code-input"
|
|
401
401
|
}
|
|
402
402
|
), /* @__PURE__ */ e.createElement(
|
|
@@ -420,7 +420,7 @@ 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.
|
|
423
|
+
const ze = "1.0.16", Xe = {
|
|
424
424
|
version: ze
|
|
425
425
|
};
|
|
426
426
|
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,
|
|
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") || (
|
|
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
|
|
468
|
-
if (
|
|
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,
|
|
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,
|
|
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(
|
|
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
|
|
489
|
+
const m = "\\text{";
|
|
490
490
|
for (; a < l.length; ) {
|
|
491
|
-
const n = l.indexOf(
|
|
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
|
|
498
|
-
for (; d < l.length &&
|
|
499
|
-
l[d] === "{" ?
|
|
500
|
-
const p = l.slice(n +
|
|
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
|
|
532
|
-
if (
|
|
533
|
-
const x = window.__ckMathWidgets.get(
|
|
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
|
|
542
|
-
if (!
|
|
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") ===
|
|
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,
|
|
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,
|
|
555
|
-
if (!
|
|
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,
|
|
560
|
+
d && d(n, s), window.dispatchEvent(new CustomEvent("editAneesWidget", {
|
|
561
561
|
detail: {
|
|
562
562
|
editor: l,
|
|
563
563
|
modelElement: n,
|
|
564
|
-
latex:
|
|
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 = (
|
|
571
|
+
const a = (m) => {
|
|
572
572
|
var n;
|
|
573
|
-
|
|
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
|
}
|
|
@@ -3635,19 +3635,19 @@ class ct extends Ve {
|
|
|
3635
3635
|
isObject: !0,
|
|
3636
3636
|
allowWhere: "$text",
|
|
3637
3637
|
allowAttributes: ["latex"]
|
|
3638
|
-
}), o.model.schema.addChildCheck((
|
|
3638
|
+
}), o.model.schema.addChildCheck((m, n) => {
|
|
3639
3639
|
if (n.name === "mathInline")
|
|
3640
3640
|
return !0;
|
|
3641
3641
|
}), o.conversion.for("editingDowncast").elementToElement({
|
|
3642
3642
|
model: "mathInline",
|
|
3643
|
-
view: (
|
|
3644
|
-
const
|
|
3645
|
-
window.__ckMathWidgets.set(d,
|
|
3643
|
+
view: (m, { writer: n }) => {
|
|
3644
|
+
const s = m.getAttribute("latex") || "", d = "math-" + Math.random().toString(36).substr(2, 9);
|
|
3645
|
+
window.__ckMathWidgets.set(d, m);
|
|
3646
3646
|
const p = n.createContainerElement("span", {
|
|
3647
3647
|
class: "ck-math-widget ck-math-inline-word",
|
|
3648
3648
|
contenteditable: "false",
|
|
3649
3649
|
"data-math-id": d,
|
|
3650
|
-
"data-latex":
|
|
3650
|
+
"data-latex": s
|
|
3651
3651
|
}), x = n.createRawElement(
|
|
3652
3652
|
"span",
|
|
3653
3653
|
{
|
|
@@ -3666,7 +3666,7 @@ class ct extends Ve {
|
|
|
3666
3666
|
let E = ge(
|
|
3667
3667
|
ne(
|
|
3668
3668
|
X(
|
|
3669
|
-
de(
|
|
3669
|
+
de(s)
|
|
3670
3670
|
)
|
|
3671
3671
|
)
|
|
3672
3672
|
);
|
|
@@ -3695,26 +3695,26 @@ class ct extends Ve {
|
|
|
3695
3695
|
}
|
|
3696
3696
|
});
|
|
3697
3697
|
const a = o.editing.view.document;
|
|
3698
|
-
this.listenTo(a, "mousedown", (
|
|
3699
|
-
const
|
|
3700
|
-
|
|
3698
|
+
this.listenTo(a, "mousedown", (m, n) => {
|
|
3699
|
+
const s = Ke(n.domTarget);
|
|
3700
|
+
s && n.domEvent.button === 0 && (m.stop(), n.preventDefault(), We(
|
|
3701
3701
|
o,
|
|
3702
3702
|
null,
|
|
3703
|
-
oe(
|
|
3704
|
-
|
|
3703
|
+
oe(s),
|
|
3704
|
+
s
|
|
3705
3705
|
));
|
|
3706
|
-
}, { priority: "high" }), o.conversion.for("editingDowncast").add((
|
|
3707
|
-
|
|
3708
|
-
if (!d.consumable.consume(
|
|
3706
|
+
}, { priority: "high" }), o.conversion.for("editingDowncast").add((m) => {
|
|
3707
|
+
m.on("attribute:latex:mathInline", (n, s, d) => {
|
|
3708
|
+
if (!d.consumable.consume(s.item, n.name))
|
|
3709
3709
|
return;
|
|
3710
|
-
const p = d.writer, x = d.mapper.toViewElement(
|
|
3710
|
+
const p = d.writer, x = d.mapper.toViewElement(s.item);
|
|
3711
3711
|
if (x) {
|
|
3712
|
-
p.setAttribute("data-latex",
|
|
3712
|
+
p.setAttribute("data-latex", s.attributeNewValue, x);
|
|
3713
3713
|
const I = o.editing.view.domConverter.mapViewToDom(x);
|
|
3714
3714
|
if (I) {
|
|
3715
3715
|
const g = I.querySelector("math-field");
|
|
3716
3716
|
if (g) {
|
|
3717
|
-
let A = ge(ne(X(de(
|
|
3717
|
+
let A = ge(ne(X(de(s.attributeNewValue))));
|
|
3718
3718
|
A.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(A.trim()) && (A = A.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")), g.removeAttribute("read-only");
|
|
3719
3719
|
try {
|
|
3720
3720
|
g.setValue ? g.setValue("", { silenceNotifications: !0 }) : g.value = "", g.executeCommand(["insert", A, { insertionMode: "replaceAll" }]);
|
|
@@ -3729,16 +3729,16 @@ class ct extends Ve {
|
|
|
3729
3729
|
});
|
|
3730
3730
|
}), o.conversion.for("dataDowncast").elementToElement({
|
|
3731
3731
|
model: "mathInline",
|
|
3732
|
-
view: (
|
|
3733
|
-
const
|
|
3732
|
+
view: (m, { writer: n }) => {
|
|
3733
|
+
const s = m.getAttribute("latex") || "", d = n.createContainerElement("span", {
|
|
3734
3734
|
class: "math-tex",
|
|
3735
|
-
"data-latex":
|
|
3735
|
+
"data-latex": s,
|
|
3736
3736
|
// Keep raw latex in data-latex for restoring
|
|
3737
3737
|
style: "display:inline;"
|
|
3738
3738
|
});
|
|
3739
3739
|
let p = ne(
|
|
3740
3740
|
X(
|
|
3741
|
-
de(
|
|
3741
|
+
de(s)
|
|
3742
3742
|
)
|
|
3743
3743
|
);
|
|
3744
3744
|
p.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(p.trim()) && (p = p.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1"));
|
|
@@ -3750,14 +3750,14 @@ class ct extends Ve {
|
|
|
3750
3750
|
name: "span",
|
|
3751
3751
|
classes: "math-tex"
|
|
3752
3752
|
},
|
|
3753
|
-
model: (
|
|
3754
|
-
const
|
|
3755
|
-
return n.createElement("mathInline", { latex:
|
|
3753
|
+
model: (m, { writer: n }) => {
|
|
3754
|
+
const s = m.getAttribute("data-latex") || "";
|
|
3755
|
+
return n.createElement("mathInline", { latex: s });
|
|
3756
3756
|
}
|
|
3757
3757
|
});
|
|
3758
3758
|
}
|
|
3759
3759
|
}
|
|
3760
|
-
function tt({ matrixType: l, x: o, y: a, onSelect:
|
|
3760
|
+
function tt({ matrixType: l, x: o, y: a, onSelect: m, onMouseEnter: n, onMouseLeave: s }) {
|
|
3761
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
3762
|
const y = k.target.value;
|
|
3763
3763
|
if (y === "") {
|
|
@@ -3784,18 +3784,18 @@ function tt({ matrixType: l, x: o, y: a, onSelect: h, onMouseEnter: n, onMouseLe
|
|
|
3784
3784
|
if (y.key === "Enter") {
|
|
3785
3785
|
y.preventDefault(), y.stopPropagation();
|
|
3786
3786
|
const T = parseInt(d.r, 10) || 1, L = parseInt(d.c, 10) || 1;
|
|
3787
|
-
|
|
3787
|
+
m(T, L);
|
|
3788
3788
|
}
|
|
3789
3789
|
};
|
|
3790
3790
|
return window.addEventListener("keydown", k, !0), () => window.removeEventListener("keydown", k, !0);
|
|
3791
|
-
}, [d.r, d.c,
|
|
3791
|
+
}, [d.r, d.c, m]), /* @__PURE__ */ e.createElement(
|
|
3792
3792
|
"div",
|
|
3793
3793
|
{
|
|
3794
3794
|
className: "cme-matrix-hover-popover ck-only",
|
|
3795
3795
|
style: { top: `${a}px`, left: `${o}px` },
|
|
3796
|
-
|
|
3796
|
+
onPointerDown: (k) => k.stopPropagation(),
|
|
3797
3797
|
onMouseEnter: n,
|
|
3798
|
-
onMouseLeave:
|
|
3798
|
+
onMouseLeave: s
|
|
3799
3799
|
},
|
|
3800
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
3801
|
const q = parseInt(d.r, 10) || 0, K = parseInt(d.c, 10) || 0, j = y < q && L < K;
|
|
@@ -3806,7 +3806,7 @@ function tt({ matrixType: l, x: o, y: a, onSelect: h, onMouseEnter: n, onMouseLe
|
|
|
3806
3806
|
className: `cme-matrix-hover-cell${j ? " selected" : ""}`,
|
|
3807
3807
|
onMouseEnter: () => p({ r: y + 1, c: L + 1 }),
|
|
3808
3808
|
onClick: (_) => {
|
|
3809
|
-
_.preventDefault(), _.stopPropagation(),
|
|
3809
|
+
_.preventDefault(), _.stopPropagation(), m(y + 1, L + 1);
|
|
3810
3810
|
}
|
|
3811
3811
|
}
|
|
3812
3812
|
);
|
|
@@ -3849,20 +3849,20 @@ function tt({ matrixType: l, x: o, y: a, onSelect: h, onMouseEnter: n, onMouseLe
|
|
|
3849
3849
|
);
|
|
3850
3850
|
}
|
|
3851
3851
|
let J = !1, be = null, U = null;
|
|
3852
|
-
function lt({ mode: l, onInsert: o, onClose: a, initialLatex:
|
|
3853
|
-
const
|
|
3852
|
+
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);
|
|
3854
3854
|
re(null);
|
|
3855
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);
|
|
3856
3856
|
O(() => {
|
|
3857
3857
|
const t = (r) => {
|
|
3858
3858
|
if (!q) return;
|
|
3859
|
-
const
|
|
3860
|
-
let w =
|
|
3859
|
+
const h = r.touches && r.touches.length > 0 ? r.touches[0].clientX : r.clientX, b = r.touches && r.touches.length > 0 ? r.touches[0].clientY : r.clientY;
|
|
3860
|
+
let w = h - j.current.x, c = b - j.current.y;
|
|
3861
3861
|
if (se.current) {
|
|
3862
3862
|
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),
|
|
3863
|
+
w < M && (w = M), w > R && (w = R), c < H && (c = H), c > P && (c = P);
|
|
3864
3864
|
}
|
|
3865
|
-
L({ x: w, y:
|
|
3865
|
+
L({ x: w, y: c });
|
|
3866
3866
|
}, i = () => K(!1);
|
|
3867
3867
|
return q && (window.addEventListener("mousemove", t, { passive: !1 }), window.addEventListener("mouseup", i), window.addEventListener("touchmove", t, { passive: !1 }), window.addEventListener("touchend", i)), () => {
|
|
3868
3868
|
window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", i), window.removeEventListener("touchmove", t), window.removeEventListener("touchend", i);
|
|
@@ -3876,9 +3876,9 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
3876
3876
|
x: i - T.x,
|
|
3877
3877
|
y: r - T.y
|
|
3878
3878
|
};
|
|
3879
|
-
const
|
|
3880
|
-
if (
|
|
3881
|
-
const b =
|
|
3879
|
+
const h = document.querySelector(".cme-editor-popup");
|
|
3880
|
+
if (h) {
|
|
3881
|
+
const b = h.getBoundingClientRect();
|
|
3882
3882
|
se.current = {
|
|
3883
3883
|
left: b.left - T.x,
|
|
3884
3884
|
top: b.top - T.y,
|
|
@@ -3896,13 +3896,13 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
3896
3896
|
fontSize: "auto"
|
|
3897
3897
|
}), F = he(() => {
|
|
3898
3898
|
if (J || window.__cmeIgnoreStyleUpdate && Date.now() - window.__cmeIgnoreStyleUpdate < 150) return;
|
|
3899
|
-
const t =
|
|
3899
|
+
const t = s.current;
|
|
3900
3900
|
if (!(!t || typeof t.queryStyle != "function"))
|
|
3901
3901
|
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",
|
|
3903
|
-
(
|
|
3902
|
+
const i = window.__cmeManualBold !== void 0 ? window.__cmeManualBold : t.queryStyle({ fontSeries: "b" }) === "all" || t.queryStyle({ variantStyle: "bold" }) === "all", r = window.__cmeManualItalic !== void 0 ? window.__cmeManualItalic : t.queryStyle({ variantStyle: "italic" }) === "all" || t.queryStyle({ shape: "it" }) === "all", h = window.__cmeManualFontFamily !== void 0 ? window.__cmeManualFontFamily : ["roman", "sans-serif", "monospace"].find(
|
|
3903
|
+
(c) => t.queryStyle({ fontFamily: c }) === "all"
|
|
3904
3904
|
) || "none", b = window.__cmeManualFontSize !== void 0 ? window.__cmeManualFontSize : [5, 7, 9].find(
|
|
3905
|
-
(
|
|
3905
|
+
(c) => t.queryStyle({ fontSize: c }) === "all"
|
|
3906
3906
|
) || "auto", w = [
|
|
3907
3907
|
"black",
|
|
3908
3908
|
"dimgray",
|
|
@@ -3929,12 +3929,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
3929
3929
|
"violet",
|
|
3930
3930
|
"gold"
|
|
3931
3931
|
].find(
|
|
3932
|
-
(
|
|
3932
|
+
(c) => t.queryStyle({ color: c }) === "all"
|
|
3933
3933
|
) || "none";
|
|
3934
|
-
ce((
|
|
3934
|
+
ce((c) => ({
|
|
3935
3935
|
bold: i,
|
|
3936
3936
|
italic: r,
|
|
3937
|
-
fontFamily:
|
|
3937
|
+
fontFamily: h,
|
|
3938
3938
|
fontSize: String(b),
|
|
3939
3939
|
color: w
|
|
3940
3940
|
}));
|
|
@@ -3967,18 +3967,18 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
3967
3967
|
if (!t) return;
|
|
3968
3968
|
t.macros = { ...t.macros, ...window.__cme_macros || {} }, t.defaultMode = "math";
|
|
3969
3969
|
const i = () => {
|
|
3970
|
-
if (typeof t.applyStyle == "function" && t.applyStyle({ variantStyle: "up" }),
|
|
3971
|
-
let r = ge(
|
|
3970
|
+
if (typeof t.applyStyle == "function" && t.applyStyle({ variantStyle: "up" }), m) {
|
|
3971
|
+
let r = ge(m);
|
|
3972
3972
|
if (l === "chem") {
|
|
3973
|
-
const
|
|
3974
|
-
|
|
3973
|
+
const h = r.match(/^\\ce\{([\s\S]*)\}$/i);
|
|
3974
|
+
h && (r = h[1]);
|
|
3975
3975
|
}
|
|
3976
3976
|
r = X(r), r = ne(r), t.setValue ? t.setValue("", { silenceNotifications: !0 }) : t.value = "", t.executeCommand(["insert", r, { insertionMode: "replaceAll" }]);
|
|
3977
3977
|
}
|
|
3978
3978
|
requestAnimationFrame(() => t.focus());
|
|
3979
3979
|
};
|
|
3980
3980
|
customElements.get("math-field") ? requestAnimationFrame(i) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(i));
|
|
3981
|
-
}, [l,
|
|
3981
|
+
}, [l, m]), O(() => {
|
|
3982
3982
|
const t = U;
|
|
3983
3983
|
if (!t) return;
|
|
3984
3984
|
const i = (r) => {
|
|
@@ -3986,17 +3986,17 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
3986
3986
|
J = !1;
|
|
3987
3987
|
}, 500)), ["`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "_", '"', "'", "/", "\\", "|"].includes(r.key) && !r.ctrlKey && !r.metaKey && !r.altKey) {
|
|
3988
3988
|
r.preventDefault(), r.stopPropagation();
|
|
3989
|
-
let
|
|
3990
|
-
r.key === "`" ?
|
|
3989
|
+
let h = "";
|
|
3990
|
+
r.key === "`" ? h = "\\grave{\\ }" : r.key === "~" ? h = "\\sim" : r.key === "!" ? h = "!" : r.key === "@" ? h = "@" : r.key === "#" ? h = "\\#" : r.key === "$" ? h = "\\$" : r.key === "%" ? h = "\\%" : r.key === "^" ? h = "\\wedge" : r.key === "&" ? h = "\\&" : r.key === "*" ? h = "\\ast" : r.key === "_" ? h = "\\_" : r.key === '"' ? h = '\\text{"}' : r.key === "'" ? h = "\\text{'}" : r.key === "/" ? h = "\\mathord{/}" : r.key === "\\" ? h = "\\backslash" : r.key === "|" && (h = "|"), t.executeCommand(["insert", h]);
|
|
3991
3991
|
return;
|
|
3992
3992
|
}
|
|
3993
3993
|
if (r.key.length === 1 && !r.ctrlKey && !r.metaKey && !r.altKey && /[a-zA-Z0-9]/.test(r.key)) {
|
|
3994
3994
|
r.preventDefault(), r.stopPropagation();
|
|
3995
|
-
const
|
|
3995
|
+
const h = f.fontFamily === "sans-serif", b = f.fontFamily === "monospace", w = f.bold, c = f.italic;
|
|
3996
3996
|
let C = "\\mathrm";
|
|
3997
|
-
|
|
3997
|
+
h ? C = "\\mathsf" : b ? C = "\\mathtt" : c && !w ? C = "\\mathit" : w && !c && (C = "\\mathbf");
|
|
3998
3998
|
let M = `${C}{${r.key}}`;
|
|
3999
|
-
w &&
|
|
3999
|
+
w && c ? (M = `\\mathbfit{${r.key}}`, h && (M = `\\boldsymbol{\\mathsf{${r.key}}}`), b && (M = `\\boldsymbol{\\mathtt{${r.key}}}`)) : w && (h || b) && (M = `\\boldsymbol{${M}}`);
|
|
4000
4000
|
let R = M;
|
|
4001
4001
|
const H = f.fontSize === "auto" ? 5 : parseInt(f.fontSize, 10);
|
|
4002
4002
|
if (H !== 5) {
|
|
@@ -4016,8 +4016,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4016
4016
|
setTimeout(() => {
|
|
4017
4017
|
const r = t.shadowRoot;
|
|
4018
4018
|
if (!r) return;
|
|
4019
|
-
const
|
|
4020
|
-
|
|
4019
|
+
const h = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
|
|
4020
|
+
h && h.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }), F();
|
|
4021
4021
|
}, 0);
|
|
4022
4022
|
};
|
|
4023
4023
|
return t.addEventListener("selection-change", i), t.addEventListener("input", i), t.addEventListener("keydown", i), setTimeout(F, 50), () => {
|
|
@@ -4028,13 +4028,13 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4028
4028
|
const i = U;
|
|
4029
4029
|
i && (i.focus(), i.executeCommand(["insert", t]));
|
|
4030
4030
|
}, []), De = he((t, i, r) => {
|
|
4031
|
-
let
|
|
4031
|
+
let h = `\\begin{${t}} `;
|
|
4032
4032
|
for (let b = 0; b < i; b++) {
|
|
4033
4033
|
for (let w = 0; w < r; w++)
|
|
4034
|
-
|
|
4035
|
-
b < i - 1 && (
|
|
4034
|
+
h += "#?", w < r - 1 && (h += " & ");
|
|
4035
|
+
b < i - 1 && (h += " \\\\ ");
|
|
4036
4036
|
}
|
|
4037
|
-
|
|
4037
|
+
h += ` \\end{${t}}`, Q(h);
|
|
4038
4038
|
}, [Q]), Ne = (t) => {
|
|
4039
4039
|
t.stopPropagation(), ke((i) => !i), ue(!1), L({ x: 0, y: 0 });
|
|
4040
4040
|
}, Re = (t) => {
|
|
@@ -4046,8 +4046,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4046
4046
|
a && a();
|
|
4047
4047
|
return;
|
|
4048
4048
|
}
|
|
4049
|
-
const r = i.getValue ? i.getValue("latex") : i.value,
|
|
4050
|
-
!r || r.trim() === "" || r ===
|
|
4049
|
+
const r = i.getValue ? i.getValue("latex") : i.value, h = m || "";
|
|
4050
|
+
!r || r.trim() === "" || r === h ? a && a() : Y(!0);
|
|
4051
4051
|
}, Oe = () => {
|
|
4052
4052
|
const t = U;
|
|
4053
4053
|
if (!t) return;
|
|
@@ -4059,8 +4059,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4059
4059
|
l === "chem" && (i = et(i)), i = X(i);
|
|
4060
4060
|
const r = i.match(/^\\(mathrm|mathit|mathbf|mathsf|text)\{\\displaylines\{([\s\S]*)\}\}$/);
|
|
4061
4061
|
if (r) {
|
|
4062
|
-
const
|
|
4063
|
-
i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${
|
|
4062
|
+
const h = r[1];
|
|
4063
|
+
i = `\\displaylines{${r[2].split("\\\\").map((C) => `\\${h}{${C.trim()}}`).join(" \\\\ ")}}`;
|
|
4064
4064
|
}
|
|
4065
4065
|
i = i.replace(/[\r\n]+/g, " "), o && o(i), t.setValue ? t.setValue("") : t.value = "", a && a();
|
|
4066
4066
|
};
|
|
@@ -4070,13 +4070,13 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4070
4070
|
{
|
|
4071
4071
|
className: `cme-editor-popup ${_ ? "maximized" : ""} ${Ie ? "minimized" : ""}`,
|
|
4072
4072
|
style: { transform: `translate(${T.x}px, ${T.y}px)` },
|
|
4073
|
-
|
|
4073
|
+
onPointerDown: (t) => t.stopPropagation()
|
|
4074
4074
|
},
|
|
4075
4075
|
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-topbar" }, /* @__PURE__ */ e.createElement(
|
|
4076
4076
|
"div",
|
|
4077
4077
|
{
|
|
4078
4078
|
className: "cme-popup-header",
|
|
4079
|
-
|
|
4079
|
+
onPointerDown: we,
|
|
4080
4080
|
onTouchStart: we,
|
|
4081
4081
|
style: { cursor: q ? "grabbing" : "grab", touchAction: "none" }
|
|
4082
4082
|
},
|
|
@@ -4090,8 +4090,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4090
4090
|
key: t.isMatrix ? "matrix-tab" : t.label,
|
|
4091
4091
|
className: `cme-group-tab${r ? " active" : ""}`,
|
|
4092
4092
|
type: "button",
|
|
4093
|
-
|
|
4094
|
-
|
|
4093
|
+
onPointerDown: (h) => {
|
|
4094
|
+
h.preventDefault(), p(i), I(null);
|
|
4095
4095
|
}
|
|
4096
4096
|
},
|
|
4097
4097
|
t.mathLabel ? /* @__PURE__ */ e.createElement(
|
|
@@ -4118,8 +4118,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4118
4118
|
) : t.label
|
|
4119
4119
|
);
|
|
4120
4120
|
})), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
|
|
4121
|
-
var
|
|
4122
|
-
const t = ((
|
|
4121
|
+
var h;
|
|
4122
|
+
const t = ((h = G[d]) == null ? void 0 : h.items) || [], i = t.some((b) => b.type === "sep"), r = [];
|
|
4123
4123
|
if (i) {
|
|
4124
4124
|
let b = { cols: 2, small: !1, cls: "", items: [], moreItems: null };
|
|
4125
4125
|
for (const w of t)
|
|
@@ -4146,24 +4146,24 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4146
4146
|
type: "button",
|
|
4147
4147
|
className: "cme-more-trigger-btn",
|
|
4148
4148
|
title: "more",
|
|
4149
|
-
|
|
4150
|
-
|
|
4149
|
+
onPointerDown: (c) => {
|
|
4150
|
+
c.preventDefault();
|
|
4151
4151
|
},
|
|
4152
|
-
onClick: (
|
|
4153
|
-
if (
|
|
4152
|
+
onClick: (c) => {
|
|
4153
|
+
if (c.stopPropagation(), k && k.items === b.moreItems)
|
|
4154
4154
|
y(null);
|
|
4155
4155
|
else {
|
|
4156
|
-
const C =
|
|
4156
|
+
const C = c.currentTarget.getBoundingClientRect(), M = G[d] || {};
|
|
4157
4157
|
y({ cx: C.left + C.width / 2, y: C.bottom, items: b.moreItems, cols: b.moreCols, isTemplate: M.isTemplate || M.label === "√(□)" || M.isMatrix });
|
|
4158
4158
|
}
|
|
4159
4159
|
}
|
|
4160
4160
|
},
|
|
4161
4161
|
"▶"
|
|
4162
4162
|
),
|
|
4163
|
-
b.items.map((
|
|
4163
|
+
b.items.map((c, C) => {
|
|
4164
4164
|
const M = G[d];
|
|
4165
|
-
if (
|
|
4166
|
-
const N =
|
|
4165
|
+
if (c.type === "dropdown") {
|
|
4166
|
+
const N = c.label === "Font...", v = c.label === "Size", $ = N && f.fontFamily !== "none", ee = v && f.fontSize !== "auto" && f.fontSize !== "5", te = N ? f.fontFamily === "none" ? "" : f.fontFamily : v ? f.fontSize === "auto" || f.fontSize === "5" ? "" : f.fontSize : "";
|
|
4167
4167
|
return /* @__PURE__ */ e.createElement(
|
|
4168
4168
|
"select",
|
|
4169
4169
|
{
|
|
@@ -4171,7 +4171,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4171
4171
|
className: `cme-btn template${$ || ee ? " active" : ""}`,
|
|
4172
4172
|
value: te,
|
|
4173
4173
|
style: {
|
|
4174
|
-
width:
|
|
4174
|
+
width: c.width || "60px",
|
|
4175
4175
|
height: "18px",
|
|
4176
4176
|
minHeight: "18px",
|
|
4177
4177
|
maxHeight: "18px",
|
|
@@ -4188,12 +4188,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4188
4188
|
!V || typeof V.applyStyle != "function" || (V.focus(), N ? V.applyStyle({ fontFamily: Z || "none" }) : v && V.applyStyle({ fontSize: Z ? parseInt(Z, 10) : "auto" }), F());
|
|
4189
4189
|
}
|
|
4190
4190
|
},
|
|
4191
|
-
/* @__PURE__ */ e.createElement("option", { value: "" },
|
|
4191
|
+
/* @__PURE__ */ e.createElement("option", { value: "" }, c.label),
|
|
4192
4192
|
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
4193
|
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
4194
|
);
|
|
4195
4195
|
}
|
|
4196
|
-
if (M.isMatrix && !
|
|
4196
|
+
if (M.isMatrix && !c.directInsert)
|
|
4197
4197
|
return /* @__PURE__ */ e.createElement(
|
|
4198
4198
|
"div",
|
|
4199
4199
|
{
|
|
@@ -4204,23 +4204,23 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4204
4204
|
"button",
|
|
4205
4205
|
{
|
|
4206
4206
|
type: "button",
|
|
4207
|
-
className: `cme-btn template${
|
|
4208
|
-
title:
|
|
4209
|
-
|
|
4210
|
-
if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) ===
|
|
4207
|
+
className: `cme-btn template${c.cls ? ` ${c.cls}` : ""}${M.isMatrix ? " cme-matrix-btn-small" : ""}`,
|
|
4208
|
+
title: c.title || c.label || c.insert,
|
|
4209
|
+
onPointerDown: (N) => {
|
|
4210
|
+
if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === c.insert)
|
|
4211
4211
|
I(null);
|
|
4212
4212
|
else {
|
|
4213
4213
|
J || (window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0);
|
|
4214
4214
|
const v = N.currentTarget.getBoundingClientRect();
|
|
4215
4215
|
I({
|
|
4216
|
-
type:
|
|
4216
|
+
type: c.insert,
|
|
4217
4217
|
x: v.left + v.width / 2,
|
|
4218
4218
|
y: v.bottom
|
|
4219
4219
|
});
|
|
4220
4220
|
}
|
|
4221
4221
|
}
|
|
4222
4222
|
},
|
|
4223
|
-
typeof
|
|
4223
|
+
typeof c.label == "object" ? c.label : /* @__PURE__ */ e.createElement(
|
|
4224
4224
|
"math-field",
|
|
4225
4225
|
{
|
|
4226
4226
|
"read-only": !0,
|
|
@@ -4239,29 +4239,29 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4239
4239
|
cursor: "pointer"
|
|
4240
4240
|
}
|
|
4241
4241
|
},
|
|
4242
|
-
pe(
|
|
4242
|
+
pe(c.mathLabel != null ? c.mathLabel : c.insert)
|
|
4243
4243
|
)
|
|
4244
4244
|
)
|
|
4245
4245
|
);
|
|
4246
|
-
const R =
|
|
4246
|
+
const R = c.action === "BOLD", H = c.action === "ITALIC", P = c.action === "TEXT_COLOR", He = R && f.bold || H && f.italic || P && f.color !== "none" && f.color !== "black";
|
|
4247
4247
|
return /* @__PURE__ */ e.createElement(
|
|
4248
4248
|
"button",
|
|
4249
4249
|
{
|
|
4250
4250
|
key: `${M.label}-${w * 4 + C}`,
|
|
4251
4251
|
type: "button",
|
|
4252
|
-
className: `cme-btn${M.isTemplate ? " template" : ""}${
|
|
4253
|
-
title:
|
|
4254
|
-
|
|
4252
|
+
className: `cme-btn${M.isTemplate ? " template" : ""}${c.cls ? ` ${c.cls}` : ""}${He ? " active" : ""}`,
|
|
4253
|
+
title: c.title || c.label || c.insert,
|
|
4254
|
+
onPointerDown: (N) => {
|
|
4255
4255
|
var $, ee, te, le, Z, V, Ee;
|
|
4256
4256
|
N.preventDefault();
|
|
4257
|
-
const v =
|
|
4258
|
-
if (
|
|
4257
|
+
const v = s.current;
|
|
4258
|
+
if (c.action === "SPECIAL_CHARS") {
|
|
4259
4259
|
const S = N.currentTarget.getBoundingClientRect();
|
|
4260
4260
|
A({ x: S.left, y: S.bottom + 4 });
|
|
4261
|
-
} else if (
|
|
4261
|
+
} else if (c.action === "TEXT_COLOR") {
|
|
4262
4262
|
const S = N.currentTarget.getBoundingClientRect();
|
|
4263
4263
|
E({ x: S.left, y: S.bottom + 4 });
|
|
4264
|
-
} else if (
|
|
4264
|
+
} else if (c.action === "BOLD") {
|
|
4265
4265
|
if (v) {
|
|
4266
4266
|
v.focus();
|
|
4267
4267
|
const S = !f.bold;
|
|
@@ -4273,7 +4273,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4273
4273
|
}
|
|
4274
4274
|
ce((W) => ({ ...W, bold: S }));
|
|
4275
4275
|
}
|
|
4276
|
-
} else if (
|
|
4276
|
+
} else if (c.action === "ITALIC") {
|
|
4277
4277
|
if (v) {
|
|
4278
4278
|
v.focus();
|
|
4279
4279
|
const S = !f.italic;
|
|
@@ -4285,16 +4285,16 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4285
4285
|
}
|
|
4286
4286
|
ce((W) => ({ ...W, italic: S }));
|
|
4287
4287
|
}
|
|
4288
|
-
} else
|
|
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) => {
|
|
4289
4289
|
var D;
|
|
4290
|
-
(D =
|
|
4290
|
+
(D = s.current) == null || D.executeCommand(["insert", S]);
|
|
4291
4291
|
}).catch((S) => {
|
|
4292
4292
|
var D;
|
|
4293
|
-
(D =
|
|
4294
|
-
})) : Q(
|
|
4293
|
+
(D = s.current) == null || D.executeCommand("pasteFromClipboard");
|
|
4294
|
+
})) : Q(c.insert);
|
|
4295
4295
|
}
|
|
4296
4296
|
},
|
|
4297
|
-
(M.isTemplate || M.label === "√(□)" || M.isMatrix ||
|
|
4297
|
+
(M.isTemplate || M.label === "√(□)" || M.isMatrix || c.isWidget) && c.insert && !c.action && !c.forceLabel ? /* @__PURE__ */ e.createElement(
|
|
4298
4298
|
"math-field",
|
|
4299
4299
|
{
|
|
4300
4300
|
"read-only": !0,
|
|
@@ -4313,8 +4313,8 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4313
4313
|
cursor: "pointer"
|
|
4314
4314
|
}
|
|
4315
4315
|
},
|
|
4316
|
-
pe(
|
|
4317
|
-
) :
|
|
4316
|
+
pe(c.insert)
|
|
4317
|
+
) : c.label
|
|
4318
4318
|
);
|
|
4319
4319
|
})
|
|
4320
4320
|
));
|
|
@@ -4325,12 +4325,12 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4325
4325
|
ref: (t) => {
|
|
4326
4326
|
t && requestAnimationFrame(() => {
|
|
4327
4327
|
const i = t.getBoundingClientRect(), r = document.querySelector(".cme-editor-popup");
|
|
4328
|
-
let
|
|
4328
|
+
let h = k.cx - i.width / 2, b = k.y;
|
|
4329
4329
|
if (r) {
|
|
4330
4330
|
const w = r.getBoundingClientRect();
|
|
4331
|
-
|
|
4331
|
+
h + i.width > w.right - 4 && (h = w.right - i.width - 4), h < w.left + 4 && (h = w.left + 4), b + i.height > w.bottom - 4 && (b = w.bottom - i.height - 4);
|
|
4332
4332
|
}
|
|
4333
|
-
|
|
4333
|
+
h + i.width > window.innerWidth - 4 && (h = window.innerWidth - i.width - 4), b + i.height > window.innerHeight - 4 && (b = window.innerHeight - i.height - 4), h < 4 && (h = 4), t.style.left = `${h}px`, t.style.top = `${b}px`, t.style.transform = "none";
|
|
4334
4334
|
});
|
|
4335
4335
|
},
|
|
4336
4336
|
className: "cme-more-popup",
|
|
@@ -4350,7 +4350,7 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4350
4350
|
type: "button",
|
|
4351
4351
|
className: `cme-more-popup-btn ${t.cls || ""}`,
|
|
4352
4352
|
title: t.title || t.label || t.insert,
|
|
4353
|
-
|
|
4353
|
+
onPointerDown: (r) => {
|
|
4354
4354
|
r.preventDefault(), Q(t.insert), y(null);
|
|
4355
4355
|
}
|
|
4356
4356
|
},
|
|
@@ -4381,18 +4381,20 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4381
4381
|
"div",
|
|
4382
4382
|
{
|
|
4383
4383
|
className: "cme-mathfield-container",
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4384
|
+
onPointerDown: (t) => {
|
|
4385
|
+
var i, r;
|
|
4386
|
+
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));
|
|
4387
|
+
},
|
|
4388
|
+
onTouchStart: (t) => {
|
|
4389
|
+
var i, r;
|
|
4390
|
+
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
4391
|
}
|
|
4390
4392
|
},
|
|
4391
4393
|
/* @__PURE__ */ e.createElement(
|
|
4392
4394
|
"math-field",
|
|
4393
4395
|
{
|
|
4394
4396
|
ref: (t) => {
|
|
4395
|
-
|
|
4397
|
+
s.current = t, U = t, t && (t.inlineShortcuts = Object.assign({}, t.inlineShortcuts, { "*": "*" }), window.mathVirtualKeyboard && (window.mathVirtualKeyboard.policy = "manual"));
|
|
4396
4398
|
},
|
|
4397
4399
|
class: "cme-mathfield",
|
|
4398
4400
|
tabIndex: 0,
|
|
@@ -4402,9 +4404,9 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4402
4404
|
)
|
|
4403
4405
|
),
|
|
4404
4406
|
/* @__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",
|
|
4407
|
+
Be && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onPointerDown: (t) => {
|
|
4406
4408
|
t.stopPropagation(), Y(!1);
|
|
4407
|
-
} }, /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-modal",
|
|
4409
|
+
} }, /* @__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
4410
|
t.stopPropagation(), Y(!1), a && a();
|
|
4409
4411
|
} }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
|
|
4410
4412
|
t.stopPropagation(), Y(!1);
|
|
@@ -4501,10 +4503,10 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4501
4503
|
border: i ? "2px solid #e6c229" : "1px solid #000",
|
|
4502
4504
|
boxSizing: "border-box"
|
|
4503
4505
|
},
|
|
4504
|
-
|
|
4506
|
+
onPointerDown: (r) => {
|
|
4505
4507
|
r.preventDefault(), r.stopPropagation();
|
|
4506
|
-
const
|
|
4507
|
-
|
|
4508
|
+
const h = s.current;
|
|
4509
|
+
h && typeof h.applyStyle == "function" && (h.focus(), h.applyStyle({ color: t === "black" ? "none" : t }), F()), E(null);
|
|
4508
4510
|
}
|
|
4509
4511
|
}
|
|
4510
4512
|
);
|
|
@@ -4516,11 +4518,11 @@ function lt({ mode: l, onInsert: o, onClose: a, initialLatex: h, isEditing: n })
|
|
|
4516
4518
|
document.body
|
|
4517
4519
|
);
|
|
4518
4520
|
}
|
|
4519
|
-
const ht = ({ isOpen: l, mode: o, initialValue: a, onInsert:
|
|
4521
|
+
const ht = ({ isOpen: l, mode: o, initialValue: a, onInsert: m, onClose: n }) => l ? /* @__PURE__ */ e.createElement(
|
|
4520
4522
|
lt,
|
|
4521
4523
|
{
|
|
4522
4524
|
mode: o,
|
|
4523
|
-
onInsert:
|
|
4525
|
+
onInsert: m,
|
|
4524
4526
|
onClose: n,
|
|
4525
4527
|
initialLatex: a || "",
|
|
4526
4528
|
isEditing: !!a
|