@pie-lib/math-toolbar 2.1.0-next.2 → 2.1.0-next.30
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 +8 -0
- package/lib/done-button.js +61 -0
- package/lib/done-button.js.map +1 -0
- package/lib/editor-and-pad.js +545 -0
- package/lib/editor-and-pad.js.map +1 -0
- package/lib/index.js +243 -0
- package/lib/index.js.map +1 -0
- package/lib/math-preview.js +203 -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 +5 -5
- package/src/__tests__/math-preview.test.js +1 -5
- package/src/math-preview.jsx +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
# [2.1.0-next.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@2.1.0-next.2...@pie-lib/math-toolbar@2.1.0-next.4) (2026-01-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/math-toolbar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [2.1.0-next.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@2.1.0-next.1...@pie-lib/math-toolbar@2.1.0-next.2) (2026-01-26)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-lib/math-toolbar
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.js");
|
|
4
|
+
require("core-js/modules/es.array.filter.js");
|
|
5
|
+
require("core-js/modules/es.array.for-each.js");
|
|
6
|
+
require("core-js/modules/es.object.define-properties.js");
|
|
7
|
+
require("core-js/modules/es.object.define-property.js");
|
|
8
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
9
|
+
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
10
|
+
require("core-js/modules/es.object.keys.js");
|
|
11
|
+
require("core-js/modules/es.object.to-string.js");
|
|
12
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
exports.RawDoneButton = exports.DoneButton = void 0;
|
|
18
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
+
var _react = _interopRequireDefault(require("react"));
|
|
20
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
21
|
+
var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
|
|
22
|
+
var _styles = require("@mui/material/styles");
|
|
23
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
24
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
|
+
var StyledIconButton = (0, _styles.styled)(_IconButton["default"])(function (_ref) {
|
|
27
|
+
var theme = _ref.theme,
|
|
28
|
+
hideBackground = _ref.hideBackground;
|
|
29
|
+
return _objectSpread(_objectSpread({
|
|
30
|
+
verticalAlign: 'top',
|
|
31
|
+
width: '28px',
|
|
32
|
+
height: '28px',
|
|
33
|
+
color: '#00bb00'
|
|
34
|
+
}, hideBackground && {
|
|
35
|
+
backgroundColor: theme.palette.common.white,
|
|
36
|
+
'&:hover': {
|
|
37
|
+
backgroundColor: theme.palette.grey[200]
|
|
38
|
+
}
|
|
39
|
+
}), {}, {
|
|
40
|
+
'& .MuiIconButton-label': {
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: '2px'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
var RawDoneButton = exports.RawDoneButton = function RawDoneButton(_ref2) {
|
|
47
|
+
var onClick = _ref2.onClick,
|
|
48
|
+
hideBackground = _ref2.hideBackground;
|
|
49
|
+
return /*#__PURE__*/_react["default"].createElement(StyledIconButton, {
|
|
50
|
+
"aria-label": "Done",
|
|
51
|
+
onClick: onClick,
|
|
52
|
+
hideBackground: hideBackground,
|
|
53
|
+
size: "large"
|
|
54
|
+
}, /*#__PURE__*/_react["default"].createElement(_Check["default"], null));
|
|
55
|
+
};
|
|
56
|
+
RawDoneButton.propTypes = {
|
|
57
|
+
onClick: _propTypes["default"].func,
|
|
58
|
+
hideBackground: _propTypes["default"].bool
|
|
59
|
+
};
|
|
60
|
+
var DoneButton = exports.DoneButton = RawDoneButton;
|
|
61
|
+
//# sourceMappingURL=done-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"done-button.js","names":["_react","_interopRequireDefault","require","_IconButton","_Check","_styles","_propTypes","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","StyledIconButton","styled","IconButton","_ref","theme","hideBackground","verticalAlign","width","height","color","backgroundColor","palette","common","white","grey","position","top","RawDoneButton","exports","_ref2","onClick","createElement","size","propTypes","PropTypes","func","bool","DoneButton"],"sources":["../src/done-button.jsx"],"sourcesContent":["import React from 'react';\n\nimport IconButton from '@mui/material/IconButton';\nimport Check from '@mui/icons-material/Check';\nimport { styled } from '@mui/material/styles';\nimport PropTypes from 'prop-types';\n\nconst StyledIconButton = styled(IconButton)(({ theme, hideBackground }) => ({\n verticalAlign: 'top',\n width: '28px',\n height: '28px',\n color: '#00bb00',\n ...(hideBackground && {\n backgroundColor: theme.palette.common.white,\n '&:hover': {\n backgroundColor: theme.palette.grey[200],\n },\n }),\n '& .MuiIconButton-label': {\n position: 'absolute',\n top: '2px',\n },\n}));\n\nexport const RawDoneButton = ({ onClick, hideBackground }) => (\n <StyledIconButton\n aria-label=\"Done\"\n onClick={onClick}\n hideBackground={hideBackground}\n size=\"large\"\n >\n <Check />\n </StyledIconButton>\n);\n\nRawDoneButton.propTypes = {\n onClick: PropTypes.func,\n hideBackground: PropTypes.bool,\n};\n\nexport const DoneButton = RawDoneButton;\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.js");
|
|
4
|
+
require("core-js/modules/es.array.filter.js");
|
|
5
|
+
require("core-js/modules/es.array.for-each.js");
|
|
6
|
+
require("core-js/modules/es.object.define-properties.js");
|
|
7
|
+
require("core-js/modules/es.object.define-property.js");
|
|
8
|
+
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
9
|
+
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
10
|
+
require("core-js/modules/es.object.keys.js");
|
|
11
|
+
require("core-js/modules/es.reflect.construct.js");
|
|
12
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
exports["default"] = exports.EditorAndPad = void 0;
|
|
18
|
+
require("core-js/modules/es.array.index-of.js");
|
|
19
|
+
require("core-js/modules/es.date.to-string.js");
|
|
20
|
+
require("core-js/modules/es.object.to-string.js");
|
|
21
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
22
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
23
|
+
require("core-js/modules/es.string.match.js");
|
|
24
|
+
require("core-js/modules/es.string.replace.js");
|
|
25
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
26
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
27
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
28
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
29
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
30
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
|
+
var _react = _interopRequireDefault(require("react"));
|
|
32
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
33
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
34
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
35
|
+
var _styles = require("@mui/material/styles");
|
|
36
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
37
|
+
var _Select = _interopRequireDefault(require("@mui/material/Select"));
|
|
38
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
39
|
+
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
40
|
+
var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
|
|
41
|
+
var _mathInput = require("@pie-lib/math-input");
|
|
42
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
43
|
+
var _utils = require("./utils");
|
|
44
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
45
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
46
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
47
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
48
|
+
var _mq$CommonMqStyles = _mathInput.mq.CommonMqStyles,
|
|
49
|
+
commonMqFontStyles = _mq$CommonMqStyles.commonMqFontStyles,
|
|
50
|
+
commonMqKeyboardStyles = _mq$CommonMqStyles.commonMqKeyboardStyles,
|
|
51
|
+
longdivStyles = _mq$CommonMqStyles.longdivStyles,
|
|
52
|
+
supsubStyles = _mq$CommonMqStyles.supsubStyles;
|
|
53
|
+
var log = (0, _debug["default"])('@pie-lib:math-toolbar:editor-and-pad');
|
|
54
|
+
var decimalRegex = /\.|,/g;
|
|
55
|
+
var MathToolbarContainer = (0, _styles.styled)('div')(function (_ref) {
|
|
56
|
+
var theme = _ref.theme;
|
|
57
|
+
return {
|
|
58
|
+
zIndex: 9,
|
|
59
|
+
position: 'relative',
|
|
60
|
+
textAlign: 'center',
|
|
61
|
+
width: 'auto',
|
|
62
|
+
'& > .mq-math-mode': {
|
|
63
|
+
border: 'solid 1px lightgrey'
|
|
64
|
+
},
|
|
65
|
+
'& > .mq-focused': {
|
|
66
|
+
outline: 'none',
|
|
67
|
+
boxShadow: 'none',
|
|
68
|
+
border: "dotted 1px ".concat(theme.palette.primary.main),
|
|
69
|
+
borderRadius: '0px'
|
|
70
|
+
},
|
|
71
|
+
'& .mq-overarrow-inner': {
|
|
72
|
+
border: 'none !important',
|
|
73
|
+
paddingTop: '0 !important'
|
|
74
|
+
},
|
|
75
|
+
'& .mq-overarrow-inner-right': {
|
|
76
|
+
display: 'none !important'
|
|
77
|
+
},
|
|
78
|
+
'& .mq-overarrow-inner-left': {
|
|
79
|
+
display: 'none !important'
|
|
80
|
+
},
|
|
81
|
+
'& .mq-longdiv-inner': {
|
|
82
|
+
borderTop: '1px solid !important',
|
|
83
|
+
paddingTop: '1.5px !important'
|
|
84
|
+
},
|
|
85
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
86
|
+
top: '7.8px',
|
|
87
|
+
marginTop: '0px',
|
|
88
|
+
minWidth: '1.23em'
|
|
89
|
+
},
|
|
90
|
+
'& .mq-parallelogram': {
|
|
91
|
+
lineHeight: 0.85
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
var InputAndTypeContainer = (0, _styles.styled)('div')(function (_ref2) {
|
|
96
|
+
var theme = _ref2.theme,
|
|
97
|
+
hide = _ref2.hide;
|
|
98
|
+
return {
|
|
99
|
+
display: hide ? 'none' : 'flex',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
'& .mq-editable-field .mq-cursor': {
|
|
102
|
+
top: '-4px'
|
|
103
|
+
},
|
|
104
|
+
'& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {
|
|
105
|
+
paddingTop: '18px'
|
|
106
|
+
},
|
|
107
|
+
'& .mq-math-mode .mq-overarrow': {
|
|
108
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
109
|
+
},
|
|
110
|
+
'& .mq-math-mode .mq-overline .mq-overline-inner': {
|
|
111
|
+
paddingTop: '0.4em !important'
|
|
112
|
+
},
|
|
113
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
114
|
+
minWidth: '1.23em',
|
|
115
|
+
'& *': {
|
|
116
|
+
lineHeight: '1 !important'
|
|
117
|
+
},
|
|
118
|
+
'&:before': {
|
|
119
|
+
top: '-0.45em',
|
|
120
|
+
left: '-1px'
|
|
121
|
+
},
|
|
122
|
+
'&:after': {
|
|
123
|
+
position: 'absolute !important',
|
|
124
|
+
top: '0px !important',
|
|
125
|
+
right: '-2px'
|
|
126
|
+
},
|
|
127
|
+
'&.mq-empty:after': {
|
|
128
|
+
top: '-0.45em'
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
132
|
+
'&:before': {
|
|
133
|
+
top: '-0.4em',
|
|
134
|
+
right: '-1px'
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
'& *': _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), supsubStyles), longdivStyles), {}, {
|
|
138
|
+
'& .mq-math-mode .mq-sqrt-prefix': {
|
|
139
|
+
verticalAlign: 'baseline !important',
|
|
140
|
+
top: '1px !important',
|
|
141
|
+
left: '-0.1em !important'
|
|
142
|
+
},
|
|
143
|
+
'& .mq-math-mode .mq-overarc ': {
|
|
144
|
+
paddingTop: '0.45em !important'
|
|
145
|
+
},
|
|
146
|
+
'& .mq-math-mode .mq-empty': {
|
|
147
|
+
padding: '9px 1px !important'
|
|
148
|
+
},
|
|
149
|
+
'& .mq-math-mode .mq-root-block': {
|
|
150
|
+
paddingTop: '10px'
|
|
151
|
+
},
|
|
152
|
+
'& .mq-scaled .mq-sqrt-prefix': {
|
|
153
|
+
top: '0 !important'
|
|
154
|
+
},
|
|
155
|
+
'& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
|
|
156
|
+
marginLeft: '4px !important',
|
|
157
|
+
paddingTop: '6px !important',
|
|
158
|
+
paddingLeft: '6px !important'
|
|
159
|
+
},
|
|
160
|
+
'& .mq-math-mode .mq-paren': {
|
|
161
|
+
verticalAlign: 'top !important',
|
|
162
|
+
padding: '1px 0.1em !important'
|
|
163
|
+
},
|
|
164
|
+
'& .mq-math-mode .mq-sqrt-stem': {
|
|
165
|
+
borderTop: '0.07em solid',
|
|
166
|
+
marginLeft: '-1.5px',
|
|
167
|
+
marginTop: '-2px !important',
|
|
168
|
+
paddingTop: '5px !important'
|
|
169
|
+
},
|
|
170
|
+
'& .mq-math-mode .mq-denominator': {
|
|
171
|
+
marginTop: '-5px !important',
|
|
172
|
+
padding: '0.5em 0.1em 0.1em !important'
|
|
173
|
+
},
|
|
174
|
+
'& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
|
|
175
|
+
padding: '0 0.1em !important',
|
|
176
|
+
paddingBottom: '0 !important',
|
|
177
|
+
marginBottom: '-2px'
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
'& span[data-prime="true"]': {
|
|
181
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
var StyledFormControl = (0, _styles.styled)(_FormControl["default"])({
|
|
186
|
+
flex: 'initial',
|
|
187
|
+
width: '25%',
|
|
188
|
+
minWidth: '100px',
|
|
189
|
+
marginLeft: '15px',
|
|
190
|
+
marginTop: '5px',
|
|
191
|
+
marginBottom: '5px',
|
|
192
|
+
marginRight: '5px',
|
|
193
|
+
'& label': {
|
|
194
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
195
|
+
},
|
|
196
|
+
'& div': {
|
|
197
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
var StyledInputLabel = (0, _styles.styled)(_InputLabel["default"])(function () {
|
|
201
|
+
return {
|
|
202
|
+
backgroundColor: 'transparent'
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
var InputContainerDiv = (0, _styles.styled)('div')(function (_ref3) {
|
|
206
|
+
var theme = _ref3.theme,
|
|
207
|
+
error = _ref3.error;
|
|
208
|
+
return _objectSpread(_objectSpread({
|
|
209
|
+
minWidth: '500px',
|
|
210
|
+
maxWidth: '900px',
|
|
211
|
+
minHeight: '30px',
|
|
212
|
+
width: '100%',
|
|
213
|
+
display: 'flex',
|
|
214
|
+
marginTop: theme.spacing(1),
|
|
215
|
+
marginBottom: theme.spacing(1)
|
|
216
|
+
}, error && {
|
|
217
|
+
border: '2px solid red'
|
|
218
|
+
}), {}, {
|
|
219
|
+
'& .mq-sqrt-prefix .mq-scaled': {
|
|
220
|
+
verticalAlign: 'middle !important'
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
var MathEditor = (0, _styles.styled)(_mathInput.mq.Input)(function (_ref4) {
|
|
225
|
+
var controlledKeypadMode = _ref4.controlledKeypadMode;
|
|
226
|
+
return {
|
|
227
|
+
maxWidth: controlledKeypadMode ? '400px' : '500px',
|
|
228
|
+
color: _renderUi.color.text(),
|
|
229
|
+
backgroundColor: _renderUi.color.background(),
|
|
230
|
+
padding: '2px'
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
var AddAnswerBlockButton = (0, _styles.styled)(_Button["default"])({
|
|
234
|
+
position: 'absolute',
|
|
235
|
+
right: '12px',
|
|
236
|
+
border: '1px solid lightgrey',
|
|
237
|
+
color: _renderUi.color.text()
|
|
238
|
+
});
|
|
239
|
+
var StyledHr = (0, _styles.styled)('hr')(function (_ref5) {
|
|
240
|
+
var theme = _ref5.theme;
|
|
241
|
+
return {
|
|
242
|
+
padding: 0,
|
|
243
|
+
margin: 0,
|
|
244
|
+
height: '1px',
|
|
245
|
+
border: 'none',
|
|
246
|
+
borderBottom: "solid 1px ".concat(theme.palette.primary.main)
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
var KeyboardContainer = (0, _styles.styled)(_mathInput.HorizontalKeypad)(function (_ref6) {
|
|
250
|
+
var mode = _ref6.mode;
|
|
251
|
+
return _objectSpread(_objectSpread({}, commonMqKeyboardStyles), mode === 'language' && {
|
|
252
|
+
'& *': {
|
|
253
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
var toNodeData = function toNodeData(data) {
|
|
258
|
+
if (!data) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
var type = data.type,
|
|
262
|
+
value = data.value;
|
|
263
|
+
if (type === 'command' || type === 'cursor') {
|
|
264
|
+
return data;
|
|
265
|
+
} else if (type === 'answer') {
|
|
266
|
+
return _objectSpread({
|
|
267
|
+
type: 'answer'
|
|
268
|
+
}, data);
|
|
269
|
+
} else if (value === 'clear') {
|
|
270
|
+
return {
|
|
271
|
+
type: 'clear'
|
|
272
|
+
};
|
|
273
|
+
} else {
|
|
274
|
+
return {
|
|
275
|
+
type: 'write',
|
|
276
|
+
value: value
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
var EditorAndPad = exports.EditorAndPad = /*#__PURE__*/function (_React$Component) {
|
|
281
|
+
function EditorAndPad(props) {
|
|
282
|
+
var _this;
|
|
283
|
+
(0, _classCallCheck2["default"])(this, EditorAndPad);
|
|
284
|
+
_this = _callSuper(this, EditorAndPad, [props]);
|
|
285
|
+
(0, _defineProperty2["default"])(_this, "onClick", function (data) {
|
|
286
|
+
var _this$props = _this.props,
|
|
287
|
+
noDecimal = _this$props.noDecimal,
|
|
288
|
+
noLatexHandling = _this$props.noLatexHandling,
|
|
289
|
+
onChange = _this$props.onChange;
|
|
290
|
+
var c = toNodeData(data);
|
|
291
|
+
log('mathChange: ', c);
|
|
292
|
+
if (noLatexHandling) {
|
|
293
|
+
onChange(c.value);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// if decimals are not allowed for this response, we discard the input
|
|
298
|
+
if (noDecimal && (c.value === '.' || c.value === ',')) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (!c) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (c.type === 'clear') {
|
|
305
|
+
log('call clear...');
|
|
306
|
+
_this.input.clear();
|
|
307
|
+
} else if (c.type === 'command') {
|
|
308
|
+
_this.input.command(c.value);
|
|
309
|
+
} else if (c.type === 'cursor') {
|
|
310
|
+
_this.input.keystroke(c.value);
|
|
311
|
+
} else if (c.type === 'answer') {
|
|
312
|
+
_this.input.write('%response%');
|
|
313
|
+
} else {
|
|
314
|
+
_this.input.write(c.value);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
(0, _defineProperty2["default"])(_this, "updateDisable", function (isEdit) {
|
|
318
|
+
var maxResponseAreas = _this.props.maxResponseAreas;
|
|
319
|
+
if (maxResponseAreas) {
|
|
320
|
+
var shouldDisable = _this.checkResponseAreasNumber(maxResponseAreas, isEdit);
|
|
321
|
+
_this.setState({
|
|
322
|
+
addDisabled: shouldDisable
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
(0, _defineProperty2["default"])(_this, "onAnswerBlockClick", function () {
|
|
327
|
+
_this.props.onAnswerBlockAdd();
|
|
328
|
+
_this.onClick({
|
|
329
|
+
type: 'answer'
|
|
330
|
+
});
|
|
331
|
+
_this.updateDisable(true);
|
|
332
|
+
});
|
|
333
|
+
(0, _defineProperty2["default"])(_this, "onEditorChange", function (latex) {
|
|
334
|
+
var _this$props2 = _this.props,
|
|
335
|
+
onChange = _this$props2.onChange,
|
|
336
|
+
noDecimal = _this$props2.noDecimal;
|
|
337
|
+
(0, _mathInput.updateSpans)();
|
|
338
|
+
(0, _utils.markFractionBaseSuperscripts)();
|
|
339
|
+
_this.updateDisable(true);
|
|
340
|
+
|
|
341
|
+
// if no decimals are allowed and the last change is a decimal dot, discard the change
|
|
342
|
+
if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && _this.input) {
|
|
343
|
+
_this.input.clear();
|
|
344
|
+
_this.input.write(latex.replace(decimalRegex, ''));
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// eslint-disable-next-line no-useless-escape
|
|
349
|
+
var regexMatch = latex.match(/[0-9]\\ \\frac\{[^\{]*\}\{ \}/);
|
|
350
|
+
if (_this.input && regexMatch && regexMatch !== null && regexMatch !== void 0 && regexMatch.length) {
|
|
351
|
+
try {
|
|
352
|
+
_this.input.mathField.__controller.cursor.insLeftOf(_this.input.mathField.__controller.cursor.parent[-1].parent);
|
|
353
|
+
_this.input.mathField.el().dispatchEvent(new KeyboardEvent('keydown', {
|
|
354
|
+
keyCode: 8
|
|
355
|
+
}));
|
|
356
|
+
} catch (e) {
|
|
357
|
+
// eslint-disable-next-line no-console
|
|
358
|
+
console.error(e.toString());
|
|
359
|
+
}
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
onChange(latex);
|
|
363
|
+
});
|
|
364
|
+
(0, _defineProperty2["default"])(_this, "onEditorTypeChange", function (evt) {
|
|
365
|
+
_this.setState({
|
|
366
|
+
equationEditor: evt.target.value
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
(0, _defineProperty2["default"])(_this, "checkResponseAreasNumber", function (maxResponseAreas, isEdit) {
|
|
370
|
+
var _ref7 = _this.input && _this.input.props || {},
|
|
371
|
+
latex = _ref7.latex;
|
|
372
|
+
if (latex) {
|
|
373
|
+
var count = (latex.match(/answerBlock/g) || []).length;
|
|
374
|
+
return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
|
|
375
|
+
}
|
|
376
|
+
return false;
|
|
377
|
+
});
|
|
378
|
+
_this.state = {
|
|
379
|
+
equationEditor: 'item-authoring',
|
|
380
|
+
addDisabled: false
|
|
381
|
+
};
|
|
382
|
+
return _this;
|
|
383
|
+
}
|
|
384
|
+
(0, _inherits2["default"])(EditorAndPad, _React$Component);
|
|
385
|
+
return (0, _createClass2["default"])(EditorAndPad, [{
|
|
386
|
+
key: "componentDidMount",
|
|
387
|
+
value: function componentDidMount() {
|
|
388
|
+
if (this.input && this.props.autoFocus) {
|
|
389
|
+
this.input.focus();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}, {
|
|
393
|
+
key: "shouldComponentUpdate",
|
|
394
|
+
value:
|
|
395
|
+
/** Only render if the mathquill instance's latex is different
|
|
396
|
+
* or the keypad state changed from one state to the other (shown / hidden) */
|
|
397
|
+
function shouldComponentUpdate(nextProps, nextState) {
|
|
398
|
+
var inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
|
|
399
|
+
log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
|
|
400
|
+
if (!(0, _isEqual["default"])(this.props.error, nextProps.error)) {
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
if (!inputIsDifferent && this.props.controlledKeypad) {
|
|
413
|
+
return this.props.showKeypad !== nextProps.showKeypad;
|
|
414
|
+
}
|
|
415
|
+
return inputIsDifferent;
|
|
416
|
+
}
|
|
417
|
+
}, {
|
|
418
|
+
key: "render",
|
|
419
|
+
value: function render() {
|
|
420
|
+
var _this2 = this;
|
|
421
|
+
var _this$props3 = this.props,
|
|
422
|
+
classNames = _this$props3.classNames,
|
|
423
|
+
keypadMode = _this$props3.keypadMode,
|
|
424
|
+
allowAnswerBlock = _this$props3.allowAnswerBlock,
|
|
425
|
+
additionalKeys = _this$props3.additionalKeys,
|
|
426
|
+
controlledKeypad = _this$props3.controlledKeypad,
|
|
427
|
+
controlledKeypadMode = _this$props3.controlledKeypadMode,
|
|
428
|
+
showKeypad = _this$props3.showKeypad,
|
|
429
|
+
setKeypadInteraction = _this$props3.setKeypadInteraction,
|
|
430
|
+
noDecimal = _this$props3.noDecimal,
|
|
431
|
+
hideInput = _this$props3.hideInput,
|
|
432
|
+
layoutForKeyPad = _this$props3.layoutForKeyPad,
|
|
433
|
+
latex = _this$props3.latex,
|
|
434
|
+
_onFocus = _this$props3.onFocus,
|
|
435
|
+
_onBlur = _this$props3.onBlur,
|
|
436
|
+
error = _this$props3.error;
|
|
437
|
+
var shouldShowKeypad = !controlledKeypad || controlledKeypad && showKeypad;
|
|
438
|
+
var addDisabled = this.state.addDisabled;
|
|
439
|
+
log('[render]', latex);
|
|
440
|
+
return /*#__PURE__*/_react["default"].createElement(MathToolbarContainer, {
|
|
441
|
+
className: classNames.mathToolbar
|
|
442
|
+
}, /*#__PURE__*/_react["default"].createElement(InputAndTypeContainer, {
|
|
443
|
+
hide: hideInput
|
|
444
|
+
}, controlledKeypadMode && /*#__PURE__*/_react["default"].createElement(StyledFormControl, {
|
|
445
|
+
variant: 'standard'
|
|
446
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledInputLabel, {
|
|
447
|
+
id: "equation-editor-label"
|
|
448
|
+
}, 'Equation Editor'), /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
449
|
+
labelId: "equation-editor-label",
|
|
450
|
+
id: "equation-editor-select",
|
|
451
|
+
name: "equationEditor",
|
|
452
|
+
label: 'Equation Editor',
|
|
453
|
+
onChange: this.onEditorTypeChange,
|
|
454
|
+
value: this.state.equationEditor,
|
|
455
|
+
MenuProps: {
|
|
456
|
+
transitionDuration: {
|
|
457
|
+
enter: 225,
|
|
458
|
+
exit: 195
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}, /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
462
|
+
value: "non-negative-integers"
|
|
463
|
+
}, "Numeric - Non-Negative Integers"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
464
|
+
value: "integers"
|
|
465
|
+
}, "Numeric - Integers"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
466
|
+
value: "decimals"
|
|
467
|
+
}, "Numeric - Decimals"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
468
|
+
value: "fractions"
|
|
469
|
+
}, "Numeric - Fractions"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
470
|
+
value: 1
|
|
471
|
+
}, "Grade 1 - 2"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
472
|
+
value: 3
|
|
473
|
+
}, "Grade 3 - 5"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
474
|
+
value: 6
|
|
475
|
+
}, "Grade 6 - 7"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
476
|
+
value: 8
|
|
477
|
+
}, "Grade 8 - HS"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
478
|
+
value: 'geometry'
|
|
479
|
+
}, "Geometry"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
480
|
+
value: 'advanced-algebra'
|
|
481
|
+
}, "Advanced Algebra"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
482
|
+
value: 'statistics'
|
|
483
|
+
}, "Statistics"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
484
|
+
value: 'item-authoring'
|
|
485
|
+
}, "Item Authoring"))), /*#__PURE__*/_react["default"].createElement(InputContainerDiv, {
|
|
486
|
+
error: error
|
|
487
|
+
}, /*#__PURE__*/_react["default"].createElement(MathEditor, {
|
|
488
|
+
onFocus: function onFocus() {
|
|
489
|
+
_onFocus && _onFocus();
|
|
490
|
+
_this2.updateDisable(false);
|
|
491
|
+
},
|
|
492
|
+
onBlur: function onBlur(event) {
|
|
493
|
+
_this2.updateDisable(false);
|
|
494
|
+
_onBlur && _onBlur(event);
|
|
495
|
+
},
|
|
496
|
+
className: classNames && classNames.editor || '',
|
|
497
|
+
controlledKeypadMode: controlledKeypadMode,
|
|
498
|
+
ref: function ref(r) {
|
|
499
|
+
return _this2.input = r;
|
|
500
|
+
},
|
|
501
|
+
latex: latex,
|
|
502
|
+
onChange: this.onEditorChange
|
|
503
|
+
}))), allowAnswerBlock && /*#__PURE__*/_react["default"].createElement(AddAnswerBlockButton, {
|
|
504
|
+
type: "primary",
|
|
505
|
+
style: {
|
|
506
|
+
bottom: shouldShowKeypad ? '320px' : '20px'
|
|
507
|
+
},
|
|
508
|
+
onClick: this.onAnswerBlockClick,
|
|
509
|
+
disabled: addDisabled
|
|
510
|
+
}, "+ Response Area"), /*#__PURE__*/_react["default"].createElement(StyledHr, null), shouldShowKeypad && /*#__PURE__*/_react["default"].createElement(KeyboardContainer, {
|
|
511
|
+
mode: controlledKeypadMode ? this.state.equationEditor : keypadMode,
|
|
512
|
+
controlledKeypadMode: controlledKeypadMode,
|
|
513
|
+
layoutForKeyPad: layoutForKeyPad,
|
|
514
|
+
additionalKeys: additionalKeys,
|
|
515
|
+
onClick: this.onClick,
|
|
516
|
+
noDecimal: noDecimal,
|
|
517
|
+
setKeypadInteraction: setKeypadInteraction
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
}]);
|
|
521
|
+
}(_react["default"].Component);
|
|
522
|
+
(0, _defineProperty2["default"])(EditorAndPad, "propTypes", {
|
|
523
|
+
classNames: _propTypes["default"].object,
|
|
524
|
+
keypadMode: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
525
|
+
autoFocus: _propTypes["default"].bool,
|
|
526
|
+
allowAnswerBlock: _propTypes["default"].bool,
|
|
527
|
+
showKeypad: _propTypes["default"].bool,
|
|
528
|
+
controlledKeypad: _propTypes["default"].bool,
|
|
529
|
+
controlledKeypadMode: _propTypes["default"].bool,
|
|
530
|
+
error: _propTypes["default"].string,
|
|
531
|
+
noDecimal: _propTypes["default"].bool,
|
|
532
|
+
hideInput: _propTypes["default"].bool,
|
|
533
|
+
noLatexHandling: _propTypes["default"].bool,
|
|
534
|
+
layoutForKeyPad: _propTypes["default"].object,
|
|
535
|
+
maxResponseAreas: _propTypes["default"].number,
|
|
536
|
+
additionalKeys: _propTypes["default"].array,
|
|
537
|
+
latex: _propTypes["default"].string.isRequired,
|
|
538
|
+
onAnswerBlockAdd: _propTypes["default"].func,
|
|
539
|
+
onFocus: _propTypes["default"].func,
|
|
540
|
+
onBlur: _propTypes["default"].func,
|
|
541
|
+
onChange: _propTypes["default"].func.isRequired,
|
|
542
|
+
setKeypadInteraction: _propTypes["default"].func
|
|
543
|
+
});
|
|
544
|
+
var _default = exports["default"] = EditorAndPad;
|
|
545
|
+
//# sourceMappingURL=editor-and-pad.js.map
|