@khanacademy/perseus-editor 2.15.3 → 2.15.5
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 +38 -0
- package/dist/editor-page.d.ts +4 -10
- package/dist/editor.d.ts +2 -2
- package/dist/es/index.js +362 -360
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +426 -425
- package/dist/index.js.map +1 -1
- package/dist/widgets/interaction-editor/function-editor.d.ts +26 -0
- package/dist/widgets/interaction-editor/index.d.ts +2 -0
- package/dist/widgets/interaction-editor/label-editor.d.ts +22 -0
- package/dist/widgets/interaction-editor/line-editor.d.ts +30 -0
- package/dist/widgets/interaction-editor/movable-line-editor.d.ts +32 -0
- package/dist/widgets/interaction-editor/movable-point-editor.d.ts +28 -0
- package/dist/widgets/interaction-editor/parametric-editor.d.ts +28 -0
- package/dist/widgets/interaction-editor/point-editor.d.ts +20 -0
- package/dist/widgets/interaction-editor/rectangle-editor.d.ts +24 -0
- package/dist/widgets/interactive-graph-editor.d.ts +92 -92
- package/package.json +2 -2
- package/src/__stories__/editor-page.stories.tsx +65 -0
- package/src/__stories__/editor.stories.tsx +2 -4
- package/src/editor-page.tsx +5 -11
- package/src/editor.tsx +2 -2
- package/src/widgets/__stories__/categorizer-editor.stories.tsx +24 -0
- package/src/widgets/__stories__/definition-editor.stories.tsx +18 -0
- package/src/widgets/__stories__/dropdown-editor.stories.tsx +18 -0
- package/src/widgets/__stories__/explanation-editor.stories.tsx +18 -0
- package/src/widgets/__stories__/input-number-editor.stories.tsx +18 -0
- package/src/widgets/__stories__/interaction-editor.stories.tsx +24 -0
- package/src/widgets/__stories__/matcher-editor.stories.tsx +18 -0
- package/src/widgets/__stories__/number-line-editor.stories.tsx +18 -0
- package/src/widgets/__stories__/numeric-input-editor.stories.tsx +18 -0
- package/src/widgets/__stories__/radio-editor.stories.tsx +3 -3
- package/src/widgets/__stories__/sorter-editor.stories.tsx +18 -0
- package/src/widgets/__tests__/categorizer-editor.test.tsx +51 -0
- package/src/widgets/__tests__/definition-editor.test.tsx +41 -0
- package/src/widgets/__tests__/dropdown-editor.test.tsx +57 -0
- package/src/widgets/__tests__/explanation-editor.test.tsx +59 -0
- package/src/widgets/__tests__/input-number-editor.test.tsx +128 -0
- package/src/widgets/__tests__/matcher-editor.test.tsx +47 -0
- package/src/widgets/__tests__/number-line-editor.test.tsx +144 -0
- package/src/widgets/__tests__/numeric-input-editor.test.tsx +177 -0
- package/src/widgets/__tests__/radio-editor.test.tsx +118 -0
- package/src/widgets/__tests__/sorter-editor.test.tsx +55 -0
- package/src/widgets/dropdown-editor.tsx +1 -0
- package/src/widgets/input-number-editor.tsx +2 -0
- package/src/widgets/interaction-editor/function-editor.tsx +111 -0
- package/src/widgets/interaction-editor/index.ts +3 -0
- package/src/widgets/{interaction-editor.tsx → interaction-editor/interaction-editor.tsx} +14 -768
- package/src/widgets/interaction-editor/label-editor.tsx +91 -0
- package/src/widgets/interaction-editor/line-editor.tsx +129 -0
- package/src/widgets/interaction-editor/movable-line-editor.tsx +125 -0
- package/src/widgets/interaction-editor/movable-point-editor.tsx +92 -0
- package/src/widgets/interaction-editor/parametric-editor.tsx +122 -0
- package/src/widgets/interaction-editor/point-editor.tsx +79 -0
- package/src/widgets/interaction-editor/rectangle-editor.tsx +105 -0
- package/src/widgets/number-line-editor.tsx +16 -5
- package/src/widgets/numeric-input-editor.tsx +2 -0
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/widgets/{interaction → interaction-editor}/constraint-editor.d.ts +0 -0
- package/dist/widgets/{interaction-editor.d.ts → interaction-editor/interaction-editor.d.ts} +1 -1
- /package/src/widgets/{interaction → interaction-editor}/constraint-editor.tsx +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
components,
|
|
3
|
+
Changeable,
|
|
4
|
+
Dependencies,
|
|
5
|
+
EditorJsonify,
|
|
6
|
+
KhanColors,
|
|
7
|
+
ColorPicker,
|
|
8
|
+
DashPicker,
|
|
9
|
+
} from "@khanacademy/perseus";
|
|
10
|
+
import PropTypes from "prop-types";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import _ from "underscore";
|
|
13
|
+
|
|
14
|
+
const {MathInput, NumberInput} = components;
|
|
15
|
+
const {getDependencies} = Dependencies;
|
|
16
|
+
|
|
17
|
+
type FunctionEditorProps = any;
|
|
18
|
+
|
|
19
|
+
//
|
|
20
|
+
// Editor for function plots
|
|
21
|
+
//
|
|
22
|
+
// TODO(eater): Factor this out
|
|
23
|
+
//
|
|
24
|
+
class FunctionEditor extends React.Component<FunctionEditorProps> {
|
|
25
|
+
static propTypes = {
|
|
26
|
+
...Changeable.propTypes,
|
|
27
|
+
value: PropTypes.string,
|
|
28
|
+
rangeMin: PropTypes.string,
|
|
29
|
+
rangeMax: PropTypes.string,
|
|
30
|
+
color: PropTypes.string,
|
|
31
|
+
strokeDashArray: PropTypes.string,
|
|
32
|
+
strokeWidth: PropTypes.number,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
static defaultProps = {
|
|
36
|
+
value: "x",
|
|
37
|
+
rangeMin: "-10",
|
|
38
|
+
rangeMax: "10",
|
|
39
|
+
color: KhanColors.BLUE,
|
|
40
|
+
strokeDasharray: "",
|
|
41
|
+
strokeWidth: 2,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
change: (arg1: any, arg2?: any, arg3?: any) => any = (...args) => {
|
|
45
|
+
return Changeable.change.apply(this, args);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
serialize = () => {
|
|
49
|
+
return EditorJsonify.serialize.call(this);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
render(): React.ReactNode {
|
|
53
|
+
const {TeX} = getDependencies();
|
|
54
|
+
const analyticsStub = {onAnalyticsEvent: () => Promise.resolve()};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className="graph-settings">
|
|
58
|
+
<div className="perseus-widget-row">
|
|
59
|
+
<TeX>{this.props.funcName + "(x)="}</TeX>{" "}
|
|
60
|
+
<MathInput
|
|
61
|
+
buttonsVisible="never"
|
|
62
|
+
value={this.props.value}
|
|
63
|
+
onChange={this.change("value")}
|
|
64
|
+
analytics={analyticsStub}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
<div className="perseus-widget-row">
|
|
68
|
+
Range: <TeX>\Large(</TeX>
|
|
69
|
+
<MathInput
|
|
70
|
+
buttonsVisible="never"
|
|
71
|
+
value={this.props.rangeMin}
|
|
72
|
+
onChange={this.change("rangeMin")}
|
|
73
|
+
analytics={analyticsStub}
|
|
74
|
+
/>
|
|
75
|
+
<TeX>,</TeX>{" "}
|
|
76
|
+
<MathInput
|
|
77
|
+
buttonsVisible="never"
|
|
78
|
+
value={this.props.rangeMax}
|
|
79
|
+
onChange={this.change("rangeMax")}
|
|
80
|
+
analytics={analyticsStub}
|
|
81
|
+
/>
|
|
82
|
+
<TeX>\Large)</TeX>
|
|
83
|
+
</div>
|
|
84
|
+
<div className="perseus-widget-row">
|
|
85
|
+
<ColorPicker
|
|
86
|
+
value={this.props.color}
|
|
87
|
+
onChange={this.change("color")}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
<div className="perseus-widget-row">
|
|
91
|
+
<DashPicker
|
|
92
|
+
value={this.props.strokeDasharray}
|
|
93
|
+
onChange={this.change("strokeDasharray")}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
<div className="perseus-widget-row">
|
|
97
|
+
<div className="perseus-widget-left-col">
|
|
98
|
+
Width:{" "}
|
|
99
|
+
<NumberInput
|
|
100
|
+
value={this.props.strokeWidth}
|
|
101
|
+
placeholder={2}
|
|
102
|
+
onChange={this.change("strokeWidth")}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default FunctionEditor;
|