@khanacademy/math-input 21.1.0 → 21.1.1
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/aphrodite-css-transition-group/util.d.ts +0 -3
- package/dist/components/input/mathquill-helpers.d.ts +0 -5
- package/dist/components/input/mathquill-types.d.ts +0 -7
- package/dist/components/input/scroll-into-view.d.ts +0 -1
- package/dist/components/tabbar/item.d.ts +1 -2
- package/dist/enums.d.ts +2 -1
- package/dist/es/index.js +25 -66
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/index.d.ts +0 -1
- package/dist/index.js +25 -66
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
- package/dist/fake-react-native-web/text.d.ts +0 -14
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
45
45
|
|
|
46
46
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
47
47
|
const libName = "@khanacademy/math-input";
|
|
48
|
-
const libVersion = "21.1.
|
|
48
|
+
const libVersion = "21.1.1";
|
|
49
49
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
50
50
|
|
|
51
51
|
function _extends() {
|
|
@@ -63,25 +63,6 @@ function _extends() {
|
|
|
63
63
|
return _extends.apply(this, arguments);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// https://github.com/necolas/react-native-web/blob/master/src/components/Text/index.js
|
|
67
|
-
aphrodite.StyleSheet.create({
|
|
68
|
-
initial: {
|
|
69
|
-
color: "inherit",
|
|
70
|
-
display: "inline",
|
|
71
|
-
font: "inherit",
|
|
72
|
-
margin: 0,
|
|
73
|
-
padding: 0,
|
|
74
|
-
textDecorationLine: "none",
|
|
75
|
-
wordWrap: "break-word"
|
|
76
|
-
},
|
|
77
|
-
singleLineStyle: {
|
|
78
|
-
maxWidth: "100%",
|
|
79
|
-
overflow: "hidden",
|
|
80
|
-
textOverflow: "ellipsis",
|
|
81
|
-
whiteSpace: "nowrap"
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
66
|
class View extends React__namespace.Component {
|
|
86
67
|
static styles = aphrodite.StyleSheet.create({
|
|
87
68
|
// From: https://github.com/necolas/react-native-web/blob/master/src/components/View/index.js
|
|
@@ -438,6 +419,14 @@ class DragListener {
|
|
|
438
419
|
}
|
|
439
420
|
}
|
|
440
421
|
|
|
422
|
+
let MathFieldActionType = /*#__PURE__*/function (MathFieldActionType) {
|
|
423
|
+
MathFieldActionType["WRITE"] = "write";
|
|
424
|
+
MathFieldActionType["CMD"] = "cmd";
|
|
425
|
+
MathFieldActionType["KEYSTROKE"] = "keystroke";
|
|
426
|
+
MathFieldActionType[MathFieldActionType["MQ_END"] = 0] = "MQ_END";
|
|
427
|
+
return MathFieldActionType;
|
|
428
|
+
}({});
|
|
429
|
+
|
|
441
430
|
/**
|
|
442
431
|
* Enum that defines the various contexts in which a cursor can exist. The
|
|
443
432
|
* active context is determined first by looking at the cursor's siblings (e.g.,
|
|
@@ -609,29 +598,6 @@ function createMathField(container, locale, strings, configCallback) {
|
|
|
609
598
|
return mathField;
|
|
610
599
|
}
|
|
611
600
|
|
|
612
|
-
/**
|
|
613
|
-
* Editable math fields have all of the above methods in addition to
|
|
614
|
-
* the ones listed here.
|
|
615
|
-
* https://docs.mathquill.com/en/latest/Api_Methods/
|
|
616
|
-
*/
|
|
617
|
-
|
|
618
|
-
let MathFieldActionType = /*#__PURE__*/function (MathFieldActionType) {
|
|
619
|
-
MathFieldActionType["WRITE"] = "write";
|
|
620
|
-
MathFieldActionType["CMD"] = "cmd";
|
|
621
|
-
MathFieldActionType["KEYSTROKE"] = "keystroke";
|
|
622
|
-
MathFieldActionType[MathFieldActionType["MQ_END"] = 0] = "MQ_END";
|
|
623
|
-
return MathFieldActionType;
|
|
624
|
-
}({});
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* The MathQuill API (see mathuill.d.ts) does not include types
|
|
628
|
-
* for cursor() and controller(), and adding these types there
|
|
629
|
-
* in the MathQuill repo causes unexpected conflicts with other types.
|
|
630
|
-
*
|
|
631
|
-
* We don't want to use the cursor and controller default type `any`
|
|
632
|
-
* so we declare the types here.
|
|
633
|
-
*/
|
|
634
|
-
|
|
635
601
|
const Numerals = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
636
602
|
const GreekLetters = ["\\theta", "\\pi"];
|
|
637
603
|
const Letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
|
|
@@ -1214,28 +1180,21 @@ function handleJumpOut(mathField, key) {
|
|
|
1214
1180
|
}
|
|
1215
1181
|
}
|
|
1216
1182
|
|
|
1217
|
-
var ActionType = /*#__PURE__*/function (ActionType) {
|
|
1218
|
-
ActionType["WRITE"] = "write";
|
|
1219
|
-
ActionType["CMD"] = "cmd";
|
|
1220
|
-
ActionType["KEYSTROKE"] = "keystroke";
|
|
1221
|
-
ActionType[ActionType["MQ_END"] = 0] = "MQ_END";
|
|
1222
|
-
return ActionType;
|
|
1223
|
-
}(ActionType || {});
|
|
1224
1183
|
function buildGenericCallback(str) {
|
|
1225
|
-
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
1184
|
+
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MathFieldActionType.WRITE;
|
|
1226
1185
|
return function (mathQuill) {
|
|
1227
1186
|
switch (type) {
|
|
1228
|
-
case
|
|
1187
|
+
case MathFieldActionType.WRITE:
|
|
1229
1188
|
{
|
|
1230
1189
|
mathQuill.write(str);
|
|
1231
1190
|
return;
|
|
1232
1191
|
}
|
|
1233
|
-
case
|
|
1192
|
+
case MathFieldActionType.CMD:
|
|
1234
1193
|
{
|
|
1235
1194
|
mathQuill.cmd(str);
|
|
1236
1195
|
return;
|
|
1237
1196
|
}
|
|
1238
|
-
case
|
|
1197
|
+
case MathFieldActionType.KEYSTROKE:
|
|
1239
1198
|
{
|
|
1240
1199
|
mathQuill.keystroke(str);
|
|
1241
1200
|
return;
|
|
@@ -1301,17 +1260,17 @@ const getKeyTranslator = (locale, strings) => ({
|
|
|
1301
1260
|
TIMES: buildGenericCallback("\\times"),
|
|
1302
1261
|
// The `FRAC_EXCLUSIVE` variant is handled manually, since we may need to do
|
|
1303
1262
|
// some additional navigation depending on the cursor position.
|
|
1304
|
-
FRAC_INCLUSIVE: buildGenericCallback("/",
|
|
1305
|
-
FRAC: buildGenericCallback("\\frac",
|
|
1306
|
-
LEFT_PAREN: buildGenericCallback("(",
|
|
1307
|
-
RIGHT_PAREN: buildGenericCallback(")",
|
|
1308
|
-
SQRT: buildGenericCallback("sqrt",
|
|
1309
|
-
PI: buildGenericCallback("pi",
|
|
1310
|
-
THETA: buildGenericCallback("theta",
|
|
1311
|
-
RADICAL: buildGenericCallback("nthroot",
|
|
1312
|
-
BACKSPACE: buildGenericCallback("Backspace",
|
|
1313
|
-
UP: buildGenericCallback("Up",
|
|
1314
|
-
DOWN: buildGenericCallback("Down",
|
|
1263
|
+
FRAC_INCLUSIVE: buildGenericCallback("/", MathFieldActionType.CMD),
|
|
1264
|
+
FRAC: buildGenericCallback("\\frac", MathFieldActionType.CMD),
|
|
1265
|
+
LEFT_PAREN: buildGenericCallback("(", MathFieldActionType.CMD),
|
|
1266
|
+
RIGHT_PAREN: buildGenericCallback(")", MathFieldActionType.CMD),
|
|
1267
|
+
SQRT: buildGenericCallback("sqrt", MathFieldActionType.CMD),
|
|
1268
|
+
PI: buildGenericCallback("pi", MathFieldActionType.CMD),
|
|
1269
|
+
THETA: buildGenericCallback("theta", MathFieldActionType.CMD),
|
|
1270
|
+
RADICAL: buildGenericCallback("nthroot", MathFieldActionType.CMD),
|
|
1271
|
+
BACKSPACE: buildGenericCallback("Backspace", MathFieldActionType.KEYSTROKE),
|
|
1272
|
+
UP: buildGenericCallback("Up", MathFieldActionType.KEYSTROKE),
|
|
1273
|
+
DOWN: buildGenericCallback("Down", MathFieldActionType.KEYSTROKE),
|
|
1315
1274
|
CUBE_ROOT: mathQuill => {
|
|
1316
1275
|
mathQuill.write("\\sqrt[3]{}");
|
|
1317
1276
|
mathQuill.keystroke("Left"); // under the root
|
|
@@ -1321,7 +1280,7 @@ const getKeyTranslator = (locale, strings) => ({
|
|
|
1321
1280
|
const cursor = mathQuill.cursor();
|
|
1322
1281
|
// If there's nothing to the left of the cursor, then we want to
|
|
1323
1282
|
// leave the cursor to the left of the fraction after creating it.
|
|
1324
|
-
const shouldNavigateLeft = cursor[mathQuillInstance.L] ===
|
|
1283
|
+
const shouldNavigateLeft = cursor[mathQuillInstance.L] === MathFieldActionType.MQ_END;
|
|
1325
1284
|
mathQuill.cmd("\\frac");
|
|
1326
1285
|
if (shouldNavigateLeft) {
|
|
1327
1286
|
mathQuill.keystroke("Left");
|