@pie-element/math-inline 13.0.2-next.20261007003844 → 13.0.2
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/browser/author/index.js +471 -471
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/delivery/index.js +1 -1
- package/dist/browser/{dist-DRuFhF6c.js → dist-JjcMlN8y.js} +5368 -4442
- package/dist/browser/dist-JjcMlN8y.js.map +1 -0
- package/dist/browser/editor-runtime/author/index.js +762 -762
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/delivery/index.js +1 -1
- package/dist/browser/editor-runtime/{dist-DTpumvp_.js → dist-CMbgPo5-.js} +5368 -4442
- package/dist/browser/editor-runtime/dist-CMbgPo5-.js.map +1 -0
- package/dist/browser/editor-runtime/{main-BhJ6__1J.js → main-CSiqPOLM.js} +186 -186
- package/dist/browser/editor-runtime/{main-BhJ6__1J.js.map → main-CSiqPOLM.js.map} +1 -1
- package/dist/browser/editor-runtime/print/index.js +2 -2
- package/dist/browser/{main-CK_AKSba.js → main-CHivxCym.js} +186 -186
- package/dist/browser/{main-CK_AKSba.js.map → main-CHivxCym.js.map} +1 -1
- package/dist/browser/print/index.js +2 -2
- package/dist/delivery/main.js +66 -65
- package/dist/index.iife.js +62 -60
- package/module/print.js +7898 -6972
- package/module/print.js.map +1 -1
- package/package.json +15 -14
- package/dist/browser/dist-DRuFhF6c.js.map +0 -1
- package/dist/browser/editor-runtime/dist-DTpumvp_.js.map +0 -1
package/dist/delivery/main.js
CHANGED
|
@@ -13,14 +13,15 @@ import { styled as w } from "@mui/material/styles";
|
|
|
13
13
|
import T from "@mui/material/Tooltip";
|
|
14
14
|
import { isEmpty as ee, isEqual as E } from "@pie-element/shared-lodash";
|
|
15
15
|
import D from "react-dom";
|
|
16
|
+
import { sanitizeModelHtml as O } from "@pie-element/shared-utils";
|
|
16
17
|
//#region src/delivery/main.tsx
|
|
17
|
-
function
|
|
18
|
+
function k(e) {
|
|
18
19
|
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
return !e ||
|
|
21
|
+
function A(e, t) {
|
|
22
|
+
return !e || k(e) ? e : k(e.default) ? e.default : t && k(e[t]) ? e[t] : t && k(e[t]?.default) ? e[t].default : e;
|
|
22
23
|
}
|
|
23
|
-
var
|
|
24
|
+
var j = A(g, "UiLayout") || A(I.UiLayout, "UiLayout"), M = A(m, "PreviewPrompt") || A(I.PreviewPrompt, "PreviewPrompt"), te = A(h, "Readable") || A(I.Readable, "Readable"), N = A(f, "Collapsible") || A(I.Collapsible, "Collapsible"), ne = A(p, "Feedback") || A(I.Feedback, "Feedback"), P = d, F = P.default, I = F && typeof F == "object" ? F : P, { translator: L } = r, R = !1, z = /\\newline/g, B = /{{response}}/gm, re = 6, V = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
24
25
|
function ie(e = []) {
|
|
25
26
|
return e.map((e) => ({
|
|
26
27
|
name: e,
|
|
@@ -29,7 +30,7 @@ function ie(e = []) {
|
|
|
29
30
|
label: e
|
|
30
31
|
}));
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function H(e, t) {
|
|
33
34
|
let n = e;
|
|
34
35
|
for (; n !== null;) {
|
|
35
36
|
if (t && n === t) return !0;
|
|
@@ -46,27 +47,27 @@ function oe(e, t) {
|
|
|
46
47
|
let e = i;
|
|
47
48
|
if (t.showCorrect) return a && a.length && a[0].answer;
|
|
48
49
|
let n = 1;
|
|
49
|
-
return (e || "").replace(
|
|
50
|
+
return (e || "").replace(B, function() {
|
|
50
51
|
let e = t.session.answers[`r${n}`];
|
|
51
52
|
if (o && !s) {
|
|
52
53
|
let e = "\\ \\ ".repeat(30) + "\\newline ";
|
|
53
54
|
return `\\MathQuillMathField[r${n++}]{${e.repeat(3)}}`;
|
|
54
55
|
}
|
|
55
56
|
return r ? `\\embed{answerBlock}[r${n++}]` : `\\MathQuillMathField[r${n++}]{${e && e.value || ""}}`;
|
|
56
|
-
}).replace(
|
|
57
|
+
}).replace(z, "\\embed{newLine}[]");
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function U(e, t) {
|
|
60
61
|
let n = {};
|
|
61
62
|
if (t.config && t.config.expression) {
|
|
62
63
|
let r = 1;
|
|
63
|
-
(t.config.expression || "").replace(
|
|
64
|
+
(t.config.expression || "").replace(B, () => {
|
|
64
65
|
n[`r${r}`] = { value: e && e.answers && e.answers[`r${r}`] && e.answers[`r${r}`].value || "" }, r += 1;
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
return n;
|
|
68
69
|
}
|
|
69
|
-
var
|
|
70
|
+
var W = class extends n.Component {
|
|
70
71
|
static propTypes = {
|
|
71
72
|
session: i.object.isRequired,
|
|
72
73
|
onSessionChange: i.func,
|
|
@@ -74,7 +75,7 @@ var U = class extends n.Component {
|
|
|
74
75
|
};
|
|
75
76
|
constructor(e) {
|
|
76
77
|
super(e);
|
|
77
|
-
let { model: t, session: r } = e, i =
|
|
78
|
+
let { model: t, session: r } = e, i = U(r, t);
|
|
78
79
|
this.state = {
|
|
79
80
|
session: {
|
|
80
81
|
...e.session,
|
|
@@ -86,8 +87,8 @@ var U = class extends n.Component {
|
|
|
86
87
|
}, this.instructionsIdPrefix = v("math-inline-instructions");
|
|
87
88
|
}
|
|
88
89
|
UNSAFE_componentWillMount() {
|
|
89
|
-
typeof window < "u" && (
|
|
90
|
-
let t =
|
|
90
|
+
typeof window < "u" && (R ||= (l("answerBlock", (e) => {
|
|
91
|
+
let t = G();
|
|
91
92
|
return {
|
|
92
93
|
htmlString: `<div class="${t.blockContainer}">
|
|
93
94
|
<div class="${t.blockResponse}" data-answer-block-index="${e}">R</div>
|
|
@@ -118,13 +119,13 @@ var U = class extends n.Component {
|
|
|
118
119
|
let { config: t } = this.props.model, { config: n = {} } = e.model || {}, { session: r } = this.props, { session: i = {} } = e || {};
|
|
119
120
|
if (r && i && !E(r.answers, i.answers) && this.setState({ session: {
|
|
120
121
|
...i,
|
|
121
|
-
answers:
|
|
122
|
-
} }), t.note && t.language && t.language !== n.language && t.note ===
|
|
122
|
+
answers: U(i, this.props.model)
|
|
123
|
+
} }), t.note && t.language && t.language !== n.language && t.note === L.t("mathInline.primaryCorrectWithAlternates", { lng: t.language }) && (t.note = L.t("mathInline.primaryCorrectWithAlternates", { lng: n.language })), (t.env && t.env.mode !== "evaluate" || n.env && n.env.mode !== "evaluate") && this.setState({
|
|
123
124
|
...this.state.session,
|
|
124
125
|
showCorrect: !1
|
|
125
126
|
}), n.alwaysShowCorrect && this.setState({ showCorrect: !0 }), this.countResponseOccurrences(t.expression) < this.countResponseOccurrences(n.expression) && setTimeout(() => this.updateAria(), 100), t && t.responses && t.responses.length !== n.responses.length || !t && n && n.responses || t && n && t.expression !== n.expression) {
|
|
126
127
|
let e = {}, t = this.state.session.answers, r = 1;
|
|
127
|
-
(n.expression || "").replace(
|
|
128
|
+
(n.expression || "").replace(B, () => {
|
|
128
129
|
e[`r${r}`] = { value: t && t[`r${r}`] && t[`r${r}`].value || "" }, r++;
|
|
129
130
|
}), this.setState((t) => ({ session: {
|
|
130
131
|
...t.session,
|
|
@@ -146,7 +147,7 @@ var U = class extends n.Component {
|
|
|
146
147
|
updateAria = () => {
|
|
147
148
|
if (this.root) {
|
|
148
149
|
this.root.querySelectorAll(".mq-selectable").forEach((e) => e.setAttribute("aria-hidden", "true"));
|
|
149
|
-
let e =
|
|
150
|
+
let e = L.t("mathInline.keypadInstructions", { lng: this.props.model?.language });
|
|
150
151
|
this.root.querySelectorAll("textarea").forEach((t, n) => {
|
|
151
152
|
let r = `${this.instructionsIdPrefix}-${n}`, i = t.closest(".mq-textarea");
|
|
152
153
|
if (i) {
|
|
@@ -166,7 +167,7 @@ var U = class extends n.Component {
|
|
|
166
167
|
}, 0);
|
|
167
168
|
};
|
|
168
169
|
handleKeyDown = (e, t) => {
|
|
169
|
-
let n =
|
|
170
|
+
let n = H(e.target, this.root), r = this.mqStatic && this.mqStatic.inputRef?.current ? this.mqStatic.inputRef?.current.contains(document.activeElement) : !!document.activeElement?.closest(".mq-editable-field"), { key: i, type: a } = e;
|
|
170
171
|
r && (i === "ArrowDown" || a === "click" || a === "touchstart") ? this.state.activeAnswerBlock !== t && n && (this.cleanupKeyDownListener(), this.setState({ activeAnswerBlock: t }, () => {
|
|
171
172
|
this.onSubFieldFocus(t), i === "ArrowDown" && this.focusFirstKeypadElement();
|
|
172
173
|
})) : e.key === "Escape" && this.setState({ activeAnswerBlock: "" });
|
|
@@ -259,7 +260,7 @@ var U = class extends n.Component {
|
|
|
259
260
|
};
|
|
260
261
|
setTooltipRef(e) {
|
|
261
262
|
setTimeout(() => {
|
|
262
|
-
if (e &&
|
|
263
|
+
if (e && V) {
|
|
263
264
|
let e = document.querySelector("[role='tooltip']");
|
|
264
265
|
e && e.firstChild.setAttribute("tabindex", "-1");
|
|
265
266
|
}
|
|
@@ -268,45 +269,45 @@ var U = class extends n.Component {
|
|
|
268
269
|
render() {
|
|
269
270
|
let { model: n } = this.props, { activeAnswerBlock: r, showCorrect: i, session: a, tooltipContainerRef: s } = this.state, { config: l, correctness: u, disabled: d, extraCSSRules: f, view: p, teacherInstructions: m, rationale: h, feedback: g, animationsDisabled: v, printMode: C, alwaysShowCorrect: w, language: E } = n || {};
|
|
270
271
|
if (!l) return null;
|
|
271
|
-
let { showNote:
|
|
272
|
+
let { showNote: k, note: A, prompt: j, responses: P, responseType: F, equationEditor: I, customKeys: R, env: { mode: z, role: B } = {} } = l || {}, V = (i || z === "view" && B === "instructor") && k && A, H = ee(P), U = !H && u && u.correctness !== "correct", W = d && u, G = ie(R), Y = u && u.correct, X = oe(n, this.state) || "", Z = d && !u, ge = C && !w, Q = h && (b(h) || y(h)), $ = m && (b(m) || y(m)), _e = /* @__PURE__ */ x(pe, { children: /* @__PURE__ */ x(c.Static, {
|
|
272
273
|
className: "static-math",
|
|
273
274
|
ref: (e) => {
|
|
274
275
|
e && (this.mqStatic = e);
|
|
275
276
|
},
|
|
276
|
-
latex:
|
|
277
|
+
latex: X,
|
|
277
278
|
language: E,
|
|
278
279
|
onSubFieldChange: this.subFieldChanged,
|
|
279
280
|
getFieldName: this.getFieldName,
|
|
280
281
|
setInput: this.setInput,
|
|
281
282
|
onSubFieldFocus: this.onSubFieldFocus,
|
|
282
283
|
onBlur: this.onBlur
|
|
283
|
-
}) }),
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
}) }), ve = /* @__PURE__ */ S(q, { children: [
|
|
285
|
+
z === "gather" && /* @__PURE__ */ x(me, { children: L.t("mathInline.mathEquationResponseQuestion", { lng: E }) }),
|
|
286
|
+
Z && $ && (v ? /* @__PURE__ */ x("div", { dangerouslySetInnerHTML: { __html: O(m) } }) : /* @__PURE__ */ x(J, {
|
|
286
287
|
labels: {
|
|
287
|
-
hidden:
|
|
288
|
-
visible:
|
|
288
|
+
hidden: L.t("common:showTeacherInstructions", { lng: E }),
|
|
289
|
+
visible: L.t("common:hideTeacherInstructions", { lng: E })
|
|
289
290
|
},
|
|
290
|
-
children: /* @__PURE__ */ x("div", { dangerouslySetInnerHTML: { __html: m } })
|
|
291
|
+
children: /* @__PURE__ */ x("div", { dangerouslySetInnerHTML: { __html: O(m) } })
|
|
291
292
|
})),
|
|
292
|
-
|
|
293
|
+
j && /* @__PURE__ */ x(ce, { children: /* @__PURE__ */ x(M, { prompt: j }) }),
|
|
293
294
|
ge ? _e : /* @__PURE__ */ x(te, {
|
|
294
295
|
false: !0,
|
|
295
296
|
children: /* @__PURE__ */ S(fe, {
|
|
296
297
|
tabIndex: 0,
|
|
297
|
-
children: [
|
|
298
|
+
children: [F === e.simple && /* @__PURE__ */ x(t, {
|
|
298
299
|
onSimpleResponseChange: this.onSimpleResponseChange,
|
|
299
300
|
showCorrect: i,
|
|
300
|
-
emptyResponse:
|
|
301
|
+
emptyResponse: H,
|
|
301
302
|
model: n,
|
|
302
303
|
session: a,
|
|
303
304
|
onSubFieldFocus: this.onSubFieldFocus,
|
|
304
305
|
showKeypad: !!r
|
|
305
|
-
}),
|
|
306
|
+
}), F === e.advanced && /* @__PURE__ */ x(de, {
|
|
306
307
|
ref: s,
|
|
307
|
-
isIncorrect: !
|
|
308
|
-
isCorrect: !
|
|
309
|
-
showCorrectness: !
|
|
308
|
+
isIncorrect: !H && !Y && !i,
|
|
309
|
+
isCorrect: !H && (Y || i),
|
|
310
|
+
showCorrectness: !H && d && u && !p,
|
|
310
311
|
correctAnswerShown: i,
|
|
311
312
|
printCorrect: C && w,
|
|
312
313
|
children: /* @__PURE__ */ x(T, {
|
|
@@ -361,10 +362,10 @@ var U = class extends n.Component {
|
|
|
361
362
|
},
|
|
362
363
|
title: Object.keys(a.answers).map((e) => e === r && !(i || d) && /* @__PURE__ */ x(ue, {
|
|
363
364
|
"data-keypad": !0,
|
|
364
|
-
style: { width: ae(
|
|
365
|
+
style: { width: ae(G, I) },
|
|
365
366
|
children: /* @__PURE__ */ x(o, {
|
|
366
|
-
additionalKeys:
|
|
367
|
-
mode:
|
|
367
|
+
additionalKeys: G,
|
|
368
|
+
mode: I || re,
|
|
368
369
|
onClick: this.onClick
|
|
369
370
|
})
|
|
370
371
|
}, e) || null),
|
|
@@ -373,7 +374,7 @@ var U = class extends n.Component {
|
|
|
373
374
|
ref: (e) => {
|
|
374
375
|
e && (this.mqStatic = e);
|
|
375
376
|
},
|
|
376
|
-
latex:
|
|
377
|
+
latex: X,
|
|
377
378
|
language: E,
|
|
378
379
|
onSubFieldChange: this.subFieldChanged,
|
|
379
380
|
getFieldName: this.getFieldName,
|
|
@@ -385,16 +386,16 @@ var U = class extends n.Component {
|
|
|
385
386
|
})]
|
|
386
387
|
})
|
|
387
388
|
}),
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
Z && V && /* @__PURE__ */ x(le, { dangerouslySetInnerHTML: { __html: `<strong>Note:</strong> ${O(A)}` } }),
|
|
390
|
+
Z && Q && (v ? /* @__PURE__ */ x("div", { dangerouslySetInnerHTML: { __html: O(h) } }) : /* @__PURE__ */ x(N, {
|
|
390
391
|
labels: {
|
|
391
|
-
hidden:
|
|
392
|
-
visible:
|
|
392
|
+
hidden: L.t("common:showRationale", { lng: E }),
|
|
393
|
+
visible: L.t("common:hideRationale", { lng: E })
|
|
393
394
|
},
|
|
394
|
-
children: /* @__PURE__ */ x("div", { dangerouslySetInnerHTML: { __html: h } })
|
|
395
|
+
children: /* @__PURE__ */ x("div", { dangerouslySetInnerHTML: { __html: O(h) } })
|
|
395
396
|
}))
|
|
396
397
|
] });
|
|
397
|
-
return
|
|
398
|
+
return W && (U || $ || Q || g) ? /* @__PURE__ */ x(K, {
|
|
398
399
|
extraCSSRules: f,
|
|
399
400
|
ref: (e) => {
|
|
400
401
|
let t = D.findDOMNode(e);
|
|
@@ -422,50 +423,50 @@ var U = class extends n.Component {
|
|
|
422
423
|
}
|
|
423
424
|
},
|
|
424
425
|
title: /* @__PURE__ */ S("div", { children: [
|
|
425
|
-
/* @__PURE__ */ x(
|
|
426
|
+
/* @__PURE__ */ x(q, { children: U && /* @__PURE__ */ x(he, {
|
|
426
427
|
language: E,
|
|
427
428
|
show: !0,
|
|
428
429
|
toggled: i,
|
|
429
430
|
onToggle: this.toggleShowCorrect
|
|
430
431
|
}) }),
|
|
431
|
-
|
|
432
|
+
$ && /* @__PURE__ */ x(J, {
|
|
432
433
|
labels: {
|
|
433
|
-
hidden:
|
|
434
|
-
visible:
|
|
434
|
+
hidden: L.t("common:showTeacherInstructions", { lng: E }),
|
|
435
|
+
visible: L.t("common:hideTeacherInstructions", { lng: E })
|
|
435
436
|
},
|
|
436
|
-
children: /* @__PURE__ */ x(
|
|
437
|
+
children: /* @__PURE__ */ x(M, { prompt: m })
|
|
437
438
|
}, "collapsible-teacher-instructions"),
|
|
438
|
-
|
|
439
|
+
V && b(A) && /* @__PURE__ */ x(J, {
|
|
439
440
|
labels: {
|
|
440
|
-
hidden:
|
|
441
|
-
visible:
|
|
441
|
+
hidden: L.t("common:showNote", { lng: E }),
|
|
442
|
+
visible: L.t("common:hideNote", { lng: E })
|
|
442
443
|
},
|
|
443
|
-
children: /* @__PURE__ */ x(
|
|
444
|
+
children: /* @__PURE__ */ x(M, { prompt: A })
|
|
444
445
|
}, "collapsible-note"),
|
|
445
|
-
|
|
446
|
+
Q && /* @__PURE__ */ x(J, {
|
|
446
447
|
labels: {
|
|
447
|
-
hidden:
|
|
448
|
-
visible:
|
|
448
|
+
hidden: L.t("common:showRationale", { lng: E }),
|
|
449
|
+
visible: L.t("common:hideRationale", { lng: E })
|
|
449
450
|
},
|
|
450
|
-
children: /* @__PURE__ */ x(
|
|
451
|
+
children: /* @__PURE__ */ x(M, { prompt: h })
|
|
451
452
|
}, "collapsible-rationale"),
|
|
452
453
|
g && /* @__PURE__ */ x(ne, {
|
|
453
454
|
correctness: u.correctness,
|
|
454
455
|
feedback: g
|
|
455
456
|
})
|
|
456
457
|
] }),
|
|
457
|
-
children:
|
|
458
|
+
children: ve
|
|
458
459
|
})
|
|
459
|
-
}) : /* @__PURE__ */ x(
|
|
460
|
+
}) : /* @__PURE__ */ x(K, {
|
|
460
461
|
extraCSSRules: f,
|
|
461
462
|
ref: (e) => {
|
|
462
463
|
let t = D.findDOMNode(e);
|
|
463
464
|
this.root = t || this.root;
|
|
464
465
|
},
|
|
465
|
-
children:
|
|
466
|
+
children: ve
|
|
466
467
|
});
|
|
467
468
|
}
|
|
468
|
-
},
|
|
469
|
+
}, G = () => ({
|
|
469
470
|
blockContainer: "block-container",
|
|
470
471
|
blockResponse: "block-response",
|
|
471
472
|
blockMath: "block-math"
|
|
@@ -519,16 +520,16 @@ if (typeof document < "u") {
|
|
|
519
520
|
`, document.head.appendChild(t);
|
|
520
521
|
}
|
|
521
522
|
}
|
|
522
|
-
var
|
|
523
|
+
var K = w(j)(() => ({
|
|
523
524
|
color: _.text(),
|
|
524
525
|
backgroundColor: _.background(),
|
|
525
526
|
display: "inline-block"
|
|
526
|
-
})), se = w(T)({}), ce = w("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })),
|
|
527
|
+
})), se = w(T)({}), ce = w("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), q = w("div")({
|
|
527
528
|
width: "100%",
|
|
528
529
|
position: "relative",
|
|
529
530
|
backgroundColor: _.background(),
|
|
530
531
|
color: _.text()
|
|
531
|
-
}), le = w("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })),
|
|
532
|
+
}), le = w("div")(({ theme: e }) => ({ paddingBottom: e.spacing(2) })), J = w(N)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), ue = w("div")(({ theme: e }) => ({
|
|
532
533
|
zIndex: 10,
|
|
533
534
|
minWidth: "400px",
|
|
534
535
|
marginTop: e.spacing(2)
|
|
@@ -607,4 +608,4 @@ var G = w(A)(() => ({
|
|
|
607
608
|
marginBottom: e.spacing(2)
|
|
608
609
|
}));
|
|
609
610
|
//#endregion
|
|
610
|
-
export {
|
|
611
|
+
export { W as Main, W as default };
|