@khanacademy/perseus-editor 2.3.10 → 2.3.11
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 +9 -0
- package/dist/es/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/widgets/interactive-graph-editor.d.ts +46 -46
- package/dist/widgets/interactive-graph-editor.js.flow +276 -138
- package/package.json +2 -2
- package/src/widgets/__stories__/expression-editor.stories.tsx +123 -0
- package/src/widgets/interactive-graph-editor.tsx +2 -2
- package/tsconfig-build.tsbuildinfo +1 -1
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.3.
|
|
6
|
+
"version": "2.3.11",
|
|
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": "^6.
|
|
26
|
+
"@khanacademy/perseus": "^6.6.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@khanacademy/wonder-blocks-button": "^4.0.8",
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {StyleSheet, css} from "aphrodite";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import {RendererWithDebugUI} from "../../../../../testing/renderer-with-debug-ui";
|
|
5
|
+
import ExpressionEditor from "../expression-editor";
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
PerseusRenderer,
|
|
9
|
+
APIOptions,
|
|
10
|
+
PerseusExpressionWidgetOptions,
|
|
11
|
+
} from "@khanacademy/perseus";
|
|
12
|
+
|
|
13
|
+
type StoryArgs = Record<any, any>;
|
|
14
|
+
|
|
15
|
+
type Story = {
|
|
16
|
+
title: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
title: "Perseus/Editor/Widgets/Expression Editor",
|
|
21
|
+
} as Story;
|
|
22
|
+
|
|
23
|
+
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
24
|
+
type Empty = Record<string, never>;
|
|
25
|
+
|
|
26
|
+
type State = PerseusExpressionWidgetOptions;
|
|
27
|
+
|
|
28
|
+
class WithDebug extends React.Component<Empty, State> {
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super(props);
|
|
31
|
+
|
|
32
|
+
const baseWidget = question.widgets["expression 1"].options;
|
|
33
|
+
this.state = {
|
|
34
|
+
answerForms: baseWidget.answerForms,
|
|
35
|
+
times: baseWidget.times,
|
|
36
|
+
buttonSets: baseWidget.buttonSets,
|
|
37
|
+
functions: baseWidget.functions,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
mergeQuestionWithState() {
|
|
42
|
+
return {
|
|
43
|
+
...question,
|
|
44
|
+
widgets: {
|
|
45
|
+
...question.widgets,
|
|
46
|
+
"expression 1": {
|
|
47
|
+
...question.widgets["expression 1"],
|
|
48
|
+
options: {
|
|
49
|
+
...question.widgets["expression 1"].options,
|
|
50
|
+
...this.state,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
render(): React.ReactNode {
|
|
58
|
+
const apiOptions: APIOptions = Object.freeze({});
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className={css(styles.wrapper)}>
|
|
62
|
+
<div className={css(styles.editorWrapper)}>
|
|
63
|
+
<ExpressionEditor
|
|
64
|
+
{...this.state}
|
|
65
|
+
apiOptions={apiOptions}
|
|
66
|
+
onChange={(props) => {
|
|
67
|
+
this.setState({
|
|
68
|
+
...props,
|
|
69
|
+
});
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
<RendererWithDebugUI
|
|
74
|
+
question={this.mergeQuestionWithState()}
|
|
75
|
+
apiOptions={apiOptions}
|
|
76
|
+
reviewMode={true}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const Debug = (args: StoryArgs): React.ReactElement => {
|
|
84
|
+
return <WithDebug />;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const question: PerseusRenderer = {
|
|
88
|
+
content:
|
|
89
|
+
"This is a cool expression question\n\n[[\u2603 expression 1]]\n\n",
|
|
90
|
+
images: {},
|
|
91
|
+
widgets: {
|
|
92
|
+
"expression 1": {
|
|
93
|
+
alignment: "default",
|
|
94
|
+
graded: true,
|
|
95
|
+
options: {
|
|
96
|
+
answerForms: [
|
|
97
|
+
{
|
|
98
|
+
considered: "correct",
|
|
99
|
+
form: true,
|
|
100
|
+
key: "0",
|
|
101
|
+
simplify: false,
|
|
102
|
+
value: "16+88i",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
buttonSets: ["basic"],
|
|
106
|
+
functions: ["f", "g", "h"],
|
|
107
|
+
times: false,
|
|
108
|
+
},
|
|
109
|
+
static: false,
|
|
110
|
+
type: "expression",
|
|
111
|
+
version: {major: 1, minor: 0},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const styles = StyleSheet.create({
|
|
117
|
+
wrapper: {
|
|
118
|
+
padding: 50,
|
|
119
|
+
},
|
|
120
|
+
editorWrapper: {
|
|
121
|
+
paddingBottom: 100,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
@@ -81,13 +81,13 @@ type Props = {
|
|
|
81
81
|
|
|
82
82
|
valid: boolean;
|
|
83
83
|
backgroundImage: PerseusImageBackground;
|
|
84
|
-
markings: string; //
|
|
84
|
+
markings: string; // TODO(jeremy)
|
|
85
85
|
showProtractor: boolean;
|
|
86
86
|
showRuler: boolean;
|
|
87
87
|
showTooltips: boolean;
|
|
88
88
|
rulerLabel: string;
|
|
89
89
|
rulerTicks: number;
|
|
90
|
-
correct: any; //
|
|
90
|
+
correct: any; // TODO(jeremy)
|
|
91
91
|
|
|
92
92
|
graph: InteractiveGraphProps["graph"];
|
|
93
93
|
onChange: (props: Partial<Props>) => void;
|