@pie-lib/math-input-mathlive 2.0.4-next.20261201094125 → 2.0.4-next.20261202142832
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/_virtual/_rolldown/runtime.js +2 -2
- package/dist/horizontal-keypad.js +20 -20
- package/dist/i18n/index.js +4 -4
- package/dist/keypad/index.js +69 -69
- package/dist/longdiv.js +1 -1
- package/dist/math-input.js +25 -25
- package/dist/mathlive-instance.js +21 -21
- package/dist/mf/input.js +34 -34
- package/dist/mf/static.js +43 -43
- package/dist/selection.js +1 -1
- package/package.json +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// \0rolldown/runtime.js
|
|
2
2
|
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
-
let r = {};
|
|
3
|
+
let r = Object.setPrototypeOf({}, null);
|
|
4
4
|
for (var i in t) e(r, i, {
|
|
5
5
|
get: t[i],
|
|
6
6
|
enumerable: !0
|
|
7
7
|
});
|
|
8
|
-
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
8
|
+
return n & 1 || e(r, Symbol.toStringTag, { value: "Module" }), n & 2 ? r : Object.preventExtensions(r);
|
|
9
9
|
};
|
|
10
10
|
export { t as __exportAll };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import i from "
|
|
5
|
-
import a from "
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { keysForGrade as n, normalizeAdditionalKeys as r } from "./keys/grades.js";
|
|
4
|
+
import { extendKeySet as i } from "./keys/utils.js";
|
|
5
|
+
import { KeyPad as a } from "./keypad/index.js";
|
|
6
6
|
import { jsx as o } from "react/jsx-runtime";
|
|
7
7
|
// src/horizontal-keypad.tsx
|
|
8
8
|
var s = (e) => {
|
|
@@ -15,17 +15,17 @@ var s = (e) => {
|
|
|
15
15
|
type: "cursor",
|
|
16
16
|
value: e.keystroke
|
|
17
17
|
};
|
|
18
|
-
}, c = class extends
|
|
18
|
+
}, c = class extends e.Component {
|
|
19
19
|
static propTypes = {
|
|
20
|
-
className:
|
|
21
|
-
controlledKeypadMode:
|
|
22
|
-
mode:
|
|
23
|
-
layoutForKeyPad:
|
|
24
|
-
onClick:
|
|
25
|
-
onFocus:
|
|
26
|
-
noDecimal:
|
|
27
|
-
additionalKeys:
|
|
28
|
-
setKeypadInteraction:
|
|
20
|
+
className: t.string,
|
|
21
|
+
controlledKeypadMode: t.bool,
|
|
22
|
+
mode: t.oneOfType([t.string, t.number]),
|
|
23
|
+
layoutForKeyPad: t.object,
|
|
24
|
+
onClick: t.func.isRequired,
|
|
25
|
+
onFocus: t.func,
|
|
26
|
+
noDecimal: t.bool,
|
|
27
|
+
additionalKeys: t.array,
|
|
28
|
+
setKeypadInteraction: t.func
|
|
29
29
|
};
|
|
30
30
|
static defaultProps = {
|
|
31
31
|
mode: "scientific",
|
|
@@ -36,16 +36,16 @@ var s = (e) => {
|
|
|
36
36
|
this.props.onClick(s(e));
|
|
37
37
|
};
|
|
38
38
|
render() {
|
|
39
|
-
let { mode:
|
|
40
|
-
return /* @__PURE__ */ o(
|
|
39
|
+
let { mode: e, onFocus: t, controlledKeypadMode: s, noDecimal: c, className: l, additionalKeys: u, layoutForKeyPad: d, setKeypadInteraction: f } = this.props, p = r(u);
|
|
40
|
+
return /* @__PURE__ */ o(a, {
|
|
41
41
|
className: l,
|
|
42
42
|
controlledKeypadMode: s,
|
|
43
|
-
onFocus:
|
|
43
|
+
onFocus: t,
|
|
44
44
|
noDecimal: c,
|
|
45
45
|
layoutForKeyPad: d,
|
|
46
|
-
additionalKeys: n(e
|
|
46
|
+
additionalKeys: i(n(e), p),
|
|
47
47
|
onPress: this.keypadPress,
|
|
48
|
-
mode:
|
|
48
|
+
mode: e,
|
|
49
49
|
setKeypadInteraction: f
|
|
50
50
|
});
|
|
51
51
|
}
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
1
|
+
import { defineCatalogs as e } from "@pie-element/shared-i18n";
|
|
2
|
+
import t from "./en-US.js";
|
|
3
3
|
// src/i18n/index.ts
|
|
4
|
-
var n =
|
|
4
|
+
var n = e({
|
|
5
5
|
packageName: "@pie-lib/math-input-mathlive",
|
|
6
|
-
source:
|
|
6
|
+
source: t,
|
|
7
7
|
loaders: {
|
|
8
8
|
es: () => import(
|
|
9
9
|
/* webpackMode: "eager" */
|
package/dist/keypad/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { flatten as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import m from "
|
|
14
|
-
import h from "
|
|
15
|
-
import {
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import n from "@mui/material/Button";
|
|
4
|
+
import r from "@mui/material/IconButton";
|
|
5
|
+
import { styled as i } from "@mui/material/styles";
|
|
6
|
+
import a from "debug";
|
|
7
|
+
import { flatten as o } from "@pie-element/shared-lodash";
|
|
8
|
+
import { color as s } from "@pie-lib/render-ui";
|
|
9
|
+
import { baseSet as c } from "../keys/index.js";
|
|
10
|
+
import { sortKeys as l } from "./keys-layout.js";
|
|
11
|
+
import { commonKeyboardStyles as u, rootIndexStyles as d } from "../mf/common-styles.js";
|
|
12
|
+
import { latexToMarkup as f, loadMathLive as p } from "../mathlive-instance.js";
|
|
13
|
+
import { fixLongDivisionWhenReady as m } from "../longdiv.js";
|
|
14
|
+
import { KEYPAD_ATTRIBUTE as h } from "../mf/inactive-caret.js";
|
|
15
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
16
16
|
// src/keypad/index.tsx
|
|
17
|
-
var _ =
|
|
18
|
-
outline: `2px solid ${
|
|
17
|
+
var _ = a("pie-lib:math-input-mathlive:keypad"), v = () => [s.text(), s.keypadInk()], y = () => ({ "& .MuiTouchRipple-root": { color: `rgb(from ${s.text()} min(r, 255 - r) min(g, 255 - g) min(b, 255 - b))` } }), b = () => ({ "&.Mui-focusVisible": {
|
|
18
|
+
outline: `2px solid ${s.focusOutline()}`,
|
|
19
19
|
outlineOffset: "-2px",
|
|
20
|
-
boxShadow: `inset 0 0 0 4px ${
|
|
21
|
-
} }), x = ["\\parallel"], S = "skewX(-15deg)", C = "0.03em currentColor", w = 1.25, T =
|
|
20
|
+
boxShadow: `inset 0 0 0 4px ${s.v("pie")("background", s.defaults.WHITE)}`
|
|
21
|
+
} }), x = ["\\parallel"], S = "skewX(-15deg)", C = "0.03em currentColor", w = 1.25, T = i("span", { shouldForwardProp: (e) => e !== "slanted" })(({ slanted: e }) => ({
|
|
22
22
|
...e && {
|
|
23
23
|
transform: `${S} scaleY(${w})`,
|
|
24
24
|
"& *": { WebkitTextStroke: C }
|
|
@@ -31,7 +31,7 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
31
31
|
lineHeight: 1,
|
|
32
32
|
maxWidth: "100%",
|
|
33
33
|
overflow: "hidden",
|
|
34
|
-
"& .ML__placeholder": { backgroundColor:
|
|
34
|
+
"& .ML__placeholder": { backgroundColor: s.keypadEmptyPlaceholder ? s.keypadEmptyPlaceholder() : void 0 },
|
|
35
35
|
"& [data-pie-empty]": { opacity: .5 },
|
|
36
36
|
"&:has(.ML__mfrac)": { paddingTop: "0.25em" },
|
|
37
37
|
"& .ML__mfrac:has([data-pie-empty]) .ML__frac-line": {
|
|
@@ -40,38 +40,38 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
40
40
|
},
|
|
41
41
|
"& .ML__mfrac:has([data-pie-empty]):not(:has(.ML__center ~ .ML__center [data-pie-empty])) .ML__frac-line": { top: "0.13em" },
|
|
42
42
|
"& .ML__mfrac:has([data-pie-empty]):not(:only-child) .ML__frac-line": { top: "0.1em" },
|
|
43
|
-
...
|
|
44
|
-
})), E = class
|
|
43
|
+
...d
|
|
44
|
+
})), E = class n extends e.Component {
|
|
45
45
|
static propTypes = {
|
|
46
|
-
latex:
|
|
47
|
-
decorative:
|
|
46
|
+
latex: t.string.isRequired,
|
|
47
|
+
decorative: t.bool
|
|
48
48
|
};
|
|
49
|
-
constructor(
|
|
50
|
-
super(
|
|
49
|
+
constructor(t) {
|
|
50
|
+
super(t), this.state = { markup: f(t.latex) }, this.labelRef = e.createRef();
|
|
51
51
|
}
|
|
52
52
|
async componentDidMount() {
|
|
53
53
|
if (this.state.markup) {
|
|
54
|
-
|
|
54
|
+
m(this.labelRef.current);
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
if (await
|
|
58
|
-
let
|
|
59
|
-
|
|
57
|
+
if (await p(), this.unmounted) return;
|
|
58
|
+
let e = f(this.props.latex);
|
|
59
|
+
e ? this.setState({ markup: e }) : n.warned || (n.warned = !0, _("MathLive unavailable - keypad labels are falling back to raw latex"));
|
|
60
60
|
}
|
|
61
61
|
componentDidUpdate(e, t) {
|
|
62
|
-
e.latex !== this.props.latex && this.setState({ markup:
|
|
62
|
+
e.latex !== this.props.latex && this.setState({ markup: f(this.props.latex) }), this.state.markup !== (t && t.markup) && m(this.labelRef.current);
|
|
63
63
|
}
|
|
64
64
|
componentWillUnmount() {
|
|
65
65
|
this.unmounted = !0;
|
|
66
66
|
}
|
|
67
67
|
render() {
|
|
68
68
|
let { markup: e } = this.state, t = this.props.decorative ? "true" : void 0;
|
|
69
|
-
return e ? /* @__PURE__ */
|
|
69
|
+
return e ? /* @__PURE__ */ g(T, {
|
|
70
70
|
ref: this.labelRef,
|
|
71
71
|
"aria-hidden": t,
|
|
72
72
|
slanted: x.includes(this.props.latex),
|
|
73
73
|
dangerouslySetInnerHTML: { __html: e }
|
|
74
|
-
}) : /* @__PURE__ */
|
|
74
|
+
}) : /* @__PURE__ */ g(T, {
|
|
75
75
|
"aria-hidden": t,
|
|
76
76
|
slanted: x.includes(this.props.latex),
|
|
77
77
|
children: this.props.latex
|
|
@@ -81,8 +81,8 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
81
81
|
gridTemplateColumns: `repeat(${e.columns}, minmax(min-content, 150px))`,
|
|
82
82
|
gridTemplateRows: `repeat(${e.rows}, minmax(40px, 60px))`,
|
|
83
83
|
gridAutoFlow: "initial"
|
|
84
|
-
} : {}, O =
|
|
85
|
-
...
|
|
84
|
+
} : {}, O = i("div")(() => ({
|
|
85
|
+
...u,
|
|
86
86
|
width: "100%",
|
|
87
87
|
display: "grid",
|
|
88
88
|
gridTemplateRows: "repeat(5, minmax(40px, 60px))",
|
|
@@ -98,9 +98,9 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
98
98
|
"& *": { fontFamily: "Roboto, Helvetica, Arial, sans-serif !important" }
|
|
99
99
|
}
|
|
100
100
|
})), k = (e) => ({
|
|
101
|
-
backgroundColor: e === "operators" ?
|
|
102
|
-
"&:hover": { backgroundColor: e === "operators" ?
|
|
103
|
-
}), A =
|
|
101
|
+
backgroundColor: e === "operators" ? s.keypadButtonOperator() : s.keypadButton(),
|
|
102
|
+
"&:hover": { backgroundColor: e === "operators" ? s.keypadButtonOperatorHover() : s.keypadButtonHover() }
|
|
103
|
+
}), A = i(n)(({ category: e, isDelete: t, isComma: n, isDot: r }) => ({
|
|
104
104
|
minWidth: "auto",
|
|
105
105
|
textTransform: "none",
|
|
106
106
|
fontSize: n || r ? "200% !important" : "140% !important",
|
|
@@ -111,7 +111,7 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
111
111
|
...t && { fontFamily: "Roboto, Helvetica, Arial, sans-serif !important" },
|
|
112
112
|
...y(),
|
|
113
113
|
...b()
|
|
114
|
-
})), j =
|
|
114
|
+
})), j = i(n)(({ category: e }) => ({
|
|
115
115
|
textTransform: "none",
|
|
116
116
|
padding: 0,
|
|
117
117
|
margin: 0,
|
|
@@ -121,33 +121,33 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
121
121
|
...k(e),
|
|
122
122
|
...y(),
|
|
123
123
|
...b()
|
|
124
|
-
})), M =
|
|
124
|
+
})), M = i(r)(({ category: e }) => ({
|
|
125
125
|
minWidth: "auto",
|
|
126
126
|
...k(e),
|
|
127
127
|
borderRadius: 0,
|
|
128
128
|
"& .icon": { height: "30px" }
|
|
129
|
-
})), N = class extends
|
|
129
|
+
})), N = class extends e.Component {
|
|
130
130
|
static propTypes = {
|
|
131
|
-
className:
|
|
132
|
-
controlledKeypadMode:
|
|
133
|
-
baseSet:
|
|
134
|
-
additionalKeys:
|
|
135
|
-
layoutForKeyPad:
|
|
136
|
-
onPress:
|
|
137
|
-
onFocus:
|
|
138
|
-
noDecimal:
|
|
139
|
-
setKeypadInteraction:
|
|
140
|
-
mode:
|
|
131
|
+
className: t.string,
|
|
132
|
+
controlledKeypadMode: t.bool,
|
|
133
|
+
baseSet: t.array,
|
|
134
|
+
additionalKeys: t.array,
|
|
135
|
+
layoutForKeyPad: t.object,
|
|
136
|
+
onPress: t.func.isRequired,
|
|
137
|
+
onFocus: t.func,
|
|
138
|
+
noDecimal: t.bool,
|
|
139
|
+
setKeypadInteraction: t.func,
|
|
140
|
+
mode: t.oneOfType([t.string, t.number])
|
|
141
141
|
};
|
|
142
142
|
static defaultProps = {
|
|
143
|
-
baseSet:
|
|
143
|
+
baseSet: c,
|
|
144
144
|
noDecimal: !1
|
|
145
145
|
};
|
|
146
|
-
constructor(
|
|
147
|
-
super(
|
|
146
|
+
constructor(t) {
|
|
147
|
+
super(t), this.keypadRef = e.createRef();
|
|
148
148
|
}
|
|
149
149
|
componentDidMount() {
|
|
150
|
-
|
|
150
|
+
p();
|
|
151
151
|
let e = this.keypadRef?.current, t = e?.closest(".main-container"), n = e?.closest(".pie-toolbar");
|
|
152
152
|
if (this.props.controlledKeypadMode && t && n) {
|
|
153
153
|
let e = t.getBoundingClientRect(), r = n.getBoundingClientRect(), i = e.top + e.height - (r.top + r.height);
|
|
@@ -172,7 +172,7 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
172
172
|
buttonClick = (e) => {
|
|
173
173
|
_("[buttonClick]", e), this.props.onPress(e);
|
|
174
174
|
};
|
|
175
|
-
flowKeys = (e,
|
|
175
|
+
flowKeys = (e, t) => o([...l(e), ...l(t)]);
|
|
176
176
|
keyIsNotAllowed = (e) => {
|
|
177
177
|
let { noDecimal: t } = this.props;
|
|
178
178
|
return !!((e.write === "." && e.label === "." || e.write === "," && e.label === ",") && t);
|
|
@@ -185,19 +185,19 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
185
185
|
"fractions",
|
|
186
186
|
"item-authoring",
|
|
187
187
|
"language"
|
|
188
|
-
].includes(a),
|
|
189
|
-
gridTemplateColumns: `repeat(${Math.floor(
|
|
188
|
+
].includes(a), s = o ? this.flowKeys([], n || []) : this.flowKeys(t, n || []), c = s.length % 5 ? 1 : 0, l = {
|
|
189
|
+
gridTemplateColumns: `repeat(${Math.floor(s.length / 5) + c}, minmax(min-content, 150px))`,
|
|
190
190
|
...D(r)
|
|
191
191
|
};
|
|
192
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ g(O, {
|
|
193
193
|
ref: this.keypadRef,
|
|
194
|
-
[
|
|
194
|
+
[h]: "",
|
|
195
195
|
className: [e, a].filter(Boolean).join(" "),
|
|
196
|
-
style:
|
|
196
|
+
style: l,
|
|
197
197
|
onFocus: i,
|
|
198
|
-
children:
|
|
199
|
-
if (!e) return /* @__PURE__ */
|
|
200
|
-
if (!(e.label || e.latex || e.icon || e.command || e.keystroke || e.write || e.type || e.actions || e.extraProps)) return /* @__PURE__ */
|
|
198
|
+
children: s.map((e, t) => {
|
|
199
|
+
if (!e) return /* @__PURE__ */ g("span", {}, `empty-${t}`);
|
|
200
|
+
if (!(e.label || e.latex || e.icon || e.command || e.keystroke || e.write || e.type || e.actions || e.extraProps)) return /* @__PURE__ */ g(A, {
|
|
201
201
|
disabled: !0,
|
|
202
202
|
"aria-hidden": "true",
|
|
203
203
|
tabIndex: -1,
|
|
@@ -207,18 +207,18 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
207
207
|
...e.actions || {},
|
|
208
208
|
...e.extraProps || {}
|
|
209
209
|
}, a = this.buttonClick.bind(this, e), s = this.keyIsNotAllowed(e), c = e.ariaLabel ? e.ariaLabel : e.name || e.label;
|
|
210
|
-
if (e.latex) return /* @__PURE__ */
|
|
210
|
+
if (e.latex) return /* @__PURE__ */ g(j, {
|
|
211
211
|
onClick: a,
|
|
212
212
|
disabled: s,
|
|
213
213
|
category: r,
|
|
214
214
|
"aria-label": c,
|
|
215
215
|
...i,
|
|
216
|
-
children: /* @__PURE__ */
|
|
216
|
+
children: /* @__PURE__ */ g(E, {
|
|
217
217
|
latex: e.latex,
|
|
218
218
|
decorative: !!c
|
|
219
219
|
})
|
|
220
220
|
}, n);
|
|
221
|
-
if (e.label) return /* @__PURE__ */
|
|
221
|
+
if (e.label) return /* @__PURE__ */ g(A, {
|
|
222
222
|
onClick: a,
|
|
223
223
|
disabled: s,
|
|
224
224
|
category: r,
|
|
@@ -230,14 +230,14 @@ var _ = f("pie-lib:math-input-mathlive:keypad"), v = () => [g.text(), g.keypadIn
|
|
|
230
230
|
children: e.label
|
|
231
231
|
}, n);
|
|
232
232
|
let l = e.icon ? e.icon : "div";
|
|
233
|
-
return /* @__PURE__ */
|
|
233
|
+
return /* @__PURE__ */ g(M, {
|
|
234
234
|
tabIndex: "-1",
|
|
235
235
|
onClick: a,
|
|
236
236
|
disabled: s,
|
|
237
237
|
category: r,
|
|
238
238
|
size: "large",
|
|
239
239
|
...i,
|
|
240
|
-
children: /* @__PURE__ */
|
|
240
|
+
children: /* @__PURE__ */ g(l, { className: "icon" })
|
|
241
241
|
}, n);
|
|
242
242
|
})
|
|
243
243
|
});
|
package/dist/longdiv.js
CHANGED
|
@@ -4,7 +4,7 @@ var t = e("pie-lib:math-input-mathlive:longdiv"), n = (e, t) => {
|
|
|
4
4
|
let n = RegExp(`(?:^|;)\\s*${t}:\\s*(-?[\\d.]+)em`).exec(e || "");
|
|
5
5
|
return n ? parseFloat(n[1]) : 0;
|
|
6
6
|
}, r = (e, t) => e && Array.from(e.children || []).find((e) => e.tagName.toLowerCase() === t), i = (e) => {
|
|
7
|
-
let t = -
|
|
7
|
+
let t = -1e400;
|
|
8
8
|
return e.querySelectorAll("*").forEach((e) => {
|
|
9
9
|
if (e.children.length || e.classList && e.classList.contains("ML__caret")) return;
|
|
10
10
|
let n = e.getBoundingClientRect();
|
package/dist/math-input.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import i from "
|
|
6
|
-
import a from "
|
|
7
|
-
import {
|
|
8
|
-
import s from "
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { styled as n } from "@mui/material/styles";
|
|
4
|
+
import r from "debug";
|
|
5
|
+
import { baseSet as i } from "./keys/index.js";
|
|
6
|
+
import { KeyPad as a } from "./keypad/index.js";
|
|
7
|
+
import { Input as o } from "./mf/input.js";
|
|
8
|
+
import { keyToAction as s } from "./latex-bridge.js";
|
|
9
9
|
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
10
10
|
// src/math-input.tsx
|
|
11
|
-
var u =
|
|
11
|
+
var u = r("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = n("div")(({ theme: e, focused: t }) => ({
|
|
12
12
|
borderRadius: "4px",
|
|
13
13
|
border: `solid 1px ${t ? e.palette.primary.main : d}`,
|
|
14
14
|
marginTop: e.spacing(1),
|
|
15
15
|
marginBottom: e.spacing(1),
|
|
16
16
|
transition: "border 200ms linear"
|
|
17
|
-
})), p =
|
|
17
|
+
})), p = n("div")({
|
|
18
18
|
width: "100%",
|
|
19
19
|
display: "flex"
|
|
20
|
-
}), m = o
|
|
20
|
+
}), m = n(o)(({ theme: e }) => ({
|
|
21
21
|
width: "100%",
|
|
22
22
|
transition: "border 200ms linear",
|
|
23
23
|
padding: e.spacing(1),
|
|
@@ -25,13 +25,13 @@ var u = s("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = o("div"
|
|
|
25
25
|
outline: "none",
|
|
26
26
|
boxShadow: "none"
|
|
27
27
|
}
|
|
28
|
-
})), h = class extends
|
|
28
|
+
})), h = class extends e.Component {
|
|
29
29
|
static propTypes = {
|
|
30
|
-
className:
|
|
31
|
-
keyset:
|
|
32
|
-
displayMode:
|
|
33
|
-
latex:
|
|
34
|
-
onChange:
|
|
30
|
+
className: t.string,
|
|
31
|
+
keyset: t.array,
|
|
32
|
+
displayMode: t.oneOf(["block", "block-on-focus"]),
|
|
33
|
+
latex: t.string,
|
|
34
|
+
onChange: t.func
|
|
35
35
|
};
|
|
36
36
|
static defaultProps = {
|
|
37
37
|
keyset: [],
|
|
@@ -42,7 +42,7 @@ var u = s("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = o("div"
|
|
|
42
42
|
}
|
|
43
43
|
keypadPress = (e) => {
|
|
44
44
|
if (u("[keypadPress] key:", e), !this.input) return;
|
|
45
|
-
let t =
|
|
45
|
+
let t = s(e);
|
|
46
46
|
t && (t.type === "command" ? this.input.keystroke(t.value) : this.input.write(t.value));
|
|
47
47
|
};
|
|
48
48
|
inputFocus = () => this.setState({ focused: !0 });
|
|
@@ -52,19 +52,19 @@ var u = s("pie-lib:math-input-mathlive"), d = "rgba(0, 0, 0, 0.23)", f = o("div"
|
|
|
52
52
|
t && e !== this.props.latex && (u("[changeLatex]", e, this.props.latex), t(e));
|
|
53
53
|
};
|
|
54
54
|
render() {
|
|
55
|
-
let { className:
|
|
55
|
+
let { className: e, keyset: t, latex: n } = this.props, { focused: r } = this.state;
|
|
56
56
|
return /* @__PURE__ */ l(f, {
|
|
57
|
-
className:
|
|
58
|
-
focused:
|
|
57
|
+
className: e,
|
|
58
|
+
focused: r,
|
|
59
59
|
children: [/* @__PURE__ */ c(m, {
|
|
60
60
|
innerRef: (e) => this.input = e,
|
|
61
61
|
onFocus: this.inputFocus,
|
|
62
62
|
onBlur: this.inputBlur,
|
|
63
|
-
latex:
|
|
63
|
+
latex: n,
|
|
64
64
|
onChange: this.changeLatex
|
|
65
|
-
}), /* @__PURE__ */ c(p, { children: /* @__PURE__ */ c(
|
|
66
|
-
baseSet:
|
|
67
|
-
additionalKeys:
|
|
65
|
+
}), /* @__PURE__ */ c(p, { children: /* @__PURE__ */ c(a, {
|
|
66
|
+
baseSet: i,
|
|
67
|
+
additionalKeys: t,
|
|
68
68
|
onPress: this.keypadPress
|
|
69
69
|
}) })]
|
|
70
70
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import s from "
|
|
1
|
+
import e from "debug";
|
|
2
|
+
import { toAccessibleLatex as t, toMathLive as n, withVisibleEmptySlots as r } from "./latex-bridge.js";
|
|
3
|
+
import { PARALLEL_CSS as i, ROOT_INDEX_CSS as a } from "./mf/common-styles.js";
|
|
4
|
+
import { fixLongDivisionWhenReady as o } from "./longdiv.js";
|
|
5
|
+
import { KEYPAD_CARET_CSS as s } from "./mf/inactive-caret.js";
|
|
6
6
|
// src/mathlive-instance.ts
|
|
7
|
-
var c =
|
|
7
|
+
var c = e("pie-lib:math-input-mathlive:instance"), l, u, d = (e) => {
|
|
8
8
|
if (!e || /^(?:[a-z+]+:)?\/\//i.test(e)) return e;
|
|
9
9
|
try {
|
|
10
10
|
return new URL(e, document.baseURI).href;
|
|
@@ -44,7 +44,7 @@ var c = s("pie-lib:math-input-mathlive:instance"), l, u, d = (e) => {
|
|
|
44
44
|
"content:\"\";position:absolute;left:50%;top:12%;height:76%;",
|
|
45
45
|
"border-right:2px solid var(--_caret-color, currentColor);",
|
|
46
46
|
"animation:ML__caret-blink 1.05s step-end forwards infinite}"
|
|
47
|
-
].join(""), C = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 522' preserveAspectRatio='none'%3E%3Crect y='241' width='100' height='40'/%3E%3C/svg%3E\") 0 0/100% 100% no-repeat", w = `.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.07em !important}.ML__latex .overline:has(>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span>span[style*="height:0.9em"])>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.1em !important}.ML__latex .overline{position:relative;top:-0.06em}.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>span[style*="height:0.9em"]){top:-2.97em !important}.ML__latex .overline .overline-line{position:relative}.ML__latex .overline .overline-line:before{content:"";display:block;position:absolute;left:0;right:0;top:-0.241em;height:0.522em !important;border:0 !important;background:currentColor;-webkit-mask:${C};mask:${C}}.ML__latex .overline .overline-line:after{display:none !important}.ML__latex:has(.overline)>.ML__strut{height:1.37em !important}`, T = ".ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}" +
|
|
47
|
+
].join(""), C = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 522' preserveAspectRatio='none'%3E%3Crect y='241' width='100' height='40'/%3E%3C/svg%3E\") 0 0/100% 100% no-repeat", w = `.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.07em !important}.ML__latex .overline:has(>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span>span[style*="height:0.9em"])>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>.overline-line){top:-4.1em !important}.ML__latex .overline{position:relative;top:-0.06em}.ML__latex .overline>.ML__vlist-t>.ML__vlist-r>.ML__vlist>span:has(>span[style*="height:0.9em"]){top:-2.97em !important}.ML__latex .overline .overline-line{position:relative}.ML__latex .overline .overline-line:before{content:"";display:block;position:absolute;left:0;right:0;top:-0.241em;height:0.522em !important;border:0 !important;background:currentColor;-webkit-mask:${C};mask:${C}}.ML__latex .overline .overline-line:after{display:none !important}.ML__latex:has(.overline)>.ML__strut{height:1.37em !important}`, T = ".ML__latex .ML__center:has(.ML__stretchy){margin-left:0 !important}" + a + i + w + ".ML__latex .ML__mfrac:has(.ML__vlist>.ML__center:first-child span[style*=\"height:0.9em\"]) .ML__frac-line{position:relative;top:-0.025em}.ML__latex .ML__mfrac:not(:has(span[style*=\"height:0.9em\"])) .ML__frac-line{position:relative;top:0.04em}" + S + s, E = (e) => {
|
|
48
48
|
if (!e || typeof e.addEventListener != "function") return;
|
|
49
49
|
let t = () => {
|
|
50
50
|
let t = "";
|
|
@@ -116,40 +116,40 @@ function P(e, t) {
|
|
|
116
116
|
latex: r
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
function F(e,
|
|
119
|
+
function F(e, t, i = {}) {
|
|
120
120
|
if (!e || typeof window > "u") return;
|
|
121
|
-
let
|
|
121
|
+
let a = t ?? e.textContent, s = M() || A();
|
|
122
122
|
if (!s) c("applyStaticMath called before MathLive loaded - deferring until it is ready"), j().then((t) => {
|
|
123
|
-
t && e.isConnected !== !1 && F(e,
|
|
123
|
+
t && e.isConnected !== !1 && F(e, a, i);
|
|
124
124
|
});
|
|
125
|
-
else return e.innerHTML = s.convertLatexToMarkup(n(
|
|
125
|
+
else return e.innerHTML = s.convertLatexToMarkup(r(n(a)), { macros: {
|
|
126
126
|
...N(),
|
|
127
127
|
...i.macros || {}
|
|
128
|
-
} }),
|
|
128
|
+
} }), o(e), e;
|
|
129
129
|
}
|
|
130
|
-
function I(e,
|
|
130
|
+
function I(e, t = {}) {
|
|
131
131
|
let i = M() || A();
|
|
132
132
|
if (!i || !e) return "";
|
|
133
133
|
try {
|
|
134
|
-
return i.convertLatexToMarkup(n(
|
|
135
|
-
...
|
|
134
|
+
return i.convertLatexToMarkup(r(n(e)), {
|
|
135
|
+
...t,
|
|
136
136
|
macros: {
|
|
137
137
|
...N(),
|
|
138
|
-
...
|
|
138
|
+
...t.macros || {}
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
141
|
} catch (t) {
|
|
142
142
|
return c("convertLatexToMarkup failed for \"%s\": %s", e, t.message), "";
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
function L(
|
|
145
|
+
function L(e) {
|
|
146
146
|
let r = M();
|
|
147
|
-
if (!r?.convertLatexToMathMl || !
|
|
147
|
+
if (!r?.convertLatexToMathMl || !e) return "";
|
|
148
148
|
try {
|
|
149
|
-
let i = r.convertLatexToMathMl(
|
|
149
|
+
let i = r.convertLatexToMathMl(t(n(e)));
|
|
150
150
|
return i ? `<math xmlns="http://www.w3.org/1998/Math/MathML">${i}</math>` : "";
|
|
151
|
-
} catch (
|
|
152
|
-
return c("convertLatexToMathMl failed for \"%s\": %s",
|
|
151
|
+
} catch (t) {
|
|
152
|
+
return c("convertLatexToMathMl failed for \"%s\": %s", e, t.message), "";
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
function R(e) {
|
package/dist/mf/input.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import p from "
|
|
8
|
-
import m from "
|
|
9
|
-
import {
|
|
10
|
-
import g from "
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { styled as n } from "@mui/material/styles";
|
|
4
|
+
import r from "debug";
|
|
5
|
+
import { applyShadowStyles as i, createMathField as a, loadMathLive as o, trackPlaceholderCaret as s } from "../mathlive-instance.js";
|
|
6
|
+
import { describeMathField as c, labelMathField as l } from "./field-label.js";
|
|
7
|
+
import { KEYSTROKES as u, fromMathLive as d, keyToAction as f, toMathLive as p } from "../latex-bridge.js";
|
|
8
|
+
import { trackWholeAtomSelection as m } from "../selection.js";
|
|
9
|
+
import { trackLongDivision as h } from "../longdiv.js";
|
|
10
|
+
import { keepCaretWhileKeypadFocused as g } from "./inactive-caret.js";
|
|
11
11
|
import { jsx as _ } from "react/jsx-runtime";
|
|
12
12
|
// src/mf/input.tsx
|
|
13
|
-
var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.filter(({ key: e, ifMode: t }) => !(v.has(e) && t !== "latex")), b =
|
|
13
|
+
var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.filter(({ key: e, ifMode: t }) => !(v.has(e) && t !== "latex")), b = r("pie-lib:math-input-mathlive:input"), x = /([0-9])\\ (\\frac\{[^{}]*\}\{(?:\\placeholder\{\})?\})/, S = n("span")({
|
|
14
14
|
display: "inline-block",
|
|
15
15
|
"& math-field": {
|
|
16
16
|
display: "block",
|
|
@@ -18,32 +18,32 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
|
|
|
18
18
|
},
|
|
19
19
|
"& math-field::part(virtual-keyboard-toggle)": { display: "none" },
|
|
20
20
|
"& math-field::part(menu-toggle)": { display: "none" }
|
|
21
|
-
}), C = class extends
|
|
21
|
+
}), C = class extends e.Component {
|
|
22
22
|
static propTypes = {
|
|
23
|
-
className:
|
|
24
|
-
latex:
|
|
25
|
-
onChange:
|
|
26
|
-
onClick:
|
|
27
|
-
onFocus:
|
|
28
|
-
onBlur:
|
|
29
|
-
language:
|
|
30
|
-
ariaDescribedBy:
|
|
31
|
-
readOnly:
|
|
32
|
-
innerRef:
|
|
23
|
+
className: t.string,
|
|
24
|
+
latex: t.string,
|
|
25
|
+
onChange: t.func,
|
|
26
|
+
onClick: t.func,
|
|
27
|
+
onFocus: t.func,
|
|
28
|
+
onBlur: t.func,
|
|
29
|
+
language: t.string,
|
|
30
|
+
ariaDescribedBy: t.string,
|
|
31
|
+
readOnly: t.bool,
|
|
32
|
+
innerRef: t.func
|
|
33
33
|
};
|
|
34
|
-
relabel = () =>
|
|
35
|
-
constructor(
|
|
36
|
-
super(
|
|
34
|
+
relabel = () => l(this.mathField, this.props.language);
|
|
35
|
+
constructor(t) {
|
|
36
|
+
super(t), this.holderRef = e.createRef(), this.lastEmitted = void 0;
|
|
37
37
|
}
|
|
38
38
|
async componentDidMount() {
|
|
39
|
-
let
|
|
40
|
-
|
|
39
|
+
let e = this.mountGeneration = (this.mountGeneration || 0) + 1, t = await o();
|
|
40
|
+
e === this.mountGeneration && t?.MathfieldElement && this.holderRef.current && !this.mathField && (this.mathField = a(t), l(this.mathField, this.props.language, this.relabel), c(this.mathField, this.props.ariaDescribedBy), this.mathField.value = p(this.props.latex || ""), this.lastEmitted = this.props.latex, this.props.readOnly && (this.mathField.readOnly = !0), this.mathField.mathVirtualKeyboardPolicy = "manual", this.mathField.mathModeSpace = "\\ ", this.mathField.smartSuperscript = !1, this.mathField.popoverPolicy = "off", i(this.mathField), this.untrackCaret = s(this.mathField), this.untrackSelection = m(this.mathField), this.untrackLongDivision = h(this.mathField), this.stopKeepingCaret = g(this.mathField), this.mathField.addEventListener("input", this.onInputEdit), this.holderRef.current.replaceChildren(this.mathField), l(this.mathField, this.props.language, this.relabel), this.mathField.keybindings = y(this.mathField.keybindings), this.props.innerRef && this.props.innerRef(this), this.pendingFocus && (this.pendingFocus = !1, this.mathField.focus()));
|
|
41
41
|
}
|
|
42
42
|
componentDidUpdate(e) {
|
|
43
43
|
if (!this.mathField) return;
|
|
44
44
|
let { latex: t, readOnly: n, language: r } = this.props;
|
|
45
|
-
if (r !== e.language &&
|
|
46
|
-
let e =
|
|
45
|
+
if (r !== e.language && l(this.mathField, r, this.relabel), this.props.ariaDescribedBy !== e.ariaDescribedBy && c(this.mathField, this.props.ariaDescribedBy), n !== e.readOnly && (this.mathField.readOnly = !!n), t != null && t !== this.lastEmitted) {
|
|
46
|
+
let e = p(t);
|
|
47
47
|
e !== this.mathField.value && (this.mathField.value = e);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -53,11 +53,11 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
|
|
|
53
53
|
onInputEdit = () => {
|
|
54
54
|
let { onChange: e } = this.props;
|
|
55
55
|
if (!this.mathField) return;
|
|
56
|
-
let t =
|
|
56
|
+
let t = d(this.mathField.getValue("latex"));
|
|
57
57
|
this.lastEmitted = t, e && e(t);
|
|
58
58
|
};
|
|
59
59
|
latex() {
|
|
60
|
-
return this.mathField ?
|
|
60
|
+
return this.mathField ? d(this.mathField.getValue("latex")) : "";
|
|
61
61
|
}
|
|
62
62
|
get element() {
|
|
63
63
|
return this.mathField;
|
|
@@ -71,7 +71,7 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
setLatex(e) {
|
|
74
|
-
this.mathField && (this.mathField.value =
|
|
74
|
+
this.mathField && (this.mathField.value = p(e || ""));
|
|
75
75
|
}
|
|
76
76
|
clear() {
|
|
77
77
|
return this.mathField && (this.mathField.value = "", this.onInputEdit()), "";
|
|
@@ -94,12 +94,12 @@ var v = /* @__PURE__ */ new Set(["[Tab]", "shift+[Tab]"]), y = (e = []) => e.fil
|
|
|
94
94
|
}
|
|
95
95
|
command(e) {
|
|
96
96
|
if (b("command: ", e), !this.mathField) return "";
|
|
97
|
-
let t =
|
|
97
|
+
let t = f({ command: e });
|
|
98
98
|
return t && this.mathField.insert(t.value, { focus: !0 }), this.mathField.focus(), this.latex();
|
|
99
99
|
}
|
|
100
100
|
keystroke(e) {
|
|
101
101
|
if (b("keystroke: ", e), !this.mathField) return "";
|
|
102
|
-
let t =
|
|
102
|
+
let t = u[e] || e;
|
|
103
103
|
try {
|
|
104
104
|
this.mathField.executeCommand(t);
|
|
105
105
|
} catch (t) {
|
package/dist/mf/static.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import T from "
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { styled as n } from "@mui/material/styles";
|
|
4
|
+
import r from "debug";
|
|
5
|
+
import { applyShadowStyles as i, createMathField as a, latexToMarkup as o, latexToMathMl as s, loadMathLive as c, trackPlaceholderCaret as l } from "../mathlive-instance.js";
|
|
6
|
+
import { fixLongDivisionWhenReady as u, trackLongDivision as d } from "../longdiv.js";
|
|
7
|
+
import { keepCaretWhileKeypadFocused as f } from "./inactive-caret.js";
|
|
8
|
+
import { describeMathField as p, labelMathField as m } from "./field-label.js";
|
|
9
|
+
import { KEYSTROKES as h, fieldIds as g, fieldTemplate as _, fieldValues as v, fromMathLive as y, inlineFields as b, keyToAction as x, toMathLive as S } from "../latex-bridge.js";
|
|
10
|
+
import { parallelStyles as C, placeholderStyles as w, rootIndexStyles as T } from "./common-styles.js";
|
|
11
11
|
import { jsx as E } from "react/jsx-runtime";
|
|
12
12
|
// src/mf/static.tsx
|
|
13
|
-
var D =
|
|
13
|
+
var D = r("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", k = n("span")({
|
|
14
14
|
display: "inline-block",
|
|
15
|
-
...
|
|
16
|
-
...
|
|
17
|
-
...
|
|
15
|
+
...w,
|
|
16
|
+
...T,
|
|
17
|
+
...C,
|
|
18
18
|
"& math-field": {
|
|
19
19
|
display: "inline-block",
|
|
20
20
|
border: "none",
|
|
@@ -22,38 +22,38 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
|
|
|
22
22
|
},
|
|
23
23
|
"& math-field::part(virtual-keyboard-toggle)": { display: "none" },
|
|
24
24
|
"& math-field::part(menu-toggle)": { display: "none" }
|
|
25
|
-
}), A = class extends
|
|
25
|
+
}), A = class extends e.Component {
|
|
26
26
|
static propTypes = {
|
|
27
|
-
latex:
|
|
28
|
-
className:
|
|
29
|
-
onFocus:
|
|
30
|
-
onBlur:
|
|
31
|
-
language:
|
|
32
|
-
ariaDescribedBy:
|
|
33
|
-
getFieldName:
|
|
34
|
-
onSubFieldChange:
|
|
35
|
-
onSubFieldFocus:
|
|
36
|
-
setInput:
|
|
27
|
+
latex: t.string.isRequired,
|
|
28
|
+
className: t.string,
|
|
29
|
+
onFocus: t.func,
|
|
30
|
+
onBlur: t.func,
|
|
31
|
+
language: t.string,
|
|
32
|
+
ariaDescribedBy: t.string,
|
|
33
|
+
getFieldName: t.func,
|
|
34
|
+
onSubFieldChange: t.func,
|
|
35
|
+
onSubFieldFocus: t.func,
|
|
36
|
+
setInput: t.func
|
|
37
37
|
};
|
|
38
38
|
static defaultProps = { getFieldName: () => {} };
|
|
39
|
-
relabel = () =>
|
|
40
|
-
constructor(
|
|
41
|
-
super(
|
|
39
|
+
relabel = () => m(this.mathField, this.props.language);
|
|
40
|
+
constructor(t) {
|
|
41
|
+
super(t), this.holderRef = e.createRef(), this.state = { markup: "" }, this.promptValues = {};
|
|
42
42
|
}
|
|
43
43
|
componentDidMount() {
|
|
44
44
|
this.mount();
|
|
45
45
|
}
|
|
46
46
|
async mount() {
|
|
47
|
-
let
|
|
47
|
+
let e = this.mountGeneration = (this.mountGeneration || 0) + 1;
|
|
48
48
|
if (this.interactive = this.isInteractive(), !this.interactive) {
|
|
49
|
-
await
|
|
49
|
+
await c(), e === this.mountGeneration && this.renderMarkup();
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
let
|
|
53
|
-
|
|
52
|
+
let t = await c();
|
|
53
|
+
e === this.mountGeneration && t?.MathfieldElement && this.holderRef.current && !this.mathField && (this.mathField = a(t), m(this.mathField, this.props.language, this.relabel), p(this.mathField, this.props.ariaDescribedBy), this.mathField.readOnly = !0, this.mathField.mathVirtualKeyboardPolicy = "manual", this.mathField.mathModeSpace = "\\ ", this.mathField.smartSuperscript = !1, this.mathField.popoverPolicy = "off", this.mathField.value = S(this.props.latex), i(this.mathField), this.untrackCaret = l(this.mathField), this.untrackLongDivision = d(this.mathField), this.stopKeepingCaret = f(this.mathField), this.mathField.addEventListener("input", this.onPromptInput), this.mathField.addEventListener("pointerdown", this.onPointerDown, !0), this.mathField.addEventListener("focusin", this.onPromptFocus), this.mathField.addEventListener("selection-change", this.onSelectionChange), this.mathField.addEventListener("keydown", this.onKeyDown), this.holderRef.current.replaceChildren(this.mathField), m(this.mathField, this.props.language, this.relabel), this.parkCaret(), this.createLiveRegion());
|
|
54
54
|
}
|
|
55
55
|
componentDidUpdate(e, t) {
|
|
56
|
-
!this.mathField && this.state.markup !== (t && t.markup) &&
|
|
56
|
+
!this.mathField && this.state.markup !== (t && t.markup) && u(this.holderRef.current), this.mathField && e.language !== this.props.language && m(this.mathField, this.props.language, this.relabel), this.mathField && e.ariaDescribedBy !== this.props.ariaDescribedBy && p(this.mathField, this.props.ariaDescribedBy), e.latex !== this.props.latex && (this.isInteractive() === this.interactive ? this.mathField ? _(this.props.latex) === _(e.latex) ? this.syncPrompts() : (this.mathField.value = S(this.props.latex), this.parkCaret()) : this.renderMarkup() : (this.unmountField(), this.setState({ markup: "" }), this.mount()));
|
|
57
57
|
}
|
|
58
58
|
parkCaret() {
|
|
59
59
|
if (!this.mathField || this.mathField.hasFocus?.()) return;
|
|
@@ -61,10 +61,10 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
|
|
|
61
61
|
t && (this.mathField.selection = { ranges: [[t[0], t[0]]] });
|
|
62
62
|
}
|
|
63
63
|
syncPrompts() {
|
|
64
|
-
let e =
|
|
64
|
+
let e = v(this.props.latex);
|
|
65
65
|
Object.keys(e).forEach((t) => {
|
|
66
66
|
let n = e[t];
|
|
67
|
-
n !== this.promptValues[t] && n !==
|
|
67
|
+
n !== this.promptValues[t] && n !== y(this.mathField.getPromptValue(t)) && (this.mathField.setPromptValue(t, S(n), {}), this.promptValues[t] = n);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
componentWillUnmount() {
|
|
@@ -102,21 +102,21 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
|
|
|
102
102
|
};
|
|
103
103
|
isInteractive() {
|
|
104
104
|
let e = this.props.latex || "";
|
|
105
|
-
return
|
|
105
|
+
return g(e).length > 0 || e.indexOf("\\placeholder") !== -1;
|
|
106
106
|
}
|
|
107
107
|
renderMarkup() {
|
|
108
|
-
let e =
|
|
109
|
-
|
|
108
|
+
let e = o(this.props.latex), t = e && s(this.props.latex), n = t ? `<span aria-hidden="true">${e}</span><span style="${O}">${t}</span>` : e;
|
|
109
|
+
n !== this.state.markup && this.setState({ markup: n });
|
|
110
110
|
}
|
|
111
111
|
values() {
|
|
112
112
|
if (!this.mathField) return {};
|
|
113
113
|
let e = {};
|
|
114
114
|
return (this.mathField.getPrompts() || []).forEach((t) => {
|
|
115
|
-
e[t] =
|
|
115
|
+
e[t] = y(this.mathField.getPromptValue(t));
|
|
116
116
|
}), e;
|
|
117
117
|
}
|
|
118
118
|
latex() {
|
|
119
|
-
return this.mathField ?
|
|
119
|
+
return this.mathField ? b(this.props.latex, this.values()) : "";
|
|
120
120
|
}
|
|
121
121
|
selectPrompt(e) {
|
|
122
122
|
this.promptContaining(this.mathField.position) !== e && this.focusPrompt(e);
|
|
@@ -129,12 +129,12 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
|
|
|
129
129
|
id: e,
|
|
130
130
|
write: (e) => t((t) => (Array.isArray(e) ? e : [e]).forEach((e) => t.insert(e, { focus: !0 }))),
|
|
131
131
|
cmd: (e) => t((t) => {
|
|
132
|
-
let n =
|
|
132
|
+
let n = x({ command: e });
|
|
133
133
|
n && t.insert(n.value, { focus: !0 });
|
|
134
134
|
}),
|
|
135
135
|
keystroke: (e) => t((t) => {
|
|
136
136
|
try {
|
|
137
|
-
t.executeCommand(
|
|
137
|
+
t.executeCommand(h[e] || e);
|
|
138
138
|
} catch (t) {
|
|
139
139
|
D("unknown keystroke/selector \"%s\": %s", e, t && t.message);
|
|
140
140
|
}
|
|
@@ -146,7 +146,7 @@ var D = T("pie-lib:math-input-mathlive:static"), O = "position:absolute;width:1p
|
|
|
146
146
|
this.mathField && (this.mathField.focus(), this.selectPrompt(e));
|
|
147
147
|
},
|
|
148
148
|
el: () => this.mathField,
|
|
149
|
-
latex: (t) => this.mathField ? t === void 0 ?
|
|
149
|
+
latex: (t) => this.mathField ? t === void 0 ? y(this.mathField.getPromptValue(e)) : (this.mathField.setPromptValue(e, S(t), {}), t) : ""
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
get innerFields() {
|
package/dist/selection.js
CHANGED
|
@@ -3,7 +3,7 @@ import e from "debug";
|
|
|
3
3
|
var t = e("pie-lib:math-input-mathlive:selection"), n = (e, t, n, r) => {
|
|
4
4
|
let i = (e) => n(e) || {}, a = (e) => i(e).depth || 0, o = (e) => a(e) > 0 && i(e).latex === "";
|
|
5
5
|
if (t < e && ([e, t] = [t, e]), t - e < 1) return [e, t];
|
|
6
|
-
let s =
|
|
6
|
+
let s = 1e400;
|
|
7
7
|
for (let n = e; n <= t; n++) s = Math.min(s, a(n));
|
|
8
8
|
for (let n = e + 1; n <= t; n++) if (a(n) === s && o(n)) {
|
|
9
9
|
--s;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/math-input-mathlive",
|
|
3
|
-
"version": "2.0.4-next.
|
|
3
|
+
"version": "2.0.4-next.20261202142832",
|
|
4
4
|
"description": "MathLive-based math input (drop-in alternative to @pie-lib/math-input)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"debug": "^4.1.1",
|
|
17
17
|
"mathlive": "0.111.4",
|
|
18
18
|
"prop-types": "^15.7.2",
|
|
19
|
-
"@pie-element/shared-lodash": "0.1.7-next.
|
|
20
|
-
"@pie-lib/render-ui": "8.0.11-next.
|
|
21
|
-
"@pie-element/shared-i18n": "0.1.6-next.
|
|
19
|
+
"@pie-element/shared-lodash": "0.1.7-next.20261202142832",
|
|
20
|
+
"@pie-lib/render-ui": "8.0.11-next.20261202142832",
|
|
21
|
+
"@pie-element/shared-i18n": "0.1.6-next.20261202142832"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"main": "./dist/index.js",
|