@pie-element/drag-in-the-blank 10.1.2-next.2 → 10.1.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/CHANGELOG.json +1042 -0
- package/CHANGELOG.md +2183 -0
- package/LICENSE.md +5 -0
- package/README.md +1 -0
- package/configure/CHANGELOG.json +652 -0
- package/configure/CHANGELOG.md +1883 -0
- package/configure/lib/choice.js +137 -0
- package/configure/lib/choice.js.map +1 -0
- package/configure/lib/choices.js +319 -0
- package/configure/lib/choices.js.map +1 -0
- package/configure/lib/defaults.js +169 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +144 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +440 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/markupUtils.js +83 -0
- package/configure/lib/markupUtils.js.map +1 -0
- package/configure/package.json +25 -0
- package/configure/utils.js +17 -0
- package/controller/CHANGELOG.json +457 -0
- package/controller/CHANGELOG.md +1284 -0
- package/controller/lib/defaults.js +24 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +251 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +39 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +16 -0
- package/docs/config-schema.json +2580 -0
- package/docs/config-schema.json.md +1905 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +41 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +10 -0
- package/docs/pie-schema.json +1181 -0
- package/docs/pie-schema.json.md +853 -0
- package/lib/index.js +206 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +126 -0
- package/lib/main.js.map +1 -0
- package/package.json +22 -87
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/choice.d.ts +0 -22
- package/dist/author/choice.js +0 -88
- package/dist/author/choices.d.ts +0 -41
- package/dist/author/choices.js +0 -172
- package/dist/author/defaults.d.ts +0 -171
- package/dist/author/defaults.js +0 -123
- package/dist/author/index.d.ts +0 -42
- package/dist/author/index.js +0 -92
- package/dist/author/main.d.ts +0 -36
- package/dist/author/main.js +0 -301
- package/dist/author/markupUtils.d.ts +0 -17
- package/dist/author/markupUtils.js +0 -38
- package/dist/author/utils.d.ts +0 -9
- package/dist/author/utils.js +0 -7
- package/dist/browser/author/index.js +0 -39603
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -176
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -3414
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-BkH5WSi5.js +0 -121
- package/dist/browser/dist-BkH5WSi5.js.map +0 -1
- package/dist/browser/drag-in-the-blank.css +0 -2
- package/dist/browser/drag-provider-D0fyq5lq.js +0 -10946
- package/dist/browser/drag-provider-D0fyq5lq.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -26
- package/dist/controller/defaults.js +0 -20
- package/dist/controller/index.d.ts +0 -41
- package/dist/controller/index.js +0 -104
- package/dist/controller/utils.d.ts +0 -16
- package/dist/controller/utils.js +0 -14
- package/dist/delivery/index.d.ts +0 -21
- package/dist/delivery/index.js +0 -105
- package/dist/delivery/main.d.ts +0 -28
- package/dist/delivery/main.js +0 -83
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -152
- package/dist/index.js +0 -2
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
package/dist/author/main.js
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { createSlateMarkup as e } from "./markupUtils.js";
|
|
2
|
-
import t from "./choice.js";
|
|
3
|
-
import n from "./choices.js";
|
|
4
|
-
import { generateValidationMessage as r } from "./utils.js";
|
|
5
|
-
import i from "react";
|
|
6
|
-
import { renderMath as a } from "@pie-element/shared-math-rendering-mathjax";
|
|
7
|
-
import * as o from "@pie-lib/render-ui";
|
|
8
|
-
import { InputContainer as s } from "@pie-lib/render-ui";
|
|
9
|
-
import c from "prop-types";
|
|
10
|
-
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
11
|
-
import { styled as d } from "@mui/material/styles";
|
|
12
|
-
import f, { ALL_PLUGINS as ee } from "@pie-lib/editable-html-tip-tap";
|
|
13
|
-
import { layout as te, settings as p } from "@pie-lib/config-ui";
|
|
14
|
-
import { DragProvider as m } from "@pie-lib/drag";
|
|
15
|
-
import h from "@mui/material/Typography";
|
|
16
|
-
import ne from "@mui/icons-material/Info";
|
|
17
|
-
import g from "@mui/material/Tooltip";
|
|
18
|
-
import { DragOverlay as re } from "@dnd-kit/core";
|
|
19
|
-
//#region src/author/main.tsx
|
|
20
|
-
function _(e) {
|
|
21
|
-
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
22
|
-
}
|
|
23
|
-
function v(e, t) {
|
|
24
|
-
return !e || _(e) ? e : _(e.default) ? e.default : t && _(e[t]) ? e[t] : t && _(e[t]?.default) ? e[t].default : e;
|
|
25
|
-
}
|
|
26
|
-
var y = v(s, "InputContainer") || v(S.InputContainer, "InputContainer"), b = o, x = b.default, S = x && typeof x == "object" ? x : b, ie = class extends i.Component {
|
|
27
|
-
containerRef = i.createRef();
|
|
28
|
-
componentDidMount() {
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
this.containerRef.current && a(this.containerRef.current);
|
|
31
|
-
}, 0);
|
|
32
|
-
}
|
|
33
|
-
componentDidUpdate() {
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
this.containerRef.current && a(this.containerRef.current);
|
|
36
|
-
}, 0);
|
|
37
|
-
}
|
|
38
|
-
render() {
|
|
39
|
-
return /* @__PURE__ */ l("div", {
|
|
40
|
-
ref: this.containerRef,
|
|
41
|
-
children: this.props.children
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}, { dropdown: C, toggle: w, Panel: T } = p, E = d(y)(({ theme: e }) => ({
|
|
45
|
-
width: "100%",
|
|
46
|
-
paddingTop: e.spacing(2),
|
|
47
|
-
marginBottom: e.spacing(2)
|
|
48
|
-
})), D = d("div")(({ theme: e }) => ({
|
|
49
|
-
minHeight: "235px",
|
|
50
|
-
paddingTop: e.spacing(1),
|
|
51
|
-
paddingBottom: e.spacing(2),
|
|
52
|
-
width: "100%",
|
|
53
|
-
"& [data-slate-editor=\"true\"]": { minHeight: "235px" }
|
|
54
|
-
})), ae = d(h)(({ theme: e }) => ({ fontSize: e.typography.fontSize + 2 })), oe = d(g)(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
|
|
55
|
-
fontSize: e.typography.fontSize - 2,
|
|
56
|
-
whiteSpace: "pre",
|
|
57
|
-
maxWidth: "500px"
|
|
58
|
-
} })), O = d("div")(({ theme: e }) => ({
|
|
59
|
-
fontSize: e.typography.fontSize - 2,
|
|
60
|
-
color: e.palette.error.main,
|
|
61
|
-
paddingTop: e.spacing(1)
|
|
62
|
-
})), k = d("div")({
|
|
63
|
-
display: "flex",
|
|
64
|
-
alignItems: "center"
|
|
65
|
-
}), A = class extends i.Component {
|
|
66
|
-
static propTypes = {
|
|
67
|
-
configuration: c.object.isRequired,
|
|
68
|
-
model: c.object.isRequired,
|
|
69
|
-
disableSidePanel: c.bool,
|
|
70
|
-
onModelChanged: c.func.isRequired,
|
|
71
|
-
onConfigurationChanged: c.func.isRequired,
|
|
72
|
-
imageSupport: c.shape({
|
|
73
|
-
add: c.func.isRequired,
|
|
74
|
-
delete: c.func.isRequired
|
|
75
|
-
}),
|
|
76
|
-
uploadSoundSupport: c.object
|
|
77
|
-
};
|
|
78
|
-
state = { activeDragItem: null };
|
|
79
|
-
constructor(e) {
|
|
80
|
-
super(e), this.markupRef = i.createRef();
|
|
81
|
-
}
|
|
82
|
-
onModelChange = (e) => {
|
|
83
|
-
this.props.onModelChanged({
|
|
84
|
-
...this.props.model,
|
|
85
|
-
...e
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
onPromptChanged = (e) => {
|
|
89
|
-
this.props.onModelChanged({
|
|
90
|
-
...this.props.model,
|
|
91
|
-
prompt: e
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
onRationaleChanged = (e) => {
|
|
95
|
-
this.props.onModelChanged({
|
|
96
|
-
...this.props.model,
|
|
97
|
-
rationale: e
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
onTeacherInstructionsChanged = (e) => {
|
|
101
|
-
this.props.onModelChanged({
|
|
102
|
-
...this.props.model,
|
|
103
|
-
teacherInstructions: e
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
onMarkupChanged = (e) => {
|
|
107
|
-
this.props.onModelChanged({
|
|
108
|
-
...this.props.model,
|
|
109
|
-
slateMarkup: e
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
onResponsesChanged = (t) => {
|
|
113
|
-
let { model: { correctResponse: n, markup: r } } = this.props, i = e(r, t, n);
|
|
114
|
-
this.props.onModelChanged({
|
|
115
|
-
...this.props.model,
|
|
116
|
-
slateMarkup: i,
|
|
117
|
-
choices: t
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
render() {
|
|
121
|
-
let { model: e, configuration: i, onConfigurationChanged: a, imageSupport: o, uploadSoundSupport: s } = this.props, { addChoice: c = {}, baseInputConfiguration: d = {}, contentDimensions: p = {}, duplicates: h = {}, prompt: g = {}, partialScoring: _ = {}, lockChoiceOrder: v = {}, rationale: y = {}, teacherInstructions: b = {}, choicesPosition: x = {}, spellCheck: S = {}, settingsPanelDisabled: A, maxChoices: se, maxResponseAreas: ce, maxImageWidth: j = {}, maxImageHeight: M = {}, withRubric: N = {}, mathMlOptions: P = {}, language: F = {}, languageChoices: I = {}, maxLength: L = {} } = i || {}, { rationaleEnabled: R, promptEnabled: z, teacherInstructionsEnabled: B, spellCheckEnabled: V, toolbarEditorPosition: H, errors: U, extraCSSRules: W } = e || {}, { choicesError: le, correctResponseError: G, prompt: K, rationale: q, responseAreasError: J, teacherInstructions: Y } = U || {}, ue = r(i), X = j && j.prompt, Z = M && M.prompt, Q = { position: H === "top" ? "top" : "bottom" }, de = {
|
|
122
|
-
partialScoring: _.settings && w(_.label),
|
|
123
|
-
duplicates: h.settings && w(h.label),
|
|
124
|
-
lockChoiceOrder: v.settings && w(v.label),
|
|
125
|
-
choicesPosition: x.settings && C(x.label, [
|
|
126
|
-
"above",
|
|
127
|
-
"below",
|
|
128
|
-
"left",
|
|
129
|
-
"right"
|
|
130
|
-
]),
|
|
131
|
-
"language.enabled": F.settings && w(F.label, !0),
|
|
132
|
-
language: F.settings && F.enabled && C(I.label, I.options)
|
|
133
|
-
}, fe = {
|
|
134
|
-
teacherInstructionsEnabled: b.settings && w(b.label),
|
|
135
|
-
rationaleEnabled: y.settings && w(y.label),
|
|
136
|
-
spellCheckEnabled: S.settings && w(S.label),
|
|
137
|
-
promptEnabled: g.settings && w(g.label),
|
|
138
|
-
rubricEnabled: N?.settings && w(N?.label)
|
|
139
|
-
}, $ = (e) => Object.assign({ ...d }, e || {});
|
|
140
|
-
return /* @__PURE__ */ u(m, {
|
|
141
|
-
onDragEnd: ({ active: e, over: t }) => {
|
|
142
|
-
if (e && !t) {
|
|
143
|
-
let t = e.data.current;
|
|
144
|
-
if (t && t.type === "drag-in-the-blank-placed-choice" && this.markupRef.current) {
|
|
145
|
-
let n = this.markupRef.current.getBoundingClientRect(), r = e.rect.current.translated?.x || 0, i = e.rect.current.translated?.y || 0;
|
|
146
|
-
(r < n.left || r > n.right || i < n.top || i > n.bottom) && t.onRemove && typeof t.onRemove == "function" && t.onRemove(t);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (!e || !t) {
|
|
150
|
-
this.setState({ activeDragItem: null });
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
let n = e.data.current, r = t.data.current;
|
|
154
|
-
if (r && typeof r.onDrop == "function") {
|
|
155
|
-
r.onDrop(n, r);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
n && typeof n.onDrop == "function" && n.onDrop(n, r), this.setState({ activeDragItem: null });
|
|
159
|
-
},
|
|
160
|
-
onDragStart: (e) => {
|
|
161
|
-
let { active: t } = e;
|
|
162
|
-
t?.data?.current && this.setState({ activeDragItem: t.data.current });
|
|
163
|
-
},
|
|
164
|
-
children: [/* @__PURE__ */ u(te.ConfigLayout, {
|
|
165
|
-
extraCSSRules: W,
|
|
166
|
-
dimensions: p,
|
|
167
|
-
hideSettings: A,
|
|
168
|
-
settings: /* @__PURE__ */ l(T, {
|
|
169
|
-
model: e,
|
|
170
|
-
configuration: i,
|
|
171
|
-
onChangeModel: (e) => this.onModelChange(e),
|
|
172
|
-
onChangeConfiguration: (e) => a(e, !0),
|
|
173
|
-
groups: {
|
|
174
|
-
Settings: de,
|
|
175
|
-
Properties: fe
|
|
176
|
-
}
|
|
177
|
-
}),
|
|
178
|
-
children: [
|
|
179
|
-
B && /* @__PURE__ */ u(E, {
|
|
180
|
-
label: b.label,
|
|
181
|
-
children: [/* @__PURE__ */ l(f, {
|
|
182
|
-
markup: e.teacherInstructions || "",
|
|
183
|
-
onChange: this.onTeacherInstructionsChanged,
|
|
184
|
-
imageSupport: o,
|
|
185
|
-
nonEmpty: !1,
|
|
186
|
-
error: Y,
|
|
187
|
-
toolbarOpts: Q,
|
|
188
|
-
pluginProps: $(b?.inputConfiguration),
|
|
189
|
-
spellCheck: V,
|
|
190
|
-
maxImageWidth: j && j.teacherInstructions || X,
|
|
191
|
-
maxImageHeight: M && M.teacherInstructions || Z,
|
|
192
|
-
uploadSoundSupport: s,
|
|
193
|
-
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
194
|
-
mathMlOptions: P
|
|
195
|
-
}), Y && /* @__PURE__ */ l(O, { children: Y })]
|
|
196
|
-
}),
|
|
197
|
-
z && /* @__PURE__ */ u(E, {
|
|
198
|
-
label: g.label,
|
|
199
|
-
children: [/* @__PURE__ */ l(f, {
|
|
200
|
-
markup: e.prompt,
|
|
201
|
-
onChange: this.onPromptChanged,
|
|
202
|
-
imageSupport: o,
|
|
203
|
-
nonEmpty: !1,
|
|
204
|
-
disableUnderline: !0,
|
|
205
|
-
error: K,
|
|
206
|
-
toolbarOpts: Q,
|
|
207
|
-
pluginProps: $(g?.inputConfiguration),
|
|
208
|
-
spellCheck: V,
|
|
209
|
-
maxImageWidth: X,
|
|
210
|
-
maxImageHeight: Z,
|
|
211
|
-
uploadSoundSupport: s,
|
|
212
|
-
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
213
|
-
mathMlOptions: P
|
|
214
|
-
}), K && /* @__PURE__ */ l(O, { children: K })]
|
|
215
|
-
}),
|
|
216
|
-
/* @__PURE__ */ u(k, { children: [/* @__PURE__ */ l(ae, {
|
|
217
|
-
component: "div",
|
|
218
|
-
children: "Define Template, Choices, and Correct Responses"
|
|
219
|
-
}), /* @__PURE__ */ l(oe, {
|
|
220
|
-
disableFocusListener: !0,
|
|
221
|
-
disableTouchListener: !0,
|
|
222
|
-
placement: "right",
|
|
223
|
-
title: ue,
|
|
224
|
-
children: /* @__PURE__ */ l(ne, {
|
|
225
|
-
fontSize: "small",
|
|
226
|
-
color: "primary",
|
|
227
|
-
style: { marginLeft: "5px" }
|
|
228
|
-
})
|
|
229
|
-
})] }),
|
|
230
|
-
/* @__PURE__ */ l(D, {
|
|
231
|
-
ref: this.markupRef,
|
|
232
|
-
children: /* @__PURE__ */ l(f, {
|
|
233
|
-
activePlugins: ee,
|
|
234
|
-
responseAreaProps: {
|
|
235
|
-
type: "drag-in-the-blank",
|
|
236
|
-
options: { duplicates: e.duplicates },
|
|
237
|
-
maxResponseAreas: ce
|
|
238
|
-
},
|
|
239
|
-
pluginProps: $(),
|
|
240
|
-
markup: e.slateMarkup,
|
|
241
|
-
onChange: this.onMarkupChanged,
|
|
242
|
-
imageSupport: o,
|
|
243
|
-
disableImageAlignmentButtons: !0,
|
|
244
|
-
nonEmpty: !1,
|
|
245
|
-
disableUnderline: !0,
|
|
246
|
-
error: J || G,
|
|
247
|
-
toolbarOpts: Q,
|
|
248
|
-
spellCheck: V,
|
|
249
|
-
uploadSoundSupport: s,
|
|
250
|
-
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
251
|
-
mathMlOptions: P
|
|
252
|
-
})
|
|
253
|
-
}),
|
|
254
|
-
J && /* @__PURE__ */ l(O, { children: J }),
|
|
255
|
-
G && /* @__PURE__ */ l(O, { children: G }),
|
|
256
|
-
/* @__PURE__ */ l(n, {
|
|
257
|
-
model: e,
|
|
258
|
-
imageSupport: o,
|
|
259
|
-
duplicates: e.duplicates,
|
|
260
|
-
error: le,
|
|
261
|
-
onChange: this.onResponsesChanged,
|
|
262
|
-
toolbarOpts: Q,
|
|
263
|
-
maxChoices: se,
|
|
264
|
-
uploadSoundSupport: s,
|
|
265
|
-
mathMlOptions: P,
|
|
266
|
-
pluginProps: $(c?.inputConfiguration),
|
|
267
|
-
maxImageWidth: j && j.choice || X,
|
|
268
|
-
maxImageHeight: M && M.choice || Z,
|
|
269
|
-
maxLength: L
|
|
270
|
-
}),
|
|
271
|
-
R && /* @__PURE__ */ u(E, {
|
|
272
|
-
label: y.label,
|
|
273
|
-
children: [/* @__PURE__ */ l(f, {
|
|
274
|
-
markup: e.rationale || "",
|
|
275
|
-
onChange: this.onRationaleChanged,
|
|
276
|
-
imageSupport: o,
|
|
277
|
-
error: q,
|
|
278
|
-
toolbarOpts: Q,
|
|
279
|
-
pluginProps: $(y?.inputConfiguration),
|
|
280
|
-
spellCheck: V,
|
|
281
|
-
maxImageWidth: j && j.rationale || X,
|
|
282
|
-
maxImageHeight: M && M.rationale || Z,
|
|
283
|
-
uploadSoundSupport: s,
|
|
284
|
-
languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
|
|
285
|
-
mathMlOptions: P
|
|
286
|
-
}), q && /* @__PURE__ */ l(O, { children: q })]
|
|
287
|
-
})
|
|
288
|
-
]
|
|
289
|
-
}), /* @__PURE__ */ l(re, { children: /* @__PURE__ */ l(ie, { children: (() => {
|
|
290
|
-
let { activeDragItem: e } = this.state, { model: n } = this.props;
|
|
291
|
-
if (!e) return null;
|
|
292
|
-
if ((e.type === "drag-in-the-blank-choice" || e.type === "drag-in-the-blank-placed-choice") && e.value) {
|
|
293
|
-
let r = n.choices?.find((t) => t.id === e.value.id);
|
|
294
|
-
return r ? /* @__PURE__ */ l(t, { choice: r }) : null;
|
|
295
|
-
}
|
|
296
|
-
})() }) })]
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
//#endregion
|
|
301
|
-
export { A as default };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/configure/src/markupUtils.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export declare const createElementFromHTML: (htmlString: any) => HTMLDivElement;
|
|
10
|
-
export declare const removeUnwantedCharacters: (markup: any) => any;
|
|
11
|
-
export declare const processMarkup: (markup: any) => {
|
|
12
|
-
markup: string;
|
|
13
|
-
choices: any[];
|
|
14
|
-
correctResponse: any;
|
|
15
|
-
};
|
|
16
|
-
export declare const createSlateMarkup: (markup: any, choices: any, correctResponse: any) => any;
|
|
17
|
-
export declare const choiceIsEmpty: (choice: any) => boolean;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { escape as e } from "@pie-element/shared-lodash";
|
|
2
|
-
//#region src/author/markupUtils.tsx
|
|
3
|
-
var t = (e) => {
|
|
4
|
-
let t = document.createElement("div");
|
|
5
|
-
return t.innerHTML = e.trim(), t;
|
|
6
|
-
}, n = "imes|riangle|an|heta|herefore", r = "throot|parallel|cong|approx|eq|e|sim", i = RegExp(`(\\t(?!${n}))|(\\n(?!${r}))|(\\\\t(?!${n}))|(\\\\n(?!${r}))`, "g"), a = (e) => e.replace(i, "").replace(/\\"/g, "\"").replace(/\\\//g, "/"), o = (e) => {
|
|
7
|
-
let n = t(a(e)), r = [], i = 0;
|
|
8
|
-
return n.querySelectorAll("[data-type=\"drag_in_the_blank\"]").forEach((e) => {
|
|
9
|
-
let t = e.dataset.value && e.dataset.value.replace(/ /g, " ").trim();
|
|
10
|
-
t ||= "", r.push({
|
|
11
|
-
value: t,
|
|
12
|
-
id: e.dataset.id
|
|
13
|
-
}), e.replaceWith(`{{${i++}}}`);
|
|
14
|
-
}), {
|
|
15
|
-
markup: n.innerHTML,
|
|
16
|
-
choices: r,
|
|
17
|
-
correctResponse: r.reduce((e, t, n) => (e[n] = t.id !== void 0 && t.id || "", e), {})
|
|
18
|
-
};
|
|
19
|
-
}, s = /\{\{(\d+)\}\}/g, c = (t, n, r) => {
|
|
20
|
-
let i = a(t), o = 0;
|
|
21
|
-
return i.replace(s, (t, i) => {
|
|
22
|
-
let a = r[i], s = n.find((e) => e.id === a);
|
|
23
|
-
return (!s || !s.value) && (s = {
|
|
24
|
-
id: "",
|
|
25
|
-
value: ""
|
|
26
|
-
}), `<span data-type="drag_in_the_blank" data-index="${o++}" data-id="${s.id}" data-value="${e(s.value)}"></span>`;
|
|
27
|
-
});
|
|
28
|
-
}, l = (e) => {
|
|
29
|
-
if (e) {
|
|
30
|
-
let { value: n = "" } = e, r = t(n);
|
|
31
|
-
return Array.from(r.querySelectorAll("*")).forEach((e) => {
|
|
32
|
-
e.tagName !== "IMG" && e.childNodes.length === 0 && e.remove();
|
|
33
|
-
}), r.innerHTML.trim() === "";
|
|
34
|
-
}
|
|
35
|
-
return !1;
|
|
36
|
-
};
|
|
37
|
-
//#endregion
|
|
38
|
-
export { l as choiceIsEmpty, c as createSlateMarkup, o as processMarkup };
|
package/dist/author/utils.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/configure/utils.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export declare const generateValidationMessage: (config: any) => string;
|
package/dist/author/utils.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
//#region src/author/utils.ts
|
|
2
|
-
var e = (e) => {
|
|
3
|
-
let { maxResponseAreas: t, minChoices: n, maxChoices: r } = e;
|
|
4
|
-
return n ||= 2, "Validation requirements:" + ("\nThe tokens should not be empty and should be unique.\nThere should be at least 1 " + (t ? `and at most ${t} ` : "") + "response area" + (t ? "s" : "") + ` defined.\nThere should be at least ${n} ` + (r ? `and at most ${r} ` : "") + "tokens defined.");
|
|
5
|
-
};
|
|
6
|
-
//#endregion
|
|
7
|
-
export { e as generateValidationMessage };
|