@pie-lib/math-input 6.6.1-next.45 → 6.6.1-next.506

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.
Files changed (69) hide show
  1. package/CHANGELOG.json +60 -0
  2. package/CHANGELOG.md +140 -0
  3. package/lib/horizontal-keypad.js +33 -38
  4. package/lib/horizontal-keypad.js.map +1 -1
  5. package/lib/index.js +12 -7
  6. package/lib/index.js.map +1 -1
  7. package/lib/keypad/index.js +119 -71
  8. package/lib/keypad/index.js.map +1 -1
  9. package/lib/keypad/keys-layout.js +5 -1
  10. package/lib/keypad/keys-layout.js.map +1 -1
  11. package/lib/keys/basic-operators.js +1 -1
  12. package/lib/keys/basic-operators.js.map +1 -1
  13. package/lib/keys/chars.js +1 -1
  14. package/lib/keys/chars.js.map +1 -1
  15. package/lib/keys/comparison.js +7 -5
  16. package/lib/keys/comparison.js.map +1 -1
  17. package/lib/keys/constants.js +17 -1
  18. package/lib/keys/constants.js.map +1 -1
  19. package/lib/keys/digits.js +2 -2
  20. package/lib/keys/digits.js.map +1 -1
  21. package/lib/keys/edit.js.map +1 -1
  22. package/lib/keys/exponent.js +1 -1
  23. package/lib/keys/exponent.js.map +1 -1
  24. package/lib/keys/fractions.js +1 -1
  25. package/lib/keys/fractions.js.map +1 -1
  26. package/lib/keys/geometry.js +35 -7
  27. package/lib/keys/geometry.js.map +1 -1
  28. package/lib/keys/grades.js +122 -37
  29. package/lib/keys/grades.js.map +1 -1
  30. package/lib/keys/index.js +7 -3
  31. package/lib/keys/index.js.map +1 -1
  32. package/lib/keys/log.js +2 -2
  33. package/lib/keys/log.js.map +1 -1
  34. package/lib/keys/logic.js +1 -1
  35. package/lib/keys/logic.js.map +1 -1
  36. package/lib/keys/matrices.js +1 -1
  37. package/lib/keys/matrices.js.map +1 -1
  38. package/lib/keys/misc.js +1 -1
  39. package/lib/keys/misc.js.map +1 -1
  40. package/lib/keys/navigation.js.map +1 -1
  41. package/lib/keys/operators.js.map +1 -1
  42. package/lib/keys/statistics.js +8 -1
  43. package/lib/keys/statistics.js.map +1 -1
  44. package/lib/keys/sub-sup.js +1 -1
  45. package/lib/keys/sub-sup.js.map +1 -1
  46. package/lib/keys/trigonometry.js +1 -1
  47. package/lib/keys/trigonometry.js.map +1 -1
  48. package/lib/keys/utils.js +11 -17
  49. package/lib/keys/utils.js.map +1 -1
  50. package/lib/keys/vars.js +1 -1
  51. package/lib/keys/vars.js.map +1 -1
  52. package/lib/math-input.js +39 -47
  53. package/lib/math-input.js.map +1 -1
  54. package/lib/mq/custom-elements.js.map +1 -1
  55. package/lib/mq/index.js +2 -2
  56. package/lib/mq/index.js.map +1 -1
  57. package/lib/mq/input.js +67 -40
  58. package/lib/mq/input.js.map +1 -1
  59. package/lib/mq/static.js +26 -34
  60. package/lib/mq/static.js.map +1 -1
  61. package/package.json +3 -3
  62. package/src/horizontal-keypad.jsx +4 -1
  63. package/src/keypad/index.jsx +97 -11
  64. package/src/keys/constants.js +16 -0
  65. package/src/keys/geometry.js +26 -2
  66. package/src/keys/grades.js +198 -84
  67. package/src/keys/log.js +1 -1
  68. package/src/keys/statistics.js +7 -0
  69. package/src/mq/input.jsx +35 -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 _react = _interopRequireDefault(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _styles = require("@material-ui/core/styles");
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
11
 
14
- var _debug = _interopRequireDefault(require("debug"));
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
13
 
16
- var _classnames = _interopRequireDefault(require("classnames"));
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
15
 
18
- var _customElements = require("./custom-elements");
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
17
 
20
- var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
19
 
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
21
 
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
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
+ var _react = _interopRequireDefault(require("react"));
27
25
 
28
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
26
+ var _propTypes = _interopRequireDefault(require("prop-types"));
29
27
 
30
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
28
+ var _styles = require("@material-ui/core/styles");
31
29
 
32
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
30
+ var _debug = _interopRequireDefault(require("debug"));
33
31
 
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
32
+ var _classnames = _interopRequireDefault(require("classnames"));
35
33
 
36
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
34
+ var _customElements = require("./custom-elements");
37
35
 
38
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
36
+ var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
39
37
 
40
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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
- /*#__PURE__*/
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
- function Input() {
65
- var _getPrototypeOf2;
60
+ var _super = _createSuper(Input);
66
61
 
62
+ function Input() {
67
63
  var _this;
68
64
 
69
- _classCallCheck(this, Input);
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 = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Input)).call.apply(_getPrototypeOf2, [this].concat(args)));
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) {
@@ -111,12 +104,48 @@ function (_React$Component) {
111
104
 
112
105
  _this.onInputEdit();
113
106
  }
114
- });
115
107
 
