@khanacademy/math-input 0.6.3 → 0.6.6

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Khan Academy's new expression editor for the mobile web.",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "0.6.3",
6
+ "version": "0.6.6",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -22,9 +22,9 @@
22
22
  "performance-now": "^0.2.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@khanacademy/wonder-blocks-clickable": "^2.2.6",
25
+ "@khanacademy/wonder-blocks-clickable": "^2.4.4",
26
26
  "@khanacademy/wonder-blocks-color": "^1.1.20",
27
- "@khanacademy/wonder-blocks-core": "^4.3.0",
27
+ "@khanacademy/wonder-blocks-core": "^4.6.2",
28
28
  "@khanacademy/wonder-blocks-i18n": "^1.2.3",
29
29
  "aphrodite": "^1.1.0",
30
30
  "jquery": "^2.1.1",
@@ -41,9 +41,9 @@
41
41
  "redux": "^4.0.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "@khanacademy/wonder-blocks-clickable": "^2.2.6",
44
+ "@khanacademy/wonder-blocks-clickable": "^2.4.4",
45
45
  "@khanacademy/wonder-blocks-color": "^1.1.20",
46
- "@khanacademy/wonder-blocks-core": "^4.3.0",
46
+ "@khanacademy/wonder-blocks-core": "^4.6.2",
47
47
  "@khanacademy/wonder-blocks-i18n": "^1.2.3",
48
48
  "aphrodite": "^1.1.0",
49
49
  "jquery": "^2.1.1",
@@ -59,4 +59,4 @@
59
59
  "redux": "^4.0.0"
60
60
  },
61
61
  "keywords": []
62
- }
62
+ }
@@ -11,6 +11,27 @@
11
11
  * the radical.
12
12
  */
13
13
 
14
+ export type CursorContext =
15
+ // The cursor is not in any of the other viable contexts.
16
+ | "NONE"
17
+ // The cursor is within a set of parentheses.
18
+ | "IN_PARENS"
19
+ // The cursor is within a superscript (e.g., an exponent).
20
+ | "IN_SUPER_SCRIPT"
21
+ // The cursor is within a subscript (e.g., the base of a custom logarithm).
22
+ | "IN_SUB_SCRIPT"
23
+ // The cursor is in the numerator of a fraction.
24
+ | "IN_NUMERATOR"
25
+ // The cursor is in the denominator of a fraction.
26
+ | "IN_DENOMINATOR"
27
+ // The cursor is sitting before a fraction; that is, the cursor is within
28
+ // what looks to be a mixed number preceding a fraction. This will only be
29
+ // the case when the only math between the cursor and the fraction to its
30
+ // write is non-leaf math (numbers and variables).
31
+ | "BEFORE_FRACTION";
32
+
33
+ // TODO: Get rid of these constants in favour of CursorContext type.
34
+
14
35
  // The cursor is not in any of the other viable contexts.
15
36
  export const NONE = "NONE";
16
37
  // The cursor is within a set of parentheses.
