@pie-element/explicit-constructed-response 3.9.0 → 3.9.3-next.1014

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,14 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
  exports["default"] = exports.Main = void 0;
11
11
 
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
12
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
15
 
14
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -31,6 +33,10 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
31
33
 
32
34
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
33
35
 
36
+ var _pick = _interopRequireDefault(require("lodash/pick"));
37
+
38
+ var _throttle = _interopRequireDefault(require("lodash/throttle"));
39
+
34
40
  var _editableHtml = _interopRequireWildcard(require("@pie-lib/editable-html"));
35
41
 
36
42
  var _configUi = require("@pie-lib/config-ui");
@@ -39,17 +45,29 @@ var _styles = require("@material-ui/core/styles");
39
45
 
40
46
  var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
41
47
 
48
+ var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
49
+
50
+ var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
51
+
42
52
  var _ecrToolbar = _interopRequireDefault(require("./ecr-toolbar"));
43
53
 
44
54
  var _alternateResponses = _interopRequireDefault(require("./alternateResponses"));
45
55
 
46
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
56
+ var _markupUtils = require("./markupUtils");
47
57
 
48
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
58
+ var _utils = require("./utils");
59
+
60
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
61
+
62
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
63
+
64
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
65
+
66
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
49
67
 
50
68
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
51
69
 
52
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
70
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
71
 
54
72
  var toggle = _configUi.settings.toggle,
55
73
  Panel = _configUi.settings.Panel;
@@ -93,6 +111,20 @@ var styles = function styles(theme) {
93
111
  fontSize: '16px',
94
112
  lineHeight: '19px',
95
113
  marginTop: theme.spacing.unit * 4
114
+ },
115
+ tooltip: {
116
+ fontSize: '12px',
117
+ whiteSpace: 'pre',
118
+ maxWidth: '500px'
119
+ },
120
+ errorText: {
121
+ fontSize: '12px',
122
+ color: 'red',
123
+ padding: '5px 0'
124
+ },
125
+ flexContainer: {
126
+ display: 'flex',
127
+ alignItems: 'end'
96
128
  }
97
129
  };
98
130
  };
@@ -150,70 +182,167 @@ var Main = /*#__PURE__*/function (_React$Component) {
150
182
  choices: choices
151
183
  }));
152
184
  });
185
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLengthChanged", function (maxLengthPerChoice) {
186
+ var _this$props2 = _this.props,
187
+ model = _this$props2.model,
188
+ onModelChanged = _this$props2.onModelChanged;
189
+ onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
190
+ maxLengthPerChoice: maxLengthPerChoice
191
+ }));
192
+ });
153
193
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeResponse", function (index, newVal) {
154
- var choices = _this.props.model.choices;
194
+ var _this$props3 = _this.props,
195
+ model = _this$props3.model,
196
+ onModelChanged = _this$props3.onModelChanged;
197
+ var choices = model.choices;
198
+ var maxLengthPerChoice = model.maxLengthPerChoice;
199
+ var newValLength = (newVal || '').length;
155
200
 
156
201
  if (!choices[index]) {
157
202
  choices[index] = [{
158
- label: '',
203
+ label: newVal || '',
159
204
  value: '0'
160
- }];
161
- }
205
+ }]; // add default values for missing choices up to the new index position
162
206
 
163
- choices[index][0].label = newVal || '';
207
+ var nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;
208
+ maxLengthPerChoice = [].concat((0, _toConsumableArray2["default"])(maxLengthPerChoice), (0, _toConsumableArray2["default"])(Array(nbOfMissingChoices).fill(1)));
209
+ maxLengthPerChoice.splice(index, 0, (0, _markupUtils.getAdjustedLength)(newValLength));
210
+ } else {
211
+ choices[index][0].label = newVal || '';
164
212
 
165
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
166
- choices: choices
213
+ if (maxLengthPerChoice && (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)) {
214
+ maxLengthPerChoice[index] = (0, _markupUtils.getAdjustedLength)(newValLength);
215
+ }
216
+ }
217
+
218
+ onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
219
+ choices: choices,
220
+ maxLengthPerChoice: maxLengthPerChoice
167
221
  }));
168
222
  });
