@pie-element/math-inline 10.0.2-esm.0 → 10.2.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/esm/configure.js DELETED
@@ -1,1453 +0,0 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
3
- import ReactDOM from 'react-dom';
4
- import { withStyles } from '@material-ui/core/styles';
5
- import { InputContainer, layout, FeedbackConfig, settings } from '@pie-lib/config-ui';
6
- import PropTypes from 'prop-types';
7
- import debug from 'debug';
8
- import EditableHtml from '@pie-lib/editable-html';
9
- import cx from 'classnames';
10
- import InputLabel from '@material-ui/core/InputLabel';
11
- import Select from '@material-ui/core/Select';
12
- import MenuItem from '@material-ui/core/MenuItem';
13
- import { MathToolbar } from '@pie-lib/math-toolbar';
14
- import Card from '@material-ui/core/Card';
15
- import CardContent from '@material-ui/core/CardContent';
16
- import Button from '@material-ui/core/Button';
17
- import FormControlLabel from '@material-ui/core/FormControlLabel';
18
- import Typography from '@material-ui/core/Typography';
19
- import Checkbox from '@material-ui/core/Checkbox';
20
- import { color } from '@pie-lib/render-ui';
21
- import isEqual from 'lodash/isEqual';
22
- import MathQuill from '@pie-framework/mathquill';
23
- import Info from '@material-ui/icons/Info';
24
- import Tooltip from '@material-ui/core/Tooltip';
25
- import isEmpty from 'lodash/isEmpty';
26
- import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
27
-
28
- function _extends() {
29
- _extends = Object.assign || function (target) {
30
- for (var i = 1; i < arguments.length; i++) {
31
- var source = arguments[i];
32
-
33
- for (var key in source) {
34
- if (Object.prototype.hasOwnProperty.call(source, key)) {
35
- target[key] = source[key];
36
- }
37
- }
38
- }
39
-
40
- return target;
41
- };
42
-
43
- return _extends.apply(this, arguments);
44
- }
45
-
46
- const styles$2 = theme => ({
47
- responseContainer: {
48
- marginBottom: theme.spacing.unit * 2.5,
49
- width: '100%',
50
- minWidth: '548px',
51
- border: `1px solid ${theme.palette.grey[700]}`,
52
- display: 'flex',
53
- flexDirection: 'column',
54
- justifyContent: 'space-between'
55
- },
56
- cardContent: {
57
- paddingBottom: `${theme.spacing.unit * 2}px !important`
58
- },
59
- title: {
60
- fontWeight: 700,
61
- fontSize: '1.2rem',
62
- flex: 3
63
- },
64
- selectContainer: {
65
- flex: 2
66
- },
67
- inputContainer: {
68
- marginBottom: theme.spacing.unit * 2
69
- },
70
- titleBar: {
71
- display: 'flex',
72
- alignItems: 'center',
73
- justifyContent: 'space-between'
74
- },
75
- responseEditor: {
76
- display: 'flex',
77
- alignItems: 'center',
78
- justifyContent: 'center',
79
- width: '100%',
80
- minWidth: '500px',
81
- maxWidth: '900px',
82
- height: 'auto',
83
- minHeight: '40px'
84
- },
85
- mathToolbar: {
86
- width: '100%'
87
- },
88
- alternateButton: {
89
- border: `1px solid ${theme.palette.grey['A100']}`
90
- },
91
- removeAlternateButton: {
92
- marginLeft: theme.spacing.unit * 2,
93
- border: `1px solid ${theme.palette.grey['A100']}`,
94
- color: 'gray',
95
- fontSize: '0.8rem'
96
- },
97
- errorText: {
98
- fontSize: theme.typography.fontSize - 2,
99
- color: theme.palette.error.main,
100
- paddingTop: theme.spacing.unit
101
- },
102
- customColor: {
103
- color: `${color.tertiary()} !important`
104
- }
105
- });
106
-
107
- class Response extends React.Component {
108
- constructor(props) {
109
- super(props);
110
-
111
- this.onChange = name => evt => {
112
- const {
113
- response,
114
- onResponseChange,
115
- index
116
- } = this.props;
117
-
118
- const newResponse = _extends({}, response);
119
-
120
- newResponse[name] = evt.target.value;
121
- onResponseChange(newResponse, index);
122
- };
123
-
124
- this.onConfigChanged = name => evt => {
125
- const {
126
- response,
127
- onResponseChange,
128
- index
129
- } = this.props;
130
-
131
- const newResponse = _extends({}, response);
132
-
133
- newResponse[name] = evt.target.checked;
134
- onResponseChange(newResponse, index);
135
- };
136
-
137
- this.onLiteralOptionsChange = name => () => {
138
- const {
139
- response,
140
- onResponseChange,
141
- index
142
- } = this.props;
143
-
144
- const newResponse = _extends({}, response);
145
-
146
- newResponse[name] = !response[name];
147
- onResponseChange(newResponse, index);
148
- };
149
-
150
- this.onAnswerChange = answer => {
151
- const {
152
- response,
153
- onResponseChange,
154
- index
155
- } = this.props;
156
-
157
- const newResponse = _extends({}, response);
158
-
159
- newResponse.answer = answer;
160
- onResponseChange(newResponse, index);
161
- };
162
-
163
- this.onAlternateAnswerChange = alternateId => answer => {
164
- const {
165
- response,
166
- onResponseChange,
167
- index
168
- } = this.props;
169
-
170
- const newResponse = _extends({}, response);
171
-
172
- newResponse.alternates[alternateId] = answer;
173
- onResponseChange(newResponse, index);
174
- };
175
-
176
- this.onAddAlternate = () => {
177
- const {
178
- response,
179
- onResponseChange,
180
- index
181
- } = this.props;
182
- const {
183
- alternateIdCounter
184
- } = this.state;
185
-
186
- const newResponse = _extends({}, response);
187
-
188
- if (!newResponse.alternates) {
189
- newResponse.alternates = {};
190
- }
191
-
192
- newResponse.alternates[alternateIdCounter] = '';
193
- onResponseChange(newResponse, index);
194
- this.setState({
195
- alternateIdCounter: alternateIdCounter + 1
196
- });
197
- };
198
-
199
- this.onRemoveAlternate = alternateId => () => {
200
- const {
201
- response,
202
- onResponseChange,
203
- index
204
- } = this.props;
205
-
206
- const newResponse = _extends({}, response);
207
-
208
- delete newResponse.alternates[alternateId];
209
- onResponseChange(newResponse, index);
210
- this.setState(state => ({
211
- showKeypad: _extends({}, state.showKeypad, {
212
- openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount : state.showKeypad.openCount - 1
213
- })
214
- }));
215
- };
216
-
217
- this.onDone = () => {
218
- this.setState(state => ({
219
- showKeypad: _extends({}, state.showKeypad, {
220
- openCount: state.showKeypad.openCount - 1,
221
- main: false
222
- })
223
- }));
224
- };
225
-
226
- this.onFocus = () => {
227
- this.setState(state => ({
228
- showKeypad: _extends({}, state.showKeypad, {
229
- openCount: !state.showKeypad.main ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
230
- main: true
231
- })
232
- }));
233
- };
234
-
235
- this.onAlternateFocus = alternateId => () => {
236
- this.setState(state => ({
237
- showKeypad: _extends({}, state.showKeypad, {
238
- openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
239
- [alternateId]: true
240
- })
241
- }));
242
- };
243
-
244
- this.onAlternateDone = alternateId => () => {
245
- this.setState(state => ({
246
- showKeypad: _extends({}, state.showKeypad, {
247
- openCount: state.showKeypad.openCount - 1,
248
- [alternateId]: false
249
- })
250
- }));
251
- };
252
-
253
- const {
254
- response: {
255
- alternates
256
- } = {}
257
- } = props || {};
258
- const alternatesLength = Object.keys(alternates || {}).length;
259
- this.state = {
260
- alternateIdCounter: alternatesLength + 1,
261
- showKeypad: {
262
- openCount: 0,
263
- main: false
264
- }
265
- };
266
- }
267
-
268
- render() {
269
- const {
270
- classes,
271
- mode,
272
- defaultResponse,
273
- index,
274
- response,
275
- cAllowTrailingZeros,
276
- cIgnoreOrder,
277
- error
278
- } = this.props;
279
- const {
280
- showKeypad
281
- } = this.state;
282
- const {
283
- validation,
284
- answer,
285
- alternates,
286
- ignoreOrder,
287
- allowTrailingZeros
288
- } = response;
289
- const hasAlternates = Object.keys(alternates || {}).length > 0;
290
- const classNames = {
291
- editor: classes.responseEditor,
292
- mathToolbar: classes.mathToolbar
293
- };
294
- const styles = {
295
- minHeight: `${showKeypad.openCount > 0 ? 430 : 230}px`
296
- };
297
- return /*#__PURE__*/React.createElement(Card, {
298
- className: classes.responseContainer,
299
- style: styles
300
- }, /*#__PURE__*/React.createElement(CardContent, {
301
- className: classes.cardContent
302
- }, /*#__PURE__*/React.createElement("div", {
303
- className: classes.titleBar
304
- }, /*#__PURE__*/React.createElement(Typography, {
305
- className: classes.title,
306
- component: "div"
307
- }, "Response ", ''), /*#__PURE__*/React.createElement(InputContainer, {
308
- label: "Validation",
309
- className: classes.selectContainer
310
- }, /*#__PURE__*/React.createElement(Select, {
311
- className: classes.select,
312
- onChange: this.onChange('validation'),
313
- value: validation || 'literal'
314
- }, /*#__PURE__*/React.createElement(MenuItem, {
315
- value: "literal"
316
- }, "Literal Validation"), /*#__PURE__*/React.createElement(MenuItem, {
317
- value: "symbolic"
318
- }, "Symbolic Validation")))), validation === 'literal' && /*#__PURE__*/React.createElement("div", {
319
- className: classes.flexContainer
320
- }, cAllowTrailingZeros.enabled && /*#__PURE__*/React.createElement(FormControlLabel, {
321
- label: cAllowTrailingZeros.label,
322
- control: /*#__PURE__*/React.createElement(Checkbox, {
323
- className: classes.customColor,
324
- checked: allowTrailingZeros,
325
- onChange: this.onLiteralOptionsChange('allowTrailingZeros')
326
- })
327
- }), cIgnoreOrder.enabled && /*#__PURE__*/React.createElement(FormControlLabel, {
328
- label: cIgnoreOrder.label,
329
- control: /*#__PURE__*/React.createElement(Checkbox, {
330
- className: classes.customColor,
331
- checked: ignoreOrder,
332
- onChange: this.onLiteralOptionsChange('ignoreOrder')
333
- })
334
- })), /*#__PURE__*/React.createElement("div", {
335
- className: classes.inputContainer
336
- }, /*#__PURE__*/React.createElement(InputLabel, null, "Correct Answer"), /*#__PURE__*/React.createElement(MathToolbar, {
337
- keypadMode: mode,
338
- classNames: classNames,
339
- controlledKeypad: true,
340
- showKeypad: showKeypad.main,
341
- latex: answer || '',
342
- onChange: this.onAnswerChange,
343
- onFocus: this.onFocus,
344
- onDone: this.onDone,
345
- error: error && error.answer
346
- }), error && error.answer ? /*#__PURE__*/React.createElement("div", {
347
- className: classes.errorText
348
- }, error.answer) : null), hasAlternates && Object.keys(alternates).map((alternateId, altIdx) => /*#__PURE__*/React.createElement("div", {
349
- className: classes.inputContainer,
350
- key: alternateId
351
- }, /*#__PURE__*/React.createElement("div", {
352
- className: classes.alternateBar
353
- }, /*#__PURE__*/React.createElement(InputLabel, null, "Alternate", Object.keys(alternates).length > 1 ? ` ${altIdx + 1}` : ''), /*#__PURE__*/React.createElement(Button, {
354
- className: classes.removeAlternateButton,
355
- type: "secondary",
356
- onClick: this.onRemoveAlternate(alternateId)
357
- }, "Remove")), /*#__PURE__*/React.createElement(MathToolbar, {
358
- classNames: classNames,
359
- controlledKeypad: true,
360
- keypadMode: mode,
361
- showKeypad: showKeypad[alternateId] || false,
362
- latex: alternates[alternateId] || '',
363
- onChange: this.onAlternateAnswerChange(alternateId),
364
- onFocus: this.onAlternateFocus(alternateId),
365
- onDone: this.onAlternateDone(alternateId),
366
- error: error && error[alternateId]
367
- }), error && error[alternateId] ? /*#__PURE__*/React.createElement("div", {
368
- className: classes.errorText
369
- }, error[alternateId]) : null)), /*#__PURE__*/React.createElement(Button, {
370
- className: classes.alternateButton,
371
- type: "primary",
372
- onClick: this.onAddAlternate
373
- }, "ADD ALTERNATE")));
374
- }
375
-
376
- }
377
-
378
- Response.propTypes = {
379
- classes: PropTypes.object.isRequired,
380
- defaultResponse: PropTypes.bool,
381
- error: PropTypes.object,
382
- mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
383
- index: PropTypes.number,
384
- onResponseChange: PropTypes.func.isRequired,
385
- response: PropTypes.object.isRequired,
386
- cIgnoreOrder: PropTypes.object.isRequired,
387
- cAllowTrailingZeros: PropTypes.object.isRequired
388
- };
389
- Response.defaultProps = {
390
- defaultResponse: false,
391
- mode: 'miscellaneous'
392
- };
393
- var Response$1 = withStyles(styles$2)(Response);
394
-
395
- const ResponseTypes = {
396
- advanced: 'Advanced Multi',
397
- simple: 'Simple'
398
- };
399
- const generateValidationMessage = (model = {}, config = {}) => {
400
- const {
401
- maxResponseAreas
402
- } = config;
403
- const {
404
- responseType
405
- } = model;
406
- let responseAreasMessage = '';
407
- const answersMessage = '\nAll correct answers (the primary and any alternates) should not be empty and should be unique.';
408
-
409
- if (responseType === 'Advanced Multi') {
410
- responseAreasMessage = '\nThere should be at least 1 ' + (maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') + 'response area' + (maxResponseAreas ? 's' : '') + ' defined.';
411
- }
412
-
413
- return 'Validation requirements:' + answersMessage + responseAreasMessage;
414
- };
415
- const getPluginProps = (props = {}, baseInputConfiguration = {}) => _extends({}, baseInputConfiguration, props);
416
-
417
- let registered = false;
418
-
419
- const styles$1 = theme => ({
420
- container: {
421
- display: 'flex',
422
- flexDirection: 'column'
423
- },
424
- templateTitle: {
425
- fontSize: '0.85rem'
426
- },
427
- title: {
428
- fontSize: '1.1rem'
429
- },
430
- addResponseButton: {
431
- border: `1px solid ${theme.palette.grey['A100']}`,
432
- float: 'right',
433
- width: '150px'
434
- },
435
- flexContainer: {
436
- display: 'flex',
437
- alignItems: 'center',
438
- justifyContent: 'space-between'
439
- },
440
- selectContainer: {
441
- flex: 'initial',
442
- width: '40%',
443
- marginTop: theme.spacing.unit * 2,
444
- marginBottom: theme.spacing.unit * 2
445
- },
446
- responseTemplate: {
447
- display: 'flex',
448
- flexDirection: 'column'
449
- },
450
- responseEditor: {
451
- display: 'flex',
452
- justifyContent: 'center',
453
- width: '100%',
454
- // minWidth: '500px',
455
- maxWidth: 'inherit',
456
- height: 'auto',
457
- minHeight: '130px',
458
- textAlign: 'left',
459
- padding: theme.spacing.unit
460
- },
461
- promptHolder: {
462
- width: '100%',
463
- paddingTop: theme.spacing.unit * 2,
464
- marginBottom: theme.spacing.unit * 2
465
- },
466
- blockContainer: {
467
- margin: theme.spacing.unit,
468
- display: 'inline-flex',
469
- border: '2px solid grey'
470
- },
471
- blockContainerGeneric: {
472
- margin: theme.spacing.unit / 2
473
- },
474
- blockResponse: {
475
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
476
- flex: 2,
477
- color: 'grey',
478
- background: theme.palette.grey['A100'],
479
- fontSize: '0.8rem',
480
- padding: theme.spacing.unit / 2,
481
- display: 'flex',
482
- alignItems: 'center',
483
- justifyContent: 'center',
484
- borderRight: '2px solid grey'
485
- },
486
- blockResponseGeneric: {
487
- borderRight: 0
488
- },
489
- blockMath: {
490
- color: theme.palette.grey[400],
491
- padding: theme.spacing.unit / 2,
492
- display: 'flex',
493
- alignItems: 'center',
494
- justifyContent: 'center',
495
- flex: 8,
496
- '& > .mq-math-mode': {
497
- '& > .mq-hasCursor': {
498
- '& > .mq-cursor': {
499
- display: 'none'
500
- }
501
- }
502
- }
503
- },
504
- tooltip: {
505
- fontSize: theme.typography.fontSize - 2,
506
- whiteSpace: 'pre-wrap'
507
- },
508
- errorText: {
509
- fontSize: theme.typography.fontSize - 2,
510
- color: theme.palette.error.main,
511
- paddingTop: theme.spacing.unit
512
- },
513
- advancedResponse: {
514
- marginBottom: theme.spacing.unit * 2.5
515
- }
516
- });
517
-
518
- const REGEX = /{{response}}/gm;
519
- const TEMPORARY_RESPONSE_FIELD = /\\%response\\%/gm;
520
- const ANSWER_BLOCK_REGEX = /\\embed\{answerBlock\}\[r\d*\]/g;
521
- const NEWLINE_BLOCK = /\\embed\{newLine\}\[\]/g;
522
- const NEWLINE_LATEX = /\\newline/g;
523
-
524
- function prepareForStatic(expression) {
525
- if (expression) {
526
- let answerBlocks = 1; // assume one at least
527
-
528
- return expression.replace(REGEX, () => `\\embed{answerBlock}[r${answerBlocks++}]`).replace(NEWLINE_LATEX, '\\embed{newLine}[]');
529
- }
530
- }
531
-
532
- function prepareForModel(expression) {
533
- if (expression) {
534
- return expression.replace(ANSWER_BLOCK_REGEX, () => '{{response}}').replace(TEMPORARY_RESPONSE_FIELD, () => '{{response}}').replace(NEWLINE_BLOCK, () => '\\newline');
535
- }
536
- }
537
-
538
- class GeneralConfigBlock extends React.Component {
539
- constructor(props) {
540
- super(props);
541
-
542
- this.onChange = name => evtOrValue => {
543
- const {
544
- model,
545
- onChange
546
- } = this.props;
547
-
548
- const newModel = _extends({}, model);
549
-
550
- if (typeof evtOrValue === 'object') {
551
- newModel[name] = evtOrValue.target.value;
552
- } else {
553
- newModel[name] = evtOrValue;
554
- }
555
-
556
- if (name === 'expression') {
557
- newModel[name] = prepareForModel(evtOrValue);
558
- }
559
-
560
- onChange(newModel);
561
- };
562
-
563
- this.onDone = () => {
564
- this.setState({
565
- showKeypad: false
566
- });
567
- };
568
-
569
- this.onFocus = () => {
570
- this.setState({
571
- showKeypad: true
572
- });
573
- };
574
-
575
- this.onPromptFocus = () => {
576
- this.setState({
577
- showKeypad: false
578
- });
579
- };
580
-
581
- this.handleAnswerBlockDomUpdate = () => {
582
- const {
583
- model
584
- } = this.props;
585
- const responseAreas = {};
586
-
587
- if (model && model.expression) {
588
- let answerBlocks = 1; // assume one at least
589
- // build out local state model using responses declared in expression
590
-
591
- model.expression.replace(REGEX, () => {
592
- responseAreas[`r${answerBlocks++}`] = {
593
- value: ''
594
- };
595
- });
596
- }
597
-
598
- if (!isEqual(responseAreas, this.state.responseAreas)) {
599
- this.setState({
600
- responseAreas
601
- }, () => {
602
- if (this.root && Object.keys(responseAreas).length) {
603
- Object.keys(responseAreas).forEach((responseId, idx) => {
604
- const el = this.root.querySelector(`#${responseId}`);
605
- const indexEl = this.root.querySelector(`#${responseId}Index`);
606
-
607
- if (el) {
608
- // const MathQuill = require('@pie-framework/mathquill');
609
- let MQ = MathQuill.getInterface(2); // We no longer have individual answers, so we cannot set text content of blocks
610
- // el.textContent = response.answer;
611
-
612
- MQ.StaticMath(el);
613
- indexEl.textContent = `R${idx + 1}`;
614
- }
615
- });
616
- }
617
- });
618
- }
619
- };
620
-
621
- this.onAddResponse = () => {
622
- const {
623
- model,
624
- onChange
625
- } = this.props;
626
- const {
627
- responseIdCounter
628
- } = this.state;
629
-
630
- const newModel = _extends({}, model);
631
-
632
- let newCounter = responseIdCounter;
633
-
634
- while (model.responses.find(response => response.id === newCounter)) {
635
- newCounter++;
636
- }
637
-
638
- const response = {
639
- id: newCounter,
640
- validation: 'literal',
641
- answer: '',
642
- alternates: {}
643
- };
644
- newModel.responses = newModel.responses.concat(response);
645
- onChange(newModel);
646
- this.setState({
647
- responseIdCounter: response.id
648
- });
649
- };
650
-
651
- this.onResponseChange = (response, index) => {
652
- const {
653
- model,
654
- onChange
655
- } = this.props;
656
-
657
- const newModel = _extends({}, model);
658
-
659
- newModel.responses[index] = response;
660
- onChange(newModel);
661
- };
662
-
663
- const _responseAreas = {};
664
-
665
- if (props.model && props.model.expression) {
666
- let answerBlocks = 1; // assume one at least
667
- // build out local state model using responses declared in expression
668
-
669
- props.model.expression.replace(REGEX, () => {
670
- _responseAreas[`r${answerBlocks++}`] = {
671
- value: ''
672
- };
673
- });
674
- }
675
-
676
- this.state = {
677
- showKeypad: false,
678
- responseAreas: _responseAreas,
679
- responseIdCounter: Object.keys(_responseAreas).length
680
- };
681
- }
682
-
683
- UNSAFE_componentWillMount() {
684
- const {
685
- classes
686
- } = this.props;
687
-
688
- if (typeof window !== 'undefined') {
689
- // const MathQuill = require('@pie-framework/mathquill');
690
- let MQ = MathQuill.getInterface(2);
691
-
692
- if (!registered) {
693
- MQ.registerEmbed('answerBlock', data => {
694
- // not used until we implement individual answer tracking
695
- // const individualAnswerBlock = `<div class="${classes.blockContainer}">
696
- // <div class="${classes.blockResponse}" id="${data}Index">R</div>
697
- // <div class="${classes.blockMath}">
698
- // <span id="${data}"></span>
699
- // </div>
700
- // </div>`;
701
- const genericAnswerBlock = `<div class="${cx(classes.blockContainer, classes.blockContainerGeneric)}">
702
- <div class="${cx(classes.blockResponse, classes.blockResponseGeneric)}" id="${data}Index">Response</div>
703
- </div>`;
704
- return {
705
- htmlString: genericAnswerBlock,
706
- text: () => 'text',
707
- latex: () => `\\embed{answerBlock}[${data}]`
708
- };
709
- });
710
- registered = true;
711
- }
712
- }
713
- }
714
-
715
- componentDidMount() {
716
- this.handleAnswerBlockDomUpdate();
717
- }
718
-
719
- componentDidUpdate() {
720
- this.handleAnswerBlockDomUpdate();
721
- }
722
-
723
- render() {
724
- const {
725
- classes,
726
- model,
727
- imageSupport,
728
- uploadSoundSupport,
729
- configuration,
730
- promptEnabled,
731
- rationaleEnabled,
732
- toolbarOpts
733
- } = this.props;
734
- const {
735
- showKeypad
736
- } = this.state;
737
- const {
738
- prompt,
739
- expression,
740
- equationEditor,
741
- promptEquationEditor = '8',
742
- responses,
743
- responseType,
744
- rationale,
745
- spellCheckEnabled,
746
- errors = {}
747
- } = model;
748
- const {
749
- baseInputConfiguration = {},
750
- rationale: cRationale = {},
751
- prompt: cPrompt = {},
752
- ignoreOrder: cIgnoreOrder = {},
753
- allowTrailingZeros: cAllowTrailingZeros = {},
754
- maxResponseAreas,
755
- maxImageWidth = {},
756
- maxImageHeight = {},
757
- mathMlOptions = {}
758
- } = configuration || {};
759
- const validationMessage = generateValidationMessage(configuration, model);
760
- const {
761
- prompt: promptError,
762
- rationale: rationaleError,
763
- responsesErrors,
764
- responseAreasError
765
- } = errors;
766
- const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
767
- const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
768
- const classNames = {
769
- editor: classes.responseEditor,
770
- mathToolbar: classes.mathToolbar
771
- };
772
- const responsesToUse = responseType === ResponseTypes.advanced ? responses : responses.slice(0, 1);
773
- const validationTooltip = /*#__PURE__*/React.createElement(Tooltip, {
774
- classes: {
775
- tooltip: classes.tooltip
776
- },
777
- disableFocusListener: true,
778
- disableTouchListener: true,
779
- placement: 'right',
780
- title: validationMessage
781
- }, /*#__PURE__*/React.createElement(Info, {
782
- fontSize: 'small',
783
- color: 'primary',
784
- style: {
785
- marginLeft: '5px'
786
- }
787
- }));
788
- return /*#__PURE__*/React.createElement("div", {
789
- ref: r => this.root = r || this.root,
790
- className: classes.container
791
- }, promptEnabled && /*#__PURE__*/React.createElement(InputContainer, {
792
- label: cPrompt.label,
793
- className: classes.promptHolder
794
- }, /*#__PURE__*/React.createElement(EditableHtml, {
795
- onFocus: this.onPromptFocus,
796
- className: classes.prompt,
797
- markup: prompt || '',
798
- onChange: this.onChange('prompt'),
799
- imageSupport: imageSupport,
800
- nonEmpty: false,
801
- error: promptError,
802
- toolbarOpts: toolbarOpts,
803
- pluginProps: getPluginProps(cPrompt == null ? void 0 : cPrompt.inputConfiguration, baseInputConfiguration),
804
- spellCheck: spellCheckEnabled,
805
- maxImageWidth: defaultImageMaxWidth,
806
- maxImageHeight: defaultImageMaxHeight,
807
- uploadSoundSupport: uploadSoundSupport,
808
- languageCharactersProps: [{
809
- language: 'spanish'
810
- }, {
811
- language: 'special'
812
- }],
813
- mathMlOptions: mathMlOptions
814
- }), promptError && /*#__PURE__*/React.createElement("div", {
815
- className: classes.errorText
816
- }, promptError)), responseType === ResponseTypes.advanced && /*#__PURE__*/React.createElement("div", {
817
- className: classes.advancedResponse
818
- }, /*#__PURE__*/React.createElement("div", {
819
- className: classes.flexContainer,
820
- style: {
821
- justifyContent: 'flex-start'
822
- }
823
- }, /*#__PURE__*/React.createElement("div", {
824
- className: classes.title
825
- }, "Define Response"), validationTooltip), /*#__PURE__*/React.createElement(InputContainer, {
826
- key: "templateEditorType",
827
- label: "Response Template Equation Editor",
828
- className: classes.selectContainer
829
- }, /*#__PURE__*/React.createElement(Select, {
830
- className: classes.select,
831
- onChange: this.onChange('promptEquationEditor'),
832
- value: promptEquationEditor
833
- }, /*#__PURE__*/React.createElement(MenuItem, {
834
- value: "non-negative-integers"
835
- }, "Numeric - Non-Negative Integers"), /*#__PURE__*/React.createElement(MenuItem, {
836
- value: "integers"
837
- }, "Numeric - Integers"), /*#__PURE__*/React.createElement(MenuItem, {
838
- value: "decimals"
839
- }, "Numeric - Decimals"), /*#__PURE__*/React.createElement(MenuItem, {
840
- value: "fractions"
841
- }, "Numeric - Fractions"), /*#__PURE__*/React.createElement(MenuItem, {
842
- value: 1
843
- }, "Grade 1 - 2"), /*#__PURE__*/React.createElement(MenuItem, {
844
- value: 3
845
- }, "Grade 3 - 5"), /*#__PURE__*/React.createElement(MenuItem, {
846
- value: 6
847
- }, "Grade 6 - 7"), /*#__PURE__*/React.createElement(MenuItem, {
848
- value: 8
849
- }, "Grade 8 - HS"), /*#__PURE__*/React.createElement(MenuItem, {
850
- value: 'geometry'
851
- }, "Geometry"), /*#__PURE__*/React.createElement(MenuItem, {
852
- value: 'advanced-algebra'
853
- }, "Advanced Algebra"), /*#__PURE__*/React.createElement(MenuItem, {
854
- value: 'statistics'
855
- }, "Statistics"), /*#__PURE__*/React.createElement(MenuItem, {
856
- value: 'item-authoring'
857
- }, "Item Authoring"))), /*#__PURE__*/React.createElement("div", {
858
- className: classes.responseTemplate,
859
- key: "templateHolder"
860
- }, /*#__PURE__*/React.createElement(InputLabel, {
861
- className: classes.templateTitle
862
- }, "RESPONSE TEMPLATE"), /*#__PURE__*/React.createElement(MathToolbar, {
863
- classNames: classNames,
864
- allowAnswerBlock: true,
865
- keypadMode: promptEquationEditor,
866
- controlledKeypad: true,
867
- showKeypad: showKeypad,
868
- latex: prepareForStatic(expression) || '',
869
- onChange: this.onChange('expression'),
870
- onFocus: this.onFocus,
871
- onDone: this.onDone,
872
- maxResponseAreas: maxResponseAreas,
873
- error: responseAreasError
874
- })), responseAreasError && /*#__PURE__*/React.createElement("div", {
875
- className: classes.errorText
876
- }, responseAreasError)), /*#__PURE__*/React.createElement("div", {
877
- className: classes.flexContainer,
878
- style: {
879
- justifyContent: 'flex-start'
880
- }
881
- }, /*#__PURE__*/React.createElement("div", {
882
- className: classes.title
883
- }, "Define Correct Response"), responseType === ResponseTypes.simple ? validationTooltip : null), /*#__PURE__*/React.createElement(InputContainer, {
884
- label: "Equation Editor",
885
- className: classes.selectContainer
886
- }, /*#__PURE__*/React.createElement(Select, {
887
- className: classes.select,
888
- onChange: this.onChange('equationEditor'),
889
- value: equationEditor
890
- }, /*#__PURE__*/React.createElement(MenuItem, {
891
- value: "non-negative-integers"
892
- }, "Numeric - Non-Negative Integers"), /*#__PURE__*/React.createElement(MenuItem, {
893
- value: "integers"
894
- }, "Numeric - Integers"), /*#__PURE__*/React.createElement(MenuItem, {
895
- value: "decimals"
896
- }, "Numeric - Decimals"), /*#__PURE__*/React.createElement(MenuItem, {
897
- value: "fractions"
898
- }, "Numeric - Fractions"), /*#__PURE__*/React.createElement(MenuItem, {
899
- value: 1
900
- }, "Grade 1 - 2"), /*#__PURE__*/React.createElement(MenuItem, {
901
- value: 3
902
- }, "Grade 3 - 5"), /*#__PURE__*/React.createElement(MenuItem, {
903
- value: 6
904
- }, "Grade 6 - 7"), /*#__PURE__*/React.createElement(MenuItem, {
905
- value: 8
906
- }, "Grade 8 - HS"), /*#__PURE__*/React.createElement(MenuItem, {
907
- value: 'geometry'
908
- }, "Geometry"), /*#__PURE__*/React.createElement(MenuItem, {
909
- value: 'advanced-algebra'
910
- }, "Advanced Algebra"), /*#__PURE__*/React.createElement(MenuItem, {
911
- value: 'statistics'
912
- }, "Statistics"), /*#__PURE__*/React.createElement(MenuItem, {
913
- value: 'item-authoring'
914
- }, "Item Authoring"))), responsesToUse.map((response, idx) => /*#__PURE__*/React.createElement(Response$1, {
915
- key: response.id,
916
- mode: equationEditor,
917
- response: response,
918
- defaultResponse: responseType === ResponseTypes.simple,
919
- onResponseChange: this.onResponseChange,
920
- index: idx,
921
- cIgnoreOrder: cIgnoreOrder,
922
- cAllowTrailingZeros: cAllowTrailingZeros,
923
- error: responsesErrors && responsesErrors[idx]
924
- })), rationaleEnabled && /*#__PURE__*/React.createElement(InputContainer, {
925
- label: cRationale.label,
926
- className: classes.promptHolder
927
- }, /*#__PURE__*/React.createElement(EditableHtml, {
928
- className: classes.prompt,
929
- markup: rationale || '',
930
- onChange: this.onChange('rationale'),
931
- imageSupport: imageSupport,
932
- nonEmpty: false,
933
- error: rationaleError,
934
- toolbarOpts: toolbarOpts,
935
- pluginProps: getPluginProps(cRationale == null ? void 0 : cRationale.inputConfiguration, _extends({}, baseInputConfiguration, {
936
- math: {
937
- controlledKeypadMode: false
938
- }
939
- })),
940
- spellCheck: spellCheckEnabled,
941
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
942
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
943
- uploadSoundSupport: uploadSoundSupport,
944
- languageCharactersProps: [{
945
- language: 'spanish'
946
- }, {
947
- language: 'special'
948
- }],
949
- mathMlOptions: mathMlOptions
950
- }), rationaleError && /*#__PURE__*/React.createElement("div", {
951
- className: classes.errorText
952
- }, rationaleError)));
953
- }
954
-
955
- }
956
-
957
- GeneralConfigBlock.propTypes = {
958
- classes: PropTypes.object.isRequired,
959
- model: PropTypes.object.isRequired,
960
- imageSupport: PropTypes.object,
961
- uploadSoundSupport: PropTypes.object,
962
- configuration: PropTypes.object,
963
- onChange: PropTypes.func.isRequired,
964
- promptEnabled: PropTypes.bool,
965
- rationaleEnabled: PropTypes.bool,
966
- toolbarOpts: PropTypes.object
967
- };
968
- var GeneralConfigBlock$1 = withStyles(styles$1)(GeneralConfigBlock);
969
-
970
- const log$1 = debug('@pie-element:math-inline:configure');
971
- const {
972
- Panel,
973
- toggle,
974
- radio,
975
- dropdown
976
- } = settings;
977
-
978
- const styles = theme => ({
979
- promptHolder: {
980
- width: '100%',
981
- paddingTop: theme.spacing.unit * 2,
982
- marginBottom: theme.spacing.unit * 2
983
- },
984
- errorText: {
985
- fontSize: theme.typography.fontSize - 2,
986
- color: theme.palette.error.main,
987
- paddingTop: theme.spacing.unit
988
- }
989
- });
990
-
991
- class Configure extends React__default.Component {
992
- constructor(...args) {
993
- super(...args);
994
-
995
- this.onChange = model => {
996
- this.props.onModelChanged(model);
997
- };
998
-
999
- this.changeTeacherInstructions = teacherInstructions => {
1000
- this.props.onModelChanged(_extends({}, this.props.model, {
1001
- teacherInstructions
1002
- }));
1003
- };
1004
-
1005
- this.onFeedbackChange = feedback => {
1006
- const {
1007
- model,
1008
- onModelChanged
1009
- } = this.props;
1010
- model.feedback = feedback;
1011
- onModelChanged(model);
1012
- };
1013
- }
1014
-
1015
- render() {
1016
- const {
1017
- classes,
1018
- model,
1019
- imageSupport,
1020
- onModelChanged,
1021
- configuration,
1022
- onConfigurationChanged,
1023
- uploadSoundSupport
1024
- } = this.props;
1025
- const {
1026
- allowTrailingZeros = {},
1027
- baseInputConfiguration = {},
1028
- contentDimensions = {},
1029
- feedback = {},
1030
- ignoreOrder = {},
1031
- maxImageWidth = {},
1032
- maxImageHeight = {},
1033
- prompt = {},
1034
- rationale = {},
1035
- responseType = {},
1036
- scoringType = {},
1037
- settingsPanelDisabled,
1038
- spellCheck = {},
1039
- studentInstructions = {},
1040
- teacherInstructions = {},
1041
- withRubric = {},
1042
- mathMlOptions = {},
1043
- language = {},
1044
- languageChoices = {}
1045
- } = configuration || {};
1046
- const {
1047
- errors = {},
1048
- extraCSSRules,
1049
- feedbackEnabled,
1050
- promptEnabled,
1051
- rationaleEnabled,
1052
- spellCheckEnabled,
1053
- teacherInstructionsEnabled,
1054
- toolbarEditorPosition
1055
- } = model || {};
1056
- const {
1057
- teacherInstructions: teacherInstructionsError
1058
- } = errors;
1059
- log$1('[render] model', model);
1060
- const toolbarOpts = {
1061
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
1062
- };
1063
- const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
1064
- const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
1065
- const panelSettings = {
1066
- responseType: responseType.settings && radio(responseType.label, [ResponseTypes.simple, ResponseTypes.advanced]),
1067
- feedbackEnabled: feedback.settings && toggle(feedback.label),
1068
- promptEnabled: prompt.settings && toggle(prompt.label),
1069
- 'language.enabled': language.settings && toggle(language.label, true),
1070
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
1071
- };
1072
- const panelProperties = {
1073
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
1074
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
1075
- rationaleEnabled: rationale.settings && toggle(rationale.label),
1076
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
1077
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
1078
- 'ignoreOrder.enabled': ignoreOrder.settings && toggle(ignoreOrder.label),
1079
- 'allowTrailingZeros.enabled': allowTrailingZeros.settings && toggle(allowTrailingZeros.label),
1080
- rubricEnabled: (withRubric == null ? void 0 : withRubric.settings) && toggle(withRubric == null ? void 0 : withRubric.label)
1081
- };
1082
- return /*#__PURE__*/React__default.createElement(layout.ConfigLayout, {
1083
- extraCSSRules: extraCSSRules,
1084
- dimensions: contentDimensions,
1085
- hideSettings: settingsPanelDisabled,
1086
- settings: /*#__PURE__*/React__default.createElement(Panel, {
1087
- model: model,
1088
- configuration: configuration,
1089
- onChangeModel: model => onModelChanged(model),
1090
- onChangeConfiguration: config => onConfigurationChanged(config),
1091
- groups: {
1092
- Settings: panelSettings,
1093
- Properties: panelProperties
1094
- }
1095
- })
1096
- }, teacherInstructionsEnabled && /*#__PURE__*/React__default.createElement(InputContainer, {
1097
- label: teacherInstructions.label,
1098
- className: classes.promptHolder
1099
- }, /*#__PURE__*/React__default.createElement(EditableHtml, {
1100
- className: classes.prompt,
1101
- markup: model.teacherInstructions || '',
1102
- onChange: this.changeTeacherInstructions,
1103
- imageSupport: imageSupport,
1104
- nonEmpty: false,
1105
- error: teacherInstructionsError,
1106
- toolbarOpts: toolbarOpts,
1107
- pluginProps: getPluginProps(teacherInstructions == null ? void 0 : teacherInstructions.inputConfiguration, baseInputConfiguration),
1108
- spellCheck: spellCheckEnabled,
1109
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
1110
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
1111
- uploadSoundSupport: uploadSoundSupport,
1112
- languageCharactersProps: [{
1113
- language: 'spanish'
1114
- }, {
1115
- language: 'special'
1116
- }],
1117
- mathMlOptions: mathMlOptions
1118
- }), teacherInstructionsError && /*#__PURE__*/React__default.createElement("div", {
1119
- className: classes.errorText
1120
- }, teacherInstructionsError)), /*#__PURE__*/React__default.createElement(GeneralConfigBlock$1, {
1121
- imageSupport: imageSupport,
1122
- uploadSoundSupport: uploadSoundSupport,
1123
- model: model,
1124
- configuration: configuration,
1125
- onChange: this.onChange,
1126
- rationaleEnabled: rationaleEnabled,
1127
- promptEnabled: promptEnabled,
1128
- toolbarOpts: toolbarOpts,
1129
- spellCheck: spellCheckEnabled
1130
- }), feedbackEnabled && /*#__PURE__*/React__default.createElement(FeedbackConfig, {
1131
- feedback: model.feedback,
1132
- onChange: this.onFeedbackChange,
1133
- toolbarOpts: toolbarOpts
1134
- }));
1135
- }
1136
-
1137
- }
1138
- Configure.propTypes = {
1139
- onModelChanged: PropTypes.func,
1140
- onConfigurationChanged: PropTypes.func,
1141
- classes: PropTypes.object,
1142
- model: PropTypes.object.isRequired,
1143
- configuration: PropTypes.object.isRequired,
1144
- imageSupport: PropTypes.object,
1145
- uploadSoundSupport: PropTypes.object
1146
- };
1147
- var Configure$1 = withStyles(styles)(Configure);
1148
-
1149
- /** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
1150
- * functionalities are not defined yet - the value for those can belong to
1151
- * model or to configure
1152
- */
1153
-
1154
- var defaults = {
1155
- model: {
1156
- allowTrailingZerosDefault: false,
1157
- customKeys: [],
1158
- equationEditor: '8',
1159
- expression: '',
1160
- feedback: {
1161
- correct: {
1162
- default: 'Correct',
1163
- type: 'none'
1164
- },
1165
- incorrect: {
1166
- default: 'Incorrect',
1167
- type: 'none'
1168
- },
1169
- partial: {
1170
- default: 'Nearly',
1171
- type: 'none'
1172
- }
1173
- },
1174
- feedbackEnabled: false,
1175
- ignoreOrderDefault: false,
1176
- partialScoring: true,
1177
- prompt: '',
1178
- promptEnabled: true,
1179
- rationale: '',
1180
- rationaleEnabled: true,
1181
- responseType: ResponseTypes.advanced,
1182
- responses: [],
1183
- scoringType: 'auto',
1184
- studentInstructionsEnabled: true,
1185
- teacherInstructions: '',
1186
- teacherInstructionsEnabled: true,
1187
- toolbarEditorPosition: 'bottom',
1188
- validationDefault: 'literal'
1189
- },
1190
- configuration: {
1191
- baseInputConfiguration: {
1192
- audio: {
1193
- disabled: false
1194
- },
1195
- video: {
1196
- disabled: false
1197
- },
1198
- image: {
1199
- disabled: false
1200
- },
1201
- textAlign: {
1202
- disabled: true
1203
- },
1204
- showParagraphs: {
1205
- disabled: false
1206
- },
1207
- separateParagraphs: {
1208
- disabled: true
1209
- }
1210
- },
1211
- prompt: {
1212
- settings: true,
1213
- label: 'Prompt',
1214
- inputConfiguration: {
1215
- audio: {
1216
- disabled: false
1217
- },
1218
- video: {
1219
- disabled: false
1220
- },
1221
- image: {
1222
- disabled: false
1223
- }
1224
- },
1225
- required: false
1226
- },
1227
- feedback: {
1228
- settings: true,
1229
- label: 'Feedback'
1230
- },
1231
- responseType: {
1232
- settings: true,
1233
- label: 'Response type'
1234
- },
1235
- rationale: {
1236
- settings: true,
1237
- label: 'Rationale',
1238
- inputConfiguration: {
1239
- audio: {
1240
- disabled: false
1241
- },
1242
- video: {
1243
- disabled: false
1244
- },
1245
- image: {
1246
- disabled: false
1247
- }
1248
- },
1249
- required: false
1250
- },
1251
- settingsPanelDisabled: false,
1252
- spellCheck: {
1253
- label: 'Spellcheck',
1254
- settings: false,
1255
- enabled: true
1256
- },
1257
- scoringType: {
1258
- settings: false,
1259
- label: 'Scoring Type'
1260
- },
1261
- studentInstructions: {
1262
- settings: false,
1263
- label: 'Student Instructions'
1264
- },
1265
- teacherInstructions: {
1266
- settings: true,
1267
- label: 'Teacher Instructions',
1268
- inputConfiguration: {
1269
- audio: {
1270
- disabled: false
1271
- },
1272
- video: {
1273
- disabled: false
1274
- },
1275
- image: {
1276
- disabled: false
1277
- }
1278
- },
1279
- required: false
1280
- },
1281
- partialScoring: {
1282
- settings: false,
1283
- label: 'Allow Partial Scoring'
1284
- },
1285
- ignoreOrder: {
1286
- settings: false,
1287
- label: 'Ignore Order',
1288
- enabled: true
1289
- },
1290
- allowTrailingZeros: {
1291
- settings: false,
1292
- label: 'Allow Trailing Zeros',
1293
- enabled: true
1294
- },
1295
- maxImageWidth: {
1296
- teacherInstructions: 300,
1297
- prompt: 300,
1298
- rationale: 300
1299
- },
1300
- maxImageHeight: {
1301
- teacherInstructions: 300,
1302
- prompt: 300,
1303
- rationale: 300
1304
- },
1305
- withRubric: {
1306
- settings: false,
1307
- label: 'Add Rubric'
1308
- },
1309
- mathMlOptions: {
1310
- mmlOutput: false,
1311
- mmlEditing: false
1312
- },
1313
- language: {
1314
- settings: false,
1315
- label: 'Specify Language',
1316
- enabled: false
1317
- },
1318
- languageChoices: {
1319
- label: 'Language Choices',
1320
- options: []
1321
- }
1322
- }
1323
- };
1324
-
1325
- const log = debug('pie-elements:math-inline:configure');
1326
- class MathInlineConfigure extends HTMLElement {
1327
- constructor() {
1328
- super();
1329
- this._model = MathInlineConfigure.createDefaultModel();
1330
- this._configuration = defaults.configuration;
1331
- }
1332
-
1333
- set model(m) {
1334
- this._model = MathInlineConfigure.createDefaultModel(m);
1335
-
1336
- this._render();
1337
- }
1338
-
1339
- set configuration(c) {
1340
- var _newConfiguration$lan;
1341
-
1342
- const newConfiguration = _extends({}, defaults.configuration, c);
1343
-
1344
- this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
1345
- // if it is false, then the language field should be omitted from the item model.
1346
- // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
1347
- // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
1348
-
1349
- if (newConfiguration != null && (_newConfiguration$lan = newConfiguration.language) != null && _newConfiguration$lan.enabled) {
1350
- var _newConfiguration$lan2, _newConfiguration$lan3;
1351
-
1352
- if (newConfiguration != null && (_newConfiguration$lan2 = newConfiguration.languageChoices) != null && (_newConfiguration$lan3 = _newConfiguration$lan2.options) != null && _newConfiguration$lan3.length) {
1353
- this._model.language = newConfiguration == null ? void 0 : newConfiguration.languageChoices.options[0].value;
1354
- }
1355
- } else if (newConfiguration.language.settings && this._model.language) {
1356
- this._configuration.language.enabled = true;
1357
-
1358
- if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
1359
- this._configuration.languageChoices.options = [];
1360
- } // check if the language is already included in the languageChoices.options array
1361
- // and if not, then add it.
1362
-
1363
-
1364
- if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
1365
- this._configuration.languageChoices.options.push({
1366
- value: this._model.language,
1367
- label: this._model.language
1368
- });
1369
- }
1370
- } else {
1371
- delete this._model.language;
1372
- }
1373
-
1374
- this._render();
1375
- }
1376
-
1377
- onModelChanged(model) {
1378
- this._model = model;
1379
- log('[onModelChanged]: ', this._model);
1380
-
1381
- this._render();
1382
-
1383
- this.dispatchEvent(new ModelUpdatedEvent(this._model));
1384
- }
1385
-
1386
- onConfigurationChanged(c) {
1387
- this._configuration = c;
1388
-
1389
- if (this._model) {
1390
- this.onModelChanged(this._model);
1391
- }
1392
-
1393
- this._render();
1394
- }
1395
- /**
1396
- *
1397
- * @param {done, progress, file} handler
1398
- */
1399
-
1400
-
1401
- insertImage(handler) {
1402
- this.dispatchEvent(new InsertImageEvent(handler));
1403
- }
1404
-
1405
- onDeleteImage(src, done) {
1406
- this.dispatchEvent(new DeleteImageEvent(src, done));
1407
- }
1408
-
1409
- insertSound(handler) {
1410
- this.dispatchEvent(new InsertSoundEvent(handler));
1411
- }
1412
-
1413
- onDeleteSound(src, done) {
1414
- this.dispatchEvent(new DeleteSoundEvent(src, done));
1415
- }
1416
-
1417
- _render() {
1418
- if (this._model) {
1419
- const el = /*#__PURE__*/React__default.createElement(Configure$1, {
1420
- onModelChanged: this.onModelChanged.bind(this),
1421
- onConfigurationChanged: this.onConfigurationChanged.bind(this),
1422
- model: this._model,
1423
- configuration: this._configuration,
1424
- imageSupport: {
1425
- add: this.insertImage.bind(this),
1426
- delete: this.onDeleteImage.bind(this)
1427
- },
1428
- uploadSoundSupport: {
1429
- add: this.insertSound.bind(this),
1430
- delete: this.onDeleteSound.bind(this)
1431
- }
1432
- });
1433
- ReactDOM.render(el, this);
1434
- }
1435
- }
1436
-
1437
- }
1438
-
1439
- MathInlineConfigure.createDefaultModel = (model = {}) => {
1440
- // making sure that defaults are set
1441
- if (!isEmpty(model.responses)) {
1442
- model.responses = model.responses.map(correctResponse => _extends({}, correctResponse, {
1443
- validation: correctResponse.validation || defaults.model.validationDefault,
1444
- allowTrailingZeros: correctResponse.allowTrailingZeros || defaults.model.allowTrailingZerosDefault,
1445
- ignoreOrder: correctResponse.ignoreOrder || defaults.model.ignoreOrderDefault || false
1446
- }));
1447
- }
1448
-
1449
- return _extends({}, defaults.model, model);
1450
- };
1451
-
1452
- export { MathInlineConfigure as default };
1453
- //# sourceMappingURL=configure.js.map