@pie-lib/math-toolbar 1.14.0 → 1.15.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.
@@ -1,575 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = exports.EditorAndPad = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
- var _react = _interopRequireDefault(require("react"));
25
-
26
- var _debug = _interopRequireDefault(require("debug"));
27
-
28
- var _propTypes = _interopRequireDefault(require("prop-types"));
29
-
30
- var _classnames = _interopRequireDefault(require("classnames"));
31
-
32
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
33
-
34
- var _styles = require("@material-ui/core/styles");
35
-
36
- var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
37
-
38
- var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
39
-
40
- var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
41
-
42
- var _mathInput = require("@pie-lib/math-input");
43
-
44
- var _index = require("./shared/index");
45
-
46
- var _utils = require("./utils");
47
-
48
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
49
-
50
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
51
-
52
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
53
-
54
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
55
-
56
- var _mq$CommonMqStyles = _mathInput.mq.CommonMqStyles,
57
- commonMqFontStyles = _mq$CommonMqStyles.commonMqFontStyles,
58
- commonMqKeyboardStyles = _mq$CommonMqStyles.commonMqKeyboardStyles,
59
- longdivStyles = _mq$CommonMqStyles.longdivStyles,
60
- supsubStyles = _mq$CommonMqStyles.supsubStyles;
61
- var log = (0, _debug["default"])('@pie-lib:math-toolbar:editor-and-pad');
62
- var decimalRegex = /\.|,/g;
63
-
64
- var toNodeData = function toNodeData(data) {
65
- if (!data) {
66
- return;
67
- }
68
-
69
- var type = data.type,
70
- value = data.value;
71
-
72
- if (type === 'command' || type === 'cursor') {
73
- return data;
74
- } else if (type === 'answer') {
75
- return _objectSpread({
76
- type: 'answer'
77
- }, data);
78
- } else if (value === 'clear') {
79
- return {
80
- type: 'clear'
81
- };
82
- } else {
83
- return {
84
- type: 'write',
85
- value: value
86
- };
87
- }
88
- };
89
-
90
- var EditorAndPad = /*#__PURE__*/function (_React$Component) {
91
- (0, _inherits2["default"])(EditorAndPad, _React$Component);
92
-
93
- var _super = _createSuper(EditorAndPad);
94
-
95
- function EditorAndPad(props) {
96
- var _this;
97
-
98
- (0, _classCallCheck2["default"])(this, EditorAndPad);
99
- _this = _super.call(this, props);
100
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onClick", function (data) {
101
- var _this$props = _this.props,
102
- noDecimal = _this$props.noDecimal,
103
- noLatexHandling = _this$props.noLatexHandling,
104
- onChange = _this$props.onChange;
105
- var c = toNodeData(data);
106
- log('mathChange: ', c);
107
-
108
- if (noLatexHandling) {
109
- onChange(c.value);
110
- return;
111
- } // if decimals are not allowed for this response, we discard the input
112
-
113
-
114
- if (noDecimal && (c.value === '.' || c.value === ',')) {
115
- return;
116
- }
117
-
118
- if (!c) {
119
- return;
120
- }
121
-
122
- if (c.type === 'clear') {
123
- log('call clear...');
124
-
125
- _this.input.clear();
126
- } else if (c.type === 'command') {
127
- _this.input.command(c.value);
128
- } else if (c.type === 'cursor') {
129
- _this.input.keystroke(c.value);
130
- } else if (c.type === 'answer') {
131
- _this.input.write('%response%');
132
- } else {
133
- _this.input.write(c.value);
134
- }
135
- });
136
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateDisable", function (isEdit) {
137
- var maxResponseAreas = _this.props.maxResponseAreas;
138
-
139
- if (maxResponseAreas) {
140
- var shouldDisable = _this.checkResponseAreasNumber(maxResponseAreas, isEdit);
141
-
142
- _this.setState({
143
- addDisabled: shouldDisable
144
- });
145
- }
146
- });
147
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAnswerBlockClick", function () {
148
- _this.props.onAnswerBlockAdd();
149
-
150
- _this.onClick({
151
- type: 'answer'
152
- });
153
-
154
- _this.updateDisable(true);
155
- });
156
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditorChange", function (latex) {
157
- var _this$props2 = _this.props,
158
- onChange = _this$props2.onChange,
159
- noDecimal = _this$props2.noDecimal;
160
- (0, _mathInput.updateSpans)();
161
- (0, _utils.markFractionBaseSuperscripts)();
162
-
163
- _this.updateDisable(true); // if no decimals are allowed and the last change is a decimal dot, discard the change
164
-
165
-
166
- if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && _this.input) {
167
- _this.input.clear();
168
-
169
- _this.input.write(latex.replace(decimalRegex, ''));
170
-
171
- return;
172
- } // eslint-disable-next-line no-useless-escape
173
-
174
-
175
- var regexMatch = latex.match(/[0-9]\\ \\frac\{[^\{]*\}\{ \}/);
176
-
177
- if (_this.input && regexMatch && regexMatch !== null && regexMatch !== void 0 && regexMatch.length) {
178
- try {
179
- _this.input.mathField.__controller.cursor.insLeftOf(_this.input.mathField.__controller.cursor.parent[-1].parent);
180
-
181
- _this.input.mathField.el().dispatchEvent(new KeyboardEvent('keydown', {
182
- keyCode: 8
183
- }));
184
- } catch (e) {
185
- // eslint-disable-next-line no-console
186
- console.error(e.toString());
187
- }
188
-
189
- return;
190
- }
191
-
192
- onChange(latex);
193
- });
194
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditorTypeChange", function (evt) {
195
- _this.setState({
196
- equationEditor: evt.target.value
197
- });
198
- });
199
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "checkResponseAreasNumber", function (maxResponseAreas, isEdit) {
200
- var _ref = _this.input && _this.input.props || {},
201
- latex = _ref.latex;
202
-
203
- if (latex) {
204
- var count = (latex.match(/answerBlock/g) || []).length;
205
- return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
206
- }
207
-
208
- return false;
209
- });
210
- _this.state = {
211
- equationEditor: 'item-authoring',
212
- addDisabled: false
213
- };
214
- return _this;
215
- }
216
-
217
- (0, _createClass2["default"])(EditorAndPad, [{
218
- key: "componentDidMount",
219
- value: function componentDidMount() {
220
- if (this.input && this.props.autoFocus) {
221
- this.input.focus();
222
- }
223
- }
224
- }, {
225
- key: "shouldComponentUpdate",
226
- value:
227
- /** Only render if the mathquill instance's latex is different
228
- * or the keypad state changed from one state to the other (shown / hidden) */
229
- function shouldComponentUpdate(nextProps, nextState) {
230
- var inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
231
- log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
232
-
233
- if (!(0, _isEqual["default"])(this.props.error, nextProps.error)) {
234
- return true;
235
- }
236
-
237
- if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {
238
- return true;
239
- }
240
-
241
- if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {
242
- return true;
243
- }
244
-
245
- if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {
246
- return true;
247
- }
248
-
249
- if (!inputIsDifferent && this.props.controlledKeypad) {
250
- return this.props.showKeypad !== nextProps.showKeypad;
251
- }
252
-
253
- return inputIsDifferent;
254
- }
255
- }, {
256
- key: "render",
257
- value: function render() {
258
- var _this2 = this;
259
-
260
- var _this$props3 = this.props,
261
- classNames = _this$props3.classNames,
262
- keypadMode = _this$props3.keypadMode,
263
- allowAnswerBlock = _this$props3.allowAnswerBlock,
264
- additionalKeys = _this$props3.additionalKeys,
265
- controlledKeypad = _this$props3.controlledKeypad,
266
- controlledKeypadMode = _this$props3.controlledKeypadMode,
267
- showKeypad = _this$props3.showKeypad,
268
- setKeypadInteraction = _this$props3.setKeypadInteraction,
269
- noDecimal = _this$props3.noDecimal,
270
- hideInput = _this$props3.hideInput,
271
- layoutForKeyPad = _this$props3.layoutForKeyPad,
272
- latex = _this$props3.latex,
273
- _onFocus = _this$props3.onFocus,
274
- _onBlur = _this$props3.onBlur,
275
- classes = _this$props3.classes,
276
- error = _this$props3.error;
277
- var shouldShowKeypad = !controlledKeypad || controlledKeypad && showKeypad;
278
- var addDisabled = this.state.addDisabled;
279
- log('[render]', latex);
280
- return /*#__PURE__*/_react["default"].createElement("div", {
281
- className: (0, _classnames["default"])(classes.mathToolbar, classNames.mathToolbar)
282
- }, /*#__PURE__*/_react["default"].createElement("div", {
283
- className: (0, _classnames["default"])(classes.inputAndTypeContainer, (0, _defineProperty2["default"])({}, classes.hide, hideInput))
284
- }, controlledKeypadMode && /*#__PURE__*/_react["default"].createElement(_index.InputContainer, {
285
- label: "Equation Editor",
286
- className: classes.selectContainer
287
- }, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
288
- className: classes.select,
289
- onChange: this.onEditorTypeChange,
290
- value: this.state.equationEditor
291
- }, /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
292
- value: "non-negative-integers"
293
- }, "Numeric - Non-Negative Integers"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
294
- value: "integers"
295
- }, "Numeric - Integers"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
296
- value: "decimals"
297
- }, "Numeric - Decimals"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
298
- value: "fractions"
299
- }, "Numeric - Fractions"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
300
- value: 1
301
- }, "Grade 1 - 2"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
302
- value: 3
303
- }, "Grade 3 - 5"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
304
- value: 6
305
- }, "Grade 6 - 7"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
306
- value: 8
307
- }, "Grade 8 - HS"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
308
- value: 'geometry'
309
- }, "Geometry"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
310
- value: 'advanced-algebra'
311
- }, "Advanced Algebra"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
312
- value: 'statistics'
313
- }, "Statistics"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
314
- value: 'item-authoring'
315
- }, "Item Authoring"))), /*#__PURE__*/_react["default"].createElement("div", {
316
- className: (0, _classnames["default"])(classes.inputContainer, error ? classes.error : '')
317
- }, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Input, {
318
- onFocus: function onFocus() {
319
- _onFocus && _onFocus();
320
-
321
- _this2.updateDisable(false);
322
- },
323
- onBlur: function onBlur(event) {
324
- _this2.updateDisable(false);
325
-
326
- _onBlur && _onBlur(event);
327
- },
328
- className: (0, _classnames["default"])(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : ''),
329
- innerRef: function innerRef(r) {
330
- return _this2.input = r;
331
- },
332
- latex: latex,
333
- onChange: this.onEditorChange
334
- }))), allowAnswerBlock && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
335
- className: classes.addAnswerBlockButton,
336
- type: "primary",
337
- style: {
338
- bottom: shouldShowKeypad ? '320px' : '20px'
339
- },
340
- onClick: this.onAnswerBlockClick,
341
- disabled: addDisabled
342
- }, "+ Response Area"), /*#__PURE__*/_react["default"].createElement("hr", {
343
- className: classes.hr
344
- }), shouldShowKeypad && /*#__PURE__*/_react["default"].createElement(_mathInput.HorizontalKeypad, {
345
- className: (0, _classnames["default"])(classes[keypadMode], classes.keyboard),
346
- controlledKeypadMode: controlledKeypadMode,
347
- layoutForKeyPad: layoutForKeyPad,
348
- additionalKeys: additionalKeys,
349
- mode: controlledKeypadMode ? this.state.equationEditor : keypadMode,
350
- onClick: this.onClick,
351
- noDecimal: noDecimal,
352
- setKeypadInteraction: setKeypadInteraction
353
- }));
354
- }
355
- }]);
356
- return EditorAndPad;
357
- }(_react["default"].Component);
358
-
359
- exports.EditorAndPad = EditorAndPad;
360
- (0, _defineProperty2["default"])(EditorAndPad, "propTypes", {
361
- classNames: _propTypes["default"].object,
362
- keypadMode: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
363
- autoFocus: _propTypes["default"].bool,
364
- allowAnswerBlock: _propTypes["default"].bool,
365
- showKeypad: _propTypes["default"].bool,
366
- controlledKeypad: _propTypes["default"].bool,
367
- controlledKeypadMode: _propTypes["default"].bool,
368
- error: _propTypes["default"].string,
369
- noDecimal: _propTypes["default"].bool,
370
- hideInput: _propTypes["default"].bool,
371
- noLatexHandling: _propTypes["default"].bool,
372
- layoutForKeyPad: _propTypes["default"].object,
373
- maxResponseAreas: _propTypes["default"].number,
374
- additionalKeys: _propTypes["default"].array,
375
- latex: _propTypes["default"].string.isRequired,
376
- onAnswerBlockAdd: _propTypes["default"].func,
377
- onFocus: _propTypes["default"].func,
378
- onBlur: _propTypes["default"].func,
379
- onChange: _propTypes["default"].func.isRequired,
380
- classes: _propTypes["default"].object,
381
- setKeypadInteraction: _propTypes["default"].func
382
- });
383
-
384
- var styles = function styles(theme) {
385
- return {
386
- inputAndTypeContainer: {
387
- display: 'flex',
388
- alignItems: 'center',
389
- '& .mq-editable-field .mq-cursor': {
390
- top: '-4px'
391
- },
392
- '& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {
393
- paddingTop: '18px'
394
- },
395
- '& .mq-math-mode .mq-overarrow': {
396
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
397
- },
398
- '& .mq-math-mode .mq-overline .mq-overline-inner': {
399
- paddingTop: '0.4em !important'
400
- },
401
- '& .mq-overarrow.mq-arrow-both': {
402
- minWidth: '1.23em',
403
- '& *': {
404
- lineHeight: '1 !important'
405
- },
406
- '&:before': {
407
- top: '-0.45em',
408
- left: '-1px'
409
- },
410
- '&:after': {
411
- position: 'absolute !important',
412
- top: '0px !important',
413
- right: '-2px'
414
- },
415
- '&.mq-empty:after': {
416
- top: '-0.45em'
417
- }
418
- },
419
- '& .mq-overarrow.mq-arrow-right': {
420
- '&:before': {
421
- top: '-0.4em',
422
- right: '-1px'
423
- }
424
- },
425
- '& *': _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), supsubStyles), longdivStyles), {}, {
426
- '& .mq-math-mode .mq-sqrt-prefix': {
427
- verticalAlign: 'baseline !important',
428
- top: '1px !important',
429
- left: '-0.1em !important'
430
- },
431
- '& .mq-math-mode .mq-overarc ': {
432
- paddingTop: '0.45em !important'
433
- },
434
- '& .mq-math-mode .mq-empty': {
435
- padding: '9px 1px !important'
436
- },
437
- '& .mq-math-mode .mq-root-block': {
438
- paddingTop: '10px'
439
- },
440
- '& .mq-scaled .mq-sqrt-prefix': {
441
- top: '0 !important'
442
- },
443
- '& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
444
- marginLeft: '4px !important',
445
- paddingTop: '6px !important',
446
- paddingLeft: '6px !important'
447
- },
448
- '& .mq-math-mode .mq-paren': {
449
- verticalAlign: 'top !important',
450
- padding: '1px 0.1em !important'
451
- },
452
- '& .mq-math-mode .mq-sqrt-stem': {
453
- borderTop: '0.07em solid',
454
- marginLeft: '-1.5px',
455
- marginTop: '-2px !important',
456
- paddingTop: '5px !important'
457
- },
458
- '& .mq-math-mode .mq-denominator': {
459
- marginTop: '-5px !important',
460
- padding: '0.5em 0.1em 0.1em !important'
461
- },
462
- '& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
463
- padding: '0 0.1em !important',
464
- paddingBottom: '0 !important',
465
- marginBottom: '-2px'
466
- }
467
- }),
468
- '& span[data-prime="true"]': {
469
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
470
- }
471
- },
472
- hide: {
473
- display: 'none'
474
- },
475
- selectContainer: {
476
- flex: 'initial',
477
- width: '25%',
478
- minWidth: '100px',
479
- marginLeft: '15px',
480
- marginTop: '5px',
481
- marginBottom: '5px',
482
- marginRight: '5px',
483
- '& label': {
484
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
485
- },
486
- '& div': {
487
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
488
- }
489
- },
490
- mathEditor: {
491
- maxWidth: '400px',
492
- color: _index.color.text(),
493
- backgroundColor: _index.color.background(),
494
- padding: '2px'
495
- },
496
- longMathEditor: {
497
- maxWidth: '500px'
498
- },
499
- addAnswerBlockButton: {
500
- position: 'absolute',
501
- right: '12px',
502
- border: '1px solid lightgrey'
503
- },
504
- hr: {
505
- padding: 0,
506
- margin: 0,
507
- height: '1px',
508
- border: 'none',
509
- borderBottom: "solid 1px ".concat(theme.palette.primary.main)
510
- },
511
- mathToolbar: {
512
- zIndex: 9,
513
- position: 'relative',
514
- textAlign: 'center',
515
- width: 'auto',
516
- '& > .mq-math-mode': {
517
- border: 'solid 1px lightgrey'
518
- },
519
- '& > .mq-focused': {
520
- outline: 'none',
521
- boxShadow: 'none',
522
- border: "dotted 1px ".concat(theme.palette.primary.main),
523
- borderRadius: '0px'
524
- },
525
- '& .mq-overarrow-inner': {
526
- border: 'none !important',
527
- paddingTop: '0 !important'
528
- },
529
- '& .mq-overarrow-inner-right': {
530
- display: 'none !important'
531
- },
532
- '& .mq-overarrow-inner-left': {
533
- display: 'none !important'
534
- },
535
- '& .mq-longdiv-inner': {
536
- borderTop: '1px solid !important',
537
- paddingTop: '1.5px !important'
538
- },
539
- '& .mq-overarrow.mq-arrow-both': {
540
- top: '7.8px',
541
- marginTop: '0px',
542
- minWidth: '1.23em'
543
- },
544
- '& .mq-parallelogram': {
545
- lineHeight: 0.85
546
- }
547
- },
548
- inputContainer: {
549
- minWidth: '500px',
550
- maxWidth: '900px',
551
- minHeight: '30px',
552
- width: '100%',
553
- display: 'flex',
554
- marginTop: theme.spacing.unit,
555
- marginBottom: theme.spacing.unit,
556
- '& .mq-sqrt-prefix .mq-scaled': {
557
- verticalAlign: 'middle !important'
558
- }
559
- },
560
- error: {
561
- border: '2px solid red'
562
- },
563
- keyboard: commonMqKeyboardStyles,
564
- language: {
565
- '& *': {
566
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
567
- }
568
- }
569
- };
570
- };
571
-
572
- var _default = (0, _styles.withStyles)(styles)(EditorAndPad);
573
-
574
- exports["default"] = _default;
575
- //# sourceMappingURL=editor-and-pad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/editor-and-pad.jsx"],"names":["mq","CommonMqStyles","commonMqFontStyles","commonMqKeyboardStyles","longdivStyles","supsubStyles","log","decimalRegex","toNodeData","data","type","value","EditorAndPad","props","noDecimal","noLatexHandling","onChange","c","input","clear","command","keystroke","write","isEdit","maxResponseAreas","shouldDisable","checkResponseAreasNumber","setState","addDisabled","onAnswerBlockAdd","onClick","updateDisable","latex","indexOf","replace","regexMatch","match","length","mathField","__controller","cursor","insLeftOf","parent","el","dispatchEvent","KeyboardEvent","keyCode","e","console","error","toString","evt","equationEditor","target","count","state","autoFocus","focus","nextProps","nextState","inputIsDifferent","keypadMode","controlledKeypad","showKeypad","classNames","allowAnswerBlock","additionalKeys","controlledKeypadMode","setKeypadInteraction","hideInput","layoutForKeyPad","onFocus","onBlur","classes","shouldShowKeypad","mathToolbar","inputAndTypeContainer","hide","selectContainer","select","onEditorTypeChange","inputContainer","event","mathEditor","editor","longMathEditor","r","onEditorChange","addAnswerBlockButton","bottom","onAnswerBlockClick","hr","keyboard","React","Component","PropTypes","object","oneOfType","string","number","bool","array","isRequired","func","styles","theme","display","alignItems","top","paddingTop","fontFamily","minWidth","lineHeight","left","position","right","verticalAlign","padding","marginLeft","paddingLeft","borderTop","marginTop","paddingBottom","marginBottom","flex","width","marginRight","maxWidth","color","text","backgroundColor","background","border","margin","height","borderBottom","palette","primary","main","zIndex","textAlign","outline","boxShadow","borderRadius","minHeight","spacing","unit","language"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,yBAAoFA,cAAGC,cAAvF;AAAA,IAAQC,kBAAR,sBAAQA,kBAAR;AAAA,IAA4BC,sBAA5B,sBAA4BA,sBAA5B;AAAA,IAAoDC,aAApD,sBAAoDA,a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;AADoB,OAlBpB;AAqBX,oCAA8B;AAC5BA,QAAAA,OAAO,EAAE;AADmB,OArBnB;AAwBX,6BAAuB;AACrBc,QAAAA,SAAS,EAAE,sBADU;AAErBX,QAAAA,UAAU,EAAE;AAFS,OAxBZ;AA4BX,uCAAiC;AAC/BD,QAAAA,GAAG,EAAE,OAD0B;AAE/Ba,QAAAA,SAAS,EAAE,KAFoB;AAG/BV,QAAAA,QAAQ,EAAE;AAHqB,OA5BtB;AAiCX,6BAAuB;AACrBC,QAAAA,UAAU,EAAE;AADS;AAjCZ,KA9IY;AAmLzB/B,IAAAA,cAAc,EAAE;AACd8B,MAAAA,QAAQ,EAAE,OADI;AAEdgB,MAAAA,QAAQ,EAAE,OAFI;AAGdiB,MAAAA,SAAS,EAAE,MAHG;AAIdnB,MAAAA,KAAK,EAAE,MAJO;AAKdnB,MAAAA,OAAO,EAAE,MALK;AAMde,MAAAA,SAAS,EAAEhB,KAAK,CAACwC,OAAN,CAAcC,IANX;AAOdvB,MAAAA,YAAY,EAAElB,KAAK,CAACwC,OAAN,CAAcC,IAPd;AASd,sCAAgC;AAC9B9B,QAAAA,aAAa,EAAE;AADe;AATlB,KAnLS;AAgMzBnE,IAAAA,KAAK,EAAE;AACLmF,MAAAA,MAAM,EAAE;AADH,KAhMkB;AAmMzBxC,IAAAA,QAAQ,EAAEzF,sBAnMe;AAoMzBgJ,IAAAA,QAAQ,EAAE;AACR,aAAO;AACLrC,QAAAA,UAAU,EAAE;AADP;AADC;AApMe,GAAZ;AAAA,CAAf;;eA2Me,wBAAWN,MAAX,EAAmB5F,YAAnB,C","sourcesContent":["import React from 'react';\nimport debug from 'debug';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport Button from '@material-ui/core/Button';\nimport { withStyles } from '@material-ui/core/styles';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport isEqual from 'lodash/isEqual';\n\nimport { HorizontalKeypad, mq, updateSpans } from '@pie-lib/math-input';\nimport { color, InputContainer } from '../../render-ui/src/index';\nimport { markFractionBaseSuperscripts } from './utils';\n\nconst { commonMqFontStyles, commonMqKeyboardStyles, longdivStyles, supsubStyles } = mq.CommonMqStyles;\nconst log = debug('@pie-lib:math-toolbar:editor-and-pad');\n\nconst decimalRegex = /\\.|,/g;\n\nconst toNodeData = (data) => {\n if (!data) {\n return;\n }\n\n const { type, value } = data;\n\n if (type === 'command' || type === 'cursor') {\n return data;\n } else if (type === 'answer') {\n return { type: 'answer', ...data };\n } else if (value === 'clear') {\n return { type: 'clear' };\n } else {\n return { type: 'write', value };\n }\n};\n\nexport class EditorAndPad extends React.Component {\n static propTypes = {\n classNames: PropTypes.object,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n autoFocus: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n showKeypad: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n error: PropTypes.string,\n noDecimal: PropTypes.bool,\n hideInput: PropTypes.bool,\n noLatexHandling: PropTypes.bool,\n layoutForKeyPad: PropTypes.object,\n maxResponseAreas: PropTypes.number,\n additionalKeys: PropTypes.array,\n latex: PropTypes.string.isRequired,\n onAnswerBlockAdd: PropTypes.func,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.object,\n setKeypadInteraction: PropTypes.func,\n };\n\n constructor(props) {\n super(props);\n\n this.state = { equationEditor: 'item-authoring', addDisabled: false };\n }\n\n componentDidMount() {\n if (this.input && this.props.autoFocus) {\n this.input.focus();\n }\n }\n\n onClick = (data) => {\n const { noDecimal, noLatexHandling, onChange } = this.props;\n const c = toNodeData(data);\n log('mathChange: ', c);\n\n if (noLatexHandling) {\n onChange(c.value);\n return;\n }\n\n // if decimals are not allowed for this response, we discard the input\n if (noDecimal && (c.value === '.' || c.value === ',')) {\n return;\n }\n\n if (!c) {\n return;\n }\n\n if (c.type === 'clear') {\n log('call clear...');\n this.input.clear();\n } else if (c.type === 'command') {\n this.input.command(c.value);\n } else if (c.type === 'cursor') {\n this.input.keystroke(c.value);\n } else if (c.type === 'answer') {\n this.input.write('%response%');\n } else {\n this.input.write(c.value);\n }\n };\n\n updateDisable = (isEdit) => {\n const { maxResponseAreas } = this.props;\n\n if (maxResponseAreas) {\n const shouldDisable = this.checkResponseAreasNumber(maxResponseAreas, isEdit);\n\n this.setState({ addDisabled: shouldDisable });\n }\n };\n\n onAnswerBlockClick = () => {\n this.props.onAnswerBlockAdd();\n this.onClick({\n type: 'answer',\n });\n\n this.updateDisable(true);\n };\n\n onEditorChange = (latex) => {\n const { onChange, noDecimal } = this.props;\n\n updateSpans();\n markFractionBaseSuperscripts();\n\n this.updateDisable(true);\n\n // if no decimals are allowed and the last change is a decimal dot, discard the change\n if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && this.input) {\n this.input.clear();\n this.input.write(latex.replace(decimalRegex, ''));\n return;\n }\n\n // eslint-disable-next-line no-useless-escape\n const regexMatch = latex.match(/[0-9]\\\\ \\\\frac\\{[^\\{]*\\}\\{ \\}/);\n\n if (this.input && regexMatch && regexMatch?.length) {\n try {\n this.input.mathField.__controller.cursor.insLeftOf(this.input.mathField.__controller.cursor.parent[-1].parent);\n this.input.mathField.el().dispatchEvent(new KeyboardEvent('keydown', { keyCode: 8 }));\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(e.toString());\n }\n\n return;\n }\n\n onChange(latex);\n };\n\n /** Only render if the mathquill instance's latex is different\n * or the keypad state changed from one state to the other (shown / hidden) */\n shouldComponentUpdate(nextProps, nextState) {\n const inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;\n log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);\n\n if (!isEqual(this.props.error, nextProps.error)) {\n return true;\n }\n\n if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {\n return true;\n }\n\n if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {\n return true;\n }\n\n if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {\n return true;\n }\n\n if (!inputIsDifferent && this.props.controlledKeypad) {\n return this.props.showKeypad !== nextProps.showKeypad;\n }\n\n return inputIsDifferent;\n }\n\n onEditorTypeChange = (evt) => {\n this.setState({ equationEditor: evt.target.value });\n };\n\n checkResponseAreasNumber = (maxResponseAreas, isEdit) => {\n const { latex } = (this.input && this.input.props) || {};\n\n if (latex) {\n const count = (latex.match(/answerBlock/g) || []).length;\n\n return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;\n }\n\n return false;\n };\n\n render() {\n const {\n classNames,\n keypadMode,\n allowAnswerBlock,\n additionalKeys,\n controlledKeypad,\n controlledKeypadMode,\n showKeypad,\n setKeypadInteraction,\n noDecimal,\n hideInput,\n layoutForKeyPad,\n latex,\n onFocus,\n onBlur,\n classes,\n error,\n } = this.props;\n const shouldShowKeypad = !controlledKeypad || (controlledKeypad && showKeypad);\n const { addDisabled } = this.state;\n\n log('[render]', latex);\n\n return (\n <div className={cx(classes.mathToolbar, classNames.mathToolbar)}>\n <div className={cx(classes.inputAndTypeContainer, { [classes.hide]: hideInput })}>\n {controlledKeypadMode && (\n <InputContainer label=\"Equation Editor\" className={classes.selectContainer}>\n <Select className={classes.select} onChange={this.onEditorTypeChange} value={this.state.equationEditor}>\n <MenuItem value=\"non-negative-integers\">Numeric - Non-Negative Integers</MenuItem>\n <MenuItem value=\"integers\">Numeric - Integers</MenuItem>\n <MenuItem value=\"decimals\">Numeric - Decimals</MenuItem>\n <MenuItem value=\"fractions\">Numeric - Fractions</MenuItem>\n <MenuItem value={1}>Grade 1 - 2</MenuItem>\n <MenuItem value={3}>Grade 3 - 5</MenuItem>\n <MenuItem value={6}>Grade 6 - 7</MenuItem>\n <MenuItem value={8}>Grade 8 - HS</MenuItem>\n <MenuItem value={'geometry'}>Geometry</MenuItem>\n <MenuItem value={'advanced-algebra'}>Advanced Algebra</MenuItem>\n <MenuItem value={'statistics'}>Statistics</MenuItem>\n <MenuItem value={'item-authoring'}>Item Authoring</MenuItem>\n </Select>\n </InputContainer>\n )}\n <div className={cx(classes.inputContainer, error ? classes.error : '')}>\n <mq.Input\n onFocus={() => {\n onFocus && onFocus();\n this.updateDisable(false);\n }}\n onBlur={(event) => {\n this.updateDisable(false);\n onBlur && onBlur(event);\n }}\n className={cx(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : '')}\n innerRef={(r) => (this.input = r)}\n latex={latex}\n onChange={this.onEditorChange}\n />\n </div>\n </div>\n {allowAnswerBlock && (\n <Button\n className={classes.addAnswerBlockButton}\n type=\"primary\"\n style={{ bottom: shouldShowKeypad ? '320px' : '20px' }}\n onClick={this.onAnswerBlockClick}\n disabled={addDisabled}\n >\n + Response Area\n </Button>\n )}\n <hr className={classes.hr} />\n {shouldShowKeypad && (\n <HorizontalKeypad\n className={cx(classes[keypadMode], classes.keyboard)}\n controlledKeypadMode={controlledKeypadMode}\n layoutForKeyPad={layoutForKeyPad}\n additionalKeys={additionalKeys}\n mode={controlledKeypadMode ? this.state.equationEditor : keypadMode}\n onClick={this.onClick}\n noDecimal={noDecimal}\n setKeypadInteraction={setKeypadInteraction}\n />\n )}\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n inputAndTypeContainer: {\n display: 'flex',\n alignItems: 'center',\n '& .mq-editable-field .mq-cursor': {\n top: '-4px',\n },\n '& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {\n paddingTop: '18px',\n },\n '& .mq-math-mode .mq-overarrow': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n '& .mq-math-mode .mq-overline .mq-overline-inner': {\n paddingTop: '0.4em !important',\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important',\n },\n '&:before': {\n top: '-0.45em',\n left: '-1px',\n },\n '&:after': {\n position: 'absolute !important',\n top: '0px !important',\n right: '-2px',\n },\n '&.mq-empty:after': {\n top: '-0.45em',\n },\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px',\n },\n },\n\n '& *': {\n ...commonMqFontStyles,\n ...supsubStyles,\n ...longdivStyles,\n '& .mq-math-mode .mq-sqrt-prefix': {\n verticalAlign: 'baseline !important',\n top: '1px !important',\n left: '-0.1em !important',\n },\n\n '& .mq-math-mode .mq-overarc ': {\n paddingTop: '0.45em !important',\n },\n\n '& .mq-math-mode .mq-empty': {\n padding: '9px 1px !important',\n },\n\n '& .mq-math-mode .mq-root-block': {\n paddingTop: '10px',\n },\n\n '& .mq-scaled .mq-sqrt-prefix': {\n top: '0 !important',\n },\n\n '& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {\n marginLeft: '4px !important',\n paddingTop: '6px !important',\n paddingLeft: '6px !important',\n },\n\n '& .mq-math-mode .mq-paren': {\n verticalAlign: 'top !important',\n padding: '1px 0.1em !important',\n },\n\n '& .mq-math-mode .mq-sqrt-stem': {\n borderTop: '0.07em solid',\n marginLeft: '-1.5px',\n marginTop: '-2px !important',\n paddingTop: '5px !important',\n },\n\n '& .mq-math-mode .mq-denominator': {\n marginTop: '-5px !important',\n padding: '0.5em 0.1em 0.1em !important',\n },\n\n '& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {\n padding: '0 0.1em !important',\n paddingBottom: '0 !important',\n marginBottom: '-2px',\n },\n },\n\n '& span[data-prime=\"true\"]': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n hide: {\n display: 'none',\n },\n selectContainer: {\n flex: 'initial',\n width: '25%',\n minWidth: '100px',\n marginLeft: '15px',\n marginTop: '5px',\n marginBottom: '5px',\n marginRight: '5px',\n\n '& label': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n\n '& div': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n mathEditor: {\n maxWidth: '400px',\n color: color.text(),\n backgroundColor: color.background(),\n padding: '2px',\n },\n longMathEditor: {\n maxWidth: '500px',\n },\n addAnswerBlockButton: {\n position: 'absolute',\n right: '12px',\n border: '1px solid lightgrey',\n },\n hr: {\n padding: 0,\n margin: 0,\n height: '1px',\n border: 'none',\n borderBottom: `solid 1px ${theme.palette.primary.main}`,\n },\n mathToolbar: {\n zIndex: 9,\n position: 'relative',\n textAlign: 'center',\n width: 'auto',\n '& > .mq-math-mode': {\n border: 'solid 1px lightgrey',\n },\n '& > .mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: `dotted 1px ${theme.palette.primary.main}`,\n borderRadius: '0px',\n },\n '& .mq-overarrow-inner': {\n border: 'none !important',\n paddingTop: '0 !important',\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important',\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important',\n },\n '& .mq-longdiv-inner': {\n borderTop: '1px solid !important',\n paddingTop: '1.5px !important',\n },\n '& .mq-overarrow.mq-arrow-both': {\n top: '7.8px',\n marginTop: '0px',\n minWidth: '1.23em',\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85,\n },\n },\n inputContainer: {\n minWidth: '500px',\n maxWidth: '900px',\n minHeight: '30px',\n width: '100%',\n display: 'flex',\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit,\n\n '& .mq-sqrt-prefix .mq-scaled': {\n verticalAlign: 'middle !important',\n },\n },\n error: {\n border: '2px solid red',\n },\n keyboard: commonMqKeyboardStyles,\n language: {\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',\n },\n },\n});\n\nexport default withStyles(styles)(EditorAndPad);\n"],"file":"editor-and-pad.js"}