@khanacademy/math-input 21.1.6 → 22.0.0
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/dist/es/index.js
CHANGED
|
@@ -16,17 +16,25 @@ import PropTypes from 'prop-types';
|
|
|
16
16
|
|
|
17
17
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
18
18
|
const libName = "@khanacademy/math-input";
|
|
19
|
-
const libVersion = "
|
|
19
|
+
const libVersion = "22.0.0";
|
|
20
20
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
21
21
|
|
|
22
22
|
function _extends() {
|
|
23
|
-
|
|
24
|
-
for (var
|
|
25
|
-
var
|
|
26
|
-
|
|
23
|
+
_extends = Object.assign || function (target) {
|
|
24
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
25
|
+
var source = arguments[i];
|
|
26
|
+
|
|
27
|
+
for (var key in source) {
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
29
|
+
target[key] = source[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return _extends.apply(this, arguments);
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
class View extends React.Component {
|
|
@@ -539,6 +547,7 @@ function createMathField(container, locale, strings, configCallback) {
|
|
|
539
547
|
// HTTP request to fetch non-english speech rules, and cannot be easily
|
|
540
548
|
// mocked in consuming packages now that we do not bundle source code.
|
|
541
549
|
// When it eventually times out, it will cause arbitrary test failures.
|
|
550
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
542
551
|
!inJest && SpeechRuleEngine.setup(locale).then(SRE => mathField.setMathspeakOverride(SRE.texToSpeech));
|
|
543
552
|
return mathField;
|
|
544
553
|
}
|
|
@@ -1761,6 +1770,7 @@ class MathInput extends React.Component {
|
|
|
1761
1770
|
* @param {number} y - the y coordinate in the viewport
|
|
1762
1771
|
*/
|
|
1763
1772
|
this._insertCursorAtClosestNode = (x, y) => {
|
|
1773
|
+
var _this$props$keypadEle3;
|
|
1764
1774
|
const cursor = this.mathField.getCursor();
|
|
1765
1775
|
|
|
1766
1776
|
// Pre-emptively check if the input has any child nodes; if not, the
|
|
@@ -1819,7 +1829,7 @@ class MathInput extends React.Component {
|
|
|
1819
1829
|
cursor.insAtLeftEnd(this.mathField.mathField.controller().root);
|
|
1820
1830
|
}
|
|
1821
1831
|
// In that event, we need to update the cursor context ourselves.
|
|
1822
|
-
this.props.keypadElement
|
|
1832
|
+
(_this$props$keypadEle3 = this.props.keypadElement) == null || _this$props$keypadEle3.setCursor({
|
|
1823
1833
|
context: this.mathField.contextForCursor()
|
|
1824
1834
|
});
|
|
1825
1835
|
};
|
|
@@ -2091,12 +2101,13 @@ class MathInput extends React.Component {
|
|
|
2091
2101
|
this._isMounted = true;
|
|
2092
2102
|
this.mathField = new MathWrapper(this._mathContainer, this.props.ariaLabel, this.context.strings, this.context.locale, {
|
|
2093
2103
|
onCursorMove: cursor => {
|
|
2104
|
+
var _this$props$keypadEle4;
|
|
2094
2105
|
// TODO(charlie): It's not great that there is so much coupling
|
|
2095
2106
|
// between this keypad and the input behavior. We should wrap
|
|
2096
2107
|
// this `MathInput` component in an intermediary component
|
|
2097
2108
|
// that translates accesses on the keypad into vanilla props,
|
|
2098
2109
|
// to make this input keypad-agnostic.
|
|
2099
|
-
this.props.keypadElement
|
|
2110
|
+
(_this$props$keypadEle4 = this.props.keypadElement) == null || _this$props$keypadEle4.setCursor(cursor);
|
|
2100
2111
|
}
|
|
2101
2112
|
});
|
|
2102
2113
|
this.mathField.setContent(this.props.value);
|
|
@@ -2188,8 +2199,9 @@ class MathInput extends React.Component {
|
|
|
2188
2199
|
// that the keypad may be anchored above the 'Check answer' bottom bar,
|
|
2189
2200
|
// in which case we don't want to dismiss the keypad on check.
|
|
2190
2201
|
if (!isWithinKeypadBounds(x, y)) {
|
|
2202
|
+
var _this$props$onBlur2, _this$props3;
|
|
2191
2203
|
this.blur();
|
|
2192
|
-
this.props.onBlur
|
|
2204
|
+
(_this$props$onBlur2 = (_this$props3 = this.props).onBlur) == null || _this$props$onBlur2.call(_this$props3);
|
|
2193
2205
|
}
|
|
2194
2206
|
}
|
|
2195
2207
|
}
|
|
@@ -2217,8 +2229,8 @@ class MathInput extends React.Component {
|
|
|
2217
2229
|
}
|
|
2218
2230
|
/** Returns the current bounds of the keypadElement */
|
|
2219
2231
|
_getKeypadBounds() {
|
|
2220
|
-
var _this$props$
|
|
2221
|
-
const keypadNode = (_this$props$
|
|
2232
|
+
var _this$props$keypadEle5;
|
|
2233
|
+
const keypadNode = (_this$props$keypadEle5 = this.props.keypadElement) == null ? void 0 : _this$props$keypadEle5.getDOMNode();
|
|
2222
2234
|
|
|
2223
2235
|
// If the keypad is mounted, return its bounds. Otherwise, return null.
|
|
2224
2236
|
if (keypadNode instanceof Element) {
|
|
@@ -2343,14 +2355,19 @@ const inlineStyles = {
|
|
|
2343
2355
|
}
|
|
2344
2356
|
};
|
|
2345
2357
|
|
|
2346
|
-
function _objectWithoutPropertiesLoose(
|
|
2347
|
-
if (
|
|
2348
|
-
var
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2358
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
2359
|
+
if (source == null) return {};
|
|
2360
|
+
var target = {};
|
|
2361
|
+
var sourceKeys = Object.keys(source);
|
|
2362
|
+
var key, i;
|
|
2363
|
+
|
|
2364
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
2365
|
+
key = sourceKeys[i];
|
|
2366
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
2367
|
+
target[key] = source[key];
|
|
2352
2368
|
}
|
|
2353
|
-
|
|
2369
|
+
|
|
2370
|
+
return target;
|
|
2354
2371
|
}
|
|
2355
2372
|
|
|
2356
2373
|
const IconAsset = function IconAsset({
|