169
223
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (markup) {
170
- var choices = _this.props.model.choices;
224
+ var _this$props4 = _this.props,
225
+ _this$props4$model = _this$props4.model,
226
+ choices = _this$props4$model.choices,
227
+ maxLengthPerChoice = _this$props4$model.maxLengthPerChoice,
228
+ onModelChanged = _this$props4.onModelChanged;
171
229
  var domMarkup = createElementFromHTML(markup);
172
230
  var allRespAreas = domMarkup.querySelectorAll('[data-type="explicit_constructed_response"]');
173
231
  var allChoices = {};
232
+ var updatedMaxLengthPerChoice = [];
174
233
  allRespAreas.forEach(function (el, index) {
175
- el.dataset.index = index;
176
- });
177
- allRespAreas.forEach(function (el, index) {
178
- var newChoices = (0, _cloneDeep["default"])(Object.values(choices)[index]);
234
+ var newChoices = (0, _cloneDeep["default"])(choices[el.dataset.index]);
179
235
 
180
236
  if (newChoices) {
181
237
  newChoices[0] = {
182
238
  label: el.dataset.value || '',
183
239
  value: '0'
184
240
  };
241
+ updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];
185
242
  }
186
243
 
187
- allChoices[el.dataset.index] = newChoices;
244
+ allChoices[index] = newChoices;
245
+ el.dataset.index = index;
188
246
  });
189
247
 
190
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
191
- choices: allChoices,
192
- slateMarkup: domMarkup.innerHTML
193
- }));
248
+ var callback = function callback() {
249
+ return onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
250
+ choices: allChoices,
251
+ slateMarkup: domMarkup.innerHTML,
252
+ maxLengthPerChoice: updatedMaxLengthPerChoice
253
+ }));
254
+ };
255
+
256
+ _this.setState({
257
+ cachedChoices: undefined
258
+ }, callback);
194
259
  });
260
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onHandleAreaChange", (0, _throttle["default"])(function (nodes) {
261
+ var _this$props5 = _this.props,
262
+ choices = _this$props5.model.choices,
263
+ onModelChanged = _this$props5.onModelChanged;
264
+ var cachedChoices = _this.state.cachedChoices;
265
+
266
+ if (!nodes) {
267
+ return;
268
+ }
269
+
270
+ var newChoices = choices ? (0, _cloneDeep["default"])(choices) : {};
271
+ var newCachedChoices = cachedChoices ? (0, _cloneDeep["default"])(cachedChoices) : {};
272
+ nodes.forEach(function (node) {
273
+ var keyForNode = node.data.get('index');
274
+
275
+ if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {
276
+ Object.assign(newChoices, (0, _pick["default"])(newCachedChoices, keyForNode));
277
+
278
+ if (newCachedChoices.hasOwnProperty(keyForNode)) {
279
+ delete newCachedChoices[keyForNode];
280
+ }
281
+ } else {
282
+ Object.assign(newCachedChoices, (0, _pick["default"])(newChoices, keyForNode));
283
+
284
+ if (newChoices.hasOwnProperty(keyForNode)) {
285
+ delete newChoices[keyForNode];
286
+ }
287
+ }
288
+ });
289
+
290
+ var callback = function callback() {
291
+ return onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
292
+ choices: newChoices
293
+ }));
294
+ };
295
+
296
+ _this.setState({
297
+ cachedChoices: newCachedChoices
298
+ }, callback);
299
+ }, 500, {
300
+ trailing: false,
301
+ leading: true
302
+ }));
195
303
  return _this;
196
304
  }
197
305
 
