@pie-element/explicit-constructed-response 3.7.19-next.85 → 3.8.1-beta.587
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.md +541 -0
- package/configure/CHANGELOG.md +482 -0
- package/configure/lib/alternateResponses.js +45 -12
- package/configure/lib/alternateResponses.js.map +1 -1
- package/configure/lib/alternateSection.js +116 -19
- package/configure/lib/alternateSection.js.map +1 -1
- package/configure/lib/defaults.js +35 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/ecr-toolbar.js +35 -19
- package/configure/lib/ecr-toolbar.js.map +1 -1
- package/configure/lib/index.js +17 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +291 -58
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/markupUtils.js +29 -3
- package/configure/lib/markupUtils.js.map +1 -1
- package/configure/lib/utils.js +15 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +23 -5
- package/controller/CHANGELOG.md +107 -0
- package/controller/lib/defaults.js +1 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +109 -6
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/docs/config-schema.json +137 -0
- package/docs/config-schema.json.md +105 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +6 -2
- package/docs/pie-schema.json +68 -0
- package/docs/pie-schema.json.md +53 -0
- package/lib/index.js +8 -1
- package/lib/index.js.map +1 -1
- package/lib/main.js +95 -25
- package/lib/main.js.map +1 -1
- package/lib/print.js +115 -0
- package/lib/print.js.map +1 -0
- package/package.json +14 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ecr-toolbar.jsx"],"names":["findSlateNode","key","window","document","querySelector","ECRToolbar","
|
|
1
|
+
{"version":3,"sources":["../src/ecr-toolbar.jsx"],"names":["findSlateNode","key","window","document","querySelector","ECRToolbar","markup","newValue","state","props","node","nodePath","editor","onToolbarDone","onChangeResponse","update","data","value","apply","type","path","properties","newProperties","e","setState","target","correctChoice","choice","domNode","domNodeRect","getBoundingClientRect","closest","editorRect","top","left","label","toolbarStyle","position","height","width","classes","backgroundColor","input","onChange","onDone","React","Component","PropTypes","object","array","func","isRequired","StyledECRToolbar","respArea","padding","errorInput","border"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,GAAD,EAAS;AAC7B,SAAOC,MAAM,CAACC,QAAP,CAAgBC,aAAhB,CAA8B,gBAAgBH,GAAhB,GAAsB,IAApD,CAAP;AACD,CAFD;;IAIaI,U;;;;;;;;;;;;;;;8FAYH;AACNC,MAAAA,MAAM,EAAE;AADF,K;+FA8BC,YAAM;AACb,UAAgBC,QAAhB,GAA6B,MAAKC,KAAlC,CAAQF,MAAR;AACA,wBAAoE,MAAKG,KAAzE;AAAA,UAAQC,IAAR,eAAQA,IAAR;AAAA,UAAcC,QAAd,eAAcA,QAAd;AAAA,UAAwBC,MAAxB,eAAwBA,MAAxB;AAAA,UAAgCC,aAAhC,eAAgCA,aAAhC;AAAA,UAA+CC,gBAA/C,eAA+CA,gBAA/C;;AACA,UAAMC,MAAM,mCAAQL,IAAI,CAACM,IAAb;AAAmBC,QAAAA,KAAK,EAAEV;AAA1B,QAAZ;;AAEAK,MAAAA,MAAM,CAACM,KAAP,CAAa;AACXC,QAAAA,IAAI,EAAE,UADK;AAEXC,QAAAA,IAAI,EAAET,QAFK;AAGXU,QAAAA,UAAU,EAAE;AACVL,UAAAA,IAAI,EAAEN,IAAI,CAACM;AADD,SAHD;AAMXM,QAAAA,aAAa,EAAE;AAAEN,UAAAA,IAAI,EAAED;AAAR;AANJ,OAAb;AASAF,MAAAA,aAAa,CAAC,IAAD,CAAb;AACAC,MAAAA,gBAAgB,CAACP,QAAD,CAAhB;AACD,K;iGAEU,UAACgB,CAAD;AAA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AAX,EAWtBnD,UAXsB,CAAzB;eAae+C,gB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport classNames from 'classnames';\n\nconst findSlateNode = (key) => {\n return window.document.querySelector('[data-key=\"' + key + '\"]');\n};\n\nexport class ECRToolbar extends React.Component {\n static propTypes = {\n correctChoice: PropTypes.object,\n classes: PropTypes.object,\n node: PropTypes.object,\n nodePath: PropTypes.array,\n onDone: PropTypes.func,\n onChangeResponse: PropTypes.func.isRequired,\n onToolbarDone: PropTypes.func.isRequired,\n editor: PropTypes.object\n };\n\n state = {\n markup: '',\n };\n\n componentDidMount() {\n const { correctChoice, node } = this.props;\n const choice = correctChoice || {};\n\n const domNode = findSlateNode(node.key);\n\n if (domNode) {\n //eslint-disable-next-line\n const domNodeRect = domNode.getBoundingClientRect();\n const editor = domNode.closest('[data-slate-editor]');\n const editorRect = editor.getBoundingClientRect();\n const top = domNodeRect.top - editorRect.top;\n const left = domNodeRect.left - editorRect.left;\n\n this.setState({\n markup: choice.label,\n toolbarStyle: {\n position: 'absolute',\n top: `${top + domNodeRect.height + 20}px`,\n left: `${left + 20}px`,\n width: domNodeRect.width,\n },\n });\n }\n }\n\n onDone = () => {\n const { markup: newValue } = this.state;\n const { node, nodePath, editor, onToolbarDone, onChangeResponse } = this.props;\n const update = { ...node.data, value: newValue };\n\n editor.apply({\n type: 'set_node',\n path: nodePath,\n properties: {\n data: node.data\n },\n newProperties: { data: update }\n });\n\n onToolbarDone(true);\n onChangeResponse(newValue);\n };\n\n onChange = (e) => this.setState({ markup: e.target.value });\n\n render() {\n const { classes, node } = this.props;\n const { markup, toolbarStyle } = this.state;\n\n return (\n <div\n style={{\n ...toolbarStyle,\n backgroundColor: '#E0E1E6',\n }}\n >\n <OutlinedInput\n style={{ width: '100%' }}\n autoFocus\n labelWidth={0}\n classes={{\n input: classes.input,\n }}\n onChange={this.onChange}\n onBlur={this.onDone}\n value={markup || node?.data?.value || ''}\n />\n </div>\n );\n }\n}\n\nconst StyledECRToolbar = withStyles({\n respArea: {\n backgroundColor: '#fff',\n },\n input: {\n backgroundColor: '#fff',\n padding: '10px 20px 10px 10px',\n },\n errorInput: {\n border: '2px solid red',\n },\n})(ECRToolbar);\n\nexport default StyledECRToolbar;\n"],"file":"ecr-toolbar.js"}
|
package/configure/lib/index.js
CHANGED
|
@@ -41,13 +41,13 @@ var _defaults2 = _interopRequireDefault(require("./defaults"));
|
|
|
41
41
|
|
|
42
42
|
var _markupUtils = require("./markupUtils");
|
|
43
43
|
|
|
44
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
44
|
+
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; }
|
|
45
45
|
|
|
46
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
46
|
+
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; }
|
|
47
47
|
|
|
48
48
|
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); }; }
|
|
49
49
|
|
|
50
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
50
|
+
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; } }
|
|
51
51
|
|
|
52
52
|
var log = (0, _debug["default"])('explicit-constructed-response:configure');
|
|
53
53
|
|
|
@@ -123,6 +123,16 @@ var ExplicitConstructedResponse = /*#__PURE__*/function (_HTMLElement) {
|
|
|
123
123
|
value: function onDeleteImage(src, done) {
|
|
124
124
|
this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
|
|
125
125
|
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "insertSound",
|
|
128
|
+
value: function insertSound(handler) {
|
|
129
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "onDeleteSound",
|
|
133
|
+
value: function onDeleteSound(src, done) {
|
|
134
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
135
|
+
}
|
|
126
136
|
}, {
|
|
127
137
|
key: "_render",
|
|
128
138
|
value: function _render() {
|
|
@@ -137,6 +147,10 @@ var ExplicitConstructedResponse = /*#__PURE__*/function (_HTMLElement) {
|
|
|
137
147
|
imageSupport: {
|
|
138
148
|
add: this.insertImage.bind(this),
|
|
139
149
|
"delete": this.onDeleteImage.bind(this)
|
|
150
|
+
},
|
|
151
|
+
uploadSoundSupport: {
|
|
152
|
+
add: this.insertSound.bind(this),
|
|
153
|
+
"delete": this.onDeleteSound.bind(this)
|
|
140
154
|
}
|
|
141
155
|
});
|
|
142
156
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","ExplicitConstructedResponse","_model","prepareModel","_configuration","sensibleDefaults","configuration","onModelChanged","bind","onConfigurationChanged","s","_render","c","_disableSidePanel","reset","resetValue","dispatchEvent","ModelUpdatedEvent","m","dispatchModelUpdated","handler","InsertImageEvent","src","done","DeleteImageEvent","element","React","createElement","Main","model","disableSidePanel","imageSupport","add","insertImage","onDeleteImage","ReactDOM","render","HTMLElement","joinedObj","slateMarkup","markup","choices","processedMarkup","Object","keys","forEach","key","map","item","index","value"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","ExplicitConstructedResponse","_model","prepareModel","_configuration","sensibleDefaults","configuration","onModelChanged","bind","onConfigurationChanged","s","_render","c","_disableSidePanel","reset","resetValue","dispatchEvent","ModelUpdatedEvent","m","dispatchModelUpdated","handler","InsertImageEvent","src","done","DeleteImageEvent","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Main","model","disableSidePanel","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement","joinedObj","slateMarkup","markup","choices","processedMarkup","Object","keys","forEach","key","map","item","index","value"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,yCAAN,CAAZ;;IAEqBC,2B;;;;;AAiCnB,yCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAcD,2BAA2B,CAACE,YAA5B,EAAd;AACA,UAAKC,cAAL,GAAsBC,sBAAiBC,aAAvC;AACA,UAAKC,cAAL,GAAsB,MAAKA,cAAL,CAAoBC,IAApB,gDAAtB;AACA,UAAKC,sBAAL,GAA8B,MAAKA,sBAAL,C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AA/B,CAAuC,UAACC,GAAD,EAAS;AAC9C,UAAI,yBAAQR,SAAS,CAACG,OAAV,CAAkBK,GAAlB,CAAR,CAAJ,EAAqC;AACnCR,QAAAA,SAAS,CAACG,OAAV,CAAkBK,GAAlB,IAAyB,CAACR,SAAS,CAACG,OAAV,CAAkBK,GAAlB,KAA0B,EAA3B,EAA+BC,GAA/B,CAAmC,UAACC,IAAD,EAAOC,KAAP,EAAiB;AAC3E,cAAI,CAACD,IAAI,CAACE,KAAV,EAAiB;AACfvD,YAAAA,GAAG,CAAC,8DAAD,EAAiEqD,IAAjE,CAAH;AACA;AAASE,cAAAA,KAAK,YAAKD,KAAL;AAAd,eAA+BD,IAA/B;AACD;;AAED,iBAAOA,IAAP;AACD,SAPwB,CAAzB;AAQD;AACF,KAXD;AAYD;;AAED,yCACKV,SADL;AAEEC,IAAAA,WAAW,EAAXA,WAFF;AAGEC,IAAAA,MAAM,EAAEE;AAHV;AAKD,C","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debug from 'debug';\nimport defaults from 'lodash/defaults';\nimport isArray from 'lodash/isArray';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Main from './main';\n\nimport sensibleDefaults from './defaults';\nimport { processMarkup, createSlateMarkup } from './markupUtils';\n\nconst log = debug('explicit-constructed-response:configure');\n\nexport default class ExplicitConstructedResponse extends HTMLElement {\n static prepareModel = (model = {}) => {\n const joinedObj = {\n ...sensibleDefaults.model,\n ...model,\n };\n const slateMarkup = joinedObj.slateMarkup || createSlateMarkup(joinedObj.markup, joinedObj.choices);\n const processedMarkup = processMarkup(slateMarkup);\n\n // this was added to treat an exception, when the model has choices without the \"value\" property\n // like: { label: 'test' }\n if (joinedObj.choices) {\n Object.keys(joinedObj.choices).forEach((key) => {\n if (isArray(joinedObj.choices[key])) {\n joinedObj.choices[key] = (joinedObj.choices[key] || []).map((item, index) => {\n if (!item.value) {\n log('Choice does not contain \"value\" property, which is required.', item);\n return { value: `${index}`, ...item };\n }\n\n return item;\n });\n }\n });\n }\n\n return {\n ...joinedObj,\n slateMarkup,\n markup: processedMarkup,\n };\n };\n\n constructor() {\n super();\n this._model = ExplicitConstructedResponse.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(s) {\n this._model = ExplicitConstructedResponse.prepareModel(s);\n this._render();\n }\n\n set configuration(c) {\n this._configuration = defaults(c, sensibleDefaults.configuration);\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 = ExplicitConstructedResponse.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 ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
|
package/configure/lib/main.js
CHANGED
|
@@ -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
|
-
|
|
56
|
+
var _markupUtils = require("./markupUtils");
|
|
57
|
+
|
|
58
|
+
var _utils = require("./utils");
|
|
47
59
|
|
|
48
|
-
function
|
|
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 {
|
|
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;
|
|
@@ -90,9 +108,23 @@ var styles = function styles(theme) {
|
|
|
90
108
|
text: {
|
|
91
109
|
color: '#495B8F',
|
|
92
110
|
fontFamily: 'Cerebri Sans',
|
|
93
|
-
fontSize:
|
|
111
|
+
fontSize: theme.typography.fontSize + 2,
|
|
94
112
|
lineHeight: '19px',
|
|
95
113
|
marginTop: theme.spacing.unit * 4
|
|
114
|
+
},
|
|
115
|
+
tooltip: {
|
|
116
|
+
fontSize: theme.typography.fontSize - 2,
|
|
117
|
+
whiteSpace: 'pre',
|
|
118
|
+
maxWidth: '500px'
|
|
119
|
+
},
|
|
120
|
+
errorText: {
|
|
121
|
+
fontSize: theme.typography.fontSize - 2,
|
|
122
|
+
color: 'red',
|
|
123
|
+
paddingTop: theme.spacing.unit
|
|
124
|
+
},
|
|
125
|
+
flexContainer: {
|
|
126
|
+
display: 'flex',
|
|
127
|
+
alignItems: 'end'
|
|
96
128
|
}
|
|
97
129
|
};
|
|
98
130
|
};
|
|
@@ -150,89 +182,229 @@ 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
|
|
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
|
-
|
|
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
|
-
|
|
166
|
-
|
|
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
|
|
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
|
|
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[
|
|
244
|
+
allChoices[index] = newChoices;
|
|
245
|
+
el.dataset.index = index;
|
|
188
246
|
});
|
|
189
247
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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.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
|
|
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$
|
|
212
|
-
classes = _this$
|
|
213
|
-
model = _this$
|
|
214
|
-
configuration = _this$
|
|
215
|
-
onConfigurationChanged = _this$
|
|
216
|
-
imageSupport = _this$
|
|
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,
|
|
346
|
+
uploadSoundSupport = _this$props7.uploadSoundSupport;
|
|
217
347
|
|
|
218
348
|
var _ref = configuration || {},
|
|
219
|
-
_ref$
|
|
220
|
-
|
|
349
|
+
_ref$maxImageWidth = _ref.maxImageWidth,
|
|
350
|
+
maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
|
|
351
|
+
_ref$maxImageHeight = _ref.maxImageHeight,
|
|
352
|
+
maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
|
|
353
|
+
_ref$maxLengthPerChoi = _ref.maxLengthPerChoice,
|
|
354
|
+
maxLengthPerChoice = _ref$maxLengthPerChoi === void 0 ? {} : _ref$maxLengthPerChoi,
|
|
355
|
+
maxResponseAreas = _ref.maxResponseAreas,
|
|
221
356
|
_ref$partialScoring = _ref.partialScoring,
|
|
222
357
|
partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
|
|
358
|
+
_ref$playerSpellCheck = _ref.playerSpellCheck,
|
|
359
|
+
playerSpellCheck = _ref$playerSpellCheck === void 0 ? {} : _ref$playerSpellCheck,
|
|
360
|
+
_ref$prompt = _ref.prompt,
|
|
361
|
+
prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
|
|
223
362
|
_ref$rationale = _ref.rationale,
|
|
224
363
|
rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
|
|
364
|
+
settingsPanelDisabled = _ref.settingsPanelDisabled,
|
|
365
|
+
_ref$spellCheck = _ref.spellCheck,
|
|
366
|
+
spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
|
|
225
367
|
_ref$teacherInstructi = _ref.teacherInstructions,
|
|
226
|
-
teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi
|
|
368
|
+
teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
|
|
369
|
+
_ref$withRubric = _ref.withRubric,
|
|
370
|
+
withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric;
|
|
227
371
|
|
|
228
372
|
var _ref2 = model || {},
|
|
229
|
-
|
|
373
|
+
errors = _ref2.errors,
|
|
374
|
+
maxLengthPerChoiceEnabled = _ref2.maxLengthPerChoiceEnabled,
|
|
230
375
|
promptEnabled = _ref2.promptEnabled,
|
|
231
|
-
rationaleEnabled = _ref2.rationaleEnabled
|
|
232
|
-
|
|
376
|
+
rationaleEnabled = _ref2.rationaleEnabled,
|
|
377
|
+
spellCheckEnabled = _ref2.spellCheckEnabled,
|
|
378
|
+
teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
|
|
379
|
+
toolbarEditorPosition = _ref2.toolbarEditorPosition;
|
|
380
|
+
|
|
381
|
+
var _ref3 = errors || {},
|
|
382
|
+
_ref3$choicesErrors = _ref3.choicesErrors,
|
|
383
|
+
choicesErrors = _ref3$choicesErrors === void 0 ? {} : _ref3$choicesErrors,
|
|
384
|
+
responseAreasError = _ref3.responseAreasError;
|
|
385
|
+
|
|
386
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
387
|
+
var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
388
|
+
var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
389
|
+
var toolbarOpts = {
|
|
390
|
+
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
391
|
+
};
|
|
392
|
+
var panelSettings = {
|
|
393
|
+
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
394
|
+
maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label)
|
|
395
|
+
};
|
|
396
|
+
var panelProperties = {
|
|
397
|
+
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
398
|
+
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
399
|
+
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
400
|
+
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
401
|
+
playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label),
|
|
402
|
+
rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
|
|
403
|
+
};
|
|
233
404
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
234
405
|
className: classes.design
|
|
235
406
|
}, /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
|
|
407
|
+
hideSettings: settingsPanelDisabled,
|
|
236
408
|
settings: /*#__PURE__*/_react["default"].createElement(Panel, {
|
|
237
409
|
model: model,
|
|
238
410
|
configuration: configuration,
|
|
@@ -243,14 +415,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
243
415
|
return onConfigurationChanged(configuration, true);
|
|
244
416
|
},
|
|
245
417
|
groups: {
|
|
246
|
-
Settings:
|
|
247
|
-
|
|
248
|
-
},
|
|
249
|
-
Properties: {
|
|
250
|
-
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
251
|
-
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
252
|
-
promptEnabled: prompt.settings && toggle(prompt.label)
|
|
253
|
-
}
|
|
418
|
+
Settings: panelSettings,
|
|
419
|
+
Properties: panelProperties
|
|
254
420
|
}
|
|
255
421
|
})
|
|
256
422
|
}, /*#__PURE__*/_react["default"].createElement("div", null, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
@@ -261,7 +427,17 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
261
427
|
markup: model.teacherInstructions || '',
|
|
262
428
|
onChange: this.onTeacherInstructionsChanged,
|
|
263
429
|
imageSupport: imageSupport,
|
|
264
|
-
nonEmpty: false
|
|
430
|
+
nonEmpty: false,
|
|
431
|
+
toolbarOpts: toolbarOpts,
|
|
432
|
+
spellCheck: spellCheckEnabled,
|
|
433
|
+
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
434
|
+
maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
|
|
435
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
436
|
+
languageCharactersProps: [{
|
|
437
|
+
language: 'spanish'
|
|
438
|
+
}, {
|
|
439
|
+
language: 'special'
|
|
440
|
+
}]
|
|
265
441
|
})), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
266
442
|
label: prompt.label,
|
|
267
443
|
className: classes.promptHolder
|
|
@@ -271,47 +447,94 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
271
447
|
onChange: this.onPromptChanged,
|
|
272
448
|
imageSupport: imageSupport,
|
|
273
449
|
nonEmpty: false,
|
|
274
|
-
disableUnderline: true
|
|
275
|
-
|
|
450
|
+
disableUnderline: true,
|
|
451
|
+
toolbarOpts: toolbarOpts,
|
|
452
|
+
spellCheck: spellCheckEnabled,
|
|
453
|
+
maxImageWidth: defaultImageMaxWidth,
|
|
454
|
+
maxImageHeight: defaultImageMaxHeight,
|
|
455
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
456
|
+
languageCharactersProps: [{
|
|
457
|
+
language: 'spanish'
|
|
458
|
+
}, {
|
|
459
|
+
language: 'special'
|
|
460
|
+
}]
|
|
461
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
462
|
+
className: classes.flexContainer
|
|
463
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
276
464
|
className: classes.text
|
|
277
|
-
}, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(
|
|
465
|
+
}, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
466
|
+
classes: {
|
|
467
|
+
tooltip: classes.tooltip
|
|
468
|
+
},
|
|
469
|
+
disableFocusListener: true,
|
|
470
|
+
disableTouchListener: true,
|
|
471
|
+
placement: 'right',
|
|
472
|
+
title: validationMessage
|
|
473
|
+
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
474
|
+
fontSize: 'small',
|
|
475
|
+
color: 'primary',
|
|
476
|
+
style: {
|
|
477
|
+
marginLeft: '8px'
|
|
478
|
+
}
|
|
479
|
+
}))), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
278
480
|
activePlugins: _editableHtml.ALL_PLUGINS,
|
|
279
481
|
toolbarOpts: {
|
|
280
482
|
position: 'top'
|
|
281
483
|
},
|
|
484
|
+
spellCheck: spellCheckEnabled,
|
|
282
485
|
responseAreaProps: {
|
|
283
486
|
type: 'explicit-constructed-response',
|
|
284
487
|
options: {
|
|
285
488
|
duplicates: true
|
|
286
489
|
},
|
|
287
|
-
|
|
490
|
+
maxResponseAreas: maxResponseAreas,
|
|
491
|
+
respAreaToolbar: function respAreaToolbar(node, nodePath, editor, onToolbarDone) {
|
|
288
492
|
var model = _this2.props.model;
|
|
289
|
-
var correctChoice = (model.choices[node.data.
|
|
493
|
+
var correctChoice = (model.choices[node.data.index] || [])[0];
|
|
290
494
|
return function () {
|
|
291
495
|
return /*#__PURE__*/_react["default"].createElement(_ecrToolbar["default"], {
|
|
292
496
|
onChangeResponse: function onChangeResponse(newVal) {
|
|
293
|
-
return _this2.onChangeResponse(node.data.
|
|
497
|
+
return _this2.onChangeResponse(node.data.index, newVal);
|
|
294
498
|
},
|
|
295
499
|
node: node,
|
|
296
|
-
|
|
500
|
+
nodePath: nodePath,
|
|
501
|
+
editor: editor,
|
|
297
502
|
onToolbarDone: onToolbarDone,
|
|
298
503
|
correctChoice: correctChoice
|
|
299
504
|
});
|
|
300
505
|
};
|
|
301
|
-
}
|
|
506
|
+
},
|
|
507
|
+
error: function error() {
|
|
508
|
+
return choicesErrors;
|
|
509
|
+
},
|
|
510
|
+
onHandleAreaChange: this.onHandleAreaChange
|
|
302
511
|
},
|
|
303
512
|
className: classes.markup,
|
|
304
513
|
markup: model.slateMarkup,
|
|
305
514
|
onChange: this.onChange,
|
|
306
515
|
imageSupport: imageSupport,
|
|
516
|
+
disableImageAlignmentButtons: true,
|
|
307
517
|
onBlur: this.onBlur,
|
|
308
518
|
disabled: false,
|
|
309
|
-
highlightShape: false
|
|
310
|
-
|
|
519
|
+
highlightShape: false,
|
|
520
|
+
error: responseAreasError,
|
|
521
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
522
|
+
languageCharactersProps: [{
|
|
523
|
+
language: 'spanish'
|
|
524
|
+
}, {
|
|
525
|
+
language: 'special'
|
|
526
|
+
}]
|
|
527
|
+
}), responseAreasError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
528
|
+
className: classes.errorText
|
|
529
|
+
}, responseAreasError), !(0, _isEmpty["default"])(model.choices) && /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
311
530
|
className: classes.text
|
|
312
|
-
}, "Define Alternates"), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
|
|
531
|
+
}, "Define Alternates ".concat(maxLengthPerChoiceEnabled ? 'and Character Limits' : '')), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
|
|
313
532
|
model: model,
|
|
314
|
-
onChange: this.onResponsesChanged
|
|
533
|
+
onChange: this.onResponsesChanged,
|
|
534
|
+
onLengthChange: this.onLengthChanged,
|
|
535
|
+
maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
|
|
536
|
+
spellCheck: spellCheckEnabled,
|
|
537
|
+
choicesErrors: choicesErrors
|
|
315
538
|
}), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
316
539
|
label: rationale.label,
|
|
317
540
|
className: classes.promptHolder
|
|
@@ -319,7 +542,17 @@ var Main = /*#__PURE__*/function (_React$Component) {
|
|
|
319
542
|
className: classes.prompt,
|
|
320
543
|
markup: model.rationale || '',
|
|
321
544
|
onChange: this.onRationaleChanged,
|
|
322
|
-
imageSupport: imageSupport
|
|
545
|
+
imageSupport: imageSupport,
|
|
546
|
+
toolbarOpts: toolbarOpts,
|
|
547
|
+
spellCheck: spellCheckEnabled,
|
|
548
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
549
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
550
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
551
|
+
languageCharactersProps: [{
|
|
552
|
+
language: 'spanish'
|
|
553
|
+
}, {
|
|
554
|
+
language: 'special'
|
|
555
|
+
}]
|
|
323
556
|
})))));
|
|
324
557
|
}
|
|
325
558
|
}]);
|