@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["model","choices","choicesPosition","correctResponse","disabled","duplicates","markup","mode","prompt","promptEnabled","rationale","rationaleEnabled","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition","configuration","baseInputConfiguration","audio","video","image","h3","blockquote","textAlign","showParagraphs","separateParagraphs","spellCheck","label","settings","enabled","inputConfiguration","required","addChoice","lockChoiceOrder","partialScoring","settingsPanelDisabled","minChoices","maxResponseAreas","maxImageWidth","choice","maxImageHeight","withRubric","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options","maxLength"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n model: {\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 configuration: {\n baseInputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n h3: { disabled: true },\n blockquote: { disabled: true },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n choicesPosition: {\n settings: true,\n label: 'Choices Position',\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n addChoice: {\n inputConfiguration: {\n audio: { disabled: true },\n video: { disabled: true },\n image: { disabled: false },\n },\n },\n duplicates: {\n settings: true,\n label: 'Duplicates',\n },\n lockChoiceOrder: {\n settings: true,\n label: 'Lock Choice Order',\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n settingsPanelDisabled: false,\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n minChoices: 2,\n maxResponseAreas: 10,\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n choice: 300,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n choice: 300,\n },\n withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n maxLength: 200\n },\n};\n"],"mappings":";;;;;;iCAAe;EACbA,KAAK,EAAE;IACLC,OAAO,EAAE,EAAE;IACXC,eAAe,EAAE,OAAO;IACxBC,eAAe,EAAE,CAAC,CAAC;IACnBC,QAAQ,EAAE,KAAK;IACfC,UAAU,EAAE,IAAI;IAChBC,MAAM,EAAE,EAAE;IACVC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE,EAAE;IACVC,aAAa,EAAE,IAAI;IACnBC,SAAS,EAAE,EAAE;IACbC,gBAAgB,EAAE,IAAI;IACtBC,0BAA0B,EAAE,IAAI;IAChCC,mBAAmB,EAAE,EAAE;IACvBC,0BAA0B,EAAE,IAAI;IAChCC,qBAAqB,EAAE;EACzB,CAAC;EACDC,aAAa,EAAE;IACbC,sBAAsB,EAAE;MACtBC,KAAK,EAAE;QAAEd,QAAQ,EAAE;MAAM,CAAC;MAC1Be,KAAK,EAAE;QAAEf,QAAQ,EAAE;MAAM,CAAC;MAC1BgB,KAAK,EAAE;QAAEhB,QAAQ,EAAE;MAAM,CAAC;MAC1BiB,EAAE,EAAE;QAAEjB,QAAQ,EAAE;MAAK,CAAC;MACtBkB,UAAU,EAAE;QAAElB,QAAQ,EAAE;MAAK,CAAC;MAC9BmB,SAAS,EAAE;QAAEnB,QAAQ,EAAE;MAAK,CAAC;MAC7BoB,cAAc,EAAE;QAAEpB,QAAQ,EAAE;MAAM,CAAC;MACnCqB,kBAAkB,EAAE;QAAErB,QAAQ,EAAE;MAAK;IACvC,CAAC;IACDsB,UAAU,EAAE;MACVC,KAAK,EAAE,YAAY;MACnBC,QAAQ,EAAE,KAAK;MACfC,OAAO,EAAE;IACX,CAAC;IACD3B,e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QAAQ,EAAE;QAAM,CAAC;QAC1Be,KAAK,EAAE;UAAEf,QAAQ,EAAE;QAAM,CAAC;QAC1BgB,KAAK,EAAE;UAAEhB,QAAQ,EAAE;QAAM;MAC3B,CAAC;MACD2B,QAAQ,EAAE;IACZ,CAAC;IACDK,UAAU,EAAE,CAAC;IACbC,gBAAgB,EAAE,EAAE;IACpBC,aAAa,EAAE;MACbzB,mBAAmB,EAAE,GAAG;MACxBL,MAAM,EAAE,GAAG;MACXE,SAAS,EAAE,GAAG;MACd6B,MAAM,EAAE;IACV,CAAC;IACDC,cAAc,EAAE;MACd3B,mBAAmB,EAAE,GAAG;MACxBL,MAAM,EAAE,GAAG;MACXE,SAAS,EAAE,GAAG;MACd6B,MAAM,EAAE;IACV,CAAC;IACDE,UAAU,EAAE;MACVb,QAAQ,EAAE,KAAK;MACfD,KAAK,EAAE;IACT,CAAC;IACDe,aAAa,EAAE;MACbC,SAAS,EAAE,KAAK;MAChBC,UAAU,EAAE;IACd,CAAC;IACDC,QAAQ,EAAE;MACRjB,QAAQ,EAAE,KAAK;MACfD,KAAK,EAAE,kBAAkB;MACzBE,OAAO,EAAE;IACX,CAAC;IACDiB,eAAe,EAAE;MACfnB,KAAK,EAAE,kBAAkB;MACzBoB,OAAO,EAAE;IACX,CAAC;IACDC,SAAS,EAAE;EACb;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _client = require("react-dom/client");
|
|
12
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
13
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
14
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
15
|
+
var _lodashEs = require("lodash-es");
|
|
16
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
17
|
+
var _markupUtils = require("./markupUtils");
|
|
18
|
+
const log = (0, _debug.default)('multiple-choice:configure');
|
|
19
|
+
class DragInTheBlank extends HTMLElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
this._root = null;
|
|
23
|
+
this._model = DragInTheBlank.prepareModel();
|
|
24
|
+
this._configuration = _defaults.default.configuration;
|
|
25
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
26
|
+
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
27
|
+
}
|
|
28
|
+
set model(m) {
|
|
29
|
+
const formModel = {
|
|
30
|
+
...m,
|
|
31
|
+
markup: `<div>${m.markup || _defaults.default.model.markup}</div>`
|
|
32
|
+
};
|
|
33
|
+
this._model = DragInTheBlank.prepareModel(formModel);
|
|
34
|
+
this._render();
|
|
35
|
+
}
|
|
36
|
+
set configuration(c) {
|
|
37
|
+
const newConfiguration = (0, _lodashEs.defaults)(c, _defaults.default.configuration);
|
|
38
|
+
this._configuration = newConfiguration;
|
|
39
|
+
|
|
40
|
+
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
41
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
42
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
43
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
44
|
+
if (newConfiguration?.language?.enabled) {
|
|
45
|
+
if (newConfiguration?.languageChoices?.options?.length) {
|
|
46
|
+
this._model.language = newConfiguration?.languageChoices.options[0].value;
|
|
47
|
+
}
|
|
48
|
+
} else if (newConfiguration.language.settings && this._model.language) {
|
|
49
|
+
this._configuration.language.enabled = true;
|
|
50
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
51
|
+
this._configuration.languageChoices.options = [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// check if the language is already included in the languageChoices.options array
|
|
55
|
+
// and if not, then add it.
|
|
56
|
+
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
57
|
+
this._configuration.languageChoices.options.push({
|
|
58
|
+
value: this._model.language,
|
|
59
|
+
label: this._model.language
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
delete this._model.language;
|
|
64
|
+
}
|
|
65
|
+
this._render();
|
|
66
|
+
}
|
|
67
|
+
set disableSidePanel(s) {
|
|
68
|
+
this._disableSidePanel = s;
|
|
69
|
+
this._render();
|
|
70
|
+
}
|
|
71
|
+
dispatchModelUpdated(reset) {
|
|
72
|
+
const resetValue = !!reset;
|
|
73
|
+
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model, resetValue));
|
|
74
|
+
}
|
|
75
|
+
onModelChanged(m, reset) {
|
|
76
|
+
this._model = DragInTheBlank.prepareModel(m);
|
|
77
|
+
this._render();
|
|
78
|
+
this.dispatchModelUpdated(reset);
|
|
79
|
+
}
|
|
80
|
+
onConfigurationChanged(c) {
|
|
81
|
+
this._configuration = c;
|
|
82
|
+
this._render();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** @param {done, progress, file} handler */
|
|
86
|
+
insertImage(handler) {
|
|
87
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
|
|
88
|
+
}
|
|
89
|
+
onDeleteImage(src, done) {
|
|
90
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
|
|
91
|
+
}
|
|
92
|
+
insertSound(handler) {
|
|
93
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
94
|
+
}
|
|
95
|
+
onDeleteSound(src, done) {
|
|
96
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
97
|
+
}
|
|
98
|
+
_render() {
|
|
99
|
+
log('_render');
|
|
100
|
+
let element = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
101
|
+
model: this._model,
|
|
102
|
+
configuration: this._configuration,
|
|
103
|
+
onModelChanged: this.onModelChanged,
|
|
104
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
105
|
+
disableSidePanel: this._disableSidePanel,
|
|
106
|
+
imageSupport: {
|
|
107
|
+
add: this.insertImage.bind(this),
|
|
108
|
+
delete: this.onDeleteImage.bind(this)
|
|
109
|
+
},
|
|
110
|
+
uploadSoundSupport: {
|
|
111
|
+
add: this.insertSound.bind(this),
|
|
112
|
+
delete: this.onDeleteSound.bind(this)
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (!this._root) {
|
|
116
|
+
this._root = (0, _client.createRoot)(this);
|
|
117
|
+
}
|
|
118
|
+
this._root.render(element);
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
(0, _mathRendering.renderMath)(this);
|
|
121
|
+
}, 0);
|
|
122
|
+
}
|
|
123
|
+
disconnectedCallback() {
|
|
124
|
+
if (this._root) {
|
|
125
|
+
this._root.unmount();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.default = DragInTheBlank;
|
|
130
|
+
(0, _defineProperty2.default)(DragInTheBlank, "prepareModel", (model = {}) => {
|
|
131
|
+
const joinedObj = {
|
|
132
|
+
..._defaults.default.model,
|
|
133
|
+
...model
|
|
134
|
+
};
|
|
135
|
+
const slateMarkup = model.slateMarkup || (0, _markupUtils.createSlateMarkup)(joinedObj.markup, joinedObj.choices, joinedObj.correctResponse);
|
|
136
|
+
const processedMarkup = (0, _markupUtils.processMarkup)(slateMarkup);
|
|
137
|
+
return {
|
|
138
|
+
...joinedObj,
|
|
139
|
+
slateMarkup,
|
|
140
|
+
markup: processedMarkup.markup,
|
|
141
|
+
correctResponse: processedMarkup.correctResponse
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_pieConfigureEvents","require","_react","_interopRequireDefault","_client","_mathRendering","_main","_debug","_lodashEs","_defaults","_markupUtils","log","debug","DragInTheBlank","HTMLElement","constructor","_root","_model","prepareModel","_configuration","sensibleDefaults","configuration","onModelChanged","bind","onConfigurationChanged","model","m","formModel","markup","_render","c","newConfiguration","defaults","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","disableSidePanel","s","_disableSidePanel","dispatchModelUpdated","reset","resetValue","dispatchEvent","ModelUpdatedEvent","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","delete","uploadSoundSupport","createRoot","render","setTimeout","renderMath","disconnectedCallback","unmount","exports","default","_defineProperty2","joinedObj","slateMarkup","createSlateMarkup","choices","correctResponse","processedMarkup","processMarkup"],"sources":["../src/index.js"],"sourcesContent":["import {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport Main from './main';\nimport debug from 'debug';\nimport { defaults } from 'lodash-es';\n\nimport sensibleDefaults from './defaults';\nimport { processMarkup, createSlateMarkup } from './markupUtils';\n\nconst log = debug('multiple-choice:configure');\n\nexport default class DragInTheBlank extends HTMLElement {\n static prepareModel = (model = {}) => {\n const joinedObj = {\n ...sensibleDefaults.model,\n ...model,\n };\n const slateMarkup =\n model.slateMarkup || createSlateMarkup(joinedObj.markup, joinedObj.choices, joinedObj.correctResponse);\n const processedMarkup = processMarkup(slateMarkup);\n\n return {\n ...joinedObj,\n slateMarkup,\n markup: processedMarkup.markup,\n correctResponse: processedMarkup.correctResponse,\n };\n };\n\n constructor() {\n super();\n this._root = null;\n this._model = DragInTheBlank.prepareModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(m) {\n const formModel = {\n ...m,\n markup: `<div>${m.markup || sensibleDefaults.model.markup}</div>`,\n };\n\n this._model = DragInTheBlank.prepareModel(formModel);\n this._render();\n }\n\n set configuration(c) {\n const newConfiguration = defaults(c, sensibleDefaults.configuration);\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n set disableSidePanel(s) {\n this._disableSidePanel = s;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = DragInTheBlank.prepareModel(m);\n this._render();\n this.dispatchModelUpdated(reset);\n }\n\n onConfigurationChanged(c) {\n this._configuration = c;\n this._render();\n }\n\n /** @param {done, progress, file} handler */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render');\n\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n disableSidePanel: this._disableSidePanel,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n\n setTimeout(() => {\n renderMath(this);\n }, 0);\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,SAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AAEA,MAAMU,GAAG,GAAG,IAAAC,cAAK,EAAC,2BAA2B,CAAC;AAE/B,MAAMC,cAAc,SAASC,WAAW,CAAC;EAkBtDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACC,MAAM,GAAGJ,cAAc,CAACK,YAAY,CAAC,CAAC;IAC3C,IAAI,CAACC,cAAc,GA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ACwD,MAAM,CAACT,OAAO,CAAC;IAE1BU,UAAU,CAAC,MAAM;MACf,IAAAC,yBAAU,EAAC,IAAI,CAAC;IAClB,CAAC,EAAE,CAAC,CAAC;EACP;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAAC3D,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAAC4D,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAjE,cAAA;AAAA,IAAAkE,gBAAA,CAAAD,OAAA,EAjJoBjE,cAAc,kBACX,CAACY,KAAK,GAAG,CAAC,CAAC,KAAK;EACpC,MAAMuD,SAAS,GAAG;IAChB,GAAG5D,iBAAgB,CAACK,KAAK;IACzB,GAAGA;EACL,CAAC;EACD,MAAMwD,WAAW,GACfxD,KAAK,CAACwD,WAAW,IAAI,IAAAC,8BAAiB,EAACF,SAAS,CAACpD,MAAM,EAAEoD,SAAS,CAACG,OAAO,EAAEH,SAAS,CAACI,eAAe,CAAC;EACxG,MAAMC,eAAe,GAAG,IAAAC,0BAAa,EAACL,WAAW,CAAC;EAElD,OAAO;IACL,GAAGD,SAAS;IACZC,WAAW;IACXrD,MAAM,EAAEyD,eAAe,CAACzD,MAAM;IAC9BwD,eAAe,EAAEC,eAAe,CAACD;EACnC,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,440 @@
|
|
|
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
|