@pie-element/select-text 11.0.5-esm.0 → 11.1.0
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 +8 -0
- package/configure/CHANGELOG.md +8 -0
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +8 -0
- package/controller/package.json +3 -3
- package/package.json +8 -26
- package/esm/configure.css +0 -847
- package/esm/configure.js +0 -1147
- package/esm/configure.js.map +0 -1
- package/esm/controller.css +0 -847
- package/esm/controller.js +0 -227
- package/esm/controller.js.map +0 -1
- package/esm/element.css +0 -847
- package/esm/element.js +0 -399
- package/esm/element.js.map +0 -1
- package/esm/print.css +0 -847
- package/esm/print.js +0 -376
- package/esm/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -1967
- package/module/demo.js +0 -301
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -10
- package/module/print-demo.js +0 -339
- package/module/print.html +0 -18
- package/module/print.js +0 -1
package/esm/configure.js
DELETED
|
@@ -1,1147 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import TextField from '@material-ui/core/TextField';
|
|
5
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
6
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
7
|
-
import debounce from 'lodash/debounce';
|
|
8
|
-
import { Tokenizer } from '@pie-lib/text-select';
|
|
9
|
-
import { layout, InputContainer, NumberTextField, FeedbackConfig, settings } from '@pie-lib/config-ui';
|
|
10
|
-
import Chip from '@material-ui/core/Chip';
|
|
11
|
-
import require$$3 from '@material-ui/core/SvgIcon';
|
|
12
|
-
import debug from 'debug';
|
|
13
|
-
import EditableHtml from '@pie-lib/editable-html';
|
|
14
|
-
import Tooltip from '@material-ui/core/Tooltip';
|
|
15
|
-
import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
|
|
16
|
-
|
|
17
|
-
function _extends() {
|
|
18
|
-
_extends = Object.assign || function (target) {
|
|
19
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
20
|
-
var source = arguments[i];
|
|
21
|
-
|
|
22
|
-
for (var key in source) {
|
|
23
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
24
|
-
target[key] = source[key];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return target;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return _extends.apply(this, arguments);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var Info = {};
|
|
36
|
-
|
|
37
|
-
var interopRequireDefault = {exports: {}};
|
|
38
|
-
|
|
39
|
-
(function (module) {
|
|
40
|
-
function _interopRequireDefault(obj) {
|
|
41
|
-
return obj && obj.__esModule ? obj : {
|
|
42
|
-
"default": obj
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
47
|
-
}(interopRequireDefault));
|
|
48
|
-
|
|
49
|
-
var createSvgIcon$1 = {};
|
|
50
|
-
|
|
51
|
-
var pure$1 = {};
|
|
52
|
-
|
|
53
|
-
var shouldUpdate$1 = {};
|
|
54
|
-
|
|
55
|
-
var inheritsLoose = {exports: {}};
|
|
56
|
-
|
|
57
|
-
var setPrototypeOf = {exports: {}};
|
|
58
|
-
|
|
59
|
-
(function (module) {
|
|
60
|
-
function _setPrototypeOf(o, p) {
|
|
61
|
-
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
62
|
-
o.__proto__ = p;
|
|
63
|
-
return o;
|
|
64
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
65
|
-
return _setPrototypeOf(o, p);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
69
|
-
}(setPrototypeOf));
|
|
70
|
-
|
|
71
|
-
(function (module) {
|
|
72
|
-
var setPrototypeOf$1 = setPrototypeOf.exports;
|
|
73
|
-
|
|
74
|
-
function _inheritsLoose(subClass, superClass) {
|
|
75
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
76
|
-
subClass.prototype.constructor = subClass;
|
|
77
|
-
setPrototypeOf$1(subClass, superClass);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = _inheritsLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
81
|
-
}(inheritsLoose));
|
|
82
|
-
|
|
83
|
-
var setDisplayName$1 = {};
|
|
84
|
-
|
|
85
|
-
var setStatic$1 = {};
|
|
86
|
-
|
|
87
|
-
setStatic$1.__esModule = true;
|
|
88
|
-
setStatic$1.default = void 0;
|
|
89
|
-
|
|
90
|
-
var setStatic = function setStatic(key, value) {
|
|
91
|
-
return function (BaseComponent) {
|
|
92
|
-
/* eslint-disable no-param-reassign */
|
|
93
|
-
BaseComponent[key] = value;
|
|
94
|
-
/* eslint-enable no-param-reassign */
|
|
95
|
-
|
|
96
|
-
return BaseComponent;
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
var _default$8 = setStatic;
|
|
101
|
-
setStatic$1.default = _default$8;
|
|
102
|
-
|
|
103
|
-
var _interopRequireDefault$6 = interopRequireDefault.exports;
|
|
104
|
-
|
|
105
|
-
setDisplayName$1.__esModule = true;
|
|
106
|
-
setDisplayName$1.default = void 0;
|
|
107
|
-
|
|
108
|
-
var _setStatic = _interopRequireDefault$6(setStatic$1);
|
|
109
|
-
|
|
110
|
-
var setDisplayName = function setDisplayName(displayName) {
|
|
111
|
-
return (0, _setStatic.default)('displayName', displayName);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
var _default$7 = setDisplayName;
|
|
115
|
-
setDisplayName$1.default = _default$7;
|
|
116
|
-
|
|
117
|
-
var wrapDisplayName$1 = {};
|
|
118
|
-
|
|
119
|
-
var getDisplayName$1 = {};
|
|
120
|
-
|
|
121
|
-
getDisplayName$1.__esModule = true;
|
|
122
|
-
getDisplayName$1.default = void 0;
|
|
123
|
-
|
|
124
|
-
var getDisplayName = function getDisplayName(Component) {
|
|
125
|
-
if (typeof Component === 'string') {
|
|
126
|
-
return Component;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (!Component) {
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return Component.displayName || Component.name || 'Component';
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
var _default$6 = getDisplayName;
|
|
137
|
-
getDisplayName$1.default = _default$6;
|
|
138
|
-
|
|
139
|
-
var _interopRequireDefault$5 = interopRequireDefault.exports;
|
|
140
|
-
|
|
141
|
-
wrapDisplayName$1.__esModule = true;
|
|
142
|
-
wrapDisplayName$1.default = void 0;
|
|
143
|
-
|
|
144
|
-
var _getDisplayName = _interopRequireDefault$5(getDisplayName$1);
|
|
145
|
-
|
|
146
|
-
var wrapDisplayName = function wrapDisplayName(BaseComponent, hocName) {
|
|
147
|
-
return hocName + "(" + (0, _getDisplayName.default)(BaseComponent) + ")";
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
var _default$5 = wrapDisplayName;
|
|
151
|
-
wrapDisplayName$1.default = _default$5;
|
|
152
|
-
|
|
153
|
-
var _interopRequireDefault$4 = interopRequireDefault.exports;
|
|
154
|
-
|
|
155
|
-
shouldUpdate$1.__esModule = true;
|
|
156
|
-
shouldUpdate$1.default = void 0;
|
|
157
|
-
|
|
158
|
-
var _inheritsLoose2 = _interopRequireDefault$4(inheritsLoose.exports);
|
|
159
|
-
|
|
160
|
-
var _react$2 = React;
|
|
161
|
-
|
|
162
|
-
var _setDisplayName$1 = _interopRequireDefault$4(setDisplayName$1);
|
|
163
|
-
|
|
164
|
-
var _wrapDisplayName$1 = _interopRequireDefault$4(wrapDisplayName$1);
|
|
165
|
-
|
|
166
|
-
var shouldUpdate = function shouldUpdate(test) {
|
|
167
|
-
return function (BaseComponent) {
|
|
168
|
-
var factory = (0, _react$2.createFactory)(BaseComponent);
|
|
169
|
-
|
|
170
|
-
var ShouldUpdate =
|
|
171
|
-
/*#__PURE__*/
|
|
172
|
-
function (_Component) {
|
|
173
|
-
(0, _inheritsLoose2.default)(ShouldUpdate, _Component);
|
|
174
|
-
|
|
175
|
-
function ShouldUpdate() {
|
|
176
|
-
return _Component.apply(this, arguments) || this;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
var _proto = ShouldUpdate.prototype;
|
|
180
|
-
|
|
181
|
-
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
182
|
-
return test(this.props, nextProps);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
_proto.render = function render() {
|
|
186
|
-
return factory(this.props);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
return ShouldUpdate;
|
|
190
|
-
}(_react$2.Component);
|
|
191
|
-
|
|
192
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
193
|
-
return (0, _setDisplayName$1.default)((0, _wrapDisplayName$1.default)(BaseComponent, 'shouldUpdate'))(ShouldUpdate);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return ShouldUpdate;
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
var _default$4 = shouldUpdate;
|
|
201
|
-
shouldUpdate$1.default = _default$4;
|
|
202
|
-
|
|
203
|
-
var shallowEqual$1 = {};
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
207
|
-
*
|
|
208
|
-
* This source code is licensed under the MIT license found in the
|
|
209
|
-
* LICENSE file in the root directory of this source tree.
|
|
210
|
-
*
|
|
211
|
-
* @typechecks
|
|
212
|
-
*
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
219
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
220
|
-
*/
|
|
221
|
-
function is(x, y) {
|
|
222
|
-
// SameValue algorithm
|
|
223
|
-
if (x === y) {
|
|
224
|
-
// Steps 1-5, 7-10
|
|
225
|
-
// Steps 6.b-6.e: +0 != -0
|
|
226
|
-
// Added the nonzero y check to make Flow happy, but it is redundant
|
|
227
|
-
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
228
|
-
} else {
|
|
229
|
-
// Step 6.a: NaN == NaN
|
|
230
|
-
return x !== x && y !== y;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Performs equality by iterating through keys on an object and returning false
|
|
236
|
-
* when any key has values which are not strictly equal between the arguments.
|
|
237
|
-
* Returns true when the values of all keys are strictly equal.
|
|
238
|
-
*/
|
|
239
|
-
function shallowEqual(objA, objB) {
|
|
240
|
-
if (is(objA, objB)) {
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
var keysA = Object.keys(objA);
|
|
249
|
-
var keysB = Object.keys(objB);
|
|
250
|
-
|
|
251
|
-
if (keysA.length !== keysB.length) {
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Test for A's keys different from B.
|
|
256
|
-
for (var i = 0; i < keysA.length; i++) {
|
|
257
|
-
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
var shallowEqual_1 = shallowEqual;
|
|
266
|
-
|
|
267
|
-
var _interopRequireDefault$3 = interopRequireDefault.exports;
|
|
268
|
-
|
|
269
|
-
shallowEqual$1.__esModule = true;
|
|
270
|
-
shallowEqual$1.default = void 0;
|
|
271
|
-
|
|
272
|
-
var _shallowEqual$1 = _interopRequireDefault$3(shallowEqual_1);
|
|
273
|
-
|
|
274
|
-
var _default$3 = _shallowEqual$1.default;
|
|
275
|
-
shallowEqual$1.default = _default$3;
|
|
276
|
-
|
|
277
|
-
var _interopRequireDefault$2 = interopRequireDefault.exports;
|
|
278
|
-
|
|
279
|
-
pure$1.__esModule = true;
|
|
280
|
-
pure$1.default = void 0;
|
|
281
|
-
|
|
282
|
-
var _shouldUpdate = _interopRequireDefault$2(shouldUpdate$1);
|
|
283
|
-
|
|
284
|
-
var _shallowEqual = _interopRequireDefault$2(shallowEqual$1);
|
|
285
|
-
|
|
286
|
-
var _setDisplayName = _interopRequireDefault$2(setDisplayName$1);
|
|
287
|
-
|
|
288
|
-
var _wrapDisplayName = _interopRequireDefault$2(wrapDisplayName$1);
|
|
289
|
-
|
|
290
|
-
var pure = function pure(BaseComponent) {
|
|
291
|
-
var hoc = (0, _shouldUpdate.default)(function (props, nextProps) {
|
|
292
|
-
return !(0, _shallowEqual.default)(props, nextProps);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
296
|
-
return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'pure'))(hoc(BaseComponent));
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return hoc(BaseComponent);
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
var _default$2 = pure;
|
|
303
|
-
pure$1.default = _default$2;
|
|
304
|
-
|
|
305
|
-
var _interopRequireDefault$1 = interopRequireDefault.exports;
|
|
306
|
-
|
|
307
|
-
Object.defineProperty(createSvgIcon$1, "__esModule", {
|
|
308
|
-
value: true
|
|
309
|
-
});
|
|
310
|
-
createSvgIcon$1.default = void 0;
|
|
311
|
-
|
|
312
|
-
var _react$1 = _interopRequireDefault$1(React);
|
|
313
|
-
|
|
314
|
-
var _pure = _interopRequireDefault$1(pure$1);
|
|
315
|
-
|
|
316
|
-
var _SvgIcon = _interopRequireDefault$1(require$$3);
|
|
317
|
-
|
|
318
|
-
function createSvgIcon(path, displayName) {
|
|
319
|
-
var Icon = function Icon(props) {
|
|
320
|
-
return _react$1.default.createElement(_SvgIcon.default, props, path);
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
Icon.displayName = "".concat(displayName, "Icon");
|
|
324
|
-
Icon = (0, _pure.default)(Icon);
|
|
325
|
-
Icon.muiName = 'SvgIcon';
|
|
326
|
-
return Icon;
|
|
327
|
-
}
|
|
328
|
-
var _default$1 = createSvgIcon;
|
|
329
|
-
createSvgIcon$1.default = _default$1;
|
|
330
|
-
|
|
331
|
-
var _interopRequireDefault = interopRequireDefault.exports;
|
|
332
|
-
|
|
333
|
-
Object.defineProperty(Info, "__esModule", {
|
|
334
|
-
value: true
|
|
335
|
-
});
|
|
336
|
-
var default_1 = Info.default = void 0;
|
|
337
|
-
|
|
338
|
-
var _react = _interopRequireDefault(React);
|
|
339
|
-
|
|
340
|
-
var _createSvgIcon = _interopRequireDefault(createSvgIcon$1);
|
|
341
|
-
|
|
342
|
-
var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
|
|
343
|
-
fill: "none",
|
|
344
|
-
d: "M0 0h24v24H0z"
|
|
345
|
-
}), _react.default.createElement("path", {
|
|
346
|
-
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"
|
|
347
|
-
})), 'Info');
|
|
348
|
-
|
|
349
|
-
default_1 = Info.default = _default;
|
|
350
|
-
|
|
351
|
-
var createElementFromHTML = function createElementFromHTML() {
|
|
352
|
-
var htmlString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
353
|
-
var div = document.createElement('div');
|
|
354
|
-
div.innerHTML = htmlString.trim();
|
|
355
|
-
return div;
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
var parseParagraph = function parseParagraph(paragraph, end) {
|
|
359
|
-
if (end) {
|
|
360
|
-
return paragraph.innerHTML;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return ''.concat(paragraph.innerHTML, '\n\n');
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
var parseParagraphs = function parseParagraphs(dom) {
|
|
367
|
-
var paragraphs = dom.querySelectorAll('div[separator=true]'); // separate variable for easily debugging, if needed
|
|
368
|
-
|
|
369
|
-
var str = '';
|
|
370
|
-
paragraphs.forEach(function (par, index) {
|
|
371
|
-
str += parseParagraph(par, index === paragraphs.length - 1);
|
|
372
|
-
});
|
|
373
|
-
return str || null;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
var prepareText = function prepareText(text) {
|
|
377
|
-
var txtDom = createElementFromHTML(text);
|
|
378
|
-
var div = document.createElement('div');
|
|
379
|
-
div.innerHTML = "<div separator='true'>".concat(txtDom.innerHTML, '</div>');
|
|
380
|
-
txtDom = div;
|
|
381
|
-
var allDomElements = Array.from(txtDom.querySelectorAll('*'));
|
|
382
|
-
|
|
383
|
-
if (allDomElements.length === 0) {
|
|
384
|
-
return text;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return parseParagraphs(txtDom);
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
const generateModel = model => {
|
|
391
|
-
if (!model) return model; // parsing
|
|
392
|
-
|
|
393
|
-
const modelText = prepareText(model.text || '');
|
|
394
|
-
const newTokens = (model.tokens || []).reduce((acc, token = {}) => {
|
|
395
|
-
const tokenText = prepareText((model.text || '').slice(token.start, token.end));
|
|
396
|
-
|
|
397
|
-
if (!tokenText) {
|
|
398
|
-
return [...acc, token];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const getStartIndex = start => {
|
|
402
|
-
let length = start;
|
|
403
|
-
|
|
404
|
-
while (length >= 0) {
|
|
405
|
-
let newStartIndex = modelText.slice(length).indexOf(tokenText);
|
|
406
|
-
|
|
407
|
-
if (newStartIndex >= 0) {
|
|
408
|
-
return newStartIndex + length;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
length--;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
return 0;
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
const lastToken = acc[acc.length - 1];
|
|
418
|
-
const newStart = getStartIndex(lastToken ? lastToken.end : token.start);
|
|
419
|
-
const newEnd = newStart + tokenText.length;
|
|
420
|
-
return [...acc, _extends({}, token, {
|
|
421
|
-
text: tokenText,
|
|
422
|
-
start: newStart,
|
|
423
|
-
end: newEnd,
|
|
424
|
-
// needed for getScore when tokens position is recalculated
|
|
425
|
-
oldStart: token.start,
|
|
426
|
-
oldEnd: token.end
|
|
427
|
-
})];
|
|
428
|
-
}, []);
|
|
429
|
-
return _extends({}, model, {
|
|
430
|
-
tokens: newTokens,
|
|
431
|
-
text: modelText
|
|
432
|
-
});
|
|
433
|
-
};
|
|
434
|
-
const generateValidationMessage = config => {
|
|
435
|
-
const {
|
|
436
|
-
minTokens,
|
|
437
|
-
maxTokens,
|
|
438
|
-
maxSelections
|
|
439
|
-
} = config;
|
|
440
|
-
const tokensMessage = `\nThere should be at least ${minTokens} ` + (maxTokens ? `and at most ${maxTokens} ` : '') + 'tokens defined.';
|
|
441
|
-
const selectionsMessage = '\nThere should be at least 1 ' + (maxSelections ? `and at most ${maxSelections} ` : '') + 'token' + (maxSelections ? 's' : '') + ' selected.';
|
|
442
|
-
const message = 'Validation requirements:' + tokensMessage + selectionsMessage;
|
|
443
|
-
return message;
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
const {
|
|
447
|
-
Panel,
|
|
448
|
-
toggle,
|
|
449
|
-
radio,
|
|
450
|
-
dropdown
|
|
451
|
-
} = settings;
|
|
452
|
-
const log = debug('@pie-element:select-text:configure');
|
|
453
|
-
class Design extends React.Component {
|
|
454
|
-
constructor(props) {
|
|
455
|
-
super(props);
|
|
456
|
-
this.updateText = debounce(val => {
|
|
457
|
-
this.apply(u => {
|
|
458
|
-
u.text = val;
|
|
459
|
-
u.tokens = [];
|
|
460
|
-
});
|
|
461
|
-
}, 200);
|
|
462
|
-
|
|
463
|
-
this.changeText = event => this.updateText(event.target.value);
|
|
464
|
-
|
|
465
|
-
this.changeTokens = (tokens, mode) => {
|
|
466
|
-
this.apply(u => {
|
|
467
|
-
u.tokens = tokens;
|
|
468
|
-
u.mode = mode;
|
|
469
|
-
const correctTokenCount = tokens.filter(t => t.correct).length;
|
|
470
|
-
const max = isFinite(u.maxSelections) ? u.maxSelections : 0;
|
|
471
|
-
u.maxSelections = Math.max(max, correctTokenCount);
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
this.changeMaxSelections = (event, max) => {
|
|
476
|
-
this.apply(u => u.maxSelections = max);
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
this.apply = fn => {
|
|
480
|
-
const {
|
|
481
|
-
onModelChanged,
|
|
482
|
-
model
|
|
483
|
-
} = this.props;
|
|
484
|
-
const update = cloneDeep(model);
|
|
485
|
-
fn(update);
|
|
486
|
-
onModelChanged(update);
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
this.changeFeedback = feedback => {
|
|
490
|
-
this.apply(u => u.feedback = feedback);
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
this.changePartialScoring = partialScoring => {
|
|
494
|
-
const {
|
|
495
|
-
onModelChanged,
|
|
496
|
-
model
|
|
497
|
-
} = this.props;
|
|
498
|
-
const update = cloneDeep(model);
|
|
499
|
-
update.partialScoring = partialScoring;
|
|
500
|
-
onModelChanged(update);
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
this.onPromptChanged = prompt => {
|
|
504
|
-
const {
|
|
505
|
-
onModelChanged,
|
|
506
|
-
model
|
|
507
|
-
} = this.props;
|
|
508
|
-
const update = cloneDeep(model);
|
|
509
|
-
update.prompt = prompt;
|
|
510
|
-
onModelChanged(update);
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
this.onTeacherInstructionsChanged = teacherInstructions => {
|
|
514
|
-
const {
|
|
515
|
-
onModelChanged,
|
|
516
|
-
model
|
|
517
|
-
} = this.props;
|
|
518
|
-
const update = cloneDeep(model);
|
|
519
|
-
update.teacherInstructions = teacherInstructions;
|
|
520
|
-
onModelChanged(update);
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
this.onRationaleChanged = rationale => {
|
|
524
|
-
const {
|
|
525
|
-
onModelChanged,
|
|
526
|
-
model
|
|
527
|
-
} = this.props;
|
|
528
|
-
onModelChanged(_extends({}, model, {
|
|
529
|
-
rationale
|
|
530
|
-
}));
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
const {
|
|
534
|
-
model: _model
|
|
535
|
-
} = this.props;
|
|
536
|
-
this.state = {
|
|
537
|
-
text: _model && _model.text || ''
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
UNSAFE_componentWillReceiveProps(nProps) {
|
|
542
|
-
const {
|
|
543
|
-
model
|
|
544
|
-
} = nProps;
|
|
545
|
-
|
|
546
|
-
if (model && model.text) {
|
|
547
|
-
this.setState({
|
|
548
|
-
text: model.text
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
render() {
|
|
554
|
-
var _configuration$teache, _configuration$prompt, _configuration$ration;
|
|
555
|
-
|
|
556
|
-
const {
|
|
557
|
-
text: textValue
|
|
558
|
-
} = this.state;
|
|
559
|
-
const {
|
|
560
|
-
classes,
|
|
561
|
-
configuration,
|
|
562
|
-
imageSupport,
|
|
563
|
-
model,
|
|
564
|
-
onConfigurationChanged,
|
|
565
|
-
onModelChanged,
|
|
566
|
-
uploadSoundSupport
|
|
567
|
-
} = this.props;
|
|
568
|
-
const {
|
|
569
|
-
baseInputConfiguration = {},
|
|
570
|
-
correctAnswer = {},
|
|
571
|
-
contentDimensions = {},
|
|
572
|
-
feedback = {},
|
|
573
|
-
highlightChoices = {},
|
|
574
|
-
mode = {},
|
|
575
|
-
partialScoring = {},
|
|
576
|
-
prompt = {},
|
|
577
|
-
rationale = {},
|
|
578
|
-
selectionCount = {},
|
|
579
|
-
selections = {},
|
|
580
|
-
settingsPanelDisabled,
|
|
581
|
-
scoringType = {},
|
|
582
|
-
spellCheck = {},
|
|
583
|
-
studentInstructions = {},
|
|
584
|
-
teacherInstructions = {},
|
|
585
|
-
text = {},
|
|
586
|
-
tokens = {},
|
|
587
|
-
maxImageWidth = {},
|
|
588
|
-
maxImageHeight = {},
|
|
589
|
-
withRubric = {},
|
|
590
|
-
mathMlOptions = {},
|
|
591
|
-
language = {},
|
|
592
|
-
languageChoices = {}
|
|
593
|
-
} = configuration || {};
|
|
594
|
-
const {
|
|
595
|
-
errors,
|
|
596
|
-
extraCSSRules,
|
|
597
|
-
feedbackEnabled,
|
|
598
|
-
promptEnabled,
|
|
599
|
-
rationaleEnabled,
|
|
600
|
-
spellCheckEnabled,
|
|
601
|
-
teacherInstructionsEnabled,
|
|
602
|
-
toolbarEditorPosition
|
|
603
|
-
} = model || {};
|
|
604
|
-
const {
|
|
605
|
-
prompt: promptError,
|
|
606
|
-
rationale: rationaleError,
|
|
607
|
-
selectionsError,
|
|
608
|
-
teacherInstructions: teacherInstructionsError,
|
|
609
|
-
tokensError
|
|
610
|
-
} = errors || {};
|
|
611
|
-
const validationMessage = generateValidationMessage(configuration);
|
|
612
|
-
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
613
|
-
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
614
|
-
let {
|
|
615
|
-
tokens: tokensModel
|
|
616
|
-
} = model;
|
|
617
|
-
tokensModel = tokensModel || [];
|
|
618
|
-
const toolbarOpts = {
|
|
619
|
-
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
620
|
-
};
|
|
621
|
-
log('[render] maxSelections:', model.maxSelections);
|
|
622
|
-
const panelSettings = {
|
|
623
|
-
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
624
|
-
highlightChoices: highlightChoices.settings && toggle(highlightChoices.label),
|
|
625
|
-
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
626
|
-
'language.enabled': language.settings && toggle(language.label, true),
|
|
627
|
-
language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
|
|
628
|
-
};
|
|
629
|
-
const panelProperties = {
|
|
630
|
-
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
631
|
-
studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
|
|
632
|
-
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
633
|
-
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
634
|
-
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
635
|
-
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
|
|
636
|
-
rubricEnabled: (withRubric == null ? void 0 : withRubric.settings) && toggle(withRubric == null ? void 0 : withRubric.label)
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
const getPluginProps = (props = {}) => _extends({}, baseInputConfiguration, props);
|
|
640
|
-
|
|
641
|
-
return /*#__PURE__*/React.createElement(layout.ConfigLayout, {
|
|
642
|
-
extraCSSRules: extraCSSRules,
|
|
643
|
-
dimensions: contentDimensions,
|
|
644
|
-
hideSettings: settingsPanelDisabled,
|
|
645
|
-
settings: /*#__PURE__*/React.createElement(Panel, {
|
|
646
|
-
model: model,
|
|
647
|
-
configuration: configuration,
|
|
648
|
-
onChangeModel: model => onModelChanged(model),
|
|
649
|
-
onChangeConfiguration: onConfigurationChanged,
|
|
650
|
-
groups: {
|
|
651
|
-
Settings: panelSettings,
|
|
652
|
-
Properties: panelProperties
|
|
653
|
-
}
|
|
654
|
-
})
|
|
655
|
-
}, teacherInstructionsEnabled && /*#__PURE__*/React.createElement(InputContainer, {
|
|
656
|
-
label: teacherInstructions.label,
|
|
657
|
-
className: classes.promptHolder
|
|
658
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
659
|
-
className: classes.prompt,
|
|
660
|
-
markup: model.teacherInstructions || '',
|
|
661
|
-
onChange: this.onTeacherInstructionsChanged,
|
|
662
|
-
imageSupport: imageSupport,
|
|
663
|
-
nonEmpty: false,
|
|
664
|
-
error: teacherInstructionsError,
|
|
665
|
-
toolbarOpts: toolbarOpts,
|
|
666
|
-
pluginProps: getPluginProps(configuration == null ? void 0 : (_configuration$teache = configuration.teacherInstructions) == null ? void 0 : _configuration$teache.inputConfiguration),
|
|
667
|
-
spellCheck: spellCheckEnabled,
|
|
668
|
-
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
669
|
-
maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
|
|
670
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
671
|
-
languageCharactersProps: [{
|
|
672
|
-
language: 'spanish'
|
|
673
|
-
}, {
|
|
674
|
-
language: 'special'
|
|
675
|
-
}],
|
|
676
|
-
mathMlOptions: mathMlOptions
|
|
677
|
-
}), teacherInstructionsError && /*#__PURE__*/React.createElement("div", {
|
|
678
|
-
className: classes.errorText
|
|
679
|
-
}, teacherInstructionsError)), promptEnabled && /*#__PURE__*/React.createElement(InputContainer, {
|
|
680
|
-
label: prompt.label || '',
|
|
681
|
-
className: classes.promptHolder
|
|
682
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
683
|
-
className: classes.prompt,
|
|
684
|
-
markup: model.prompt,
|
|
685
|
-
onChange: this.onPromptChanged,
|
|
686
|
-
imageSupport: imageSupport,
|
|
687
|
-
error: promptError,
|
|
688
|
-
toolbarOpts: toolbarOpts,
|
|
689
|
-
pluginProps: getPluginProps(configuration == null ? void 0 : (_configuration$prompt = configuration.prompt) == null ? void 0 : _configuration$prompt.inputConfiguration),
|
|
690
|
-
spellCheck: spellCheckEnabled,
|
|
691
|
-
maxImageWidth: defaultImageMaxWidth,
|
|
692
|
-
maxImageHeight: defaultImageMaxHeight,
|
|
693
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
694
|
-
languageCharactersProps: [{
|
|
695
|
-
language: 'spanish'
|
|
696
|
-
}, {
|
|
697
|
-
language: 'special'
|
|
698
|
-
}],
|
|
699
|
-
mathMlOptions: mathMlOptions
|
|
700
|
-
}), promptError && /*#__PURE__*/React.createElement("div", {
|
|
701
|
-
className: classes.errorText
|
|
702
|
-
}, promptError)), text.settings && /*#__PURE__*/React.createElement(InputContainer, {
|
|
703
|
-
label: text.label || '',
|
|
704
|
-
className: classes.promptHolder
|
|
705
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
706
|
-
className: classes.input,
|
|
707
|
-
multiline: true,
|
|
708
|
-
defaultValue: textValue,
|
|
709
|
-
onChange: this.changeText,
|
|
710
|
-
spellCheck: spellCheckEnabled
|
|
711
|
-
})), tokens.settings && /*#__PURE__*/React.createElement(InputContainer, {
|
|
712
|
-
label: tokens.label || '',
|
|
713
|
-
className: classes.tokenizerContainer
|
|
714
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
715
|
-
classes: {
|
|
716
|
-
tooltip: classes.tooltip
|
|
717
|
-
},
|
|
718
|
-
disableFocusListener: true,
|
|
719
|
-
disableTouchListener: true,
|
|
720
|
-
placement: 'right',
|
|
721
|
-
title: validationMessage
|
|
722
|
-
}, /*#__PURE__*/React.createElement(default_1, {
|
|
723
|
-
fontSize: 'small',
|
|
724
|
-
color: 'primary',
|
|
725
|
-
style: {
|
|
726
|
-
position: 'absolute',
|
|
727
|
-
left: '48px',
|
|
728
|
-
top: '-3px'
|
|
729
|
-
}
|
|
730
|
-
})), /*#__PURE__*/React.createElement(Tokenizer, {
|
|
731
|
-
className: classes.tokenizer,
|
|
732
|
-
text: model.text,
|
|
733
|
-
tokens: tokensModel,
|
|
734
|
-
onChange: this.changeTokens
|
|
735
|
-
})), tokensError && /*#__PURE__*/React.createElement("div", {
|
|
736
|
-
className: classes.errorText
|
|
737
|
-
}, tokensError), selectionsError && /*#__PURE__*/React.createElement("div", {
|
|
738
|
-
className: classes.errorText
|
|
739
|
-
}, selectionsError), /*#__PURE__*/React.createElement("div", {
|
|
740
|
-
className: classes.tokensDetails
|
|
741
|
-
}, mode.settings && /*#__PURE__*/React.createElement(Chip, {
|
|
742
|
-
label: `${mode.label}: ${model.mode ? model.mode : 'None'}`,
|
|
743
|
-
className: classes.chip
|
|
744
|
-
}), selections.settings && /*#__PURE__*/React.createElement(Chip, {
|
|
745
|
-
label: `${selections.label}: ${tokensModel.length}`,
|
|
746
|
-
className: classes.chip
|
|
747
|
-
}), correctAnswer.settings && /*#__PURE__*/React.createElement(Chip, {
|
|
748
|
-
label: `${correctAnswer.label}: ${tokensModel.filter(t => t.correct).length}`,
|
|
749
|
-
className: classes.chip
|
|
750
|
-
}), selectionCount.settings && /*#__PURE__*/React.createElement(NumberTextField, {
|
|
751
|
-
min: tokensModel.filter(t => t.correct).length || 0,
|
|
752
|
-
label: `${selectionCount.label} (0:any)`,
|
|
753
|
-
max: tokensModel.length,
|
|
754
|
-
value: model.maxSelections,
|
|
755
|
-
onChange: this.changeMaxSelections,
|
|
756
|
-
className: classes.numberField
|
|
757
|
-
})), rationaleEnabled && /*#__PURE__*/React.createElement(InputContainer, {
|
|
758
|
-
label: rationale.label || '',
|
|
759
|
-
className: classes.promptHolder
|
|
760
|
-
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
761
|
-
className: classes.prompt,
|
|
762
|
-
markup: model.rationale || '',
|
|
763
|
-
onChange: this.onRationaleChanged,
|
|
764
|
-
imageSupport: imageSupport,
|
|
765
|
-
error: rationaleError,
|
|
766
|
-
toolbarOpts: toolbarOpts,
|
|
767
|
-
pluginProps: getPluginProps(configuration == null ? void 0 : (_configuration$ration = configuration.rationale) == null ? void 0 : _configuration$ration.inputConfiguration),
|
|
768
|
-
spellCheck: spellCheckEnabled,
|
|
769
|
-
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
770
|
-
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
771
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
772
|
-
languageCharactersProps: [{
|
|
773
|
-
language: 'spanish'
|
|
774
|
-
}, {
|
|
775
|
-
language: 'special'
|
|
776
|
-
}],
|
|
777
|
-
mathMlOptions: mathMlOptions
|
|
778
|
-
}), rationaleError && /*#__PURE__*/React.createElement("div", {
|
|
779
|
-
className: classes.errorText
|
|
780
|
-
}, rationaleError)), feedbackEnabled && /*#__PURE__*/React.createElement(FeedbackConfig, {
|
|
781
|
-
feedback: model.feedback,
|
|
782
|
-
onChange: this.changeFeedback,
|
|
783
|
-
toolbarOpts: toolbarOpts
|
|
784
|
-
}));
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
Design.propTypes = {
|
|
789
|
-
model: PropTypes.object.isRequired,
|
|
790
|
-
configuration: PropTypes.object.isRequired,
|
|
791
|
-
classes: PropTypes.object.isRequired,
|
|
792
|
-
onModelChanged: PropTypes.func.isRequired,
|
|
793
|
-
onConfigurationChanged: PropTypes.func.isRequired,
|
|
794
|
-
imageSupport: PropTypes.shape({
|
|
795
|
-
add: PropTypes.func.isRequired,
|
|
796
|
-
delete: PropTypes.func.isRequired
|
|
797
|
-
}),
|
|
798
|
-
uploadSoundSupport: PropTypes.object
|
|
799
|
-
};
|
|
800
|
-
Design.defaultProps = {};
|
|
801
|
-
var Main = withStyles(theme => ({
|
|
802
|
-
tokenizerContainer: {
|
|
803
|
-
paddingRight: 0,
|
|
804
|
-
marginRight: 0,
|
|
805
|
-
'&:after': {
|
|
806
|
-
position: 'absolute',
|
|
807
|
-
bottom: 0,
|
|
808
|
-
left: 0,
|
|
809
|
-
right: 0,
|
|
810
|
-
height: '1px',
|
|
811
|
-
content: '""',
|
|
812
|
-
backgroundColor: theme.palette.primary.main
|
|
813
|
-
},
|
|
814
|
-
marginBottom: theme.spacing.unit
|
|
815
|
-
},
|
|
816
|
-
chip: {
|
|
817
|
-
marginTop: theme.spacing.unit / 2,
|
|
818
|
-
marginRight: theme.spacing.unit * 2
|
|
819
|
-
},
|
|
820
|
-
input: {
|
|
821
|
-
width: '100%'
|
|
822
|
-
},
|
|
823
|
-
tokenizer: {
|
|
824
|
-
marginTop: theme.spacing.unit * 2
|
|
825
|
-
},
|
|
826
|
-
mainOpts: {
|
|
827
|
-
width: '100%',
|
|
828
|
-
justifyContent: 'space-between',
|
|
829
|
-
display: 'flex',
|
|
830
|
-
alignItems: 'baseline'
|
|
831
|
-
},
|
|
832
|
-
promptHolder: {
|
|
833
|
-
width: '100%',
|
|
834
|
-
paddingTop: theme.spacing.unit * 2,
|
|
835
|
-
marginBottom: theme.spacing.unit * 2
|
|
836
|
-
},
|
|
837
|
-
tokensDetails: {
|
|
838
|
-
display: 'flex',
|
|
839
|
-
alignItems: 'center',
|
|
840
|
-
flexWrap: 'wrap',
|
|
841
|
-
marginBottom: theme.spacing.unit * 2.5
|
|
842
|
-
},
|
|
843
|
-
numberField: {
|
|
844
|
-
width: '180px',
|
|
845
|
-
margin: `${theme.spacing.unit / 2}px auto 0`
|
|
846
|
-
},
|
|
847
|
-
tooltip: {
|
|
848
|
-
fontSize: theme.typography.fontSize - 2,
|
|
849
|
-
whiteSpace: 'pre',
|
|
850
|
-
maxWidth: '500px'
|
|
851
|
-
},
|
|
852
|
-
errorText: {
|
|
853
|
-
fontSize: theme.typography.fontSize - 2,
|
|
854
|
-
color: theme.palette.error.main,
|
|
855
|
-
paddingTop: theme.spacing.unit
|
|
856
|
-
}
|
|
857
|
-
}))(Design);
|
|
858
|
-
|
|
859
|
-
var defaultValues = {
|
|
860
|
-
model: {
|
|
861
|
-
feedbackEnabled: false,
|
|
862
|
-
highlightChoices: false,
|
|
863
|
-
maxSelections: 0,
|
|
864
|
-
mode: 'sentence',
|
|
865
|
-
partialScoring: false,
|
|
866
|
-
prompt: '',
|
|
867
|
-
promptEnabled: true,
|
|
868
|
-
rationale: '',
|
|
869
|
-
rationaleEnabled: true,
|
|
870
|
-
scoringType: 'auto',
|
|
871
|
-
studentInstructionsEnabled: true,
|
|
872
|
-
teacherInstructions: '',
|
|
873
|
-
teacherInstructionsEnabled: true,
|
|
874
|
-
text: '',
|
|
875
|
-
tokens: [],
|
|
876
|
-
toolbarEditorPosition: 'bottom'
|
|
877
|
-
},
|
|
878
|
-
configuration: {
|
|
879
|
-
baseInputConfiguration: {
|
|
880
|
-
audio: {
|
|
881
|
-
disabled: false
|
|
882
|
-
},
|
|
883
|
-
video: {
|
|
884
|
-
disabled: false
|
|
885
|
-
},
|
|
886
|
-
image: {
|
|
887
|
-
disabled: false
|
|
888
|
-
},
|
|
889
|
-
textAlign: {
|
|
890
|
-
disabled: true
|
|
891
|
-
},
|
|
892
|
-
showParagraphs: {
|
|
893
|
-
disabled: false
|
|
894
|
-
},
|
|
895
|
-
separateParagraphs: {
|
|
896
|
-
disabled: true
|
|
897
|
-
}
|
|
898
|
-
},
|
|
899
|
-
selectionCount: {
|
|
900
|
-
settings: true,
|
|
901
|
-
label: 'Selection count'
|
|
902
|
-
},
|
|
903
|
-
correctAnswer: {
|
|
904
|
-
settings: true,
|
|
905
|
-
label: 'Correct Answers'
|
|
906
|
-
},
|
|
907
|
-
selections: {
|
|
908
|
-
settings: true,
|
|
909
|
-
label: 'Selections Available'
|
|
910
|
-
},
|
|
911
|
-
highlightChoices: {
|
|
912
|
-
settings: true,
|
|
913
|
-
label: 'Highlight choices'
|
|
914
|
-
},
|
|
915
|
-
rationale: {
|
|
916
|
-
settings: true,
|
|
917
|
-
label: 'Rationale',
|
|
918
|
-
inputConfiguration: {
|
|
919
|
-
audio: {
|
|
920
|
-
disabled: false
|
|
921
|
-
},
|
|
922
|
-
video: {
|
|
923
|
-
disabled: false
|
|
924
|
-
},
|
|
925
|
-
image: {
|
|
926
|
-
disabled: false
|
|
927
|
-
}
|
|
928
|
-
},
|
|
929
|
-
required: false
|
|
930
|
-
},
|
|
931
|
-
scoringType: {
|
|
932
|
-
settings: false,
|
|
933
|
-
label: 'Scoring Type'
|
|
934
|
-
},
|
|
935
|
-
studentInstructions: {
|
|
936
|
-
settings: false,
|
|
937
|
-
label: 'Student Instructions'
|
|
938
|
-
},
|
|
939
|
-
teacherInstructions: {
|
|
940
|
-
settings: true,
|
|
941
|
-
label: 'Teacher Instructions',
|
|
942
|
-
inputConfiguration: {
|
|
943
|
-
audio: {
|
|
944
|
-
disabled: false
|
|
945
|
-
},
|
|
946
|
-
video: {
|
|
947
|
-
disabled: false
|
|
948
|
-
},
|
|
949
|
-
image: {
|
|
950
|
-
disabled: false
|
|
951
|
-
}
|
|
952
|
-
},
|
|
953
|
-
required: false
|
|
954
|
-
},
|
|
955
|
-
prompt: {
|
|
956
|
-
label: 'Prompt',
|
|
957
|
-
settings: true,
|
|
958
|
-
inputConfiguration: {
|
|
959
|
-
audio: {
|
|
960
|
-
disabled: false
|
|
961
|
-
},
|
|
962
|
-
video: {
|
|
963
|
-
disabled: false
|
|
964
|
-
},
|
|
965
|
-
image: {
|
|
966
|
-
disabled: false
|
|
967
|
-
}
|
|
968
|
-
},
|
|
969
|
-
required: false
|
|
970
|
-
},
|
|
971
|
-
text: {
|
|
972
|
-
settings: true,
|
|
973
|
-
label: 'Content'
|
|
974
|
-
},
|
|
975
|
-
tokens: {
|
|
976
|
-
settings: true,
|
|
977
|
-
label: 'Tokens'
|
|
978
|
-
},
|
|
979
|
-
feedback: {
|
|
980
|
-
settings: true,
|
|
981
|
-
label: 'Feedback'
|
|
982
|
-
},
|
|
983
|
-
spellCheck: {
|
|
984
|
-
label: 'Spellcheck',
|
|
985
|
-
settings: false,
|
|
986
|
-
enabled: true
|
|
987
|
-
},
|
|
988
|
-
partialScoring: {
|
|
989
|
-
settings: false,
|
|
990
|
-
label: 'Allow Partial Scoring'
|
|
991
|
-
},
|
|
992
|
-
mode: {
|
|
993
|
-
settings: true,
|
|
994
|
-
label: 'Mode'
|
|
995
|
-
},
|
|
996
|
-
minTokens: 2,
|
|
997
|
-
maxImageWidth: {
|
|
998
|
-
teacherInstructions: 300,
|
|
999
|
-
prompt: 300,
|
|
1000
|
-
rationale: 300
|
|
1001
|
-
},
|
|
1002
|
-
maxImageHeight: {
|
|
1003
|
-
teacherInstructions: 300,
|
|
1004
|
-
prompt: 300,
|
|
1005
|
-
rationale: 300
|
|
1006
|
-
},
|
|
1007
|
-
withRubric: {
|
|
1008
|
-
settings: false,
|
|
1009
|
-
label: 'Add Rubric'
|
|
1010
|
-
},
|
|
1011
|
-
mathMlOptions: {
|
|
1012
|
-
mmlOutput: false,
|
|
1013
|
-
mmlEditing: false
|
|
1014
|
-
},
|
|
1015
|
-
language: {
|
|
1016
|
-
settings: false,
|
|
1017
|
-
label: 'Specify Language',
|
|
1018
|
-
enabled: false
|
|
1019
|
-
},
|
|
1020
|
-
languageChoices: {
|
|
1021
|
-
label: 'Language Choices',
|
|
1022
|
-
options: []
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
|
|
1027
|
-
class SelectTextConfigure extends HTMLElement {
|
|
1028
|
-
constructor() {
|
|
1029
|
-
super();
|
|
1030
|
-
this._model = SelectTextConfigure.createDefaultModel();
|
|
1031
|
-
this._configuration = defaultValues.configuration;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
set model(m) {
|
|
1035
|
-
this._model = SelectTextConfigure.createDefaultModel(m);
|
|
1036
|
-
this.render();
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
set configuration(c) {
|
|
1040
|
-
var _newConfiguration$lan;
|
|
1041
|
-
|
|
1042
|
-
const newConfiguration = _extends({}, defaultValues.configuration, c);
|
|
1043
|
-
|
|
1044
|
-
this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
|
|
1045
|
-
// if it is false, then the language field should be omitted from the item model.
|
|
1046
|
-
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
1047
|
-
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
1048
|
-
|
|
1049
|
-
if (newConfiguration != null && (_newConfiguration$lan = newConfiguration.language) != null && _newConfiguration$lan.enabled) {
|
|
1050
|
-
var _newConfiguration$lan2, _newConfiguration$lan3;
|
|
1051
|
-
|
|
1052
|
-
if (newConfiguration != null && (_newConfiguration$lan2 = newConfiguration.languageChoices) != null && (_newConfiguration$lan3 = _newConfiguration$lan2.options) != null && _newConfiguration$lan3.length) {
|
|
1053
|
-
this._model.language = newConfiguration == null ? void 0 : newConfiguration.languageChoices.options[0].value;
|
|
1054
|
-
}
|
|
1055
|
-
} else if (newConfiguration.language.settings && this._model.language) {
|
|
1056
|
-
this._configuration.language.enabled = true;
|
|
1057
|
-
|
|
1058
|
-
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
1059
|
-
this._configuration.languageChoices.options = [];
|
|
1060
|
-
} // check if the language is already included in the languageChoices.options array
|
|
1061
|
-
// and if not, then add it.
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
1065
|
-
this._configuration.languageChoices.options.push({
|
|
1066
|
-
value: this._model.language,
|
|
1067
|
-
label: this._model.language
|
|
1068
|
-
});
|
|
1069
|
-
}
|
|
1070
|
-
} else {
|
|
1071
|
-
delete this._model.language;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
this.render();
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
connectedCallback() {
|
|
1078
|
-
this.render();
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
modelChanged(m) {
|
|
1082
|
-
this._model = m;
|
|
1083
|
-
this.dispatchEvent(new ModelUpdatedEvent(this._model), true);
|
|
1084
|
-
this.render();
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
onConfigurationChanged(c) {
|
|
1088
|
-
this._configuration = c;
|
|
1089
|
-
|
|
1090
|
-
if (this._model) {
|
|
1091
|
-
this.dispatchEvent(new ModelUpdatedEvent(this._model), false);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
this.render();
|
|
1095
|
-
}
|
|
1096
|
-
/**
|
|
1097
|
-
*
|
|
1098
|
-
* @param {done, progress, file} handler
|
|
1099
|
-
*/
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
insertImage(handler) {
|
|
1103
|
-
this.dispatchEvent(new InsertImageEvent(handler));
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
onDeleteImage(src, done) {
|
|
1107
|
-
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
insertSound(handler) {
|
|
1111
|
-
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
onDeleteSound(src, done) {
|
|
1115
|
-
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
render() {
|
|
1119
|
-
if (this._model) {
|
|
1120
|
-
const el = /*#__PURE__*/React.createElement(Main, {
|
|
1121
|
-
model: this._model,
|
|
1122
|
-
configuration: this._configuration,
|
|
1123
|
-
onModelChanged: this.modelChanged.bind(this),
|
|
1124
|
-
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
1125
|
-
imageSupport: {
|
|
1126
|
-
add: this.insertImage.bind(this),
|
|
1127
|
-
delete: this.onDeleteImage.bind(this)
|
|
1128
|
-
},
|
|
1129
|
-
uploadSoundSupport: {
|
|
1130
|
-
add: this.insertSound.bind(this),
|
|
1131
|
-
delete: this.onDeleteSound.bind(this)
|
|
1132
|
-
}
|
|
1133
|
-
});
|
|
1134
|
-
ReactDOM.render(el, this);
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
SelectTextConfigure.createDefaultModel = (model = {}) => {
|
|
1141
|
-
const newModel = _extends({}, defaultValues.model, model);
|
|
1142
|
-
|
|
1143
|
-
return generateModel(newModel);
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
export { SelectTextConfigure as default };
|
|
1147
|
-
//# sourceMappingURL=configure.js.map
|