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.
@@ -1,5 +1,5 @@
1
- import e, { useState as W, useEffect as O, useMemo as we, useRef as te, useCallback as ce } from "react";
2
- import { createPortal as le } from "react-dom";
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, Q = parseInt(m.c, 10) || 0, J = f < P && M < Q;
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: (X) => {
3763
- X.preventDefault(), X.stopPropagation(), s(f + 1, M + 1);
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 = te(null), [m, k] = W(0), [x, B] = W(null), [E, D] = W(null), [g, y] = W(null), [p, f] = W(null);
3808
- te(null);
3809
- const [C, M] = W({ x: 0, y: 0 }), [P, Q] = W(!1), J = te({ x: 0, y: 0 }), [X, be] = W(!1), [Te, ge] = W(!1), [We, K] = W(!1), oe = te(null);
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 = () => Q(!1);
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
- Q(!0), J.current = {
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 Y = { 1: "\\tiny", 2: "\\scriptsize", 3: "\\footnotesize", 4: "\\small", 5: "\\normalsize", 6: "\\large", 7: "\\Large", 8: "\\LARGE", 9: "\\huge", 10: "\\Huge" };
3949
- Y[z] && (R = `{${Y[z]} ${R}}`);
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() : K(!0);
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 /* @__PURE__ */ e.createElement(
4015
- "div",
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: "cme-popup-header",
4025
- onMouseDown: Ie,
4026
- style: { cursor: P ? "grabbing" : "grab" }
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("span", null, r ? l === "math" ? "Edit Math Formula" : "Edit Chemistry Formula" : l === "math" ? "Math Editor" : "Chemistry Editor")
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
- key: w,
4085
- className: `cme-symbol-subgroup${b.small ? " cme-symbol-subgroup--small" : ""}${b.cls ? ` ${b.cls}` : ""}${b.moreItems ? " cme-subgroup-has-more" : ""}`,
4086
- style: { gridTemplateColumns: `repeat(${b.cols}, auto)`, position: "relative" }
4025
+ className: "cme-popup-header",
4026
+ onMouseDown: Ie,
4027
+ style: { cursor: P ? "grabbing" : "grab" }
4087
4028
  },
4088
- b.moreItems && /* @__PURE__ */ e.createElement(
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
- className: "cme-more-trigger-btn",
4093
- title: "more",
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
- b.items.map((c, T) => {
4106
- const L = q[m];
4107
- if (c.type === "dropdown") {
4108
- const N = c.label === "Font...", v = c.label === "Size", _ = N && u.fontFamily !== "none", G = v && u.fontSize !== "auto" && u.fontSize !== "5", $ = N ? u.fontFamily === "none" ? "" : u.fontFamily : v ? u.fontSize === "auto" || u.fontSize === "5" ? "" : u.fontSize : "";
4109
- return /* @__PURE__ */ e.createElement(
4110
- "select",
4111
- {
4112
- key: T,
4113
- className: `cme-btn template${_ || G ? " active" : ""}`,
4114
- value: $,
4115
- style: {
4116
- width: c.width || "60px",
4117
- height: "18px",
4118
- minHeight: "18px",
4119
- maxHeight: "18px",
4120
- lineHeight: "18px",
4121
- boxSizing: "border-box",
4122
- marginTop: "10px",
4123
- fontSize: "10px",
4124
- padding: "0",
4125
- margin: "2px 0",
4126
- gridColumn: b.cols === 3 || b.cols === 1 ? "span 1" : "span 2"
4127
- },
4128
- onChange: (ee) => {
4129
- const F = ee.target.value, H = U;
4130
- !H || typeof H.applyStyle != "function" || (H.focus(), N ? H.applyStyle({ fontFamily: F || "none" }) : v && H.applyStyle({ fontSize: F ? parseInt(F, 10) : "auto" }), V());
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
- /* @__PURE__ */ e.createElement("option", { value: "" }, c.label),
4134
- 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")),
4135
- 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"))
4136
- );
4137
- }
4138
- if (L.isMatrix && !c.directInsert)
4139
- return /* @__PURE__ */ e.createElement(
4140
- "div",
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
- type: "button",
4149
- className: `cme-btn template${c.cls ? ` ${c.cls}` : ""}${L.isMatrix ? " cme-matrix-btn-small" : ""}`,
4150
- title: c.title || c.label || c.insert,
4151
- onMouseDown: (N) => {
4152
- if (N.preventDefault(), N.stopPropagation(), (x == null ? void 0 : x.type) === c.insert)
4153
- B(null);
4154
- else {
4155
- Z || (window.__cmeManualBold = void 0, window.__cmeManualItalic = void 0, window.__cmeManualFontFamily = void 0, window.__cmeManualFontSize = void 0);
4156
- const v = N.currentTarget.getBoundingClientRect();
4157
- B({
4158
- type: c.insert,
4159
- x: v.left + v.width / 2,
4160
- y: v.bottom
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
- typeof c.label == "object" ? c.label : /* @__PURE__ */ e.createElement(
4166
- "math-field",
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
- "read-only": !0,
4169
- style: {
4170
- pointerEvents: "none",
4171
- background: "transparent",
4172
- border: "none",
4173
- outline: "none",
4174
- fontSize: "12px",
4175
- display: "inline-block",
4176
- width: "auto",
4177
- minHeight: "auto",
4178
- padding: "0",
4179
- margin: "0",
4180
- boxShadow: "none",
4181
- cursor: "pointer"
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
- me(c.mathLabel != null ? c.mathLabel : c.insert)
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
- const R = c.action === "BOLD", z = c.action === "ITALIC", Y = c.action === "TEXT_COLOR", Oe = R && u.bold || z && u.italic || Y && u.color !== "none" && u.color !== "black";
4189
- return /* @__PURE__ */ e.createElement(
4190
- "button",
4191
- {
4192
- key: `${L.label}-${w * 4 + T}`,
4193
- type: "button",
4194
- className: `cme-btn${L.isTemplate ? " template" : ""}${c.cls ? ` ${c.cls}` : ""}${Oe ? " active" : ""}`,
4195
- title: c.title || c.label || c.insert,
4196
- onMouseDown: (N) => {
4197
- var _, G, $, ee, F, H, ue;
4198
- N.preventDefault();
4199
- const v = h.current;
4200
- if (c.action === "SPECIAL_CHARS") {
4201
- const A = N.currentTarget.getBoundingClientRect();
4202
- D({ x: A.left, y: A.bottom + 4 });
4203
- } else if (c.action === "TEXT_COLOR") {
4204
- const A = N.currentTarget.getBoundingClientRect();
4205
- y({ x: A.left, y: A.bottom + 4 });
4206
- } else if (c.action === "BOLD") {
4207
- if (v) {
4208
- v.focus();
4209
- const A = !u.bold;
4210
- window.__cmeManualBold = A;
4211
- const I = v.selection;
4212
- if (I && !I.isCollapsed) {
4213
- let S = v.getValue(I);
4214
- 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}}`]);
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
- se((S) => ({ ...S, bold: A }));
4217
- }
4218
- } else if (c.action === "ITALIC") {
4219
- if (v) {
4220
- v.focus();
4221
- const A = !u.italic;
4222
- window.__cmeManualItalic = A;
4223
- const I = v.selection;
4224
- if (I && !I.isCollapsed) {
4225
- let S = v.getValue(I);
4226
- 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}}`]);
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
- se((S) => ({ ...S, italic: A }));
4229
- }
4230
- } else c.action === "UNDO" ? (_ = h.current) == null || _.executeCommand("undo") : c.action === "REDO" ? (G = h.current) == null || G.executeCommand("redo") : c.action === "CUT" ? (($ = h.current) == null || $.focus(), (ee = h.current) == null || ee.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) => {
4231
- var I;
4232
- (I = h.current) == null || I.executeCommand(["insert", A]);
4233
- }).catch((A) => {
4234
- var I;
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
- me(c.insert)
4259
- ) : c.label
4260
- );
4261
- })
4262
- ));
4263
- })())),
4264
- p && le(/* @__PURE__ */ e.createElement(
4265
- "div",
4266
- {
4267
- ref: (t) => {
4268
- t && requestAnimationFrame(() => {
4269
- const i = t.getBoundingClientRect(), a = document.querySelector(".cme-editor-popup");
4270
- let d = p.cx - i.width / 2, b = p.y;
4271
- if (a) {
4272
- const w = a.getBoundingClientRect();
4273
- 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);
4274
- }
4275
- 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";
4276
- });
4277
- },
4278
- className: "cme-more-popup",
4279
- style: {
4280
- position: "fixed",
4281
- left: `${p.cx}px`,
4282
- top: `${p.y}px`,
4283
- transform: "translateX(-50%)",
4284
- visibility: "hidden",
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
- key: i,
4293
- type: "button",
4294
- className: `cme-more-popup-btn ${t.cls || ""}`,
4295
- title: t.title || t.label || t.insert,
4296
- onMouseDown: (a) => {
4297
- a.preventDefault(), j(t.insert), f(null);
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
- t.insert && !t.action && (t.cls === "template" || t.isWidget) ? /* @__PURE__ */ e.createElement(
4301
- "math-field",
4290
+ p.items.map((t, i) => /* @__PURE__ */ e.createElement(
4291
+ "button",
4302
4292
  {
4303
- "read-only": !0,
4304
- style: {
4305
- pointerEvents: "none",
4306
- background: "transparent",
4307
- border: "none",
4308
- outline: "none",
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
- me(t.mathLabel != null ? t.mathLabel : t.insert)
4320
- ) : t.label
4321
- ))
4322
- ), document.body),
4323
- /* @__PURE__ */ e.createElement(
4324
- "div",
4325
- {
4326
- className: "cme-mathfield-container",
4327
- onMouseDown: (t) => {
4328
- h.current && (t.target === h.current || h.current.contains(t.target)) || (t.preventDefault(), requestAnimationFrame(() => {
4329
- var i, a;
4330
- (a = (i = h.current) == null ? void 0 : i.focus) == null || a.call(i);
4331
- }));
4332
- }
4333
- },
4334
- /* @__PURE__ */ e.createElement(
4335
- "math-field",
4336
- {
4337
- ref: (t) => {
4338
- h.current = t, U = t;
4339
- },
4340
- class: "cme-mathfield",
4341
- tabIndex: 0,
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
- Ge,
4325
+ "div",
4358
4326
  {
4359
- matrixType: x.type,
4360
- x: x.x,
4361
- y: x.y,
4362
- onSelect: (t, i) => {
4363
- Be(x.type, t, i), B(null);
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
- document.body
4372
- ),
4373
- E && le(
4374
- /* @__PURE__ */ e.createElement(
4375
- je,
4376
- {
4377
- isOpen: !!E,
4378
- position: E,
4379
- onClose: () => D(null),
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
- document.body
4386
- ),
4387
- g && le(
4388
- /* @__PURE__ */ e.createElement(
4389
- "div",
4390
- {
4391
- className: "cme-color-picker-popup",
4392
- style: {
4393
- position: "fixed",
4394
- left: Math.min(g.x, window.innerWidth - 160) + "px",
4395
- top: Math.min(g.y, window.innerHeight - 100) + "px",
4396
- zIndex: 1e5,
4397
- background: "#fff",
4398
- border: "1px solid #ccc",
4399
- padding: "6px",
4400
- display: "grid",
4401
- gridTemplateColumns: "repeat(6, 1fr)",
4402
- gap: "4px",
4403
- borderRadius: "4px",
4404
- boxShadow: "0 2px 5px rgba(0,0,0,0.2)"
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
- "black",
4409
- "dimgray",
4410
- "gray",
4411
- "darkgray",
4412
- "silver",
4413
- "white",
4414
- "red",
4415
- "orange",
4416
- "yellow",
4417
- "lime",
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
- document.body
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(