digi-mathchem-editor 1.0.5 → 1.0.7
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/README.md +9 -9
- package/dist/digi-mathchem-editor.es.js +423 -420
- package/dist/digi-mathchem-editor.umd.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import e, { useState as W, useEffect as O, useMemo as we, useRef as
|
|
2
|
-
import { createPortal as
|
|
1
|
+
import e, { useState as W, useEffect as O, useMemo as we, useRef as le, useCallback as ce } from "react";
|
|
2
|
+
import { createPortal as Q } from "react-dom";
|
|
3
3
|
import { FontAwesomeIcon as ie } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { faBold as fe, faItalic as ve } from "@fortawesome/free-solid-svg-icons";
|
|
5
5
|
import { MathfieldElement as xe } from "mathlive";
|
|
@@ -3752,15 +3752,15 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: r, onMouseLe
|
|
|
3752
3752
|
onMouseLeave: h
|
|
3753
3753
|
},
|
|
3754
3754
|
/* @__PURE__ */ e.createElement("div", { className: "cme-matrix-hover-grid" }, Array.from({ length: x }).map((p, f) => /* @__PURE__ */ e.createElement("div", { key: f, className: "cme-matrix-hover-row" }, Array.from({ length: B }).map((C, M) => {
|
|
3755
|
-
const P = parseInt(m.r, 10) || 0,
|
|
3755
|
+
const P = parseInt(m.r, 10) || 0, X = parseInt(m.c, 10) || 0, J = f < P && M < X;
|
|
3756
3756
|
return /* @__PURE__ */ e.createElement(
|
|
3757
3757
|
"div",
|
|
3758
3758
|
{
|
|
3759
3759
|
key: `${f}-${M}`,
|
|
3760
3760
|
className: `cme-matrix-hover-cell${J ? " selected" : ""}`,
|
|
3761
3761
|
onMouseEnter: () => k({ r: f + 1, c: M + 1 }),
|
|
3762
|
-
onClick: (
|
|
3763
|
-
|
|
3762
|
+
onClick: (K) => {
|
|
3763
|
+
K.preventDefault(), K.stopPropagation(), s(f + 1, M + 1);
|
|
3764
3764
|
}
|
|
3765
3765
|
}
|
|
3766
3766
|
);
|
|
@@ -3804,9 +3804,9 @@ function Ge({ matrixType: l, x: o, y: n, onSelect: s, onMouseEnter: r, onMouseLe
|
|
|
3804
3804
|
}
|
|
3805
3805
|
let Z = !1, de = null, U = null;
|
|
3806
3806
|
function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r }) {
|
|
3807
|
-
const h =
|
|
3808
|
-
|
|
3809
|
-
const [C, M] = W({ x: 0, y: 0 }), [P,
|
|
3807
|
+
const h = le(null), [m, k] = W(0), [x, B] = W(null), [E, D] = W(null), [g, y] = W(null), [p, f] = W(null);
|
|
3808
|
+
le(null);
|
|
3809
|
+
const [C, M] = W({ x: 0, y: 0 }), [P, X] = W(!1), J = le({ x: 0, y: 0 }), [K, be] = W(!1), [Te, ge] = W(!1), [We, Y] = W(!1), oe = le(null);
|
|
3810
3810
|
O(() => {
|
|
3811
3811
|
const t = (a) => {
|
|
3812
3812
|
if (!P) return;
|
|
@@ -3816,14 +3816,14 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
|
|
|
3816
3816
|
d < c && (d = c), d > T && (d = T), b < L && (b = L), b > R && (b = R);
|
|
3817
3817
|
}
|
|
3818
3818
|
M({ x: d, y: b });
|
|
3819
|
-
}, i = () =>
|
|
3819
|
+
}, i = () => X(!1);
|
|
3820
3820
|
return P && (window.addEventListener("mousemove", t), window.addEventListener("mouseup", i)), () => {
|
|
3821
3821
|
window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", i);
|
|
3822
3822
|
};
|
|
3823
3823
|
}, [P]);
|
|
3824
3824
|
const Ie = (t) => {
|
|
3825
3825
|
if (t.target.closest(".cme-popup-controls")) return;
|
|
3826
|
-
|
|
3826
|
+
X(!0), J.current = {
|
|
3827
3827
|
x: t.clientX - C.x,
|
|
3828
3828
|
y: t.clientY - C.y
|
|
3829
3829
|
};
|
|
@@ -3945,8 +3945,8 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
|
|
|
3945
3945
|
let R = L;
|
|
3946
3946
|
const z = u.fontSize === "auto" ? 5 : parseInt(u.fontSize, 10);
|
|
3947
3947
|
if (z !== 5) {
|
|
3948
|
-
const
|
|
3949
|
-
|
|
3948
|
+
const _ = { 1: "\\tiny", 2: "\\scriptsize", 3: "\\footnotesize", 4: "\\small", 5: "\\normalsize", 6: "\\large", 7: "\\Large", 8: "\\LARGE", 9: "\\huge", 10: "\\Huge" };
|
|
3949
|
+
_[z] && (R = `{${_[z]} ${R}}`);
|
|
3950
3950
|
}
|
|
3951
3951
|
u.color !== "none" && (R = `\\textcolor{${u.color}}{${R}}`), t.executeCommand(["insert", R]);
|
|
3952
3952
|
return;
|
|
@@ -4000,7 +4000,7 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
|
|
|
4000
4000
|
return;
|
|
4001
4001
|
}
|
|
4002
4002
|
const a = i.getValue ? i.getValue("latex") : i.value, d = s || "";
|
|
4003
|
-
!a || a.trim() === "" || a === d ? n && n() :
|
|
4003
|
+
!a || a.trim() === "" || a === d ? n && n() : Y(!0);
|
|
4004
4004
|
}, Re = () => {
|
|
4005
4005
|
const t = U;
|
|
4006
4006
|
if (!t) return;
|
|
@@ -4011,450 +4011,453 @@ function $e({ mode: l, onInsert: o, onClose: n, initialLatex: s, isEditing: r })
|
|
|
4011
4011
|
}
|
|
4012
4012
|
l === "chem" && (i = _e(i)), i = ne(i), o && o(i), t.setValue ? t.setValue("") : t.value = "", n && n();
|
|
4013
4013
|
};
|
|
4014
|
-
return
|
|
4015
|
-
|
|
4016
|
-
{
|
|
4017
|
-
className: `cme-editor-popup ${X ? "maximized" : ""} ${Te ? "minimized" : ""}`,
|
|
4018
|
-
style: { transform: `translate(${C.x}px, ${C.y}px)` },
|
|
4019
|
-
onMouseDown: (t) => t.stopPropagation()
|
|
4020
|
-
},
|
|
4021
|
-
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-topbar" }, /* @__PURE__ */ e.createElement(
|
|
4014
|
+
return Q(
|
|
4015
|
+
/* @__PURE__ */ e.createElement(
|
|
4022
4016
|
"div",
|
|
4023
4017
|
{
|
|
4024
|
-
className:
|
|
4025
|
-
|
|
4026
|
-
|
|
4018
|
+
className: `cme-editor-popup ${K ? "maximized" : ""} ${Te ? "minimized" : ""}`,
|
|
4019
|
+
style: { transform: `translate(${C.x}px, ${C.y}px)` },
|
|
4020
|
+
onMouseDown: (t) => t.stopPropagation()
|
|
4027
4021
|
},
|
|
4028
|
-
/* @__PURE__ */ e.createElement("
|
|
4029
|
-
), /* @__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: ke, title: "Close" }, "✕"))),
|
|
4030
|
-
/* @__PURE__ */ e.createElement("div", { className: "cme-toolbar", role: "toolbar", "aria-label": "Symbol palette" }, /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-groups" }, q.map((t, i) => {
|
|
4031
|
-
const a = m === i;
|
|
4032
|
-
return /* @__PURE__ */ e.createElement(
|
|
4033
|
-
"button",
|
|
4034
|
-
{
|
|
4035
|
-
key: t.isMatrix ? "matrix-tab" : t.label,
|
|
4036
|
-
className: `cme-group-tab${a ? " active" : ""}`,
|
|
4037
|
-
type: "button",
|
|
4038
|
-
onMouseDown: (d) => {
|
|
4039
|
-
d.preventDefault(), k(i), B(null);
|
|
4040
|
-
}
|
|
4041
|
-
},
|
|
4042
|
-
t.mathLabel ? /* @__PURE__ */ e.createElement(
|
|
4043
|
-
"math-field",
|
|
4044
|
-
{
|
|
4045
|
-
"read-only": !0,
|
|
4046
|
-
tabIndex: -1,
|
|
4047
|
-
style: {
|
|
4048
|
-
pointerEvents: "none",
|
|
4049
|
-
background: "transparent",
|
|
4050
|
-
border: "none",
|
|
4051
|
-
outline: "none",
|
|
4052
|
-
fontSize: t.fontSize || (t.isMatrix ? "8px" : "11px"),
|
|
4053
|
-
display: "inline-block",
|
|
4054
|
-
width: "auto",
|
|
4055
|
-
minHeight: "auto",
|
|
4056
|
-
padding: "0",
|
|
4057
|
-
margin: "0",
|
|
4058
|
-
boxShadow: "none",
|
|
4059
|
-
color: a ? "#333333" : "#ffffff"
|
|
4060
|
-
}
|
|
4061
|
-
},
|
|
4062
|
-
t.mathLabel
|
|
4063
|
-
) : t.label
|
|
4064
|
-
);
|
|
4065
|
-
})), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
|
|
4066
|
-
var d;
|
|
4067
|
-
const t = ((d = q[m]) == null ? void 0 : d.items) || [], i = t.some((b) => b.type === "sep"), a = [];
|
|
4068
|
-
if (i) {
|
|
4069
|
-
let b = { cols: 2, small: !1, cls: "", items: [], moreItems: null };
|
|
4070
|
-
for (const w of t)
|
|
4071
|
-
w.type === "sep" ? (b.items.length > 0 && a.push(b), b = { cols: w.cols || 2, small: !!w.small, cls: w.cls || "", items: [], moreItems: w.moreItems || null, moreCols: w.moreCols || 1 }) : b.items.push(w);
|
|
4072
|
-
b.items.length > 0 && a.push(b);
|
|
4073
|
-
} else
|
|
4074
|
-
for (let w = 0; w < t.length; w += 4)
|
|
4075
|
-
a.push({
|
|
4076
|
-
cols: 2,
|
|
4077
|
-
small: !1,
|
|
4078
|
-
cls: "",
|
|
4079
|
-
items: t.slice(w, w + 4)
|
|
4080
|
-
});
|
|
4081
|
-
return a.map((b, w) => /* @__PURE__ */ e.createElement(
|
|
4022
|
+
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-topbar" }, /* @__PURE__ */ e.createElement(
|
|
4082
4023
|
"div",
|
|
4083
4024
|
{
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
style: {
|
|
4025
|
+
className: "cme-popup-header",
|
|
4026
|
+
onMouseDown: Ie,
|
|
4027
|
+
style: { cursor: P ? "grabbing" : "grab" }
|
|
4087
4028
|
},
|
|
4088
|
-
|
|
4029
|
+
/* @__PURE__ */ e.createElement("span", null, r ? l === "math" ? "Edit Math Formula" : "Edit Chemistry Formula" : l === "math" ? "Math Editor" : "Chemistry Editor")
|
|
4030
|
+
), /* @__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: ke, title: "Close" }, "✕"))),
|
|
4031
|
+
/* @__PURE__ */ e.createElement("div", { className: "cme-toolbar", role: "toolbar", "aria-label": "Symbol palette" }, /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-groups" }, q.map((t, i) => {
|
|
4032
|
+
const a = m === i;
|
|
4033
|
+
return /* @__PURE__ */ e.createElement(
|
|
4089
4034
|
"button",
|
|
4090
4035
|
{
|
|
4036
|
+
key: t.isMatrix ? "matrix-tab" : t.label,
|
|
4037
|
+
className: `cme-group-tab${a ? " active" : ""}`,
|
|
4091
4038
|
type: "button",
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
onMouseDown: (c) => {
|
|
4095
|
-
if (c.preventDefault(), p && p.items === b.moreItems)
|
|
4096
|
-
f(null);
|
|
4097
|
-
else {
|
|
4098
|
-
const T = c.currentTarget.getBoundingClientRect();
|
|
4099
|
-
f({ cx: T.left + T.width / 2, y: T.bottom, items: b.moreItems, cols: b.moreCols, isTemplate: q[m].isTemplate || q[m].label === "√(□)" || q[m].isMatrix });
|
|
4100
|
-
}
|
|
4039
|
+
onMouseDown: (d) => {
|
|
4040
|
+
d.preventDefault(), k(i), B(null);
|
|
4101
4041
|
}
|
|
4102
4042
|
},
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4043
|
+
t.mathLabel ? /* @__PURE__ */ e.createElement(
|
|
4044
|
+
"math-field",
|
|
4045
|
+
{
|
|
4046
|
+
"read-only": !0,
|
|
4047
|
+
tabIndex: -1,
|
|
4048
|
+
style: {
|
|
4049
|
+
pointerEvents: "none",
|
|
4050
|
+
background: "transparent",
|
|
4051
|
+
border: "none",
|
|
4052
|
+
outline: "none",
|
|
4053
|
+
fontSize: t.fontSize || (t.isMatrix ? "8px" : "11px"),
|
|
4054
|
+
display: "inline-block",
|
|
4055
|
+
width: "auto",
|
|
4056
|
+
minHeight: "auto",
|
|
4057
|
+
padding: "0",
|
|
4058
|
+
margin: "0",
|
|
4059
|
+
boxShadow: "none",
|
|
4060
|
+
color: a ? "#333333" : "#ffffff"
|
|
4061
|
+
}
|
|
4062
|
+
},
|
|
4063
|
+
t.mathLabel
|
|
4064
|
+
) : t.label
|
|
4065
|
+
);
|
|
4066
|
+
})), /* @__PURE__ */ e.createElement("div", { className: "cme-toolbar-items" }, (() => {
|
|
4067
|
+
var d;
|
|
4068
|
+
const t = ((d = q[m]) == null ? void 0 : d.items) || [], i = t.some((b) => b.type === "sep"), a = [];
|
|
4069
|
+
if (i) {
|
|
4070
|
+
let b = { cols: 2, small: !1, cls: "", items: [], moreItems: null };
|
|
4071
|
+
for (const w of t)
|
|
4072
|
+
w.type === "sep" ? (b.items.length > 0 && a.push(b), b = { cols: w.cols || 2, small: !!w.small, cls: w.cls || "", items: [], moreItems: w.moreItems || null, moreCols: w.moreCols || 1 }) : b.items.push(w);
|
|
4073
|
+
b.items.length > 0 && a.push(b);
|
|
4074
|
+
} else
|
|
4075
|
+
for (let w = 0; w < t.length; w += 4)
|
|
4076
|
+
a.push({
|
|
4077
|
+
cols: 2,
|
|
4078
|
+
small: !1,
|
|
4079
|
+
cls: "",
|
|
4080
|
+
items: t.slice(w, w + 4)
|
|
4081
|
+
});
|
|
4082
|
+
return a.map((b, w) => /* @__PURE__ */ e.createElement(
|
|
4083
|
+
"div",
|
|
4084
|
+
{
|
|
4085
|
+
key: w,
|
|
4086
|
+
className: `cme-symbol-subgroup${b.small ? " cme-symbol-subgroup--small" : ""}${b.cls ? ` ${b.cls}` : ""}${b.moreItems ? " cme-subgroup-has-more" : ""}`,
|
|
4087
|
+
style: { gridTemplateColumns: `repeat(${b.cols}, auto)`, position: "relative" }
|
|
4088
|
+
},
|
|
4089
|
+
b.moreItems && /* @__PURE__ */ e.createElement(
|
|
4090
|
+
"button",
|
|
4091
|
+
{
|
|
4092
|
+
type: "button",
|
|
4093
|
+
className: "cme-more-trigger-btn",
|
|
4094
|
+
title: "more",
|
|
4095
|
+
onMouseDown: (c) => {
|
|
4096
|
+
if (c.preventDefault(), p && p.items === b.moreItems)
|
|
4097
|
+
f(null);
|
|
4098
|
+
else {
|
|
4099
|
+
const T = c.currentTarget.getBoundingClientRect();
|
|
4100
|
+
f({ cx: T.left + T.width / 2, y: T.bottom, items: b.moreItems, cols: b.moreCols, isTemplate: q[m].isTemplate || q[m].label === "√(□)" || q[m].isMatrix });
|
|
4131
4101
|
}
|
|
4132
|
-
}
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
key: T,
|
|
4143
|
-
className: "cme-matrix-btn-wrapper"
|
|
4144
|
-
},
|
|
4145
|
-
/* @__PURE__ */ e.createElement(
|
|
4146
|
-
"button",
|
|
4102
|
+
}
|
|
4103
|
+
},
|
|
4104
|
+
"▶"
|
|
4105
|
+
),
|
|
4106
|
+
b.items.map((c, T) => {
|
|
4107
|
+
const L = q[m];
|
|
4108
|
+
if (c.type === "dropdown") {
|
|
4109
|
+
const N = c.label === "Font...", v = c.label === "Size", G = N && u.fontFamily !== "none", $ = v && u.fontSize !== "auto" && u.fontSize !== "5", ee = N ? u.fontFamily === "none" ? "" : u.fontFamily : v ? u.fontSize === "auto" || u.fontSize === "5" ? "" : u.fontSize : "";
|
|
4110
|
+
return /* @__PURE__ */ e.createElement(
|
|
4111
|
+
"select",
|
|
4147
4112
|
{
|
|
4148
|
-
|
|
4149
|
-
className: `cme-btn template${
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4113
|
+
key: T,
|
|
4114
|
+
className: `cme-btn template${G || $ ? " active" : ""}`,
|
|
4115
|
+
value: ee,
|
|
4116
|
+
style: {
|
|
4117
|
+
width: c.width || "60px",
|
|
4118
|
+
height: "18px",
|
|
4119
|
+
minHeight: "18px",
|
|
4120
|
+
maxHeight: "18px",
|
|
4121
|
+
lineHeight: "18px",
|
|
4122
|
+
boxSizing: "border-box",
|
|
4123
|
+
marginTop: "10px",
|
|
4124
|
+
fontSize: "10px",
|
|
4125
|
+
padding: "0",
|
|
4126
|
+
margin: "2px 0",
|
|
4127
|
+
gridColumn: b.cols === 3 || b.cols === 1 ? "span 1" : "span 2"
|
|
4128
|
+
},
|
|
4129
|
+
onChange: (te) => {
|
|
4130
|
+
const F = te.target.value, H = U;
|
|
4131
|
+
!H || typeof H.applyStyle != "function" || (H.focus(), N ? H.applyStyle({ fontFamily: F || "none" }) : v && H.applyStyle({ fontSize: F ? parseInt(F, 10) : "auto" }), V());
|
|
4163
4132
|
}
|
|
4164
4133
|
},
|
|
4165
|
-
|
|
4166
|
-
|
|
4134
|
+
/* @__PURE__ */ e.createElement("option", { value: "" }, c.label),
|
|
4135
|
+
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")),
|
|
4136
|
+
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"))
|
|
4137
|
+
);
|
|
4138
|
+
}
|
|
4139
|
+
if (L.isMatrix && !c.directInsert)
|
|
4140
|
+
return /* @__PURE__ */ e.createElement(
|
|
4141
|
+
"div",
|
|
4142
|
+
{
|
|
4143
|
+
key: T,
|
|
4144
|
+
className: "cme-matrix-btn-wrapper"
|
|
4145
|
+
},
|
|
4146
|
+
/* @__PURE__ */ e.createElement(
|
|
4147
|
+
"button",
|
|
4167
4148
|
{
|
|
4168
|
-
"
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4149
|
+
type: "button",
|
|
4150
|
+
className: `cme-btn template${c.cls ? ` ${c.cls}` : ""}${L.isMatrix ? " cme-matrix-btn-small" : ""}`,
|
|
4151
|
+
title: c.title || c.label || c.insert,
|
|
4152
|
+
onMouseDown: (N) => {
|
|
4153
|
+
if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === c.insert)
|
|
4154
|
+
B(null);
|
|
4155
|
+
else {
|
|
4156
|
+
Z || (window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0);
|
|
4157
|
+
const v = N.currentTarget.getBoundingClientRect();
|
|
4158
|
+
B({
|
|
4159
|
+
type: c.insert,
|
|
4160
|
+
x: v.left + v.width / 2,
|
|
4161
|
+
y: v.bottom
|
|
4162
|
+
});
|
|
4163
|
+
}
|
|
4182
4164
|
}
|
|
4183
4165
|
},
|
|
4184
|
-
|
|
4166
|
+
typeof c.label == "object" ? c.label : /* @__PURE__ */ e.createElement(
|
|
4167
|
+
"math-field",
|
|
4168
|
+
{
|
|
4169
|
+
"read-only": !0,
|
|
4170
|
+
style: {
|
|
4171
|
+
pointerEvents: "none",
|
|
4172
|
+
background: "transparent",
|
|
4173
|
+
border: "none",
|
|
4174
|
+
outline: "none",
|
|
4175
|
+
fontSize: "12px",
|
|
4176
|
+
display: "inline-block",
|
|
4177
|
+
width: "auto",
|
|
4178
|
+
minHeight: "auto",
|
|
4179
|
+
padding: "0",
|
|
4180
|
+
margin: "0",
|
|
4181
|
+
boxShadow: "none",
|
|
4182
|
+
cursor: "pointer"
|
|
4183
|
+
}
|
|
4184
|
+
},
|
|
4185
|
+
me(c.mathLabel != null ? c.mathLabel : c.insert)
|
|
4186
|
+
)
|
|
4185
4187
|
)
|
|
4186
|
-
)
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4188
|
+
);
|
|
4189
|
+
const R = c.action === "BOLD", z = c.action === "ITALIC", _ = c.action === "TEXT_COLOR", Oe = R && u.bold || z && u.italic || _ && u.color !== "none" && u.color !== "black";
|
|
4190
|
+
return /* @__PURE__ */ e.createElement(
|
|
4191
|
+
"button",
|
|
4192
|
+
{
|
|
4193
|
+
key: `${L.label}-${w * 4 + T}`,
|
|
4194
|
+
type: "button",
|
|
4195
|
+
className: `cme-btn${L.isTemplate ? " template" : ""}${c.cls ? ` ${c.cls}` : ""}${Oe ? " active" : ""}`,
|
|
4196
|
+
title: c.title || c.label || c.insert,
|
|
4197
|
+
onMouseDown: (N) => {
|
|
4198
|
+
var G, $, ee, te, F, H, ue;
|
|
4199
|
+
N.preventDefault();
|
|
4200
|
+
const v = h.current;
|
|
4201
|
+
if (c.action === "SPECIAL_CHARS") {
|
|
4202
|
+
const A = N.currentTarget.getBoundingClientRect();
|
|
4203
|
+
D({ x: A.left, y: A.bottom + 4 });
|
|
4204
|
+
} else if (c.action === "TEXT_COLOR") {
|
|
4205
|
+
const A = N.currentTarget.getBoundingClientRect();
|
|
4206
|
+
y({ x: A.left, y: A.bottom + 4 });
|
|
4207
|
+
} else if (c.action === "BOLD") {
|
|
4208
|
+
if (v) {
|
|
4209
|
+
v.focus();
|
|
4210
|
+
const A = !u.bold;
|
|
4211
|
+
window.__cmeManualBold = A;
|
|
4212
|
+
const I = v.selection;
|
|
4213
|
+
if (I && !I.isCollapsed) {
|
|
4214
|
+
let S = v.getValue(I);
|
|
4215
|
+
S = S.replace(/\\mathrm{([^}]*)}/g, "$1").replace(/\\mathbf{([^}]*)}/g, "$1").replace(/\\mathit{([^}]*)}/g, "$1").replace(/\\mathbfit{([^}]*)}/g, "$1"), A && u.italic ? v.executeCommand(["insert", `\\mathbfit{${S}}`]) : A ? v.executeCommand(["insert", `\\mathbf{${S}}`]) : u.italic ? v.executeCommand(["insert", `\\mathit{${S}}`]) : v.executeCommand(["insert", `\\mathrm{${S}}`]);
|
|
4216
|
+
}
|
|
4217
|
+
se((S) => ({ ...S, bold: A }));
|
|
4215
4218
|
}
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4219
|
+
} else if (c.action === "ITALIC") {
|
|
4220
|
+
if (v) {
|
|
4221
|
+
v.focus();
|
|
4222
|
+
const A = !u.italic;
|
|
4223
|
+
window.__cmeManualItalic = A;
|
|
4224
|
+
const I = v.selection;
|
|
4225
|
+
if (I && !I.isCollapsed) {
|
|
4226
|
+
let S = v.getValue(I);
|
|
4227
|
+
S = S.replace(/\\mathrm{([^}]*)}/g, "$1").replace(/\\mathbf{([^}]*)}/g, "$1").replace(/\\mathit{([^}]*)}/g, "$1").replace(/\\mathbfit{([^}]*)}/g, "$1"), u.bold && A ? v.executeCommand(["insert", `\\mathbfit{${S}}`]) : u.bold ? v.executeCommand(["insert", `\\mathbf{${S}}`]) : A ? v.executeCommand(["insert", `\\mathit{${S}}`]) : v.executeCommand(["insert", `\\mathrm{${S}}`]);
|
|
4228
|
+
}
|
|
4229
|
+
se((S) => ({ ...S, italic: A }));
|
|
4227
4230
|
}
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
(I = h.current) == null || I.executeCommand("pasteFromClipboard");
|
|
4236
|
-
})) : j(c.insert);
|
|
4237
|
-
}
|
|
4238
|
-
},
|
|
4239
|
-
(L.isTemplate || L.label === "√(□)" || L.isMatrix || c.isWidget) && c.insert && !c.action && !c.forceLabel ? /* @__PURE__ */ e.createElement(
|
|
4240
|
-
"math-field",
|
|
4241
|
-
{
|
|
4242
|
-
"read-only": !0,
|
|
4243
|
-
style: {
|
|
4244
|
-
pointerEvents: "none",
|
|
4245
|
-
background: "transparent",
|
|
4246
|
-
border: "none",
|
|
4247
|
-
outline: "none",
|
|
4248
|
-
fontSize: "12px",
|
|
4249
|
-
display: "inline-block",
|
|
4250
|
-
width: "auto",
|
|
4251
|
-
minHeight: "auto",
|
|
4252
|
-
padding: "0",
|
|
4253
|
-
margin: "0",
|
|
4254
|
-
boxShadow: "none",
|
|
4255
|
-
cursor: "pointer"
|
|
4231
|
+
} else c.action === "UNDO" ? (G = h.current) == null || G.executeCommand("undo") : c.action === "REDO" ? ($ = h.current) == null || $.executeCommand("redo") : c.action === "CUT" ? ((ee = h.current) == null || ee.focus(), (te = h.current) == null || te.executeCommand("cutToClipboard")) : c.action === "COPY" ? ((F = h.current) == null || F.focus(), (H = h.current) == null || H.executeCommand("copyToClipboard")) : c.action === "PASTE" ? ((ue = h.current) == null || ue.focus(), navigator.clipboard.readText().then((A) => {
|
|
4232
|
+
var I;
|
|
4233
|
+
(I = h.current) == null || I.executeCommand(["insert", A]);
|
|
4234
|
+
}).catch((A) => {
|
|
4235
|
+
var I;
|
|
4236
|
+
(I = h.current) == null || I.executeCommand("pasteFromClipboard");
|
|
4237
|
+
})) : j(c.insert);
|
|
4256
4238
|
}
|
|
4257
4239
|
},
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
zIndex: 1e5,
|
|
4286
|
-
gridTemplateColumns: `repeat(${p.cols || 1}, auto)`
|
|
4287
|
-
}
|
|
4288
|
-
},
|
|
4289
|
-
p.items.map((t, i) => /* @__PURE__ */ e.createElement(
|
|
4290
|
-
"button",
|
|
4240
|
+
(L.isTemplate || L.label === "√(□)" || L.isMatrix || c.isWidget) && c.insert && !c.action && !c.forceLabel ? /* @__PURE__ */ e.createElement(
|
|
4241
|
+
"math-field",
|
|
4242
|
+
{
|
|
4243
|
+
"read-only": !0,
|
|
4244
|
+
style: {
|
|
4245
|
+
pointerEvents: "none",
|
|
4246
|
+
background: "transparent",
|
|
4247
|
+
border: "none",
|
|
4248
|
+
outline: "none",
|
|
4249
|
+
fontSize: "12px",
|
|
4250
|
+
display: "inline-block",
|
|
4251
|
+
width: "auto",
|
|
4252
|
+
minHeight: "auto",
|
|
4253
|
+
padding: "0",
|
|
4254
|
+
margin: "0",
|
|
4255
|
+
boxShadow: "none",
|
|
4256
|
+
cursor: "pointer"
|
|
4257
|
+
}
|
|
4258
|
+
},
|
|
4259
|
+
me(c.insert)
|
|
4260
|
+
) : c.label
|
|
4261
|
+
);
|
|
4262
|
+
})
|
|
4263
|
+
));
|
|
4264
|
+
})())),
|
|
4265
|
+
p && Q(/* @__PURE__ */ e.createElement(
|
|
4266
|
+
"div",
|
|
4291
4267
|
{
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4268
|
+
ref: (t) => {
|
|
4269
|
+
t && requestAnimationFrame(() => {
|
|
4270
|
+
const i = t.getBoundingClientRect(), a = document.querySelector(".cme-editor-popup");
|
|
4271
|
+
let d = p.cx - i.width / 2, b = p.y;
|
|
4272
|
+
if (a) {
|
|
4273
|
+
const w = a.getBoundingClientRect();
|
|
4274
|
+
d + i.width > w.right - 4 && (d = w.right - i.width - 4), d < w.left + 4 && (d = w.left + 4), b + i.height > w.bottom - 4 && (b = w.bottom - i.height - 4);
|
|
4275
|
+
}
|
|
4276
|
+
d + i.width > window.innerWidth - 4 && (d = window.innerWidth - i.width - 4), b + i.height > window.innerHeight - 4 && (b = window.innerHeight - i.height - 4), d < 4 && (d = 4), t.style.left = `${d}px`, t.style.top = `${b}px`, t.style.transform = "none", t.style.visibility = "visible";
|
|
4277
|
+
});
|
|
4278
|
+
},
|
|
4279
|
+
className: "cme-more-popup",
|
|
4280
|
+
style: {
|
|
4281
|
+
position: "fixed",
|
|
4282
|
+
left: `${p.cx}px`,
|
|
4283
|
+
top: `${p.y}px`,
|
|
4284
|
+
transform: "translateX(-50%)",
|
|
4285
|
+
visibility: "hidden",
|
|
4286
|
+
zIndex: 1e5,
|
|
4287
|
+
gridTemplateColumns: `repeat(${p.cols || 1}, auto)`
|
|
4298
4288
|
}
|
|
4299
4289
|
},
|
|
4300
|
-
|
|
4301
|
-
"
|
|
4290
|
+
p.items.map((t, i) => /* @__PURE__ */ e.createElement(
|
|
4291
|
+
"button",
|
|
4302
4292
|
{
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
fontSize: "12px",
|
|
4310
|
-
display: "inline-block",
|
|
4311
|
-
width: "auto",
|
|
4312
|
-
minHeight: "auto",
|
|
4313
|
-
padding: "0",
|
|
4314
|
-
margin: "0",
|
|
4315
|
-
boxShadow: "none",
|
|
4316
|
-
cursor: "pointer"
|
|
4293
|
+
key: i,
|
|
4294
|
+
type: "button",
|
|
4295
|
+
className: `cme-more-popup-btn ${t.cls || ""}`,
|
|
4296
|
+
title: t.title || t.label || t.insert,
|
|
4297
|
+
onMouseDown: (a) => {
|
|
4298
|
+
a.preventDefault(), j(t.insert), f(null);
|
|
4317
4299
|
}
|
|
4318
4300
|
},
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
"math-virtual-keyboard-policy": "manual",
|
|
4343
|
-
placeholder: ""
|
|
4344
|
-
}
|
|
4345
|
-
)
|
|
4346
|
-
),
|
|
4347
|
-
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-footer" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-insert-btn", onClick: Re }, r ? "Update" : "Insert"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-cancel-btn", onClick: ke }, "Cancel")),
|
|
4348
|
-
We && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
|
|
4349
|
-
t.stopPropagation(), K(!1);
|
|
4350
|
-
} }, /* @__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) => {
|
|
4351
|
-
t.stopPropagation(), K(!1), n && n();
|
|
4352
|
-
} }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
|
|
4353
|
-
t.stopPropagation(), K(!1);
|
|
4354
|
-
} }, "Cancel")))),
|
|
4355
|
-
x && le(
|
|
4301
|
+
t.insert && !t.action && (t.cls === "template" || t.isWidget) ? /* @__PURE__ */ e.createElement(
|
|
4302
|
+
"math-field",
|
|
4303
|
+
{
|
|
4304
|
+
"read-only": !0,
|
|
4305
|
+
style: {
|
|
4306
|
+
pointerEvents: "none",
|
|
4307
|
+
background: "transparent",
|
|
4308
|
+
border: "none",
|
|
4309
|
+
outline: "none",
|
|
4310
|
+
fontSize: "12px",
|
|
4311
|
+
display: "inline-block",
|
|
4312
|
+
width: "auto",
|
|
4313
|
+
minHeight: "auto",
|
|
4314
|
+
padding: "0",
|
|
4315
|
+
margin: "0",
|
|
4316
|
+
boxShadow: "none",
|
|
4317
|
+
cursor: "pointer"
|
|
4318
|
+
}
|
|
4319
|
+
},
|
|
4320
|
+
me(t.mathLabel != null ? t.mathLabel : t.insert)
|
|
4321
|
+
) : t.label
|
|
4322
|
+
))
|
|
4323
|
+
), document.body),
|
|
4356
4324
|
/* @__PURE__ */ e.createElement(
|
|
4357
|
-
|
|
4325
|
+
"div",
|
|
4358
4326
|
{
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
onMouseEnter: () => {
|
|
4366
|
-
},
|
|
4367
|
-
onMouseLeave: () => {
|
|
4327
|
+
className: "cme-mathfield-container",
|
|
4328
|
+
onMouseDown: (t) => {
|
|
4329
|
+
h.current && (t.target === h.current || h.current.contains(t.target)) || (t.preventDefault(), requestAnimationFrame(() => {
|
|
4330
|
+
var i, a;
|
|
4331
|
+
(a = (i = h.current) == null ? void 0 : i.focus) == null || a.call(i);
|
|
4332
|
+
}));
|
|
4368
4333
|
}
|
|
4369
|
-
}
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
onInsert: (t) => {
|
|
4381
|
-
j(t), D(null);
|
|
4334
|
+
},
|
|
4335
|
+
/* @__PURE__ */ e.createElement(
|
|
4336
|
+
"math-field",
|
|
4337
|
+
{
|
|
4338
|
+
ref: (t) => {
|
|
4339
|
+
h.current = t, U = t;
|
|
4340
|
+
},
|
|
4341
|
+
class: "cme-mathfield",
|
|
4342
|
+
tabIndex: 0,
|
|
4343
|
+
"math-virtual-keyboard-policy": "manual",
|
|
4344
|
+
placeholder: ""
|
|
4382
4345
|
}
|
|
4383
|
-
|
|
4346
|
+
)
|
|
4384
4347
|
),
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
/* @__PURE__ */ e.createElement(
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4348
|
+
/* @__PURE__ */ e.createElement("div", { className: "cme-popup-footer" }, /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-insert-btn", onClick: Re }, r ? "Update" : "Insert"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-cancel-btn", onClick: ke }, "Cancel")),
|
|
4349
|
+
We && /* @__PURE__ */ e.createElement("div", { className: "cme-confirm-overlay", onMouseDown: (t) => {
|
|
4350
|
+
t.stopPropagation(), Y(!1);
|
|
4351
|
+
} }, /* @__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) => {
|
|
4352
|
+
t.stopPropagation(), Y(!1), n && n();
|
|
4353
|
+
} }, "Close"), /* @__PURE__ */ e.createElement("button", { type: "button", className: "cme-confirm-cancel-btn", onClick: (t) => {
|
|
4354
|
+
t.stopPropagation(), Y(!1);
|
|
4355
|
+
} }, "Cancel")))),
|
|
4356
|
+
x && Q(
|
|
4357
|
+
/* @__PURE__ */ e.createElement(
|
|
4358
|
+
Ge,
|
|
4359
|
+
{
|
|
4360
|
+
matrixType: x.type,
|
|
4361
|
+
x: x.x,
|
|
4362
|
+
y: x.y,
|
|
4363
|
+
onSelect: (t, i) => {
|
|
4364
|
+
Be(x.type, t, i), B(null);
|
|
4365
|
+
},
|
|
4366
|
+
onMouseEnter: () => {
|
|
4367
|
+
},
|
|
4368
|
+
onMouseLeave: () => {
|
|
4369
|
+
}
|
|
4405
4370
|
}
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
"cyan",
|
|
4419
|
-
"blue",
|
|
4420
|
-
"purple",
|
|
4421
|
-
"magenta",
|
|
4422
|
-
"pink",
|
|
4423
|
-
"brown",
|
|
4424
|
-
"maroon",
|
|
4425
|
-
"olive",
|
|
4426
|
-
"green",
|
|
4427
|
-
"teal",
|
|
4428
|
-
"navy",
|
|
4429
|
-
"indigo",
|
|
4430
|
-
"violet",
|
|
4431
|
-
"gold"
|
|
4432
|
-
].map((t) => {
|
|
4433
|
-
const i = u.color === t || t === "black" && (u.color === "none" || !u.color);
|
|
4434
|
-
return /* @__PURE__ */ e.createElement(
|
|
4435
|
-
"div",
|
|
4436
|
-
{
|
|
4437
|
-
key: t,
|
|
4438
|
-
title: t,
|
|
4439
|
-
style: {
|
|
4440
|
-
width: "16px",
|
|
4441
|
-
height: "16px",
|
|
4442
|
-
backgroundColor: t,
|
|
4443
|
-
cursor: "pointer",
|
|
4444
|
-
border: i ? "2px solid #e6c229" : "1px solid #000",
|
|
4445
|
-
boxSizing: "border-box"
|
|
4446
|
-
},
|
|
4447
|
-
onMouseDown: (a) => {
|
|
4448
|
-
a.preventDefault(), a.stopPropagation();
|
|
4449
|
-
const d = h.current;
|
|
4450
|
-
d && typeof d.applyStyle == "function" && (d.focus(), d.applyStyle({ color: t === "black" ? "none" : t }), V()), y(null);
|
|
4451
|
-
}
|
|
4371
|
+
),
|
|
4372
|
+
document.body
|
|
4373
|
+
),
|
|
4374
|
+
E && Q(
|
|
4375
|
+
/* @__PURE__ */ e.createElement(
|
|
4376
|
+
je,
|
|
4377
|
+
{
|
|
4378
|
+
isOpen: !!E,
|
|
4379
|
+
position: E,
|
|
4380
|
+
onClose: () => D(null),
|
|
4381
|
+
onInsert: (t) => {
|
|
4382
|
+
j(t), D(null);
|
|
4452
4383
|
}
|
|
4453
|
-
|
|
4454
|
-
|
|
4384
|
+
}
|
|
4385
|
+
),
|
|
4386
|
+
document.body
|
|
4455
4387
|
),
|
|
4456
|
-
|
|
4457
|
-
|
|
4388
|
+
g && Q(
|
|
4389
|
+
/* @__PURE__ */ e.createElement(
|
|
4390
|
+
"div",
|
|
4391
|
+
{
|
|
4392
|
+
className: "cme-color-picker-popup",
|
|
4393
|
+
style: {
|
|
4394
|
+
position: "fixed",
|
|
4395
|
+
left: Math.min(g.x, window.innerWidth - 160) + "px",
|
|
4396
|
+
top: Math.min(g.y, window.innerHeight - 100) + "px",
|
|
4397
|
+
zIndex: 1e5,
|
|
4398
|
+
background: "#fff",
|
|
4399
|
+
border: "1px solid #ccc",
|
|
4400
|
+
padding: "6px",
|
|
4401
|
+
display: "grid",
|
|
4402
|
+
gridTemplateColumns: "repeat(6, 1fr)",
|
|
4403
|
+
gap: "4px",
|
|
4404
|
+
borderRadius: "4px",
|
|
4405
|
+
boxShadow: "0 2px 5px rgba(0,0,0,0.2)"
|
|
4406
|
+
}
|
|
4407
|
+
},
|
|
4408
|
+
[
|
|
4409
|
+
"black",
|
|
4410
|
+
"dimgray",
|
|
4411
|
+
"gray",
|
|
4412
|
+
"darkgray",
|
|
4413
|
+
"silver",
|
|
4414
|
+
"white",
|
|
4415
|
+
"red",
|
|
4416
|
+
"orange",
|
|
4417
|
+
"yellow",
|
|
4418
|
+
"lime",
|
|
4419
|
+
"cyan",
|
|
4420
|
+
"blue",
|
|
4421
|
+
"purple",
|
|
4422
|
+
"magenta",
|
|
4423
|
+
"pink",
|
|
4424
|
+
"brown",
|
|
4425
|
+
"maroon",
|
|
4426
|
+
"olive",
|
|
4427
|
+
"green",
|
|
4428
|
+
"teal",
|
|
4429
|
+
"navy",
|
|
4430
|
+
"indigo",
|
|
4431
|
+
"violet",
|
|
4432
|
+
"gold"
|
|
4433
|
+
].map((t) => {
|
|
4434
|
+
const i = u.color === t || t === "black" && (u.color === "none" || !u.color);
|
|
4435
|
+
return /* @__PURE__ */ e.createElement(
|
|
4436
|
+
"div",
|
|
4437
|
+
{
|
|
4438
|
+
key: t,
|
|
4439
|
+
title: t,
|
|
4440
|
+
style: {
|
|
4441
|
+
width: "16px",
|
|
4442
|
+
height: "16px",
|
|
4443
|
+
backgroundColor: t,
|
|
4444
|
+
cursor: "pointer",
|
|
4445
|
+
border: i ? "2px solid #e6c229" : "1px solid #000",
|
|
4446
|
+
boxSizing: "border-box"
|
|
4447
|
+
},
|
|
4448
|
+
onMouseDown: (a) => {
|
|
4449
|
+
a.preventDefault(), a.stopPropagation();
|
|
4450
|
+
const d = h.current;
|
|
4451
|
+
d && typeof d.applyStyle == "function" && (d.focus(), d.applyStyle({ color: t === "black" ? "none" : t }), V()), y(null);
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
);
|
|
4455
|
+
})
|
|
4456
|
+
),
|
|
4457
|
+
document.body
|
|
4458
|
+
)
|
|
4459
|
+
),
|
|
4460
|
+
document.body
|
|
4458
4461
|
);
|
|
4459
4462
|
}
|
|
4460
4463
|
const ot = ({ isOpen: l, mode: o, initialValue: n, onInsert: s, onClose: r }) => l ? /* @__PURE__ */ e.createElement(
|