@khanacademy/math-input 0.6.8 → 0.7.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/.eslintrc.js +1 -0
- package/CHANGELOG.md +6 -0
- package/dist/components/common-style.d.ts +21 -0
- package/dist/components/common-style.js.flow +27 -0
- package/dist/components/input/cursor-contexts.d.ts +19 -0
- package/dist/components/input/cursor-contexts.js.flow +32 -0
- package/dist/components/input/cursor-handle.d.ts +25 -0
- package/dist/components/input/cursor-handle.js.flow +28 -0
- package/dist/components/input/math-input.d.ts +128 -0
- package/dist/components/input/math-input.js.flow +152 -0
- package/dist/components/keypad/button-assets.d.ts +6 -0
- package/dist/components/keypad/button-assets.js.flow +12 -0
- package/dist/components/keypad/button.d.ts +14 -0
- package/dist/components/keypad/button.js.flow +19 -0
- package/dist/components/keypad/index.d.ts +15 -0
- package/dist/components/keypad/index.js.flow +22 -0
- package/dist/components/keypad/keypad-page-items.d.ts +24 -0
- package/dist/components/keypad/keypad-page-items.js.flow +30 -0
- package/dist/components/keypad/numeric-input-page.d.ts +8 -0
- package/dist/components/keypad/numeric-input-page.js.flow +13 -0
- package/dist/components/keypad/pre-algebra-page.d.ts +8 -0
- package/dist/components/keypad/pre-algebra-page.js.flow +13 -0
- package/dist/components/keypad/trigonometry-page.d.ts +8 -0
- package/dist/components/keypad/trigonometry-page.js.flow +15 -0
- package/dist/components/provided-keypad.d.ts +23 -0
- package/dist/components/provided-keypad.js.flow +32 -0
- package/dist/components/tabbar/icons.d.ts +7 -0
- package/dist/components/tabbar/icons.js.flow +13 -0
- package/dist/components/tabbar/item.d.ts +14 -0
- package/dist/components/tabbar/item.js.flow +20 -0
- package/dist/components/tabbar/tabbar.d.ts +14 -0
- package/dist/components/tabbar/tabbar.js.flow +20 -0
- package/{src/components/tabbar/types.js → dist/components/tabbar/types.d.ts} +0 -2
- package/dist/components/tabbar/types.js.flow +7 -0
- package/dist/components/z-indexes.d.ts +7 -0
- package/dist/components/z-indexes.js.flow +13 -0
- package/dist/consts.d.ts +51 -0
- package/dist/consts.js.flow +66 -0
- package/dist/data/key-configs.d.ts +7 -0
- package/dist/data/key-configs.js.flow +13 -0
- package/dist/data/keys.d.ts +57 -0
- package/dist/data/keys.js.flow +112 -0
- package/dist/es/index.js +487 -985
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/index.d.ts +10 -0
- package/dist/fake-react-native-web/index.js.flow +8 -0
- package/dist/fake-react-native-web/text.d.ts +12 -0
- package/dist/fake-react-native-web/text.js.flow +18 -0
- package/dist/fake-react-native-web/view.d.ts +22 -0
- package/dist/fake-react-native-web/view.js.flow +28 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +524 -951
- package/dist/index.js.flow +20 -2
- package/dist/index.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js.flow +7 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js.flow +7 -0
- package/package.json +2 -2
- package/src/components/__tests__/gesture-state-machine_test.js +1 -1
- package/src/components/__tests__/node-manager_test.js +1 -1
- package/src/components/__tests__/two-page-keypad_test.js +1 -1
- package/src/components/app.js +2 -2
- package/src/components/{common-style.js → common-style.ts} +0 -1
- package/src/components/compute-layout-parameters.js +2 -2
- package/src/components/corner-decal.js +2 -2
- package/src/components/echo-manager.js +5 -5
- package/src/components/empty-keypad-button.js +3 -3
- package/src/components/expression-keypad.js +10 -10
- package/src/components/fraction-keypad.js +9 -9
- package/src/components/gesture-manager.js +3 -3
- package/src/components/icon.js +6 -6
- package/src/components/iconography/down.js +1 -1
- package/src/components/iconography/index.js +41 -41
- package/src/components/iconography/left.js +1 -1
- package/src/components/iconography/right.js +1 -1
- package/src/components/iconography/up.js +1 -1
- package/src/components/input/__tests__/context-tracking_test.js +3 -3
- package/src/components/input/__tests__/mathquill_test.js +2 -2
- package/src/components/input/__tests__/test-math-wrapper.jsx +1 -1
- package/src/components/input/{cursor-contexts.js → cursor-contexts.ts} +7 -14
- package/src/components/input/{cursor-handle.js → cursor-handle.tsx} +19 -20
- package/src/components/input/{math-input.js → math-input.tsx} +170 -151
- package/src/components/input/math-wrapper.js +5 -5
- package/src/components/input/scroll-into-view.js +1 -1
- package/src/components/keypad/{button-assets.js → button-assets.tsx} +5 -4
- package/src/components/keypad/button.stories.js +1 -1
- package/src/components/keypad/{button.js → button.tsx} +9 -9
- package/src/components/keypad/{index.js → index.tsx} +16 -15
- package/src/components/keypad/{keypad-page-items.js → keypad-page-items.tsx} +24 -39
- package/src/components/keypad/{keypad-pages.stories.js → keypad-pages.stories.tsx} +6 -8
- package/src/components/keypad/{keypad.stories.js → keypad.stories.tsx} +3 -5
- package/src/components/keypad/{numeric-input-page.js → numeric-input-page.tsx} +6 -7
- package/src/components/keypad/{pre-algebra-page.js → pre-algebra-page.tsx} +6 -7
- package/src/components/keypad/{trigonometry-page.js → trigonometry-page.tsx} +6 -7
- package/src/components/keypad-button.js +7 -11
- package/src/components/keypad-container.js +10 -10
- package/src/components/keypad.js +5 -5
- package/src/components/many-keypad-button.js +6 -6
- package/src/components/math-icon.js +3 -3
- package/src/components/multi-symbol-grid.js +6 -6
- package/src/components/multi-symbol-popover.js +5 -5
- package/src/components/navigation-pad.js +6 -6
- package/src/components/popover-manager.js +3 -3
- package/src/components/prop-types.js +3 -3
- package/src/components/{provided-keypad.js → provided-keypad.tsx} +16 -14
- package/src/components/styles.js +1 -1
- package/src/components/svg-icon.js +1 -1
- package/src/components/tabbar/__tests__/tabbar_test.js +1 -1
- package/src/components/tabbar/{icons.js → icons.tsx} +7 -12
- package/src/components/tabbar/{item.js → item.tsx} +6 -8
- package/src/components/tabbar/tabbar.stories.js +2 -2
- package/src/components/tabbar/{tabbar.js → tabbar.tsx} +6 -8
- package/src/components/tabbar/types.ts +1 -0
- package/src/components/text-icon.js +3 -3
- package/src/components/touchable-keypad-button.js +5 -5
- package/src/components/two-page-keypad.js +5 -5
- package/src/components/{z-indexes.js → z-indexes.ts} +0 -1
- package/src/{consts.js → consts.ts} +22 -27
- package/src/data/{key-configs.js → key-configs.ts} +7 -8
- package/src/data/{keys.js → keys.ts} +7 -13
- package/src/demo.js +1 -1
- package/src/fake-react-native-web/{index.js → index.ts} +2 -3
- package/src/fake-react-native-web/{text.js → text.tsx} +7 -9
- package/src/fake-react-native-web/{view.js → view.tsx} +15 -17
- package/src/{index.js → index.ts} +9 -10
- package/src/native-app.js +3 -3
- package/src/store/{index.js → index.ts} +63 -34
- package/src/{utils.js → utils.ts} +1 -2
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
- /package/dist/{strings.js → strings} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createStore: () => any;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const decimalSeparator: string;
|
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
|
+
"version": "0.7.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"module": "dist/es/index.js",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
|
-
"source": "src/index.
|
|
19
|
+
"source": "src/index.ts",
|
|
20
20
|
"scripts": {},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"performance-now": "^0.2.0"
|
package/src/components/app.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {StyleSheet} from "aphrodite";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
import {View} from "../fake-react-native-web/index
|
|
5
|
-
import {Keypad, KeypadInput, KeypadTypes} from "../index
|
|
4
|
+
import {View} from "../fake-react-native-web/index";
|
|
5
|
+
import {Keypad, KeypadInput, KeypadTypes} from "../index";
|
|
6
6
|
|
|
7
7
|
class App extends React.Component {
|
|
8
8
|
state = {
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
* might need to be.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import {DeviceTypes, DeviceOrientations, LayoutModes} from "../consts
|
|
22
|
+
import {DeviceTypes, DeviceOrientations, LayoutModes} from "../consts";
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
25
|
pageIndicatorHeightPx,
|
|
26
26
|
toolbarHeightPx,
|
|
27
27
|
navigationPadWidthPx,
|
|
28
28
|
innerBorderWidthPx,
|
|
29
|
-
} from "./common-style
|
|
29
|
+
} from "./common-style";
|
|
30
30
|
|
|
31
31
|
const minButtonHeight = 48;
|
|
32
32
|
const maxButtonSize = 64;
|
|
@@ -6,9 +6,9 @@ import {StyleSheet} from "aphrodite";
|
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
|
|
9
|
-
import {View} from "../fake-react-native-web/index
|
|
9
|
+
import {View} from "../fake-react-native-web/index";
|
|
10
10
|
|
|
11
|
-
import {offBlack} from "./common-style
|
|
11
|
+
import {offBlack} from "./common-style";
|
|
12
12
|
|
|
13
13
|
class CornerDecal extends React.Component {
|
|
14
14
|
static propTypes = {
|
|
@@ -6,17 +6,17 @@ import PropTypes from "prop-types";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import {TransitionGroup, CSSTransition} from "react-transition-group";
|
|
8
8
|
|
|
9
|
-
import {KeyTypes, EchoAnimationTypes} from "../consts
|
|
10
|
-
import KeyConfigs from "../data/key-configs
|
|
9
|
+
import {KeyTypes, EchoAnimationTypes} from "../consts";
|
|
10
|
+
import KeyConfigs from "../data/key-configs";
|
|
11
11
|
|
|
12
|
-
import KeypadButton from "./keypad-button
|
|
12
|
+
import KeypadButton from "./keypad-button";
|
|
13
13
|
import {
|
|
14
14
|
echoPropType,
|
|
15
15
|
bordersPropType,
|
|
16
16
|
boundingBoxPropType,
|
|
17
17
|
keyIdPropType,
|
|
18
|
-
} from "./prop-types
|
|
19
|
-
import * as zIndexes from "./z-indexes
|
|
18
|
+
} from "./prop-types";
|
|
19
|
+
import * as zIndexes from "./z-indexes";
|
|
20
20
|
|
|
21
21
|
class Echo extends React.Component {
|
|
22
22
|
static propTypes = {
|
|
@@ -6,10 +6,10 @@ import PropTypes from "prop-types";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import {connect} from "react-redux";
|
|
8
8
|
|
|
9
|
-
import KeyConfigs from "../data/key-configs
|
|
9
|
+
import KeyConfigs from "../data/key-configs";
|
|
10
10
|
|
|
11
|
-
import GestureManager from "./gesture-manager
|
|
12
|
-
import KeypadButton from "./keypad-button
|
|
11
|
+
import GestureManager from "./gesture-manager";
|
|
12
|
+
import KeypadButton from "./keypad-button";
|
|
13
13
|
|
|
14
14
|
class EmptyKeypadButton extends React.Component {
|
|
15
15
|
static propTypes = {
|
|
@@ -7,17 +7,17 @@ import PropTypes from "prop-types";
|
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import {connect} from "react-redux";
|
|
9
9
|
|
|
10
|
-
import {BorderStyles} from "../consts
|
|
11
|
-
import KeyConfigs from "../data/key-configs
|
|
12
|
-
import {View} from "../fake-react-native-web/index
|
|
10
|
+
import {BorderStyles} from "../consts";
|
|
11
|
+
import KeyConfigs from "../data/key-configs";
|
|
12
|
+
import {View} from "../fake-react-native-web/index";
|
|
13
13
|
|
|
14
|
-
import {valueGrey, controlGrey} from "./common-style
|
|
15
|
-
import * as CursorContexts from "./input/cursor-contexts
|
|
16
|
-
import ManyKeypadButton from "./many-keypad-button
|
|
17
|
-
import {cursorContextPropType, keyIdPropType} from "./prop-types
|
|
18
|
-
import Styles from "./styles
|
|
19
|
-
import TouchableKeypadButton from "./touchable-keypad-button
|
|
20
|
-
import TwoPageKeypad from "./two-page-keypad
|
|
14
|
+
import {valueGrey, controlGrey} from "./common-style";
|
|
15
|
+
import * as CursorContexts from "./input/cursor-contexts";
|
|
16
|
+
import ManyKeypadButton from "./many-keypad-button";
|
|
17
|
+
import {cursorContextPropType, keyIdPropType} from "./prop-types";
|
|
18
|
+
import Styles from "./styles";
|
|
19
|
+
import TouchableKeypadButton from "./touchable-keypad-button";
|
|
20
|
+
import TwoPageKeypad from "./two-page-keypad";
|
|
21
21
|
|
|
22
22
|
const {row, column, oneColumn, fullWidth, roundedTopLeft, roundedTopRight} =
|
|
23
23
|
Styles;
|
|
@@ -7,15 +7,15 @@ import PropTypes from "prop-types";
|
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import {connect} from "react-redux";
|
|
9
9
|
|
|
10
|
-
import {BorderStyles} from "../consts
|
|
11
|
-
import KeyConfigs from "../data/key-configs
|
|
12
|
-
import {View} from "../fake-react-native-web/index
|
|
13
|
-
|
|
14
|
-
import * as CursorContexts from "./input/cursor-contexts
|
|
15
|
-
import Keypad from "./keypad
|
|
16
|
-
import {cursorContextPropType} from "./prop-types
|
|
17
|
-
import Styles from "./styles
|
|
18
|
-
import TouchableKeypadButton from "./touchable-keypad-button
|
|
10
|
+
import {BorderStyles} from "../consts";
|
|
11
|
+
import KeyConfigs from "../data/key-configs";
|
|
12
|
+
import {View} from "../fake-react-native-web/index";
|
|
13
|
+
|
|
14
|
+
import * as CursorContexts from "./input/cursor-contexts";
|
|
15
|
+
import Keypad from "./keypad";
|
|
16
|
+
import {cursorContextPropType} from "./prop-types";
|
|
17
|
+
import Styles from "./styles";
|
|
18
|
+
import TouchableKeypadButton from "./touchable-keypad-button";
|
|
19
19
|
|
|
20
20
|
const {row, roundedTopLeft, roundedTopRight} = Styles;
|
|
21
21
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* and links them together.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import GestureStateMachine from "./gesture-state-machine
|
|
8
|
-
import NodeManager from "./node-manager
|
|
9
|
-
import PopoverStateMachine from "./popover-state-machine
|
|
7
|
+
import GestureStateMachine from "./gesture-state-machine";
|
|
8
|
+
import NodeManager from "./node-manager";
|
|
9
|
+
import PopoverStateMachine from "./popover-state-machine";
|
|
10
10
|
|
|
11
11
|
const coordsForEvent = (evt) => {
|
|
12
12
|
return [evt.changedTouches[0].clientX, evt.changedTouches[0].clientY];
|
package/src/components/icon.js
CHANGED
|
@@ -6,13 +6,13 @@ import {StyleSheet} from "aphrodite";
|
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
|
|
9
|
-
import {IconTypes} from "../consts
|
|
9
|
+
import {IconTypes} from "../consts";
|
|
10
10
|
|
|
11
|
-
import {offBlack} from "./common-style
|
|
12
|
-
import MathIcon from "./math-icon
|
|
13
|
-
import {iconPropType} from "./prop-types
|
|
14
|
-
import SvgIcon from "./svg-icon
|
|
15
|
-
import TextIcon from "./text-icon
|
|
11
|
+
import {offBlack} from "./common-style";
|
|
12
|
+
import MathIcon from "./math-icon";
|
|
13
|
+
import {iconPropType} from "./prop-types";
|
|
14
|
+
import SvgIcon from "./svg-icon";
|
|
15
|
+
import TextIcon from "./text-icon";
|
|
16
16
|
|
|
17
17
|
const focusedColor = "#FFF";
|
|
18
18
|
const unfocusedColor = offBlack;
|
|
@@ -2,44 +2,44 @@
|
|
|
2
2
|
* A directory of autogenerated icon components.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export {default as COS} from "./cos
|
|
6
|
-
export {default as LOG} from "./log
|
|
7
|
-
export {default as EQUAL} from "./equal
|
|
8
|
-
export {default as BACKSPACE} from "./backspace
|
|
9
|
-
export {default as SQRT} from "./sqrt
|
|
10
|
-
export {default as EXP} from "./exp
|
|
11
|
-
export {default as NEQ} from "./neq
|
|
12
|
-
export {default as GEQ} from "./geq
|
|
13
|
-
export {default as LN} from "./ln
|
|
14
|
-
export {default as DISMISS} from "./dismiss
|
|
15
|
-
export {default as SIN} from "./sin
|
|
16
|
-
export {default as LT} from "./lt
|
|
17
|
-
export {default as CUBE_ROOT} from "./cube-root
|
|
18
|
-
export {default as PLUS} from "./plus
|
|
19
|
-
export {default as TAN} from "./tan
|
|
20
|
-
export {default as LEFT} from "./left
|
|
21
|
-
export {default as UP} from "./up
|
|
22
|
-
export {default as DOWN} from "./down
|
|
23
|
-
export {default as LEFT_PAREN} from "./left-paren
|
|
24
|
-
export {default as RIGHT_PAREN} from "./right-paren
|
|
25
|
-
export {default as GT} from "./gt
|
|
26
|
-
export {default as DIVIDE} from "./divide
|
|
27
|
-
export {default as PERIOD} from "./period
|
|
28
|
-
export {default as PERCENT} from "./percent
|
|
29
|
-
export {default as TIMES} from "./times
|
|
30
|
-
export {default as EXP_3} from "./exp-3
|
|
31
|
-
export {default as EXP_2} from "./exp-2
|
|
32
|
-
export {default as RIGHT} from "./right
|
|
33
|
-
export {default as CDOT} from "./cdot
|
|
34
|
-
export {default as LOG_N} from "./log-n
|
|
35
|
-
export {default as LEQ} from "./leq
|
|
36
|
-
export {default as MINUS} from "./minus
|
|
37
|
-
export {default as NEGATIVE} from "./minus
|
|
38
|
-
export {default as RADICAL} from "./radical
|
|
39
|
-
export {default as FRAC} from "./frac
|
|
40
|
-
export {default as JUMP_OUT_PARENTHESES} from "./jump-out-parentheses
|
|
41
|
-
export {default as JUMP_OUT_EXPONENT} from "./jump-out-exponent
|
|
42
|
-
export {default as JUMP_OUT_BASE} from "./jump-out-base
|
|
43
|
-
export {default as JUMP_INTO_NUMERATOR} from "./jump-into-numerator
|
|
44
|
-
export {default as JUMP_OUT_NUMERATOR} from "./jump-out-numerator
|
|
45
|
-
export {default as JUMP_OUT_DENOMINATOR} from "./jump-out-denominator
|
|
5
|
+
export {default as COS} from "./cos";
|
|
6
|
+
export {default as LOG} from "./log";
|
|
7
|
+
export {default as EQUAL} from "./equal";
|
|
8
|
+
export {default as BACKSPACE} from "./backspace";
|
|
9
|
+
export {default as SQRT} from "./sqrt";
|
|
10
|
+
export {default as EXP} from "./exp";
|
|
11
|
+
export {default as NEQ} from "./neq";
|
|
12
|
+
export {default as GEQ} from "./geq";
|
|
13
|
+
export {default as LN} from "./ln";
|
|
14
|
+
export {default as DISMISS} from "./dismiss";
|
|
15
|
+
export {default as SIN} from "./sin";
|
|
16
|
+
export {default as LT} from "./lt";
|
|
17
|
+
export {default as CUBE_ROOT} from "./cube-root";
|
|
18
|
+
export {default as PLUS} from "./plus";
|
|
19
|
+
export {default as TAN} from "./tan";
|
|
20
|
+
export {default as LEFT} from "./left";
|
|
21
|
+
export {default as UP} from "./up";
|
|
22
|
+
export {default as DOWN} from "./down";
|
|
23
|
+
export {default as LEFT_PAREN} from "./left-paren";
|
|
24
|
+
export {default as RIGHT_PAREN} from "./right-paren";
|
|
25
|
+
export {default as GT} from "./gt";
|
|
26
|
+
export {default as DIVIDE} from "./divide";
|
|
27
|
+
export {default as PERIOD} from "./period";
|
|
28
|
+
export {default as PERCENT} from "./percent";
|
|
29
|
+
export {default as TIMES} from "./times";
|
|
30
|
+
export {default as EXP_3} from "./exp-3";
|
|
31
|
+
export {default as EXP_2} from "./exp-2";
|
|
32
|
+
export {default as RIGHT} from "./right";
|
|
33
|
+
export {default as CDOT} from "./cdot";
|
|
34
|
+
export {default as LOG_N} from "./log-n";
|
|
35
|
+
export {default as LEQ} from "./leq";
|
|
36
|
+
export {default as MINUS} from "./minus";
|
|
37
|
+
export {default as NEGATIVE} from "./minus";
|
|
38
|
+
export {default as RADICAL} from "./radical";
|
|
39
|
+
export {default as FRAC} from "./frac";
|
|
40
|
+
export {default as JUMP_OUT_PARENTHESES} from "./jump-out-parentheses";
|
|
41
|
+
export {default as JUMP_OUT_EXPONENT} from "./jump-out-exponent";
|
|
42
|
+
export {default as JUMP_OUT_BASE} from "./jump-out-base";
|
|
43
|
+
export {default as JUMP_INTO_NUMERATOR} from "./jump-into-numerator";
|
|
44
|
+
export {default as JUMP_OUT_NUMERATOR} from "./jump-out-numerator";
|
|
45
|
+
export {default as JUMP_OUT_DENOMINATOR} from "./jump-out-denominator";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Keys from "../../../data/keys
|
|
2
|
-
import * as CursorContexts from "../cursor-contexts
|
|
1
|
+
import Keys from "../../../data/keys";
|
|
2
|
+
import * as CursorContexts from "../cursor-contexts";
|
|
3
3
|
|
|
4
|
-
import TestMathWrapper from "./test-math-wrapper
|
|
4
|
+
import TestMathWrapper from "./test-math-wrapper";
|
|
5
5
|
|
|
6
6
|
describe("Cursor context", () => {
|
|
7
7
|
let mathField;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Constants that define the various contexts in which a cursor can exist. The
|
|
4
3
|
* active context is determined first by looking at the cursor's siblings (e.g.,
|
|
@@ -11,23 +10,17 @@
|
|
|
11
10
|
* the radical.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
|
-
export type CursorContext =
|
|
15
|
-
// The cursor is not in any of the other viable contexts.
|
|
16
|
-
| "NONE"
|
|
13
|
+
export type CursorContext = // The cursor is not in any of the other viable contexts.
|
|
17
14
|
// The cursor is within a set of parentheses.
|
|
18
|
-
| "
|
|
19
|
-
// The cursor is within a
|
|
20
|
-
| "IN_SUPER_SCRIPT"
|
|
21
|
-
// The cursor is
|
|
22
|
-
| "
|
|
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
|
|
15
|
+
| "NONE" // The cursor is within a superscript (e.g., an exponent).
|
|
16
|
+
| "IN_PARENS" // The cursor is within a subscript (e.g., the base of a custom logarithm).
|
|
17
|
+
| "IN_SUPER_SCRIPT" // The cursor is in the numerator of a fraction.
|
|
18
|
+
| "IN_SUB_SCRIPT" // The cursor is in the denominator of a fraction.
|
|
19
|
+
| "IN_NUMERATOR" // The cursor is sitting before a fraction; that is, the cursor is within
|
|
28
20
|
// what looks to be a mixed number preceding a fraction. This will only be
|
|
29
21
|
// the case when the only math between the cursor and the fraction to its
|
|
30
22
|
// write is non-leaf math (numbers and variables).
|
|
23
|
+
| "IN_DENOMINATOR"
|
|
31
24
|
| "BEFORE_FRACTION";
|
|
32
25
|
|
|
33
26
|
// TODO: Get rid of these constants in favour of CursorContext type.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Renders the green tear-shaped handle under the cursor.
|
|
4
3
|
*/
|
|
@@ -8,7 +7,7 @@ import * as React from "react";
|
|
|
8
7
|
import {
|
|
9
8
|
cursorHandleRadiusPx,
|
|
10
9
|
cursorHandleDistanceMultiplier,
|
|
11
|
-
} from "../common-style
|
|
10
|
+
} from "../common-style";
|
|
12
11
|
|
|
13
12
|
const touchTargetRadiusPx = 2 * cursorHandleRadiusPx;
|
|
14
13
|
const touchTargetHeightPx = 2 * touchTargetRadiusPx;
|
|
@@ -18,23 +17,23 @@ const cursorRadiusPx = cursorHandleRadiusPx;
|
|
|
18
17
|
const cursorHeightPx = cursorHandleDistanceMultiplier * (cursorRadiusPx * 4);
|
|
19
18
|
const cursorWidthPx = 4 * cursorRadiusPx;
|
|
20
19
|
|
|
21
|
-
type Props = {
|
|
22
|
-
animateIntoPosition:
|
|
23
|
-
onTouchCancel: (
|
|
24
|
-
onTouchEnd: (
|
|
25
|
-
onTouchMove: (
|
|
26
|
-
onTouchStart: (
|
|
27
|
-
visible: boolean
|
|
28
|
-
x: number
|
|
29
|
-
y: number
|
|
30
|
-
|
|
20
|
+
type Props = {
|
|
21
|
+
animateIntoPosition: boolean | null | undefined;
|
|
22
|
+
onTouchCancel: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
|
|
23
|
+
onTouchEnd: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
|
|
24
|
+
onTouchMove: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
|
|
25
|
+
onTouchStart: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
|
|
26
|
+
visible: boolean;
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
};
|
|
31
30
|
|
|
32
|
-
type DefaultProps = {
|
|
33
|
-
animateIntoPosition: Props["animateIntoPosition"]
|
|
34
|
-
visible: Props["visible"]
|
|
35
|
-
x: Props["x"]
|
|
36
|
-
y: Props["y"]
|
|
37
|
-
|
|
31
|
+
type DefaultProps = {
|
|
32
|
+
animateIntoPosition: Props["animateIntoPosition"];
|
|
33
|
+
visible: Props["visible"];
|
|
34
|
+
x: Props["x"];
|
|
35
|
+
y: Props["y"];
|
|
36
|
+
};
|
|
38
37
|
|
|
39
38
|
class CursorHandle extends React.Component<Props> {
|
|
40
39
|
static defaultProps: DefaultProps = {
|
|
@@ -44,7 +43,7 @@ class CursorHandle extends React.Component<Props> {
|
|
|
44
43
|
y: 0,
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
render(): React.
|
|
46
|
+
render(): React.ReactNode {
|
|
48
47
|
const {x, y, animateIntoPosition} = this.props;
|
|
49
48
|
|
|
50
49
|
const animationStyle = animateIntoPosition
|
|
@@ -69,7 +68,7 @@ class CursorHandle extends React.Component<Props> {
|
|
|
69
68
|
// produce page scrolls.
|
|
70
69
|
touchAction: "none",
|
|
71
70
|
...animationStyle,
|
|
72
|
-
};
|
|
71
|
+
} as const;
|
|
73
72
|
|
|
74
73
|
return (
|
|
75
74
|
<span
|