198
306
  (0, _createClass2["default"])(Main, [{
199
307
  key: "componentDidMount",
200
308
  value: function componentDidMount() {
201
- var slateMarkup = this.props.model.slateMarkup;
309
+ var _this$props6 = this.props,
310
+ _this$props6$model = _this$props6.model,
311
+ slateMarkup = _this$props6$model.slateMarkup,
312
+ choices = _this$props6$model.choices,
313
+ _this$props6$model$ma = _this$props6$model.maxLengthPerChoice,
314
+ maxLengthPerChoice = _this$props6$model$ma === void 0 ? [] : _this$props6$model$ma,
315
+ onModelChanged = _this$props6.onModelChanged;
316
+ var undefinedLengths = !maxLengthPerChoice.length;
202
317
  this.setState({
203
318
  markup: slateMarkup
319
+ }); // calculate maxLengthPerChoice array if it is not defined or defined incorrectly
320
+
321
+ Object.values(choices).forEach(function (choice, index) {
322
+ var labelLengthsArr = (choice || []).map(function (choice) {
323
+ return (choice.label || '').length;
324
+ });
325
+ var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
326
+
327
+ if (undefinedLengths || !maxLengthPerChoice[index] || maxLengthPerChoice[index] < length || maxLengthPerChoice[index] > length + 10) {
328
+ maxLengthPerChoice[index] = (0, _markupUtils.getAdjustedLength)(length);
329
+ }
204
330
  });
331
+ onModelChanged(_objectSpread(_objectSpread({}, this.props.model), {}, {
332
+ maxLengthPerChoice: maxLengthPerChoice
333
+ }));
205
334
  }
206
335
  }, {
207
336
  key: "render",
208
337
  value: function render() {
209
338
  var _this2 = this;
210
339
 
211
- var _this$props2 = this.props,
212
- classes = _this$props2.classes,
213
- model = _this$props2.model,
214
- configuration = _this$props2.configuration,
215
- onConfigurationChanged = _this$props2.onConfigurationChanged,
216
- imageSupport = _this$props2.imageSupport;
340
+ var _this$props7 = this.props,
341
+ classes = _this$props7.classes,
342
+ model = _this$props7.model,
343
+ configuration = _this$props7.configuration,
344
+ onConfigurationChanged = _this$props7.onConfigurationChanged,
345
+ imageSupport = _this$props7.imageSupport;
217
346
 
218
347
  var _ref = configuration || {},
219
348
  _ref$prompt = _ref.prompt,
@@ -223,12 +352,47 @@ var Main = /*#__PURE__*/function (_React$Component) {
223
352
  _ref$rationale = _ref.rationale,
224
353
  rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
225
354
  _ref$teacherInstructi = _ref.teacherInstructions,
226
- teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi;
355
+ teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
356
+ _ref$maxLengthPerChoi = _ref.maxLengthPerChoice,
357
+ maxLengthPerChoice = _ref$maxLengthPerChoi === void 0 ? {} : _ref$maxLengthPerChoi,
358
+ _ref$spellCheck = _ref.spellCheck,
359
+ spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
360
+ _ref$playerSpellCheck = _ref.playerSpellCheck,
361
+ playerSpellCheck = _ref$playerSpellCheck === void 0 ? {} : _ref$playerSpellCheck,
362
+ maxResponseAreas = _ref.maxResponseAreas,
363
+ _ref$maxImageWidth = _ref.maxImageWidth,
364
+ maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
365
+ _ref$maxImageHeight = _ref.maxImageHeight,
366
+ maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight;
227
367
 
228
368
  var _ref2 = model || {},
229
369
  teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
230
370
  promptEnabled = _ref2.promptEnabled,
231
- rationaleEnabled = _ref2.rationaleEnabled;
371
+ rationaleEnabled = _ref2.rationaleEnabled,
372
+ maxLengthPerChoiceEnabled = _ref2.maxLengthPerChoiceEnabled,
373
+ spellCheckEnabled = _ref2.spellCheckEnabled,
374
+ errors = _ref2.errors;
375
+
376
+ var toolbarOpts = {};
377
+
378
+ var _ref3 = errors || {},
379
+ responseAreasError = _ref3.responseAreasError,
380
+ _ref3$choicesErrors = _ref3.choicesErrors,
381
+ choicesErrors = _ref3$choicesErrors === void 0 ? {} : _ref3$choicesErrors;
382
+
383
+ var validationMessage = (0, _utils.generateValidationMessage)(configuration);
384
+ var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
385
+ var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
386
+
387
+ switch (model.toolbarEditorPosition) {
388
+ case 'top':
389
+ toolbarOpts.position = 'top';
390
+ break;
391
+
392
+ default:
393
+ toolbarOpts.position = 'bottom';
394
+ break;
395
+ }
232
396
 
233
397
  return /*#__PURE__*/_react["default"].createElement("div", {
234
398
  className: classes.design
@@ -244,12 +408,15 @@ var Main = /*#__PURE__*/function (_React$Component) {
244
408
  },
245
409
  groups: {
246
410
  Settings: {
247
- partialScoring: partialScoring.settings && toggle(partialScoring.label)
411
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
412
+ maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label)
248
413
  },
249
414
  Properties: {
250
415
  teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
251
416
  rationaleEnabled: rationale.settings && toggle(rationale.label),
252
- promptEnabled: prompt.settings && toggle(prompt.label)
417
+ promptEnabled: prompt.settings && toggle(prompt.label),
418
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
419
+ playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label)
253
420
  }
254
421
  }
255
422
  })
@@ -261,7 +428,11 @@ var Main = /*#__PURE__*/function (_React$Component) {
261
428
  markup: model.teacherInstructions || '',
262
429
  onChange: this.onTeacherInstructionsChanged,
263
430
  imageSupport: imageSupport,
264
- nonEmpty: false
431
+ nonEmpty: false,
432
+ toolbarOpts: toolbarOpts,
433
+ spellCheck: spellCheckEnabled,
434
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
435
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight
265
436
  })), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
266
437
  label: prompt.label,
267
438
  className: classes.promptHolder
@@ -271,19 +442,43 @@ var Main = /*#__PURE__*/function (_React$Component) {
271
442
  onChange: this.onPromptChanged,
272
443
  imageSupport: imageSupport,
273
444
  nonEmpty: false,
274
- disableUnderline: true
275
- })), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
445
+ disableUnderline: true,
446
+ toolbarOpts: toolbarOpts,
447
+ spellCheck: spellCheckEnabled,
448
+ maxImageWidth: defaultImageMaxWidth,
449
+ maxImageHeight: defaultImageMaxHeight
450
+ })), /*#__PURE__*/_react["default"].createElement("div", {
451
+ className: classes.flexContainer
452
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
276
453
  className: classes.text
277
- }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
454
+ }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
455
+ classes: {
456
+ tooltip: classes.tooltip
457
+ },
458
+ disableFocusListener: true,
459
+ disableTouchListener: true,
460
+ placement: 'right',
461
+ title: validationMessage
462
+ }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
463
+ fontSize: 'small',
464
+ color: 'primary',
465
+ style: {
466
+ marginLeft: '5px'
467
+ }
468
+ }))), responseAreasError && /*#__PURE__*/_react["default"].createElement("div", {
469
+ className: classes.errorText
470
+ }, responseAreasError), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
278
471
  activePlugins: _editableHtml.ALL_PLUGINS,
