@pie-lib/math-toolbar 1.8.9 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/lib/editor-and-pad.js +66 -13
- package/lib/editor-and-pad.js.map +1 -1
- package/lib/index.js +12 -4
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/editor-and-pad.jsx +64 -17
- package/src/index.jsx +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.9.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.9.1...@pie-lib/math-toolbar@1.9.2) (2022-05-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **math-toolbar:** fix simple response gather PD-1786 ([1769577](https://github.com/pie-framework/pie-lib/commit/176957700d75d3efa0e5fbf08e8e4c6ffe61320d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.9.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.9.0...@pie-lib/math-toolbar@1.9.1) (2022-05-03)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **math-toolbar:** add sanity checks ([e012294](https://github.com/pie-framework/pie-lib/commit/e012294184b6f0c1472e6306be01e76e650c8fa5))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [1.9.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.8.9...@pie-lib/math-toolbar@1.9.0) (2022-05-03)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **math-toolbar:** add validation ui/ux for math-inline inputs PD-1705 ([cbc7205](https://github.com/pie-framework/pie-lib/commit/cbc72051deaefd76765cd60a387e47eebd0abc2f))
|
|
34
|
+
* **math-toolbar:** PD-1705 disable logic for add button in editor if maxResponseAreas is defined ([d68034c](https://github.com/pie-framework/pie-lib/commit/d68034cb4a2d24224f2c778fa4cf425ff157177a))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
6
40
|
## [1.8.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.8.8...@pie-lib/math-toolbar@1.8.9) (2022-04-12)
|
|
7
41
|
|
|
8
42
|
**Note:** Version bump only for package @pie-lib/math-toolbar
|
package/lib/editor-and-pad.js
CHANGED
|
@@ -120,19 +120,36 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
+
_defineProperty(_assertThisInitialized(_this), "updateDisable", function (isEdit) {
|
|
124
|
+
var maxResponseAreas = _this.props.maxResponseAreas;
|
|
125
|
+
|
|
126
|
+
if (maxResponseAreas) {
|
|
127
|
+
var shouldDisable = _this.checkResponseAreasNumber(maxResponseAreas, isEdit);
|
|
128
|
+
|
|
129
|
+
_this.setState({
|
|
130
|
+
addDisabled: shouldDisable
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
123
135
|
_defineProperty(_assertThisInitialized(_this), "onAnswerBlockClick", function () {
|
|
124
136
|
_this.props.onAnswerBlockAdd();
|
|
125
137
|
|
|
126
138
|
_this.onClick({
|
|
127
139
|
type: 'answer'
|
|
128
140
|
});
|
|
141
|
+
|
|
142
|
+
_this.updateDisable(true);
|
|
129
143
|
});
|
|
130
144
|
|
|
131
145
|
_defineProperty(_assertThisInitialized(_this), "onEditorChange", function (latex) {
|
|
132
146
|
var _this$props = _this.props,
|
|
133
147
|
onChange = _this$props.onChange,
|
|
134
148
|
noDecimal = _this$props.noDecimal;
|
|
135
|
-
(0, _mathInput.updateSpans)();
|
|
149
|
+
(0, _mathInput.updateSpans)();
|
|
150
|
+
|
|
151
|
+
_this.updateDisable(true); // if no decimals are allowed and the last change is a decimal dot, discard the change
|
|
152
|
+
|
|
136
153
|
|
|
137
154
|
if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && _this.input) {
|
|
138
155
|
_this.input.clear();
|
|
@@ -151,8 +168,21 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
|
|
|
151
168
|
});
|
|
152
169
|
});
|
|
153
170
|
|
|
171
|
+
_defineProperty(_assertThisInitialized(_this), "checkResponseAreasNumber", function (maxResponseAreas, isEdit) {
|
|
172
|
+
var _ref = _this.input && _this.input.props || {},
|
|
173
|
+
latex = _ref.latex;
|
|
174
|
+
|
|
175
|
+
if (latex) {
|
|
176
|
+
var count = (latex.match(/answerBlock/g) || []).length;
|
|
177
|
+
return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return false;
|
|
181
|
+
});
|
|
182
|
+
|
|
154
183
|
_this.state = {
|
|
155
|
-
equationEditor: 'item-authoring'
|
|
184
|
+
equationEditor: 'item-authoring',
|
|
185
|
+
addDisabled: false
|
|
156
186
|
};
|
|
157
187
|
return _this;
|
|
158
188
|
}
|
|
@@ -206,10 +236,12 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
|
|
|
206
236
|
showKeypad = _this$props2.showKeypad,
|
|
207
237
|
noDecimal = _this$props2.noDecimal,
|
|
208
238
|
latex = _this$props2.latex,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
classes = _this$props2.classes
|
|
239
|
+
_onFocus = _this$props2.onFocus,
|
|
240
|
+
_onBlur = _this$props2.onBlur,
|
|
241
|
+
classes = _this$props2.classes,
|
|
242
|
+
error = _this$props2.error;
|
|
212
243
|
var shouldShowKeypad = !controlledKeypad || controlledKeypad && showKeypad;
|
|
244
|
+
var addDisabled = this.state.addDisabled;
|
|
213
245
|
log('[render]', latex);
|
|
214
246
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
215
247
|
className: (0, _classnames["default"])(classes.mathToolbar, classNames.mathToolbar)
|
|
@@ -246,22 +278,33 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
|
|
|
246
278
|
value: 'statistics'
|
|
247
279
|
}, "Statistics"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
248
280
|
value: 'item-authoring'
|
|
249
|
-
}, "Item Authoring"))), /*#__PURE__*/_react["default"].createElement(
|
|
250
|
-
|
|
251
|
-
|
|
281
|
+
}, "Item Authoring"))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
282
|
+
className: (0, _classnames["default"])(classes.inputContainer, error ? classes.error : '')
|
|
283
|
+
}, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Input, {
|
|
284
|
+
onFocus: function onFocus() {
|
|
285
|
+
_onFocus && _onFocus();
|
|
286
|
+
|
|
287
|
+
_this2.updateDisable(false);
|
|
288
|
+
},
|
|
289
|
+
onBlur: function onBlur(event) {
|
|
290
|
+
_this2.updateDisable(false);
|
|
291
|
+
|
|
292
|
+
_onBlur && _onBlur(event);
|
|
293
|
+
},
|
|
252
294
|
className: (0, _classnames["default"])(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : ''),
|
|
253
295
|
innerRef: function innerRef(r) {
|
|
254
296
|
return _this2.input = r;
|
|
255
297
|
},
|
|
256
298
|
latex: latex,
|
|
257
299
|
onChange: this.onEditorChange
|
|
258
|
-
})), allowAnswerBlock && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
300
|
+
}))), allowAnswerBlock && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
259
301
|
className: classes.addAnswerBlockButton,
|
|
260
302
|
type: "primary",
|
|
261
303
|
style: {
|
|
262
304
|
bottom: shouldShowKeypad ? '320px' : '20px'
|
|
263
305
|
},
|
|
264
|
-
onClick: this.onAnswerBlockClick
|
|
306
|
+
onClick: this.onAnswerBlockClick,
|
|
307
|
+
disabled: addDisabled
|
|
265
308
|
}, "+ Response Area"), /*#__PURE__*/_react["default"].createElement("hr", {
|
|
266
309
|
className: classes.hr
|
|
267
310
|
}), shouldShowKeypad && /*#__PURE__*/_react["default"].createElement(_mathInput.HorizontalKeypad, {
|
|
@@ -341,9 +384,7 @@ var styles = function styles(theme) {
|
|
|
341
384
|
maxWidth: '400px',
|
|
342
385
|
color: _renderUi.color.text(),
|
|
343
386
|
backgroundColor: _renderUi.color.background(),
|
|
344
|
-
padding: theme.spacing.unit
|
|
345
|
-
marginTop: theme.spacing.unit,
|
|
346
|
-
marginBottom: theme.spacing.unit
|
|
387
|
+
padding: theme.spacing.unit
|
|
347
388
|
},
|
|
348
389
|
longMathEditor: {
|
|
349
390
|
maxWidth: '500px'
|
|
@@ -394,6 +435,18 @@ var styles = function styles(theme) {
|
|
|
394
435
|
'& .mq-parallelogram': {
|
|
395
436
|
lineHeight: 0.85
|
|
396
437
|
}
|
|
438
|
+
},
|
|
439
|
+
inputContainer: {
|
|
440
|
+
minWidth: '500px',
|
|
441
|
+
maxWidth: '900px',
|
|
442
|
+
minHeight: '40px',
|
|
443
|
+
width: '100%',
|
|
444
|
+
display: 'flex',
|
|
445
|
+
marginTop: theme.spacing.unit,
|
|
446
|
+
marginBottom: theme.spacing.unit
|
|
447
|
+
},
|
|
448
|
+
error: {
|
|
449
|
+
border: '2px solid red'
|
|
397
450
|
}
|
|
398
451
|
};
|
|
399
452
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/editor-and-pad.jsx"],"names":["log","decimalRegex","toNodeData","data","type","value","EditorAndPad","props","noDecimal","c","input","clear","command","keystroke","write","onAnswerBlockAdd","onClick","latex","onChange","indexOf","replace","evt","setState","equationEditor","target","state","autoFocus","focus","nextProps","nextState","inputIsDifferent","mathField","keypadMode","controlledKeypad","showKeypad","classNames","allowAnswerBlock","additionalKeys","controlledKeypadMode","onFocus","onBlur","classes","shouldShowKeypad","mathToolbar","inputAndTypeContainer","selectContainer","select","onEditorTypeChange","mathEditor","editor","longMathEditor","r","onEditorChange","addAnswerBlockButton","bottom","onAnswerBlockClick","hr","React","Component","PropTypes","object","oneOfType","string","number","bool","array","isRequired","func","styles","theme","display","alignItems","fontFamily","minWidth","lineHeight","top","left","right","flex","width","marginLeft","marginTop","marginBottom","marginRight","maxWidth","color","text","backgroundColor","background","padding","spacing","unit","position","border","margin","height","borderBottom","palette","primary","main","zIndex","textAlign","outline","boxShadow","borderRadius","paddingTop","borderTop"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAHA,IAAMA,GAAG,GAAG,uBAAM,sCAAN,CAAZ;AAMA,IAAMC,YAAY,GAAG,OAArB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,IAAI,EAAI;AACzB,MAAI,CAACA,IAAL,EAAW;AACT;AACD;;AAED,MAAQC,IAAR,GAAwBD,IAAxB,CAAQC,IAAR;AAAA,MAAcC,KAAd,GAAwBF,IAAxB,CAAcE,KAAd;;AAEA,MAAID,IAAI,KAAK,SAAT,IAAsBA,IAAI,KAAK,QAAnC,EAA6C;AAC3C,WAAOD,IAAP;AACD,GAFD,MAEO,IAAIC,IAAI,KAAK,QAAb,EAAuB;AAC5B;AAASA,MAAAA,IAAI,EAAE;AAAf,OAA4BD,IAA5B;AACD,GAFM,MAEA,IAAIE,KAAK,KAAK,OAAd,EAAuB;AAC5B,WAAO;AAAED,MAAAA,IAAI,EAAE;AAAR,KAAP;AACD,GAFM,MAEA;AACL,WAAO;AAAEA,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,KAAK,EAALA;AAAjB,KAAP;AACD;AACF,CAhBD;;IAkB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C,QAAAA,SAAS,EAAE,sBADU;AAErBD,QAAAA,UAAU,EAAE;AAFS,OAxBZ;AA4BX,uCAAiC;AAC/BhC,QAAAA,QAAQ,EAAE;AADqB,OA5BtB;AA+BX,6BAAuB;AACrBC,QAAAA,UAAU,EAAE;AADS;AA/BZ;AA/DU,GAAL;AAAA,CAApB;;eAoGe,wBAAWN,MAAX,EAAmB9D,YAAnB,C","sourcesContent":["import { HorizontalKeypad, mq } from '@pie-lib/math-input';\nimport 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';\nconst log = debug('@pie-lib:math-toolbar:editor-and-pad');\nimport { color, InputContainer } from '@pie-lib/render-ui';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { updateSpans } from '@pie-lib/math-input';\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 noDecimal: PropTypes.bool,\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 };\n\n constructor(props) {\n super(props);\n\n this.state = { equationEditor: 'item-authoring' };\n }\n\n componentDidMount() {\n if (this.input && this.props.autoFocus) {\n this.input.focus();\n }\n }\n\n onClick = data => {\n const { noDecimal } = this.props;\n const c = toNodeData(data);\n log('mathChange: ', c);\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.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 onAnswerBlockClick = () => {\n this.props.onAnswerBlockAdd();\n this.onClick({\n type: 'answer'\n });\n };\n\n onEditorChange = latex => {\n const { onChange, noDecimal } = this.props;\n\n updateSpans();\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 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 (!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 render() {\n const {\n classNames,\n keypadMode,\n allowAnswerBlock,\n additionalKeys,\n controlledKeypad,\n controlledKeypadMode,\n showKeypad,\n noDecimal,\n latex,\n onFocus,\n onBlur,\n classes\n } = this.props;\n const shouldShowKeypad = !controlledKeypad || (controlledKeypad && showKeypad);\n\n log('[render]', latex);\n\n return (\n <div className={cx(classes.mathToolbar, classNames.mathToolbar)}>\n <div className={classes.inputAndTypeContainer}>\n {controlledKeypadMode && (\n <InputContainer label=\"Equation Editor\" className={classes.selectContainer}>\n <Select\n className={classes.select}\n onChange={this.onEditorTypeChange}\n value={this.state.equationEditor}\n >\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 <mq.Input\n onFocus={onFocus}\n onBlur={onBlur}\n className={cx(\n classes.mathEditor,\n classNames.editor,\n !controlledKeypadMode ? classes.longMathEditor : ''\n )}\n innerRef={r => (this.input = r)}\n latex={latex}\n onChange={this.onEditorChange}\n />\n </div>\n {allowAnswerBlock && (\n <Button\n className={classes.addAnswerBlockButton}\n type=\"primary\"\n style={{ bottom: shouldShowKeypad ? '320px' : '20px' }}\n onClick={this.onAnswerBlockClick}\n >\n + Response Area\n </Button>\n )}\n <hr className={classes.hr} />\n {shouldShowKeypad && (\n <HorizontalKeypad\n additionalKeys={additionalKeys}\n mode={controlledKeypadMode ? this.state.equationEditor : keypadMode}\n onClick={this.onClick}\n noDecimal={noDecimal}\n />\n )}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n inputAndTypeContainer: {\n display: 'flex',\n alignItems: 'center',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important'\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px'\n },\n '&:after': {\n top: '-2.36em',\n right: '-1px'\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 selectContainer: {\n flex: 'initial',\n width: '25%',\n minWidth: '100px',\n marginLeft: '15px',\n marginTop: '5px',\n marginBottom: '5px',\n marginRight: '5px'\n },\n mathEditor: {\n maxWidth: '400px',\n color: color.text(),\n backgroundColor: color.background(),\n padding: theme.spacing.unit,\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit\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 minWidth: '1.23em'\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85\n }\n }\n});\n\nexport default withStyles(styles)(EditorAndPad);\n"],"file":"editor-and-pad.js"}
|
|
1
|
+
{"version":3,"sources":["../src/editor-and-pad.jsx"],"names":["log","decimalRegex","toNodeData","data","type","value","EditorAndPad","props","noDecimal","c","input","clear","command","keystroke","write","isEdit","maxResponseAreas","shouldDisable","checkResponseAreasNumber","setState","addDisabled","onAnswerBlockAdd","onClick","updateDisable","latex","onChange","indexOf","replace","evt","equationEditor","target","count","match","length","state","autoFocus","focus","nextProps","nextState","inputIsDifferent","mathField","keypadMode","controlledKeypad","showKeypad","classNames","allowAnswerBlock","additionalKeys","controlledKeypadMode","onFocus","onBlur","classes","error","shouldShowKeypad","mathToolbar","inputAndTypeContainer","selectContainer","select","onEditorTypeChange","inputContainer","event","mathEditor","editor","longMathEditor","r","onEditorChange","addAnswerBlockButton","bottom","onAnswerBlockClick","hr","React","Component","PropTypes","object","oneOfType","string","number","bool","array","isRequired","func","styles","theme","display","alignItems","fontFamily","minWidth","lineHeight","top","left","right","flex","width","marginLeft","marginTop","marginBottom","marginRight","maxWidth","color","text","backgroundColor","background","padding","spacing","unit","position","border","margin","height","borderBottom","palette","primary","main","zIndex","textAlign","outline","boxShadow","borderRadius","paddingTop","borderTop","minHeight"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAHA,IAAMA,GAAG,GAAG,uBAAM,sCAAN,CAAZ;AAMA,IAAMC,YAAY,GAAG,OAArB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,IAAI,EAAI;AACzB,MAAI,CAACA,IAAL,EAAW;AACT;AACD;;AAED,MAAQC,IAAR,GAAwBD,IAAxB,CAAQC,IAAR;AAAA,MAAcC,KAAd,GAAwBF,IAAxB,CAAcE,KAAd;;AAEA,MAAID,IAAI,KAAK,SAAT,IAAsBA,IAAI,KAAK,QAAnC,EAA6C;AAC3C,WAAOD,IAAP;AACD,GAFD,MAEO,IAAIC,IAAI,KAAK,QAAb,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,+BAAyB;AACvBX,QAAAA,MAAM,EAAE,iBADe;AAEvBY,QAAAA,UAAU,EAAE;AAFW,OAdd;AAkBX,qCAA+B;AAC7BnC,QAAAA,OAAO,EAAE;AADoB,OAlBpB;AAqBX,oCAA8B;AAC5BA,QAAAA,OAAO,EAAE;AADmB,OArBnB;AAwBX,6BAAuB;AACrBoC,QAAAA,SAAS,EAAE,sBADU;AAErBD,QAAAA,UAAU,EAAE;AAFS,OAxBZ;AA4BX,uCAAiC;AAC/BhC,QAAAA,QAAQ,EAAE;AADqB,OA5BtB;AA+BX,6BAAuB;AACrBC,QAAAA,UAAU,EAAE;AADS;AA/BZ,KA7DU;AAgGvB5B,IAAAA,cAAc,EAAE;AACd2B,MAAAA,QAAQ,EAAE,OADI;AAEdW,MAAAA,QAAQ,EAAE,OAFI;AAGduB,MAAAA,SAAS,EAAE,MAHG;AAId5B,MAAAA,KAAK,EAAE,MAJO;AAKdT,MAAAA,OAAO,EAAE,MALK;AAMdW,MAAAA,SAAS,EAAEZ,KAAK,CAACqB,OAAN,CAAcC,IANX;AAOdT,MAAAA,YAAY,EAAEb,KAAK,CAACqB,OAAN,CAAcC;AAPd,KAhGO;AAyGvBpD,IAAAA,KAAK,EAAE;AACLsD,MAAAA,MAAM,EAAE;AADH;AAzGgB,GAAL;AAAA,CAApB;;eA8Ge,wBAAWzB,MAAX,EAAmB1E,YAAnB,C","sourcesContent":["import { HorizontalKeypad, mq } from '@pie-lib/math-input';\nimport 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';\nconst log = debug('@pie-lib:math-toolbar:editor-and-pad');\nimport { color, InputContainer } from '@pie-lib/render-ui';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { updateSpans } from '@pie-lib/math-input';\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 noDecimal: PropTypes.bool,\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 };\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 } = this.props;\n const c = toNodeData(data);\n log('mathChange: ', c);\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.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\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 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 (!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 noDecimal,\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={classes.inputAndTypeContainer}>\n {controlledKeypadMode && (\n <InputContainer label=\"Equation Editor\" className={classes.selectContainer}>\n <Select\n className={classes.select}\n onChange={this.onEditorTypeChange}\n value={this.state.equationEditor}\n >\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(\n classes.mathEditor,\n classNames.editor,\n !controlledKeypadMode ? classes.longMathEditor : ''\n )}\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 additionalKeys={additionalKeys}\n mode={controlledKeypadMode ? this.state.equationEditor : keypadMode}\n onClick={this.onClick}\n noDecimal={noDecimal}\n />\n )}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n inputAndTypeContainer: {\n display: 'flex',\n alignItems: 'center',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important'\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px'\n },\n '&:after': {\n top: '-2.36em',\n right: '-1px'\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 selectContainer: {\n flex: 'initial',\n width: '25%',\n minWidth: '100px',\n marginLeft: '15px',\n marginTop: '5px',\n marginBottom: '5px',\n marginRight: '5px'\n },\n mathEditor: {\n maxWidth: '400px',\n color: color.text(),\n backgroundColor: color.background(),\n padding: theme.spacing.unit\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 minWidth: '1.23em'\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85\n }\n },\n inputContainer: {\n minWidth: '500px',\n maxWidth: '900px',\n minHeight: '40px',\n width: '100%',\n display: 'flex',\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit\n },\n error: {\n border: '2px solid red'\n }\n});\n\nexport default withStyles(styles)(EditorAndPad);\n"],"file":"editor-and-pad.js"}
|
package/lib/index.js
CHANGED
|
@@ -105,7 +105,9 @@ var MathToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
105
105
|
showKeypad = _this$props.showKeypad,
|
|
106
106
|
onFocus = _this$props.onFocus,
|
|
107
107
|
onBlur = _this$props.onBlur,
|
|
108
|
-
hideDoneButton = _this$props.hideDoneButton
|
|
108
|
+
hideDoneButton = _this$props.hideDoneButton,
|
|
109
|
+
error = _this$props.error,
|
|
110
|
+
maxResponseAreas = _this$props.maxResponseAreas;
|
|
109
111
|
return /*#__PURE__*/_react["default"].createElement(PureToolbar, {
|
|
110
112
|
autoFocus: autoFocus,
|
|
111
113
|
classNames: classNames,
|
|
@@ -122,7 +124,9 @@ var MathToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
122
124
|
showKeypad: showKeypad,
|
|
123
125
|
controlledKeypad: controlledKeypad,
|
|
124
126
|
controlledKeypadMode: controlledKeypadMode,
|
|
125
|
-
hideDoneButton: hideDoneButton
|
|
127
|
+
hideDoneButton: hideDoneButton,
|
|
128
|
+
error: error,
|
|
129
|
+
maxResponseAreas: maxResponseAreas
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
132
|
}]);
|
|
@@ -198,7 +202,9 @@ var RawPureToolbar = /*#__PURE__*/function (_React$Component2) {
|
|
|
198
202
|
onFocus = _this$props2.onFocus,
|
|
199
203
|
onBlur = _this$props2.onBlur,
|
|
200
204
|
hideDoneButton = _this$props2.hideDoneButton,
|
|
201
|
-
classes = _this$props2.classes
|
|
205
|
+
classes = _this$props2.classes,
|
|
206
|
+
error = _this$props2.error,
|
|
207
|
+
maxResponseAreas = _this$props2.maxResponseAreas;
|
|
202
208
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
203
209
|
className: (0, _classnames["default"])(classes.pureToolbar, (classNames || {}).toolbar)
|
|
204
210
|
}, /*#__PURE__*/_react["default"].createElement("div", null), /*#__PURE__*/_react["default"].createElement(_editorAndPad["default"], {
|
|
@@ -215,7 +221,9 @@ var RawPureToolbar = /*#__PURE__*/function (_React$Component2) {
|
|
|
215
221
|
latex: latex,
|
|
216
222
|
onChange: onChange,
|
|
217
223
|
onFocus: onFocus,
|
|
218
|
-
onBlur: onBlur
|
|
224
|
+
onBlur: onBlur,
|
|
225
|
+
error: error,
|
|
226
|
+
maxResponseAreas: maxResponseAreas
|
|
219
227
|
}), (!controlledKeypad || controlledKeypad && showKeypad) && !hideDoneButton && /*#__PURE__*/_react["default"].createElement(_doneButton.DoneButton, {
|
|
220
228
|
onClick: onDone
|
|
221
229
|
}));
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.jsx"],"names":["MathToolbar","props","onDone","state","latex","setState","onChange","nextProps","classNames","autoFocus","allowAnswerBlock","onAnswerBlockAdd","controlledKeypad","controlledKeypadMode","keypadMode","noDecimal","additionalKeys","showKeypad","onFocus","onBlur","hideDoneButton","done","React","Component","PropTypes","bool","oneOfType","string","number","object","array","isRequired","func","RawPureToolbar","classes","pureToolbar","toolbar","styles","display","width","zIndex","alignItems","PureToolbar"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;IAIaA,W;;;;;AAoCX,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,2DAOZ,YAAM;AACX,YAAKA,KAAL,CAAWC,MAAX,CAAkB,MAAKC,KAAL,CAAWC,KAA7B;AACD,KATkB;;AAAA,+DAeR,UAAAA,KAAK,EAAI;AAClB,YAAKC,QAAL,CAAc;AAAED,QAAAA,KAAK,EAALA;AAAF,OAAd;;AACA,YAAKH,KAAL,CAAWK,QAAX,CAAoBF,KAApB;AACD,KAlBkB;;AAEjB,UAAKD,KAAL,GAAa;AACXC,MAAAA,KAAK,EAAEH,KAAK,CAACG;AADF,KAAb;AAFiB;AAKlB;;;;WAMD,0CAAiCG,SAAjC,EAA4C;AAC1C,WAAKF,QAAL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W,EAAE;AACXG,MAAAA,OAAO,EAAE,MADE;AAEXC,MAAAA,KAAK,EAAE,MAFI;AAGXC,MAAAA,MAAM,EAAE,CAHG;AAIXC,MAAAA,UAAU,EAAE;AAJD;AADO,GAAP;AAAA,CAAf;;AASO,IAAMC,WAAW,GAAG,wBAAWL,MAAX,EAAmBJ,cAAnB,CAApB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport EditorAndPad from './editor-and-pad';\nimport { DoneButton } from './done-button';\nimport { withStyles } from '@material-ui/core/styles';\nimport MathPreview from './math-preview';\n\nexport { MathPreview };\n\nexport class MathToolbar extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classNames: PropTypes.object,\n showKeypad: PropTypes.bool,\n noDecimal: PropTypes.bool,\n additionalKeys: PropTypes.array,\n latex: PropTypes.string.isRequired,\n onAnswerBlockAdd: PropTypes.func,\n onChange: PropTypes.func,\n onDone: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n hideDoneButton: PropTypes.bool\n };\n\n static defaultProps = {\n classNames: {},\n keypadMode: 'item-authoring',\n autoFocus: false,\n allowAnswerBlock: false,\n controlledKeypad: false,\n controlledKeypadMode: false,\n noDecimal: false,\n showKeypad: true,\n additionalKeys: [],\n onChange: () => {},\n onAnswerBlockAdd: () => {},\n onFocus: () => {},\n hideDoneButton: false\n };\n\n constructor(props) {\n super(props);\n this.state = {\n latex: props.latex\n };\n }\n\n done = () => {\n this.props.onDone(this.state.latex);\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({ latex: nextProps.latex });\n }\n\n onChange = latex => {\n this.setState({ latex });\n this.props.onChange(latex);\n };\n\n render() {\n const { latex } = this.state;\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n keypadMode,\n noDecimal,\n additionalKeys,\n showKeypad,\n onFocus,\n onBlur,\n hideDoneButton\n } = this.props;\n\n return (\n <PureToolbar\n autoFocus={autoFocus}\n classNames={classNames}\n onAnswerBlockAdd={onAnswerBlockAdd}\n allowAnswerBlock={allowAnswerBlock}\n latex={latex}\n additionalKeys={additionalKeys}\n noDecimal={noDecimal}\n keypadMode={keypadMode}\n onChange={this.onChange}\n onDone={this.done}\n onFocus={onFocus}\n onBlur={onBlur}\n showKeypad={showKeypad}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n hideDoneButton={hideDoneButton}\n />\n );\n }\n}\n\nexport class RawPureToolbar extends React.Component {\n static propTypes = {\n classNames: PropTypes.object,\n latex: PropTypes.string.isRequired,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n onChange: PropTypes.func.isRequired,\n onDone: PropTypes.func.isRequired,\n onBlur: PropTypes.func,\n onAnswerBlockAdd: PropTypes.func,\n additionalKeys: PropTypes.array,\n onFocus: PropTypes.func,\n classes: PropTypes.object.isRequired,\n autoFocus: PropTypes.bool,\n noDecimal: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n showKeypad: PropTypes.bool,\n hideDoneButton: PropTypes.bool\n };\n\n render() {\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n additionalKeys,\n showKeypad,\n keypadMode,\n noDecimal,\n latex,\n onChange,\n onDone,\n onFocus,\n onBlur,\n hideDoneButton,\n classes\n } = this.props;\n\n return (\n <div className={cx(classes.pureToolbar, (classNames || {}).toolbar)}>\n <div />\n <EditorAndPad\n autoFocus={autoFocus}\n keypadMode={keypadMode}\n classNames={classNames || {}}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n noDecimal={noDecimal}\n showKeypad={showKeypad}\n additionalKeys={additionalKeys}\n allowAnswerBlock={allowAnswerBlock}\n onAnswerBlockAdd={onAnswerBlockAdd}\n latex={latex}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n />\n {(!controlledKeypad || (controlledKeypad && showKeypad)) && !hideDoneButton && (\n <DoneButton onClick={onDone} />\n )}\n </div>\n );\n }\n}\nconst styles = () => ({\n pureToolbar: {\n display: 'flex',\n width: '100%',\n zIndex: 8,\n alignItems: 'center'\n }\n});\n\nexport const PureToolbar = withStyles(styles)(RawPureToolbar);\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/index.jsx"],"names":["MathToolbar","props","onDone","state","latex","setState","onChange","nextProps","classNames","autoFocus","allowAnswerBlock","onAnswerBlockAdd","controlledKeypad","controlledKeypadMode","keypadMode","noDecimal","additionalKeys","showKeypad","onFocus","onBlur","hideDoneButton","error","maxResponseAreas","done","React","Component","PropTypes","bool","oneOfType","string","number","object","array","isRequired","func","RawPureToolbar","classes","pureToolbar","toolbar","styles","display","width","zIndex","alignItems","PureToolbar"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;IAIaA,W;;;;;AAoCX,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,2DAOZ,YAAM;AACX,YAAKA,KAAL,CAAWC,MAAX,CAAkB,MAAKC,KAAL,CAAWC,KAA7B;AACD,KATkB;;AAAA,+DAeR,UAAAA,KAAK,EAAI;AAClB,YAAKC,QAAL,CAAc;AAAED,QAAAA,KAAK,EAALA;AAAF,OAAd;;AACA,YAAKH,KAAL,CAAWK,QAAX,CAAoBF,KAApB;AACD,KAlBkB;;AAEjB,UAAKD,KAAL,GAAa;AACXC,MAAAA,KAAK,EAAEH,KAAK,CAACG;AADF,KAAb;AAFiB;AAKlB;;;;WAMD,0C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AAA,SAAS,EAAEW,sBAAUC,IAZJ;AAajBjB,EAAAA,gBAAgB,EAAEgB,sBAAUC,IAbX;AAcjBf,EAAAA,gBAAgB,EAAEc,sBAAUC,IAdX;AAejBd,EAAAA,oBAAoB,EAAEa,sBAAUC,IAff;AAgBjBV,EAAAA,UAAU,EAAES,sBAAUC,IAhBL;AAiBjBP,EAAAA,cAAc,EAAEM,sBAAUC;AAjBT,C;;AAuErB,IAAMY,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBF,IAAAA,WAAW,EAAE;AACXG,MAAAA,OAAO,EAAE,MADE;AAEXC,MAAAA,KAAK,EAAE,MAFI;AAGXC,MAAAA,MAAM,EAAE,CAHG;AAIXC,MAAAA,UAAU,EAAE;AAJD;AADO,GAAP;AAAA,CAAf;;AASO,IAAMC,WAAW,GAAG,wBAAWL,MAAX,EAAmBJ,cAAnB,CAApB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport EditorAndPad from './editor-and-pad';\nimport { DoneButton } from './done-button';\nimport { withStyles } from '@material-ui/core/styles';\nimport MathPreview from './math-preview';\n\nexport { MathPreview };\n\nexport class MathToolbar extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classNames: PropTypes.object,\n showKeypad: PropTypes.bool,\n noDecimal: PropTypes.bool,\n additionalKeys: PropTypes.array,\n latex: PropTypes.string.isRequired,\n onAnswerBlockAdd: PropTypes.func,\n onChange: PropTypes.func,\n onDone: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n hideDoneButton: PropTypes.bool\n };\n\n static defaultProps = {\n classNames: {},\n keypadMode: 'item-authoring',\n autoFocus: false,\n allowAnswerBlock: false,\n controlledKeypad: false,\n controlledKeypadMode: false,\n noDecimal: false,\n showKeypad: true,\n additionalKeys: [],\n onChange: () => {},\n onAnswerBlockAdd: () => {},\n onFocus: () => {},\n hideDoneButton: false\n };\n\n constructor(props) {\n super(props);\n this.state = {\n latex: props.latex\n };\n }\n\n done = () => {\n this.props.onDone(this.state.latex);\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({ latex: nextProps.latex });\n }\n\n onChange = latex => {\n this.setState({ latex });\n this.props.onChange(latex);\n };\n\n render() {\n const { latex } = this.state;\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n keypadMode,\n noDecimal,\n additionalKeys,\n showKeypad,\n onFocus,\n onBlur,\n hideDoneButton,\n error,\n maxResponseAreas\n } = this.props;\n\n return (\n <PureToolbar\n autoFocus={autoFocus}\n classNames={classNames}\n onAnswerBlockAdd={onAnswerBlockAdd}\n allowAnswerBlock={allowAnswerBlock}\n latex={latex}\n additionalKeys={additionalKeys}\n noDecimal={noDecimal}\n keypadMode={keypadMode}\n onChange={this.onChange}\n onDone={this.done}\n onFocus={onFocus}\n onBlur={onBlur}\n showKeypad={showKeypad}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n hideDoneButton={hideDoneButton}\n error={error}\n maxResponseAreas={maxResponseAreas}\n />\n );\n }\n}\n\nexport class RawPureToolbar extends React.Component {\n static propTypes = {\n classNames: PropTypes.object,\n latex: PropTypes.string.isRequired,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n onChange: PropTypes.func.isRequired,\n onDone: PropTypes.func.isRequired,\n onBlur: PropTypes.func,\n onAnswerBlockAdd: PropTypes.func,\n additionalKeys: PropTypes.array,\n onFocus: PropTypes.func,\n classes: PropTypes.object.isRequired,\n autoFocus: PropTypes.bool,\n noDecimal: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n showKeypad: PropTypes.bool,\n hideDoneButton: PropTypes.bool\n };\n\n render() {\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n additionalKeys,\n showKeypad,\n keypadMode,\n noDecimal,\n latex,\n onChange,\n onDone,\n onFocus,\n onBlur,\n hideDoneButton,\n classes,\n error,\n maxResponseAreas\n } = this.props;\n\n return (\n <div className={cx(classes.pureToolbar, (classNames || {}).toolbar)}>\n <div />\n <EditorAndPad\n autoFocus={autoFocus}\n keypadMode={keypadMode}\n classNames={classNames || {}}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n noDecimal={noDecimal}\n showKeypad={showKeypad}\n additionalKeys={additionalKeys}\n allowAnswerBlock={allowAnswerBlock}\n onAnswerBlockAdd={onAnswerBlockAdd}\n latex={latex}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n error={error}\n maxResponseAreas={maxResponseAreas}\n />\n {(!controlledKeypad || (controlledKeypad && showKeypad)) && !hideDoneButton && (\n <DoneButton onClick={onDone} />\n )}\n </div>\n );\n }\n}\nconst styles = () => ({\n pureToolbar: {\n display: 'flex',\n width: '100%',\n zIndex: 8,\n alignItems: 'center'\n }\n});\n\nexport const PureToolbar = withStyles(styles)(RawPureToolbar);\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.9.2",
|
|
7
7
|
"description": "Math toolbar for editing math equations",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"math",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"@pie-lib/test-utils": "^0.2.19"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "ea44ab953756475319bd8401eb229e2c9864845b"
|
|
36
36
|
}
|
package/src/editor-and-pad.jsx
CHANGED
|
@@ -53,7 +53,7 @@ export class EditorAndPad extends React.Component {
|
|
|
53
53
|
constructor(props) {
|
|
54
54
|
super(props);
|
|
55
55
|
|
|
56
|
-
this.state = { equationEditor: 'item-authoring' };
|
|
56
|
+
this.state = { equationEditor: 'item-authoring', addDisabled: false };
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
componentDidMount() {
|
|
@@ -86,11 +86,23 @@ export class EditorAndPad extends React.Component {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
updateDisable = isEdit => {
|
|
90
|
+
const { maxResponseAreas } = this.props;
|
|
91
|
+
|
|
92
|
+
if (maxResponseAreas) {
|
|
93
|
+
const shouldDisable = this.checkResponseAreasNumber(maxResponseAreas, isEdit);
|
|
94
|
+
|
|
95
|
+
this.setState({ addDisabled: shouldDisable });
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
89
99
|
onAnswerBlockClick = () => {
|
|
90
100
|
this.props.onAnswerBlockAdd();
|
|
91
101
|
this.onClick({
|
|
92
102
|
type: 'answer'
|
|
93
103
|
});
|
|
104
|
+
|
|
105
|
+
this.updateDisable(true);
|
|
94
106
|
};
|
|
95
107
|
|
|
96
108
|
onEditorChange = latex => {
|
|
@@ -98,6 +110,8 @@ export class EditorAndPad extends React.Component {
|
|
|
98
110
|
|
|
99
111
|
updateSpans();
|
|
100
112
|
|
|
113
|
+
this.updateDisable(true);
|
|
114
|
+
|
|
101
115
|
// if no decimals are allowed and the last change is a decimal dot, discard the change
|
|
102
116
|
if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && this.input) {
|
|
103
117
|
this.input.clear();
|
|
@@ -137,6 +151,18 @@ export class EditorAndPad extends React.Component {
|
|
|
137
151
|
this.setState({ equationEditor: evt.target.value });
|
|
138
152
|
};
|
|
139
153
|
|
|
154
|
+
checkResponseAreasNumber = (maxResponseAreas, isEdit) => {
|
|
155
|
+
const { latex } = (this.input && this.input.props) || {};
|
|
156
|
+
|
|
157
|
+
if (latex) {
|
|
158
|
+
const count = (latex.match(/answerBlock/g) || []).length;
|
|
159
|
+
|
|
160
|
+
return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return false;
|
|
164
|
+
};
|
|
165
|
+
|
|
140
166
|
render() {
|
|
141
167
|
const {
|
|
142
168
|
classNames,
|
|
@@ -150,9 +176,11 @@ export class EditorAndPad extends React.Component {
|
|
|
150
176
|
latex,
|
|
151
177
|
onFocus,
|
|
152
178
|
onBlur,
|
|
153
|
-
classes
|
|
179
|
+
classes,
|
|
180
|
+
error
|
|
154
181
|
} = this.props;
|
|
155
182
|
const shouldShowKeypad = !controlledKeypad || (controlledKeypad && showKeypad);
|
|
183
|
+
const { addDisabled } = this.state;
|
|
156
184
|
|
|
157
185
|
log('[render]', latex);
|
|
158
186
|
|
|
@@ -181,18 +209,26 @@ export class EditorAndPad extends React.Component {
|
|
|
181
209
|
</Select>
|
|
182
210
|
</InputContainer>
|
|
183
211
|
)}
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
212
|
+
<div className={cx(classes.inputContainer, error ? classes.error : '')}>
|
|
213
|
+
<mq.Input
|
|
214
|
+
onFocus={() => {
|
|
215
|
+
onFocus && onFocus();
|
|
216
|
+
this.updateDisable(false);
|
|
217
|
+
}}
|
|
218
|
+
onBlur={event => {
|
|
219
|
+
this.updateDisable(false);
|
|
220
|
+
onBlur && onBlur(event);
|
|
221
|
+
}}
|
|
222
|
+
className={cx(
|
|
223
|
+
classes.mathEditor,
|
|
224
|
+
classNames.editor,
|
|
225
|
+
!controlledKeypadMode ? classes.longMathEditor : ''
|
|
226
|
+
)}
|
|
227
|
+
innerRef={r => (this.input = r)}
|
|
228
|
+
latex={latex}
|
|
229
|
+
onChange={this.onEditorChange}
|
|
230
|
+
/>
|
|
231
|
+
</div>
|
|
196
232
|
</div>
|
|
197
233
|
{allowAnswerBlock && (
|
|
198
234
|
<Button
|
|
@@ -200,6 +236,7 @@ export class EditorAndPad extends React.Component {
|
|
|
200
236
|
type="primary"
|
|
201
237
|
style={{ bottom: shouldShowKeypad ? '320px' : '20px' }}
|
|
202
238
|
onClick={this.onAnswerBlockClick}
|
|
239
|
+
disabled={addDisabled}
|
|
203
240
|
>
|
|
204
241
|
+ Response Area
|
|
205
242
|
</Button>
|
|
@@ -262,9 +299,7 @@ const styles = theme => ({
|
|
|
262
299
|
maxWidth: '400px',
|
|
263
300
|
color: color.text(),
|
|
264
301
|
backgroundColor: color.background(),
|
|
265
|
-
padding: theme.spacing.unit
|
|
266
|
-
marginTop: theme.spacing.unit,
|
|
267
|
-
marginBottom: theme.spacing.unit
|
|
302
|
+
padding: theme.spacing.unit
|
|
268
303
|
},
|
|
269
304
|
longMathEditor: {
|
|
270
305
|
maxWidth: '500px'
|
|
@@ -315,6 +350,18 @@ const styles = theme => ({
|
|
|
315
350
|
'& .mq-parallelogram': {
|
|
316
351
|
lineHeight: 0.85
|
|
317
352
|
}
|
|
353
|
+
},
|
|
354
|
+
inputContainer: {
|
|
355
|
+
minWidth: '500px',
|
|
356
|
+
maxWidth: '900px',
|
|
357
|
+
minHeight: '40px',
|
|
358
|
+
width: '100%',
|
|
359
|
+
display: 'flex',
|
|
360
|
+
marginTop: theme.spacing.unit,
|
|
361
|
+
marginBottom: theme.spacing.unit
|
|
362
|
+
},
|
|
363
|
+
error: {
|
|
364
|
+
border: '2px solid red'
|
|
318
365
|
}
|
|
319
366
|
});
|
|
320
367
|
|
package/src/index.jsx
CHANGED
|
@@ -79,7 +79,9 @@ export class MathToolbar extends React.Component {
|
|
|
79
79
|
showKeypad,
|
|
80
80
|
onFocus,
|
|
81
81
|
onBlur,
|
|
82
|
-
hideDoneButton
|
|
82
|
+
hideDoneButton,
|
|
83
|
+
error,
|
|
84
|
+
maxResponseAreas
|
|
83
85
|
} = this.props;
|
|
84
86
|
|
|
85
87
|
return (
|
|
@@ -100,6 +102,8 @@ export class MathToolbar extends React.Component {
|
|
|
100
102
|
controlledKeypad={controlledKeypad}
|
|
101
103
|
controlledKeypadMode={controlledKeypadMode}
|
|
102
104
|
hideDoneButton={hideDoneButton}
|
|
105
|
+
error={error}
|
|
106
|
+
maxResponseAreas={maxResponseAreas}
|
|
103
107
|
/>
|
|
104
108
|
);
|
|
105
109
|
}
|
|
@@ -144,7 +148,9 @@ export class RawPureToolbar extends React.Component {
|
|
|
144
148
|
onFocus,
|
|
145
149
|
onBlur,
|
|
146
150
|
hideDoneButton,
|
|
147
|
-
classes
|
|
151
|
+
classes,
|
|
152
|
+
error,
|
|
153
|
+
maxResponseAreas
|
|
148
154
|
} = this.props;
|
|
149
155
|
|
|
150
156
|
return (
|
|
@@ -165,6 +171,8 @@ export class RawPureToolbar extends React.Component {
|
|
|
165
171
|
onChange={onChange}
|
|
166
172
|
onFocus={onFocus}
|
|
167
173
|
onBlur={onBlur}
|
|
174
|
+
error={error}
|
|
175
|
+
maxResponseAreas={maxResponseAreas}
|
|
168
176
|
/>
|
|
169
177
|
{(!controlledKeypad || (controlledKeypad && showKeypad)) && !hideDoneButton && (
|
|
170
178
|
<DoneButton onClick={onDone} />
|