@khanacademy/perseus-editor 4.1.4 → 4.1.6
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/dist/es/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -6
- package/.babelrc.js +0 -8
- package/.eslintrc.js +0 -12
- package/CHANGELOG.md +0 -1146
- package/src/README.md +0 -7
- package/src/__stories__/editor-page.stories.tsx +0 -65
- package/src/__stories__/editor.stories.tsx +0 -134
- package/src/__stories__/item-editor.stories.tsx +0 -41
- package/src/__stories__/tex-error-view.stories.tsx +0 -26
- package/src/__testdata__/input-number.testdata.ts +0 -27
- package/src/__tests__/editor.test.tsx +0 -142
- package/src/__tests__/hint-editor.test.tsx +0 -83
- package/src/__tests__/i18n.test.ts +0 -501
- package/src/__tests__/integration.test.ts +0 -5
- package/src/__tests__/item-extras-editor.test.tsx +0 -85
- package/src/__tests__/traversal.test.ts +0 -377
- package/src/all-editors.test.ts +0 -16
- package/src/all-editors.ts +0 -83
- package/src/all-widgets.ts +0 -7
- package/src/article-editor.tsx +0 -438
- package/src/components/__stories__/blur-input.stories.tsx +0 -22
- package/src/components/__stories__/section-control-button.stories.tsx +0 -26
- package/src/components/__tests__/blur-input.test.tsx +0 -67
- package/src/components/blur-input.tsx +0 -69
- package/src/components/checkbox.tsx +0 -194
- package/src/components/device-framer.tsx +0 -90
- package/src/components/drag-target.tsx +0 -87
- package/src/components/dropdown-option.tsx +0 -311
- package/src/components/form-wrapped-text-field.tsx +0 -245
- package/src/components/graph-points-count-selector.tsx +0 -31
- package/src/components/graph-settings.tsx +0 -627
- package/src/components/graph-type-selector.tsx +0 -31
- package/src/components/hover-behavior.ts +0 -177
- package/src/components/json-editor.tsx +0 -121
- package/src/components/link.ts +0 -173
- package/src/components/section-control-button.tsx +0 -53
- package/src/components/segment-count-selector.tsx +0 -27
- package/src/components/simple-button.tsx +0 -85
- package/src/components/sortable.tsx +0 -187
- package/src/components/util.ts +0 -38
- package/src/components/viewport-resizer.tsx +0 -72
- package/src/components/widget-editor.tsx +0 -222
- package/src/components/widget-select.tsx +0 -48
- package/src/diffs/__stories__/perseus-diff-wrapper.tsx +0 -11
- package/src/diffs/__stories__/structured-item-diff.stories.tsx +0 -855
- package/src/diffs/__stories__/tags-diff.stories.tsx +0 -36
- package/src/diffs/__stories__/text-diff.stories.tsx +0 -35
- package/src/diffs/__tests__/split-diff.test.ts +0 -33
- package/src/diffs/__tests__/string-array-diff.test.ts +0 -73
- package/src/diffs/__tests__/structured-item-diff.test.ts +0 -433
- package/src/diffs/__tests__/widget-diff-performer.test.ts +0 -43
- package/src/diffs/article-diff.tsx +0 -69
- package/src/diffs/item-diff.tsx +0 -76
- package/src/diffs/renderer-diff.tsx +0 -137
- package/src/diffs/split-diff.ts +0 -31
- package/src/diffs/string-array-diff.ts +0 -74
- package/src/diffs/structured-item-diff.tsx +0 -275
- package/src/diffs/tags-diff.tsx +0 -49
- package/src/diffs/text-diff.tsx +0 -193
- package/src/diffs/widget-diff-performer.ts +0 -69
- package/src/diffs/widget-diff.tsx +0 -290
- package/src/editor-page.tsx +0 -325
- package/src/editor.tsx +0 -1099
- package/src/hint-editor.tsx +0 -469
- package/src/i18n.ts +0 -140
- package/src/iframe-content-renderer.tsx +0 -188
- package/src/index.ts +0 -30
- package/src/item-editor.tsx +0 -158
- package/src/item-extras-editor.tsx +0 -230
- package/src/katex-mhchem/index.js +0 -73
- package/src/katex-mhchem/parser.js +0 -2659
- package/src/multirenderer-editor.tsx +0 -1061
- package/src/stateful-article-editor.tsx +0 -173
- package/src/stateful-editor-page.tsx +0 -88
- package/src/styles/perseus-editor.less +0 -1321
- package/src/testing-widgets.ts +0 -11
- package/src/tex-error-view.tsx +0 -90
- package/src/util/points.test.ts +0 -24
- package/src/util/points.ts +0 -13
- package/src/util/register-all-widgets-and-editors-for-testing.test.ts +0 -17
- package/src/util/register-all-widgets-and-editors-for-testing.ts +0 -17
- package/src/version.ts +0 -10
- package/src/widgets/__stories__/categorizer-editor.stories.tsx +0 -24
- package/src/widgets/__stories__/definition-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/dropdown-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/explanation-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/expression-editor.stories.tsx +0 -122
- package/src/widgets/__stories__/image-editor.stories.tsx +0 -72
- package/src/widgets/__stories__/input-number-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/interaction-editor.stories.tsx +0 -37
- package/src/widgets/__stories__/label-image-editor.stories.tsx +0 -99
- package/src/widgets/__stories__/matcher-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/number-line-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/numeric-input-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/radio-editor.stories.tsx +0 -116
- package/src/widgets/__stories__/sorter-editor.stories.tsx +0 -18
- package/src/widgets/__tests__/categorizer-editor.test.tsx +0 -51
- package/src/widgets/__tests__/definition-editor.test.tsx +0 -41
- package/src/widgets/__tests__/dropdown-editor.test.tsx +0 -57
- package/src/widgets/__tests__/explanation-editor.test.tsx +0 -59
- package/src/widgets/__tests__/expression-editor.test.tsx +0 -403
- package/src/widgets/__tests__/input-number-editor.test.tsx +0 -128
- package/src/widgets/__tests__/matcher-editor.test.tsx +0 -47
- package/src/widgets/__tests__/number-line-editor.test.tsx +0 -144
- package/src/widgets/__tests__/numeric-input-editor.test.tsx +0 -177
- package/src/widgets/__tests__/radio-editor.test.tsx +0 -118
- package/src/widgets/__tests__/sorter-editor.test.tsx +0 -55
- package/src/widgets/categorizer-editor.tsx +0 -104
- package/src/widgets/cs-program-editor.tsx +0 -256
- package/src/widgets/definition-editor.tsx +0 -77
- package/src/widgets/deprecated-standin-editor.tsx +0 -29
- package/src/widgets/dropdown-editor.tsx +0 -211
- package/src/widgets/example-graphie-widget-editor.tsx +0 -70
- package/src/widgets/example-graphie-widget.tsx +0 -172
- package/src/widgets/example-widget-editor.tsx +0 -62
- package/src/widgets/example-widget.tsx +0 -154
- package/src/widgets/explanation-editor.tsx +0 -92
- package/src/widgets/expression-editor.tsx +0 -557
- package/src/widgets/graded-group-editor.tsx +0 -161
- package/src/widgets/graded-group-set-editor.tsx +0 -104
- package/src/widgets/grapher-editor.tsx +0 -155
- package/src/widgets/group-editor.tsx +0 -83
- package/src/widgets/iframe-editor.tsx +0 -202
- package/src/widgets/image-editor.tsx +0 -367
- package/src/widgets/input-number-editor.tsx +0 -288
- package/src/widgets/interaction-editor/constraint-editor.tsx +0 -134
- package/src/widgets/interaction-editor/function-editor.tsx +0 -108
- package/src/widgets/interaction-editor/index.ts +0 -3
- package/src/widgets/interaction-editor/interaction-editor.tsx +0 -749
- package/src/widgets/interaction-editor/label-editor.tsx +0 -87
- package/src/widgets/interaction-editor/line-editor.tsx +0 -125
- package/src/widgets/interaction-editor/mathquill-input.tsx +0 -81
- package/src/widgets/interaction-editor/movable-line-editor.tsx +0 -121
- package/src/widgets/interaction-editor/movable-point-editor.tsx +0 -89
- package/src/widgets/interaction-editor/parametric-editor.tsx +0 -117
- package/src/widgets/interaction-editor/point-editor.tsx +0 -72
- package/src/widgets/interaction-editor/rectangle-editor.tsx +0 -96
- package/src/widgets/interactive-graph-editor.tsx +0 -571
- package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +0 -82
- package/src/widgets/label-image/__stories__/behavior.stories.tsx +0 -31
- package/src/widgets/label-image/__stories__/marker.stories.tsx +0 -75
- package/src/widgets/label-image/__stories__/question-markers.stories.tsx +0 -107
- package/src/widgets/label-image/__stories__/select-image.stories.tsx +0 -59
- package/src/widgets/label-image/answer-choices.tsx +0 -231
- package/src/widgets/label-image/behavior.tsx +0 -122
- package/src/widgets/label-image/marker.tsx +0 -290
- package/src/widgets/label-image/question-markers.tsx +0 -176
- package/src/widgets/label-image/select-image.tsx +0 -81
- package/src/widgets/label-image-editor.tsx +0 -252
- package/src/widgets/lights-puzzle-editor.tsx +0 -278
- package/src/widgets/matcher-editor.tsx +0 -149
- package/src/widgets/matrix-editor.tsx +0 -156
- package/src/widgets/measurer-editor.tsx +0 -253
- package/src/widgets/molecule-editor.tsx +0 -64
- package/src/widgets/number-line-editor.tsx +0 -512
- package/src/widgets/numeric-input-editor.tsx +0 -536
- package/src/widgets/orderer-editor.tsx +0 -172
- package/src/widgets/passage-editor.tsx +0 -117
- package/src/widgets/passage-ref-editor.tsx +0 -80
- package/src/widgets/passage-ref-target-editor.tsx +0 -49
- package/src/widgets/plotter-editor.tsx +0 -542
- package/src/widgets/radio/editor.tsx +0 -398
- package/src/widgets/reaction-diagram-editor.tsx +0 -131
- package/src/widgets/sequence-editor.tsx +0 -205
- package/src/widgets/simple-markdown-tester-editor.tsx +0 -86
- package/src/widgets/simple-markdown-tester.tsx +0 -92
- package/src/widgets/simulator-editor.tsx +0 -146
- package/src/widgets/sorter-editor.tsx +0 -103
- package/src/widgets/table-editor.tsx +0 -164
- package/src/widgets/unit-editor.tsx +0 -299
- package/src/widgets/video-editor.tsx +0 -73
- package/tsconfig-build.json +0 -22
- package/tsconfig-build.tsbuildinfo +0 -1
package/src/testing-widgets.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ExampleGraphieWidget from "./widgets/example-graphie-widget";
|
|
2
|
-
import ExampleWidget from "./widgets/example-widget";
|
|
3
|
-
import SimpleMarkdownTester from "./widgets/simple-markdown-tester";
|
|
4
|
-
|
|
5
|
-
import type {WidgetExports} from "@khanacademy/perseus";
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
ExampleGraphieWidget,
|
|
9
|
-
ExampleWidget,
|
|
10
|
-
SimpleMarkdownTester,
|
|
11
|
-
] as ReadonlyArray<WidgetExports>;
|
package/src/tex-error-view.tsx
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
2
|
-
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon";
|
|
3
|
-
import caretRight from "@phosphor-icons/core/bold/caret-right-bold.svg";
|
|
4
|
-
import {StyleSheet} from "aphrodite";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
errorList: ReadonlyArray<{math: string; message: string}>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type State = {
|
|
12
|
-
showErrors: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Displays a collapsable list of TeX rendering errors.
|
|
17
|
-
*/
|
|
18
|
-
class TexErrorView extends React.Component<Props, State> {
|
|
19
|
-
state: State = {
|
|
20
|
-
showErrors: false,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
handleToggleTexErrors: (arg1: React.MouseEvent) => void = (e) => {
|
|
24
|
-
this.setState({showErrors: !this.state.showErrors});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
render(): React.ReactNode {
|
|
28
|
-
const {errorList} = this.props;
|
|
29
|
-
const {showErrors} = this.state;
|
|
30
|
-
|
|
31
|
-
const iconStyle = showErrors
|
|
32
|
-
? styles.iconExpanded
|
|
33
|
-
: styles.iconCollapsed;
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<View style={styles.errorContainer}>
|
|
37
|
-
<View style={styles.title} onClick={this.handleToggleTexErrors}>
|
|
38
|
-
<PhosphorIcon icon={caretRight} style={iconStyle} />
|
|
39
|
-
TeX Errors ({errorList.length})
|
|
40
|
-
</View>
|
|
41
|
-
{showErrors && (
|
|
42
|
-
<View style={styles.errorExplanation}>
|
|
43
|
-
If your math doesn't display correctly, these errors
|
|
44
|
-
might help you troubleshoot. Message #content-kitchen
|
|
45
|
-
for help.
|
|
46
|
-
</View>
|
|
47
|
-
)}
|
|
48
|
-
{showErrors &&
|
|
49
|
-
errorList.map((e, index) => (
|
|
50
|
-
<View style={styles.error} key={index}>
|
|
51
|
-
<View style={{color: "red"}}>{e.math}</View>
|
|
52
|
-
<View>{e.message}</View>
|
|
53
|
-
</View>
|
|
54
|
-
))}
|
|
55
|
-
</View>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const styles = StyleSheet.create({
|
|
61
|
-
title: {
|
|
62
|
-
backgroundColor: "#eee",
|
|
63
|
-
fontSize: "1.25em",
|
|
64
|
-
padding: "4px 10px",
|
|
65
|
-
cursor: "pointer",
|
|
66
|
-
display: "flex",
|
|
67
|
-
flexDirection: "row",
|
|
68
|
-
alignItems: "center",
|
|
69
|
-
},
|
|
70
|
-
errorContainer: {
|
|
71
|
-
border: "1px solid #ddd",
|
|
72
|
-
borderTop: "none",
|
|
73
|
-
},
|
|
74
|
-
errorExplanation: {
|
|
75
|
-
padding: "4px 10px",
|
|
76
|
-
backgroundColor: "pink",
|
|
77
|
-
},
|
|
78
|
-
error: {
|
|
79
|
-
padding: "4px 10px",
|
|
80
|
-
},
|
|
81
|
-
iconCollapsed: {
|
|
82
|
-
transition: ".15s",
|
|
83
|
-
},
|
|
84
|
-
iconExpanded: {
|
|
85
|
-
transform: "rotate(90deg)",
|
|
86
|
-
transition: ".15s",
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
export default TexErrorView;
|
package/src/util/points.test.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {parsePointCount} from "./points";
|
|
2
|
-
|
|
3
|
-
describe("parsePointCount", () => {
|
|
4
|
-
it.each([
|
|
5
|
-
// Special case, 0 means unlimited points
|
|
6
|
-
["0", "unlimited"],
|
|
7
|
-
// Regular cases, ints as a string
|
|
8
|
-
["1", 1],
|
|
9
|
-
["2", 2],
|
|
10
|
-
["3", 3],
|
|
11
|
-
["4", 4],
|
|
12
|
-
["5", 5],
|
|
13
|
-
["6", 6],
|
|
14
|
-
["7", 7],
|
|
15
|
-
["8", 8],
|
|
16
|
-
["9", 9],
|
|
17
|
-
["10", 10],
|
|
18
|
-
// Parse-error cases - all map to "unlimited"
|
|
19
|
-
["non-numeric string", "unlimited"],
|
|
20
|
-
["one", "unlimited"],
|
|
21
|
-
])("Should parse %s to %s", (input, expected) => {
|
|
22
|
-
expect(parsePointCount(input)).toEqual(expected);
|
|
23
|
-
});
|
|
24
|
-
});
|
package/src/util/points.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const UNLIMITED = "unlimited" as const;
|
|
2
|
-
export type PointValue = number | typeof UNLIMITED;
|
|
3
|
-
|
|
4
|
-
// Parses a string (ostensibly from some UI element that only supports string
|
|
5
|
-
// types, such as a <select />) into a numeric point count or the special sigil
|
|
6
|
-
// "unlimited". Note that 0 is a special case, and means "unlimited".
|
|
7
|
-
export const parsePointCount = (points: string): PointValue => {
|
|
8
|
-
const parsed = parseInt(points, 10);
|
|
9
|
-
if (isNaN(parsed)) {
|
|
10
|
-
return UNLIMITED;
|
|
11
|
-
}
|
|
12
|
-
return parsed === 0 ? UNLIMITED : parsed;
|
|
13
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {Widgets} from "@khanacademy/perseus";
|
|
2
|
-
|
|
3
|
-
import {registerAllWidgetsAndEditorsForTesting} from "./register-all-widgets-and-editors-for-testing";
|
|
4
|
-
|
|
5
|
-
describe("Registering all widgets and editors", () => {
|
|
6
|
-
it("should have an editor for every widget", () => {
|
|
7
|
-
registerAllWidgetsAndEditorsForTesting();
|
|
8
|
-
|
|
9
|
-
const allWidgetsTypes = Widgets.getAllWidgetTypes();
|
|
10
|
-
|
|
11
|
-
expect(allWidgetsTypes).not.toContain("undefined");
|
|
12
|
-
|
|
13
|
-
for (const widgetType of allWidgetsTypes) {
|
|
14
|
-
expect(Widgets.getEditor(widgetType)).toBeTruthy();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Some tests require some or all of the widgets and editors to be registered
|
|
3
|
-
* in order for them to work. Requiring this file will register all of the
|
|
4
|
-
* widgets and editors.
|
|
5
|
-
*/
|
|
6
|
-
import {Widgets} from "@khanacademy/perseus";
|
|
7
|
-
|
|
8
|
-
import allEditors from "../all-editors";
|
|
9
|
-
import allWidgets from "../all-widgets";
|
|
10
|
-
|
|
11
|
-
export const registerAllWidgetsAndEditorsForTesting = () => {
|
|
12
|
-
Widgets.registerWidgets(allWidgets);
|
|
13
|
-
Widgets.registerEditors(allEditors);
|
|
14
|
-
|
|
15
|
-
Widgets.replaceEditor("transformer", "deprecated-standin");
|
|
16
|
-
Widgets.replaceWidget("transformer", "deprecated-standin");
|
|
17
|
-
};
|
package/src/version.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
2
|
-
// version number during the release build.
|
|
3
|
-
// In dev, you'll never see the version number.
|
|
4
|
-
|
|
5
|
-
import {addLibraryVersionToPerseusDebug} from "@khanacademy/perseus-core";
|
|
6
|
-
|
|
7
|
-
const libName = "@khanacademy/perseus-editor";
|
|
8
|
-
export const libVersion = "__lib_version__";
|
|
9
|
-
|
|
10
|
-
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {ApiOptions} from "@khanacademy/perseus";
|
|
2
|
-
import {action} from "@storybook/addon-actions";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import CategorizerEditor from "../categorizer-editor";
|
|
6
|
-
|
|
7
|
-
type StoryArgs = Record<any, any>;
|
|
8
|
-
|
|
9
|
-
type Story = {
|
|
10
|
-
title: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
title: "Perseus/Editor/Widgets/Categorizer Editor",
|
|
15
|
-
} as Story;
|
|
16
|
-
|
|
17
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
18
|
-
return (
|
|
19
|
-
<CategorizerEditor
|
|
20
|
-
onChange={action("onChange")}
|
|
21
|
-
apiOptions={ApiOptions.defaults}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import DefinitionEditor from "../definition-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/Definition Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <DefinitionEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import DropdownEditor from "../dropdown-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/Dropdown Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <DropdownEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import ExplanationEditor from "../explanation-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/Explanation Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <ExplanationEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
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
|
-
onChange={(props: PerseusExpressionWidgetOptions) => {
|
|
66
|
-
this.setState({
|
|
67
|
-
...props,
|
|
68
|
-
});
|
|
69
|
-
}}
|
|
70
|
-
/>
|
|
71
|
-
</div>
|
|
72
|
-
<RendererWithDebugUI
|
|
73
|
-
question={this.mergeQuestionWithState()}
|
|
74
|
-
apiOptions={apiOptions}
|
|
75
|
-
reviewMode={true}
|
|
76
|
-
/>
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const Debug = (args: StoryArgs): React.ReactElement => {
|
|
83
|
-
return <WithDebug />;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const question: PerseusRenderer = {
|
|
87
|
-
content:
|
|
88
|
-
"This is a cool expression question\n\n[[\u2603 expression 1]]\n\n",
|
|
89
|
-
images: {},
|
|
90
|
-
widgets: {
|
|
91
|
-
"expression 1": {
|
|
92
|
-
alignment: "default",
|
|
93
|
-
graded: true,
|
|
94
|
-
options: {
|
|
95
|
-
answerForms: [
|
|
96
|
-
{
|
|
97
|
-
considered: "correct",
|
|
98
|
-
form: true,
|
|
99
|
-
key: "0",
|
|
100
|
-
simplify: false,
|
|
101
|
-
value: "16+88i",
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
buttonSets: ["basic"],
|
|
105
|
-
functions: ["f", "g", "h"],
|
|
106
|
-
times: false,
|
|
107
|
-
},
|
|
108
|
-
static: false,
|
|
109
|
-
type: "expression",
|
|
110
|
-
version: {major: 1, minor: 0},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const styles = StyleSheet.create({
|
|
116
|
-
wrapper: {
|
|
117
|
-
padding: 50,
|
|
118
|
-
},
|
|
119
|
-
editorWrapper: {
|
|
120
|
-
paddingBottom: 100,
|
|
121
|
-
},
|
|
122
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {ApiOptions} from "@khanacademy/perseus";
|
|
2
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
3
|
-
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
4
|
-
import {LabelSmall} from "@khanacademy/wonder-blocks-typography";
|
|
5
|
-
import {action} from "@storybook/addon-actions";
|
|
6
|
-
import {StyleSheet} from "aphrodite";
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
|
|
9
|
-
import ImageEditor from "../image-editor";
|
|
10
|
-
|
|
11
|
-
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
12
|
-
|
|
13
|
-
type StoryArgs = Record<any, any>;
|
|
14
|
-
|
|
15
|
-
type Story = {
|
|
16
|
-
title: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
title: "Perseus/Editor/Widgets/Image Editor",
|
|
21
|
-
} as Story;
|
|
22
|
-
|
|
23
|
-
const styles = StyleSheet.create({
|
|
24
|
-
wrapper: {
|
|
25
|
-
// The maximum width of a widget in the editor.
|
|
26
|
-
width: 338,
|
|
27
|
-
margin: 20,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const onChangeAction = action("onChange");
|
|
32
|
-
|
|
33
|
-
const WithState = () => {
|
|
34
|
-
const widgetRef = React.useRef<ImageEditor>(null);
|
|
35
|
-
const [state, setState] = React.useState<
|
|
36
|
-
Partial<PropsFor<typeof ImageEditor>>
|
|
37
|
-
>({
|
|
38
|
-
backgroundImage: {
|
|
39
|
-
url: "https://ka-perseus-images.s3.amazonaws.com/2ee5fc32e35c5178373b39fd304b325b2994c913.png",
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<View style={styles.wrapper}>
|
|
45
|
-
<LabelSmall
|
|
46
|
-
style={{fontStyle: "italic", marginBottom: Spacing.small_12}}
|
|
47
|
-
>
|
|
48
|
-
<b>Note</b> that this editor has a known-issue where it does not
|
|
49
|
-
calculate the image dimensions initially if they aren't
|
|
50
|
-
provided. It does update the dimensions when you blur the 'Image
|
|
51
|
-
url:' field.
|
|
52
|
-
</LabelSmall>
|
|
53
|
-
<ImageEditor
|
|
54
|
-
{...state}
|
|
55
|
-
apiOptions={ApiOptions.defaults}
|
|
56
|
-
onChange={(props) => {
|
|
57
|
-
onChangeAction(props);
|
|
58
|
-
|
|
59
|
-
setState({
|
|
60
|
-
...widgetRef.current?.serialize(),
|
|
61
|
-
...props,
|
|
62
|
-
});
|
|
63
|
-
}}
|
|
64
|
-
ref={widgetRef}
|
|
65
|
-
/>
|
|
66
|
-
</View>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
71
|
-
return <WithState />;
|
|
72
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import InputNumberEditor from "../input-number-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/InputNumber Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <InputNumberEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {useState} from "react";
|
|
3
|
-
|
|
4
|
-
import InteractionEditor from "../interaction-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/Interaction Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
const [elements, setElements] = useState();
|
|
18
|
-
const [graph, setGraph] = useState();
|
|
19
|
-
|
|
20
|
-
function handleChange(next) {
|
|
21
|
-
if (next.graph) {
|
|
22
|
-
setGraph(next.graph);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (next.elements) {
|
|
26
|
-
setElements(next.elements);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<InteractionEditor
|
|
32
|
-
onChange={handleChange}
|
|
33
|
-
elements={elements}
|
|
34
|
-
graph={graph}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
2
|
-
import {StyleSheet, css} from "aphrodite";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import LabelImageEditor from "../label-image-editor";
|
|
6
|
-
|
|
7
|
-
import type {MarkerType} from "@khanacademy/perseus";
|
|
8
|
-
|
|
9
|
-
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
10
|
-
type Empty = Record<string, never>;
|
|
11
|
-
|
|
12
|
-
type StoryArgs = Record<any, any>;
|
|
13
|
-
|
|
14
|
-
type Story = {
|
|
15
|
-
title: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
title: "Perseus/Editor/Widgets/Label Image Editor",
|
|
20
|
-
} as Story;
|
|
21
|
-
|
|
22
|
-
const styles = StyleSheet.create({
|
|
23
|
-
wrapper: {
|
|
24
|
-
// The maximum width of a widget in the editor.
|
|
25
|
-
width: 338,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
type State = {
|
|
30
|
-
imageAlt: string;
|
|
31
|
-
choices: ReadonlyArray<string>;
|
|
32
|
-
imageUrl: string;
|
|
33
|
-
imageWidth: number;
|
|
34
|
-
imageHeight: number;
|
|
35
|
-
markers: ReadonlyArray<MarkerType>;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
class WithState extends React.Component<Empty, State> {
|
|
39
|
-
// @ts-expect-error [FEI-5003] - TS2564 - Property '_widget' has no initializer and is not definitely assigned in the constructor.
|
|
40
|
-
_widget: LabelImageEditor;
|
|
41
|
-
|
|
42
|
-
state = {
|
|
43
|
-
imageAlt: "Map of Europe",
|
|
44
|
-
choices: [
|
|
45
|
-
"Lamborghini",
|
|
46
|
-
"BMW",
|
|
47
|
-
"Volkswagen",
|
|
48
|
-
"Fiat",
|
|
49
|
-
"Porsche",
|
|
50
|
-
"Ferrari",
|
|
51
|
-
],
|
|
52
|
-
imageUrl:
|
|
53
|
-
"https://ka-perseus-images.s3.amazonaws.com/2ee5fc32e35c5178373b39fd304b325b2994c913.png",
|
|
54
|
-
imageWidth: 1280,
|
|
55
|
-
imageHeight: 1024,
|
|
56
|
-
markers: [
|
|
57
|
-
{
|
|
58
|
-
answers: ["BMW", "Volkswagen", "Porsche"],
|
|
59
|
-
label: "Germany",
|
|
60
|
-
x: 37.3,
|
|
61
|
-
y: 53.6,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
answers: [],
|
|
65
|
-
label: "",
|
|
66
|
-
x: 21,
|
|
67
|
-
y: 46,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
answers: ["Lamborghini", "Fiat", "Ferrari"],
|
|
71
|
-
label: "Italy",
|
|
72
|
-
x: 41.4,
|
|
73
|
-
y: 78.8,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
render(): React.ReactNode {
|
|
79
|
-
return (
|
|
80
|
-
<div className={css(styles.wrapper)}>
|
|
81
|
-
<LabelImageEditor
|
|
82
|
-
{...this.state}
|
|
83
|
-
onChange={(props) =>
|
|
84
|
-
this.setState({
|
|
85
|
-
...this._widget.serialize(),
|
|
86
|
-
...props,
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
// @ts-expect-error [FEI-5003] - TS2322 - Type 'LabelImageEditor | null' is not assignable to type 'LabelImageEditor'.
|
|
90
|
-
ref={(widget) => (this._widget = widget)}
|
|
91
|
-
/>
|
|
92
|
-
</div>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
98
|
-
return <WithState />;
|
|
99
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import MatcherEditor from "../matcher-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/Matcher Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <MatcherEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import NumberLineEditor from "../number-line-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/Number Line Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <NumberLineEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import NumericInputEditor from "../numeric-input-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/NumericInput Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <NumericInputEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|