@khanacademy/math-input 4.1.1 → 4.2.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/CHANGELOG.md +11 -0
- package/dist/components/input/math-wrapper.d.ts +1 -1
- package/dist/components/input/math-wrapper.js.flow +1 -1
- package/dist/components/input/mathquill-instance.d.ts +14 -3
- package/dist/components/input/mathquill-instance.js.flow +18 -3
- package/dist/components/input/mathquill-types.d.ts +28 -6
- package/dist/components/input/mathquill-types.js.flow +31 -7
- package/dist/components/key-handlers/handle-arrow.d.ts +3 -0
- package/dist/components/{input/key-handlers → key-handlers}/handle-arrow.js.flow +2 -2
- package/dist/components/{input/key-handlers → key-handlers}/handle-backspace.d.ts +1 -1
- package/dist/components/{input/key-handlers → key-handlers}/handle-backspace.js.flow +1 -1
- package/dist/components/key-handlers/handle-exponent.d.ts +3 -0
- package/dist/components/{input/key-handlers → key-handlers}/handle-exponent.js.flow +2 -2
- package/dist/components/{input/key-handlers → key-handlers}/handle-jump-out.d.ts +2 -2
- package/dist/components/{input/key-handlers → key-handlers}/handle-jump-out.js.flow +2 -2
- package/dist/components/key-handlers/key-translator.d.ts +4 -0
- package/dist/components/{key-translator.js.flow → key-handlers/key-translator.js.flow} +3 -3
- package/dist/es/index.js +395 -366
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +398 -367
- package/dist/index.js.flow +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/math-input.tsx +10 -14
- package/src/components/input/math-wrapper.ts +23 -49
- package/src/components/input/mathquill-helpers.ts +11 -11
- package/src/components/input/mathquill-instance.ts +57 -2
- package/src/components/input/mathquill-types.ts +37 -7
- package/src/components/{input/key-handlers → key-handlers}/handle-arrow.ts +6 -6
- package/src/components/{input/key-handlers → key-handlers}/handle-backspace.ts +19 -17
- package/src/components/{input/key-handlers → key-handlers}/handle-exponent.ts +8 -5
- package/src/components/{input/key-handlers → key-handlers}/handle-jump-out.ts +15 -10
- package/src/components/{key-translator.ts → key-handlers/key-translator.ts} +43 -28
- package/src/components/keypad/__tests__/{KeypadButton.test.tsx → keypad-button.test.tsx} +3 -3
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +231 -0
- package/src/components/keypad/__tests__/keypad-v2.cypress.ts +19 -6
- package/src/components/keypad/keypad-mathquill.stories.tsx +15 -23
- package/src/components/keypad/keypad-page-items.tsx +1 -1
- package/src/index.ts +6 -1
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/input/key-handlers/handle-arrow.d.ts +0 -3
- package/dist/components/input/key-handlers/handle-exponent.d.ts +0 -3
- package/dist/components/key-translator.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @khanacademy/math-input
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d497118e: MathInput exports tools for generating MathFields, replacing the need for direct MathQuill access
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- e7d21b67: Add keypress logic from MathInput to key translator
|
|
12
|
+
- eceb4510: Updated aria-labels to be more descriptive and tests that used aria-labels.
|
|
13
|
+
|
|
3
14
|
## 4.1.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -9,7 +9,7 @@ import { MathFieldInterface, MathFieldCursor } from "./mathquill-types";
|
|
|
9
9
|
declare class MathWrapper {
|
|
10
10
|
mathField: MathFieldInterface;
|
|
11
11
|
callbacks: any;
|
|
12
|
-
constructor(element: any,
|
|
12
|
+
constructor(element: any, callbacks?: {});
|
|
13
13
|
focus(): void;
|
|
14
14
|
blur(): void;
|
|
15
15
|
/**
|
|
@@ -17,7 +17,7 @@ import { MathFieldInterface, MathFieldCursor } from "./mathquill-types";
|
|
|
17
17
|
declare class MathWrapper {
|
|
18
18
|
mathField: MathFieldInterface;
|
|
19
19
|
callbacks: any;
|
|
20
|
-
constructor(element: any,
|
|
20
|
+
constructor(element: any, callbacks?: {||}): this;
|
|
21
21
|
focus(): void;
|
|
22
22
|
blur(): void;
|
|
23
23
|
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { MathQuillInterface } from "./mathquill-types";
|
|
2
|
-
declare const
|
|
3
|
-
|
|
1
|
+
import { MathQuillInterface, MathFieldConfig } from "./mathquill-types";
|
|
2
|
+
export declare const mathQuillInstance: MathQuillInterface;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new [MathField](http://docs.mathquill.com/en/latest/Api_Methods/#mqmathfieldhtml_element-config)
|
|
5
|
+
* instance within the given `container`.
|
|
6
|
+
*
|
|
7
|
+
* An optional configuration callback can be provided to customize
|
|
8
|
+
* the created MathField. A default configuration is passed to this
|
|
9
|
+
* callback which can then be adjusted as needed. The configuration
|
|
10
|
+
* returned from this callback is used to create the MathField.
|
|
11
|
+
* This allows callers to do minimal configuration as only configs
|
|
12
|
+
* that vary from the default need to be provided.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createMathField(container: HTMLDivElement | HTMLSpanElement, configCallback?: (baseConfig: MathFieldConfig) => MathFieldConfig): import("./mathquill-types").MathFieldInterface;
|
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
declare export
|
|
7
|
+
import * as $Flowgen$Import$_2e__2f_mathquill_2d_types from "./mathquill-types";
|
|
8
|
+
import { MathQuillInterface, MathFieldConfig } from "./mathquill-types";
|
|
9
|
+
declare export var mathQuillInstance: MathQuillInterface;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new [MathField](http://docs.mathquill.com/en/latest/Api_Methods/#mqmathfieldhtml_element-config)
|
|
12
|
+
* instance within the given `container`.
|
|
13
|
+
*
|
|
14
|
+
* An optional configuration callback can be provided to customize
|
|
15
|
+
* the created MathField. A default configuration is passed to this
|
|
16
|
+
* callback which can then be adjusted as needed. The configuration
|
|
17
|
+
* returned from this callback is used to create the MathField.
|
|
18
|
+
* This allows callers to do minimal configuration as only configs
|
|
19
|
+
* that vary from the default need to be provided.
|
|
20
|
+
*/
|
|
21
|
+
declare export function createMathField(
|
|
22
|
+
container: HTMLDivElement | HTMLSpanElement,
|
|
23
|
+
configCallback?: (baseConfig: MathFieldConfig) => MathFieldConfig
|
|
24
|
+
): $Flowgen$Import$_2e__2f_mathquill_2d_types.MathFieldInterface;
|
|
@@ -2,13 +2,34 @@ import Key from "../../data/keys";
|
|
|
2
2
|
export interface MathQuillInterface {
|
|
3
3
|
L: "L";
|
|
4
4
|
R: "R";
|
|
5
|
-
MathField: (mount: HTMLDivElement,
|
|
5
|
+
MathField: (mount: HTMLDivElement | HTMLSpanElement, config: MathFieldConfig) => MathFieldInterface;
|
|
6
6
|
}
|
|
7
|
+
type MathQuillDir = "L" | "R";
|
|
8
|
+
export type MathFieldConfig = {
|
|
9
|
+
spaceBehavesLikeTab?: boolean;
|
|
10
|
+
leftRightIntoCmdGoes?: string;
|
|
11
|
+
restrictMismatchedBrackets?: boolean;
|
|
12
|
+
sumStartsWithNEquals?: boolean;
|
|
13
|
+
supSubsRequireOperand?: boolean;
|
|
14
|
+
charsThatBreakOutOfSupSub?: string;
|
|
15
|
+
autoSubscriptNumerals?: boolean;
|
|
16
|
+
autoCommands?: string;
|
|
17
|
+
autoOperatorNames?: string;
|
|
18
|
+
maxDepth?: number;
|
|
19
|
+
substituteTextarea?: () => HTMLElement;
|
|
20
|
+
handlers?: {
|
|
21
|
+
edit?: (mathField: MathFieldInterface) => void;
|
|
22
|
+
upOutOf?: (mathField: MathFieldInterface) => void;
|
|
23
|
+
moveOutOf?: (dir: MathQuillDir, mathField: MathFieldInterface) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
7
26
|
export interface MathFieldInterface {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
27
|
+
focus: () => MathFieldInterface;
|
|
28
|
+
blur: () => MathFieldInterface;
|
|
29
|
+
write: (input: string) => MathFieldInterface;
|
|
30
|
+
cmd: (input: string) => MathFieldInterface;
|
|
31
|
+
keystroke: (input: string) => MathFieldInterface;
|
|
32
|
+
typedText: (input: string) => MathFieldInterface;
|
|
12
33
|
latex: (input?: string) => string;
|
|
13
34
|
moveToDirEnd: (direction: "L" | "R") => void;
|
|
14
35
|
select: () => void;
|
|
@@ -22,4 +43,5 @@ export declare enum MathFieldActionType {
|
|
|
22
43
|
MQ_END = 0
|
|
23
44
|
}
|
|
24
45
|
export type MathFieldCursor = any;
|
|
25
|
-
export type
|
|
46
|
+
export type MathFieldUpdaterCallback = (mathField: MathFieldInterface, key: Key) => void;
|
|
47
|
+
export {};
|
|
@@ -8,13 +8,37 @@ import Key from "../../data/keys";
|
|
|
8
8
|
export interface MathQuillInterface {
|
|
9
9
|
L: "L";
|
|
10
10
|
R: "R";
|
|
11
|
-
MathField: (
|
|
11
|
+
MathField: (
|
|
12
|
+
mount: HTMLDivElement | HTMLSpanElement,
|
|
13
|
+
config: MathFieldConfig
|
|
14
|
+
) => MathFieldInterface;
|
|
12
15
|
}
|
|
16
|
+
declare type MathQuillDir = "L" | "R";
|
|
17
|
+
export type MathFieldConfig = {|
|
|
18
|
+
spaceBehavesLikeTab?: boolean,
|
|
19
|
+
leftRightIntoCmdGoes?: string,
|
|
20
|
+
restrictMismatchedBrackets?: boolean,
|
|
21
|
+
sumStartsWithNEquals?: boolean,
|
|
22
|
+
supSubsRequireOperand?: boolean,
|
|
23
|
+
charsThatBreakOutOfSupSub?: string,
|
|
24
|
+
autoSubscriptNumerals?: boolean,
|
|
25
|
+
autoCommands?: string,
|
|
26
|
+
autoOperatorNames?: string,
|
|
27
|
+
maxDepth?: number,
|
|
28
|
+
substituteTextarea?: () => HTMLElement,
|
|
29
|
+
handlers?: {|
|
|
30
|
+
edit?: (mathField: MathFieldInterface) => void,
|
|
31
|
+
upOutOf?: (mathField: MathFieldInterface) => void,
|
|
32
|
+
moveOutOf?: (dir: MathQuillDir, mathField: MathFieldInterface) => void,
|
|
33
|
+
|},
|
|
34
|
+
|};
|
|
13
35
|
export interface MathFieldInterface {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
focus: () => MathFieldInterface;
|
|
37
|
+
blur: () => MathFieldInterface;
|
|
38
|
+
write: (input: string) => MathFieldInterface;
|
|
39
|
+
cmd: (input: string) => MathFieldInterface;
|
|
40
|
+
keystroke: (input: string) => MathFieldInterface;
|
|
41
|
+
typedText: (input: string) => MathFieldInterface;
|
|
18
42
|
latex: (input?: string) => string;
|
|
19
43
|
moveToDirEnd: (direction: "L" | "R") => void;
|
|
20
44
|
select: () => void;
|
|
@@ -28,7 +52,7 @@ declare export var MathFieldActionType: {|
|
|
|
28
52
|
+MQ_END: 0, // 0
|
|
29
53
|
|};
|
|
30
54
|
export type MathFieldCursor = any;
|
|
31
|
-
export type
|
|
32
|
-
|
|
55
|
+
export type MathFieldUpdaterCallback = (
|
|
56
|
+
mathField: MathFieldInterface,
|
|
33
57
|
key: Key
|
|
34
58
|
) => void;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import Key from "
|
|
8
|
-
import { MathFieldInterface } from "../mathquill-types";
|
|
7
|
+
import Key from "../../data/keys";
|
|
8
|
+
import { MathFieldInterface } from "../input/mathquill-types";
|
|
9
9
|
declare export default function handleArrow(
|
|
10
10
|
mathField: MathFieldInterface,
|
|
11
11
|
key: Key
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import Key from "
|
|
8
|
-
import { MathFieldInterface } from "../mathquill-types";
|
|
7
|
+
import Key from "../../data/keys";
|
|
8
|
+
import { MathFieldInterface } from "../input/mathquill-types";
|
|
9
9
|
declare export default function handleExponent(
|
|
10
10
|
mathField: MathFieldInterface,
|
|
11
11
|
key: Key
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import Key from "
|
|
8
|
-
import { MathFieldInterface } from "../mathquill-types";
|
|
7
|
+
import Key from "../../data/keys";
|
|
8
|
+
import { MathFieldInterface } from "../input/mathquill-types";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Advances the cursor to the next logical position.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import Key from "
|
|
8
|
-
import {
|
|
9
|
-
declare var keyToMathquillMap: { [key: Key]:
|
|
7
|
+
import Key from "../../data/keys";
|
|
8
|
+
import { MathFieldUpdaterCallback } from "../input/mathquill-types";
|
|
9
|
+
declare var keyToMathquillMap: { [key: Key]: MathFieldUpdaterCallback };
|
|
10
10
|
declare export default typeof keyToMathquillMap;
|