@@ -575,7 +575,7 @@ class MathWrapper {
575
575
  const commandStartRegex = /^\\[a-z]$/;
576
576
  const commandEndSeq = "\\left(";
577
577
 
578
- // Note: We whitelist the set of valid commands, since relying solely on
578
+ // Note: We allowlist the set of valid commands, since relying solely on
579
579
  // a command being prefixed with a backslash leads to undesired
580
580
  // behavior. For example, Greek symbols, left parentheses, and square
581
581
  // roots all get treated as commands.
package/src/consts.js CHANGED
@@ -3,11 +3,33 @@
3
3
  * Constants that are shared between multiple files.
4
4
  */
5
5
 
6
+ export type KeypadType = "FRACTION" | "EXPRESSION";
7
+
8
+ // TODO: Retire this in favour of KeypadType (above)
6
9
  export const KeypadTypes = {
7
10
  FRACTION: "FRACTION",
8
11
  EXPRESSION: "EXPRESSION",
9
12
  };
10
13
 
14
+ export type KeyType =
15
+ | "EMPTY"
16
+ // For numerals, variables, and any other characters that themselves
17
+ // compose 'values'.
18
+ | "VALUE"
19
+ // For buttons that insert or adjust math in an input.
20
+ | "OPERATOR"
21
+ // For buttons that move the cursor in an input (including via
22
+ // deletion).
23
+ | "INPUT_NAVIGATION"
24
+ // For buttons that modify the broader keypad state (e.g., by changing
25
+ // the visible pane).
26
+ | "KEYPAD_NAVIGATION"
27
+ // For buttons that house multiple buttons and have no action
28
+ // themselves.
29
+ | "MANY"
30
+ // For the echo animation that appears on press.
31
+ | "ECHO";
32
+
11
33
  export const KeyTypes = {
12
34
  EMPTY: "EMPTY",
13
35
  // For numerals, variables, and any other characters that themselves
@@ -14,6 +14,7 @@ export type KeyConfig = {
14
14
  type: string,
15
15
  ariaLabel: string,
16
16
  };
17
+
17
18
  const KeyConfigs: Object = {
18
19
  // Basic math keys.
19
20
  [Keys.PLUS]: {
package/src/data/keys.js CHANGED
@@ -4,6 +4,64 @@
4
4
  * alphanumeric characters.
5
5
  */
6
6
 
7
+ export type Key =
8
+ | "PLUS"
9
+ | "MINUS"
10
+ | "NEGATIVE"
11
+ | "TIMES"
12
+ | "DIVIDE"
13
+ | "DECIMAL"
14
+ | "PERIOD"
15
+ | "PERCENT"
16
+ | "CDOT"
17
+ | "EQUAL"
18
+ | "NEQ"
19
+ | "GT"
20
+ | "LT"
21
+ | "GEQ"
22
+ | "LEQ"
23
+ | "FRAC_INCLUSIVE" // mobile native only
24
+ | "FRAC_EXCLUSIVE" // mobile native only
25
+ | "FRAC"
26
+ | "EXP"
27
+ | "EXP_2"
28
+ | "EXP_3"
29
+ | "SQRT"
30
+ | "CUBE_ROOT"
31
+ | "RADICAL"
32
+ | "LEFT_PAREN"
33
+ | "RIGHT_PAREN"
34
+ | "LN"
35
+ | "LOG"
36
+ | "LOG_N"
37
+ | "SIN"
38
+ | "COS"
39
+ | "TAN"
40
+
41
+ // TODO(charlie): Add in additional Greek letters.
42
+ | "PI"
43
+ | "THETA"
44
+ | "UP"
45
+ | "RIGHT"
46
+ | "DOWN"
47
+ | "LEFT"
48
+ | "BACKSPACE"
49
+ | "DISMISS"
50
+ | "JUMP_OUT_PARENTHESES"
51
+ | "JUMP_OUT_EXPONENT"
52
+ | "JUMP_OUT_BASE"
53
+ | "JUMP_INTO_NUMERATOR"
54
+ | "JUMP_OUT_NUMERATOR"
55
+ | "JUMP_OUT_DENOMINATOR"
56
+ | "NOOP"
57
+
58
+ // Multi-functional keys.
59
+ | "FRAC_MULTI" // mobile native only
60
+
61
+ // A custom key that captures an arbitrary number of symbols but has no
62
+ // 'default' symbol or action.
63
+ | "MANY";
64
+
7
65
  // TODO(charlie): There's duplication between this file and key-configs.js.
8
66
  // We should clean it up by removing this file and requiring clients to use the
9
67
  // `id` field on the key configurations.
package/src/demo.js CHANGED
@@ -5,4 +5,5 @@ import App from "./components/app.js";
5
5
 
6
6
  import "../less/main.less";
7
7
 
8
+ // eslint-disable-next-line no-restricted-syntax
8
9
  ReactDOM.render(<App />, document.getElementById("root"));
package/src/index.js CHANGED
@@ -17,3 +17,7 @@ export {default as KeyConfigs} from "./data/key-configs.js";
17
17
  import * as CursorContexts from "./components/input/cursor-contexts.js";
18
18
 
19
19
  export {CursorContexts};
20
+
21
+ export type {KeypadType, KeyType} from "./consts.js";
22
+ export type {Key} from "./data/keys.js";
23
+ export type {CursorContext} from "./components/input/cursor-contexts.js";
package/src/native-app.js CHANGED
@@ -81,4 +81,5 @@ class App extends React.Component {
81
81
  }
82
82
  }
83
83
 
84
+ // eslint-disable-next-line no-restricted-syntax
84
85
  ReactDOM.render(<App />, document.getElementById("root"));