108
+ if (event.charCode === 47) {
109
+ // Whenever the math editor cursor is positioned after an integer
110
+ // (i.e. a sequence of 1 or more digits) followed immediately by a space followed immediately by another integer,
111
+ // then a side effect of pressing the forward slash key or clicking the B fraction button should be to remove
112
+ // the space between the first integer and the second integer (which is now the numerator of a new fraction).
113
+ // E.g. if the user were trying to enter the mixed number one and two-thirds, and typed [1], [space], [2], [forward slash],
114
+ // producing the latex 1\ \frac{2}{|} (where | is not actually part of the representation, but rather
115
+ // represents the position of the cursor), this should be automatically transformed to 1\frac{2}{|}
116
+ // (with | again representing the position of the cursor).
117
+ // Similarly, if the user had typed [1], [2], [space], [3], [4], [forward slash], then the resulting representation should
118
+ // be transformed from 12\ \frac{34}{|} to 12\frac{34}{|}.
119
+ var latex = _this.mathField.latex();
120
+
121
+ if (latex.match(/([1-9])\\ /)) {
122
+ event.preventDefault();
123
+ event.stopPropagation();
124
+
125
+ _this.clear();
126
+
127
+ var indexOfSpace = latex.lastIndexOf('\\ '); // split the latex by the last space added
128
+
129
+ var firstPart = latex.slice(0, indexOfSpace);
130
+ var secondPart = latex.slice(indexOfSpace + 2); // reconstruct the latex without the extra space
131
+
132
+ var newLatex = firstPart + '\\frac{' + secondPart + '}{}';
133
+
134
+ _this.mathField.latex(newLatex); // trigger pressing keydown to move focus on the denominator
135
+
136
+
137
+ _this.mathField.el().dispatchEvent(new KeyboardEvent('keydown', {
138
+ keyCode: 37
139
+ }));
140
+
141
+ _this.onInputEdit();
142
+ }
143
+ }
144
+ });
116
145
  return _this;
117
146
  }
118
147
 
