digi-mathchem-editor 1.0.9 → 1.0.11
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.
|
@@ -302,10 +302,10 @@ const Me = "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
|
|
306
|
-
let
|
|
307
|
-
|
|
308
|
-
${
|
|
305
|
+
const a = l.hasAttribute("read-only") || l.hasAttribute("readonly"), s = a ? "readonly" : "editable";
|
|
306
|
+
let n = o.querySelector(`[${ye}]`);
|
|
307
|
+
n && n.getAttribute("data-cache") === s || (n || (n = document.createElement("style"), n.setAttribute(ye, "true"), o.appendChild(n)), n.setAttribute("data-cache", s), n.textContent = `
|
|
308
|
+
${a ? `
|
|
309
309
|
:host, :host * { cursor: pointer !important; }
|
|
310
310
|
.ML__latex, .ML__content, .ML__container, .ML__virtual-keyboard-toggle { cursor: pointer !important; }
|
|
311
311
|
` : ""}
|
|
@@ -318,15 +318,15 @@ function qe() {
|
|
|
318
318
|
let me = null;
|
|
319
319
|
function Fe() {
|
|
320
320
|
me || (qe(), me = new MutationObserver((l) => {
|
|
321
|
-
var o,
|
|
322
|
-
for (const
|
|
323
|
-
if (
|
|
324
|
-
ie(
|
|
321
|
+
var o, a, s;
|
|
322
|
+
for (const n of l) {
|
|
323
|
+
if (n.type === "attributes" && ((o = n.target.tagName) == null ? void 0 : o.toLowerCase()) === "math-field") {
|
|
324
|
+
ie(n.target);
|
|
325
325
|
continue;
|
|
326
326
|
}
|
|
327
|
-
if (
|
|
328
|
-
for (const c of
|
|
329
|
-
c instanceof Element && (((
|
|
327
|
+
if (n.addedNodes)
|
|
328
|
+
for (const c of n.addedNodes)
|
|
329
|
+
c instanceof Element && (((a = c.tagName) == null ? void 0 : a.toLowerCase()) === "math-field" && requestAnimationFrame(() => ie(c)), (s = c.querySelectorAll) == null || s.call(c, "math-field").forEach((m) => requestAnimationFrame(() => ie(m))));
|
|
330
330
|
}
|
|
331
331
|
}), me.observe(document.body, {
|
|
332
332
|
childList: !0,
|
|
@@ -347,39 +347,39 @@ const Ce = [
|
|
|
347
347
|
], Ze = () => {
|
|
348
348
|
const l = [];
|
|
349
349
|
return Ce.slice(1).forEach((o) => {
|
|
350
|
-
o.ranges.forEach((
|
|
351
|
-
for (let s =
|
|
350
|
+
o.ranges.forEach((a) => {
|
|
351
|
+
for (let s = a[0]; s <= a[1]; s++) {
|
|
352
352
|
if (s >= 127 && s <= 159) continue;
|
|
353
|
-
const
|
|
354
|
-
new RegExp("\\p{C}", "u").test(
|
|
353
|
+
const n = String.fromCodePoint(s);
|
|
354
|
+
new RegExp("\\p{C}", "u").test(n) || l.push({
|
|
355
355
|
code: s.toString(16).toUpperCase().padStart(4, "0"),
|
|
356
|
-
char:
|
|
356
|
+
char: n,
|
|
357
357
|
category: o.id
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
});
|
|
361
361
|
}), l;
|
|
362
362
|
}, Je = Ze();
|
|
363
|
-
function je({ isOpen: l, onClose: o, onInsert:
|
|
364
|
-
const [
|
|
363
|
+
function je({ isOpen: l, onClose: o, onInsert: a, position: s }) {
|
|
364
|
+
const [n, c] = B(""), [m, u] = B("All");
|
|
365
365
|
O(() => {
|
|
366
366
|
l && (c(""), u("All"));
|
|
367
367
|
}, [l]);
|
|
368
368
|
const x = xe(() => {
|
|
369
369
|
let k = Je;
|
|
370
|
-
if (m !== "All" && (k = k.filter((E) => E.category === m)),
|
|
371
|
-
const E =
|
|
370
|
+
if (m !== "All" && (k = k.filter((E) => E.category === m)), n.trim()) {
|
|
371
|
+
const E = n.trim().toUpperCase();
|
|
372
372
|
k = k.filter((b) => b.code.includes(E));
|
|
373
373
|
}
|
|
374
374
|
return k;
|
|
375
|
-
}, [m,
|
|
376
|
-
if (m !== "All" && !
|
|
375
|
+
}, [m, n]), I = xe(() => {
|
|
376
|
+
if (m !== "All" && !n.trim())
|
|
377
377
|
return { [m]: x };
|
|
378
378
|
const k = {};
|
|
379
379
|
return x.forEach((E) => {
|
|
380
380
|
k[E.category] || (k[E.category] = []), k[E.category].push(E);
|
|
381
381
|
}), k;
|
|
382
|
-
}, [x, m,
|
|
382
|
+
}, [x, m, n]), p = (k) => {
|
|
383
383
|
k.key === "Escape" && o();
|
|
384
384
|
};
|
|
385
385
|
if (O(() => (l && window.addEventListener("keydown", p), () => window.removeEventListener("keydown", p)), [l]), !l) return null;
|
|
@@ -395,7 +395,7 @@ function je({ isOpen: l, onClose: o, onInsert: n, position: s }) {
|
|
|
395
395
|
{
|
|
396
396
|
type: "text",
|
|
397
397
|
placeholder: "Code",
|
|
398
|
-
value:
|
|
398
|
+
value: n,
|
|
399
399
|
onChange: (k) => c(k.target.value),
|
|
400
400
|
className: "scm-code-input"
|
|
401
401
|
}
|
|
@@ -413,7 +413,7 @@ function je({ isOpen: l, onClose: o, onInsert: n, position: s }) {
|
|
|
413
413
|
key: b.code,
|
|
414
414
|
className: "scm-char-btn",
|
|
415
415
|
onClick: () => {
|
|
416
|
-
|
|
416
|
+
a(b.char), o();
|
|
417
417
|
},
|
|
418
418
|
title: `U+${b.code}`
|
|
419
419
|
},
|
|
@@ -449,52 +449,52 @@ typeof window < "u" && (window.MathfieldElement ? window.MathfieldElement.fontsD
|
|
|
449
449
|
window.__ckMathWidgets = window.__ckMathWidgets || /* @__PURE__ */ new Map();
|
|
450
450
|
window.__ckMathWidgetClickHandler = null;
|
|
451
451
|
function Qe(l) {
|
|
452
|
-
var
|
|
452
|
+
var a, s, n, c, m;
|
|
453
453
|
if (!l) return null;
|
|
454
454
|
const o = typeof l.composedPath == "function" ? l.composedPath() : [l];
|
|
455
455
|
for (const u of o)
|
|
456
|
-
if (u instanceof HTMLElement && ((
|
|
456
|
+
if (u instanceof HTMLElement && ((a = u.classList) != null && a.contains("ck-math-widget") || (s = u.dataset) != null && s.mathId || (n = u.classList) != null && n.contains("ck-widget") && ((c = u.querySelector) != null && c.call(u, ".ck-math-widget-inner"))))
|
|
457
457
|
return u;
|
|
458
458
|
return l instanceof Element ? (m = l.closest) == null ? void 0 : m.call(l, ".ck-math-widget, [data-math-id]") : null;
|
|
459
459
|
}
|
|
460
460
|
function de(l) {
|
|
461
461
|
if (!l) return "";
|
|
462
|
-
let o = "",
|
|
463
|
-
for (;
|
|
464
|
-
let s = l.indexOf("\\placeholder",
|
|
462
|
+
let o = "", a = 0;
|
|
463
|
+
for (; a < l.length; ) {
|
|
464
|
+
let s = l.indexOf("\\placeholder", a);
|
|
465
465
|
if (s === -1) {
|
|
466
|
-
o += l.slice(
|
|
466
|
+
o += l.slice(a);
|
|
467
467
|
break;
|
|
468
468
|
}
|
|
469
|
-
if (o += l.slice(
|
|
470
|
-
let
|
|
471
|
-
for (
|
|
472
|
-
l[
|
|
469
|
+
if (o += l.slice(a, s), a = s + 12, l[a] === "[") {
|
|
470
|
+
let n = 1;
|
|
471
|
+
for (a++; a < l.length && n > 0; )
|
|
472
|
+
l[a] === "[" ? n++ : l[a] === "]" && n--, a++;
|
|
473
473
|
}
|
|
474
|
-
if (l[
|
|
475
|
-
let
|
|
476
|
-
for (
|
|
477
|
-
l[
|
|
478
|
-
let m = l.slice(c,
|
|
474
|
+
if (l[a] === "{") {
|
|
475
|
+
let n = 1, c = a + 1;
|
|
476
|
+
for (a++; a < l.length && n > 0; )
|
|
477
|
+
l[a] === "{" ? n++ : l[a] === "}" && n--, a++;
|
|
478
|
+
let m = l.slice(c, a - 1);
|
|
479
479
|
m.trim() === "" ? o += "\\quad " : o += m;
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
return o;
|
|
483
483
|
}
|
|
484
484
|
function z(l) {
|
|
485
|
-
let o = "",
|
|
485
|
+
let o = "", a = 0;
|
|
486
486
|
const s = "\\text{";
|
|
487
|
-
for (;
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
490
|
-
o += l.slice(
|
|
487
|
+
for (; a < l.length; ) {
|
|
488
|
+
const n = l.indexOf(s, a);
|
|
489
|
+
if (n === -1) {
|
|
490
|
+
o += l.slice(a);
|
|
491
491
|
break;
|
|
492
492
|
}
|
|
493
|
-
o += l.slice(
|
|
494
|
-
let c = 1, m =
|
|
493
|
+
o += l.slice(a, n);
|
|
494
|
+
let c = 1, m = n + s.length;
|
|
495
495
|
for (; m < l.length && c > 0; )
|
|
496
496
|
l[m] === "{" ? c++ : l[m] === "}" && c--, m++;
|
|
497
|
-
o += l.slice(
|
|
497
|
+
o += l.slice(n + s.length, m - 1), a = m;
|
|
498
498
|
}
|
|
499
499
|
return o;
|
|
500
500
|
}
|
|
@@ -505,8 +505,8 @@ function oe(l) {
|
|
|
505
505
|
if (!l) return "";
|
|
506
506
|
const o = l.getAttribute("data-latex");
|
|
507
507
|
if (o) return o;
|
|
508
|
-
const
|
|
509
|
-
return
|
|
508
|
+
const a = l.querySelector("math-field");
|
|
509
|
+
return a ? a.getValue ? a.getValue("latex-expanded") : a.value || "" : "";
|
|
510
510
|
}
|
|
511
511
|
function Le(l, o) {
|
|
512
512
|
if (!l || !o) return !1;
|
|
@@ -519,16 +519,16 @@ function Le(l, o) {
|
|
|
519
519
|
function ze(l, o) {
|
|
520
520
|
var u;
|
|
521
521
|
if (!l || !o) return null;
|
|
522
|
-
const
|
|
523
|
-
if ((
|
|
522
|
+
const a = l.model.document.selection.getSelectedElement();
|
|
523
|
+
if ((a == null ? void 0 : a.name) === "mathInline") return a;
|
|
524
524
|
const s = o.getAttribute("data-math-id");
|
|
525
525
|
if (s) {
|
|
526
526
|
const x = window.__ckMathWidgets.get(s);
|
|
527
527
|
if (Le(l, x)) return x;
|
|
528
528
|
}
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
const x = l.editing.mapper.toModelElement(
|
|
529
|
+
const n = l.editing.view.domConverter.mapDomToView(o);
|
|
530
|
+
if (n) {
|
|
531
|
+
const x = l.editing.mapper.toModelElement(n);
|
|
532
532
|
if ((x == null ? void 0 : x.name) === "mathInline") return x;
|
|
533
533
|
}
|
|
534
534
|
const c = oe(o);
|
|
@@ -539,21 +539,21 @@ function ze(l, o) {
|
|
|
539
539
|
return x;
|
|
540
540
|
return null;
|
|
541
541
|
}
|
|
542
|
-
function Se(l, o,
|
|
542
|
+
function Se(l, o, a, s) {
|
|
543
543
|
if (!l || l._mathWidgetOpening) return;
|
|
544
544
|
l._mathWidgetOpening = !0, queueMicrotask(() => {
|
|
545
545
|
l._mathWidgetOpening = !1;
|
|
546
546
|
});
|
|
547
|
-
const
|
|
547
|
+
const n = Le(l, o) ? o : ze(l, s), c = (n == null ? void 0 : n.getAttribute("latex")) || a || oe(s);
|
|
548
548
|
if (!c) return;
|
|
549
|
-
|
|
550
|
-
u.setSelection(
|
|
549
|
+
n && l.model.change((u) => {
|
|
550
|
+
u.setSelection(n, "on");
|
|
551
551
|
});
|
|
552
552
|
const m = l.mathWidgetClickHandler || window.__ckMathWidgetClickHandler;
|
|
553
|
-
m && m(
|
|
553
|
+
m && m(n, c), window.dispatchEvent(new CustomEvent("editAneesWidget", {
|
|
554
554
|
detail: {
|
|
555
555
|
editor: l,
|
|
556
|
-
modelElement:
|
|
556
|
+
modelElement: n,
|
|
557
557
|
latex: c
|
|
558
558
|
}
|
|
559
559
|
}));
|
|
@@ -561,11 +561,11 @@ function Se(l, o, n, s) {
|
|
|
561
561
|
function Xe(l, o) {
|
|
562
562
|
if (!o || o._ckMathClickBound) return;
|
|
563
563
|
o._ckMathClickBound = !0;
|
|
564
|
-
const
|
|
565
|
-
var
|
|
566
|
-
s.button === 0 && (s.preventDefault(), s.stopPropagation(), (
|
|
564
|
+
const a = (s) => {
|
|
565
|
+
var n;
|
|
566
|
+
s.button === 0 && (s.preventDefault(), s.stopPropagation(), (n = s.stopImmediatePropagation) == null || n.call(s), Se(l, null, oe(o), o));
|
|
567
567
|
};
|
|
568
|
-
o.addEventListener("mousedown",
|
|
568
|
+
o.addEventListener("mousedown", a, !0), o.addEventListener("click", a, !0);
|
|
569
569
|
}
|
|
570
570
|
const Ke = [
|
|
571
571
|
{
|
|
@@ -2003,7 +2003,7 @@ const Ke = [
|
|
|
2003
2003
|
// { type: 'sep', cols: 2, cls: 'cme-trig-subgroup' }
|
|
2004
2004
|
// ]
|
|
2005
2005
|
// },
|
|
2006
|
-
],
|
|
2006
|
+
], _e = [
|
|
2007
2007
|
{
|
|
2008
2008
|
label: "H₂O",
|
|
2009
2009
|
isChem: !0,
|
|
@@ -3605,11 +3605,11 @@ const Ke = [
|
|
|
3605
3605
|
// ]
|
|
3606
3606
|
// },
|
|
3607
3607
|
];
|
|
3608
|
-
function
|
|
3608
|
+
function Ye(l = "") {
|
|
3609
3609
|
if (String(l).match(/^\\ce\{([\s\S]*)\}$/) || l.includes("\\class{cme-"))
|
|
3610
3610
|
return l;
|
|
3611
|
-
const
|
|
3612
|
-
return
|
|
3611
|
+
const a = l.replace(/\\text\{([^}]*)\}/g, "$1").replace(/\$/g, "").trim();
|
|
3612
|
+
return a ? `\\ce{${a}}` : "";
|
|
3613
3613
|
}
|
|
3614
3614
|
function pe(l) {
|
|
3615
3615
|
return l === "matrix" ? "\\begin{matrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{matrix}" : l === "bmatrix" ? "\\begin{bmatrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{bmatrix}" : l === "pmatrix" ? "\\begin{pmatrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{pmatrix}" : l === "vmatrix" ? "\\begin{vmatrix} \\placeholder{} & \\placeholder{} \\\\ \\placeholder{} & \\placeholder{} \\end{vmatrix}" : l.replace(/#0|#\?/g, "\\placeholder{}");
|
|
@@ -3628,20 +3628,20 @@ class at extends He {
|
|
|
3628
3628
|
isObject: !0,
|
|
3629
3629
|
allowWhere: "$text",
|
|
3630
3630
|
allowAttributes: ["latex"]
|
|
3631
|
-
}), o.model.schema.addChildCheck((s,
|
|
3632
|
-
if (
|
|
3631
|
+
}), o.model.schema.addChildCheck((s, n) => {
|
|
3632
|
+
if (n.name === "mathInline")
|
|
3633
3633
|
return !0;
|
|
3634
3634
|
}), o.conversion.for("editingDowncast").elementToElement({
|
|
3635
3635
|
model: "mathInline",
|
|
3636
|
-
view: (s, { writer:
|
|
3636
|
+
view: (s, { writer: n }) => {
|
|
3637
3637
|
const c = s.getAttribute("latex") || "", m = "math-" + Math.random().toString(36).substr(2, 9);
|
|
3638
3638
|
window.__ckMathWidgets.set(m, s);
|
|
3639
|
-
const u =
|
|
3639
|
+
const u = n.createContainerElement("span", {
|
|
3640
3640
|
class: "ck-math-widget ck-math-inline-word",
|
|
3641
3641
|
contenteditable: "false",
|
|
3642
3642
|
"data-math-id": m,
|
|
3643
3643
|
"data-latex": c
|
|
3644
|
-
}), x =
|
|
3644
|
+
}), x = n.createRawElement(
|
|
3645
3645
|
"span",
|
|
3646
3646
|
{
|
|
3647
3647
|
class: "ck-math-widget-inner",
|
|
@@ -3682,21 +3682,21 @@ class at extends He {
|
|
|
3682
3682
|
k(), requestAnimationFrame(k);
|
|
3683
3683
|
}
|
|
3684
3684
|
);
|
|
3685
|
-
return
|
|
3685
|
+
return n.insert(n.createPositionAt(u, 0), x), Ue(u, n, { label: "math formula" });
|
|
3686
3686
|
}
|
|
3687
3687
|
});
|
|
3688
|
-
const
|
|
3689
|
-
this.listenTo(
|
|
3690
|
-
const c = Qe(
|
|
3691
|
-
c &&
|
|
3688
|
+
const a = o.editing.view.document;
|
|
3689
|
+
this.listenTo(a, "mousedown", (s, n) => {
|
|
3690
|
+
const c = Qe(n.domTarget);
|
|
3691
|
+
c && n.domEvent.button === 0 && (s.stop(), n.preventDefault(), Se(
|
|
3692
3692
|
o,
|
|
3693
3693
|
null,
|
|
3694
3694
|
oe(c),
|
|
3695
3695
|
c
|
|
3696
3696
|
));
|
|
3697
3697
|
}, { priority: "high" }), o.conversion.for("editingDowncast").add((s) => {
|
|
3698
|
-
s.on("attribute:latex:mathInline", (
|
|
3699
|
-
if (!m.consumable.consume(c.item,
|
|
3698
|
+
s.on("attribute:latex:mathInline", (n, c, m) => {
|
|
3699
|
+
if (!m.consumable.consume(c.item, n.name))
|
|
3700
3700
|
return;
|
|
3701
3701
|
const u = m.writer, x = m.mapper.toViewElement(c.item);
|
|
3702
3702
|
if (x) {
|
|
@@ -3720,8 +3720,8 @@ class at extends He {
|
|
|
3720
3720
|
});
|
|
3721
3721
|
}), o.conversion.for("dataDowncast").elementToElement({
|
|
3722
3722
|
model: "mathInline",
|
|
3723
|
-
view: (s, { writer:
|
|
3724
|
-
const c = s.getAttribute("latex") || "", m =
|
|
3723
|
+
view: (s, { writer: n }) => {
|
|
3724
|
+
const c = s.getAttribute("latex") || "", m = n.createContainerElement("span", {
|
|
3725
3725
|
class: "math-tex",
|
|
3726
3726
|
"data-latex": c,
|
|
3727
3727
|
// Keep raw latex in data-latex for restoring
|
|
@@ -3732,21 +3732,21 @@ class at extends He {
|
|
|
3732
3732
|
de(c)
|
|
3733
3733
|
)
|
|
3734
3734
|
);
|
|
3735
|
-
return u.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(u.trim()) && (u = u.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")),
|
|
3735
|
+
return u.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(u.trim()) && (u = u.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")), n.insert(n.createPositionAt(m, 0), n.createText(u)), m;
|
|
3736
3736
|
}
|
|
3737
3737
|
}), o.conversion.for("upcast").elementToElement({
|
|
3738
3738
|
view: {
|
|
3739
3739
|
name: "span",
|
|
3740
3740
|
classes: "math-tex"
|
|
3741
3741
|
},
|
|
3742
|
-
model: (s, { writer:
|
|
3742
|
+
model: (s, { writer: n }) => {
|
|
3743
3743
|
const c = s.getAttribute("data-latex") || "";
|
|
3744
|
-
return
|
|
3744
|
+
return n.createElement("mathInline", { latex: c });
|
|
3745
3745
|
}
|
|
3746
3746
|
});
|
|
3747
3747
|
}
|
|
3748
3748
|
}
|
|
3749
|
-
function Ge({ matrixType: l, x: o, y:
|
|
3749
|
+
function Ge({ matrixType: l, x: o, y: a, onSelect: s, onMouseEnter: n, onMouseLeave: c }) {
|
|
3750
3750
|
const [m, u] = B({ r: 2, c: 2 }), x = Math.max(10, parseInt(m.r, 10) || 0), I = Math.max(10, parseInt(m.c, 10) || 0), p = (b) => {
|
|
3751
3751
|
const y = b.target.value;
|
|
3752
3752
|
if (y === "") {
|
|
@@ -3781,9 +3781,9 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: i, onMouseLe
|
|
|
3781
3781
|
"div",
|
|
3782
3782
|
{
|
|
3783
3783
|
className: "cme-matrix-hover-popover ck-only",
|
|
3784
|
-
style: { top: `${
|
|
3784
|
+
style: { top: `${a}px`, left: `${o}px` },
|
|
3785
3785
|
onMouseDown: (b) => b.stopPropagation(),
|
|
3786
|
-
onMouseEnter:
|
|
3786
|
+
onMouseEnter: n,
|
|
3787
3787
|
onMouseLeave: c
|
|
3788
3788
|
},
|
|
3789
3789
|
/* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length: x }).map((b, y) => /* @__PURE__ */ e.createElement("div", { key: y, className: "cme-matrix-hover-row" }, Array.from({ length: I }).map((T, C) => {
|
|
@@ -3838,22 +3838,22 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: i, onMouseLe
|
|
|
3838
3838
|
);
|
|
3839
3839
|
}
|
|
3840
3840
|
let F = !1, be = null, V = null;
|
|
3841
|
-
function $e({ mode: l, onInsert: o, onClose:
|
|
3841
|
+
function $e({ mode: l, onInsert: o, onClose: a, initialLatex: s, isEditing: n }) {
|
|
3842
3842
|
const c = re(null), [m, u] = B(0), [x, I] = B(null), [p, A] = B(null), [k, E] = B(null), [b, y] = B(null);
|
|
3843
3843
|
re(null);
|
|
3844
|
-
const [T, C] = B({ x: 0, y: 0 }), [U, X] = B(!1), Z = re({ x: 0, y: 0 }), [K, ge] = B(!1), [Te, ke] = B(!1), [We,
|
|
3844
|
+
const [T, C] = B({ x: 0, y: 0 }), [U, X] = B(!1), Z = re({ x: 0, y: 0 }), [K, ge] = B(!1), [Te, ke] = B(!1), [We, _] = B(!1), se = re(null);
|
|
3845
3845
|
O(() => {
|
|
3846
|
-
const t = (
|
|
3846
|
+
const t = (r) => {
|
|
3847
3847
|
if (!U) return;
|
|
3848
|
-
let d =
|
|
3848
|
+
let d = r.clientX - Z.current.x, g = r.clientY - Z.current.y;
|
|
3849
3849
|
if (se.current) {
|
|
3850
3850
|
const w = se.current, h = -w.left, L = window.innerWidth - w.right, M = -w.top, R = window.innerHeight - w.bottom;
|
|
3851
3851
|
d < h && (d = h), d > L && (d = L), g < M && (g = M), g > R && (g = R);
|
|
3852
3852
|
}
|
|
3853
3853
|
C({ x: d, y: g });
|
|
3854
|
-
},
|
|
3855
|
-
return U && (window.addEventListener("mousemove", t), window.addEventListener("mouseup",
|
|
3856
|
-
window.removeEventListener("mousemove", t), window.removeEventListener("mouseup",
|
|
3854
|
+
}, i = () => X(!1);
|
|
3855
|
+
return U && (window.addEventListener("mousemove", t), window.addEventListener("mouseup", i)), () => {
|
|
3856
|
+
window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", i);
|
|
3857
3857
|
};
|
|
3858
3858
|
}, [U]);
|
|
3859
3859
|
const Ie = (t) => {
|
|
@@ -3862,19 +3862,19 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
3862
3862
|
x: t.clientX - T.x,
|
|
3863
3863
|
y: t.clientY - T.y
|
|
3864
3864
|
};
|
|
3865
|
-
const
|
|
3866
|
-
if (
|
|
3867
|
-
const
|
|
3865
|
+
const i = document.querySelector(".cme-editor-popup");
|
|
3866
|
+
if (i) {
|
|
3867
|
+
const r = i.getBoundingClientRect();
|
|
3868
3868
|
se.current = {
|
|
3869
|
-
left:
|
|
3870
|
-
top:
|
|
3871
|
-
right:
|
|
3872
|
-
bottom:
|
|
3873
|
-
width:
|
|
3874
|
-
height:
|
|
3869
|
+
left: r.left - T.x,
|
|
3870
|
+
top: r.top - T.y,
|
|
3871
|
+
right: r.right - T.x,
|
|
3872
|
+
bottom: r.bottom - T.y,
|
|
3873
|
+
width: r.width,
|
|
3874
|
+
height: r.height
|
|
3875
3875
|
};
|
|
3876
3876
|
}
|
|
3877
|
-
},
|
|
3877
|
+
}, Y = l === "math" ? Ke : _e, [f, ce] = B({
|
|
3878
3878
|
bold: !1,
|
|
3879
3879
|
italic: !1,
|
|
3880
3880
|
color: "none",
|
|
@@ -3885,7 +3885,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
3885
3885
|
const t = c.current;
|
|
3886
3886
|
if (!(!t || typeof t.queryStyle != "function"))
|
|
3887
3887
|
try {
|
|
3888
|
-
const
|
|
3888
|
+
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", d = window.__cmeManualFontFamily !== void 0 ? window.__cmeManualFontFamily : ["roman", "sans-serif", "monospace"].find(
|
|
3889
3889
|
(h) => t.queryStyle({ fontFamily: h }) === "all"
|
|
3890
3890
|
) || "none", g = window.__cmeManualFontSize !== void 0 ? window.__cmeManualFontSize : [5, 7, 9].find(
|
|
3891
3891
|
(h) => t.queryStyle({ fontSize: h }) === "all"
|
|
@@ -3918,28 +3918,28 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
3918
3918
|
(h) => t.queryStyle({ color: h }) === "all"
|
|
3919
3919
|
) || "none";
|
|
3920
3920
|
ce((h) => ({
|
|
3921
|
-
bold:
|
|
3922
|
-
italic:
|
|
3921
|
+
bold: i,
|
|
3922
|
+
italic: r,
|
|
3923
3923
|
fontFamily: d,
|
|
3924
3924
|
fontSize: String(g),
|
|
3925
3925
|
color: w
|
|
3926
3926
|
}));
|
|
3927
|
-
} catch (
|
|
3928
|
-
console.warn("Failed to query active styles:",
|
|
3927
|
+
} catch (i) {
|
|
3928
|
+
console.warn("Failed to query active styles:", i);
|
|
3929
3929
|
}
|
|
3930
3930
|
}, []);
|
|
3931
3931
|
O(() => {
|
|
3932
3932
|
if (!x && !k) return;
|
|
3933
|
-
const t = (
|
|
3934
|
-
!
|
|
3933
|
+
const t = (i) => {
|
|
3934
|
+
!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);
|
|
3935
3935
|
};
|
|
3936
3936
|
return window.addEventListener("mousedown", t, !0), window.addEventListener("pointerdown", t, !0), () => {
|
|
3937
3937
|
window.removeEventListener("mousedown", t, !0), window.removeEventListener("pointerdown", t, !0);
|
|
3938
3938
|
};
|
|
3939
3939
|
}, [x, k]), O(() => {
|
|
3940
3940
|
if (!b) return;
|
|
3941
|
-
const t = (
|
|
3942
|
-
!
|
|
3941
|
+
const t = (i) => {
|
|
3942
|
+
!i.target.closest(".cme-more-popup") && !i.target.closest(".cme-more-trigger-btn") && y(null);
|
|
3943
3943
|
};
|
|
3944
3944
|
return window.addEventListener("mousedown", t, !0), window.addEventListener("pointerdown", t, !0), () => {
|
|
3945
3945
|
window.removeEventListener("mousedown", t, !0), window.removeEventListener("pointerdown", t, !0);
|
|
@@ -3952,31 +3952,37 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
3952
3952
|
const t = V;
|
|
3953
3953
|
if (!t) return;
|
|
3954
3954
|
t.macros = { ...t.macros, ...window.__cme_macros || {} }, t.defaultMode = "math";
|
|
3955
|
-
const
|
|
3955
|
+
const i = () => {
|
|
3956
3956
|
if (typeof t.applyStyle == "function" && t.applyStyle({ variantStyle: "up" }), s) {
|
|
3957
|
-
let
|
|
3957
|
+
let r = s;
|
|
3958
3958
|
if (l === "chem") {
|
|
3959
|
-
const d =
|
|
3960
|
-
d && (
|
|
3959
|
+
const d = r.match(/^\\ce\{([\s\S]*)\}$/i);
|
|
3960
|
+
d && (r = d[1]);
|
|
3961
3961
|
}
|
|
3962
|
-
|
|
3962
|
+
r = z(r), r = ne(r), t.setValue ? t.setValue("", { silenceNotifications: !0 }) : t.value = "", t.executeCommand(["insert", r, { insertionMode: "replaceAll" }]);
|
|
3963
3963
|
}
|
|
3964
3964
|
requestAnimationFrame(() => t.focus());
|
|
3965
3965
|
};
|
|
3966
|
-
customElements.get("math-field") ? requestAnimationFrame(
|
|
3966
|
+
customElements.get("math-field") ? requestAnimationFrame(i) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(i));
|
|
3967
3967
|
}, [l, s]), O(() => {
|
|
3968
3968
|
const t = V;
|
|
3969
3969
|
if (!t) return;
|
|
3970
|
-
const
|
|
3971
|
-
if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(
|
|
3970
|
+
const i = (r) => {
|
|
3971
|
+
if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(r.key) ? (F = !1, clearTimeout(be), window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0) : (r.key.length === 1 || r.key === " ") && (F = !0, clearTimeout(be), be = setTimeout(() => {
|
|
3972
3972
|
F = !1;
|
|
3973
|
-
}, 500)),
|
|
3974
|
-
|
|
3973
|
+
}, 500)), ["`", "~", "@", "^", "_", "$"].includes(r.key) && !r.ctrlKey && !r.metaKey && !r.altKey) {
|
|
3974
|
+
r.preventDefault(), r.stopPropagation();
|
|
3975
|
+
let d = "";
|
|
3976
|
+
r.key === "`" ? d = "\\text{\\char96}" : r.key === "~" ? d = "\\text{~}" : r.key === "@" ? d = "\\text{@}" : r.key === "^" ? d = "\\text{^}" : r.key === "_" ? d = "\\_" : r.key === "$" && (d = "\\$"), t.executeCommand(["insert", d]);
|
|
3977
|
+
return;
|
|
3978
|
+
}
|
|
3979
|
+
if (r.key.length === 1 && !r.ctrlKey && !r.metaKey && !r.altKey && /[a-zA-Z0-9]/.test(r.key)) {
|
|
3980
|
+
r.preventDefault(), r.stopPropagation();
|
|
3975
3981
|
const d = f.fontFamily === "sans-serif", g = f.fontFamily === "monospace", w = f.bold, h = f.italic;
|
|
3976
3982
|
let L = "\\mathrm";
|
|
3977
3983
|
d ? L = "\\mathsf" : g ? L = "\\mathtt" : h && !w ? L = "\\mathit" : w && !h && (L = "\\mathbf");
|
|
3978
|
-
let M = `${L}{${
|
|
3979
|
-
w && h ? (M = `\\mathbfit{${
|
|
3984
|
+
let M = `${L}{${r.key}}`;
|
|
3985
|
+
w && h ? (M = `\\mathbfit{${r.key}}`, d && (M = `\\boldsymbol{\\mathsf{${r.key}}}`), g && (M = `\\boldsymbol{\\mathtt{${r.key}}}`)) : w && (d || g) && (M = `\\boldsymbol{${M}}`);
|
|
3980
3986
|
let R = M;
|
|
3981
3987
|
const j = f.fontSize === "auto" ? 5 : parseInt(f.fontSize, 10);
|
|
3982
3988
|
if (j !== 5) {
|
|
@@ -3986,63 +3992,63 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
3986
3992
|
f.color !== "none" && (R = `\\textcolor{${f.color}}{${R}}`), t.executeCommand(["insert", R]);
|
|
3987
3993
|
return;
|
|
3988
3994
|
}
|
|
3989
|
-
|
|
3995
|
+
r.key === " " ? (r.preventDefault(), t.executeCommand(["insert", "\\, "])) : r.key === "Enter" && (r.preventDefault(), r.stopImmediatePropagation(), t.executeCommand("addRowAfter"));
|
|
3990
3996
|
};
|
|
3991
|
-
return t.addEventListener("keydown",
|
|
3997
|
+
return t.addEventListener("keydown", i, !0), () => t.removeEventListener("keydown", i, !0);
|
|
3992
3998
|
}, [l, f, P]), O(() => {
|
|
3993
3999
|
const t = V;
|
|
3994
4000
|
if (!t) return;
|
|
3995
|
-
const
|
|
4001
|
+
const i = () => {
|
|
3996
4002
|
setTimeout(() => {
|
|
3997
|
-
const
|
|
3998
|
-
if (!
|
|
3999
|
-
const d =
|
|
4003
|
+
const r = t.shadowRoot;
|
|
4004
|
+
if (!r) return;
|
|
4005
|
+
const d = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
|
|
4000
4006
|
d && d.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }), P();
|
|
4001
4007
|
}, 0);
|
|
4002
4008
|
};
|
|
4003
|
-
return t.addEventListener("selection-change",
|
|
4004
|
-
t.removeEventListener("selection-change",
|
|
4009
|
+
return t.addEventListener("selection-change", i), t.addEventListener("input", i), t.addEventListener("keydown", i), setTimeout(P, 50), () => {
|
|
4010
|
+
t.removeEventListener("selection-change", i), t.removeEventListener("input", i), t.removeEventListener("keydown", i);
|
|
4005
4011
|
};
|
|
4006
4012
|
}, [P]);
|
|
4007
4013
|
const J = he((t) => {
|
|
4008
|
-
const
|
|
4009
|
-
|
|
4010
|
-
}, []), Be = he((t,
|
|
4014
|
+
const i = V;
|
|
4015
|
+
i && (i.focus(), i.executeCommand(["insert", t]));
|
|
4016
|
+
}, []), Be = he((t, i, r) => {
|
|
4011
4017
|
let d = `\\begin{${t}} `;
|
|
4012
|
-
for (let g = 0; g <
|
|
4013
|
-
for (let w = 0; w <
|
|
4014
|
-
d += "#?", w <
|
|
4015
|
-
g <
|
|
4018
|
+
for (let g = 0; g < i; g++) {
|
|
4019
|
+
for (let w = 0; w < r; w++)
|
|
4020
|
+
d += "#?", w < r - 1 && (d += " & ");
|
|
4021
|
+
g < i - 1 && (d += " \\\\ ");
|
|
4016
4022
|
}
|
|
4017
4023
|
d += ` \\end{${t}}`, J(d);
|
|
4018
4024
|
}, [J]), De = (t) => {
|
|
4019
|
-
t.stopPropagation(), ge((
|
|
4025
|
+
t.stopPropagation(), ge((i) => !i), ke(!1), C({ x: 0, y: 0 });
|
|
4020
4026
|
}, Ne = (t) => {
|
|
4021
|
-
t.stopPropagation(), ke((
|
|
4027
|
+
t.stopPropagation(), ke((i) => !i), ge(!1), C({ x: 0, y: 0 });
|
|
4022
4028
|
}, ue = (t) => {
|
|
4023
4029
|
t && t.stopPropagation();
|
|
4024
|
-
const
|
|
4025
|
-
if (!
|
|
4026
|
-
|
|
4030
|
+
const i = V;
|
|
4031
|
+
if (!i) {
|
|
4032
|
+
a && a();
|
|
4027
4033
|
return;
|
|
4028
4034
|
}
|
|
4029
|
-
const
|
|
4030
|
-
!
|
|
4035
|
+
const r = i.getValue ? i.getValue("latex") : i.value, d = s || "";
|
|
4036
|
+
!r || r.trim() === "" || r === d ? a && a() : _(!0);
|
|
4031
4037
|
}, Re = () => {
|
|
4032
4038
|
const t = V;
|
|
4033
4039
|
if (!t) return;
|
|
4034
|
-
let
|
|
4035
|
-
if (!
|
|
4036
|
-
|
|
4040
|
+
let i = t.getValue ? t.getValue("latex") : t.value;
|
|
4041
|
+
if (!i || i.trim() === "") {
|
|
4042
|
+
a && a();
|
|
4037
4043
|
return;
|
|
4038
4044
|
}
|
|
4039
|
-
l === "chem" && (
|
|
4040
|
-
const
|
|
4041
|
-
if (
|
|
4042
|
-
const d =
|
|
4043
|
-
|
|
4045
|
+
l === "chem" && (i = Ye(i)), i = z(i);
|
|
4046
|
+
const r = i.match(/^\\(mathrm|mathit|mathbf|mathsf|text)\{\\displaylines\{([\s\S]*)\}\}$/);
|
|
4047
|
+
if (r) {
|
|
4048
|
+
const d = r[1];
|
|
4049
|
+
i = `\\displaylines{${r[2].split("\\\\").map((L) => `\\${d}{${L.trim()}}`).join(" \\\\ ")}}`;
|
|
4044
4050
|
}
|
|
4045
|
-
|
|
4051
|
+
i = i.replace(/[\r\n]+/g, " "), o && o(i), t.setValue ? t.setValue("") : t.value = "", a && a();
|
|
4046
4052
|
};
|
|
4047
4053
|
return Q(
|
|
4048
4054
|
/* @__PURE__ */ e.createElement(
|
|
@@ -4059,18 +4065,18 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4059
4065
|
onMouseDown: Ie,
|
|
4060
4066
|
style: { cursor: U ? "grabbing" : "grab" }
|
|
4061
4067
|
},
|
|
4062
|
-
/* @__PURE__ */ e.createElement("span", null,
|
|
4068
|
+
/* @__PURE__ */ e.createElement("span", null, n ? l === "math" ? "Edit Math Formula" : "Edit Chemistry Formula" : l === "math" ? "Math Editor" : "Chemistry Editor")
|
|
4063
4069
|
), /* @__PURE__ */ e.createElement("div", { className: "cme-popup-controls" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-popup-btn", onClick: Ne, title: "Minimize" }, "—"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-popup-btn", onClick: De, title: "Maximize" }, "⤢"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-popup-btn", onClick: ue, title: "Close" }, "✕"))),
|
|
4064
|
-
/* @__PURE__ */ e.createElement("div", { className: "cme-toolbar", role: "toolbar", "aria-label": "Symbol palette" }, /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-groups" },
|
|
4065
|
-
const
|
|
4070
|
+
/* @__PURE__ */ e.createElement("div", { className: "cme-toolbar", role: "toolbar", "aria-label": "Symbol palette" }, /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-groups" }, Y.map((t, i) => {
|
|
4071
|
+
const r = m === i;
|
|
4066
4072
|
return /* @__PURE__ */ e.createElement(
|
|
4067
4073
|
"button",
|
|
4068
4074
|
{
|
|
4069
4075
|
key: t.isMatrix ? "matrix-tab" : t.label,
|
|
4070
|
-
className: `cme-group-tab${
|
|
4076
|
+
className: `cme-group-tab${r ? " active" : ""}`,
|
|
4071
4077
|
type: "button",
|
|
4072
4078
|
onMouseDown: (d) => {
|
|
4073
|
-
d.preventDefault(), u(
|
|
4079
|
+
d.preventDefault(), u(i), I(null);
|
|
4074
4080
|
}
|
|
4075
4081
|
},
|
|
4076
4082
|
t.mathLabel ? /* @__PURE__ */ e.createElement(
|
|
@@ -4090,7 +4096,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4090
4096
|
padding: "0",
|
|
4091
4097
|
margin: "0",
|
|
4092
4098
|
boxShadow: "none",
|
|
4093
|
-
color:
|
|
4099
|
+
color: r ? "#333333" : "#ffffff"
|
|
4094
4100
|
}
|
|
4095
4101
|
},
|
|
4096
4102
|
t.mathLabel
|
|
@@ -4098,21 +4104,21 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4098
4104
|
);
|
|
4099
4105
|
})), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
|
|
4100
4106
|
var d;
|
|
4101
|
-
const t = ((d =
|
|
4102
|
-
if (
|
|
4107
|
+
const t = ((d = Y[m]) == null ? void 0 : d.items) || [], i = t.some((g) => g.type === "sep"), r = [];
|
|
4108
|
+
if (i) {
|
|
4103
4109
|
let g = { cols: 2, small: !1, cls: "", items: [], moreItems: null };
|
|
4104
4110
|
for (const w of t)
|
|
4105
|
-
w.type === "sep" ? (g.items.length > 0 &&
|
|
4106
|
-
g.items.length > 0 &&
|
|
4111
|
+
w.type === "sep" ? (g.items.length > 0 && r.push(g), g = { cols: w.cols || 2, small: !!w.small, cls: w.cls || "", items: [], moreItems: w.moreItems || null, moreCols: w.moreCols || 1 }) : g.items.push(w);
|
|
4112
|
+
g.items.length > 0 && r.push(g);
|
|
4107
4113
|
} else
|
|
4108
4114
|
for (let w = 0; w < t.length; w += 4)
|
|
4109
|
-
|
|
4115
|
+
r.push({
|
|
4110
4116
|
cols: 2,
|
|
4111
4117
|
small: !1,
|
|
4112
4118
|
cls: "",
|
|
4113
4119
|
items: t.slice(w, w + 4)
|
|
4114
4120
|
});
|
|
4115
|
-
return
|
|
4121
|
+
return r.map((g, w) => /* @__PURE__ */ e.createElement(
|
|
4116
4122
|
"div",
|
|
4117
4123
|
{
|
|
4118
4124
|
key: w,
|
|
@@ -4132,7 +4138,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4132
4138
|
if (h.stopPropagation(), b && b.items === g.moreItems)
|
|
4133
4139
|
y(null);
|
|
4134
4140
|
else {
|
|
4135
|
-
const L = h.currentTarget.getBoundingClientRect(), M =
|
|
4141
|
+
const L = h.currentTarget.getBoundingClientRect(), M = Y[m] || {};
|
|
4136
4142
|
y({ cx: L.left + L.width / 2, y: L.bottom, items: g.moreItems, cols: g.moreCols, isTemplate: M.isTemplate || M.label === "√(□)" || M.isMatrix });
|
|
4137
4143
|
}
|
|
4138
4144
|
}
|
|
@@ -4140,7 +4146,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4140
4146
|
"▶"
|
|
4141
4147
|
),
|
|
4142
4148
|
g.items.map((h, L) => {
|
|
4143
|
-
const M =
|
|
4149
|
+
const M = Y[m];
|
|
4144
4150
|
if (h.type === "dropdown") {
|
|
4145
4151
|
const N = h.label === "Font...", v = h.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 : "";
|
|
4146
4152
|
return /* @__PURE__ */ e.createElement(
|
|
@@ -4303,13 +4309,13 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4303
4309
|
{
|
|
4304
4310
|
ref: (t) => {
|
|
4305
4311
|
t && requestAnimationFrame(() => {
|
|
4306
|
-
const
|
|
4307
|
-
let d = b.cx -
|
|
4308
|
-
if (
|
|
4309
|
-
const w =
|
|
4310
|
-
d +
|
|
4312
|
+
const i = t.getBoundingClientRect(), r = document.querySelector(".cme-editor-popup");
|
|
4313
|
+
let d = b.cx - i.width / 2, g = b.y;
|
|
4314
|
+
if (r) {
|
|
4315
|
+
const w = r.getBoundingClientRect();
|
|
4316
|
+
d + i.width > w.right - 4 && (d = w.right - i.width - 4), d < w.left + 4 && (d = w.left + 4), g + i.height > w.bottom - 4 && (g = w.bottom - i.height - 4);
|
|
4311
4317
|
}
|
|
4312
|
-
d +
|
|
4318
|
+
d + i.width > window.innerWidth - 4 && (d = window.innerWidth - i.width - 4), g + i.height > window.innerHeight - 4 && (g = window.innerHeight - i.height - 4), d < 4 && (d = 4), t.style.left = `${d}px`, t.style.top = `${g}px`, t.style.transform = "none";
|
|
4313
4319
|
});
|
|
4314
4320
|
},
|
|
4315
4321
|
className: "cme-more-popup",
|
|
@@ -4322,15 +4328,15 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4322
4328
|
gridTemplateColumns: `repeat(${b.cols || 1}, auto)`
|
|
4323
4329
|
}
|
|
4324
4330
|
},
|
|
4325
|
-
b.items.map((t,
|
|
4331
|
+
b.items.map((t, i) => /* @__PURE__ */ e.createElement(
|
|
4326
4332
|
"button",
|
|
4327
4333
|
{
|
|
4328
|
-
key:
|
|
4334
|
+
key: i,
|
|
4329
4335
|
type: "button",
|
|
4330
4336
|
className: `cme-more-popup-btn ${t.cls || ""}`,
|
|
4331
4337
|
title: t.title || t.label || t.insert,
|
|
4332
|
-
onMouseDown: (
|
|
4333
|
-
|
|
4338
|
+
onMouseDown: (r) => {
|
|
4339
|
+
r.preventDefault(), J(t.insert), y(null);
|
|
4334
4340
|
}
|
|
4335
4341
|
},
|
|
4336
4342
|
t.insert && !t.action && (t.cls === "template" || t.isWidget) ? /* @__PURE__ */ e.createElement(
|
|
@@ -4362,8 +4368,8 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4362
4368
|
className: "cme-mathfield-container",
|
|
4363
4369
|
onMouseDown: (t) => {
|
|
4364
4370
|
c.current && (t.target === c.current || c.current.contains(t.target)) || (t.preventDefault(), requestAnimationFrame(() => {
|
|
4365
|
-
var
|
|
4366
|
-
(
|
|
4371
|
+
var i, r;
|
|
4372
|
+
(r = (i = c.current) == null ? void 0 : i.focus) == null || r.call(i);
|
|
4367
4373
|
}));
|
|
4368
4374
|
}
|
|
4369
4375
|
},
|
|
@@ -4380,13 +4386,13 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4380
4386
|
}
|
|
4381
4387
|
)
|
|
4382
4388
|
),
|
|
4383
|
-
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-footer" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-insert-btn", onClick: Re },
|
|
4389
|
+
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-footer" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-insert-btn", onClick: Re }, n ? "Update" : "Insert"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-cancel-btn", onClick: ue }, "Cancel"), /* @__PURE__ */ e.createElement("span", { style: { marginLeft: "auto", fontSize: "11px", color: "#888", alignSelf: "center", marginRight: "10px" } }, "v1.0.11")),
|
|
4384
4390
|
We && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
|
|
4385
|
-
t.stopPropagation(),
|
|
4391
|
+
t.stopPropagation(), _(!1);
|
|
4386
4392
|
} }, /* @__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) => {
|
|
4387
|
-
t.stopPropagation(),
|
|
4393
|
+
t.stopPropagation(), _(!1), a && a();
|
|
4388
4394
|
} }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
|
|
4389
|
-
t.stopPropagation(),
|
|
4395
|
+
t.stopPropagation(), _(!1);
|
|
4390
4396
|
} }, "Cancel")))),
|
|
4391
4397
|
x && Q(
|
|
4392
4398
|
/* @__PURE__ */ e.createElement(
|
|
@@ -4395,8 +4401,8 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4395
4401
|
matrixType: x.type,
|
|
4396
4402
|
x: x.x,
|
|
4397
4403
|
y: x.y,
|
|
4398
|
-
onSelect: (t,
|
|
4399
|
-
Be(x.type, t,
|
|
4404
|
+
onSelect: (t, i) => {
|
|
4405
|
+
Be(x.type, t, i), I(null);
|
|
4400
4406
|
},
|
|
4401
4407
|
onMouseEnter: () => {
|
|
4402
4408
|
},
|
|
@@ -4466,7 +4472,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4466
4472
|
"violet",
|
|
4467
4473
|
"gold"
|
|
4468
4474
|
].map((t) => {
|
|
4469
|
-
const
|
|
4475
|
+
const i = f.color === t || t === "black" && (f.color === "none" || !f.color);
|
|
4470
4476
|
return /* @__PURE__ */ e.createElement(
|
|
4471
4477
|
"div",
|
|
4472
4478
|
{
|
|
@@ -4477,11 +4483,11 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4477
4483
|
height: "16px",
|
|
4478
4484
|
backgroundColor: t,
|
|
4479
4485
|
cursor: "pointer",
|
|
4480
|
-
border:
|
|
4486
|
+
border: i ? "2px solid #e6c229" : "1px solid #000",
|
|
4481
4487
|
boxSizing: "border-box"
|
|
4482
4488
|
},
|
|
4483
|
-
onMouseDown: (
|
|
4484
|
-
|
|
4489
|
+
onMouseDown: (r) => {
|
|
4490
|
+
r.preventDefault(), r.stopPropagation();
|
|
4485
4491
|
const d = c.current;
|
|
4486
4492
|
d && typeof d.applyStyle == "function" && (d.focus(), d.applyStyle({ color: t === "black" ? "none" : t }), P()), E(null);
|
|
4487
4493
|
}
|
|
@@ -4495,14 +4501,14 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4495
4501
|
document.body
|
|
4496
4502
|
);
|
|
4497
4503
|
}
|
|
4498
|
-
const ot = ({ isOpen: l, mode: o, initialValue:
|
|
4504
|
+
const ot = ({ isOpen: l, mode: o, initialValue: a, onInsert: s, onClose: n }) => l ? /* @__PURE__ */ e.createElement(
|
|
4499
4505
|
$e,
|
|
4500
4506
|
{
|
|
4501
4507
|
mode: o,
|
|
4502
4508
|
onInsert: s,
|
|
4503
|
-
onClose:
|
|
4504
|
-
initialLatex:
|
|
4505
|
-
isEditing: !!
|
|
4509
|
+
onClose: n,
|
|
4510
|
+
initialLatex: a || "",
|
|
4511
|
+
isEditing: !!a
|
|
4506
4512
|
}
|
|
4507
4513
|
) : null;
|
|
4508
4514
|
export {
|