@khanacademy/math-input 17.0.6 → 17.0.8
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/components/input/mathquill-helpers.d.ts +1 -1
- package/dist/components/keypad/keypad-pages/fractions-page.d.ts +1 -1
- package/dist/components/keypad/keypad.d.ts +1 -1
- package/dist/components/keypad/shared-keys.d.ts +1 -1
- package/dist/components/keypad/utils.d.ts +1 -1
- package/dist/data/keys.d.ts +1 -1
- package/dist/enums.d.ts +1 -1
- package/dist/es/index.js +52 -38
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +51 -38
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +4 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var wonderStuffCore = require('@khanacademy/wonder-stuff-core');
|
|
|
9
9
|
var aphrodite = require('aphrodite');
|
|
10
10
|
var React = require('react');
|
|
11
11
|
var ReactDOM = require('react-dom');
|
|
12
|
+
var mathjaxRenderer = require('@khanacademy/mathjax-renderer');
|
|
12
13
|
var MathQuill = require('mathquill');
|
|
13
14
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
14
15
|
var Clickable = require('@khanacademy/wonder-blocks-clickable');
|
|
@@ -46,7 +47,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
46
47
|
|
|
47
48
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
48
49
|
const libName = "@khanacademy/math-input";
|
|
49
|
-
const libVersion = "17.0.
|
|
50
|
+
const libVersion = "17.0.8";
|
|
50
51
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
51
52
|
|
|
52
53
|
function _extends() {
|
|
@@ -369,6 +370,49 @@ let CursorContext = /*#__PURE__*/function (CursorContext) {
|
|
|
369
370
|
return CursorContext;
|
|
370
371
|
}({});
|
|
371
372
|
|
|
373
|
+
const DecimalSeparator = {
|
|
374
|
+
COMMA: ",",
|
|
375
|
+
PERIOD: "."
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// NOTES(kevinb):
|
|
379
|
+
// - In order to get the correct decimal separator for the current locale,
|
|
380
|
+
// the locale must bet set using `setLocale(kaLocale)` which can be
|
|
381
|
+
// imported from wonder-blocks-i18n.
|
|
382
|
+
// - Some languages/locales use different decimal separators than the ones
|
|
383
|
+
// listed here. Much of the Arab world uses U+066C.
|
|
384
|
+
const decimalSeparator = i18n.getDecimalSeparator() === "," ? DecimalSeparator.COMMA : DecimalSeparator.PERIOD;
|
|
385
|
+
const CDOT_ONLY = ["az", "cs", "da", "de", "hu", "hy", "kk", "ky", "lt", "lv", "nb", "sk", "sr", "sv", "uz"];
|
|
386
|
+
const TIMES_ONLY = ["fr", "tr", "pt-pt"];
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* convertDotToTimes (aka `times`) is an option the content creators have to
|
|
390
|
+
* use × (TIMES) rather than · (CDOT) for multiplication (for younger learners).
|
|
391
|
+
* Some locales _only_ use one or the other for all multiplication regardless
|
|
392
|
+
* of age.
|
|
393
|
+
*
|
|
394
|
+
* convertDotToTimesByLocale overrides convertDotToTimes for those locales.
|
|
395
|
+
*
|
|
396
|
+
* @param {boolean} convertDotToTimes - the setting set by content creators
|
|
397
|
+
* @returns {boolean} - true to convert to × (TIMES), false to use · (CDOT)
|
|
398
|
+
*/
|
|
399
|
+
function convertDotToTimesByLocale(convertDotToTimes) {
|
|
400
|
+
const locale = i18n.getLocale();
|
|
401
|
+
if (CDOT_ONLY.includes(locale)) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
if (TIMES_ONLY.includes(locale)) {
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
return convertDotToTimes;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Use this to avoid running code that should not run in Jest.
|
|
412
|
+
**/
|
|
413
|
+
const inJest = typeof process !== "undefined" && !!process?.env?.JEST_WORKER_ID;
|
|
414
|
+
// Explicitly checking for undefined because Cypress throws an error
|
|
415
|
+
|
|
372
416
|
// We only need one MathQuill instance (referred to as MQ in the docs)
|
|
373
417
|
// and that contains some MQ constants and the MathField constructor
|
|
374
418
|
const mathQuillInstance = MathQuill__default["default"].getInterface(3);
|
|
@@ -420,6 +464,12 @@ function createMathField(container, configCallback) {
|
|
|
420
464
|
const mathField = mathQuillInstance.MathField(container, config)
|
|
421
465
|
// translated in ./math-input.tsx
|
|
422
466
|
.setAriaLabel(i18n__namespace._("Math input box"));
|
|
467
|
+
|
|
468
|
+
// We should avoid running SpeechRuleEngine.setup() in Jest. It makes an
|
|
469
|
+
// HTTP request to fetch non-english speech rules, and cannot be easily
|
|
470
|
+
// mocked in consuming packages now that we do not bundle source code.
|
|
471
|
+
// When it eventually times out, it will cause arbitrary test failures.
|
|
472
|
+
!inJest && mathjaxRenderer.SpeechRuleEngine.setup().then(SRE => mathField.setMathspeakOverride(SRE.texToSpeech));
|
|
423
473
|
return mathField;
|
|
424
474
|
}
|
|
425
475
|
|
|
@@ -858,43 +908,6 @@ function handleBackspace(mathField) {
|
|
|
858
908
|
}
|
|
859
909
|
}
|
|
860
910
|
|
|
861
|
-
const DecimalSeparator = {
|
|
862
|
-
COMMA: ",",
|
|
863
|
-
PERIOD: "."
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
// NOTES(kevinb):
|
|
867
|
-
// - In order to get the correct decimal separator for the current locale,
|
|
868
|
-
// the locale must bet set using `setLocale(kaLocale)` which can be
|
|
869
|
-
// imported from wonder-blocks-i18n.
|
|
870
|
-
// - Some languages/locales use different decimal separators than the ones
|
|
871
|
-
// listed here. Much of the Arab world uses U+066C.
|
|
872
|
-
const decimalSeparator = i18n.getDecimalSeparator() === "," ? DecimalSeparator.COMMA : DecimalSeparator.PERIOD;
|
|
873
|
-
const CDOT_ONLY = ["az", "cs", "da", "de", "hu", "hy", "kk", "ky", "lt", "lv", "nb", "sk", "sr", "sv", "uz"];
|
|
874
|
-
const TIMES_ONLY = ["fr", "tr", "pt-pt"];
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* convertDotToTimes (aka `times`) is an option the content creators have to
|
|
878
|
-
* use × (TIMES) rather than · (CDOT) for multiplication (for younger learners).
|
|
879
|
-
* Some locales _only_ use one or the other for all multiplication regardless
|
|
880
|
-
* of age.
|
|
881
|
-
*
|
|
882
|
-
* convertDotToTimesByLocale overrides convertDotToTimes for those locales.
|
|
883
|
-
*
|
|
884
|
-
* @param {boolean} convertDotToTimes - the setting set by content creators
|
|
885
|
-
* @returns {boolean} - true to convert to × (TIMES), false to use · (CDOT)
|
|
886
|
-
*/
|
|
887
|
-
function convertDotToTimesByLocale(convertDotToTimes) {
|
|
888
|
-
const locale = i18n.getLocale();
|
|
889
|
-
if (CDOT_ONLY.includes(locale)) {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
if (TIMES_ONLY.includes(locale)) {
|
|
893
|
-
return true;
|
|
894
|
-
}
|
|
895
|
-
return convertDotToTimes;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
911
|
function handleLeftArrow(mathField, cursor) {
|
|
899
912
|
// If we're inside a function, and just after the left parentheses, we
|
|
900
913
|
// need to skip the entire function name, rather than move the cursor
|