@khanacademy/perseus-editor 2.6.0 → 2.6.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/CHANGELOG.md +11 -0
- package/dist/es/index.js +50 -72
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +45 -69
- package/dist/index.js.map +1 -1
- package/dist/widgets/plotter-editor.d.ts +47 -23
- package/dist/widgets/plotter-editor.js.flow +47 -25
- package/package.json +2 -2
- package/src/components/checkbox.tsx +1 -0
- package/src/components/dropdown-option.tsx +1 -0
- package/src/components/form-wrapped-text-field.tsx +1 -0
- package/src/components/widget-editor.tsx +1 -0
- package/src/diffs/structured-item-diff.tsx +1 -0
- package/src/editor.tsx +1 -0
- package/src/hint-editor.tsx +1 -0
- package/src/katex-mhchem/parser.js +24 -24
- package/src/widgets/__stories__/label-image-editor.stories.tsx +1 -0
- package/src/widgets/__stories__/radio-editor.stories.tsx +1 -0
- package/src/widgets/definition-editor.tsx +1 -0
- package/src/widgets/dropdown-editor.tsx +1 -0
- package/src/widgets/example-widget.tsx +1 -0
- package/src/widgets/explanation-editor.tsx +1 -0
- package/src/widgets/graded-group-editor.tsx +1 -0
- package/src/widgets/grapher-editor.tsx +1 -0
- package/src/widgets/group-editor.tsx +1 -0
- package/src/widgets/iframe-editor.tsx +1 -0
- package/src/widgets/interaction-editor.tsx +1 -0
- package/src/widgets/label-image/marker.tsx +1 -0
- package/src/widgets/lights-puzzle-editor.tsx +1 -0
- package/src/widgets/measurer-editor.tsx +1 -0
- package/src/widgets/number-line-editor.tsx +1 -0
- package/src/widgets/orderer-editor.tsx +1 -0
- package/src/widgets/passage-ref-editor.tsx +1 -0
- package/src/widgets/plotter-editor.tsx +253 -243
- package/src/widgets/simple-markdown-tester-editor.tsx +1 -0
- package/src/widgets/sorter-editor.tsx +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
|
@@ -1,32 +1,55 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
type
|
|
2
|
+
declare const plotTypes: string[];
|
|
3
|
+
type PlotType = typeof plotTypes[number];
|
|
4
|
+
declare const editingStates: string[];
|
|
5
|
+
type EditingState = typeof editingStates[number];
|
|
6
|
+
type Props = {
|
|
7
|
+
type: PlotType;
|
|
8
|
+
labels: Array<string>;
|
|
9
|
+
categories: ReadonlyArray<string | number>;
|
|
10
|
+
scaleY: number;
|
|
11
|
+
maxY: number;
|
|
12
|
+
snapsPerLine: number;
|
|
13
|
+
picSize: number;
|
|
14
|
+
picBoxHeight: number;
|
|
15
|
+
picUrl: string;
|
|
16
|
+
plotDimensions: ReadonlyArray<number>;
|
|
17
|
+
labelInterval: number;
|
|
18
|
+
starting: ReadonlyArray<number>;
|
|
19
|
+
correct: ReadonlyArray<number>;
|
|
20
|
+
static: boolean;
|
|
21
|
+
onChange: any;
|
|
22
|
+
};
|
|
23
|
+
type DefaultProps = {
|
|
24
|
+
scaleY: Props["scaleY"];
|
|
25
|
+
maxY: Props["maxY"];
|
|
26
|
+
snapsPerLine: Props["snapsPerLine"];
|
|
27
|
+
correct: Props["correct"];
|
|
28
|
+
starting: Props["starting"];
|
|
29
|
+
type: Props["type"];
|
|
30
|
+
labels: Props["labels"];
|
|
31
|
+
categories: Props["categories"];
|
|
32
|
+
picSize: Props["picSize"];
|
|
33
|
+
picBoxHeight: Props["picBoxHeight"];
|
|
34
|
+
plotDimensions: Props["plotDimensions"];
|
|
35
|
+
labelInterval: Props["labelInterval"];
|
|
36
|
+
picUrl: Props["picUrl"];
|
|
37
|
+
};
|
|
38
|
+
type State = {
|
|
39
|
+
editing: EditingState;
|
|
40
|
+
pic: any;
|
|
41
|
+
loadedUrl: string | null;
|
|
42
|
+
minX: number | null;
|
|
43
|
+
maxX: number | null;
|
|
44
|
+
tickStep: number | null;
|
|
45
|
+
};
|
|
5
46
|
declare class PlotterEditor extends React.Component<Props, State> {
|
|
6
|
-
static propTypes: {
|
|
7
|
-
readonly type: PropTypes.Requireable<string>;
|
|
8
|
-
readonly labels: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
9
|
-
readonly categories: PropTypes.Requireable<(NonNullable<string | number | null | undefined> | null | undefined)[]>;
|
|
10
|
-
readonly scaleY: PropTypes.Requireable<number>;
|
|
11
|
-
readonly maxY: PropTypes.Requireable<number>;
|
|
12
|
-
readonly snapsPerLine: PropTypes.Requireable<number>;
|
|
13
|
-
readonly picSize: PropTypes.Requireable<number>;
|
|
14
|
-
readonly pixBoxHeight: PropTypes.Requireable<number>;
|
|
15
|
-
readonly picUrl: PropTypes.Requireable<string>;
|
|
16
|
-
readonly plotDimensions: PropTypes.Requireable<(number | null | undefined)[]>;
|
|
17
|
-
readonly labelInterval: PropTypes.Requireable<number>;
|
|
18
|
-
readonly starting: PropTypes.Requireable<(number | null | undefined)[]>;
|
|
19
|
-
readonly correct: PropTypes.Requireable<(number | null | undefined)[]>;
|
|
20
|
-
readonly static: PropTypes.Requireable<boolean>;
|
|
21
|
-
readonly onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
};
|
|
23
47
|
static widgetName: "plotter";
|
|
24
|
-
static defaultProps:
|
|
48
|
+
static defaultProps: DefaultProps;
|
|
25
49
|
state: State;
|
|
26
50
|
UNSAFE_componentWillMount(): void;
|
|
27
51
|
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
28
52
|
fetchPic: (arg1: string) => any;
|
|
29
|
-
render(): React.ReactNode;
|
|
30
53
|
handleChangeTickStep: (arg1: number) => void;
|
|
31
54
|
handleChangeRange: (arg1: [number, number]) => void;
|
|
32
55
|
changeLabelInterval: (arg1: number) => void;
|
|
@@ -38,8 +61,9 @@ declare class PlotterEditor extends React.Component<Props, State> {
|
|
|
38
61
|
changeScale: (arg1: any) => void;
|
|
39
62
|
changeMax: (arg1: any) => void;
|
|
40
63
|
changeSnaps: (arg1: any) => void;
|
|
41
|
-
changeEditing: (arg1:
|
|
64
|
+
changeEditing: (arg1: EditingState) => void;
|
|
42
65
|
setCategoriesFromScale: () => void;
|
|
43
66
|
serialize: () => any;
|
|
67
|
+
render(): React.ReactNode;
|
|
44
68
|
}
|
|
45
69
|
export default PlotterEditor;
|
|
@@ -4,37 +4,58 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import PropTypes from "prop-types";
|
|
8
7
|
import * as React from "react";
|
|
9
|
-
declare
|
|
10
|
-
declare type
|
|
8
|
+
declare var plotTypes: string[];
|
|
9
|
+
declare type PlotType = $ElementType<typeof plotTypes, number>;
|
|
10
|
+
declare var editingStates: string[];
|
|
11
|
+
declare type EditingState = $ElementType<typeof editingStates, number>;
|
|
12
|
+
declare type Props = {|
|
|
13
|
+
type: PlotType,
|
|
14
|
+
labels: Array<string>,
|
|
15
|
+
categories: $ReadOnlyArray<string | number>,
|
|
16
|
+
scaleY: number,
|
|
17
|
+
maxY: number,
|
|
18
|
+
snapsPerLine: number,
|
|
19
|
+
picSize: number,
|
|
20
|
+
picBoxHeight: number,
|
|
21
|
+
picUrl: string,
|
|
22
|
+
plotDimensions: $ReadOnlyArray<number>,
|
|
23
|
+
labelInterval: number,
|
|
24
|
+
starting: $ReadOnlyArray<number>,
|
|
25
|
+
correct: $ReadOnlyArray<number>,
|
|
26
|
+
static: boolean,
|
|
27
|
+
onChange: any,
|
|
28
|
+
|};
|
|
29
|
+
declare type DefaultProps = {|
|
|
30
|
+
scaleY: $PropertyType<Props, "scaleY">,
|
|
31
|
+
maxY: $PropertyType<Props, "maxY">,
|
|
32
|
+
snapsPerLine: $PropertyType<Props, "snapsPerLine">,
|
|
33
|
+
correct: $PropertyType<Props, "correct">,
|
|
34
|
+
starting: $PropertyType<Props, "starting">,
|
|
35
|
+
type: $PropertyType<Props, "type">,
|
|
36
|
+
labels: $PropertyType<Props, "labels">,
|
|
37
|
+
categories: $PropertyType<Props, "categories">,
|
|
38
|
+
picSize: $PropertyType<Props, "picSize">,
|
|
39
|
+
picBoxHeight: $PropertyType<Props, "picBoxHeight">,
|
|
40
|
+
plotDimensions: $PropertyType<Props, "plotDimensions">,
|
|
41
|
+
labelInterval: $PropertyType<Props, "labelInterval">,
|
|
42
|
+
picUrl: $PropertyType<Props, "picUrl">,
|
|
43
|
+
|};
|
|
44
|
+
declare type State = {|
|
|
45
|
+
editing: EditingState,
|
|
46
|
+
pic: any,
|
|
47
|
+
loadedUrl: string | null,
|
|
48
|
+
minX: number | null,
|
|
49
|
+
maxX: number | null,
|
|
50
|
+
tickStep: number | null,
|
|
51
|
+
|};
|
|
11
52
|
declare class PlotterEditor extends React.Component<Props, State> {
|
|
12
|
-
static propTypes: {|
|
|
13
|
-
+type: PropTypes.Requireable<string>,
|
|
14
|
-
+labels: PropTypes.Requireable<(string | null | void)[]>,
|
|
15
|
-
+categories: PropTypes.Requireable<
|
|
16
|
-
($NonMaybeType<string | number | null | void> | null | void)[]
|
|
17
|
-
>,
|
|
18
|
-
+scaleY: PropTypes.Requireable<number>,
|
|
19
|
-
+maxY: PropTypes.Requireable<number>,
|
|
20
|
-
+snapsPerLine: PropTypes.Requireable<number>,
|
|
21
|
-
+picSize: PropTypes.Requireable<number>,
|
|
22
|
-
+pixBoxHeight: PropTypes.Requireable<number>,
|
|
23
|
-
+picUrl: PropTypes.Requireable<string>,
|
|
24
|
-
+plotDimensions: PropTypes.Requireable<(number | null | void)[]>,
|
|
25
|
-
+labelInterval: PropTypes.Requireable<number>,
|
|
26
|
-
+starting: PropTypes.Requireable<(number | null | void)[]>,
|
|
27
|
-
+correct: PropTypes.Requireable<(number | null | void)[]>,
|
|
28
|
-
+static: PropTypes.Requireable<boolean>,
|
|
29
|
-
+onChange: PropTypes.Requireable<(...args: any[]) => any>,
|
|
30
|
-
|};
|
|
31
53
|
static widgetName: "plotter";
|
|
32
|
-
static defaultProps:
|
|
54
|
+
static defaultProps: DefaultProps;
|
|
33
55
|
state: State;
|
|
34
56
|
UNSAFE_componentWillMount(): void;
|
|
35
57
|
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
36
58
|
fetchPic: (arg1: string) => any;
|
|
37
|
-
render(): React.Node;
|
|
38
59
|
handleChangeTickStep: (arg1: number) => void;
|
|
39
60
|
handleChangeRange: (arg1: [number, number]) => void;
|
|
40
61
|
changeLabelInterval: (arg1: number) => void;
|
|
@@ -46,8 +67,9 @@ declare class PlotterEditor extends React.Component<Props, State> {
|
|
|
46
67
|
changeScale: (arg1: any) => void;
|
|
47
68
|
changeMax: (arg1: any) => void;
|
|
48
69
|
changeSnaps: (arg1: any) => void;
|
|
49
|
-
changeEditing: (arg1:
|
|
70
|
+
changeEditing: (arg1: EditingState) => void;
|
|
50
71
|
setCategoriesFromScale: () => void;
|
|
51
72
|
serialize: () => any;
|
|
73
|
+
render(): React.Node;
|
|
52
74
|
}
|
|
53
75
|
declare export default typeof PlotterEditor;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Perseus editors",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.6.
|
|
6
|
+
"version": "2.6.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@khanacademy/kas": "^0.3.1",
|
|
25
25
|
"@khanacademy/kmath": "^0.1.1",
|
|
26
|
-
"@khanacademy/perseus": "^7.2.
|
|
26
|
+
"@khanacademy/perseus": "^7.2.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@khanacademy/wonder-blocks-button": "^4.0.8",
|
package/src/editor.tsx
CHANGED
package/src/hint-editor.tsx
CHANGED
|
@@ -946,7 +946,7 @@ mhchemParser.stateMachines = {
|
|
|
946
946
|
},
|
|
947
947
|
},
|
|
948
948
|
oxidation$: {
|
|
949
|
-
|
|
949
|
+
0: {action_: "oxidation-output"},
|
|
950
950
|
},
|
|
951
951
|
CMT: {
|
|
952
952
|
r: {action_: "rdt=", nextState: "rt"},
|
|
@@ -975,7 +975,7 @@ mhchemParser.stateMachines = {
|
|
|
975
975
|
q: {action_: "d=", nextState: "qd"},
|
|
976
976
|
"qd|qD": {action_: "d=", nextState: "qd"},
|
|
977
977
|
dq: {action_: ["output", "d="], nextState: "d"},
|
|
978
|
-
|
|
978
|
+
3: {
|
|
979
979
|
action_: ["sb=false", "output", "operator"],
|
|
980
980
|
nextState: "0",
|
|
981
981
|
},
|
|
@@ -1038,7 +1038,7 @@ mhchemParser.stateMachines = {
|
|
|
1038
1038
|
],
|
|
1039
1039
|
nextState: "3",
|
|
1040
1040
|
},
|
|
1041
|
-
|
|
1041
|
+
3: {action_: {type_: "bond", option: "-"}},
|
|
1042
1042
|
a: {
|
|
1043
1043
|
action_: ["output", {type_: "insert", option: "hyphen"}],
|
|
1044
1044
|
nextState: "2",
|
|
@@ -1087,7 +1087,7 @@ mhchemParser.stateMachines = {
|
|
|
1087
1087
|
},
|
|
1088
1088
|
space: {
|
|
1089
1089
|
a: {nextState: "as"},
|
|
1090
|
-
|
|
1090
|
+
0: {action_: "sb=false"},
|
|
1091
1091
|
"1|2": {action_: "sb=true"},
|
|
1092
1092
|
"r|rt|rd|rdt|rdq": {action_: "output", nextState: "0"},
|
|
1093
1093
|
"*": {action_: ["output", "sb=true"], nextState: "1"},
|
|
@@ -1605,10 +1605,10 @@ mhchemParser.stateMachines = {
|
|
|
1605
1605
|
"*": {},
|
|
1606
1606
|
},
|
|
1607
1607
|
"1/2$": {
|
|
1608
|
-
|
|
1608
|
+
0: {action_: "1/2"},
|
|
1609
1609
|
},
|
|
1610
1610
|
else: {
|
|
1611
|
-
|
|
1611
|
+
0: {nextState: "1", revisit: true},
|
|
1612
1612
|
},
|
|
1613
1613
|
"$(...)$": {
|
|
1614
1614
|
"*": {action_: "tex-math tight", nextState: "1"},
|
|
@@ -1628,10 +1628,10 @@ mhchemParser.stateMachines = {
|
|
|
1628
1628
|
"*": {},
|
|
1629
1629
|
},
|
|
1630
1630
|
"1/2$": {
|
|
1631
|
-
|
|
1631
|
+
0: {action_: "1/2"},
|
|
1632
1632
|
},
|
|
1633
1633
|
else: {
|
|
1634
|
-
|
|
1634
|
+
0: {nextState: "1", revisit: true},
|
|
1635
1635
|
},
|
|
1636
1636
|
letters: {
|
|
1637
1637
|
"*": {action_: "rm"},
|
|
@@ -1697,19 +1697,19 @@ mhchemParser.stateMachines = {
|
|
|
1697
1697
|
"*": {action_: "state of aggregation"},
|
|
1698
1698
|
},
|
|
1699
1699
|
i$: {
|
|
1700
|
-
|
|
1700
|
+
0: {nextState: "!f", revisit: true},
|
|
1701
1701
|
},
|
|
1702
1702
|
"(KV letters),": {
|
|
1703
|
-
|
|
1703
|
+
0: {action_: "rm", nextState: "0"},
|
|
1704
1704
|
},
|
|
1705
1705
|
formula$: {
|
|
1706
|
-
|
|
1706
|
+
0: {nextState: "f", revisit: true},
|
|
1707
1707
|
},
|
|
1708
1708
|
"1/2$": {
|
|
1709
|
-
|
|
1709
|
+
0: {action_: "1/2"},
|
|
1710
1710
|
},
|
|
1711
1711
|
else: {
|
|
1712
|
-
|
|
1712
|
+
0: {nextState: "!f", revisit: true},
|
|
1713
1713
|
},
|
|
1714
1714
|
"${(...)}$|$(...)$": {
|
|
1715
1715
|
"*": {action_: "tex-math"},
|
|
@@ -1772,13 +1772,13 @@ mhchemParser.stateMachines = {
|
|
|
1772
1772
|
"*": {},
|
|
1773
1773
|
},
|
|
1774
1774
|
x$: {
|
|
1775
|
-
|
|
1775
|
+
0: {nextState: "!f", revisit: true},
|
|
1776
1776
|
},
|
|
1777
1777
|
formula$: {
|
|
1778
|
-
|
|
1778
|
+
0: {nextState: "f", revisit: true},
|
|
1779
1779
|
},
|
|
1780
1780
|
else: {
|
|
1781
|
-
|
|
1781
|
+
0: {nextState: "!f", revisit: true},
|
|
1782
1782
|
},
|
|
1783
1783
|
"-9.,9 no missing 0": {
|
|
1784
1784
|
"*": {action_: "9,9"},
|
|
@@ -1948,10 +1948,10 @@ mhchemParser.stateMachines = {
|
|
|
1948
1948
|
"0|a": {action_: "copy"},
|
|
1949
1949
|
},
|
|
1950
1950
|
"(-)(9)^(-9)": {
|
|
1951
|
-
|
|
1951
|
+
0: {action_: "number^", nextState: "a"},
|
|
1952
1952
|
},
|
|
1953
1953
|
"(-)(9.,9)(e)(99)": {
|
|
1954
|
-
|
|
1954
|
+
0: {action_: "enumber", nextState: "a"},
|
|
1955
1955
|
},
|
|
1956
1956
|
space: {
|
|
1957
1957
|
"0|a": {},
|
|
@@ -2112,11 +2112,11 @@ mhchemParser.stateMachines = {
|
|
|
2112
2112
|
"*": {action_: ["output", "space"], nextState: "0"},
|
|
2113
2113
|
},
|
|
2114
2114
|
"^{(...)}|^(-1)": {
|
|
2115
|
-
|
|
2115
|
+
1: {action_: "^(-1)"},
|
|
2116
2116
|
},
|
|
2117
2117
|
"-9.,9": {
|
|
2118
|
-
|
|
2119
|
-
|
|
2118
|
+
0: {action_: "rm=", nextState: "0"},
|
|
2119
|
+
1: {action_: "^(-1)", nextState: "0"},
|
|
2120
2120
|
},
|
|
2121
2121
|
"{...}|else": {
|
|
2122
2122
|
"*": {action_: "rm=", nextState: "1"},
|
|
@@ -2156,14 +2156,14 @@ mhchemParser.stateMachines = {
|
|
|
2156
2156
|
"pu-9,9": {
|
|
2157
2157
|
transitions: mhchemParser.createTransitions({
|
|
2158
2158
|
empty: {
|
|
2159
|
-
|
|
2159
|
+
0: {action_: "output-0"},
|
|
2160
2160
|
o: {action_: "output-o"},
|
|
2161
2161
|
},
|
|
2162
2162
|
",": {
|
|
2163
|
-
|
|
2163
|
+
0: {action_: ["output-0", "comma"], nextState: "o"},
|
|
2164
2164
|
},
|
|
2165
2165
|
".": {
|
|
2166
|
-
|
|
2166
|
+
0: {action_: ["output-0", "copy"], nextState: "o"},
|
|
2167
2167
|
},
|
|
2168
2168
|
else: {
|
|
2169
2169
|
"*": {action_: "text="},
|