@pie-lib/math-toolbar 1.9.0 → 1.9.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/CHANGELOG.md +33 -0
- package/lib/editor-and-pad.js +9 -3
- package/lib/editor-and-pad.js.map +1 -1
- package/package.json +4 -3
- package/src/editor-and-pad.jsx +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
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.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.9.2...@pie-lib/math-toolbar@1.9.3) (2022-05-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **math-toolbar:** make sure errors visually update for item validation ([d36fe40](https://github.com/pie-framework/pie-lib/commit/d36fe4071deb5cb10f61758cfe73b185574b27af))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **math-toolbar:** fix simple response gather PD-1786 ([1769577](https://github.com/pie-framework/pie-lib/commit/176957700d75d3efa0e5fbf08e8e4c6ffe61320d))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [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)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **math-toolbar:** add sanity checks ([e012294](https://github.com/pie-framework/pie-lib/commit/e012294184b6f0c1472e6306be01e76e650c8fa5))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
# [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)
|
|
7
40
|
|
|
8
41
|
|
package/lib/editor-and-pad.js
CHANGED
|
@@ -27,6 +27,8 @@ var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
|
|
|
27
27
|
|
|
28
28
|
var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
|
|
29
29
|
|
|
30
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
33
|
|
|
32
34
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -203,6 +205,10 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
|
|
|
203
205
|
var inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
|
|
204
206
|
log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
|
|
205
207
|
|
|
208
|
+
if (!(0, _isEqual["default"])(this.props.error, nextProps.error)) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
|
|
206
212
|
if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {
|
|
207
213
|
return true;
|
|
208
214
|
}
|
|
@@ -282,14 +288,14 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
|
|
|
282
288
|
className: (0, _classnames["default"])(classes.inputContainer, error ? classes.error : '')
|
|
283
289
|
}, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Input, {
|
|
284
290
|
onFocus: function onFocus() {
|
|
285
|
-
_onFocus();
|
|
291
|
+
_onFocus && _onFocus();
|
|
286
292
|
|
|
287
293
|
_this2.updateDisable(false);
|
|
288
294
|
},
|
|
289
|
-
onBlur: function onBlur() {
|
|
295
|
+
onBlur: function onBlur(event) {
|
|
290
296
|
_this2.updateDisable(false);
|
|
291
297
|
|
|
292
|
-
_onBlur();
|
|
298
|
+
_onBlur && _onBlur(event);
|
|
293
299
|
},
|
|
294
300
|
className: (0, _classnames["default"])(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : ''),
|
|
295
301
|
innerRef: function innerRef(r) {
|
|
@@ -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","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","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;AAM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,KAAK,EAAE,MAJI;AAKX,2BAAqB;AACnBc,QAAAA,MAAM,EAAE;AADW,OALV;AAQX,yBAAmB;AACjBS,QAAAA,OAAO,EAAE,MADQ;AAEjBC,QAAAA,SAAS,EAAE,MAFM;AAGjBV,QAAAA,MAAM,uBAAgBxB,KAAK,CAAC4B,OAAN,CAAcC,OAAd,CAAsBC,IAAtC,CAHW;AAIjBK,QAAAA,YAAY,EAAE;AAJG,OARR;AAcX,+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;AAgGvB3B,IAAAA,cAAc,EAAE;AACd0B,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;AAyGvBnD,IAAAA,KAAK,EAAE;AACLqD,MAAAA,MAAM,EAAE;AADH;AAzGgB,GAAL;AAAA,CAApB;;eA8Ge,wBAAWzB,MAAX,EAAmBzE,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();\n this.updateDisable(false);\n }}\n onBlur={() => {\n this.updateDisable(false);\n onBlur();\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"}
|
|
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","error","keypadMode","controlledKeypad","showKeypad","classNames","allowAnswerBlock","additionalKeys","controlledKeypadMode","onFocus","onBlur","classes","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;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AALA,IAAMA,GAAG,GAAG,uBAAM,sCAAN,CAAZ;AAOA,IAAMC,YAAY,GAAG,OAArB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,IAAI,EAAI;AACzB,MAAI,CAACA,I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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';\nimport isEqual from 'lodash/isEqual';\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 (!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 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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.9.
|
|
6
|
+
"version": "1.9.3",
|
|
7
7
|
"description": "Math toolbar for editing math equations",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"math",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"@pie-lib/math-input": "^6.6.9",
|
|
23
23
|
"classnames": "^2.2.6",
|
|
24
24
|
"debug": "^4.1.1",
|
|
25
|
-
"keycode": "^2.2.0"
|
|
25
|
+
"keycode": "^2.2.0",
|
|
26
|
+
"lodash": "^4.17.11"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"react": "^16.8.1",
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"@pie-lib/test-utils": "^0.2.19"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "84fbd889875b1e3a0539451a940fb772fc46162a"
|
|
36
37
|
}
|
package/src/editor-and-pad.jsx
CHANGED
|
@@ -10,6 +10,7 @@ import { color, InputContainer } from '@pie-lib/render-ui';
|
|
|
10
10
|
import MenuItem from '@material-ui/core/MenuItem';
|
|
11
11
|
import Select from '@material-ui/core/Select';
|
|
12
12
|
import { updateSpans } from '@pie-lib/math-input';
|
|
13
|
+
import isEqual from 'lodash/isEqual';
|
|
13
14
|
|
|
14
15
|
const decimalRegex = /\.|,/g;
|
|
15
16
|
|
|
@@ -128,6 +129,10 @@ export class EditorAndPad extends React.Component {
|
|
|
128
129
|
const inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
|
|
129
130
|
log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
|
|
130
131
|
|
|
132
|
+
if (!isEqual(this.props.error, nextProps.error)) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
131
136
|
if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {
|
|
132
137
|
return true;
|
|
133
138
|
}
|
|
@@ -212,12 +217,12 @@ export class EditorAndPad extends React.Component {
|
|
|
212
217
|
<div className={cx(classes.inputContainer, error ? classes.error : '')}>
|
|
213
218
|
<mq.Input
|
|
214
219
|
onFocus={() => {
|
|
215
|
-
onFocus();
|
|
220
|
+
onFocus && onFocus();
|
|
216
221
|
this.updateDisable(false);
|
|
217
222
|
}}
|
|
218
|
-
onBlur={
|
|
223
|
+
onBlur={event => {
|
|
219
224
|
this.updateDisable(false);
|
|
220
|
-
onBlur();
|
|
225
|
+
onBlur && onBlur(event);
|
|
221
226
|
}}
|
|
222
227
|
className={cx(
|
|
223
228
|
classes.mathEditor,
|