@pie-lib/math-toolbar 1.12.0-beta.2 → 1.12.0-beta.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 +24 -0
- package/lib/done-button.js +68 -0
- package/lib/done-button.js.map +1 -0
- package/lib/editor-and-pad.js +575 -0
- package/lib/editor-and-pad.js.map +1 -0
- package/lib/index.js +287 -0
- package/lib/index.js.map +1 -0
- package/lib/math-preview.js +240 -0
- package/lib/math-preview.js.map +1 -0
- package/lib/utils.js +21 -0
- package/lib/utils.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.12.0-beta.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.11.30...@pie-lib/math-toolbar@1.12.0-beta.3) (2025-07-20)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/math-toolbar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.12.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.11.30...@pie-lib/math-toolbar@1.12.0-beta.2) (2025-07-20)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-lib/math-toolbar
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [1.12.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.11.30...@pie-lib/math-toolbar@1.12.0-beta.1) (2025-07-20)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-lib/math-toolbar
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
# [1.12.0-beta.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.11.30...@pie-lib/math-toolbar@1.12.0-beta.2) (2025-07-20)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @pie-lib/math-toolbar
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.RawDoneButton = exports.DoneButton = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
15
|
+
|
|
16
|
+
var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
|
|
17
|
+
|
|
18
|
+
var _styles = require("@material-ui/core/styles");
|
|
19
|
+
|
|
20
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
21
|
+
|
|
22
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
23
|
+
|
|
24
|
+
var RawDoneButton = function RawDoneButton(_ref) {
|
|
25
|
+
var classes = _ref.classes,
|
|
26
|
+
onClick = _ref.onClick,
|
|
27
|
+
hideBackground = _ref.hideBackground;
|
|
28
|
+
return /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
29
|
+
"aria-label": "Done",
|
|
30
|
+
className: classes.iconRoot,
|
|
31
|
+
onClick: onClick,
|
|
32
|
+
classes: {
|
|
33
|
+
label: classes.label,
|
|
34
|
+
root: (0, _classnames["default"])(classes.iconRoot, (0, _defineProperty2["default"])({}, classes.hideBackground, hideBackground))
|
|
35
|
+
}
|
|
36
|
+
}, /*#__PURE__*/_react["default"].createElement(_Check["default"], null));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.RawDoneButton = RawDoneButton;
|
|
40
|
+
RawDoneButton.propTypes = {
|
|
41
|
+
classes: _propTypes["default"].object.isRequired,
|
|
42
|
+
onClick: _propTypes["default"].func
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var styles = function styles(theme) {
|
|
46
|
+
return {
|
|
47
|
+
iconRoot: {
|
|
48
|
+
verticalAlign: 'top',
|
|
49
|
+
width: '28px',
|
|
50
|
+
height: '28px',
|
|
51
|
+
color: '#00bb00'
|
|
52
|
+
},
|
|
53
|
+
hideBackground: {
|
|
54
|
+
backgroundColor: theme.palette.common.white,
|
|
55
|
+
'&:hover': {
|
|
56
|
+
backgroundColor: theme.palette.grey[200]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
label: {
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
top: '2px'
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var DoneButton = (0, _styles.withStyles)(styles)(RawDoneButton);
|
|
67
|
+
exports.DoneButton = DoneButton;
|
|
68
|
+
//# sourceMappingURL=done-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/done-button.jsx"],"names":["RawDoneButton","classes","onClick","hideBackground","iconRoot","label","root","propTypes","PropTypes","object","isRequired","func","styles","theme","verticalAlign","width","height","color","backgroundColor","palette","common","white","grey","position","top","DoneButton"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB;AAAA,MAAGC,OAAH,QAAGA,OAAH;AAAA,MAAYC,OAAZ,QAAYA,OAAZ;AAAA,MAAqBC,cAArB,QAAqBA,cAArB;AAAA,sBAC3B,gCAAC,sBAAD;AACE,kBAAW,MADb;AAEE,IAAA,SAAS,EAAEF,OAAO,CAACG,QAFrB;AAGE,IAAA,OAAO,EAAEF,OAHX;AAIE,IAAA,OAAO,EAAE;AACPG,MAAAA,KAAK,EAAEJ,OAAO,CAACI,KADR;AAEPC,MAAAA,IAAI,EAAE,4BAAWL,OAAO,CAACG,QAAnB,uCAAgCH,OAAO,CAACE,cAAxC,EAAyDA,cAAzD;AAFC;AAJX,kBASE,gCAAC,iBAAD,OATF,CAD2B;AAAA,CAAtB;;;AAcPH,aAAa,CAACO,SAAd,GAA0B;AACxBN,EAAAA,OAAO,EAAEO,sBAAUC,MAAV,CAAiBC,UADF;AAExBR,EAAAA,OAAO,EAAEM,sBAAUG;AAFK,CAA1B;;AAKA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBT,IAAAA,QAAQ,EAAE;AACRU,MAAAA,aAAa,EAAE,KADP;AAERC,MAAAA,KAAK,EAAE,MAFC;AAGRC,MAAAA,MAAM,EAAE,MAHA;AAIRC,MAAAA,KAAK,EAAE;AAJC,KADe;AAOzBd,IAAAA,cAAc,EAAE;AACde,MAAAA,eAAe,EAAEL,KAAK,CAACM,OAAN,CAAcC,MAAd,CAAqBC,KADxB;AAGd,iBAAW;AACTH,QAAAA,eAAe,EAAEL,KAAK,CAACM,OAAN,CAAcG,IAAd,CAAmB,GAAnB;AADR;AAHG,KAPS;AAczBjB,IAAAA,KAAK,EAAE;AACLkB,MAAAA,QAAQ,EAAE,UADL;AAELC,MAAAA,GAAG,EAAE;AAFA;AAdkB,GAAZ;AAAA,CAAf;;AAmBO,IAAMC,UAAU,GAAG,wBAAWb,MAAX,EAAmBZ,aAAnB,CAAnB","sourcesContent":["import React from 'react';\n\nimport IconButton from '@material-ui/core/IconButton';\nimport Check from '@material-ui/icons/Check';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nexport const RawDoneButton = ({ classes, onClick, hideBackground }) => (\n <IconButton\n aria-label=\"Done\"\n className={classes.iconRoot}\n onClick={onClick}\n classes={{\n label: classes.label,\n root: classNames(classes.iconRoot, { [classes.hideBackground]: hideBackground }),\n }}\n >\n <Check />\n </IconButton>\n);\n\nRawDoneButton.propTypes = {\n classes: PropTypes.object.isRequired,\n onClick: PropTypes.func,\n};\n\nconst styles = (theme) => ({\n iconRoot: {\n verticalAlign: 'top',\n width: '28px',\n height: '28px',\n color: '#00bb00',\n },\n hideBackground: {\n backgroundColor: theme.palette.common.white,\n\n '&:hover': {\n backgroundColor: theme.palette.grey[200],\n },\n },\n label: {\n position: 'absolute',\n top: '2px',\n },\n});\nexport const DoneButton = withStyles(styles)(RawDoneButton);\n"],"file":"done-button.js"}
|
|
@@ -0,0 +1,575 @@
|
|
|
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 _renderUi = require("@pie-lib/render-ui");
|
|
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(_renderUi.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: _renderUi.color.text(),
|
|
493
|
+
backgroundColor: _renderUi.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
|