@pie-element/drag-in-the-blank 10.2.2-beta.5 → 10.2.2-beta.6

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,440 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.Main = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
- var _editableHtmlTipTap = _interopRequireWildcard(require("@pie-lib/editable-html-tip-tap"));
12
- var _configUi = require("@pie-lib/config-ui");
13
- var _renderUi = require("@pie-lib/render-ui");
14
- var _drag = require("@pie-lib/drag");
15
- var _mathRendering = require("@pie-lib/math-rendering");
16
- var _styles = require("@mui/material/styles");
17
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
18
- var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
19
- var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
20
- var _core = require("@dnd-kit/core");
21
- var _choice = _interopRequireDefault(require("./choice"));
22
- var _choices = _interopRequireDefault(require("./choices"));
23
- var _markupUtils = require("./markupUtils");
24
- var _utils = require("../utils");
25
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
26
- class DragPreviewWrapper extends _react.default.Component {
27
- constructor(...args) {
28
- super(...args);
29
- (0, _defineProperty2.default)(this, "containerRef", /*#__PURE__*/_react.default.createRef());
30
- }
31
- componentDidMount() {
32
- // Render math in the drag preview after it mounts
33
- setTimeout(() => {
34
- if (this.containerRef.current) {
35
- (0, _mathRendering.renderMath)(this.containerRef.current);
36
- }
37
- }, 0);
38
- }
39
- componentDidUpdate() {
40
- // Re-render math when the drag preview updates
41
- setTimeout(() => {
42
- if (this.containerRef.current) {
43
- (0, _mathRendering.renderMath)(this.containerRef.current);
44
- }
45
- }, 0);
46
- }
47
- render() {
48
- return /*#__PURE__*/_react.default.createElement("div", {
49
- ref: this.containerRef
50
- }, this.props.children);
51
- }
52
- }
53
- const {
54
- dropdown,
55
- toggle,
56
- Panel
57
- } = _configUi.settings;
58
- const StyledInputContainer = (0, _styles.styled)(_renderUi.InputContainer)(({
59
- theme
60
- }) => ({
61
- width: '100%',
62
- paddingTop: theme.spacing(2),
63
- marginBottom: theme.spacing(2)
64
- }));
65
- const StyledMarkup = (0, _styles.styled)('div')(({
66
- theme
67
- }) => ({
68
- minHeight: '235px',
69
- paddingTop: theme.spacing(1),
70
- paddingBottom: theme.spacing(2),
71
- width: '100%',
72
- '& [data-slate-editor="true"]': {
73
- minHeight: '235px'
74
- }
75
- }));
76
- const StyledText = (0, _styles.styled)(_Typography.default)(({
77
- theme
78
- }) => ({
79
- fontSize: theme.typography.fontSize + 2
80
- }));
81
- const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
82
- theme
83
- }) => ({
84
- '& .MuiTooltip-tooltip': {
85
- fontSize: theme.typography.fontSize - 2,
86
- whiteSpace: 'pre',
87
- maxWidth: '500px'
88
- }
89
- }));
90
- const ErrorText = (0, _styles.styled)('div')(({
91
- theme
92
- }) => ({
93
- fontSize: theme.typography.fontSize - 2,
94
- color: theme.palette.error.main,
95
- paddingTop: theme.spacing(1)
96
- }));
97
- const FlexContainer = (0, _styles.styled)('div')({
98
- display: 'flex',
99
- alignItems: 'center'
100
- });
101
- class Main extends _react.default.Component {
102
- constructor(props) {
103
- super(props);
104
- (0, _defineProperty2.default)(this, "state", {
105
- activeDragItem: null
106
- });
107
- (0, _defineProperty2.default)(this, "onModelChange", newVal => {
108
- this.props.onModelChanged({
109
- ...this.props.model,
110
- ...newVal
111
- });
112
- });
113
- (0, _defineProperty2.default)(this, "onPromptChanged", prompt => {
114
- this.props.onModelChanged({
115
- ...this.props.model,
116
- prompt
117
- });
118
- });
119
- (0, _defineProperty2.default)(this, "onRationaleChanged", rationale => {
120
- this.props.onModelChanged({
121
- ...this.props.model,
122
- rationale
123
- });
124
- });
125
- (0, _defineProperty2.default)(this, "onTeacherInstructionsChanged", teacherInstructions => {
126
- this.props.onModelChanged({
127
- ...this.props.model,
128
- teacherInstructions
129
- });
130
- });
131
- (0, _defineProperty2.default)(this, "onMarkupChanged", slateMarkup => {
132
- this.props.onModelChanged({
133
- ...this.props.model,
134
- slateMarkup
135
- });
136
- });
137
- (0, _defineProperty2.default)(this, "onResponsesChanged", choices => {
138
- const {
139
- model: {
140
- correctResponse,
141
- markup
142
- }
143
- } = this.props;
144
- const slateMarkup = (0, _markupUtils.createSlateMarkup)(markup, choices, correctResponse);
145
- this.props.onModelChanged({
146
- ...this.props.model,
147
- slateMarkup,
148
- choices
149
- });
150
- });
151
- this.markupRef = /*#__PURE__*/_react.default.createRef();
152
- }
153
- render() {
154
- const {
155
- model,
156
- configuration,
157
- onConfigurationChanged,
158
- imageSupport,
159
- uploadSoundSupport
160
- } = this.props;
161
- const {
162
- addChoice = {},
163
- baseInputConfiguration = {},
164
- contentDimensions = {},
165
- duplicates = {},
166
- prompt = {},
167
- partialScoring = {},
168
- lockChoiceOrder = {},
169
- rationale = {},
170
- teacherInstructions = {},
171
- choicesPosition = {},
172
- spellCheck = {},
173
- settingsPanelDisabled,
174
- maxChoices,
175
- maxResponseAreas,
176
- maxImageWidth = {},
177
- maxImageHeight = {},
178
- withRubric = {},
179
- mathMlOptions = {},
180
- language = {},
181
- languageChoices = {},
182
- maxLength = {}
183
- } = configuration || {};
184
- const {
185
- rationaleEnabled,
186
- promptEnabled,
187
- teacherInstructionsEnabled,
188
- spellCheckEnabled,
189
- toolbarEditorPosition,
190
- errors,
191
- extraCSSRules
192
- } = model || {};
193
- const {
194
- choicesError,
195
- correctResponseError,
196
- prompt: promptError,
197
- rationale: rationaleError,
198
- responseAreasError,
199
- teacherInstructions: teacherInstructionsError
200
- } = errors || {};
201
- const validationMessage = (0, _utils.generateValidationMessage)(configuration);
202
- const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
203
- const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
204
- const toolbarOpts = {
205
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
206
- };
207
- const panelSettings = {
208
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
209
- duplicates: duplicates.settings && toggle(duplicates.label),
210
- lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
211
- choicesPosition: choicesPosition.settings && dropdown(choicesPosition.label, ['above', 'below', 'left', 'right']),
212
- 'language.enabled': language.settings && toggle(language.label, true),
213
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
214
- };
215
- const panelProperties = {
216
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
217
- rationaleEnabled: rationale.settings && toggle(rationale.label),
218
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
219
- promptEnabled: prompt.settings && toggle(prompt.label),
220
- rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
221
- };
222
- const getPluginProps = props => {
223
- return Object.assign({
224
- ...baseInputConfiguration
225
- }, props || {});
226
- };
227
- const onDragEnd = ({
228
- active,
229
- over
230
- }) => {
231
- // check if item was placed as a correct answer and then dropped outside of StyledMarkup component
232
- if (active && !over) {
233
- const drag = active.data.current;
234
- if (drag && drag.type === 'drag-in-the-blank-placed-choice') {
235
- if (this.markupRef.current) {
236
- const markupBounds = this.markupRef.current.getBoundingClientRect();
237
- const dropX = active.rect.current.translated?.x || 0;
238
- const dropY = active.rect.current.translated?.y || 0;
239
- const isOutsideMarkup = dropX < markupBounds.left || dropX > markupBounds.right || dropY < markupBounds.top || dropY > markupBounds.bottom;
240
- if (isOutsideMarkup && drag.onRemove && typeof drag.onRemove === 'function') {
241
- drag.onRemove(drag);
242
- }
243
- }
244
- }
245
- }
246
- if (!active || !over) {
247
- this.setState({
248
- activeDragItem: null
249
- });
250
- return;
251
- }
252
- const drag = active.data.current;
253
- const drop = over.data.current;
254
- if (drop && typeof drop.onDrop === "function") {
255
- drop.onDrop(drag, drop);
256
- return;
257
- }
258
- if (drag && typeof drag.onDrop === "function") {
259
- drag.onDrop(drag, drop);
260
- }
261
- this.setState({
262
- activeDragItem: null
263
- });
264
- };
265
- const onDragStart = event => {
266
- const {
267
- active
268
- } = event;
269
- if (active?.data?.current) {
270
- this.setState({
271
- activeDragItem: active.data.current
272
- });
273
- }
274
- };
275
- const renderDragOverlay = () => {
276
- const {
277
- activeDragItem
278
- } = this.state;
279
- const {
280
- model
281
- } = this.props;
282
- if (!activeDragItem) return null;
283
- if ((activeDragItem.type === 'drag-in-the-blank-choice' || activeDragItem.type === 'drag-in-the-blank-placed-choice') && activeDragItem.value) {
284
- const choice = model.choices?.find(c => c.id === activeDragItem.value.id);
285
- if (!choice) return null;
286
- return /*#__PURE__*/_react.default.createElement(_choice.default, {
287
- choice: choice
288
- });
289
- }
290
- };
291
- return /*#__PURE__*/_react.default.createElement(_drag.DragProvider, {
292
- onDragEnd: onDragEnd,
293
- onDragStart: onDragStart
294
- }, /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
295
- extraCSSRules: extraCSSRules,
296
- dimensions: contentDimensions,
297
- hideSettings: settingsPanelDisabled,
298
- settings: /*#__PURE__*/_react.default.createElement(Panel, {
299
- model: model,
300
- configuration: configuration,
301
- onChangeModel: model => this.onModelChange(model),
302
- onChangeConfiguration: configuration => onConfigurationChanged(configuration, true),
303
- groups: {
304
- Settings: panelSettings,
305
- Properties: panelProperties
306
- }
307
- })
308
- }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
309
- label: teacherInstructions.label
310
- }, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
311
- markup: model.teacherInstructions || '',
312
- onChange: this.onTeacherInstructionsChanged,
313
- imageSupport: imageSupport,
314
- nonEmpty: false,
315
- error: teacherInstructionsError,
316
- toolbarOpts: toolbarOpts,
317
- pluginProps: getPluginProps(teacherInstructions?.inputConfiguration),
318
- spellCheck: spellCheckEnabled,
319
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
320
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
321
- uploadSoundSupport: uploadSoundSupport,
322
- languageCharactersProps: [{
323
- language: 'spanish'
324
- }, {
325
- language: 'special'
326
- }],
327
- mathMlOptions: mathMlOptions
328
- }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
329
- label: prompt.label
330
- }, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
331
- markup: model.prompt,
332
- onChange: this.onPromptChanged,
333
- imageSupport: imageSupport,
334
- nonEmpty: false,
335
- disableUnderline: true,
336
- error: promptError,
337
- toolbarOpts: toolbarOpts,
338
- pluginProps: getPluginProps(prompt?.inputConfiguration),
339
- spellCheck: spellCheckEnabled,
340
- maxImageWidth: defaultImageMaxWidth,
341
- maxImageHeight: defaultImageMaxHeight,
342
- uploadSoundSupport: uploadSoundSupport,
343
- languageCharactersProps: [{
344
- language: 'spanish'
345
- }, {
346
- language: 'special'
347
- }],
348
- mathMlOptions: mathMlOptions
349
- }), promptError && /*#__PURE__*/_react.default.createElement(ErrorText, null, promptError)), /*#__PURE__*/_react.default.createElement(FlexContainer, null, /*#__PURE__*/_react.default.createElement(StyledText, {
350
- component: 'div'
351
- }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react.default.createElement(StyledTooltip, {
352
- disableFocusListener: true,
353
- disableTouchListener: true,
354
- placement: 'right',
355
- title: validationMessage
356
- }, /*#__PURE__*/_react.default.createElement(_Info.default, {
357
- fontSize: 'small',
358
- color: 'primary',
359
- style: {
360
- marginLeft: '5px'
361
- }
362
- }))), /*#__PURE__*/_react.default.createElement(StyledMarkup, {
363
- ref: this.markupRef
364
- }, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
365
- activePlugins: _editableHtmlTipTap.ALL_PLUGINS,
366
- responseAreaProps: {
367
- type: 'drag-in-the-blank',
368
- options: {
369
- duplicates: model.duplicates
370
- },
371
- maxResponseAreas: maxResponseAreas
372
- },
373
- pluginProps: getPluginProps(),
374
- markup: model.slateMarkup,
375
- onChange: this.onMarkupChanged,
376
- imageSupport: imageSupport,
377
- disableImageAlignmentButtons: true,
378
- nonEmpty: false,
379
- disableUnderline: true,
380
- error: responseAreasError || correctResponseError,
381
- toolbarOpts: toolbarOpts,
382
- spellCheck: spellCheckEnabled,
383
- uploadSoundSupport: uploadSoundSupport,
384
- languageCharactersProps: [{
385
- language: 'spanish'
386
- }, {
387
- language: 'special'
388
- }],
389
- mathMlOptions: mathMlOptions
390
- })), responseAreasError && /*#__PURE__*/_react.default.createElement(ErrorText, null, responseAreasError), correctResponseError && /*#__PURE__*/_react.default.createElement(ErrorText, null, correctResponseError), /*#__PURE__*/_react.default.createElement(_choices.default, {
391
- model: model,
392
- imageSupport: imageSupport,
393
- duplicates: model.duplicates,
394
- error: choicesError,
395
- onChange: this.onResponsesChanged,
396
- toolbarOpts: toolbarOpts,
397
- maxChoices: maxChoices,
398
- uploadSoundSupport: uploadSoundSupport,
399
- mathMlOptions: mathMlOptions,
400
- pluginProps: getPluginProps(addChoice?.inputConfiguration),
401
- maxImageWidth: maxImageWidth && maxImageWidth.choice || defaultImageMaxWidth,
402
- maxImageHeight: maxImageHeight && maxImageHeight.choice || defaultImageMaxHeight,
403
- maxLength: maxLength
404
- }), rationaleEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
405
- label: rationale.label
406
- }, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
407
- markup: model.rationale || '',
408
- onChange: this.onRationaleChanged,
409
- imageSupport: imageSupport,
410
- error: rationaleError,
411
- toolbarOpts: toolbarOpts,
412
- pluginProps: getPluginProps(rationale?.inputConfiguration),
413
- spellCheck: spellCheckEnabled,
414
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
415
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
416
- uploadSoundSupport: uploadSoundSupport,
417
- languageCharactersProps: [{
418
- language: 'spanish'
419
- }, {
420
- language: 'special'
421
- }],
422
- mathMlOptions: mathMlOptions
423
- }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError))), /*#__PURE__*/_react.default.createElement(_core.DragOverlay, null, /*#__PURE__*/_react.default.createElement(DragPreviewWrapper, null, renderDragOverlay())));
424
- }
425
- }
426
- exports.Main = Main;
427
- (0, _defineProperty2.default)(Main, "propTypes", {
428
- configuration: _propTypes.default.object.isRequired,
429
- model: _propTypes.default.object.isRequired,
430
- disableSidePanel: _propTypes.default.bool,
431
- onModelChanged: _propTypes.default.func.isRequired,
432
- onConfigurationChanged: _propTypes.default.func.isRequired,
433
- imageSupport: _propTypes.default.shape({
434
- add: _propTypes.default.func.isRequired,
435
- delete: _propTypes.default.func.isRequired
436
- }),
437
- uploadSoundSupport: _propTypes.default.object
438
- });
439
- var _default = exports.default = Main;
440
- //# sourceMappingURL=main.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_editableHtmlTipTap","_interopRequireWildcard","_configUi","_renderUi","_drag","_mathRendering","_styles","_Typography","_Info","_Tooltip","_core","_choice","_choices","_markupUtils","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DragPreviewWrapper","React","Component","constructor","args","_defineProperty2","createRef","componentDidMount","setTimeout","containerRef","current","renderMath","componentDidUpdate","render","createElement","ref","props","children","dropdown","toggle","Panel","settings","StyledInputContainer","styled","InputContainer","theme","width","paddingTop","spacing","marginBottom","StyledMarkup","minHeight","paddingBottom","StyledText","Typography","fontSize","typography","StyledTooltip","Tooltip","whiteSpace","maxWidth","ErrorText","color","palette","error","main","FlexContainer","display","alignItems","Main","activeDragItem","newVal","onModelChanged","model","prompt","rationale","teacherInstructions","slateMarkup","choices","correctResponse","markup","createSlateMarkup","markupRef","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","addChoice","baseInputConfiguration","contentDimensions","duplicates","partialScoring","lockChoiceOrder","choicesPosition","spellCheck","settingsPanelDisabled","maxChoices","maxResponseAreas","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","language","languageChoices","maxLength","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","spellCheckEnabled","toolbarEditorPosition","errors","extraCSSRules","choicesError","correctResponseError","promptError","rationaleError","responseAreasError","teacherInstructionsError","validationMessage","generateValidationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarOpts","position","panelSettings","label","enabled","options","panelProperties","rubricEnabled","getPluginProps","assign","onDragEnd","active","over","drag","data","type","markupBounds","getBoundingClientRect","dropX","rect","translated","x","dropY","y","isOutsideMarkup","left","right","top","bottom","onRemove","setState","drop","onDrop","onDragStart","event","renderDragOverlay","state","value","choice","find","c","id","DragProvider","layout","ConfigLayout","dimensions","hideSettings","onChangeModel","onModelChange","onChangeConfiguration","groups","Settings","Properties","onChange","onTeacherInstructionsChanged","nonEmpty","pluginProps","inputConfiguration","languageCharactersProps","onPromptChanged","disableUnderline","component","disableFocusListener","disableTouchListener","placement","title","style","marginLeft","activePlugins","ALL_PLUGINS","responseAreaProps","onMarkupChanged","disableImageAlignmentButtons","onResponsesChanged","onRationaleChanged","DragOverlay","exports","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","delete","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html-tip-tap';\nimport { layout, settings } from '@pie-lib/config-ui';\nimport { InputContainer } from '@pie-lib/render-ui';\nimport { DragProvider } from '@pie-lib/drag';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\nimport Info from '@mui/icons-material/Info';\nimport Tooltip from '@mui/material/Tooltip';\nimport { DragOverlay } from '@dnd-kit/core';\n\nimport Choice from './choice';\nimport Choices from './choices';\nimport { createSlateMarkup } from './markupUtils';\nimport { generateValidationMessage } from '../utils';\n\nclass DragPreviewWrapper extends React.Component {\n containerRef = React.createRef();\n\n componentDidMount() {\n // Render math in the drag preview after it mounts\n setTimeout(() => {\n if (this.containerRef.current) {\n renderMath(this.containerRef.current);\n }\n }, 0);\n }\n\n componentDidUpdate() {\n // Re-render math when the drag preview updates\n setTimeout(() => {\n if (this.containerRef.current) {\n renderMath(this.containerRef.current);\n }\n }, 0);\n }\n\n render() {\n return <div ref={this.containerRef}>{this.props.children}</div>;\n }\n}\n\nconst { dropdown, toggle, Panel } = settings;\n\nconst StyledInputContainer = styled(InputContainer)(({ theme }) => ({\n width: '100%',\n paddingTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst StyledMarkup = styled('div')(({ theme }) => ({\n minHeight: '235px',\n paddingTop: theme.spacing(1),\n paddingBottom: theme.spacing(2),\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '235px',\n },\n}));\n\nconst StyledText = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize + 2,\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorText = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nconst FlexContainer = styled('div')({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n disableSidePanel: PropTypes.bool,\n onModelChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired,\n }),\n uploadSoundSupport: PropTypes.object,\n };\n\n state = {\n activeDragItem: null,\n };\n\n constructor(props) {\n super(props);\n this.markupRef = React.createRef();\n }\n\n onModelChange = (newVal) => {\n this.props.onModelChanged({\n ...this.props.model,\n ...newVal,\n });\n };\n\n onPromptChanged = (prompt) => {\n this.props.onModelChanged({\n ...this.props.model,\n prompt,\n });\n };\n\n onRationaleChanged = (rationale) => {\n this.props.onModelChanged({\n ...this.props.model,\n rationale,\n });\n };\n\n onTeacherInstructionsChanged = (teacherInstructions) => {\n this.props.onModelChanged({\n ...this.props.model,\n teacherInstructions,\n });\n };\n\n onMarkupChanged = (slateMarkup) => {\n this.props.onModelChanged({\n ...this.props.model,\n slateMarkup,\n });\n };\n\n onResponsesChanged = (choices) => {\n const {\n model: { correctResponse, markup },\n } = this.props;\n const slateMarkup = createSlateMarkup(markup, choices, correctResponse);\n\n this.props.onModelChanged({\n ...this.props.model,\n slateMarkup,\n choices,\n });\n };\n\n render() {\n const { model, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } = this.props;\n const {\n addChoice = {},\n baseInputConfiguration = {},\n contentDimensions = {},\n duplicates = {},\n prompt = {},\n partialScoring = {},\n lockChoiceOrder = {},\n rationale = {},\n teacherInstructions = {},\n choicesPosition = {},\n spellCheck = {},\n settingsPanelDisabled,\n maxChoices,\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {},\n withRubric = {},\n mathMlOptions = {},\n language = {},\n languageChoices = {},\n maxLength = {},\n } = configuration || {};\n const {\n rationaleEnabled,\n promptEnabled,\n teacherInstructionsEnabled,\n spellCheckEnabled,\n toolbarEditorPosition,\n errors,\n extraCSSRules,\n } = model || {};\n\n const {\n choicesError,\n correctResponseError,\n prompt: promptError,\n rationale: rationaleError,\n responseAreasError,\n teacherInstructions: teacherInstructionsError,\n } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const panelSettings = {\n partialScoring: partialScoring.settings && toggle(partialScoring.label),\n duplicates: duplicates.settings && toggle(duplicates.label),\n lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),\n choicesPosition: choicesPosition.settings && dropdown(choicesPosition.label, ['above', 'below', 'left', 'right']),\n 'language.enabled': language.settings && toggle(language.label, true),\n language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options),\n };\n\n const panelProperties = {\n teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n rubricEnabled: withRubric?.settings && toggle(withRubric?.label),\n };\n\n const getPluginProps = (props) => {\n return Object.assign(\n {\n ...baseInputConfiguration,\n },\n props || {},\n );\n };\n\n\n const onDragEnd = ({ active, over }) => {\n // check if item was placed as a correct answer and then dropped outside of StyledMarkup component\n if (active && !over) {\n const drag = active.data.current;\n\n if (drag && drag.type === 'drag-in-the-blank-placed-choice') {\n if (this.markupRef.current) {\n const markupBounds = this.markupRef.current.getBoundingClientRect();\n const dropX = active.rect.current.translated?.x || 0;\n const dropY = active.rect.current.translated?.y || 0;\n\n const isOutsideMarkup = (\n dropX < markupBounds.left ||\n dropX > markupBounds.right ||\n dropY < markupBounds.top ||\n dropY > markupBounds.bottom\n );\n\n if (isOutsideMarkup && drag.onRemove && typeof drag.onRemove === 'function') {\n drag.onRemove(drag);\n }\n }\n }\n }\n\n if (!active || !over) {\n this.setState({\n activeDragItem: null,\n });\n return;\n }\n\n const drag = active.data.current;\n const drop = over.data.current;\n\n if (drop && typeof drop.onDrop === \"function\") {\n drop.onDrop(drag, drop);\n return;\n }\n\n if (drag && typeof drag.onDrop === \"function\") {\n drag.onDrop(drag, drop);\n }\n\n this.setState({\n activeDragItem: null,\n });\n };\n\n const onDragStart = (event) => {\n const { active } = event;\n\n if (active?.data?.current) {\n this.setState({\n activeDragItem: active.data.current,\n });\n }\n };\n\n const renderDragOverlay = () => {\n const { activeDragItem } = this.state;\n const { model } = this.props;\n\n if (!activeDragItem) return null;\n\n if ((activeDragItem.type === 'drag-in-the-blank-choice' || activeDragItem.type === 'drag-in-the-blank-placed-choice') && activeDragItem.value) {\n const choice = model.choices?.find(c => c.id === activeDragItem.value.id);\n\n if (!choice) return null;\n\n return <Choice choice={choice} />;\n }\n };\n\n return (\n <DragProvider onDragEnd={onDragEnd} onDragStart={onDragStart}>\n <layout.ConfigLayout\n extraCSSRules={extraCSSRules}\n dimensions={contentDimensions}\n hideSettings={settingsPanelDisabled}\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={(model) => this.onModelChange(model)}\n onChangeConfiguration={(configuration) => onConfigurationChanged(configuration, true)}\n groups={{\n Settings: panelSettings,\n Properties: panelProperties,\n }}\n />\n }\n >\n {teacherInstructionsEnabled && (\n <StyledInputContainer label={teacherInstructions.label}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n error={teacherInstructionsError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(teacherInstructions?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.teacherInstructions) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.teacherInstructions) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {teacherInstructionsError && <ErrorText>{teacherInstructionsError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n {promptEnabled && (\n <StyledInputContainer label={prompt.label}>\n <EditableHtml\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n error={promptError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {promptError && <ErrorText>{promptError}</ErrorText>}\n </StyledInputContainer>\n )}\n\n <FlexContainer>\n <StyledText component={'div'}>\n Define Template, Choices, and Correct Responses\n </StyledText>\n <StyledTooltip\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }} />\n </StyledTooltip>\n </FlexContainer>\n\n <StyledMarkup ref={this.markupRef}>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n responseAreaProps={{\n type: 'drag-in-the-blank',\n options: {\n duplicates: model.duplicates,\n },\n maxResponseAreas: maxResponseAreas,\n }}\n pluginProps={getPluginProps()}\n markup={model.slateMarkup}\n onChange={this.onMarkupChanged}\n imageSupport={imageSupport}\n disableImageAlignmentButtons={true}\n nonEmpty={false}\n disableUnderline\n error={responseAreasError || correctResponseError}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </StyledMarkup>\n {responseAreasError && <ErrorText>{responseAreasError}</ErrorText>}\n {correctResponseError && <ErrorText>{correctResponseError}</ErrorText>}\n\n <Choices\n model={model}\n imageSupport={imageSupport}\n duplicates={model.duplicates}\n error={choicesError}\n onChange={this.onResponsesChanged}\n toolbarOpts={toolbarOpts}\n maxChoices={maxChoices}\n uploadSoundSupport={uploadSoundSupport}\n mathMlOptions={mathMlOptions}\n pluginProps={getPluginProps(addChoice?.inputConfiguration)}\n maxImageWidth={(maxImageWidth && maxImageWidth.choice) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.choice) || defaultImageMaxHeight}\n maxLength={maxLength}\n />\n\n {rationaleEnabled && (\n <StyledInputContainer label={rationale.label}>\n <EditableHtml\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n error={rationaleError}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(rationale?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n maxImageWidth={(maxImageWidth && maxImageWidth.rationale) || defaultImageMaxWidth}\n maxImageHeight={(maxImageHeight && maxImageHeight.rationale) || defaultImageMaxHeight}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n {rationaleError && <ErrorText>{rationaleError}</ErrorText>}\n </StyledInputContainer>\n )}\n </layout.ConfigLayout>\n <DragOverlay>\n <DragPreviewWrapper>\n {renderDragOverlay()}\n </DragPreviewWrapper>\n </DragOverlay>\n </DragProvider>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE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,CAEL,CAAC,eACtBrI,MAAA,CAAA6B,OAAA,CAAAuB,aAAA,CAACtC,KAAA,CAAAyM,WAAW,qBACVvN,MAAA,CAAA6B,OAAA,CAAAuB,aAAA,CAACd,kBAAkB,QAChByI,iBAAiB,CAAC,CACD,CACT,CACD,CAAC;EAEnB;AACF;AAACyC,OAAA,CAAAjI,IAAA,GAAAA,IAAA;AAAA,IAAA5C,gBAAA,CAAAd,OAAA,EApXY0D,IAAI,eACI;EACjBc,aAAa,EAAEoH,kBAAS,CAACC,MAAM,CAACC,UAAU;EAC1ChI,KAAK,EAAE8H,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCC,gBAAgB,EAAEH,kBAAS,CAACI,IAAI;EAChCnI,cAAc,EAAE+H,kBAAS,CAACK,IAAI,CAACH,UAAU;EACzCrH,sBAAsB,EAAEmH,kBAAS,CAACK,IAAI,CAACH,UAAU;EACjDpH,YAAY,EAAEkH,kBAAS,CAACM,KAAK,CAAC;IAC5BC,GAAG,EAAEP,kBAAS,CAACK,IAAI,CAACH,UAAU;IAC9BM,MAAM,EAAER,kBAAS,CAACK,IAAI,CAACH;EACzB,CAAC,CAAC;EACFnH,kBAAkB,EAAEiH,kBAAS,CAACC;AAChC,CAAC;AAAA,IAAAQ,QAAA,GAAAV,OAAA,CAAA3L,OAAA,GA0WY0D,IAAI","ignoreList":[]}
@@ -1,83 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.removeUnwantedCharacters = exports.processMarkup = exports.createSlateMarkup = exports.createElementFromHTML = exports.choiceIsEmpty = void 0;
7
- var _lodashEs = require("lodash-es");
8
- const createElementFromHTML = htmlString => {
9
- const div = document.createElement('div');
10
- div.innerHTML = htmlString.trim();
11
- return div;
12
- };
13
-
14
- // do not remove \t from \times, \triangle, \tan, \theta or \therefore
15
- exports.createElementFromHTML = createElementFromHTML;
16
- const tSymbols = 'imes|riangle|an|heta|herefore';
17
- // do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
18
- const nSymbols = 'throot|parallel|cong|approx|eq|e|sim';
19
- // match all \t and \n that are not part of math symbols that starts with \t or \n
20
- const matchTabAndNewLine = new RegExp(`(\\t(?!${tSymbols}))|(\\n(?!${nSymbols}))|(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))`, 'g');
21
- const removeUnwantedCharacters = markup => markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
22
- exports.removeUnwantedCharacters = removeUnwantedCharacters;
23
- const processMarkup = markup => {
24
- const newMarkup = removeUnwantedCharacters(markup);
25
- const slateMarkup = createElementFromHTML(newMarkup);
26
- const choices = [];
27
- let index = 0;
28
- slateMarkup.querySelectorAll('[data-type="drag_in_the_blank"]').forEach(s => {
29
- let value = s.dataset.value && s.dataset.value.replace(/&nbsp;/g, ' ').trim();
30
- if (!value) {
31
- value = '';
32
- }
33
- choices.push({
34
- value,
35
- id: s.dataset.id
36
- });
37
- s.replaceWith(`{{${index++}}}`);
38
- });
39
- return {
40
- markup: slateMarkup.innerHTML,
41
- choices: choices,
42
- correctResponse: choices.reduce((obj, c, index) => {
43
- obj[index] = c.id !== undefined && c.id || '';
44
- return obj;
45
- }, {})
46
- };
47
- };
48
- exports.processMarkup = processMarkup;
49
- const REGEX = /\{\{(\d+)\}\}/g;
50
- const createSlateMarkup = (markup, choices, correctResponse) => {
51
- const newMarkup = removeUnwantedCharacters(markup);
52
- let index = 0;
53
- return newMarkup.replace(REGEX, (match, g) => {
54
- const correctId = correctResponse[g];
55
- let correctChoice = choices.find(c => c.id === correctId);
56
- if (!correctChoice || !correctChoice.value) {
57
- correctChoice = {
58
- id: '',
59
- value: ''
60
- };
61
- }
62
- return `<span data-type="drag_in_the_blank" data-index="${index++}" data-id="${correctChoice.id}" data-value="${(0, _lodashEs.escape)(correctChoice.value)}"></span>`;
63
- });
64
- };
65
- exports.createSlateMarkup = createSlateMarkup;
66
- const choiceIsEmpty = choice => {
67
- if (choice) {
68
- const {
69
- value = ''
70
- } = choice;
71
- const domEl = createElementFromHTML(value);
72
- Array.from(domEl.querySelectorAll('*')).forEach(domEl => {
73
- if (domEl.tagName !== 'IMG' && domEl.childNodes.length === 0) {
74
- domEl.remove();
75
- }
76
- });
77
- const newString = domEl.innerHTML.trim();
78
- return newString === '';
79
- }
80
- return false;
81
- };
82
- exports.choiceIsEmpty = choiceIsEmpty;
83
- //# sourceMappingURL=markupUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markupUtils.js","names":["_lodashEs","require","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","exports","tSymbols","nSymbols","matchTabAndNewLine","RegExp","removeUnwantedCharacters","markup","replace","processMarkup","newMarkup","slateMarkup","choices","index","querySelectorAll","forEach","s","value","dataset","push","id","replaceWith","correctResponse","reduce","obj","c","undefined","REGEX","createSlateMarkup","match","g","correctId","correctChoice","find","escape","choiceIsEmpty","choice","domEl","Array","from","tagName","childNodes","length","remove","newString"],"sources":["../src/markupUtils.js"],"sourcesContent":["import { escape } from 'lodash-es';\n\nexport const createElementFromHTML = (htmlString) => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\n};\n\n// do not remove \\t from \\times, \\triangle, \\tan, \\theta or \\therefore\nconst tSymbols = 'imes|riangle|an|heta|herefore';\n// do not remove \\n from \\nthroot, \\nparallel, \\ncong, \\napprox, \\neq, \\ne or \\nsim\nconst nSymbols = 'throot|parallel|cong|approx|eq|e|sim';\n// match all \\t and \\n that are not part of math symbols that starts with \\t or \\n\nconst matchTabAndNewLine = new RegExp(\n `(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))|(\\\\\\\\t(?!${tSymbols}))|(\\\\\\\\n(?!${nSymbols}))`,\n 'g',\n);\n\nexport const removeUnwantedCharacters = (markup) =>\n markup.replace(matchTabAndNewLine, '').replace(/\\\\\"/g, '\"').replace(/\\\\\\//g, '/');\n\nexport const processMarkup = (markup) => {\n const newMarkup = removeUnwantedCharacters(markup);\n const slateMarkup = createElementFromHTML(newMarkup);\n const choices = [];\n let index = 0;\n\n slateMarkup.querySelectorAll('[data-type=\"drag_in_the_blank\"]').forEach((s) => {\n let value = s.dataset.value && s.dataset.value.replace(/&nbsp;/g, ' ').trim();\n\n if (!value) {\n value = '';\n }\n\n choices.push({\n value,\n id: s.dataset.id,\n });\n\n s.replaceWith(`{{${index++}}}`);\n });\n\n return {\n markup: slateMarkup.innerHTML,\n choices: choices,\n correctResponse: choices.reduce((obj, c, index) => {\n obj[index] = (c.id !== undefined && c.id) || '';\n\n return obj;\n }, {}),\n };\n};\n\nconst REGEX = /\\{\\{(\\d+)\\}\\}/g;\n\nexport const createSlateMarkup = (markup, choices, correctResponse) => {\n const newMarkup = removeUnwantedCharacters(markup);\n let index = 0;\n\n return newMarkup.replace(REGEX, (match, g) => {\n const correctId = correctResponse[g];\n let correctChoice = choices.find((c) => c.id === correctId);\n\n if (!correctChoice || !correctChoice.value) {\n correctChoice = {\n id: '',\n value: '',\n };\n }\n\n return `<span data-type=\"drag_in_the_blank\" data-index=\"${index++}\" data-id=\"${\n correctChoice.id\n }\" data-value=\"${escape(correctChoice.value)}\"></span>`;\n });\n};\n\nexport const choiceIsEmpty = (choice) => {\n if (choice) {\n const { value = '' } = choice;\n const domEl = createElementFromHTML(value);\n\n Array.from(domEl.querySelectorAll('*')).forEach((domEl) => {\n if (domEl.tagName !== 'IMG' && domEl.childNodes.length === 0) {\n domEl.remove();\n }\n });\n\n const newString = domEl.innerHTML.trim();\n\n return newString === '';\n }\n\n return false;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,qBAAqB,GAAIC,UAAU,IAAK;EACnD,MAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAEzCF,GAAG,CAACG,SAAS,GAAGJ,UAAU,CAACK,IAAI,CAAC,CAAC;EAEjC,OAAOJ,GAAG;A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AAM;IAC7B,MAAMC,KAAK,GAAG3C,qBAAqB,CAACuB,KAAK,CAAC;IAE1CqB,KAAK,CAACC,IAAI,CAACF,KAAK,CAACvB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAACC,OAAO,CAAEsB,KAAK,IAAK;MACzD,IAAIA,KAAK,CAACG,OAAO,KAAK,KAAK,IAAIH,KAAK,CAACI,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;QAC5DL,KAAK,CAACM,MAAM,CAAC,CAAC;MAChB;IACF,CAAC,CAAC;IAEF,MAAMC,SAAS,GAAGP,KAAK,CAACtC,SAAS,CAACC,IAAI,CAAC,CAAC;IAExC,OAAO4C,SAAS,KAAK,EAAE;EACzB;EAEA,OAAO,KAAK;AACd,CAAC;AAAC3C,OAAA,CAAAkC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = exports.default = {
8
- choices: [],
9
- choicesPosition: 'below',
10
- correctResponse: {},
11
- disabled: false,
12
- duplicates: true,
13
- markup: '',
14
- mode: 'gather',
15
- prompt: '',
16
- promptEnabled: true,
17
- rationale: '',
18
- rationaleEnabled: true,
19
- studentInstructionsEnabled: true,
20
- teacherInstructions: '',
21
- teacherInstructionsEnabled: true,
22
- toolbarEditorPosition: 'bottom'
23
- };
24
- //# sourceMappingURL=defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.js","names":["choices","choicesPosition","correctResponse","disabled","duplicates","markup","mode","prompt","promptEnabled","rationale","rationaleEnabled","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n choices: [],\n choicesPosition: 'below',\n correctResponse: {},\n disabled: false,\n duplicates: true,\n markup: '',\n mode: 'gather',\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n};\n"],"mappings":";;;;;;iCAAe;EACbA,OAAO,EAAE,EAAE;EACXC,eAAe,EAAE,OAAO;EACxBC,eAAe,EAAE,CAAC,CAAC;EACnBC,QAAQ,EAAE,KAAK;EACfC,UAAU,EAAE,IAAI;EAChBC,MAAM,EAAE,EAAE;EACVC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,EAAE;EACVC,aAAa,EAAE,IAAI;EACnBC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,IAAI;EACtBC,0BAA0B,EAAE,IAAI;EAChCC,mBAAmB,EAAE,EAAE;EACvBC,0BAA0B,EAAE,IAAI;EAChCC,qBAAqB,EAAE;AACzB,CAAC","ignoreList":[]}