@khanacademy/math-input 20.1.0 → 20.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.
@@ -1,4 +1,4 @@
1
1
  import { CursorContext } from "../input/cursor-contexts";
2
2
  import type { MathInputStrings } from "../../strings";
3
3
  export declare const expandedViewThreshold = 500;
4
- export declare function getCursorContextConfig(strings: MathInputStrings, cursorContext?: (typeof CursorContext)[keyof typeof CursorContext]): import("../../types").NonManyKeyConfig | null;
4
+ export declare function getCursorContextConfig(strings: MathInputStrings, cursorContext?: (typeof CursorContext)[keyof typeof CursorContext]): import("../../types").KeyConfig | null;
@@ -5,7 +5,6 @@ import type Key from "./keys";
5
5
  import type { MathInputStrings } from "../strings";
6
6
  import type { KeyConfig } from "../types";
7
7
  declare const KeyConfigs: (strings: MathInputStrings) => {
8
- MANY: KeyConfig;
9
8
  x: KeyConfig;
10
9
  y: KeyConfig;
11
10
  a: KeyConfig;
@@ -62,7 +61,6 @@ declare const KeyConfigs: (strings: MathInputStrings) => {
62
61
  JUMP_INTO_NUMERATOR: KeyConfig;
63
62
  JUMP_OUT_NUMERATOR: KeyConfig;
64
63
  JUMP_OUT_DENOMINATOR: KeyConfig;
65
- NOOP: KeyConfig;
66
64
  NUM_0: KeyConfig;
67
65
  NUM_1: KeyConfig;
68
66
  NUM_2: KeyConfig;
@@ -115,9 +113,5 @@ declare const KeyConfigs: (strings: MathInputStrings) => {
115
113
  X: KeyConfig;
116
114
  Y: KeyConfig;
117
115
  Z: KeyConfig;
118
- PHI: KeyConfig;
119
- NTHROOT3: KeyConfig;
120
- POW: KeyConfig;
121
- LOG_B: KeyConfig;
122
116
  };
123
117
  export default KeyConfigs;
@@ -1,3 +1,3 @@
1
- export declare const KeyArray: readonly ["PLUS", "MINUS", "NEGATIVE", "TIMES", "DIVIDE", "DECIMAL", "PERIOD", "PERCENT", "CDOT", "EQUAL", "NEQ", "GT", "LT", "GEQ", "LEQ", "FRAC_INCLUSIVE", "FRAC_EXCLUSIVE", "FRAC", "EXP", "EXP_2", "EXP_3", "SQRT", "CUBE_ROOT", "RADICAL", "LEFT_PAREN", "RIGHT_PAREN", "LN", "LOG", "LOG_N", "SIN", "COS", "TAN", "PI", "THETA", "UP", "RIGHT", "DOWN", "LEFT", "BACKSPACE", "DISMISS", "JUMP_OUT_PARENTHESES", "JUMP_OUT_EXPONENT", "JUMP_OUT_BASE", "JUMP_INTO_NUMERATOR", "JUMP_OUT_NUMERATOR", "JUMP_OUT_DENOMINATOR", "NOOP", "MANY", "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "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", "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", "PHI", "NTHROOT3", "POW", "LOG_B"];
1
+ export declare const KeyArray: readonly ["PLUS", "MINUS", "NEGATIVE", "TIMES", "DIVIDE", "DECIMAL", "PERIOD", "PERCENT", "CDOT", "EQUAL", "NEQ", "GT", "LT", "GEQ", "LEQ", "FRAC_INCLUSIVE", "FRAC_EXCLUSIVE", "FRAC", "EXP", "EXP_2", "EXP_3", "SQRT", "CUBE_ROOT", "RADICAL", "LEFT_PAREN", "RIGHT_PAREN", "LN", "LOG", "LOG_N", "SIN", "COS", "TAN", "PI", "THETA", "UP", "RIGHT", "DOWN", "LEFT", "BACKSPACE", "DISMISS", "JUMP_OUT_PARENTHESES", "JUMP_OUT_EXPONENT", "JUMP_OUT_BASE", "JUMP_INTO_NUMERATOR", "JUMP_OUT_NUMERATOR", "JUMP_OUT_DENOMINATOR", "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "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", "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"];
2
2
  type Key = (typeof KeyArray)[number];
3
3
  export default Key;
package/dist/es/index.js CHANGED
@@ -15,7 +15,7 @@ import PropTypes from 'prop-types';
15
15
 
16
16
  // This file is processed by a Rollup plugin (replace) to inject the production
17
17
  const libName = "@khanacademy/math-input";
18
- const libVersion = "20.1.0";
18
+ const libVersion = "20.1.1";
19
19
  addLibraryVersionToPerseusDebug(libName, libVersion);
20
20
 
21
21
  function _extends() {
@@ -1276,7 +1276,6 @@ const getKeyTranslator = locale => ({
1276
1276
  LEFT_PAREN: buildGenericCallback("(", ActionType.CMD),
1277
1277
  RIGHT_PAREN: buildGenericCallback(")", ActionType.CMD),
1278
1278
  SQRT: buildGenericCallback("sqrt", ActionType.CMD),
1279
- PHI: buildGenericCallback("\\phi", ActionType.CMD),
1280
1279
  PI: buildGenericCallback("pi", ActionType.CMD),
1281
1280
  THETA: buildGenericCallback("theta", ActionType.CMD),
1282
1281
  RADICAL: buildGenericCallback("nthroot", ActionType.CMD),
@@ -1298,13 +1297,6 @@ const getKeyTranslator = locale => ({
1298
1297
  mathQuill.keystroke("Left");
1299
1298
  }
1300
1299
  },
1301
- LOG_B: mathQuill => {
1302
- mathQuill.typedText("log_");
1303
- mathQuill.keystroke("Right");
1304
- mathQuill.typedText("(");
1305
- mathQuill.keystroke("Left");
1306
- mathQuill.keystroke("Left");
1307
- },
1308
1300
  LOG_N: mathQuill => {
1309
1301
  mathQuill.write("log_{ }\\left(\\right)");
1310
1302
  mathQuill.keystroke("Left"); // into parentheses
@@ -1312,26 +1304,9 @@ const getKeyTranslator = locale => ({
1312
1304
  mathQuill.keystroke("Left"); // into index
1313
1305
  },
1314
1306
 
1315
- NTHROOT3: mathQuill => {
1316
- mathQuill.typedText("nthroot3");
1317
- mathQuill.keystroke("Right");
1318
- },
1319
- POW: mathQuill => {
1320
- const contents = mathQuill.latex();
1321
- mathQuill.typedText("^");
1322
-
1323
- // If the input hasn't changed (for example, if we're
1324
- // attempting to add an exponent on an empty input or an empty
1325
- // denominator), insert our own "a^b"
1326
- if (mathQuill.latex() === contents) {
1327
- mathQuill.typedText("a^b");
1328
- }
1329
- },
1330
1307
  // These need to be overwritten by the consumer
1331
1308
  // if they're going to be used
1332
1309
  DISMISS: () => {},
1333
- NOOP: () => {},
1334
- MANY: () => {},
1335
1310
  NUM_0: buildGenericCallback("0"),
1336
1311
  NUM_1: buildGenericCallback("1"),
1337
1312
  NUM_2: buildGenericCallback("2"),
@@ -2912,10 +2887,6 @@ const KeyConfigs = strings => ({
2912
2887
  data: "\\theta",
2913
2888
  ariaLabel: strings.theta
2914
2889
  })),
2915
- NOOP: _extends({}, getDefaultOperatorFields({
2916
- key: "NOOP",
2917
- keyType: "EMPTY"
2918
- })),
2919
2890
  // Input navigation
2920
2891
  UP: _extends({}, getDefaultOperatorFields({
2921
2892
  key: "UP",
@@ -2978,11 +2949,6 @@ const KeyConfigs = strings => ({
2978
2949
  keyType: "KEYPAD_NAVIGATION",
2979
2950
  ariaLabel: strings.dismiss
2980
2951
  })),
2981
- // TODO(charlie): Use the numeral color for the 'Many' key.
2982
- MANY: _extends({}, getDefaultOperatorFields({
2983
- key: "MANY",
2984
- keyType: "MANY"
2985
- })),
2986
2952
  // NUMBERS
2987
2953
  NUM_0: _extends({}, getDefaultNumberFields({
2988
2954
  key: "NUM_0"
@@ -3170,18 +3136,6 @@ const KeyConfigs = strings => ({
3170
3136
  })),
3171
3137
  z: _extends({}, getDefaultValueFields({
3172
3138
  key: "z"
3173
- })),
3174
- PHI: _extends({}, getDefaultValueFields({
3175
- key: "PHI"
3176
- })),
3177
- NTHROOT3: _extends({}, getDefaultValueFields({
3178
- key: "NTHROOT3"
3179
- })),
3180
- POW: _extends({}, getDefaultValueFields({
3181
- key: "POW"
3182
- })),
3183
- LOG_B: _extends({}, getDefaultValueFields({
3184
- key: "LOG_B"
3185
3139
  }))
3186
3140
  });
3187
3141
 
@@ -4594,33 +4548,6 @@ function ButtonAsset({
4594
4548
  strokeLinejoin: "round",
4595
4549
  d: "M22 18l-6 6 6 6M16 24h16"
4596
4550
  })));
4597
-
4598
- /**
4599
- * ANYTHING BELOW IS NOT YET HANDLED
4600
- */
4601
- case "MANY":
4602
- case "NOOP":
4603
- case "PHI":
4604
- case "NTHROOT3":
4605
- case "POW":
4606
- case "LOG_B":
4607
- // placeholder
4608
- return /*#__PURE__*/React.createElement("svg", {
4609
- width: "40",
4610
- height: "40",
4611
- viewBox: "0 0 40 40",
4612
- fill: "black",
4613
- xmlns: "http://www.w3.org/2000/svg"
4614
- }, /*#__PURE__*/React.createElement("text", {
4615
- y: "20",
4616
- textLength: "100%",
4617
- lengthAdjust: "spacingAndGlyphs"
4618
- }, id), /*#__PURE__*/React.createElement("text", {
4619
- y: "35",
4620
- textLength: "100%",
4621
- lengthAdjust: "spacingAndGlyphs",
4622
- fill: "red"
4623
- }, "placeholder"));
4624
4551
  default:
4625
4552
  // this line forces an exhaustive check of all keys;
4626
4553
  // if a key is not handled, the compiler will complain.
@@ -5881,14 +5808,7 @@ const KeyArray = ["PLUS", "MINUS", "NEGATIVE", "TIMES", "DIVIDE", "DECIMAL", "PE
5881
5808
  // TODO(charlie): Add in additional Greek letters.,
5882
5809
  "TAN", "PI", "THETA", "UP", "RIGHT", "DOWN", "LEFT", "BACKSPACE", "DISMISS", "JUMP_OUT_PARENTHESES", "JUMP_OUT_EXPONENT", "JUMP_OUT_BASE", "JUMP_INTO_NUMERATOR", "JUMP_OUT_NUMERATOR", "JUMP_OUT_DENOMINATOR",
5883
5810
  // Multi-functional keys.
5884
- "NOOP",
5885
- // mobile native only
5886
- "MANY",
5887
- // A custom key that captures an arbitrary number of symbols but has no 'default' symbol or action.
5888
- "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "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", "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",
5889
- // Currently only used by
5890
- // Perseus' Expression MathInput
5891
- "PHI", "NTHROOT3", "POW", "LOG_B"];
5811
+ "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "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", "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"];
5892
5812
 
5893
5813
  /**
5894
5814
  * Constants that are shared between multiple files.