@pie-lib/math-toolbar 1.28.0 → 1.28.3
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/index.js +1410 -0
- package/esm/index.js.map +1 -0
- package/package.json +12 -5
- package/LICENSE.md +0 -5
package/esm/index.js
ADDED
|
@@ -0,0 +1,1410 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import debug from 'debug';
|
|
5
|
+
import Button from '@material-ui/core/Button';
|
|
6
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
7
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
8
|
+
import Select from '@material-ui/core/Select';
|
|
9
|
+
import isEqual from 'lodash/isEqual';
|
|
10
|
+
import { mq, updateSpans, HorizontalKeypad } from '@pie-lib/math-input';
|
|
11
|
+
import { InputContainer, color } from '@pie-lib/render-ui';
|
|
12
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
13
|
+
import require$$3 from '@material-ui/core/SvgIcon';
|
|
14
|
+
|
|
15
|
+
function _extends() {
|
|
16
|
+
_extends = Object.assign || function (target) {
|
|
17
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
+
var source = arguments[i];
|
|
19
|
+
|
|
20
|
+
for (var key in source) {
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
+
target[key] = source[key];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return _extends.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const markFractionBaseSuperscripts = () => {
|
|
34
|
+
document.querySelectorAll('.mq-supsub.mq-sup-only').forEach(supsub => {
|
|
35
|
+
const prev = supsub.previousElementSibling;
|
|
36
|
+
|
|
37
|
+
if (prev && prev.classList.contains('mq-non-leaf') && prev.querySelector('.mq-fraction')) {
|
|
38
|
+
supsub.classList.add('mq-after-fraction-group');
|
|
39
|
+
} else {
|
|
40
|
+
supsub.classList.remove('mq-after-fraction-group');
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
commonMqFontStyles: commonMqFontStyles$1,
|
|
47
|
+
commonMqKeyboardStyles,
|
|
48
|
+
longdivStyles: longdivStyles$1,
|
|
49
|
+
supsubStyles: supsubStyles$1
|
|
50
|
+
} = mq.CommonMqStyles;
|
|
51
|
+
const log$1 = debug('@pie-lib:math-toolbar:editor-and-pad');
|
|
52
|
+
const decimalRegex = /\.|,/g;
|
|
53
|
+
|
|
54
|
+
const toNodeData = data => {
|
|
55
|
+
if (!data) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
type,
|
|
61
|
+
value
|
|
62
|
+
} = data;
|
|
63
|
+
|
|
64
|
+
if (type === 'command' || type === 'cursor') {
|
|
65
|
+
return data;
|
|
66
|
+
} else if (type === 'answer') {
|
|
67
|
+
return _extends({
|
|
68
|
+
type: 'answer'
|
|
69
|
+
}, data);
|
|
70
|
+
} else if (value === 'clear') {
|
|
71
|
+
return {
|
|
72
|
+
type: 'clear'
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
return {
|
|
76
|
+
type: 'write',
|
|
77
|
+
value
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
class EditorAndPad extends React.Component {
|
|
83
|
+
constructor(props) {
|
|
84
|
+
super(props);
|
|
85
|
+
|
|
86
|
+
this.onClick = data => {
|
|
87
|
+
const {
|
|
88
|
+
noDecimal,
|
|
89
|
+
noLatexHandling,
|
|
90
|
+
onChange
|
|
91
|
+
} = this.props;
|
|
92
|
+
const c = toNodeData(data);
|
|
93
|
+
log$1('mathChange: ', c);
|
|
94
|
+
|
|
95
|
+
if (noLatexHandling) {
|
|
96
|
+
onChange(c.value);
|
|
97
|
+
return;
|
|
98
|
+
} // if decimals are not allowed for this response, we discard the input
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if (noDecimal && (c.value === '.' || c.value === ',')) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!c) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (c.type === 'clear') {
|
|
110
|
+
log$1('call clear...');
|
|
111
|
+
this.input.clear();
|
|
112
|
+
} else if (c.type === 'command') {
|
|
113
|
+
this.input.command(c.value);
|
|
114
|
+
} else if (c.type === 'cursor') {
|
|
115
|
+
this.input.keystroke(c.value);
|
|
116
|
+
} else if (c.type === 'answer') {
|
|
117
|
+
this.input.write('%response%');
|
|
118
|
+
} else {
|
|
119
|
+
this.input.write(c.value);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
this.updateDisable = isEdit => {
|
|
124
|
+
const {
|
|
125
|
+
maxResponseAreas
|
|
126
|
+
} = this.props;
|
|
127
|
+
|
|
128
|
+
if (maxResponseAreas) {
|
|
129
|
+
const shouldDisable = this.checkResponseAreasNumber(maxResponseAreas, isEdit);
|
|
130
|
+
this.setState({
|
|
131
|
+
addDisabled: shouldDisable
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
this.onAnswerBlockClick = () => {
|
|
137
|
+
this.props.onAnswerBlockAdd();
|
|
138
|
+
this.onClick({
|
|
139
|
+
type: 'answer'
|
|
140
|
+
});
|
|
141
|
+
this.updateDisable(true);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
this.onEditorChange = latex => {
|
|
145
|
+
const {
|
|
146
|
+
onChange,
|
|
147
|
+
noDecimal
|
|
148
|
+
} = this.props;
|
|
149
|
+
updateSpans();
|
|
150
|
+
markFractionBaseSuperscripts();
|
|
151
|
+
this.updateDisable(true); // if no decimals are allowed and the last change is a decimal dot, discard the change
|
|
152
|
+
|
|
153
|
+
if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && this.input) {
|
|
154
|
+
this.input.clear();
|
|
155
|
+
this.input.write(latex.replace(decimalRegex, ''));
|
|
156
|
+
return;
|
|
157
|
+
} // eslint-disable-next-line no-useless-escape
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
const regexMatch = latex.match(/[0-9]\\ \\frac\{[^\{]*\}\{ \}/);
|
|
161
|
+
|
|
162
|
+
if (this.input && regexMatch && regexMatch != null && regexMatch.length) {
|
|
163
|
+
try {
|
|
164
|
+
this.input.mathField.__controller.cursor.insLeftOf(this.input.mathField.__controller.cursor.parent[-1].parent);
|
|
165
|
+
|
|
166
|
+
this.input.mathField.el().dispatchEvent(new KeyboardEvent('keydown', {
|
|
167
|
+
keyCode: 8
|
|
168
|
+
}));
|
|
169
|
+
} catch (e) {
|
|
170
|
+
// eslint-disable-next-line no-console
|
|
171
|
+
console.error(e.toString());
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
onChange(latex);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
this.onEditorTypeChange = evt => {
|
|
181
|
+
this.setState({
|
|
182
|
+
equationEditor: evt.target.value
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
this.checkResponseAreasNumber = (maxResponseAreas, isEdit) => {
|
|
187
|
+
const {
|
|
188
|
+
latex
|
|
189
|
+
} = this.input && this.input.props || {};
|
|
190
|
+
|
|
191
|
+
if (latex) {
|
|
192
|
+
const count = (latex.match(/answerBlock/g) || []).length;
|
|
193
|
+
return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return false;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
this.state = {
|
|
200
|
+
equationEditor: 'item-authoring',
|
|
201
|
+
addDisabled: false
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
componentDidMount() {
|
|
206
|
+
if (this.input && this.props.autoFocus) {
|
|
207
|
+
this.input.focus();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Only render if the mathquill instance's latex is different
|
|
212
|
+
* or the keypad state changed from one state to the other (shown / hidden) */
|
|
213
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
214
|
+
const inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
|
|
215
|
+
log$1('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
|
|
216
|
+
|
|
217
|
+
if (!isEqual(this.props.error, nextProps.error)) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!inputIsDifferent && this.props.controlledKeypad) {
|
|
234
|
+
return this.props.showKeypad !== nextProps.showKeypad;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return inputIsDifferent;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
render() {
|
|
241
|
+
const {
|
|
242
|
+
classNames,
|
|
243
|
+
keypadMode,
|
|
244
|
+
allowAnswerBlock,
|
|
245
|
+
additionalKeys,
|
|
246
|
+
controlledKeypad,
|
|
247
|
+
controlledKeypadMode,
|
|
248
|
+
showKeypad,
|
|
249
|
+
setKeypadInteraction,
|
|
250
|
+
noDecimal,
|
|
251
|
+
hideInput,
|
|
252
|
+
layoutForKeyPad,
|
|
253
|
+
latex,
|
|
254
|
+
onFocus,
|
|
255
|
+
onBlur,
|
|
256
|
+
classes,
|
|
257
|
+
error
|
|
258
|
+
} = this.props;
|
|
259
|
+
const shouldShowKeypad = !controlledKeypad || controlledKeypad && showKeypad;
|
|
260
|
+
const {
|
|
261
|
+
addDisabled
|
|
262
|
+
} = this.state;
|
|
263
|
+
log$1('[render]', latex);
|
|
264
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
265
|
+
className: cx(classes.mathToolbar, classNames.mathToolbar)
|
|
266
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
267
|
+
className: cx(classes.inputAndTypeContainer, {
|
|
268
|
+
[classes.hide]: hideInput
|
|
269
|
+
})
|
|
270
|
+
}, controlledKeypadMode && /*#__PURE__*/React.createElement(InputContainer, {
|
|
271
|
+
label: "Equation Editor",
|
|
272
|
+
className: classes.selectContainer
|
|
273
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
274
|
+
className: classes.select,
|
|
275
|
+
onChange: this.onEditorTypeChange,
|
|
276
|
+
value: this.state.equationEditor
|
|
277
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
278
|
+
value: "non-negative-integers"
|
|
279
|
+
}, "Numeric - Non-Negative Integers"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
280
|
+
value: "integers"
|
|
281
|
+
}, "Numeric - Integers"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
282
|
+
value: "decimals"
|
|
283
|
+
}, "Numeric - Decimals"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
284
|
+
value: "fractions"
|
|
285
|
+
}, "Numeric - Fractions"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
286
|
+
value: 1
|
|
287
|
+
}, "Grade 1 - 2"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
288
|
+
value: 3
|
|
289
|
+
}, "Grade 3 - 5"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
290
|
+
value: 6
|
|
291
|
+
}, "Grade 6 - 7"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
292
|
+
value: 8
|
|
293
|
+
}, "Grade 8 - HS"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
294
|
+
value: 'geometry'
|
|
295
|
+
}, "Geometry"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
296
|
+
value: 'advanced-algebra'
|
|
297
|
+
}, "Advanced Algebra"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
298
|
+
value: 'statistics'
|
|
299
|
+
}, "Statistics"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
300
|
+
value: 'item-authoring'
|
|
301
|
+
}, "Item Authoring"))), /*#__PURE__*/React.createElement("div", {
|
|
302
|
+
className: cx(classes.inputContainer, error ? classes.error : '')
|
|
303
|
+
}, /*#__PURE__*/React.createElement(mq.Input, {
|
|
304
|
+
onFocus: () => {
|
|
305
|
+
onFocus && onFocus();
|
|
306
|
+
this.updateDisable(false);
|
|
307
|
+
},
|
|
308
|
+
onBlur: event => {
|
|
309
|
+
this.updateDisable(false);
|
|
310
|
+
onBlur && onBlur(event);
|
|
311
|
+
},
|
|
312
|
+
className: cx(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : ''),
|
|
313
|
+
innerRef: r => this.input = r,
|
|
314
|
+
latex: latex,
|
|
315
|
+
onChange: this.onEditorChange
|
|
316
|
+
}))), allowAnswerBlock && /*#__PURE__*/React.createElement(Button, {
|
|
317
|
+
className: classes.addAnswerBlockButton,
|
|
318
|
+
type: "primary",
|
|
319
|
+
style: {
|
|
320
|
+
bottom: shouldShowKeypad ? '320px' : '20px'
|
|
321
|
+
},
|
|
322
|
+
onClick: this.onAnswerBlockClick,
|
|
323
|
+
disabled: addDisabled
|
|
324
|
+
}, "+ Response Area"), /*#__PURE__*/React.createElement("hr", {
|
|
325
|
+
className: classes.hr
|
|
326
|
+
}), shouldShowKeypad && /*#__PURE__*/React.createElement(HorizontalKeypad, {
|
|
327
|
+
className: cx(classes[keypadMode], classes.keyboard),
|
|
328
|
+
controlledKeypadMode: controlledKeypadMode,
|
|
329
|
+
layoutForKeyPad: layoutForKeyPad,
|
|
330
|
+
additionalKeys: additionalKeys,
|
|
331
|
+
mode: controlledKeypadMode ? this.state.equationEditor : keypadMode,
|
|
332
|
+
onClick: this.onClick,
|
|
333
|
+
noDecimal: noDecimal,
|
|
334
|
+
setKeypadInteraction: setKeypadInteraction
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
}
|
|
339
|
+
EditorAndPad.propTypes = {
|
|
340
|
+
classNames: PropTypes.object,
|
|
341
|
+
keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
342
|
+
autoFocus: PropTypes.bool,
|
|
343
|
+
allowAnswerBlock: PropTypes.bool,
|
|
344
|
+
showKeypad: PropTypes.bool,
|
|
345
|
+
controlledKeypad: PropTypes.bool,
|
|
346
|
+
controlledKeypadMode: PropTypes.bool,
|
|
347
|
+
error: PropTypes.string,
|
|
348
|
+
noDecimal: PropTypes.bool,
|
|
349
|
+
hideInput: PropTypes.bool,
|
|
350
|
+
noLatexHandling: PropTypes.bool,
|
|
351
|
+
layoutForKeyPad: PropTypes.object,
|
|
352
|
+
maxResponseAreas: PropTypes.number,
|
|
353
|
+
additionalKeys: PropTypes.array,
|
|
354
|
+
latex: PropTypes.string.isRequired,
|
|
355
|
+
onAnswerBlockAdd: PropTypes.func,
|
|
356
|
+
onFocus: PropTypes.func,
|
|
357
|
+
onBlur: PropTypes.func,
|
|
358
|
+
onChange: PropTypes.func.isRequired,
|
|
359
|
+
classes: PropTypes.object,
|
|
360
|
+
setKeypadInteraction: PropTypes.func
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const styles$2 = theme => ({
|
|
364
|
+
inputAndTypeContainer: {
|
|
365
|
+
display: 'flex',
|
|
366
|
+
alignItems: 'center',
|
|
367
|
+
'& .mq-editable-field .mq-cursor': {
|
|
368
|
+
top: '-4px'
|
|
369
|
+
},
|
|
370
|
+
'& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {
|
|
371
|
+
paddingTop: '18px'
|
|
372
|
+
},
|
|
373
|
+
'& .mq-math-mode .mq-overarrow': {
|
|
374
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
375
|
+
},
|
|
376
|
+
'& .mq-math-mode .mq-overline .mq-overline-inner': {
|
|
377
|
+
paddingTop: '0.4em !important'
|
|
378
|
+
},
|
|
379
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
380
|
+
minWidth: '1.23em',
|
|
381
|
+
'& *': {
|
|
382
|
+
lineHeight: '1 !important'
|
|
383
|
+
},
|
|
384
|
+
'&:before': {
|
|
385
|
+
top: '-0.45em',
|
|
386
|
+
left: '-1px'
|
|
387
|
+
},
|
|
388
|
+
'&:after': {
|
|
389
|
+
position: 'absolute !important',
|
|
390
|
+
top: '0px !important',
|
|
391
|
+
right: '-2px'
|
|
392
|
+
},
|
|
393
|
+
'&.mq-empty:after': {
|
|
394
|
+
top: '-0.45em'
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
398
|
+
'&:before': {
|
|
399
|
+
top: '-0.4em',
|
|
400
|
+
right: '-1px'
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
'& *': _extends({}, commonMqFontStyles$1, supsubStyles$1, longdivStyles$1, {
|
|
404
|
+
'& .mq-math-mode .mq-sqrt-prefix': {
|
|
405
|
+
verticalAlign: 'baseline !important',
|
|
406
|
+
top: '1px !important',
|
|
407
|
+
left: '-0.1em !important'
|
|
408
|
+
},
|
|
409
|
+
'& .mq-math-mode .mq-overarc ': {
|
|
410
|
+
paddingTop: '0.45em !important'
|
|
411
|
+
},
|
|
412
|
+
'& .mq-math-mode .mq-empty': {
|
|
413
|
+
padding: '9px 1px !important'
|
|
414
|
+
},
|
|
415
|
+
'& .mq-math-mode .mq-root-block': {
|
|
416
|
+
paddingTop: '10px'
|
|
417
|
+
},
|
|
418
|
+
'& .mq-scaled .mq-sqrt-prefix': {
|
|
419
|
+
top: '0 !important'
|
|
420
|
+
},
|
|
421
|
+
'& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
422
|
+
marginLeft: '4px !important',
|
|
423
|
+
paddingTop: '6px !important',
|
|
424
|
+
paddingLeft: '6px !important'
|
|
425
|
+
},
|
|
426
|
+
'& .mq-math-mode .mq-paren': {
|
|
427
|
+
verticalAlign: 'top !important',
|
|
428
|
+
padding: '1px 0.1em !important'
|
|
429
|
+
},
|
|
430
|
+
'& .mq-math-mode .mq-sqrt-stem': {
|
|
431
|
+
borderTop: '0.07em solid',
|
|
432
|
+
marginLeft: '-1.5px',
|
|
433
|
+
marginTop: '-2px !important',
|
|
434
|
+
paddingTop: '5px !important'
|
|
435
|
+
},
|
|
436
|
+
'& .mq-math-mode .mq-denominator': {
|
|
437
|
+
marginTop: '-5px !important',
|
|
438
|
+
padding: '0.5em 0.1em 0.1em !important'
|
|
439
|
+
},
|
|
440
|
+
'& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
441
|
+
padding: '0 0.1em !important',
|
|
442
|
+
paddingBottom: '0 !important',
|
|
443
|
+
marginBottom: '-2px'
|
|
444
|
+
}
|
|
445
|
+
}),
|
|
446
|
+
'& span[data-prime="true"]': {
|
|
447
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
hide: {
|
|
451
|
+
display: 'none'
|
|
452
|
+
},
|
|
453
|
+
selectContainer: {
|
|
454
|
+
flex: 'initial',
|
|
455
|
+
width: '25%',
|
|
456
|
+
minWidth: '100px',
|
|
457
|
+
marginLeft: '15px',
|
|
458
|
+
marginTop: '5px',
|
|
459
|
+
marginBottom: '5px',
|
|
460
|
+
marginRight: '5px',
|
|
461
|
+
'& label': {
|
|
462
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
463
|
+
},
|
|
464
|
+
'& div': {
|
|
465
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
mathEditor: {
|
|
469
|
+
maxWidth: '400px',
|
|
470
|
+
color: color.text(),
|
|
471
|
+
backgroundColor: color.background(),
|
|
472
|
+
padding: '2px'
|
|
473
|
+
},
|
|
474
|
+
longMathEditor: {
|
|
475
|
+
maxWidth: '500px'
|
|
476
|
+
},
|
|
477
|
+
addAnswerBlockButton: {
|
|
478
|
+
position: 'absolute',
|
|
479
|
+
right: '12px',
|
|
480
|
+
border: '1px solid lightgrey'
|
|
481
|
+
},
|
|
482
|
+
hr: {
|
|
483
|
+
padding: 0,
|
|
484
|
+
margin: 0,
|
|
485
|
+
height: '1px',
|
|
486
|
+
border: 'none',
|
|
487
|
+
borderBottom: `solid 1px ${theme.palette.primary.main}`
|
|
488
|
+
},
|
|
489
|
+
mathToolbar: {
|
|
490
|
+
zIndex: 9,
|
|
491
|
+
position: 'relative',
|
|
492
|
+
textAlign: 'center',
|
|
493
|
+
width: 'auto',
|
|
494
|
+
'& > .mq-math-mode': {
|
|
495
|
+
border: 'solid 1px lightgrey'
|
|
496
|
+
},
|
|
497
|
+
'& > .mq-focused': {
|
|
498
|
+
outline: 'none',
|
|
499
|
+
boxShadow: 'none',
|
|
500
|
+
border: `dotted 1px ${theme.palette.primary.main}`,
|
|
501
|
+
borderRadius: '0px'
|
|
502
|
+
},
|
|
503
|
+
'& .mq-overarrow-inner': {
|
|
504
|
+
border: 'none !important',
|
|
505
|
+
paddingTop: '0 !important'
|
|
506
|
+
},
|
|
507
|
+
'& .mq-overarrow-inner-right': {
|
|
508
|
+
display: 'none !important'
|
|
509
|
+
},
|
|
510
|
+
'& .mq-overarrow-inner-left': {
|
|
511
|
+
display: 'none !important'
|
|
512
|
+
},
|
|
513
|
+
'& .mq-longdiv-inner': {
|
|
514
|
+
borderTop: '1px solid !important',
|
|
515
|
+
paddingTop: '1.5px !important'
|
|
516
|
+
},
|
|
517
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
518
|
+
top: '7.8px',
|
|
519
|
+
marginTop: '0px',
|
|
520
|
+
minWidth: '1.23em'
|
|
521
|
+
},
|
|
522
|
+
'& .mq-parallelogram': {
|
|
523
|
+
lineHeight: 0.85
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
inputContainer: {
|
|
527
|
+
minWidth: '500px',
|
|
528
|
+
maxWidth: '900px',
|
|
529
|
+
minHeight: '30px',
|
|
530
|
+
width: '100%',
|
|
531
|
+
display: 'flex',
|
|
532
|
+
marginTop: theme.spacing.unit,
|
|
533
|
+
marginBottom: theme.spacing.unit,
|
|
534
|
+
'& .mq-sqrt-prefix .mq-scaled': {
|
|
535
|
+
verticalAlign: 'middle !important'
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
error: {
|
|
539
|
+
border: '2px solid red'
|
|
540
|
+
},
|
|
541
|
+
keyboard: commonMqKeyboardStyles,
|
|
542
|
+
language: {
|
|
543
|
+
'& *': {
|
|
544
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
var EditorAndPad$1 = withStyles(styles$2)(EditorAndPad);
|
|
550
|
+
|
|
551
|
+
function getDefaultExportFromCjs (x) {
|
|
552
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
var Check$1 = {};
|
|
556
|
+
|
|
557
|
+
var interopRequireDefault = {exports: {}};
|
|
558
|
+
|
|
559
|
+
var hasRequiredInteropRequireDefault;
|
|
560
|
+
|
|
561
|
+
function requireInteropRequireDefault () {
|
|
562
|
+
if (hasRequiredInteropRequireDefault) return interopRequireDefault.exports;
|
|
563
|
+
hasRequiredInteropRequireDefault = 1;
|
|
564
|
+
(function (module) {
|
|
565
|
+
function _interopRequireDefault(obj) {
|
|
566
|
+
return obj && obj.__esModule ? obj : {
|
|
567
|
+
"default": obj
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
572
|
+
} (interopRequireDefault));
|
|
573
|
+
return interopRequireDefault.exports;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
var createSvgIcon = {};
|
|
577
|
+
|
|
578
|
+
var pure = {};
|
|
579
|
+
|
|
580
|
+
var shouldUpdate = {};
|
|
581
|
+
|
|
582
|
+
var inheritsLoose = {exports: {}};
|
|
583
|
+
|
|
584
|
+
var setPrototypeOf = {exports: {}};
|
|
585
|
+
|
|
586
|
+
var hasRequiredSetPrototypeOf;
|
|
587
|
+
|
|
588
|
+
function requireSetPrototypeOf () {
|
|
589
|
+
if (hasRequiredSetPrototypeOf) return setPrototypeOf.exports;
|
|
590
|
+
hasRequiredSetPrototypeOf = 1;
|
|
591
|
+
(function (module) {
|
|
592
|
+
function _setPrototypeOf(o, p) {
|
|
593
|
+
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
594
|
+
o.__proto__ = p;
|
|
595
|
+
return o;
|
|
596
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
597
|
+
return _setPrototypeOf(o, p);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
601
|
+
} (setPrototypeOf));
|
|
602
|
+
return setPrototypeOf.exports;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
var hasRequiredInheritsLoose;
|
|
606
|
+
|
|
607
|
+
function requireInheritsLoose () {
|
|
608
|
+
if (hasRequiredInheritsLoose) return inheritsLoose.exports;
|
|
609
|
+
hasRequiredInheritsLoose = 1;
|
|
610
|
+
(function (module) {
|
|
611
|
+
var setPrototypeOf = requireSetPrototypeOf();
|
|
612
|
+
|
|
613
|
+
function _inheritsLoose(subClass, superClass) {
|
|
614
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
615
|
+
subClass.prototype.constructor = subClass;
|
|
616
|
+
setPrototypeOf(subClass, superClass);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
module.exports = _inheritsLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
620
|
+
} (inheritsLoose));
|
|
621
|
+
return inheritsLoose.exports;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
var setDisplayName = {};
|
|
625
|
+
|
|
626
|
+
var setStatic = {};
|
|
627
|
+
|
|
628
|
+
var hasRequiredSetStatic;
|
|
629
|
+
|
|
630
|
+
function requireSetStatic () {
|
|
631
|
+
if (hasRequiredSetStatic) return setStatic;
|
|
632
|
+
hasRequiredSetStatic = 1;
|
|
633
|
+
|
|
634
|
+
setStatic.__esModule = true;
|
|
635
|
+
setStatic.default = void 0;
|
|
636
|
+
|
|
637
|
+
var setStatic$1 = function setStatic(key, value) {
|
|
638
|
+
return function (BaseComponent) {
|
|
639
|
+
/* eslint-disable no-param-reassign */
|
|
640
|
+
BaseComponent[key] = value;
|
|
641
|
+
/* eslint-enable no-param-reassign */
|
|
642
|
+
|
|
643
|
+
return BaseComponent;
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
var _default = setStatic$1;
|
|
648
|
+
setStatic.default = _default;
|
|
649
|
+
return setStatic;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
var hasRequiredSetDisplayName;
|
|
653
|
+
|
|
654
|
+
function requireSetDisplayName () {
|
|
655
|
+
if (hasRequiredSetDisplayName) return setDisplayName;
|
|
656
|
+
hasRequiredSetDisplayName = 1;
|
|
657
|
+
|
|
658
|
+
var _interopRequireDefault = requireInteropRequireDefault();
|
|
659
|
+
|
|
660
|
+
setDisplayName.__esModule = true;
|
|
661
|
+
setDisplayName.default = void 0;
|
|
662
|
+
|
|
663
|
+
var _setStatic = _interopRequireDefault(requireSetStatic());
|
|
664
|
+
|
|
665
|
+
var setDisplayName$1 = function setDisplayName(displayName) {
|
|
666
|
+
return (0, _setStatic.default)('displayName', displayName);
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
var _default = setDisplayName$1;
|
|
670
|
+
setDisplayName.default = _default;
|
|
671
|
+
return setDisplayName;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
var wrapDisplayName = {};
|
|
675
|
+
|
|
676
|
+
var getDisplayName = {};
|
|
677
|
+
|
|
678
|
+
var hasRequiredGetDisplayName;
|
|
679
|
+
|
|
680
|
+
function requireGetDisplayName () {
|
|
681
|
+
if (hasRequiredGetDisplayName) return getDisplayName;
|
|
682
|
+
hasRequiredGetDisplayName = 1;
|
|
683
|
+
|
|
684
|
+
getDisplayName.__esModule = true;
|
|
685
|
+
getDisplayName.default = void 0;
|
|
686
|
+
|
|
687
|
+
var getDisplayName$1 = function getDisplayName(Component) {
|
|
688
|
+
if (typeof Component === 'string') {
|
|
689
|
+
return Component;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (!Component) {
|
|
693
|
+
return undefined;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
return Component.displayName || Component.name || 'Component';
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
var _default = getDisplayName$1;
|
|
700
|
+
getDisplayName.default = _default;
|
|
701
|
+
return getDisplayName;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
var hasRequiredWrapDisplayName;
|
|
705
|
+
|
|
706
|
+
function requireWrapDisplayName () {
|
|
707
|
+
if (hasRequiredWrapDisplayName) return wrapDisplayName;
|
|
708
|
+
hasRequiredWrapDisplayName = 1;
|
|
709
|
+
|
|
710
|
+
var _interopRequireDefault = requireInteropRequireDefault();
|
|
711
|
+
|
|
712
|
+
wrapDisplayName.__esModule = true;
|
|
713
|
+
wrapDisplayName.default = void 0;
|
|
714
|
+
|
|
715
|
+
var _getDisplayName = _interopRequireDefault(requireGetDisplayName());
|
|
716
|
+
|
|
717
|
+
var wrapDisplayName$1 = function wrapDisplayName(BaseComponent, hocName) {
|
|
718
|
+
return hocName + "(" + (0, _getDisplayName.default)(BaseComponent) + ")";
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
var _default = wrapDisplayName$1;
|
|
722
|
+
wrapDisplayName.default = _default;
|
|
723
|
+
return wrapDisplayName;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
var hasRequiredShouldUpdate;
|
|
727
|
+
|
|
728
|
+
function requireShouldUpdate () {
|
|
729
|
+
if (hasRequiredShouldUpdate) return shouldUpdate;
|
|
730
|
+
hasRequiredShouldUpdate = 1;
|
|
731
|
+
|
|
732
|
+
var _interopRequireDefault = requireInteropRequireDefault();
|
|
733
|
+
|
|
734
|
+
shouldUpdate.__esModule = true;
|
|
735
|
+
shouldUpdate.default = void 0;
|
|
736
|
+
|
|
737
|
+
var _inheritsLoose2 = _interopRequireDefault(requireInheritsLoose());
|
|
738
|
+
|
|
739
|
+
var _react = React;
|
|
740
|
+
|
|
741
|
+
var _setDisplayName = _interopRequireDefault(requireSetDisplayName());
|
|
742
|
+
|
|
743
|
+
var _wrapDisplayName = _interopRequireDefault(requireWrapDisplayName());
|
|
744
|
+
|
|
745
|
+
var shouldUpdate$1 = function shouldUpdate(test) {
|
|
746
|
+
return function (BaseComponent) {
|
|
747
|
+
var factory = (0, _react.createFactory)(BaseComponent);
|
|
748
|
+
|
|
749
|
+
var ShouldUpdate =
|
|
750
|
+
/*#__PURE__*/
|
|
751
|
+
function (_Component) {
|
|
752
|
+
(0, _inheritsLoose2.default)(ShouldUpdate, _Component);
|
|
753
|
+
|
|
754
|
+
function ShouldUpdate() {
|
|
755
|
+
return _Component.apply(this, arguments) || this;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
var _proto = ShouldUpdate.prototype;
|
|
759
|
+
|
|
760
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
761
|
+
return test(this.props, nextProps);
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
_proto.render = function render() {
|
|
765
|
+
return factory(this.props);
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
return ShouldUpdate;
|
|
769
|
+
}(_react.Component);
|
|
770
|
+
|
|
771
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
772
|
+
return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'shouldUpdate'))(ShouldUpdate);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
return ShouldUpdate;
|
|
776
|
+
};
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
var _default = shouldUpdate$1;
|
|
780
|
+
shouldUpdate.default = _default;
|
|
781
|
+
return shouldUpdate;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
var shallowEqual = {};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
788
|
+
*
|
|
789
|
+
* This source code is licensed under the MIT license found in the
|
|
790
|
+
* LICENSE file in the root directory of this source tree.
|
|
791
|
+
*
|
|
792
|
+
* @typechecks
|
|
793
|
+
*
|
|
794
|
+
*/
|
|
795
|
+
|
|
796
|
+
var shallowEqual_1;
|
|
797
|
+
var hasRequiredShallowEqual$1;
|
|
798
|
+
|
|
799
|
+
function requireShallowEqual$1 () {
|
|
800
|
+
if (hasRequiredShallowEqual$1) return shallowEqual_1;
|
|
801
|
+
hasRequiredShallowEqual$1 = 1;
|
|
802
|
+
|
|
803
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
807
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
808
|
+
*/
|
|
809
|
+
function is(x, y) {
|
|
810
|
+
// SameValue algorithm
|
|
811
|
+
if (x === y) {
|
|
812
|
+
// Steps 1-5, 7-10
|
|
813
|
+
// Steps 6.b-6.e: +0 != -0
|
|
814
|
+
// Added the nonzero y check to make Flow happy, but it is redundant
|
|
815
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
816
|
+
} else {
|
|
817
|
+
// Step 6.a: NaN == NaN
|
|
818
|
+
return x !== x && y !== y;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Performs equality by iterating through keys on an object and returning false
|
|
824
|
+
* when any key has values which are not strictly equal between the arguments.
|
|
825
|
+
* Returns true when the values of all keys are strictly equal.
|
|
826
|
+
*/
|
|
827
|
+
function shallowEqual(objA, objB) {
|
|
828
|
+
if (is(objA, objB)) {
|
|
829
|
+
return true;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
833
|
+
return false;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
var keysA = Object.keys(objA);
|
|
837
|
+
var keysB = Object.keys(objB);
|
|
838
|
+
|
|
839
|
+
if (keysA.length !== keysB.length) {
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// Test for A's keys different from B.
|
|
844
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
845
|
+
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
846
|
+
return false;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
shallowEqual_1 = shallowEqual;
|
|
854
|
+
return shallowEqual_1;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
var hasRequiredShallowEqual;
|
|
858
|
+
|
|
859
|
+
function requireShallowEqual () {
|
|
860
|
+
if (hasRequiredShallowEqual) return shallowEqual;
|
|
861
|
+
hasRequiredShallowEqual = 1;
|
|
862
|
+
|
|
863
|
+
var _interopRequireDefault = requireInteropRequireDefault();
|
|
864
|
+
|
|
865
|
+
shallowEqual.__esModule = true;
|
|
866
|
+
shallowEqual.default = void 0;
|
|
867
|
+
|
|
868
|
+
var _shallowEqual = _interopRequireDefault(requireShallowEqual$1());
|
|
869
|
+
|
|
870
|
+
var _default = _shallowEqual.default;
|
|
871
|
+
shallowEqual.default = _default;
|
|
872
|
+
return shallowEqual;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
var hasRequiredPure;
|
|
876
|
+
|
|
877
|
+
function requirePure () {
|
|
878
|
+
if (hasRequiredPure) return pure;
|
|
879
|
+
hasRequiredPure = 1;
|
|
880
|
+
|
|
881
|
+
var _interopRequireDefault = requireInteropRequireDefault();
|
|
882
|
+
|
|
883
|
+
pure.__esModule = true;
|
|
884
|
+
pure.default = void 0;
|
|
885
|
+
|
|
886
|
+
var _shouldUpdate = _interopRequireDefault(requireShouldUpdate());
|
|
887
|
+
|
|
888
|
+
var _shallowEqual = _interopRequireDefault(requireShallowEqual());
|
|
889
|
+
|
|
890
|
+
var _setDisplayName = _interopRequireDefault(requireSetDisplayName());
|
|
891
|
+
|
|
892
|
+
var _wrapDisplayName = _interopRequireDefault(requireWrapDisplayName());
|
|
893
|
+
|
|
894
|
+
var pure$1 = function pure(BaseComponent) {
|
|
895
|
+
var hoc = (0, _shouldUpdate.default)(function (props, nextProps) {
|
|
896
|
+
return !(0, _shallowEqual.default)(props, nextProps);
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
900
|
+
return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'pure'))(hoc(BaseComponent));
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
return hoc(BaseComponent);
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
var _default = pure$1;
|
|
907
|
+
pure.default = _default;
|
|
908
|
+
return pure;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
var hasRequiredCreateSvgIcon;
|
|
912
|
+
|
|
913
|
+
function requireCreateSvgIcon () {
|
|
914
|
+
if (hasRequiredCreateSvgIcon) return createSvgIcon;
|
|
915
|
+
hasRequiredCreateSvgIcon = 1;
|
|
916
|
+
|
|
917
|
+
var _interopRequireDefault = requireInteropRequireDefault();
|
|
918
|
+
|
|
919
|
+
Object.defineProperty(createSvgIcon, "__esModule", {
|
|
920
|
+
value: true
|
|
921
|
+
});
|
|
922
|
+
createSvgIcon.default = void 0;
|
|
923
|
+
|
|
924
|
+
var _react = _interopRequireDefault(React);
|
|
925
|
+
|
|
926
|
+
var _pure = _interopRequireDefault(requirePure());
|
|
927
|
+
|
|
928
|
+
var _SvgIcon = _interopRequireDefault(require$$3);
|
|
929
|
+
|
|
930
|
+
function createSvgIcon$1(path, displayName) {
|
|
931
|
+
var Icon = function Icon(props) {
|
|
932
|
+
return _react.default.createElement(_SvgIcon.default, props, path);
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
Icon.displayName = "".concat(displayName, "Icon");
|
|
936
|
+
Icon = (0, _pure.default)(Icon);
|
|
937
|
+
Icon.muiName = 'SvgIcon';
|
|
938
|
+
return Icon;
|
|
939
|
+
}
|
|
940
|
+
var _default = createSvgIcon$1;
|
|
941
|
+
createSvgIcon.default = _default;
|
|
942
|
+
return createSvgIcon;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
var hasRequiredCheck;
|
|
946
|
+
|
|
947
|
+
function requireCheck () {
|
|
948
|
+
if (hasRequiredCheck) return Check$1;
|
|
949
|
+
hasRequiredCheck = 1;
|
|
950
|
+
|
|
951
|
+
var _interopRequireDefault = requireInteropRequireDefault();
|
|
952
|
+
|
|
953
|
+
Object.defineProperty(Check$1, "__esModule", {
|
|
954
|
+
value: true
|
|
955
|
+
});
|
|
956
|
+
Check$1.default = void 0;
|
|
957
|
+
|
|
958
|
+
var _react = _interopRequireDefault(React);
|
|
959
|
+
|
|
960
|
+
var _createSvgIcon = _interopRequireDefault(/*@__PURE__*/ requireCreateSvgIcon());
|
|
961
|
+
|
|
962
|
+
var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
|
|
963
|
+
fill: "none",
|
|
964
|
+
d: "M0 0h24v24H0z"
|
|
965
|
+
}), _react.default.createElement("path", {
|
|
966
|
+
d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
|
|
967
|
+
})), 'Check');
|
|
968
|
+
|
|
969
|
+
Check$1.default = _default;
|
|
970
|
+
return Check$1;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
var CheckExports = /*@__PURE__*/ requireCheck();
|
|
974
|
+
var Check = /*@__PURE__*/getDefaultExportFromCjs(CheckExports);
|
|
975
|
+
|
|
976
|
+
const RawDoneButton = ({
|
|
977
|
+
classes,
|
|
978
|
+
onClick,
|
|
979
|
+
hideBackground
|
|
980
|
+
}) => /*#__PURE__*/React.createElement(IconButton, {
|
|
981
|
+
"aria-label": "Done",
|
|
982
|
+
className: classes.iconRoot,
|
|
983
|
+
onClick: onClick,
|
|
984
|
+
classes: {
|
|
985
|
+
label: classes.label,
|
|
986
|
+
root: cx(classes.iconRoot, {
|
|
987
|
+
[classes.hideBackground]: hideBackground
|
|
988
|
+
})
|
|
989
|
+
}
|
|
990
|
+
}, /*#__PURE__*/React.createElement(Check, null));
|
|
991
|
+
RawDoneButton.propTypes = {
|
|
992
|
+
classes: PropTypes.object.isRequired,
|
|
993
|
+
onClick: PropTypes.func
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
const styles$1 = theme => ({
|
|
997
|
+
iconRoot: {
|
|
998
|
+
verticalAlign: 'top',
|
|
999
|
+
width: '28px',
|
|
1000
|
+
height: '28px',
|
|
1001
|
+
color: '#00bb00'
|
|
1002
|
+
},
|
|
1003
|
+
hideBackground: {
|
|
1004
|
+
backgroundColor: theme.palette.common.white,
|
|
1005
|
+
'&:hover': {
|
|
1006
|
+
backgroundColor: theme.palette.grey[200]
|
|
1007
|
+
}
|
|
1008
|
+
},
|
|
1009
|
+
label: {
|
|
1010
|
+
position: 'absolute',
|
|
1011
|
+
top: '2px'
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
const DoneButton = withStyles(styles$1)(RawDoneButton);
|
|
1016
|
+
|
|
1017
|
+
const {
|
|
1018
|
+
commonMqFontStyles,
|
|
1019
|
+
longdivStyles,
|
|
1020
|
+
supsubStyles
|
|
1021
|
+
} = mq.CommonMqStyles;
|
|
1022
|
+
const log = debug('@pie-lib:math-toolbar:math-preview');
|
|
1023
|
+
class RawMathPreview extends React.Component {
|
|
1024
|
+
componentDidMount() {
|
|
1025
|
+
markFractionBaseSuperscripts();
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
componentDidUpdate(prevProps) {
|
|
1029
|
+
// Re-run only if LaTeX changed
|
|
1030
|
+
if (this.props.node.data.get('latex') !== prevProps.node.data.get('latex')) {
|
|
1031
|
+
markFractionBaseSuperscripts();
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
render() {
|
|
1036
|
+
log('[render] data: ', this.props.node.data);
|
|
1037
|
+
const latex = this.props.node.data.get('latex');
|
|
1038
|
+
const {
|
|
1039
|
+
classes,
|
|
1040
|
+
isSelected,
|
|
1041
|
+
onFocus,
|
|
1042
|
+
onBlur
|
|
1043
|
+
} = this.props;
|
|
1044
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1045
|
+
className: cx(classes.root, isSelected && classes.selected)
|
|
1046
|
+
}, ' ', /*#__PURE__*/React.createElement("span", {
|
|
1047
|
+
className: classes.insideOverlay
|
|
1048
|
+
}), /*#__PURE__*/React.createElement(mq.Static, {
|
|
1049
|
+
latex: latex,
|
|
1050
|
+
onFocus: onFocus,
|
|
1051
|
+
onBlur: onBlur
|
|
1052
|
+
}));
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
}
|
|
1056
|
+
RawMathPreview.propTypes = {
|
|
1057
|
+
latex: PropTypes.string,
|
|
1058
|
+
node: PropTypes.object,
|
|
1059
|
+
classes: PropTypes.object,
|
|
1060
|
+
isSelected: PropTypes.bool,
|
|
1061
|
+
onFocus: PropTypes.func,
|
|
1062
|
+
onBlur: PropTypes.func
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
const mp = theme => ({
|
|
1066
|
+
root: _extends({
|
|
1067
|
+
display: 'inline-flex',
|
|
1068
|
+
alignItems: 'center',
|
|
1069
|
+
position: 'relative',
|
|
1070
|
+
'& *': commonMqFontStyles
|
|
1071
|
+
}, supsubStyles, longdivStyles, {
|
|
1072
|
+
'& > .mq-math-mode': {
|
|
1073
|
+
border: 'solid 1px lightgrey'
|
|
1074
|
+
},
|
|
1075
|
+
'& > .mq-focused': {
|
|
1076
|
+
outline: 'none',
|
|
1077
|
+
boxShadow: 'none',
|
|
1078
|
+
border: 'solid 1px black',
|
|
1079
|
+
borderRadius: '0px'
|
|
1080
|
+
},
|
|
1081
|
+
'& > .mq-math-mode .mq-root-block': {
|
|
1082
|
+
paddingTop: '7px !important'
|
|
1083
|
+
},
|
|
1084
|
+
'& > .mq-math-mode .mq-overarc ': {
|
|
1085
|
+
paddingTop: '0.45em !important'
|
|
1086
|
+
},
|
|
1087
|
+
'& > .mq-math-mode .mq-sqrt-prefix': {
|
|
1088
|
+
verticalAlign: 'baseline !important',
|
|
1089
|
+
top: '1px !important',
|
|
1090
|
+
left: '-0.1em !important'
|
|
1091
|
+
},
|
|
1092
|
+
'& > .mq-math-mode .mq-denominator': {
|
|
1093
|
+
marginTop: '-5px !important',
|
|
1094
|
+
padding: '0.5em 0.1em 0.1em !important'
|
|
1095
|
+
},
|
|
1096
|
+
'& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
1097
|
+
padding: '0 0.1em !important',
|
|
1098
|
+
paddingBottom: '0 !important',
|
|
1099
|
+
marginBottom: '-2px'
|
|
1100
|
+
},
|
|
1101
|
+
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner .mq-empty': {
|
|
1102
|
+
paddingTop: '6px !important',
|
|
1103
|
+
paddingLeft: '4px !important'
|
|
1104
|
+
},
|
|
1105
|
+
'& > .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
1106
|
+
marginLeft: '0 !important'
|
|
1107
|
+
},
|
|
1108
|
+
'& > .mq-math-mode .mq-overarrow': {
|
|
1109
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
1110
|
+
},
|
|
1111
|
+
'& > .mq-math-mode .mq-paren': {
|
|
1112
|
+
verticalAlign: 'top !important',
|
|
1113
|
+
padding: '1px 0.1em !important'
|
|
1114
|
+
},
|
|
1115
|
+
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
1116
|
+
borderTop: '0.07em solid',
|
|
1117
|
+
marginLeft: '-1.5px',
|
|
1118
|
+
marginTop: '-2px !important',
|
|
1119
|
+
paddingTop: '5px !important'
|
|
1120
|
+
},
|
|
1121
|
+
'& .mq-overarrow-inner': {
|
|
1122
|
+
paddingTop: '0 !important',
|
|
1123
|
+
border: 'none !important'
|
|
1124
|
+
},
|
|
1125
|
+
'& .mq-editable-field .mq-cursor': {
|
|
1126
|
+
marginTop: '-15px !important'
|
|
1127
|
+
},
|
|
1128
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
1129
|
+
top: '7.5px',
|
|
1130
|
+
marginTop: '0px',
|
|
1131
|
+
minWidth: '1.23em',
|
|
1132
|
+
'& *': {
|
|
1133
|
+
lineHeight: '1 !important'
|
|
1134
|
+
},
|
|
1135
|
+
'&:before': {
|
|
1136
|
+
top: '-0.4em',
|
|
1137
|
+
left: '-1px'
|
|
1138
|
+
},
|
|
1139
|
+
// NOTE: This workaround adds `!important` to enforce the correct positioning and styling
|
|
1140
|
+
// of `.mq-overarrow.mq-arrow-both` elements in MathQuill. This ensures consistent display
|
|
1141
|
+
// regardless of the order in which MathQuill is initialized on our websites.
|
|
1142
|
+
//
|
|
1143
|
+
// In the future, investigate why MathQuill scripts and styles are being initialized
|
|
1144
|
+
// more than once and address the root cause to prevent potential conflicts and ensure
|
|
1145
|
+
// optimal performance.
|
|
1146
|
+
'&:after': {
|
|
1147
|
+
top: '0px !important',
|
|
1148
|
+
position: 'absolute !important',
|
|
1149
|
+
right: '-2px'
|
|
1150
|
+
},
|
|
1151
|
+
'&.mq-empty:after': {
|
|
1152
|
+
top: '-0.45em'
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
1156
|
+
'&:before': {
|
|
1157
|
+
top: '-0.4em',
|
|
1158
|
+
right: '-1px'
|
|
1159
|
+
}
|
|
1160
|
+
},
|
|
1161
|
+
'& .mq-overarrow-inner-right': {
|
|
1162
|
+
display: 'none !important'
|
|
1163
|
+
},
|
|
1164
|
+
'& .mq-overarrow-inner-left': {
|
|
1165
|
+
display: 'none !important'
|
|
1166
|
+
},
|
|
1167
|
+
'& .mq-longdiv-inner': {
|
|
1168
|
+
borderTop: '1px solid !important',
|
|
1169
|
+
paddingTop: '1.5px !important'
|
|
1170
|
+
},
|
|
1171
|
+
'& .mq-parallelogram': {
|
|
1172
|
+
lineHeight: 0.85
|
|
1173
|
+
},
|
|
1174
|
+
'& span[data-prime="true"]': {
|
|
1175
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
1176
|
+
}
|
|
1177
|
+
}),
|
|
1178
|
+
selected: {
|
|
1179
|
+
border: `solid 1px ${theme.palette.primary.main}`,
|
|
1180
|
+
'& > .mq-math-mode': {
|
|
1181
|
+
border: 'solid 0px lightgrey'
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
insideOverlay: {
|
|
1185
|
+
position: 'absolute',
|
|
1186
|
+
bottom: 0,
|
|
1187
|
+
left: 0,
|
|
1188
|
+
right: 0,
|
|
1189
|
+
top: 0
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
|
|
1193
|
+
var mathPreview = withStyles(mp)(RawMathPreview);
|
|
1194
|
+
|
|
1195
|
+
class MathToolbar extends React.Component {
|
|
1196
|
+
constructor(props) {
|
|
1197
|
+
super(props);
|
|
1198
|
+
|
|
1199
|
+
this.done = () => {
|
|
1200
|
+
this.props.onDone(this.state.latex);
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
this.onChange = latex => {
|
|
1204
|
+
this.setState({
|
|
1205
|
+
latex
|
|
1206
|
+
});
|
|
1207
|
+
this.props.onChange(latex);
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
this.state = {
|
|
1211
|
+
latex: props.latex
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
1216
|
+
this.setState({
|
|
1217
|
+
latex: nextProps.latex
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
render() {
|
|
1222
|
+
const {
|
|
1223
|
+
latex
|
|
1224
|
+
} = this.state;
|
|
1225
|
+
const {
|
|
1226
|
+
classNames,
|
|
1227
|
+
autoFocus,
|
|
1228
|
+
allowAnswerBlock,
|
|
1229
|
+
onAnswerBlockAdd,
|
|
1230
|
+
controlledKeypad,
|
|
1231
|
+
controlledKeypadMode,
|
|
1232
|
+
keypadMode,
|
|
1233
|
+
noDecimal,
|
|
1234
|
+
additionalKeys,
|
|
1235
|
+
showKeypad,
|
|
1236
|
+
onFocus,
|
|
1237
|
+
onBlur,
|
|
1238
|
+
hideDoneButton,
|
|
1239
|
+
error,
|
|
1240
|
+
keyPadCharacterRef,
|
|
1241
|
+
setKeypadInteraction,
|
|
1242
|
+
maxResponseAreas
|
|
1243
|
+
} = this.props;
|
|
1244
|
+
return /*#__PURE__*/React.createElement(PureToolbar, {
|
|
1245
|
+
autoFocus: autoFocus,
|
|
1246
|
+
classNames: classNames,
|
|
1247
|
+
onAnswerBlockAdd: onAnswerBlockAdd,
|
|
1248
|
+
allowAnswerBlock: allowAnswerBlock,
|
|
1249
|
+
latex: latex,
|
|
1250
|
+
additionalKeys: additionalKeys,
|
|
1251
|
+
noDecimal: noDecimal,
|
|
1252
|
+
keypadMode: keypadMode,
|
|
1253
|
+
keyPadCharacterRef: keyPadCharacterRef,
|
|
1254
|
+
setKeypadInteraction: setKeypadInteraction,
|
|
1255
|
+
onChange: this.onChange,
|
|
1256
|
+
onDone: this.done,
|
|
1257
|
+
onFocus: onFocus,
|
|
1258
|
+
onBlur: onBlur,
|
|
1259
|
+
showKeypad: showKeypad,
|
|
1260
|
+
controlledKeypad: controlledKeypad,
|
|
1261
|
+
controlledKeypadMode: controlledKeypadMode,
|
|
1262
|
+
hideDoneButton: hideDoneButton,
|
|
1263
|
+
error: error,
|
|
1264
|
+
maxResponseAreas: maxResponseAreas
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
}
|
|
1269
|
+
MathToolbar.propTypes = {
|
|
1270
|
+
autoFocus: PropTypes.bool,
|
|
1271
|
+
allowAnswerBlock: PropTypes.bool,
|
|
1272
|
+
controlledKeypad: PropTypes.bool,
|
|
1273
|
+
controlledKeypadMode: PropTypes.bool,
|
|
1274
|
+
keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1275
|
+
classNames: PropTypes.object,
|
|
1276
|
+
error: PropTypes.string,
|
|
1277
|
+
maxResponseAreas: PropTypes.number,
|
|
1278
|
+
showKeypad: PropTypes.bool,
|
|
1279
|
+
noDecimal: PropTypes.bool,
|
|
1280
|
+
additionalKeys: PropTypes.array,
|
|
1281
|
+
latex: PropTypes.string.isRequired,
|
|
1282
|
+
onAnswerBlockAdd: PropTypes.func,
|
|
1283
|
+
onChange: PropTypes.func,
|
|
1284
|
+
onDone: PropTypes.func.isRequired,
|
|
1285
|
+
onFocus: PropTypes.func,
|
|
1286
|
+
onBlur: PropTypes.func,
|
|
1287
|
+
hideDoneButton: PropTypes.bool,
|
|
1288
|
+
keyPadCharacterRef: PropTypes.func,
|
|
1289
|
+
setKeypadInteraction: PropTypes.func
|
|
1290
|
+
};
|
|
1291
|
+
MathToolbar.defaultProps = {
|
|
1292
|
+
classNames: {},
|
|
1293
|
+
keypadMode: 'item-authoring',
|
|
1294
|
+
autoFocus: false,
|
|
1295
|
+
allowAnswerBlock: false,
|
|
1296
|
+
controlledKeypad: false,
|
|
1297
|
+
controlledKeypadMode: false,
|
|
1298
|
+
noDecimal: false,
|
|
1299
|
+
showKeypad: true,
|
|
1300
|
+
additionalKeys: [],
|
|
1301
|
+
onChange: () => {},
|
|
1302
|
+
onAnswerBlockAdd: () => {},
|
|
1303
|
+
onFocus: () => {},
|
|
1304
|
+
hideDoneButton: false
|
|
1305
|
+
};
|
|
1306
|
+
class RawPureToolbar extends React.Component {
|
|
1307
|
+
render() {
|
|
1308
|
+
const {
|
|
1309
|
+
classNames,
|
|
1310
|
+
autoFocus,
|
|
1311
|
+
allowAnswerBlock,
|
|
1312
|
+
onAnswerBlockAdd,
|
|
1313
|
+
controlledKeypad,
|
|
1314
|
+
controlledKeypadMode,
|
|
1315
|
+
additionalKeys,
|
|
1316
|
+
showKeypad,
|
|
1317
|
+
keypadMode,
|
|
1318
|
+
noDecimal,
|
|
1319
|
+
hideInput,
|
|
1320
|
+
noLatexHandling,
|
|
1321
|
+
layoutForKeyPad,
|
|
1322
|
+
keyPadCharacterRef,
|
|
1323
|
+
setKeypadInteraction,
|
|
1324
|
+
latex,
|
|
1325
|
+
onChange,
|
|
1326
|
+
onDone,
|
|
1327
|
+
onFocus,
|
|
1328
|
+
onBlur,
|
|
1329
|
+
hideDoneButton,
|
|
1330
|
+
hideDoneButtonBackground,
|
|
1331
|
+
classes,
|
|
1332
|
+
error,
|
|
1333
|
+
maxResponseAreas
|
|
1334
|
+
} = this.props;
|
|
1335
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1336
|
+
className: cx(classes.pureToolbar, (classNames || {}).toolbar),
|
|
1337
|
+
ref: keyPadCharacterRef
|
|
1338
|
+
}, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement(EditorAndPad$1, {
|
|
1339
|
+
autoFocus: autoFocus,
|
|
1340
|
+
keypadMode: keypadMode,
|
|
1341
|
+
classNames: classNames || {},
|
|
1342
|
+
controlledKeypad: controlledKeypad,
|
|
1343
|
+
controlledKeypadMode: controlledKeypadMode,
|
|
1344
|
+
noDecimal: noDecimal,
|
|
1345
|
+
hideInput: hideInput,
|
|
1346
|
+
noLatexHandling: noLatexHandling,
|
|
1347
|
+
layoutForKeyPad: layoutForKeyPad,
|
|
1348
|
+
showKeypad: showKeypad,
|
|
1349
|
+
additionalKeys: additionalKeys,
|
|
1350
|
+
allowAnswerBlock: allowAnswerBlock,
|
|
1351
|
+
onAnswerBlockAdd: onAnswerBlockAdd,
|
|
1352
|
+
latex: latex,
|
|
1353
|
+
onChange: onChange,
|
|
1354
|
+
onFocus: onFocus,
|
|
1355
|
+
onBlur: onBlur,
|
|
1356
|
+
error: error,
|
|
1357
|
+
maxResponseAreas: maxResponseAreas,
|
|
1358
|
+
setKeypadInteraction: setKeypadInteraction
|
|
1359
|
+
}), (!controlledKeypad || controlledKeypad && showKeypad) && !hideDoneButton && /*#__PURE__*/React.createElement(DoneButton, {
|
|
1360
|
+
hideBackground: hideDoneButtonBackground,
|
|
1361
|
+
onClick: onDone
|
|
1362
|
+
}));
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
}
|
|
1366
|
+
RawPureToolbar.propTypes = {
|
|
1367
|
+
classNames: PropTypes.object,
|
|
1368
|
+
latex: PropTypes.string.isRequired,
|
|
1369
|
+
keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1370
|
+
hideInput: PropTypes.bool,
|
|
1371
|
+
noLatexHandling: PropTypes.bool,
|
|
1372
|
+
layoutForKeyPad: PropTypes.object,
|
|
1373
|
+
onChange: PropTypes.func.isRequired,
|
|
1374
|
+
onDone: PropTypes.func.isRequired,
|
|
1375
|
+
onBlur: PropTypes.func,
|
|
1376
|
+
onAnswerBlockAdd: PropTypes.func,
|
|
1377
|
+
additionalKeys: PropTypes.array,
|
|
1378
|
+
onFocus: PropTypes.func,
|
|
1379
|
+
classes: PropTypes.object.isRequired,
|
|
1380
|
+
autoFocus: PropTypes.bool,
|
|
1381
|
+
noDecimal: PropTypes.bool,
|
|
1382
|
+
allowAnswerBlock: PropTypes.bool,
|
|
1383
|
+
controlledKeypad: PropTypes.bool,
|
|
1384
|
+
controlledKeypadMode: PropTypes.bool,
|
|
1385
|
+
showKeypad: PropTypes.bool,
|
|
1386
|
+
hideDoneButton: PropTypes.bool,
|
|
1387
|
+
hideDoneButtonBackground: PropTypes.bool,
|
|
1388
|
+
error: PropTypes.any,
|
|
1389
|
+
maxResponseAreas: PropTypes.number,
|
|
1390
|
+
keyPadCharacterRef: PropTypes.object,
|
|
1391
|
+
setKeypadInteraction: PropTypes.func
|
|
1392
|
+
};
|
|
1393
|
+
RawPureToolbar.defaultProps = {
|
|
1394
|
+
classNames: {},
|
|
1395
|
+
hideDoneButtonBackground: false
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
const styles = () => ({
|
|
1399
|
+
pureToolbar: {
|
|
1400
|
+
display: 'flex',
|
|
1401
|
+
width: '100%',
|
|
1402
|
+
zIndex: 8,
|
|
1403
|
+
alignItems: 'center'
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
|
|
1407
|
+
const PureToolbar = withStyles(styles)(RawPureToolbar);
|
|
1408
|
+
|
|
1409
|
+
export { mathPreview as MathPreview, MathToolbar, PureToolbar, RawPureToolbar };
|
|
1410
|
+
//# sourceMappingURL=index.js.map
|