@pie-lib/math-input 6.6.1-next.42 → 6.6.1-next.437
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.json +75 -0
- package/CHANGELOG.md +95 -0
- package/lib/horizontal-keypad.js +33 -38
- package/lib/horizontal-keypad.js.map +1 -1
- package/lib/index.js +12 -7
- package/lib/index.js.map +1 -1
- package/lib/keypad/index.js +114 -68
- package/lib/keypad/index.js.map +1 -1
- package/lib/keypad/keys-layout.js +5 -1
- package/lib/keypad/keys-layout.js.map +1 -1
- package/lib/keys/basic-operators.js +1 -1
- package/lib/keys/basic-operators.js.map +1 -1
- package/lib/keys/chars.js +1 -1
- package/lib/keys/chars.js.map +1 -1
- package/lib/keys/comparison.js +7 -5
- package/lib/keys/comparison.js.map +1 -1
- package/lib/keys/constants.js +17 -1
- package/lib/keys/constants.js.map +1 -1
- package/lib/keys/digits.js +2 -2
- package/lib/keys/digits.js.map +1 -1
- package/lib/keys/edit.js.map +1 -1
- package/lib/keys/exponent.js +1 -1
- package/lib/keys/exponent.js.map +1 -1
- package/lib/keys/fractions.js +1 -1
- package/lib/keys/fractions.js.map +1 -1
- package/lib/keys/geometry.js +35 -7
- package/lib/keys/geometry.js.map +1 -1
- package/lib/keys/grades.js +122 -37
- package/lib/keys/grades.js.map +1 -1
- package/lib/keys/index.js +7 -3
- package/lib/keys/index.js.map +1 -1
- package/lib/keys/log.js +2 -2
- package/lib/keys/log.js.map +1 -1
- package/lib/keys/logic.js +1 -1
- package/lib/keys/logic.js.map +1 -1
- package/lib/keys/matrices.js +1 -1
- package/lib/keys/matrices.js.map +1 -1
- package/lib/keys/misc.js +1 -1
- package/lib/keys/misc.js.map +1 -1
- package/lib/keys/navigation.js.map +1 -1
- package/lib/keys/operators.js.map +1 -1
- package/lib/keys/statistics.js +8 -1
- package/lib/keys/statistics.js.map +1 -1
- package/lib/keys/sub-sup.js +1 -1
- package/lib/keys/sub-sup.js.map +1 -1
- package/lib/keys/trigonometry.js +1 -1
- package/lib/keys/trigonometry.js.map +1 -1
- package/lib/keys/utils.js +11 -17
- package/lib/keys/utils.js.map +1 -1
- package/lib/keys/vars.js +1 -1
- package/lib/keys/vars.js.map +1 -1
- package/lib/math-input.js +39 -47
- package/lib/math-input.js.map +1 -1
- package/lib/mq/custom-elements.js.map +1 -1
- package/lib/mq/index.js +2 -2
- package/lib/mq/index.js.map +1 -1
- package/lib/mq/input.js +30 -40
- package/lib/mq/input.js.map +1 -1
- package/lib/mq/static.js +26 -34
- package/lib/mq/static.js.map +1 -1
- package/package.json +2 -2
- package/src/horizontal-keypad.jsx +4 -1
- package/src/keypad/index.jsx +91 -8
- package/src/keys/constants.js +16 -0
- package/src/keys/geometry.js +26 -2
- package/src/keys/grades.js +198 -84
- package/src/keys/log.js +1 -1
- package/src/keys/statistics.js +7 -0
package/lib/mq/input.js
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = exports.Input = void 0;
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
11
|
|
|
10
|
-
var
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
21
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
-
|
|
24
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
var _styles = require("@material-ui/core/styles");
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
var _customElements = require("./custom-elements");
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
|
|
39
37
|
|
|
40
|
-
function
|
|
38
|
+
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); }; }
|
|
41
39
|
|
|
42
|
-
function
|
|
40
|
+
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; } }
|
|
43
41
|
|
|
44
42
|
var MQ;
|
|
45
43
|
|
|
@@ -56,25 +54,22 @@ var log = (0, _debug["default"])('math-input:mq:input');
|
|
|
56
54
|
* Wrapper for MathQuill MQ.MathField.
|
|
57
55
|
*/
|
|
58
56
|
|
|
59
|
-
var Input =
|
|
60
|
-
|
|
61
|
-
function (_React$Component) {
|
|
62
|
-
_inherits(Input, _React$Component);
|
|
57
|
+
var Input = /*#__PURE__*/function (_React$Component) {
|
|
58
|
+
(0, _inherits2["default"])(Input, _React$Component);
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
var _getPrototypeOf2;
|
|
60
|
+
var _super = _createSuper(Input);
|
|
66
61
|
|
|
62
|
+
function Input() {
|
|
67
63
|
var _this;
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
(0, _classCallCheck2["default"])(this, Input);
|
|
70
66
|
|
|
71
67
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
72
68
|
args[_key] = arguments[_key];
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
_this =
|
|
76
|
-
|
|
77
|
-
_defineProperty(_assertThisInitialized(_this), "onInputEdit", function () {
|
|
71
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
72
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onInputEdit", function () {
|
|
78
73
|
log('[onInputEdit] ...');
|
|
79
74
|
var onChange = _this.props.onChange;
|
|
80
75
|
|
|
@@ -86,14 +81,12 @@ function (_React$Component) {
|
|
|
86
81
|
onChange(_this.mathField.latex());
|
|
87
82
|
}
|
|
88
83
|
});
|
|
89
|
-
|
|
90
|
-
_defineProperty(_assertThisInitialized(_this), "refresh", function () {
|
|
84
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "refresh", function () {
|
|
91
85
|
_this.blur();
|
|
92
86
|
|
|
93
87
|
_this.focus();
|
|
94
88
|
});
|
|
95
|
-
|
|
96
|
-
_defineProperty(_assertThisInitialized(_this), "onKeyPress", function (event) {
|
|
89
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onKeyPress", function (event) {
|
|
97
90
|
var keys = Object.keys(_this.mathField.__controller.options);
|
|
98
91
|
|
|
99
92
|
if (keys.indexOf('ignoreNextMousedown') < 0) {
|
|
@@ -112,11 +105,10 @@ function (_React$Component) {
|
|
|
112
105
|
_this.onInputEdit();
|
|
113
106
|
}
|
|
114
107
|
});
|
|
115
|
-
|
|
116
108
|
return _this;
|
|
117
109
|
}
|
|
118
110
|
|
|
119
|
-
|
|
111
|
+
(0, _createClass2["default"])(Input, [{
|
|
120
112
|
key: "componentDidMount",
|
|
121
113
|
value: function componentDidMount() {
|
|
122
114
|
if (!MQ) {
|
|
@@ -217,7 +209,7 @@ function (_React$Component) {
|
|
|
217
209
|
onBlur = _this$props.onBlur,
|
|
218
210
|
classes = _this$props.classes,
|
|
219
211
|
className = _this$props.className;
|
|
220
|
-
return _react["default"].createElement("span", {
|
|
212
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
221
213
|
className: (0, _classnames["default"])(classes.input, className),
|
|
222
214
|
onKeyPress: this.onKeyPress,
|
|
223
215
|
onClick: onClick,
|
|
@@ -229,13 +221,11 @@ function (_React$Component) {
|
|
|
229
221
|
});
|
|
230
222
|
}
|
|
231
223
|
}]);
|
|
232
|
-
|
|
233
224
|
return Input;
|
|
234
225
|
}(_react["default"].Component);
|
|
235
226
|
|
|
236
227
|
exports.Input = Input;
|
|
237
|
-
|
|
238
|
-
_defineProperty(Input, "propTypes", {
|
|
228
|
+
(0, _defineProperty2["default"])(Input, "propTypes", {
|
|
239
229
|
className: _propTypes["default"].string,
|
|
240
230
|
classes: _propTypes["default"].object.isRequired,
|
|
241
231
|
onClick: _propTypes["default"].func,
|
package/lib/mq/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"input.js","names":["MQ","window","MathQuill","getInterface","registerEmbed","registerLineBreak","log","debug","Input","onChange","props","mathField","latex","blur","focus","event","keys","Object","__controller","options","indexOf","refresh","charCode","write","onInputEdit","Error","MathField","input","handlers","edit","bind","updateLatex","v","Array","isArray","forEach","vv","cmd","keystroke","nextProps","onClick","onFocus","onBlur","classes","className","classNames","onKeyPress","r","React","Component","PropTypes","string","object","isRequired","func","styles","withStyles"],"sources":["../../src/mq/input.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport debug from 'debug';\nimport classNames from 'classnames';\nimport { registerLineBreak } from './custom-elements';\nimport MathQuill from '@pie-framework/mathquill';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n\n if (MQ && MQ.registerEmbed) {\n registerLineBreak(MQ);\n }\n}\n\nconst log = debug('math-input:mq:input');\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport class Input extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n classes: PropTypes.object.isRequired,\n onClick: PropTypes.func,\n onChange: PropTypes.func,\n latex: PropTypes.string,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func\n };\n\n componentDidMount() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n\n this.mathField = MQ.MathField(this.input, {\n handlers: {\n edit: this.onInputEdit.bind(this)\n }\n });\n\n this.updateLatex();\n }\n\n componentDidUpdate() {\n this.updateLatex();\n }\n\n updateLatex() {\n if (!this.mathField) {\n return;\n }\n const { latex } = this.props;\n if (latex) {\n this.mathField.latex(latex);\n }\n }\n\n clear() {\n this.mathField.latex('');\n return '';\n }\n\n blur() {\n log('blur mathfield');\n this.mathField.blur();\n }\n\n focus() {\n log('focus mathfield...');\n this.mathField.focus();\n }\n\n command(v) {\n log('command: ', v);\n if (Array.isArray(v)) {\n v.forEach(vv => {\n this.mathField.cmd(vv);\n });\n } else {\n this.mathField.cmd(v);\n }\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n keystroke(v) {\n this.mathField.keystroke(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n write(v) {\n log('write: ', v);\n this.mathField.write(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n onInputEdit = () => {\n log('[onInputEdit] ...');\n const { onChange } = this.props;\n if (!this.mathField) {\n return;\n }\n\n if (onChange) {\n onChange(this.mathField.latex());\n }\n };\n\n refresh = () => {\n this.blur();\n this.focus();\n };\n\n onKeyPress = event => {\n const keys = Object.keys(this.mathField.__controller.options);\n\n if (keys.indexOf('ignoreNextMousedown') < 0) {\n // It seems like the controller has the above handler as an option\n // when all the right events are set and everything works fine\n // this seems to work in all cases\n this.refresh();\n }\n\n if (event.charCode === 13) {\n // if enter's pressed, we're going for a custom embedded element that'll\n // have a block display (empty div) - for a hacked line break using ccs\n // all because mathquill doesn't support a line break\n this.write('\\\\embed{newLine}[]');\n this.onInputEdit();\n }\n };\n\n shouldComponentUpdate(nextProps) {\n log('next: ', nextProps.latex);\n log('current: ', this.mathField.latex());\n return nextProps.latex !== this.mathField.latex();\n }\n\n render() {\n const { onClick, onFocus, onBlur, classes, className } = this.props;\n\n return (\n <span\n className={classNames(classes.input, className)}\n onKeyPress={this.onKeyPress}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n ref={r => (this.input = r)}\n />\n );\n }\n}\n\nconst styles = () => ({});\n\nexport default withStyles(styles)(Input);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;EACjCD,EAAE,GAAGE,qBAAA,CAAUC,Y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A,EAAWD,MAAX,EAAmB/C,KAAnB,C"}
|
package/lib/mq/static.js
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = void 0;
|
|
7
9
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
11
|
|
|
14
|
-
var
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
13
|
|
|
16
|
-
var
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
var _index = require("../index");
|
|
35
33
|
|
|
36
|
-
function
|
|
34
|
+
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); }; }
|
|
37
35
|
|
|
38
|
-
function
|
|
36
|
+
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; } }
|
|
39
37
|
|
|
40
38
|
var MQ;
|
|
41
39
|
|
|
@@ -56,25 +54,22 @@ function stripSpaces() {
|
|
|
56
54
|
*/
|
|
57
55
|
|
|
58
56
|
|
|
59
|
-
var Static =
|
|
60
|
-
|
|
61
|
-
function (_React$Component) {
|
|
62
|
-
_inherits(Static, _React$Component);
|
|
57
|
+
var Static = /*#__PURE__*/function (_React$Component) {
|
|
58
|
+
(0, _inherits2["default"])(Static, _React$Component);
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
var _getPrototypeOf2;
|
|
60
|
+
var _super = _createSuper(Static);
|
|
66
61
|
|
|
62
|
+
function Static() {
|
|
67
63
|
var _this;
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
(0, _classCallCheck2["default"])(this, Static);
|
|
70
66
|
|
|
71
67
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
72
68
|
args[_key] = arguments[_key];
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
_this =
|
|
76
|
-
|
|
77
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
|
|
71
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
72
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function (e) {
|
|
78
73
|
try {
|
|
79
74
|
var rootBlock = e.target.parentElement.nextSibling;
|
|
80
75
|
var id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);
|
|
@@ -102,11 +97,10 @@ function (_React$Component) {
|
|
|
102
97
|
console.error('error finding root block', err.message);
|
|
103
98
|
}
|
|
104
99
|
});
|
|
105
|
-
|
|
106
100
|
return _this;
|
|
107
101
|
}
|
|
108
102
|
|
|
109
|
-
|
|
103
|
+
(0, _createClass2["default"])(Static, [{
|
|
110
104
|
key: "componentDidMount",
|
|
111
105
|
value: function componentDidMount() {
|
|
112
106
|
this.update();
|
|
@@ -193,7 +187,7 @@ function (_React$Component) {
|
|
|
193
187
|
var _this$props = this.props,
|
|
194
188
|
onBlur = _this$props.onBlur,
|
|
195
189
|
className = _this$props.className;
|
|
196
|
-
return _react["default"].createElement("span", {
|
|
190
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
197
191
|
className: className,
|
|
198
192
|
onFocus: this.onFocus,
|
|
199
193
|
onBlur: onBlur,
|
|
@@ -203,13 +197,11 @@ function (_React$Component) {
|
|
|
203
197
|
});
|
|
204
198
|
}
|
|
205
199
|
}]);
|
|
206
|
-
|
|
207
200
|
return Static;
|
|
208
201
|
}(_react["default"].Component);
|
|
209
202
|
|
|
210
203
|
exports["default"] = Static;
|
|
211
|
-
|
|
212
|
-
_defineProperty(Static, "propTypes", {
|
|
204
|
+
(0, _defineProperty2["default"])(Static, "propTypes", {
|
|
213
205
|
latex: _propTypes["default"].string.isRequired,
|
|
214
206
|
onFocus: _propTypes["default"].func,
|
|
215
207
|
onBlur: _propTypes["default"].func,
|
package/lib/mq/static.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"static.js","names":["MQ","window","MathQuill","getInterface","log","debug","REGEX","WHITESPACE_REGEX","stripSpaces","string","replace","Static","e","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","mathField","innerFields","find","f","name","props","getFieldName","setInput","onSubFieldFocus","err","console","error","message","update","updateSpans","field","onSubFieldChange","latex","Error","StaticMath","input","handlers","edit","onInputEdit","bind","parseLatex","blur","focus","nextProps","parsedLatex","stripped","newFieldCount","match","length","out","trim","Object","keys","warn","onBlur","className","onFocus","r","React","Component","PropTypes","isRequired","func"],"sources":["../../src/mq/static.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport MathQuill from '@pie-framework/mathquill';\nimport { updateSpans } from '../index';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n}\n\nconst log = debug('pie-lib:math-input:mq:static');\nconst REGEX = /\\\\MathQuillMathField\\[r\\d*\\]\\{(.*?)\\}/g;\nconst WHITESPACE_REGEX = / /g;\n\nfunction stripSpaces(string = '') {\n return string.replace(WHITESPACE_REGEX, '');\n}\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport default class Static extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n className: PropTypes.string,\n getFieldName: PropTypes.func,\n onSubFieldChange: PropTypes.func,\n onSubFieldFocus: PropTypes.func,\n setInput: PropTypes.func\n };\n\n componentDidMount() {\n this.update();\n updateSpans();\n }\n\n componentDidUpdate() {\n this.update();\n updateSpans();\n }\n\n onInputEdit(field) {\n if (!this.mathField) {\n return;\n }\n const name = this.props.getFieldName(field, this.mathField.innerFields);\n if (this.props.onSubFieldChange) {\n this.props.onSubFieldChange(name, field.latex());\n }\n }\n\n update() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n // this.input.innerHTML = this.props.latex;\n if (!this.mathField) {\n this.mathField = MQ.StaticMath(this.input, {\n handlers: {\n edit: this.onInputEdit.bind(this)\n }\n });\n }\n\n try {\n this.mathField.parseLatex(this.props.latex);\n this.mathField.latex(this.props.latex);\n } catch (e) {\n // default latex if received has errors\n this.mathField.latex('\\\\MathQuillMathField[r1]{}');\n }\n }\n\n blur() {\n log('blur mathfield');\n this.mathField.blur();\n }\n\n focus() {\n log('focus mathfield...');\n this.mathField.focus();\n }\n\n shouldComponentUpdate(nextProps) {\n try {\n const parsedLatex = this.mathField.parseLatex(nextProps.latex);\n const stripped = stripSpaces(parsedLatex);\n const newFieldCount = (nextProps.latex.match(REGEX) || []).length;\n\n const out =\n stripped !== stripSpaces(this.mathField.latex().trim()) ||\n newFieldCount !== Object.keys(this.mathField.innerFields).length / 2;\n\n log('[shouldComponentUpdate] ', out);\n return out;\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn('Error parsing latex:', e.message, 'skip update');\n // eslint-disable-next-line no-console\n console.warn(e);\n return false;\n }\n }\n\n onFocus = e => {\n try {\n let rootBlock = e.target.parentElement.nextSibling;\n let id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n\n if (!id) {\n rootBlock = rootBlock.parentElement;\n id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n }\n\n const innerField = this.mathField.innerFields.find(f => f.id === id);\n\n if (innerField) {\n const name = this.props.getFieldName(innerField, this.mathField.innerFields);\n if (this.props.setInput) {\n this.props.setInput(innerField);\n }\n this.props.onSubFieldFocus(name, innerField);\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('error finding root block', err.message);\n }\n };\n\n render() {\n const { onBlur, className } = this.props;\n\n return (\n <span\n className={className}\n onFocus={this.onFocus}\n onBlur={onBlur}\n ref={r => (this.input = r)}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;EACjCD,EAAE,GAAGE,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AAUzD,MAAV,CAAiB0D,UADP;EAEjBL,OAAO,EAAEI,qBAAA,CAAUE,IAFF;EAGjBR,MAAM,EAAEM,qBAAA,CAAUE,IAHD;EAIjBP,SAAS,EAAEK,qBAAA,CAAUzD,MAJJ;EAKjBkB,YAAY,EAAEuC,qBAAA,CAAUE,IALP;EAMjB/B,gBAAgB,EAAE6B,qBAAA,CAAUE,IANX;EAOjBvC,eAAe,EAAEqC,qBAAA,CAAUE,IAPV;EAQjBxC,QAAQ,EAAEsC,qBAAA,CAAUE;AARH,C"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "6.6.1-next.
|
|
6
|
+
"version": "6.6.1-next.437+7133506c",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"module": "src/index.jsx",
|
|
9
9
|
"dependencies": {
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"react-dom": "^16.9.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "7133506c26c247c6be91245284e61ccd14789d4f"
|
|
26
26
|
}
|
|
@@ -18,6 +18,7 @@ export default class HorizontalKeypad extends React.Component {
|
|
|
18
18
|
static propTypes = {
|
|
19
19
|
className: PropTypes.string,
|
|
20
20
|
mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
21
|
+
layoutForKeyPad: PropTypes.object,
|
|
21
22
|
onClick: PropTypes.func.isRequired,
|
|
22
23
|
onFocus: PropTypes.func,
|
|
23
24
|
noDecimal: PropTypes.bool,
|
|
@@ -37,7 +38,7 @@ export default class HorizontalKeypad extends React.Component {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
render() {
|
|
40
|
-
const { mode, onFocus, noDecimal, className, additionalKeys } = this.props;
|
|
41
|
+
const { mode, onFocus, noDecimal, className, additionalKeys, layoutForKeyPad } = this.props;
|
|
41
42
|
const normalizedKeys = normalizeAdditionalKeys(additionalKeys);
|
|
42
43
|
|
|
43
44
|
return (
|
|
@@ -45,8 +46,10 @@ export default class HorizontalKeypad extends React.Component {
|
|
|
45
46
|
className={className}
|
|
46
47
|
onFocus={onFocus}
|
|
47
48
|
noDecimal={noDecimal}
|
|
49
|
+
layoutForKeyPad={layoutForKeyPad}
|
|
48
50
|
additionalKeys={extendKeySet(keysForGrade(mode), normalizedKeys)}
|
|
49
51
|
onPress={this.keypadPress}
|
|
52
|
+
mode={mode}
|
|
50
53
|
/>
|
|
51
54
|
);
|
|
52
55
|
}
|
package/src/keypad/index.jsx
CHANGED
|
@@ -103,11 +103,29 @@ const LatexButton = withStyles(theme => ({
|
|
|
103
103
|
paddingTop: '1.5px !important'
|
|
104
104
|
},
|
|
105
105
|
'& .mq-parallelogram': {
|
|
106
|
-
lineHeight: 0.
|
|
106
|
+
lineHeight: 0.85
|
|
107
|
+
},
|
|
108
|
+
'& .mq-overarc': {
|
|
109
|
+
borderTop: '2px solid black !important',
|
|
110
|
+
'& .mq-overline-inner': {
|
|
111
|
+
borderTop: 'none !important',
|
|
112
|
+
paddingTop: '0 !important'
|
|
113
|
+
}
|
|
107
114
|
}
|
|
108
115
|
},
|
|
109
116
|
parallelButton: {
|
|
110
117
|
fontStyle: 'italic'
|
|
118
|
+
},
|
|
119
|
+
leftRightArrowButton: {
|
|
120
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
121
|
+
'& .mq-overline-inner': {
|
|
122
|
+
borderTop: 'none !important',
|
|
123
|
+
paddingTop: '0 !important'
|
|
124
|
+
},
|
|
125
|
+
'&:after': {
|
|
126
|
+
top: '-1.64em !important'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
111
129
|
}
|
|
112
130
|
}))(props => {
|
|
113
131
|
let buttonClass;
|
|
@@ -118,9 +136,29 @@ const LatexButton = withStyles(theme => ({
|
|
|
118
136
|
props.mqClassName,
|
|
119
137
|
props.classes.parallelButton
|
|
120
138
|
);
|
|
139
|
+
} else if (props.latex === '\\overleftrightarrow{\\overline{}}') {
|
|
140
|
+
buttonClass = classNames(
|
|
141
|
+
props.classes.latexButton,
|
|
142
|
+
props.mqClassName,
|
|
143
|
+
props.classes.leftRightArrowButton
|
|
144
|
+
);
|
|
121
145
|
} else {
|
|
122
146
|
buttonClass = classNames(props.classes.latexButton, props.mqClassName);
|
|
123
147
|
}
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const MQ = MathQuill.getInterface(2);
|
|
151
|
+
const span = document.createElement('span');
|
|
152
|
+
span.innerHTML = '';
|
|
153
|
+
const mathField = MQ.StaticMath(span);
|
|
154
|
+
|
|
155
|
+
mathField.parseLatex(props.latex);
|
|
156
|
+
mathField.latex(props.latex);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
// received latex has errors - do not create button
|
|
159
|
+
return <></>;
|
|
160
|
+
}
|
|
161
|
+
|
|
124
162
|
return (
|
|
125
163
|
<Button className={classNames(props.classes.root, props.className)} onClick={props.onClick}>
|
|
126
164
|
<mq.Static className={buttonClass} latex={props.latex} />
|
|
@@ -128,15 +166,29 @@ const LatexButton = withStyles(theme => ({
|
|
|
128
166
|
);
|
|
129
167
|
});
|
|
130
168
|
|
|
169
|
+
const createCustomLayout = layoutObj => {
|
|
170
|
+
if (layoutObj) {
|
|
171
|
+
return {
|
|
172
|
+
gridTemplateColumns: `repeat(${layoutObj.columns}, minmax(min-content, 150px))`,
|
|
173
|
+
gridTemplateRows: `repeat(${layoutObj.rows}, minmax(40px, 60px))`,
|
|
174
|
+
gridAutoFlow: 'initial'
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return {};
|
|
179
|
+
};
|
|
180
|
+
|
|
131
181
|
export class KeyPad extends React.Component {
|
|
132
182
|
static propTypes = {
|
|
133
183
|
classes: PropTypes.object.isRequired,
|
|
134
184
|
className: PropTypes.string,
|
|
135
185
|
baseSet: PropTypes.array,
|
|
136
186
|
additionalKeys: PropTypes.array,
|
|
187
|
+
layoutForKeyPad: PropTypes.object,
|
|
137
188
|
onPress: PropTypes.func.isRequired,
|
|
138
189
|
onFocus: PropTypes.func,
|
|
139
|
-
noDecimal: PropTypes.bool
|
|
190
|
+
noDecimal: PropTypes.bool,
|
|
191
|
+
mode: PropTypes.string
|
|
140
192
|
};
|
|
141
193
|
static defaultProps = {
|
|
142
194
|
baseSet: baseSet,
|
|
@@ -168,17 +220,42 @@ export class KeyPad extends React.Component {
|
|
|
168
220
|
};
|
|
169
221
|
|
|
170
222
|
render() {
|
|
171
|
-
const {
|
|
223
|
+
const {
|
|
224
|
+
classes,
|
|
225
|
+
className,
|
|
226
|
+
baseSet,
|
|
227
|
+
additionalKeys,
|
|
228
|
+
layoutForKeyPad,
|
|
229
|
+
onFocus,
|
|
230
|
+
mode
|
|
231
|
+
} = this.props;
|
|
172
232
|
|
|
173
|
-
const
|
|
233
|
+
const noBaseSet = [
|
|
234
|
+
'non-negative-integers',
|
|
235
|
+
'integers',
|
|
236
|
+
'decimals',
|
|
237
|
+
'fractions',
|
|
238
|
+
'item-authoring',
|
|
239
|
+
'language'
|
|
240
|
+
];
|
|
241
|
+
|
|
242
|
+
const keysWithoutBaseSet = noBaseSet.includes(mode);
|
|
243
|
+
const allKeys = keysWithoutBaseSet
|
|
244
|
+
? this.flowKeys([], additionalKeys || [])
|
|
245
|
+
: this.flowKeys(baseSet, additionalKeys || []); //, ...sortKeys(additionalKeys)];
|
|
174
246
|
|
|
175
247
|
const shift = allKeys.length % 5 ? 1 : 0;
|
|
176
248
|
const style = {
|
|
177
249
|
gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) +
|
|
178
|
-
shift}, minmax(min-content, 150px))
|
|
250
|
+
shift}, minmax(min-content, 150px))`,
|
|
251
|
+
...createCustomLayout(layoutForKeyPad)
|
|
179
252
|
};
|
|
180
253
|
return (
|
|
181
|
-
<div
|
|
254
|
+
<div
|
|
255
|
+
className={classNames(classes.keys, className, classes[mode])}
|
|
256
|
+
style={style}
|
|
257
|
+
onFocus={onFocus}
|
|
258
|
+
>
|
|
182
259
|
{allKeys.map((k, index) => {
|
|
183
260
|
const onClick = this.buttonClick.bind(this, k);
|
|
184
261
|
|
|
@@ -190,12 +267,15 @@ export class KeyPad extends React.Component {
|
|
|
190
267
|
onClick,
|
|
191
268
|
className: classNames(
|
|
192
269
|
classes.labelButton,
|
|
193
|
-
classes[k.category],
|
|
270
|
+
!keysWithoutBaseSet && classes[k.category],
|
|
271
|
+
classes[k.extraClass],
|
|
194
272
|
k.label === ',' && classes.comma,
|
|
195
273
|
k.label === '.' && classes.dot
|
|
196
274
|
),
|
|
197
275
|
disabled: this.keyIsNotAllowed(k),
|
|
198
|
-
key: `${k.label || k.latex || k.command}-${index}
|
|
276
|
+
key: `${k.label || k.latex || k.command}-${index}`,
|
|
277
|
+
...(k.actions || {}),
|
|
278
|
+
...(k.extraProps || {})
|
|
199
279
|
};
|
|
200
280
|
|
|
201
281
|
if (k.latex) {
|
|
@@ -231,6 +311,9 @@ const styles = theme => ({
|
|
|
231
311
|
gridColumnGap: '0px',
|
|
232
312
|
gridAutoFlow: 'column'
|
|
233
313
|
},
|
|
314
|
+
character: {
|
|
315
|
+
textTransform: 'initial !important'
|
|
316
|
+
},
|
|
234
317
|
holder: {
|
|
235
318
|
position: 'relative',
|
|
236
319
|
width: '100%',
|
package/src/keys/constants.js
CHANGED
|
@@ -17,3 +17,19 @@ export const eulers = set({
|
|
|
17
17
|
command: 'e',
|
|
18
18
|
category: 'constants'
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
export const infinity = set({
|
|
22
|
+
name: 'Infinity',
|
|
23
|
+
label: '\\infty',
|
|
24
|
+
latex: '\\infty',
|
|
25
|
+
command: '\\infty',
|
|
26
|
+
category: 'constants'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const halfInfinity = set({
|
|
30
|
+
name: 'Half Infinity',
|
|
31
|
+
label: '\\propto',
|
|
32
|
+
latex: '\\propto',
|
|
33
|
+
command: '\\propto',
|
|
34
|
+
category: 'constants'
|
|
35
|
+
});
|