119
- _createClass(Input, [{
148
+ (0, _createClass2["default"])(Input, [{
120
149
  key: "componentDidMount",
121
150
  value: function componentDidMount() {
122
151
  if (!MQ) {
@@ -217,7 +246,7 @@ function (_React$Component) {
217
246
  onBlur = _this$props.onBlur,
218
247
  classes = _this$props.classes,
219
248
  className = _this$props.className;
220
- return _react["default"].createElement("span", {
249
+ return /*#__PURE__*/_react["default"].createElement("span", {
221
250
  className: (0, _classnames["default"])(classes.input, className),
222
251
  onKeyPress: this.onKeyPress,
223
252
  onClick: onClick,
@@ -229,13 +258,11 @@ function (_React$Component) {
229
258
  });
230
259
  }
231
260
  }]);
232
-
233
261
  return Input;
234
262
  }(_react["default"].Component);
235
263
 
236
264
  exports.Input = Input;
237
-
238
- _defineProperty(Input, "propTypes", {
265
+ (0, _defineProperty2["default"])(Input, "propTypes", {
239
266
  className: _propTypes["default"].string,
240
267
  classes: _propTypes["default"].object.isRequired,
241
268
  onClick: _propTypes["default"].func,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mq/input.jsx"],"names":["MQ","window","MathQuill","getInterface","registerEmbed","log","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","onKeyPress","r","React","Component","PropTypes","string","object","isRequired","func","styles"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,sBAAUC,YAAV,CAAuB,CAAvB,CAAL;;AAEA,MAAIH,EAAE,IAAIA,EAAE,CAACI,aAAb,EAA4B;AAC1B,2CAAkBJ,EAAlB;AACD;AACF;;AAED,IAAMK,GAAG,GAAG,uBAAM,qBAAN,CAAZ;AAEA;;;;IAGaC,K;;;;;;;;;;;;;;;;;;kEAgFG,YAAM;AAClBD,MAAAA,GAAG,CAAC,mBAAD,CAAH;AADkB,UAEVE,QAFU,GAEG,MAAKC,KAFR,CAEVD,QAFU;;AAGlB,UAAI,CAAC,MAAKE,SAAV,EAAqB;AACnB;AACD;;AAED,UAAIF,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAAC,MAAKE,SAAL,CAAeC,KAAf,EAAD,CAAR;AACD;AACF,K;;8DAES,YAAM;AACd,YAAKC,IAAL;;AACA,YAAKC,KAAL;AACD,K;;iEAEY,UAAAC,KAAK,EAAI;AACpB,UAAMC,IA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;AAGE,QAAA,OAAO,EAAEL,OAHX;AAIE,QAAA,OAAO,EAAEC,OAJX;AAKE,QAAA,MAAM,EAAEC,MALV;AAME,QAAA,GAAG,EAAE,aAAAI,CAAC;AAAA,iBAAK,MAAI,CAACnB,KAAL,GAAamB,CAAlB;AAAA;AANR,QADF;AAUD;;;;EAvIwBC,kBAAMC,S;;;;gBAApBxC,K,eACQ;AACjBoC,EAAAA,SAAS,EAAEK,sBAAUC,MADJ;AAEjBP,EAAAA,OAAO,EAAEM,sBAAUE,MAAV,CAAiBC,UAFT;AAGjBZ,EAAAA,OAAO,EAAES,sBAAUI,IAHF;AAIjB5C,EAAAA,QAAQ,EAAEwC,sBAAUI,IAJH;AAKjBzC,EAAAA,KAAK,EAAEqC,sBAAUC,MALA;AAMjBT,EAAAA,OAAO,EAAEQ,sBAAUI,IANF;AAOjBX,EAAAA,MAAM,EAAEO,sBAAUI;AAPD,C;;AAyIrB,IAAMC,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO,EAAP;AAAA,CAAf;;eAEe,wBAAWA,MAAX,EAAmB9C,KAAnB,C","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"],"file":"input.js"}
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","match","preventDefault","stopPropagation","clear","indexOfSpace","lastIndexOf","firstPart","slice","secondPart","newLatex","el","dispatchEvent","KeyboardEvent","keyCode","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 if (event.charCode === 47) {\n // Whenever the math editor cursor is positioned after an integer\n // (i.e. a sequence of 1 or more digits) followed immediately by a space followed immediately by another integer,\n // then a side effect of pressing the forward slash key or clicking the B fraction button should be to remove\n // the space between the first integer and the second integer (which is now the numerator of a new fraction).\n // E.g. if the user were trying to enter the mixed number one and two-thirds, and typed [1], [space], [2], [forward slash],\n // producing the latex 1\\ \\frac{2}{|} (where | is not actually part of the representation, but rather\n // represents the position of the cursor), this should be automatically transformed to 1\\frac{2}{|}\n // (with | again representing the position of the cursor).\n // Similarly, if the user had typed [1], [2], [space], [3], [4], [forward slash], then the resulting representation should\n // be transformed from 12\\ \\frac{34}{|} to 12\\frac{34}{|}.\n const latex = this.mathField.latex();\n\n if (latex.match(/([1-9])\\\\ /)) {\n event.preventDefault();\n event.stopPropagation();\n\n this.clear();\n\n const indexOfSpace = latex.lastIndexOf('\\\\ ');\n // split the latex by the last space added\n const firstPart = latex.slice(0, indexOfSpace);\n const secondPart = latex.slice(indexOfSpace + 2);\n\n // reconstruct the latex without the extra space\n const newLatex = firstPart + '\\\\frac{' + secondPart + '}{}';\n\n this.mathField.latex(newLatex);\n // trigger pressing keydown to move focus on the denominator\n this.mathField.el().dispatchEvent(new KeyboardEvent('keydown', { keyCode: 37 }));\n\n this.onInputEdit();\n }\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,YAAV,CAAuB,CAAvB,CAAL;;EAEA,IAAIH,EAAE,IAAIA,EAAE,CAACI,aAAb,EAA4B;IAC1B,IAAAC,iCAAA,EAAkBL,EAAlB;EACD;AACF;;AAED,IAAMM,GAAG,GAAG,IAAAC,iBAAA,EAAM,qBAAN,CAAZ;AAEA;AACA;AACA;;IACaC,K;;;;;;;;;;;;;;;oGAgFG,YAAM;MAClBF,GAAG,CAAC,mBAAD,CAAH;MACA,IAAQG,QAAR,GAAqB,MAAKC,KAA1B,CAAQD,QAAR;;MACA,IAAI,CAAC,MAAKE,SAAV,EAA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,CAAlB;QAAA;MANR,EADF;IAUD;;;EA1KwBC,iBAAA,CAAMC,S;;;iCAApBvD,K,eACQ;EACjBkD,SAAS,EAAEM,qBAAA,CAAUC,MADJ;EAEjBR,OAAO,EAAEO,qBAAA,CAAUE,MAAV,CAAiBC,UAFT;EAGjBb,OAAO,EAAEU,qBAAA,CAAUI,IAHF;EAIjB3D,QAAQ,EAAEuD,qBAAA,CAAUI,IAJH;EAKjBxD,KAAK,EAAEoD,qBAAA,CAAUC,MALA;EAMjBV,OAAO,EAAES,qBAAA,CAAUI,IANF;EAOjBZ,MAAM,EAAEQ,qBAAA,CAAUI;AAPD,C;;AA4KrB,IAAMC,MAAM,GAAG,SAATA,MAAS;EAAA,OAAO,EAAP;AAAA,CAAf;;eAEe,IAAAC,kBAAA,EAAWD,MAAX,EAAmB7D,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 _propTypes = _interopRequireDefault(require("prop-types"));
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 _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
13
 
16
- var _index = require("../index");
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
15
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
17
 
20
- 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); }
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
19
 
22
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
21
 
24
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
23
 
26
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
24
+ var _propTypes = _interopRequireDefault(require("prop-types"));
27
25
 
28
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
26
+ var _react = _interopRequireDefault(require("react"));
29
27
 
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
+ var _debug = _interopRequireDefault(require("debug"));
31
29
 
32
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
+ var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
33
31
 
34
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
32
+ var _index = require("../index");
35
33
 
36
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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
- /*#__PURE__*/
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
- function Static() {
65
- var _getPrototypeOf2;
60
+ var _super = _createSuper(Static);
66
61
 
62
+ function Static() {
67
63
  var _this;
68
64
 
69
- _classCallCheck(this, Static);
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 = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Static)).call.apply(_getPrototypeOf2, [this].concat(args)));
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
- _createClass(Static, [{
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,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mq/static.jsx"],"names":["MQ","window","MathQuill","getInterface","log","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","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"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,sBAAUC,YAAV,CAAuB,CAAvB,CAAL;AACD;;AAED,IAAMC,GAAG,GAAG,uBAAM,8BAAN,CAAZ;AACA,IAAMC,KAAK,GAAG,wCAAd;AACA,IAAMC,gBAAgB,GAAG,IAAzB;;AAEA,SAASC,WAAT,GAAkC;AAAA,MAAbC,MAAa,uEAAJ,EAAI;AAChC,SAAOA,MAAM,CAACC,OAAP,CAAeH,gBAAf,EAAiC,EAAjC,CAAP;AACD;AAED;;;;;IAGqBI,M;;;;;;;;;;;;;;;;;;8DAqFT,UAAAC,CAAC,EAAI;AACb,UAAI;AACF,YAAIC,SAAS,GAAGD,CAAC,CAACE,MAAF,CAASC,aAAT,CAAuBC,WAAvC;AACA,YAAIC,EAAE,GAAGC,QAAQ,CAACL,SAAS,CAACM,YAAV,CAAuB,oBAAvB,CAAD,EAA+C,EAA/C,CAAjB;;AAEA,YAAI,CAACF,EAAL,EAAS;AACPJ,UAAAA,SAAS,GAAGA,SAAS,CAACE,aAAtB;AACAE,UAAAA,EAAE,GAAGC,QAAQ,CAACL,SAAS,CAACM,YAAV,CAAuB,oBAAvB,CAAD,EAA+C,EAA/C,CAAb;AACD;;AAED,YAAMC,UAAU,GAAG,MAAKC,SAAL,CAAeC,WAAf,CAA2BC,IAA3B,CAAgC,UAAAC,CAAC;AAAA,iBAAIA,CAAC,CAACP,EAAF,KAASA,EAAb;AAAA,SAAjC,CAAnB;;AAEA,YAAIG,UAAJ,EAAgB;AACd,cAAMK,IAAI,GAAG,MAAKC,KAAL,CAAWC,YAAX,CAAwBP,UAAxB,EAAoC,MAAKC,SAAL,CAAeC,WAAnD,CAAb;;AACA,c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EF,MAHV;AAIE,QAAA,GAAG,EAAE,aAAAG,CAAC;AAAA,iBAAK,MAAI,CAACtB,KAAL,GAAasB,CAAlB;AAAA;AAJR,QADF;AAQD;;;;EAzHiCC,kBAAMC,S;;;;gBAArBrD,M,eACA;AACjB0B,EAAAA,KAAK,EAAE4B,sBAAUxD,MAAV,CAAiByD,UADP;AAEjBL,EAAAA,OAAO,EAAEI,sBAAUE,IAFF;AAGjBR,EAAAA,MAAM,EAAEM,sBAAUE,IAHD;AAIjBP,EAAAA,SAAS,EAAEK,sBAAUxD,MAJJ;AAKjBkB,EAAAA,YAAY,EAAEsC,sBAAUE,IALP;AAMjB/B,EAAAA,gBAAgB,EAAE6B,sBAAUE,IANX;AAOjBtC,EAAAA,eAAe,EAAEoC,sBAAUE,IAPV;AAQjBvC,EAAAA,QAAQ,EAAEqC,sBAAUE;AARH,C","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"],"file":"static.js"}
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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,iBAAA,CAAMC,S;;;iCAArBtD,M,eACA;EACjB2B,KAAK,EAAE4B,qBAAA,CAAUzD,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,13 +3,13 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "6.6.1-next.45+b91f0971",
6
+ "version": "6.6.1-next.506+e8b87499",
7
7
  "main": "lib/index.js",
8
8
  "module": "src/index.jsx",
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.8.3",
11
11
  "@material-ui/icons": "^3.0.2",
12
- "@pie-framework/mathquill": "^1.1.2",
12
+ "@pie-framework/mathquill": "^1.1.3",
13
13
  "debug": "^4.1.1",
14
14
  "lodash": "^4.17.11",
15
15
  "react-portal": "^4.2.0"
@@ -22,5 +22,5 @@
22
22
  "react-dom": "^16.9.0"
23
23
  },
24
24
  "scripts": {},
25
- "gitHead": "b91f09710e5de270f9c60981da49f7fbf70c9417"
25
+ "gitHead": "e8b8749942eb41c8b866c8ad2066bc95934aab05"
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
  }