279
472
  toolbarOpts: {
280
473
  position: 'top'
281
474
  },
475
+ spellCheck: spellCheckEnabled,
282
476
  responseAreaProps: {
283
477
  type: 'explicit-constructed-response',
284
478
  options: {
285
479
  duplicates: true
286
480
  },
481
+ maxResponseAreas: maxResponseAreas,
287
482
  respAreaToolbar: function respAreaToolbar(node, value, onToolbarDone) {
288
483
  var model = _this2.props.model;
289
484
  var correctChoice = (model.choices[node.data.get('index')] || [])[0];
@@ -298,7 +493,11 @@ var Main = /*#__PURE__*/function (_React$Component) {
298
493
  correctChoice: correctChoice
299
494
  });
300
495
  };
301
- }
496
+ },
497
+ error: function error() {
498
+ return choicesErrors;
499
+ },
500
+ onHandleAreaChange: this.onHandleAreaChange
302
501
  },
303
502
  className: classes.markup,
304
503
  markup: model.slateMarkup,
@@ -306,12 +505,17 @@ var Main = /*#__PURE__*/function (_React$Component) {
306
505
  imageSupport: imageSupport,
307
506
  onBlur: this.onBlur,
308
507
  disabled: false,
309
- highlightShape: false
508
+ highlightShape: false,
509
+ error: responseAreasError
310
510
  }), !(0, _isEmpty["default"])(model.choices) && /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
311
511
  className: classes.text
312
- }, "Define Alternates"), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
512
+ }, "Define Alternates ".concat(maxLengthPerChoiceEnabled ? 'and Character Limits' : '')), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
313
513
  model: model,
314
- onChange: this.onResponsesChanged
514
+ onChange: this.onResponsesChanged,
515
+ onLengthChange: this.onLengthChanged,
516
+ maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
517
+ spellCheck: spellCheckEnabled,
518
+ choicesErrors: choicesErrors
315
519
  }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
316
520
  label: rationale.label,
317
521
  className: classes.promptHolder
@@ -319,7 +523,11 @@ var Main = /*#__PURE__*/function (_React$Component) {
319
523
  className: classes.prompt,
320
524
  markup: model.rationale || '',
321
525
  onChange: this.onRationaleChanged,
322
- imageSupport: imageSupport
526
+ imageSupport: imageSupport,
527
+ toolbarOpts: toolbarOpts,
528
+ spellCheck: spellCheckEnabled,
529
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
530
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight
323
531
  })))));
324
532
  }
