digi-mathchem-editor 1.0.8 → 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.
- package/dist/digi-mathchem-editor.es.js +348 -340
- package/dist/digi-mathchem-editor.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e, { useState as B, useEffect as O, useMemo as xe, useRef as re, useCallback as he } from "react";
|
|
2
|
-
import { createPortal as
|
|
2
|
+
import { createPortal as Q } from "react-dom";
|
|
3
3
|
import { FontAwesomeIcon as ae } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { faBold as fe, faItalic as ve } from "@fortawesome/free-solid-svg-icons";
|
|
5
5
|
import { MathfieldElement as Ee } from "mathlive";
|
|
@@ -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,62 +347,62 @@ 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 (
|
|
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
|
-
}, [
|
|
376
|
-
if (
|
|
377
|
-
return { [
|
|
375
|
+
}, [m, n]), I = xe(() => {
|
|
376
|
+
if (m !== "All" && !n.trim())
|
|
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,
|
|
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;
|
|
386
|
-
let
|
|
386
|
+
let A = { top: "50%", left: "50%", transform: "translate(-50%, -50%)" };
|
|
387
387
|
if (s) {
|
|
388
388
|
let k = s.x - 120, E = s.y;
|
|
389
|
-
k < 10 && (k = 10), k + 230 > window.innerWidth && (k = window.innerWidth - 240), E + 200 > window.innerHeight && (E = window.innerHeight - 210),
|
|
389
|
+
k < 10 && (k = 10), k + 230 > window.innerWidth && (k = window.innerWidth - 240), E + 200 > window.innerHeight && (E = window.innerHeight - 210), A = { top: `${E}px`, left: `${k}px` };
|
|
390
390
|
}
|
|
391
391
|
return /* @__PURE__ */ e.createElement("div", { className: "scm-overlay", onMouseDown: (k) => {
|
|
392
392
|
k.stopPropagation(), o();
|
|
393
|
-
} }, /* @__PURE__ */ e.createElement("div", { className: "scm-modal", style:
|
|
393
|
+
} }, /* @__PURE__ */ e.createElement("div", { className: "scm-modal", style: A, onMouseDown: (k) => k.stopPropagation() }, /* @__PURE__ */ e.createElement("div", { className: "scm-toolbar" }, /* @__PURE__ */ e.createElement(
|
|
394
394
|
"input",
|
|
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
|
}
|
|
402
402
|
), /* @__PURE__ */ e.createElement(
|
|
403
403
|
"select",
|
|
404
404
|
{
|
|
405
|
-
value:
|
|
405
|
+
value: m,
|
|
406
406
|
onChange: (k) => u(k.target.value),
|
|
407
407
|
className: "scm-category-select"
|
|
408
408
|
},
|
|
@@ -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
|
-
return l instanceof Element ? (
|
|
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
|
|
479
|
-
|
|
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
|
+
m.trim() === "" ? o += "\\quad " : o += m;
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
return o;
|
|
483
483
|
}
|
|
484
|
-
function
|
|
485
|
-
let o = "",
|
|
484
|
+
function z(l) {
|
|
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,
|
|
495
|
-
for (;
|
|
496
|
-
l[
|
|
497
|
-
o += l.slice(
|
|
493
|
+
o += l.slice(a, n);
|
|
494
|
+
let c = 1, m = n + s.length;
|
|
495
|
+
for (; m < l.length && c > 0; )
|
|
496
|
+
l[m] === "{" ? c++ : l[m] === "}" && c--, m++;
|
|
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,41 +519,41 @@ 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);
|
|
535
535
|
if (!c) return null;
|
|
536
|
-
const
|
|
537
|
-
for (const { item: x } of l.model.createRangeIn(
|
|
536
|
+
const m = l.model.document.getRoot();
|
|
537
|
+
for (const { item: x } of l.model.createRangeIn(m))
|
|
538
538
|
if ((u = x.is) != null && u.call(x, "element", "mathInline") && x.getAttribute("latex") === c)
|
|
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
|
-
const
|
|
553
|
-
|
|
552
|
+
const m = l.mathWidgetClickHandler || window.__ckMathWidgetClickHandler;
|
|
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
|
{
|
|
@@ -687,7 +687,7 @@ const Ke = [
|
|
|
687
687
|
{ label: "÷", insert: "\\div", title: "Divide sign" },
|
|
688
688
|
{ label: "/", insert: "/", title: "Slash" },
|
|
689
689
|
{ label: "±", insert: "\\pm", title: "Plus-minus" },
|
|
690
|
-
{ label: "*", insert: "
|
|
690
|
+
{ label: "*", insert: "*", title: "Asterisk" },
|
|
691
691
|
{ label: "○", insert: "\\circ", title: "Circle" },
|
|
692
692
|
// Group 3 – Constants & Symbols (3 cols × 3 rows)
|
|
693
693
|
{
|
|
@@ -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,
|
|
@@ -2288,7 +2288,7 @@ const Ke = [
|
|
|
2288
2288
|
{ label: "÷", insert: "\\div", title: "Divide sign" },
|
|
2289
2289
|
{ label: "/", insert: "/", title: "Slash" },
|
|
2290
2290
|
{ label: "±", insert: "\\pm", title: "Plus-minus" },
|
|
2291
|
-
{ label: "*", insert: "
|
|
2291
|
+
{ label: "*", insert: "*", title: "Asterisk" },
|
|
2292
2292
|
{ label: "○", insert: "\\circ", title: "Circle" },
|
|
2293
2293
|
// Group 3 – Constants & Symbols (3 cols × 3 rows)
|
|
2294
2294
|
{
|
|
@@ -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:
|
|
3637
|
-
const c = s.getAttribute("latex") || "",
|
|
3638
|
-
window.__ckMathWidgets.set(
|
|
3639
|
-
const u =
|
|
3636
|
+
view: (s, { writer: n }) => {
|
|
3637
|
+
const c = s.getAttribute("latex") || "", m = "math-" + Math.random().toString(36).substr(2, 9);
|
|
3638
|
+
window.__ckMathWidgets.set(m, s);
|
|
3639
|
+
const u = n.createContainerElement("span", {
|
|
3640
3640
|
class: "ck-math-widget ck-math-inline-word",
|
|
3641
3641
|
contenteditable: "false",
|
|
3642
|
-
"data-math-id":
|
|
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",
|
|
@@ -3650,14 +3650,14 @@ class at extends He {
|
|
|
3650
3650
|
(I) => {
|
|
3651
3651
|
const p = document.createElement("math-field");
|
|
3652
3652
|
p.setAttribute("math-virtual-keyboard-policy", "manual"), p.setAttribute("tabindex", "-1"), p.style.display = "inline-block", p.style.width = "auto", p.style.maxWidth = "100%", p.style.verticalAlign = "middle", p.style.border = "none", p.style.background = "transparent", p.style.outline = "none", p.style.fontSize = "inherit", p.style.minHeight = "auto", p.style.padding = "0 2px", p.style.margin = "0", p.style.pointerEvents = "none";
|
|
3653
|
-
const
|
|
3653
|
+
const A = () => {
|
|
3654
3654
|
if (!p.isConnected) {
|
|
3655
|
-
requestAnimationFrame(
|
|
3655
|
+
requestAnimationFrame(A);
|
|
3656
3656
|
return;
|
|
3657
3657
|
}
|
|
3658
3658
|
window.__cme_macros && (p.macros = { ...p.macros, ...window.__cme_macros });
|
|
3659
3659
|
let E = ne(
|
|
3660
|
-
|
|
3660
|
+
z(
|
|
3661
3661
|
de(c)
|
|
3662
3662
|
)
|
|
3663
3663
|
);
|
|
@@ -3674,7 +3674,7 @@ class at extends He {
|
|
|
3674
3674
|
}
|
|
3675
3675
|
p.setAttribute("read-only", "");
|
|
3676
3676
|
};
|
|
3677
|
-
customElements.get("math-field") ? requestAnimationFrame(
|
|
3677
|
+
customElements.get("math-field") ? requestAnimationFrame(A) : customElements.whenDefined("math-field").then(() => requestAnimationFrame(A)), I.appendChild(p);
|
|
3678
3678
|
const k = () => {
|
|
3679
3679
|
const E = I.parentElement;
|
|
3680
3680
|
E && Xe(o, E);
|
|
@@ -3682,35 +3682,35 @@ 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 (!
|
|
3698
|
+
s.on("attribute:latex:mathInline", (n, c, m) => {
|
|
3699
|
+
if (!m.consumable.consume(c.item, n.name))
|
|
3700
3700
|
return;
|
|
3701
|
-
const u =
|
|
3701
|
+
const u = m.writer, x = m.mapper.toViewElement(c.item);
|
|
3702
3702
|
if (x) {
|
|
3703
3703
|
u.setAttribute("data-latex", c.attributeNewValue, x);
|
|
3704
3704
|
const I = o.editing.view.domConverter.mapViewToDom(x);
|
|
3705
3705
|
if (I) {
|
|
3706
3706
|
const p = I.querySelector("math-field");
|
|
3707
3707
|
if (p) {
|
|
3708
|
-
let
|
|
3709
|
-
|
|
3708
|
+
let A = ne(z(de(c.attributeNewValue)));
|
|
3709
|
+
A.includes("\\enclose") && /^\\ce\{[\s\S]*\}$/i.test(A.trim()) && (A = A.trim().replace(/^\\ce\{([\s\S]*)\}$/i, "$1")), p.removeAttribute("read-only");
|
|
3710
3710
|
try {
|
|
3711
|
-
p.setValue ? p.setValue("", { silenceNotifications: !0 }) : p.value = "", p.executeCommand(["insert",
|
|
3711
|
+
p.setValue ? p.setValue("", { silenceNotifications: !0 }) : p.value = "", p.executeCommand(["insert", A, { insertionMode: "replaceAll" }]);
|
|
3712
3712
|
} catch {
|
|
3713
|
-
p.setValue ? p.setValue(
|
|
3713
|
+
p.setValue ? p.setValue(A, { silenceNotifications: !0 }) : p.value = A;
|
|
3714
3714
|
}
|
|
3715
3715
|
p.setAttribute("read-only", "");
|
|
3716
3716
|
}
|
|
@@ -3720,82 +3720,82 @@ 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") || "",
|
|
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
|
|
3728
3728
|
style: "display:inline;"
|
|
3729
3729
|
});
|
|
3730
3730
|
let u = ne(
|
|
3731
|
-
|
|
3731
|
+
z(
|
|
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:
|
|
3750
|
-
const [
|
|
3749
|
+
function Ge({ matrixType: l, x: o, y: a, onSelect: s, onMouseEnter: n, onMouseLeave: c }) {
|
|
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 === "") {
|
|
3753
|
-
u((
|
|
3753
|
+
u((C) => ({ ...C, r: "" }));
|
|
3754
3754
|
return;
|
|
3755
3755
|
}
|
|
3756
|
-
const
|
|
3757
|
-
isNaN(
|
|
3758
|
-
},
|
|
3759
|
-
(
|
|
3756
|
+
const T = parseInt(y, 10);
|
|
3757
|
+
isNaN(T) || u((C) => ({ ...C, r: Math.max(1, Math.min(10, T)) }));
|
|
3758
|
+
}, A = () => {
|
|
3759
|
+
(m.r === "" || isNaN(parseInt(m.r, 10))) && u((b) => ({ ...b, r: 1 }));
|
|
3760
3760
|
}, k = (b) => {
|
|
3761
3761
|
const y = b.target.value;
|
|
3762
3762
|
if (y === "") {
|
|
3763
|
-
u((
|
|
3763
|
+
u((C) => ({ ...C, c: "" }));
|
|
3764
3764
|
return;
|
|
3765
3765
|
}
|
|
3766
|
-
const
|
|
3767
|
-
isNaN(
|
|
3766
|
+
const T = parseInt(y, 10);
|
|
3767
|
+
isNaN(T) || u((C) => ({ ...C, c: Math.max(1, Math.min(10, T)) }));
|
|
3768
3768
|
}, E = () => {
|
|
3769
|
-
(
|
|
3769
|
+
(m.c === "" || isNaN(parseInt(m.c, 10))) && u((b) => ({ ...b, c: 1 }));
|
|
3770
3770
|
};
|
|
3771
3771
|
return O(() => {
|
|
3772
3772
|
const b = (y) => {
|
|
3773
3773
|
if (y.key === "Enter") {
|
|
3774
3774
|
y.preventDefault(), y.stopPropagation();
|
|
3775
|
-
const
|
|
3776
|
-
s(
|
|
3775
|
+
const T = parseInt(m.r, 10) || 1, C = parseInt(m.c, 10) || 1;
|
|
3776
|
+
s(T, C);
|
|
3777
3777
|
}
|
|
3778
3778
|
};
|
|
3779
3779
|
return window.addEventListener("keydown", b, !0), () => window.removeEventListener("keydown", b, !0);
|
|
3780
|
-
}, [
|
|
3780
|
+
}, [m.r, m.c, s]), /* @__PURE__ */ e.createElement(
|
|
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
|
-
/* @__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((
|
|
3790
|
-
const U = parseInt(
|
|
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) => {
|
|
3790
|
+
const U = parseInt(m.r, 10) || 0, X = parseInt(m.c, 10) || 0, Z = y < U && C < X;
|
|
3791
3791
|
return /* @__PURE__ */ e.createElement(
|
|
3792
3792
|
"div",
|
|
3793
3793
|
{
|
|
3794
|
-
key: `${y}-${
|
|
3795
|
-
className: `cme-matrix-hover-cell${
|
|
3796
|
-
onMouseEnter: () => u({ r: y + 1, c:
|
|
3797
|
-
onClick: (
|
|
3798
|
-
|
|
3794
|
+
key: `${y}-${C}`,
|
|
3795
|
+
className: `cme-matrix-hover-cell${Z ? " selected" : ""}`,
|
|
3796
|
+
onMouseEnter: () => u({ r: y + 1, c: C + 1 }),
|
|
3797
|
+
onClick: (K) => {
|
|
3798
|
+
K.preventDefault(), K.stopPropagation(), s(y + 1, C + 1);
|
|
3799
3799
|
}
|
|
3800
3800
|
}
|
|
3801
3801
|
);
|
|
@@ -3805,9 +3805,9 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: i, onMouseLe
|
|
|
3805
3805
|
{
|
|
3806
3806
|
type: "number",
|
|
3807
3807
|
className: "cme-counter-val",
|
|
3808
|
-
value:
|
|
3808
|
+
value: m.r,
|
|
3809
3809
|
onChange: p,
|
|
3810
|
-
onBlur:
|
|
3810
|
+
onBlur: A,
|
|
3811
3811
|
min: "1",
|
|
3812
3812
|
max: "10"
|
|
3813
3813
|
}
|
|
@@ -3822,7 +3822,7 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: i, onMouseLe
|
|
|
3822
3822
|
{
|
|
3823
3823
|
type: "number",
|
|
3824
3824
|
className: "cme-counter-val",
|
|
3825
|
-
value:
|
|
3825
|
+
value: m.c,
|
|
3826
3826
|
onChange: k,
|
|
3827
3827
|
onBlur: E,
|
|
3828
3828
|
min: "1",
|
|
@@ -3837,58 +3837,58 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: i, onMouseLe
|
|
|
3837
3837
|
}) }, "▼"))))
|
|
3838
3838
|
);
|
|
3839
3839
|
}
|
|
3840
|
-
let
|
|
3841
|
-
function $e({ mode: l, onInsert: o, onClose:
|
|
3842
|
-
const c = re(null), [
|
|
3840
|
+
let F = !1, be = null, V = null;
|
|
3841
|
+
function $e({ mode: l, onInsert: o, onClose: a, initialLatex: s, isEditing: n }) {
|
|
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 [
|
|
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
|
-
const w = se.current,
|
|
3851
|
-
d <
|
|
3850
|
+
const w = se.current, h = -w.left, L = window.innerWidth - w.right, M = -w.top, R = window.innerHeight - w.bottom;
|
|
3851
|
+
d < h && (d = h), d > L && (d = L), g < M && (g = M), g > R && (g = R);
|
|
3852
3852
|
}
|
|
3853
|
-
|
|
3854
|
-
},
|
|
3855
|
-
return U && (window.addEventListener("mousemove", t), window.addEventListener("mouseup",
|
|
3856
|
-
window.removeEventListener("mousemove", t), window.removeEventListener("mouseup",
|
|
3853
|
+
C({ x: d, y: g });
|
|
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) => {
|
|
3860
3860
|
if (t.target.closest(".cme-popup-controls")) return;
|
|
3861
|
-
|
|
3862
|
-
x: t.clientX -
|
|
3863
|
-
y: t.clientY -
|
|
3861
|
+
X(!0), Z.current = {
|
|
3862
|
+
x: t.clientX - T.x,
|
|
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",
|
|
3881
3881
|
fontFamily: "none",
|
|
3882
3882
|
fontSize: "auto"
|
|
3883
|
-
}),
|
|
3884
|
-
if (
|
|
3883
|
+
}), P = he(() => {
|
|
3884
|
+
if (F || window.__cmeIgnoreStyleUpdate && Date.now() - window.__cmeIgnoreStyleUpdate < 150) return;
|
|
3885
3885
|
const t = c.current;
|
|
3886
3886
|
if (!(!t || typeof t.queryStyle != "function"))
|
|
3887
3887
|
try {
|
|
3888
|
-
const
|
|
3889
|
-
(
|
|
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
|
+
(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"
|
|
3892
3892
|
) || "auto", w = [
|
|
3893
3893
|
"black",
|
|
3894
3894
|
"dimgray",
|
|
@@ -3915,31 +3915,31 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
3915
3915
|
"violet",
|
|
3916
3916
|
"gold"
|
|
3917
3917
|
].find(
|
|
3918
|
-
(
|
|
3918
|
+
(h) => t.queryStyle({ color: h }) === "all"
|
|
3919
3919
|
) || "none";
|
|
3920
|
-
ce((
|
|
3921
|
-
bold:
|
|
3922
|
-
italic:
|
|
3920
|
+
ce((h) => ({
|
|
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);
|
|
@@ -3947,109 +3947,115 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
3947
3947
|
}, [b]), O(() => {
|
|
3948
3948
|
const t = setTimeout(() => Fe(), 50);
|
|
3949
3949
|
return () => clearTimeout(t);
|
|
3950
|
-
}, [
|
|
3951
|
-
if (
|
|
3950
|
+
}, [m]), O(() => {
|
|
3951
|
+
if (F) return;
|
|
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(
|
|
3972
|
-
|
|
3973
|
-
}, 500)),
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
const
|
|
3982
|
-
|
|
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
|
+
F = !1;
|
|
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();
|
|
3981
|
+
const d = f.fontFamily === "sans-serif", g = f.fontFamily === "monospace", w = f.bold, h = f.italic;
|
|
3982
|
+
let L = "\\mathrm";
|
|
3983
|
+
d ? L = "\\mathsf" : g ? L = "\\mathtt" : h && !w ? L = "\\mathit" : w && !h && (L = "\\mathbf");
|
|
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}}`);
|
|
3986
|
+
let R = M;
|
|
3987
|
+
const j = f.fontSize === "auto" ? 5 : parseInt(f.fontSize, 10);
|
|
3988
|
+
if (j !== 5) {
|
|
3983
3989
|
const G = { 1: "\\tiny", 2: "\\scriptsize", 3: "\\footnotesize", 4: "\\small", 5: "\\normalsize", 6: "\\large", 7: "\\Large", 8: "\\LARGE", 9: "\\huge", 10: "\\Huge" };
|
|
3984
|
-
G[
|
|
3990
|
+
G[j] && (R = `{${G[j]} ${R}}`);
|
|
3985
3991
|
}
|
|
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",
|
|
3992
|
-
}, [l, f,
|
|
3997
|
+
return t.addEventListener("keydown", i, !0), () => t.removeEventListener("keydown", i, !0);
|
|
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 =
|
|
4000
|
-
d && d.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }),
|
|
4003
|
+
const r = t.shadowRoot;
|
|
4004
|
+
if (!r) return;
|
|
4005
|
+
const d = r.querySelector(".ML__caret") || r.querySelector('[class*="caret"]');
|
|
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
|
-
}, [
|
|
4007
|
-
const
|
|
4008
|
-
const
|
|
4009
|
-
|
|
4010
|
-
}, []), Be = he((t,
|
|
4012
|
+
}, [P]);
|
|
4013
|
+
const J = 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
|
-
d += ` \\end{${t}}`,
|
|
4018
|
-
}, [
|
|
4019
|
-
t.stopPropagation(), ge((
|
|
4023
|
+
d += ` \\end{${t}}`, J(d);
|
|
4024
|
+
}, [J]), De = (t) => {
|
|
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
|
-
return
|
|
4053
|
+
return Q(
|
|
4048
4054
|
/* @__PURE__ */ e.createElement(
|
|
4049
4055
|
"div",
|
|
4050
4056
|
{
|
|
4051
|
-
className: `cme-editor-popup ${
|
|
4052
|
-
style: { transform: `translate(${
|
|
4057
|
+
className: `cme-editor-popup ${K ? "maximized" : ""} ${Te ? "minimized" : ""}`,
|
|
4058
|
+
style: { transform: `translate(${T.x}px, ${T.y}px)` },
|
|
4053
4059
|
onMouseDown: (t) => t.stopPropagation()
|
|
4054
4060
|
},
|
|
4055
4061
|
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-topbar" }, /* @__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,
|
|
@@ -4125,29 +4131,32 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4125
4131
|
type: "button",
|
|
4126
4132
|
className: "cme-more-trigger-btn",
|
|
4127
4133
|
title: "more",
|
|
4128
|
-
onMouseDown: (
|
|
4129
|
-
|
|
4134
|
+
onMouseDown: (h) => {
|
|
4135
|
+
h.preventDefault();
|
|
4136
|
+
},
|
|
4137
|
+
onClick: (h) => {
|
|
4138
|
+
if (h.stopPropagation(), b && b.items === g.moreItems)
|
|
4130
4139
|
y(null);
|
|
4131
4140
|
else {
|
|
4132
|
-
const
|
|
4133
|
-
y({ cx:
|
|
4141
|
+
const L = h.currentTarget.getBoundingClientRect(), M = Y[m] || {};
|
|
4142
|
+
y({ cx: L.left + L.width / 2, y: L.bottom, items: g.moreItems, cols: g.moreCols, isTemplate: M.isTemplate || M.label === "√(□)" || M.isMatrix });
|
|
4134
4143
|
}
|
|
4135
4144
|
}
|
|
4136
4145
|
},
|
|
4137
4146
|
"▶"
|
|
4138
4147
|
),
|
|
4139
|
-
g.items.map((
|
|
4140
|
-
const
|
|
4141
|
-
if (
|
|
4142
|
-
const N =
|
|
4148
|
+
g.items.map((h, L) => {
|
|
4149
|
+
const M = Y[m];
|
|
4150
|
+
if (h.type === "dropdown") {
|
|
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 : "";
|
|
4143
4152
|
return /* @__PURE__ */ e.createElement(
|
|
4144
4153
|
"select",
|
|
4145
4154
|
{
|
|
4146
|
-
key:
|
|
4155
|
+
key: L,
|
|
4147
4156
|
className: `cme-btn template${$ || ee ? " active" : ""}`,
|
|
4148
4157
|
value: te,
|
|
4149
4158
|
style: {
|
|
4150
|
-
width:
|
|
4159
|
+
width: h.width || "60px",
|
|
4151
4160
|
height: "18px",
|
|
4152
4161
|
minHeight: "18px",
|
|
4153
4162
|
maxHeight: "18px",
|
|
@@ -4160,43 +4169,43 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4160
4169
|
gridColumn: g.cols === 3 || g.cols === 1 ? "span 1" : "span 2"
|
|
4161
4170
|
},
|
|
4162
4171
|
onChange: (le) => {
|
|
4163
|
-
const
|
|
4164
|
-
!H || typeof H.applyStyle != "function" || (H.focus(), N ? H.applyStyle({ fontFamily:
|
|
4172
|
+
const q = le.target.value, H = V;
|
|
4173
|
+
!H || typeof H.applyStyle != "function" || (H.focus(), N ? H.applyStyle({ fontFamily: q || "none" }) : v && H.applyStyle({ fontSize: q ? parseInt(q, 10) : "auto" }), P());
|
|
4165
4174
|
}
|
|
4166
4175
|
},
|
|
4167
|
-
/* @__PURE__ */ e.createElement("option", { value: "" },
|
|
4176
|
+
/* @__PURE__ */ e.createElement("option", { value: "" }, h.label),
|
|
4168
4177
|
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")),
|
|
4169
4178
|
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"))
|
|
4170
4179
|
);
|
|
4171
4180
|
}
|
|
4172
|
-
if (
|
|
4181
|
+
if (M.isMatrix && !h.directInsert)
|
|
4173
4182
|
return /* @__PURE__ */ e.createElement(
|
|
4174
4183
|
"div",
|
|
4175
4184
|
{
|
|
4176
|
-
key:
|
|
4185
|
+
key: L,
|
|
4177
4186
|
className: "cme-matrix-btn-wrapper"
|
|
4178
4187
|
},
|
|
4179
4188
|
/* @__PURE__ */ e.createElement(
|
|
4180
4189
|
"button",
|
|
4181
4190
|
{
|
|
4182
4191
|
type: "button",
|
|
4183
|
-
className: `cme-btn template${
|
|
4184
|
-
title:
|
|
4192
|
+
className: `cme-btn template${h.cls ? ` ${h.cls}` : ""}${M.isMatrix ? " cme-matrix-btn-small" : ""}`,
|
|
4193
|
+
title: h.title || h.label || h.insert,
|
|
4185
4194
|
onMouseDown: (N) => {
|
|
4186
|
-
if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) ===
|
|
4195
|
+
if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === h.insert)
|
|
4187
4196
|
I(null);
|
|
4188
4197
|
else {
|
|
4189
|
-
|
|
4198
|
+
F || (window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0);
|
|
4190
4199
|
const v = N.currentTarget.getBoundingClientRect();
|
|
4191
4200
|
I({
|
|
4192
|
-
type:
|
|
4201
|
+
type: h.insert,
|
|
4193
4202
|
x: v.left + v.width / 2,
|
|
4194
4203
|
y: v.bottom
|
|
4195
4204
|
});
|
|
4196
4205
|
}
|
|
4197
4206
|
}
|
|
4198
4207
|
},
|
|
4199
|
-
typeof
|
|
4208
|
+
typeof h.label == "object" ? h.label : /* @__PURE__ */ e.createElement(
|
|
4200
4209
|
"math-field",
|
|
4201
4210
|
{
|
|
4202
4211
|
"read-only": !0,
|
|
@@ -4215,62 +4224,62 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4215
4224
|
cursor: "pointer"
|
|
4216
4225
|
}
|
|
4217
4226
|
},
|
|
4218
|
-
pe(
|
|
4227
|
+
pe(h.mathLabel != null ? h.mathLabel : h.insert)
|
|
4219
4228
|
)
|
|
4220
4229
|
)
|
|
4221
4230
|
);
|
|
4222
|
-
const R =
|
|
4231
|
+
const R = h.action === "BOLD", j = h.action === "ITALIC", G = h.action === "TEXT_COLOR", Oe = R && f.bold || j && f.italic || G && f.color !== "none" && f.color !== "black";
|
|
4223
4232
|
return /* @__PURE__ */ e.createElement(
|
|
4224
4233
|
"button",
|
|
4225
4234
|
{
|
|
4226
|
-
key: `${
|
|
4235
|
+
key: `${M.label}-${w * 4 + L}`,
|
|
4227
4236
|
type: "button",
|
|
4228
|
-
className: `cme-btn${
|
|
4229
|
-
title:
|
|
4237
|
+
className: `cme-btn${M.isTemplate ? " template" : ""}${h.cls ? ` ${h.cls}` : ""}${Oe ? " active" : ""}`,
|
|
4238
|
+
title: h.title || h.label || h.insert,
|
|
4230
4239
|
onMouseDown: (N) => {
|
|
4231
|
-
var $, ee, te, le,
|
|
4240
|
+
var $, ee, te, le, q, H, we;
|
|
4232
4241
|
N.preventDefault();
|
|
4233
4242
|
const v = c.current;
|
|
4234
|
-
if (
|
|
4235
|
-
const
|
|
4236
|
-
|
|
4237
|
-
} else if (
|
|
4238
|
-
const
|
|
4239
|
-
E({ x:
|
|
4240
|
-
} else if (
|
|
4243
|
+
if (h.action === "SPECIAL_CHARS") {
|
|
4244
|
+
const S = N.currentTarget.getBoundingClientRect();
|
|
4245
|
+
A({ x: S.left, y: S.bottom + 4 });
|
|
4246
|
+
} else if (h.action === "TEXT_COLOR") {
|
|
4247
|
+
const S = N.currentTarget.getBoundingClientRect();
|
|
4248
|
+
E({ x: S.left, y: S.bottom + 4 });
|
|
4249
|
+
} else if (h.action === "BOLD") {
|
|
4241
4250
|
if (v) {
|
|
4242
4251
|
v.focus();
|
|
4243
|
-
const
|
|
4244
|
-
window.__cmeManualBold =
|
|
4252
|
+
const S = !f.bold;
|
|
4253
|
+
window.__cmeManualBold = S;
|
|
4245
4254
|
const D = v.selection;
|
|
4246
4255
|
if (D && !D.isCollapsed) {
|
|
4247
4256
|
let W = v.getValue(D);
|
|
4248
|
-
W = W.replace(/\\mathrm{([^}]*)}/g, "$1").replace(/\\mathbf{([^}]*)}/g, "$1").replace(/\\mathit{([^}]*)}/g, "$1").replace(/\\mathbfit{([^}]*)}/g, "$1"),
|
|
4257
|
+
W = W.replace(/\\mathrm{([^}]*)}/g, "$1").replace(/\\mathbf{([^}]*)}/g, "$1").replace(/\\mathit{([^}]*)}/g, "$1").replace(/\\mathbfit{([^}]*)}/g, "$1"), S && f.italic ? v.executeCommand(["insert", `\\mathbfit{${W}}`]) : S ? v.executeCommand(["insert", `\\mathbf{${W}}`]) : f.italic ? v.executeCommand(["insert", `\\mathit{${W}}`]) : v.executeCommand(["insert", `\\mathrm{${W}}`]);
|
|
4249
4258
|
}
|
|
4250
|
-
ce((W) => ({ ...W, bold:
|
|
4259
|
+
ce((W) => ({ ...W, bold: S }));
|
|
4251
4260
|
}
|
|
4252
|
-
} else if (
|
|
4261
|
+
} else if (h.action === "ITALIC") {
|
|
4253
4262
|
if (v) {
|
|
4254
4263
|
v.focus();
|
|
4255
|
-
const
|
|
4256
|
-
window.__cmeManualItalic =
|
|
4264
|
+
const S = !f.italic;
|
|
4265
|
+
window.__cmeManualItalic = S;
|
|
4257
4266
|
const D = v.selection;
|
|
4258
4267
|
if (D && !D.isCollapsed) {
|
|
4259
4268
|
let W = v.getValue(D);
|
|
4260
|
-
W = W.replace(/\\mathrm{([^}]*)}/g, "$1").replace(/\\mathbf{([^}]*)}/g, "$1").replace(/\\mathit{([^}]*)}/g, "$1").replace(/\\mathbfit{([^}]*)}/g, "$1"), f.bold &&
|
|
4269
|
+
W = W.replace(/\\mathrm{([^}]*)}/g, "$1").replace(/\\mathbf{([^}]*)}/g, "$1").replace(/\\mathit{([^}]*)}/g, "$1").replace(/\\mathbfit{([^}]*)}/g, "$1"), f.bold && S ? v.executeCommand(["insert", `\\mathbfit{${W}}`]) : f.bold ? v.executeCommand(["insert", `\\mathbf{${W}}`]) : S ? v.executeCommand(["insert", `\\mathit{${W}}`]) : v.executeCommand(["insert", `\\mathrm{${W}}`]);
|
|
4261
4270
|
}
|
|
4262
|
-
ce((W) => ({ ...W, italic:
|
|
4271
|
+
ce((W) => ({ ...W, italic: S }));
|
|
4263
4272
|
}
|
|
4264
|
-
} else
|
|
4273
|
+
} else h.action === "UNDO" ? ($ = c.current) == null || $.executeCommand("undo") : h.action === "REDO" ? (ee = c.current) == null || ee.executeCommand("redo") : h.action === "CUT" ? ((te = c.current) == null || te.focus(), (le = c.current) == null || le.executeCommand("cutToClipboard")) : h.action === "COPY" ? ((q = c.current) == null || q.focus(), (H = c.current) == null || H.executeCommand("copyToClipboard")) : h.action === "PASTE" ? ((we = c.current) == null || we.focus(), navigator.clipboard.readText().then((S) => {
|
|
4265
4274
|
var D;
|
|
4266
|
-
(D = c.current) == null || D.executeCommand(["insert",
|
|
4267
|
-
}).catch((
|
|
4275
|
+
(D = c.current) == null || D.executeCommand(["insert", S]);
|
|
4276
|
+
}).catch((S) => {
|
|
4268
4277
|
var D;
|
|
4269
4278
|
(D = c.current) == null || D.executeCommand("pasteFromClipboard");
|
|
4270
|
-
})) :
|
|
4279
|
+
})) : J(h.insert);
|
|
4271
4280
|
}
|
|
4272
4281
|
},
|
|
4273
|
-
(
|
|
4282
|
+
(M.isTemplate || M.label === "√(□)" || M.isMatrix || h.isWidget) && h.insert && !h.action && !h.forceLabel ? /* @__PURE__ */ e.createElement(
|
|
4274
4283
|
"math-field",
|
|
4275
4284
|
{
|
|
4276
4285
|
"read-only": !0,
|
|
@@ -4289,24 +4298,24 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4289
4298
|
cursor: "pointer"
|
|
4290
4299
|
}
|
|
4291
4300
|
},
|
|
4292
|
-
pe(
|
|
4293
|
-
) :
|
|
4301
|
+
pe(h.insert)
|
|
4302
|
+
) : h.label
|
|
4294
4303
|
);
|
|
4295
4304
|
})
|
|
4296
4305
|
));
|
|
4297
4306
|
})())),
|
|
4298
|
-
b &&
|
|
4307
|
+
b && Q(/* @__PURE__ */ e.createElement(
|
|
4299
4308
|
"div",
|
|
4300
4309
|
{
|
|
4301
4310
|
ref: (t) => {
|
|
4302
4311
|
t && requestAnimationFrame(() => {
|
|
4303
|
-
const
|
|
4304
|
-
let d = b.cx -
|
|
4305
|
-
if (
|
|
4306
|
-
const w =
|
|
4307
|
-
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);
|
|
4308
4317
|
}
|
|
4309
|
-
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";
|
|
4310
4319
|
});
|
|
4311
4320
|
},
|
|
4312
4321
|
className: "cme-more-popup",
|
|
@@ -4315,20 +4324,19 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4315
4324
|
left: `${b.cx}px`,
|
|
4316
4325
|
top: `${b.y}px`,
|
|
4317
4326
|
transform: "translateX(-50%)",
|
|
4318
|
-
|
|
4319
|
-
zIndex: 1e5,
|
|
4327
|
+
zIndex: 2147483647,
|
|
4320
4328
|
gridTemplateColumns: `repeat(${b.cols || 1}, auto)`
|
|
4321
4329
|
}
|
|
4322
4330
|
},
|
|
4323
|
-
b.items.map((t,
|
|
4331
|
+
b.items.map((t, i) => /* @__PURE__ */ e.createElement(
|
|
4324
4332
|
"button",
|
|
4325
4333
|
{
|
|
4326
|
-
key:
|
|
4334
|
+
key: i,
|
|
4327
4335
|
type: "button",
|
|
4328
4336
|
className: `cme-more-popup-btn ${t.cls || ""}`,
|
|
4329
4337
|
title: t.title || t.label || t.insert,
|
|
4330
|
-
onMouseDown: (
|
|
4331
|
-
|
|
4338
|
+
onMouseDown: (r) => {
|
|
4339
|
+
r.preventDefault(), J(t.insert), y(null);
|
|
4332
4340
|
}
|
|
4333
4341
|
},
|
|
4334
4342
|
t.insert && !t.action && (t.cls === "template" || t.isWidget) ? /* @__PURE__ */ e.createElement(
|
|
@@ -4360,8 +4368,8 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4360
4368
|
className: "cme-mathfield-container",
|
|
4361
4369
|
onMouseDown: (t) => {
|
|
4362
4370
|
c.current && (t.target === c.current || c.current.contains(t.target)) || (t.preventDefault(), requestAnimationFrame(() => {
|
|
4363
|
-
var
|
|
4364
|
-
(
|
|
4371
|
+
var i, r;
|
|
4372
|
+
(r = (i = c.current) == null ? void 0 : i.focus) == null || r.call(i);
|
|
4365
4373
|
}));
|
|
4366
4374
|
}
|
|
4367
4375
|
},
|
|
@@ -4369,7 +4377,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4369
4377
|
"math-field",
|
|
4370
4378
|
{
|
|
4371
4379
|
ref: (t) => {
|
|
4372
|
-
c.current = t, V = t;
|
|
4380
|
+
c.current = t, V = t, t && (t.inlineShortcuts = Object.assign({}, t.inlineShortcuts, { "*": "*" }));
|
|
4373
4381
|
},
|
|
4374
4382
|
class: "cme-mathfield",
|
|
4375
4383
|
tabIndex: 0,
|
|
@@ -4378,23 +4386,23 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4378
4386
|
}
|
|
4379
4387
|
)
|
|
4380
4388
|
),
|
|
4381
|
-
/* @__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")),
|
|
4382
4390
|
We && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
|
|
4383
4391
|
t.stopPropagation(), _(!1);
|
|
4384
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) => {
|
|
4385
|
-
t.stopPropagation(), _(!1),
|
|
4393
|
+
t.stopPropagation(), _(!1), a && a();
|
|
4386
4394
|
} }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
|
|
4387
4395
|
t.stopPropagation(), _(!1);
|
|
4388
4396
|
} }, "Cancel")))),
|
|
4389
|
-
x &&
|
|
4397
|
+
x && Q(
|
|
4390
4398
|
/* @__PURE__ */ e.createElement(
|
|
4391
4399
|
Ge,
|
|
4392
4400
|
{
|
|
4393
4401
|
matrixType: x.type,
|
|
4394
4402
|
x: x.x,
|
|
4395
4403
|
y: x.y,
|
|
4396
|
-
onSelect: (t,
|
|
4397
|
-
Be(x.type, t,
|
|
4404
|
+
onSelect: (t, i) => {
|
|
4405
|
+
Be(x.type, t, i), I(null);
|
|
4398
4406
|
},
|
|
4399
4407
|
onMouseEnter: () => {
|
|
4400
4408
|
},
|
|
@@ -4404,21 +4412,21 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4404
4412
|
),
|
|
4405
4413
|
document.body
|
|
4406
4414
|
),
|
|
4407
|
-
p &&
|
|
4415
|
+
p && Q(
|
|
4408
4416
|
/* @__PURE__ */ e.createElement(
|
|
4409
4417
|
je,
|
|
4410
4418
|
{
|
|
4411
4419
|
isOpen: !!p,
|
|
4412
4420
|
position: p,
|
|
4413
|
-
onClose: () =>
|
|
4421
|
+
onClose: () => A(null),
|
|
4414
4422
|
onInsert: (t) => {
|
|
4415
|
-
|
|
4423
|
+
J(t), A(null);
|
|
4416
4424
|
}
|
|
4417
4425
|
}
|
|
4418
4426
|
),
|
|
4419
4427
|
document.body
|
|
4420
4428
|
),
|
|
4421
|
-
k &&
|
|
4429
|
+
k && Q(
|
|
4422
4430
|
/* @__PURE__ */ e.createElement(
|
|
4423
4431
|
"div",
|
|
4424
4432
|
{
|
|
@@ -4427,7 +4435,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4427
4435
|
position: "fixed",
|
|
4428
4436
|
left: Math.min(k.x, window.innerWidth - 160) + "px",
|
|
4429
4437
|
top: Math.min(k.y, window.innerHeight - 100) + "px",
|
|
4430
|
-
zIndex:
|
|
4438
|
+
zIndex: 2147483647,
|
|
4431
4439
|
background: "#fff",
|
|
4432
4440
|
border: "1px solid #ccc",
|
|
4433
4441
|
padding: "6px",
|
|
@@ -4464,7 +4472,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4464
4472
|
"violet",
|
|
4465
4473
|
"gold"
|
|
4466
4474
|
].map((t) => {
|
|
4467
|
-
const
|
|
4475
|
+
const i = f.color === t || t === "black" && (f.color === "none" || !f.color);
|
|
4468
4476
|
return /* @__PURE__ */ e.createElement(
|
|
4469
4477
|
"div",
|
|
4470
4478
|
{
|
|
@@ -4475,13 +4483,13 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4475
4483
|
height: "16px",
|
|
4476
4484
|
backgroundColor: t,
|
|
4477
4485
|
cursor: "pointer",
|
|
4478
|
-
border:
|
|
4486
|
+
border: i ? "2px solid #e6c229" : "1px solid #000",
|
|
4479
4487
|
boxSizing: "border-box"
|
|
4480
4488
|
},
|
|
4481
|
-
onMouseDown: (
|
|
4482
|
-
|
|
4489
|
+
onMouseDown: (r) => {
|
|
4490
|
+
r.preventDefault(), r.stopPropagation();
|
|
4483
4491
|
const d = c.current;
|
|
4484
|
-
d && typeof d.applyStyle == "function" && (d.focus(), d.applyStyle({ color: t === "black" ? "none" : t }),
|
|
4492
|
+
d && typeof d.applyStyle == "function" && (d.focus(), d.applyStyle({ color: t === "black" ? "none" : t }), P()), E(null);
|
|
4485
4493
|
}
|
|
4486
4494
|
}
|
|
4487
4495
|
);
|
|
@@ -4493,14 +4501,14 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: i })
|
|
|
4493
4501
|
document.body
|
|
4494
4502
|
);
|
|
4495
4503
|
}
|
|
4496
|
-
const ot = ({ isOpen: l, mode: o, initialValue:
|
|
4504
|
+
const ot = ({ isOpen: l, mode: o, initialValue: a, onInsert: s, onClose: n }) => l ? /* @__PURE__ */ e.createElement(
|
|
4497
4505
|
$e,
|
|
4498
4506
|
{
|
|
4499
4507
|
mode: o,
|
|
4500
4508
|
onInsert: s,
|
|
4501
|
-
onClose:
|
|
4502
|
-
initialLatex:
|
|
4503
|
-
isEditing: !!
|
|
4509
|
+
onClose: n,
|
|
4510
|
+
initialLatex: a || "",
|
|
4511
|
+
isEditing: !!a
|
|
4504
4512
|
}
|
|
4505
4513
|
) : null;
|
|
4506
4514
|
export {
|