325
533
  }]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","markup","minHeight","design","choiceConfiguration","switchElement","justifyContent","margin","addButton","text","color","fontFamily","fontSize","lineHeight","marginTop","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","rationale","teacherInstructions","slateMarkup","choices","index","label","value","domMarkup","allRespAreas","querySelectorAll","allChoices","forEach","el","dataset","newChoices","Object","values","setState","classes","configuration","onConfigurationChanged","imageSupport","partialScoring","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","onModelChange","Settings","Properties","onTeacherInstructionsChanged","onPromptChanged","ALL_PLUGINS","position","type","options","duplicates","respAreaToolbar","node","onToolbarDone","correctChoice","data","get","onChangeResponse","onChange","onBlur","onResponsesChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;;;IAFQA,M,GAAkBC,kB,CAAlBD,M;IAAQE,K,GAAUD,kB,CAAVC,K;;AAIhB,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,aAAa,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADS;AAMvBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAD3B;AAENH,MAAAA,KAAK,EAAE;AAFD,KANe;AAUvBO,IAAAA,MAAM,EAAE;AACNC,MAAAA,SAAS,EAAE,OADL;AAENF,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAF3B;AAGNH,MAAAA,KAAK,EAAE,MAHD;AAIN,sCAAgC;AAC9BQ,QAAAA,SAAS,EAAE;AADmB;AAJ1B,KAVe;AAkBvBC,IAAAA,MAAM,EAAE;AACNH,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAD3B,KAlBe;AAqBvBO,IAAAA,mBAAmB,EAAE;AACnBJ,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CADd;AAEnBF,MAAAA,aAAa,EAAEH,KAAK,CAACI,OAAN,C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EArQuB0B,kBAAMC,S;;;iCAAnBrD,I,eACQ;AACjBwB,EAAAA,aAAa,EAAE8B,sBAAUC,MAAV,CAAiBC,UADf;AAEjBpD,EAAAA,KAAK,EAAEkD,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBC,EAAAA,gBAAgB,EAAEH,sBAAUI,IAHX;AAIjBvD,EAAAA,cAAc,EAAEmD,sBAAUK,IAAV,CAAeH,UAJd;AAKjB/B,EAAAA,sBAAsB,EAAE6B,sBAAUK,IAAV,CAAeH,UALtB;AAMjBjC,EAAAA,OAAO,EAAE+B,sBAAUC,MAAV,CAAiBC,UANT;AAOjB9B,EAAAA,YAAY,EAAE4B,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB;AAPG,C;AAuQrB,IAAMM,MAAM,GAAG,wBAAW7F,MAAX,EAAmB+B,IAAnB,CAAf;eAEe8D,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport EditableHtml, { ALL_PLUGINS } from '@pie-lib/editable-html';\nimport { InputContainer, layout, settings } from '@pie-lib/config-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\n\nconst { toggle, Panel } = settings;\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\n\nconst styles = theme => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px'\n }\n },\n design: {\n paddingTop: theme.spacing.unit * 3\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n addButton: {\n float: 'right'\n },\n text: {\n color: '#495B8F',\n fontFamily: 'Cerebri Sans',\n fontSize: '16px',\n lineHeight: '19px',\n marginTop: theme.spacing.unit * 4\n }\n});\n\nconst createElementFromHTML = htmlString => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\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 classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n })\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup }\n } = this.props;\n\n this.setState({\n markup: slateMarkup\n });\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 const { model, onModelChanged } = this.props;\n\n onModelChanged({\n ...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 this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onChangeResponse = (index, newVal) => {\n const {\n model: { choices }\n } = this.props;\n\n if (!choices[index]) {\n choices[index] = [{ label: '', value: '0' }];\n }\n\n choices[index][0].label = newVal || '';\n\n this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onChange = markup => {\n const {\n model: { choices }\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll(\n '[data-type=\"explicit_constructed_response\"]'\n );\n\n const allChoices = {};\n\n allRespAreas.forEach((el, index) => {\n el.dataset.index = index;\n });\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(Object.values(choices)[index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0'\n };\n }\n\n allChoices[el.dataset.index] = newChoices;\n });\n\n this.props.onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML\n });\n };\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged,\n imageSupport\n } = this.props;\n const {\n prompt = {},\n partialScoring = {},\n rationale = {},\n teacherInstructions = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled } =\n model || {};\n\n return (\n <div className={classes.design}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={model => this.onModelChange(model)}\n onChangeConfiguration={configuration =>\n onConfigurationChanged(configuration, true)\n }\n groups={{\n Settings: {\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label)\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label)\n }\n }}\n />\n }\n >\n <div>\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n />\n </InputContainer>\n )}\n <Typography className={classes.text}>\n Define Template, Choices, and Correct Responses\n </Typography>\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true\n },\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[\n node.data.get('index')\n ] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={newVal =>\n this.onChangeResponse(node.data.get('index'), newVal)\n }\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n />\n );\n }\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n />\n {!isEmpty(model.choices) && (\n <Typography className={classes.text}>\n Define Alternates\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n />\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n />\n </InputContainer>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["toggle","settings","Panel","styles","theme","promptHolder","width","paddingBottom","spacing","unit","marginBottom","prompt","paddingTop","markup","minHeight","design","choiceConfiguration","switchElement","justifyContent","margin","addButton","text","color","fontFamily","fontSize","lineHeight","marginTop","tooltip","whiteSpace","maxWidth","errorText","padding","flexContainer","display","alignItems","createElementFromHTML","htmlString","div","document","createElement","innerHTML","trim","Main","newVal","props","onModelChanged","model","rationale","teacherInstructions","slateMarkup","choices","maxLengthPerChoice","index","newValLength","length","label","value","nbOfMissingChoices","Array","fill","splice","domMarkup","allRespAreas","querySelectorAll","allChoices","updatedMaxLengthPerChoice","forEach","el","newChoices","dataset","callback","setState","cachedChoices","undefined","nodes","state","newCachedChoices","node","keyForNode","data","get","Object","assign","hasOwnProperty","trailing","leading","undefinedLengths","values","choice","labelLengthsArr","map","Math","max","classes","configuration","onConfigurationChanged","imageSupport","partialScoring","spellCheck","playerSpellCheck","maxResponseAreas","maxImageWidth","maxImageHeight","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","maxLengthPerChoiceEnabled","spellCheckEnabled","errors","toolbarOpts","responseAreasError","choicesErrors","validationMessage","defaultImageMaxWidth","defaultImageMaxHeight","toolbarEditorPosition","position","onModelChange","Settings","Properties","playerSpellCheckEnabled","onTeacherInstructionsChanged","onPromptChanged","marginLeft","ALL_PLUGINS","type","options","duplicates","respAreaToolbar","onToolbarDone","correctChoice","onChangeResponse","error","onHandleAreaChange","onChange","onBlur","onResponsesChanged","onLengthChanged","onRationaleChanged","React","Component","PropTypes","object","isRequired","disableSidePanel","bool","func","shape","add","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAQA,MAAR,GAA0BC,kBAA1B,CAAQD,MAAR;AAAA,IAAgBE,KAAhB,GAA0BD,kBAA1B,CAAgBC,KAAhB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,aAAa,EAAEH,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZC,MAAAA,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAqB;AAHvB,KADS;AAMvBE,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAER,KAAK,CAACI,OAAN,CAAcC,IAAd,GAAq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X;AAIjBpG,EAAAA,cAAc,EAAEgG,sBAAUK,IAAV,CAAeH,UAJd;AAKjBhD,EAAAA,sBAAsB,EAAE8C,sBAAUK,IAAV,CAAeH,UALtB;AAMjBlD,EAAAA,OAAO,EAAEgD,sBAAUC,MAAV,CAAiBC,UANT;AAOjB/C,EAAAA,YAAY,EAAE6C,sBAAUM,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEP,sBAAUK,IAAV,CAAeH,UADQ;AAE5B,cAAQF,sBAAUK,IAAV,CAAeH;AAFK,GAAhB;AAPG,C;AAibrB,IAAMM,MAAM,GAAG,wBAAWlJ,MAAX,EAAmBuC,IAAnB,CAAf;eAEe2G,M","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport pick from 'lodash/pick';\nimport throttle from 'lodash/throttle';\nimport EditableHtml, {ALL_PLUGINS} from '@pie-lib/editable-html';\n// import EditableHtmlNew from 'editable-html';\nimport {InputContainer, layout, settings} from '@pie-lib/config-ui';\nimport {withStyles} from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport ECRToolbar from './ecr-toolbar';\nimport AlternateResponses from './alternateResponses';\nimport { getAdjustedLength } from './markupUtils';\nimport {generateValidationMessage} from './utils';\n\nconst { toggle, Panel } = settings;\n\nconst styles = theme => ({\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n markup: {\n minHeight: '100px',\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n '& [data-slate-editor=\"true\"]': {\n minHeight: '100px'\n }\n },\n design: {\n paddingTop: theme.spacing.unit * 3\n },\n choiceConfiguration: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n addButton: {\n float: 'right'\n },\n text: {\n color: '#495B8F',\n fontFamily: 'Cerebri Sans',\n fontSize: '16px',\n lineHeight: '19px',\n marginTop: theme.spacing.unit * 4\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0'\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'end'\n }\n});\n\nconst createElementFromHTML = htmlString => {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString.trim();\n\n return div;\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 classes: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func.isRequired,\n delete: PropTypes.func.isRequired\n })\n };\n\n state = {};\n\n componentDidMount() {\n const {\n model: { slateMarkup, choices, maxLengthPerChoice = []},\n onModelChanged\n } = this.props;\n const undefinedLengths = !maxLengthPerChoice.length;\n\n this.setState({ markup: slateMarkup });\n\n // calculate maxLengthPerChoice array if it is not defined or defined incorrectly\n Object.values(choices).forEach((choice, index) => {\n const labelLengthsArr = (choice || []).map(choice => (choice.label || '').length);\n const length = Math.max(...labelLengthsArr);\n\n if (\n undefinedLengths\n || !maxLengthPerChoice[index]\n || maxLengthPerChoice[index] < length\n || maxLengthPerChoice[index] > length + 10\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(length);\n }\n });\n\n onModelChanged({\n ...this.props.model,\n maxLengthPerChoice\n });\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 const { model, onModelChanged } = this.props;\n\n onModelChanged({\n ...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 this.props.onModelChanged({\n ...this.props.model,\n choices\n });\n };\n\n onLengthChanged = maxLengthPerChoice => {\n const { model, onModelChanged } = this.props;\n\n onModelChanged({\n ...model,\n maxLengthPerChoice\n });\n };\n\n onChangeResponse = (index, newVal) => {\n const { model, onModelChanged} = this.props;\n const { choices } = model;\n let { maxLengthPerChoice } = model;\n const newValLength = (newVal || '').length;\n\n if (!choices[index]) {\n choices[index] = [{ label: newVal || '', value: '0' }];\n\n // add default values for missing choices up to the new index position\n const nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;\n\n maxLengthPerChoice = [ ...maxLengthPerChoice, ...Array(nbOfMissingChoices).fill(1) ];\n\n maxLengthPerChoice.splice(index, 0, getAdjustedLength(newValLength));\n } else {\n choices[index][0].label = newVal || '';\n\n if (\n maxLengthPerChoice\n && (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)\n ) {\n maxLengthPerChoice[index] = getAdjustedLength(newValLength);\n }\n }\n\n onModelChanged({\n ...model,\n choices,\n maxLengthPerChoice\n });\n };\n\n onChange = markup => {\n const {\n model: { choices, maxLengthPerChoice },\n onModelChanged\n } = this.props;\n const domMarkup = createElementFromHTML(markup);\n const allRespAreas = domMarkup.querySelectorAll(\n '[data-type=\"explicit_constructed_response\"]'\n );\n\n const allChoices = {};\n const updatedMaxLengthPerChoice = [];\n\n allRespAreas.forEach((el, index) => {\n const newChoices = cloneDeep(choices[el.dataset.index]);\n\n if (newChoices) {\n newChoices[0] = {\n label: el.dataset.value || '',\n value: '0'\n };\n\n updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];\n }\n\n allChoices[index] = newChoices;\n el.dataset.index = index;\n });\n\n const callback = () => onModelChanged({\n ...this.props.model,\n choices: allChoices,\n slateMarkup: domMarkup.innerHTML,\n maxLengthPerChoice: updatedMaxLengthPerChoice\n });\n\n this.setState({\n cachedChoices: undefined\n }, callback);\n };\n\n onHandleAreaChange = throttle((nodes) => {\n const {\n model: { choices },\n onModelChanged\n } = this.props;\n const { cachedChoices } = this.state;\n\n if (!nodes) {\n return;\n }\n\n const newChoices = choices ? cloneDeep(choices) : {};\n const newCachedChoices = cachedChoices ? cloneDeep(cachedChoices) : {};\n\n nodes.forEach((node) => {\n const keyForNode = node.data.get('index');\n\n if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {\n Object.assign(newChoices, pick(newCachedChoices, keyForNode));\n\n if (newCachedChoices.hasOwnProperty(keyForNode)) {\n delete newCachedChoices[keyForNode];\n }\n } else {\n Object.assign(newCachedChoices, pick(newChoices, keyForNode));\n\n if (newChoices.hasOwnProperty(keyForNode)) {\n delete newChoices[keyForNode];\n }\n }\n });\n\n const callback = () => onModelChanged({\n ...this.props.model,\n choices: newChoices\n });\n\n this.setState({\n cachedChoices: newCachedChoices\n }, callback);\n }, 500, { trailing: false, leading: true });\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged,\n imageSupport\n } = this.props;\n const {\n prompt = {},\n partialScoring = {},\n rationale = {},\n teacherInstructions = {},\n maxLengthPerChoice = {},\n spellCheck = {},\n playerSpellCheck = {},\n maxResponseAreas,\n maxImageWidth = {},\n maxImageHeight = {}\n } = configuration || {};\n const {\n teacherInstructionsEnabled,\n promptEnabled,\n rationaleEnabled,\n maxLengthPerChoiceEnabled,\n spellCheckEnabled,\n errors\n } = model || {};\n const toolbarOpts = {};\n\n const { responseAreasError, choicesErrors = {} } = errors || {};\n const validationMessage = generateValidationMessage(configuration);\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n return (\n <div className={classes.design}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={model => this.onModelChange(model)}\n onChangeConfiguration={configuration =>\n onConfigurationChanged(configuration, true)\n }\n groups={{\n Settings: {\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n maxLengthPerChoiceEnabled:\n maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n rationaleEnabled:\n rationale.settings && toggle(rationale.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n playerSpellCheckEnabled:\n playerSpellCheck.settings && toggle(playerSpellCheck.label),\n }\n }}\n />\n }\n >\n <div>\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth}\n maxImageHeight={maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n disableUnderline\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n />\n {/*<EditableHtmlNew*/}\n {/* className={classes.prompt}*/}\n {/* markup={model.prompt}*/}\n {/* onChange={this.onPromptChanged}*/}\n {/* imageSupport={imageSupport}*/}\n {/* nonEmpty={false}*/}\n {/* disableUnderline*/}\n {/* toolbarOpts={toolbarOpts}*/}\n {/* spellCheck={spellCheckEnabled}*/}\n {/*/>*/}\n </InputContainer>\n )}\n <div className={classes.flexContainer}>\n <Typography className={classes.text}>\n Define Template, Choices, and Correct Responses\n </Typography>\n <Tooltip\n classes={{tooltip: classes.tooltip}}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '5px' }}/>\n </Tooltip>\n </div>\n {responseAreasError && <div className={classes.errorText}>{responseAreasError}</div>}\n\n <EditableHtml\n activePlugins={ALL_PLUGINS}\n toolbarOpts={{ position: 'top' }}\n spellCheck={spellCheckEnabled}\n responseAreaProps={{\n type: 'explicit-constructed-response',\n options: {\n duplicates: true\n },\n maxResponseAreas: maxResponseAreas,\n respAreaToolbar: (node, value, onToolbarDone) => {\n const { model } = this.props;\n const correctChoice = (model.choices[\n node.data.get('index')\n ] || [])[0];\n\n return () => (\n <ECRToolbar\n onChangeResponse={newVal =>\n this.onChangeResponse(node.data.get('index'), newVal)\n }\n node={node}\n value={value}\n onToolbarDone={onToolbarDone}\n correctChoice={correctChoice}\n />\n );\n },\n error: () => choicesErrors,\n onHandleAreaChange: this.onHandleAreaChange\n }}\n className={classes.markup}\n markup={model.slateMarkup}\n onChange={this.onChange}\n imageSupport={imageSupport}\n onBlur={this.onBlur}\n disabled={false}\n highlightShape={false}\n error={responseAreasError}\n />\n {!isEmpty(model.choices) && (\n <Typography className={classes.text}>\n {`Define Alternates ${maxLengthPerChoiceEnabled ? 'and Character Limits' : ''}`}\n </Typography>\n )}\n <AlternateResponses\n model={model}\n onChange={this.onResponsesChanged}\n onLengthChange={this.onLengthChanged}\n maxLengthPerChoiceEnabled={maxLengthPerChoiceEnabled}\n spellCheck={spellCheckEnabled}\n choicesErrors={choicesErrors}\n />\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth}\n maxImageHeight={maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight}\n />\n </InputContainer>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Main);\n\nexport default Styled;\n"],"file":"main.js"}
@@ -5,12 +5,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.createSlateMarkup = exports.processMarkup = exports.removeUnwantedCharacters = void 0;
8
+ exports.removeUnwantedCharacters = exports.processMarkup = exports.getAdjustedLength = exports.createSlateMarkup = void 0;
9
9
 
10
10
  var _escape = _interopRequireDefault(require("lodash/escape"));
11
11
 
12
+ // do not remove \t from \times, \triangle, \tan, \theta or \therefore
13
+ var tSymbols = 'imes|riangle|an|heta|herefore'; // do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
14
+
15
+ var nSymbols = 'throot|parallel|cong|approx|eq|e|sim'; // match all \t and \n that are not part of math symbols that starts with \t or \n
16
+
17
+ var matchTabAndNewLine = new RegExp("(\\t(?!".concat(tSymbols, "))|(\\n(?!").concat(nSymbols, "))|(\\\\t(?!").concat(tSymbols, "))|(\\\\n(?!").concat(nSymbols, "))"), 'g');
18
+
12
19
  var removeUnwantedCharacters = function removeUnwantedCharacters(markup) {
13
- return markup.replace(/(\t+(?!imes))|(\n)|(\\t+(?!imes))|(\\n)/g, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
20
+ return markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
14
21
  };
15
22
 
16
23
  exports.removeUnwantedCharacters = removeUnwantedCharacters;
@@ -45,7 +52,26 @@ var createSlateMarkup = function createSlateMarkup(markup, choices) {
45
52
  var label = choices[g][0].label || '';
46
53
  return "<span data-type=\"explicit_constructed_response\" data-index=\"".concat(g, "\" data-value=\"").concat((0, _escape["default"])(label), "\"></span>");
47
54
  });
48
- };
55
+ }; // also used in controller/src/index.js
56
+
49
57
 
50
58
  exports.createSlateMarkup = createSlateMarkup;
59
+
60
+ var getAdjustedLength = function getAdjustedLength(length) {
61
+ if (length <= 2) {
62
+ return length + 2;
63
+ }
64
+
65
+ if (length <= 4) {
66
+ return length + 3;
67
+ }
68
+
69
+ if (length <= 6) {
70
+ return length + 4;
71
+ }
72
+
73
+ return length + 5;
74
+ };
75
+
76
+ exports.getAdjustedLength = getAdjustedLength;
51
77
  //# sourceMappingURL=markupUtils.js.map