@khanacademy/perseus-editor 1.1.1 → 2.0.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/.babelrc.js +1 -1
- package/.eslintrc.js +1 -0
- package/CHANGELOG.md +14 -0
- package/dist/all-editors.d.ts +2 -0
- package/dist/all-editors.js.flow +8 -0
- package/dist/all-widgets.d.ts +22 -0
- package/dist/all-widgets.js.flow +34 -0
- package/dist/article-editor.d.ts +59 -0
- package/dist/article-editor.js.flow +72 -0
- package/dist/components/blur-input.d.ts +19 -0
- package/dist/components/blur-input.js.flow +25 -0
- package/dist/components/checkbox.d.ts +20 -0
- package/dist/components/checkbox.js.flow +26 -0
- package/dist/components/device-framer.d.ts +15 -0
- package/dist/components/device-framer.js.flow +20 -0
- package/dist/components/drag-target.d.ts +2 -0
- package/dist/components/drag-target.js.flow +8 -0
- package/dist/components/dropdown-option.d.ts +35 -0
- package/dist/components/dropdown-option.js.flow +49 -0
- package/dist/components/form-wrapped-text-field.d.ts +48 -0
- package/dist/components/form-wrapped-text-field.js.flow +48 -0
- package/dist/components/graph-settings.d.ts +2 -0
- package/dist/components/graph-settings.js.flow +8 -0
- package/dist/components/hover-behavior.d.ts +85 -0
- package/dist/components/hover-behavior.js.flow +48 -0
- package/dist/components/json-editor.d.ts +2 -0
- package/dist/components/json-editor.js.flow +8 -0
- package/dist/components/link.d.ts +41 -0
- package/dist/components/link.js.flow +50 -0
- package/dist/components/simple-button.d.ts +16 -0
- package/dist/components/simple-button.js.flow +18 -0
- package/dist/components/sortable.d.ts +2 -0
- package/dist/components/sortable.js.flow +8 -0
- package/dist/components/util.d.ts +1 -0
- package/dist/components/util.js.flow +9 -0
- package/dist/components/viewport-resizer.d.ts +16 -0
- package/dist/components/viewport-resizer.js.flow +22 -0
- package/dist/diffs/__stories__/perseus-diff-wrapper.d.ts +5 -0
- package/dist/diffs/__stories__/perseus-diff-wrapper.js.flow +11 -0
- package/dist/diffs/article-diff.d.ts +50 -0
- package/dist/diffs/article-diff.js.flow +71 -0
- package/dist/diffs/item-diff.d.ts +23 -0
- package/dist/diffs/item-diff.js.flow +41 -0
- package/dist/diffs/renderer-diff.d.ts +22 -0
- package/dist/diffs/renderer-diff.js.flow +25 -0
- package/dist/diffs/split-diff.d.ts +2 -0
- package/dist/diffs/split-diff.js.flow +8 -0
- package/dist/diffs/string-array-diff.d.ts +2 -0
- package/dist/diffs/string-array-diff.js.flow +11 -0
- package/dist/diffs/structured-item-diff.d.ts +25 -0
- package/dist/diffs/structured-item-diff.js.flow +37 -0
- package/dist/diffs/tags-diff.d.ts +21 -0
- package/dist/diffs/tags-diff.js.flow +24 -0
- package/dist/diffs/text-diff.d.ts +15 -0
- package/dist/diffs/text-diff.js.flow +21 -0
- package/dist/diffs/widget-diff-performer.d.ts +2 -0
- package/dist/diffs/widget-diff-performer.js.flow +8 -0
- package/dist/diffs/widget-diff.d.ts +21 -0
- package/dist/diffs/widget-diff.js.flow +31 -0
- package/dist/editor-page.d.ts +57 -0
- package/dist/editor-page.js.flow +73 -0
- package/dist/editor.d.ts +82 -0
- package/dist/editor.js.flow +98 -0
- package/dist/es/index.js +1428 -2587
- package/dist/es/index.js.map +1 -1
- package/dist/hint-editor.d.ts +64 -0
- package/dist/hint-editor.js.flow +87 -0
- package/dist/i18n.d.ts +7 -0
- package/dist/i18n.js.flow +13 -0
- package/dist/iframe-content-renderer.d.ts +22 -0
- package/dist/iframe-content-renderer.js.flow +28 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +1492 -2548
- package/dist/index.js.flow +23 -2
- package/dist/index.js.map +1 -1
- package/dist/item-editor.d.ts +36 -0
- package/dist/item-editor.js.flow +46 -0
- package/dist/item-extras-editor.d.ts +17 -0
- package/dist/item-extras-editor.js.flow +23 -0
- package/dist/katex-error-view.d.ts +16 -0
- package/dist/katex-error-view.js.flow +24 -0
- package/dist/multirenderer-editor.d.ts +32 -0
- package/dist/multirenderer-editor.js.flow +46 -0
- package/dist/section-control-button.d.ts +12 -0
- package/dist/section-control-button.js.flow +20 -0
- package/dist/stateful-article-editor.d.ts +10 -0
- package/dist/stateful-article-editor.js.flow +16 -0
- package/dist/stateful-editor-page.d.ts +2 -0
- package/dist/stateful-editor-page.js.flow +8 -0
- package/dist/testing-widgets.d.ts +22 -0
- package/dist/testing-widgets.js.flow +34 -0
- package/dist/util/register-all-widgets-and-editors-for-testing.d.ts +1 -0
- package/dist/util/register-all-widgets-and-editors-for-testing.js.flow +7 -0
- package/dist/widgets/categorizer-editor.d.ts +47 -0
- package/dist/widgets/categorizer-editor.js.flow +61 -0
- package/dist/widgets/cs-program-editor.d.ts +21 -0
- package/dist/widgets/cs-program-editor.js.flow +25 -0
- package/dist/widgets/definition-editor.d.ts +17 -0
- package/dist/widgets/definition-editor.js.flow +23 -0
- package/dist/widgets/dropdown-editor.d.ts +23 -0
- package/dist/widgets/dropdown-editor.js.flow +37 -0
- package/dist/widgets/example-graphie-widget-editor.d.ts +18 -0
- package/dist/widgets/example-graphie-widget-editor.js.flow +25 -0
- package/dist/widgets/example-graphie-widget.d.ts +87 -0
- package/dist/widgets/example-graphie-widget.js.flow +101 -0
- package/dist/widgets/example-widget-editor.d.ts +19 -0
- package/dist/widgets/example-widget-editor.js.flow +26 -0
- package/dist/widgets/example-widget.d.ts +71 -0
- package/dist/widgets/example-widget.js.flow +86 -0
- package/dist/widgets/explanation-editor.d.ts +21 -0
- package/dist/widgets/explanation-editor.js.flow +27 -0
- package/dist/widgets/expression-editor.d.ts +33 -0
- package/dist/widgets/expression-editor.js.flow +41 -0
- package/dist/widgets/graded-group-editor.d.ts +53 -0
- package/dist/widgets/graded-group-editor.js.flow +67 -0
- package/dist/widgets/graded-group-set-editor.d.ts +51 -0
- package/dist/widgets/graded-group-set-editor.js.flow +65 -0
- package/dist/widgets/grapher-editor.d.ts +14 -0
- package/dist/widgets/grapher-editor.js.flow +21 -0
- package/dist/widgets/group-editor.d.ts +49 -0
- package/dist/widgets/group-editor.js.flow +63 -0
- package/dist/widgets/iframe-editor.d.ts +18 -0
- package/dist/widgets/iframe-editor.js.flow +24 -0
- package/dist/widgets/image-editor.d.ts +2 -0
- package/dist/widgets/image-editor.js.flow +8 -0
- package/dist/widgets/input-number-editor.d.ts +47 -0
- package/dist/widgets/input-number-editor.js.flow +77 -0
- package/dist/widgets/interaction/constraint-editor.d.ts +26 -0
- package/dist/widgets/interaction/constraint-editor.js.flow +35 -0
- package/dist/widgets/interaction-editor.d.ts +28 -0
- package/dist/widgets/interaction-editor.js.flow +36 -0
- package/dist/widgets/interactive-graph-editor.d.ts +2 -0
- package/dist/widgets/interactive-graph-editor.js.flow +8 -0
- package/dist/widgets/label-image/answer-choices.d.ts +13 -0
- package/dist/widgets/label-image/answer-choices.js.flow +16 -0
- package/dist/widgets/label-image/behavior.d.ts +14 -0
- package/dist/widgets/label-image/behavior.js.flow +17 -0
- package/dist/widgets/label-image/marker.d.ts +30 -0
- package/dist/widgets/label-image/marker.js.flow +34 -0
- package/dist/widgets/label-image/question-markers.d.ts +22 -0
- package/dist/widgets/label-image/question-markers.js.flow +25 -0
- package/dist/widgets/label-image/select-image.d.ts +10 -0
- package/dist/widgets/label-image/select-image.js.flow +13 -0
- package/dist/widgets/label-image-editor.d.ts +45 -0
- package/dist/widgets/label-image-editor.js.flow +44 -0
- package/dist/widgets/lights-puzzle-editor.d.ts +24 -0
- package/dist/widgets/lights-puzzle-editor.js.flow +34 -0
- package/dist/widgets/matcher-editor.d.ts +19 -0
- package/dist/widgets/matcher-editor.js.flow +28 -0
- package/dist/widgets/matrix-editor.d.ts +20 -0
- package/dist/widgets/matrix-editor.js.flow +26 -0
- package/dist/widgets/measurer-editor.d.ts +32 -0
- package/dist/widgets/measurer-editor.js.flow +42 -0
- package/dist/widgets/molecule-editor.d.ts +17 -0
- package/dist/widgets/molecule-editor.js.flow +23 -0
- package/dist/widgets/number-line-editor.d.ts +36 -0
- package/dist/widgets/number-line-editor.js.flow +45 -0
- package/dist/widgets/numeric-input-editor.d.ts +2 -0
- package/dist/widgets/numeric-input-editor.js.flow +8 -0
- package/dist/widgets/orderer-editor.d.ts +20 -0
- package/dist/widgets/orderer-editor.js.flow +30 -0
- package/dist/widgets/passage-editor.d.ts +18 -0
- package/dist/widgets/passage-editor.js.flow +24 -0
- package/dist/widgets/passage-ref-editor.d.ts +11 -0
- package/dist/widgets/passage-ref-editor.js.flow +17 -0
- package/dist/widgets/passage-ref-target-editor.d.ts +16 -0
- package/dist/widgets/passage-ref-target-editor.js.flow +22 -0
- package/dist/widgets/plotter-editor.d.ts +45 -0
- package/dist/widgets/plotter-editor.js.flow +53 -0
- package/dist/widgets/radio/editor.d.ts +64 -0
- package/dist/widgets/radio/editor.js.flow +80 -0
- package/dist/widgets/reaction-diagram-editor.d.ts +20 -0
- package/dist/widgets/reaction-diagram-editor.js.flow +26 -0
- package/dist/widgets/sequence-editor.d.ts +56 -0
- package/dist/widgets/sequence-editor.js.flow +72 -0
- package/dist/widgets/simple-markdown-tester-editor.d.ts +14 -0
- package/dist/widgets/simple-markdown-tester-editor.js.flow +23 -0
- package/dist/widgets/simple-markdown-tester.d.ts +52 -0
- package/dist/widgets/simple-markdown-tester.js.flow +61 -0
- package/dist/widgets/simulator-editor.d.ts +20 -0
- package/dist/widgets/simulator-editor.js.flow +26 -0
- package/dist/widgets/sorter-editor.d.ts +16 -0
- package/dist/widgets/sorter-editor.js.flow +22 -0
- package/dist/widgets/table-editor.d.ts +18 -0
- package/dist/widgets/table-editor.js.flow +24 -0
- package/dist/widgets/transformer-editor.d.ts +11 -0
- package/dist/widgets/transformer-editor.js.flow +17 -0
- package/dist/widgets/unit-editor.d.ts +33 -0
- package/dist/widgets/unit-editor.js.flow +41 -0
- package/dist/widgets/video-editor.d.ts +19 -0
- package/dist/widgets/video-editor.js.flow +25 -0
- package/package.json +6 -5
- package/src/__stories__/{editor.stories.js → editor.stories.tsx} +4 -5
- package/src/__stories__/{section-control-button.stories.jsx → section-control-button.stories.tsx} +10 -11
- package/src/__testdata__/{input-number_testdata.js → input-number.testdata.ts} +2 -3
- package/src/__tests__/{editor_test.jsx → editor.test.tsx} +4 -7
- package/src/__tests__/{i18n_test.jsx → i18n.test.ts} +5 -5
- package/src/__tests__/{traversal_test.jsx → traversal.test.ts} +9 -10
- package/src/{all-editors_test.js → all-editors.test.ts} +1 -2
- package/src/all-editors.ts +83 -0
- package/src/all-widgets.ts +7 -0
- package/src/{article-editor.jsx → article-editor.tsx} +52 -42
- package/src/components/__stories__/{blur-input.stories.jsx → blur-input.stories.tsx} +2 -4
- package/src/components/{blur-input.jsx → blur-input.tsx} +12 -13
- package/src/components/{checkbox.jsx → checkbox.tsx} +18 -19
- package/src/components/{device-framer.jsx → device-framer.tsx} +4 -5
- package/src/components/{drag-target.jsx → drag-target.tsx} +0 -1
- package/src/components/{dropdown-option.jsx → dropdown-option.tsx} +40 -40
- package/src/components/{form-wrapped-text-field.jsx → form-wrapped-text-field.tsx} +47 -53
- package/src/components/{graph-settings.jsx → graph-settings.tsx} +4 -8
- package/src/components/{hover-behavior.jsx → hover-behavior.ts} +32 -33
- package/src/components/{json-editor.jsx → json-editor.tsx} +4 -3
- package/src/components/{link.jsx → link.ts} +33 -33
- package/src/components/{simple-button.jsx → simple-button.tsx} +3 -4
- package/src/components/{sortable.jsx → sortable.tsx} +3 -3
- package/src/components/{util.js → util.ts} +1 -2
- package/src/components/{viewport-resizer.jsx → viewport-resizer.tsx} +5 -6
- package/src/diffs/__stories__/{perseus-diff-wrapper.jsx → perseus-diff-wrapper.tsx} +3 -2
- package/src/diffs/__stories__/{structured-item-diff.stories.jsx → structured-item-diff.stories.tsx} +27 -22
- package/src/diffs/__stories__/{tags-diff.stories.jsx → tags-diff.stories.tsx} +12 -14
- package/src/diffs/__stories__/{text-diff.stories.jsx → text-diff.stories.tsx} +12 -14
- package/src/diffs/__tests__/{split-diff_test.js → split-diff.test.ts} +1 -2
- package/src/diffs/__tests__/{string-array-diff_test.js → string-array-diff.test.ts} +1 -2
- package/src/diffs/__tests__/{structured-item-diff_test.js → structured-item-diff.test.ts} +15 -14
- package/src/diffs/__tests__/{widget-diff-performer_test.js → widget-diff-performer.test.ts} +1 -2
- package/src/diffs/{article-diff.jsx → article-diff.tsx} +5 -6
- package/src/diffs/{item-diff.jsx → item-diff.tsx} +4 -5
- package/src/diffs/{renderer-diff.jsx → renderer-diff.tsx} +22 -28
- package/src/diffs/{split-diff.jsx → split-diff.ts} +4 -3
- package/src/diffs/{string-array-diff.jsx → string-array-diff.ts} +8 -9
- package/src/diffs/{structured-item-diff.jsx → structured-item-diff.tsx} +32 -27
- package/src/diffs/{tags-diff.jsx → tags-diff.tsx} +15 -16
- package/src/diffs/{text-diff.jsx → text-diff.tsx} +13 -13
- package/src/diffs/{widget-diff-performer.jsx → widget-diff-performer.ts} +3 -8
- package/src/diffs/{widget-diff.jsx → widget-diff.tsx} +15 -14
- package/src/{editor-page.jsx → editor-page.tsx} +52 -60
- package/src/{editor.jsx → editor.tsx} +315 -277
- package/src/{hint-editor.jsx → hint-editor.tsx} +105 -79
- package/src/{i18n.jsx → i18n.ts} +9 -6
- package/src/{iframe-content-renderer.jsx → iframe-content-renderer.tsx} +23 -17
- package/src/{index.js → index.ts} +15 -16
- package/src/{item-editor.jsx → item-editor.tsx} +35 -30
- package/src/{item-extras-editor.jsx → item-extras-editor.tsx} +3 -4
- package/src/{katex-error-view.jsx → katex-error-view.tsx} +4 -5
- package/src/{multirenderer-editor.jsx → multirenderer-editor.tsx} +132 -127
- package/src/{section-control-button.jsx → section-control-button.tsx} +10 -9
- package/src/{stateful-article-editor.jsx → stateful-article-editor.tsx} +2 -5
- package/src/{stateful-editor-page.jsx → stateful-editor-page.tsx} +1 -3
- package/src/{testing-widgets.js → testing-widgets.ts} +5 -6
- package/src/util/{register-all-widgets-and-editors-for-testing_test.js → register-all-widgets-and-editors-for-testing.test.ts} +1 -2
- package/src/util/{register-all-widgets-and-editors-for-testing.js → register-all-widgets-and-editors-for-testing.ts} +2 -3
- package/src/widgets/__stories__/{label-image-editor.stories.jsx → label-image-editor.stories.tsx} +22 -18
- package/src/widgets/__stories__/{radio-editor.stories.jsx → radio-editor.stories.tsx} +15 -10
- package/src/widgets/{categorizer-editor.jsx → categorizer-editor.tsx} +8 -6
- package/src/widgets/{cs-program-editor.jsx → cs-program-editor.tsx} +17 -17
- package/src/widgets/{definition-editor.jsx → definition-editor.tsx} +9 -8
- package/src/widgets/{dropdown-editor.jsx → dropdown-editor.tsx} +27 -19
- package/src/widgets/{example-graphie-widget-editor.jsx → example-graphie-widget-editor.tsx} +8 -8
- package/src/widgets/{example-graphie-widget.jsx → example-graphie-widget.tsx} +14 -17
- package/src/widgets/{example-widget-editor.jsx → example-widget-editor.tsx} +10 -7
- package/src/widgets/{example-widget.jsx → example-widget.tsx} +14 -12
- package/src/widgets/{explanation-editor.jsx → explanation-editor.tsx} +12 -10
- package/src/widgets/{expression-editor.jsx → expression-editor.tsx} +36 -26
- package/src/widgets/{graded-group-editor.jsx → graded-group-editor.tsx} +18 -10
- package/src/widgets/{graded-group-set-editor.jsx → graded-group-set-editor.tsx} +15 -12
- package/src/widgets/{grapher-editor.jsx → grapher-editor.tsx} +10 -9
- package/src/widgets/{group-editor.jsx → group-editor.tsx} +11 -9
- package/src/widgets/{iframe-editor.jsx → iframe-editor.tsx} +16 -13
- package/src/widgets/{image-editor.jsx → image-editor.tsx} +4 -7
- package/src/widgets/{input-number-editor.jsx → input-number-editor.tsx} +61 -47
- package/src/widgets/interaction/{constraint-editor.jsx → constraint-editor.tsx} +21 -24
- package/src/widgets/{interaction-editor.jsx → interaction-editor.tsx} +160 -61
- package/src/widgets/{interactive-graph-editor.jsx → interactive-graph-editor.tsx} +13 -10
- package/src/widgets/label-image/__stories__/{answer-choices.stories.jsx → answer-choices.stories.tsx} +22 -17
- package/src/widgets/label-image/__stories__/{behavior.stories.jsx → behavior.stories.tsx} +9 -10
- package/src/widgets/label-image/__stories__/{marker.stories.jsx → marker.stories.tsx} +11 -12
- package/src/widgets/label-image/__stories__/{question-markers.stories.jsx → question-markers.stories.tsx} +17 -16
- package/src/widgets/label-image/__stories__/{select-image.stories.jsx → select-image.stories.tsx} +12 -13
- package/src/widgets/label-image/{answer-choices.jsx → answer-choices.tsx} +18 -18
- package/src/widgets/label-image/{behavior.jsx → behavior.tsx} +9 -11
- package/src/widgets/label-image/{marker.jsx → marker.tsx} +17 -19
- package/src/widgets/label-image/{question-markers.jsx → question-markers.tsx} +16 -21
- package/src/widgets/label-image/{select-image.jsx → select-image.tsx} +5 -7
- package/src/widgets/{label-image-editor.jsx → label-image-editor.tsx} +38 -44
- package/src/widgets/{lights-puzzle-editor.jsx → lights-puzzle-editor.tsx} +34 -24
- package/src/widgets/{matcher-editor.jsx → matcher-editor.tsx} +9 -7
- package/src/widgets/{matrix-editor.jsx → matrix-editor.tsx} +10 -9
- package/src/widgets/{measurer-editor.jsx → measurer-editor.tsx} +21 -14
- package/src/widgets/{molecule-editor.jsx → molecule-editor.tsx} +9 -8
- package/src/widgets/{number-line-editor.jsx → number-line-editor.tsx} +19 -17
- package/src/widgets/{numeric-input-editor.jsx → numeric-input-editor.tsx} +10 -10
- package/src/widgets/{orderer-editor.jsx → orderer-editor.tsx} +17 -12
- package/src/widgets/{passage-editor.jsx → passage-editor.tsx} +9 -7
- package/src/widgets/{passage-ref-editor.jsx → passage-ref-editor.tsx} +8 -6
- package/src/widgets/{passage-ref-target-editor.jsx → passage-ref-target-editor.tsx} +9 -7
- package/src/widgets/{plotter-editor.jsx → plotter-editor.tsx} +34 -33
- package/src/widgets/radio/{editor.jsx → editor.tsx} +22 -21
- package/src/widgets/{reaction-diagram-editor.jsx → reaction-diagram-editor.tsx} +14 -10
- package/src/widgets/{sequence-editor.jsx → sequence-editor.tsx} +13 -13
- package/src/widgets/{simple-markdown-tester-editor.jsx → simple-markdown-tester-editor.tsx} +11 -9
- package/src/widgets/{simple-markdown-tester.jsx → simple-markdown-tester.tsx} +8 -7
- package/src/widgets/{simulator-editor.jsx → simulator-editor.tsx} +10 -8
- package/src/widgets/{sorter-editor.jsx → sorter-editor.tsx} +8 -6
- package/src/widgets/{table-editor.jsx → table-editor.tsx} +11 -10
- package/src/widgets/{transformer-editor.jsx → transformer-editor.tsx} +37 -35
- package/src/widgets/{unit-editor.jsx → unit-editor.tsx} +31 -25
- package/src/widgets/{video-editor.jsx → video-editor.tsx} +8 -9
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/all-editors.js +0 -85
- package/src/all-widgets.js +0 -10
- /package/dist/{strings.js → strings} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type Props = any;
|
|
4
|
+
declare class SimpleMarkdownTester extends React.Component<Props> {
|
|
5
|
+
static propTypes: {
|
|
6
|
+
value: PropTypes.Requireable<string>;
|
|
7
|
+
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
8
|
+
};
|
|
9
|
+
static defaultProps: Props;
|
|
10
|
+
/**
|
|
11
|
+
* This is the widget's grading function.
|
|
12
|
+
*
|
|
13
|
+
* simpleValidate generally defers to this function
|
|
14
|
+
*
|
|
15
|
+
* state is usually the result of toJSON on the widget
|
|
16
|
+
* rubric is the result of calling toJSON() on the editor
|
|
17
|
+
*/
|
|
18
|
+
static validate(state: any, rubric: any): any;
|
|
19
|
+
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
20
|
+
toJSON: () => Record<any, any>;
|
|
21
|
+
render(): React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Widgets that are focusable should add a focus method that returns
|
|
24
|
+
* true if focusing succeeded. The first such widget found will be
|
|
25
|
+
* focused on page load.
|
|
26
|
+
*/
|
|
27
|
+
focus: () => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* simpleValidate is called for grading. Rubric is the result of calling
|
|
30
|
+
* toJSON() on the editor that created this widget.
|
|
31
|
+
*
|
|
32
|
+
* Should return an object representing the grading result, such as
|
|
33
|
+
* {
|
|
34
|
+
* type: "points",
|
|
35
|
+
* earned: 1,
|
|
36
|
+
* total: 1,
|
|
37
|
+
* message: null
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
simpleValidate: (arg1: any) => any;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* For this widget to work, we must import this file in src/all-widgets.js
|
|
44
|
+
*/
|
|
45
|
+
declare const _default: {
|
|
46
|
+
name: string;
|
|
47
|
+
displayName: string;
|
|
48
|
+
hidden: boolean;
|
|
49
|
+
widget: typeof SimpleMarkdownTester;
|
|
50
|
+
transform: <T>(value: T) => T;
|
|
51
|
+
};
|
|
52
|
+
export default _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from "prop-types";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare type Props = any;
|
|
10
|
+
declare class SimpleMarkdownTester extends React.Component<Props> {
|
|
11
|
+
static propTypes: {|
|
|
12
|
+
value: PropTypes.Requireable<string>,
|
|
13
|
+
onChange: PropTypes.Validator<(...args: any[]) => any>,
|
|
14
|
+
|};
|
|
15
|
+
static defaultProps: Props;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This is the widget's grading function.
|
|
19
|
+
*
|
|
20
|
+
* simpleValidate generally defers to this function
|
|
21
|
+
*
|
|
22
|
+
* state is usually the result of toJSON on the widget
|
|
23
|
+
* rubric is the result of calling toJSON() on the editor
|
|
24
|
+
*/
|
|
25
|
+
static validate(state: any, rubric: any): any;
|
|
26
|
+
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
27
|
+
toJSON: () => { [key: any]: any };
|
|
28
|
+
render(): React.Node;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Widgets that are focusable should add a focus method that returns
|
|
32
|
+
* true if focusing succeeded. The first such widget found will be
|
|
33
|
+
* focused on page load.
|
|
34
|
+
*/
|
|
35
|
+
focus: () => boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* simpleValidate is called for grading. Rubric is the result of calling
|
|
39
|
+
* toJSON() on the editor that created this widget.
|
|
40
|
+
*
|
|
41
|
+
* Should return an object representing the grading result, such as
|
|
42
|
+
* {
|
|
43
|
+
* type: "points",
|
|
44
|
+
* earned: 1,
|
|
45
|
+
* total: 1,
|
|
46
|
+
* message: null
|
|
47
|
+
* }
|
|
48
|
+
*/
|
|
49
|
+
simpleValidate: (arg1: any) => any;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* For this widget to work, we must import this file in src/all-widgets.js
|
|
53
|
+
*/
|
|
54
|
+
declare var _default: {|
|
|
55
|
+
name: string,
|
|
56
|
+
displayName: string,
|
|
57
|
+
hidden: boolean,
|
|
58
|
+
widget: typeof SimpleMarkdownTester,
|
|
59
|
+
transform: <T>(value: T) => T,
|
|
60
|
+
|};
|
|
61
|
+
declare export default typeof _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type Props = any;
|
|
4
|
+
declare class SimulatorEditor extends React.Component<Props> {
|
|
5
|
+
static propTypes: {
|
|
6
|
+
xAxisLabel: PropTypes.Requireable<string>;
|
|
7
|
+
yAxisLabel: PropTypes.Requireable<string>;
|
|
8
|
+
numTrials: PropTypes.Requireable<number>;
|
|
9
|
+
proportionLabel: PropTypes.Requireable<string>;
|
|
10
|
+
proportionOrPercentage: PropTypes.Requireable<string>;
|
|
11
|
+
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
12
|
+
};
|
|
13
|
+
static widgetName: "simulator";
|
|
14
|
+
static defaultProps: Props;
|
|
15
|
+
render(): React.ReactNode;
|
|
16
|
+
change: (...args: ReadonlyArray<unknown>) => any;
|
|
17
|
+
handleTargetValueChange: (arg1: string, arg2: any) => void;
|
|
18
|
+
serialize: () => any;
|
|
19
|
+
}
|
|
20
|
+
export default SimulatorEditor;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from "prop-types";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare type Props = any;
|
|
10
|
+
declare class SimulatorEditor extends React.Component<Props> {
|
|
11
|
+
static propTypes: {|
|
|
12
|
+
xAxisLabel: PropTypes.Requireable<string>,
|
|
13
|
+
yAxisLabel: PropTypes.Requireable<string>,
|
|
14
|
+
numTrials: PropTypes.Requireable<number>,
|
|
15
|
+
proportionLabel: PropTypes.Requireable<string>,
|
|
16
|
+
proportionOrPercentage: PropTypes.Requireable<string>,
|
|
17
|
+
onChange: PropTypes.Validator<(...args: any[]) => any>,
|
|
18
|
+
|};
|
|
19
|
+
static widgetName: "simulator";
|
|
20
|
+
static defaultProps: Props;
|
|
21
|
+
render(): React.Node;
|
|
22
|
+
change: (...args: $ReadOnlyArray<mixed>) => any;
|
|
23
|
+
handleTargetValueChange: (arg1: string, arg2: any) => void;
|
|
24
|
+
serialize: () => any;
|
|
25
|
+
}
|
|
26
|
+
declare export default typeof SimulatorEditor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type Props = any;
|
|
4
|
+
declare class SorterEditor extends React.Component<Props> {
|
|
5
|
+
static propTypes: {
|
|
6
|
+
correct: PropTypes.Requireable<any[]>;
|
|
7
|
+
layout: PropTypes.Requireable<string>;
|
|
8
|
+
padding: PropTypes.Requireable<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static widgetName: "sorter";
|
|
11
|
+
static defaultProps: Props;
|
|
12
|
+
onLayoutChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
|
|
13
|
+
serialize: (arg1: any) => void;
|
|
14
|
+
render(): React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export default SorterEditor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from "prop-types";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare type Props = any;
|
|
10
|
+
declare class SorterEditor extends React.Component<Props> {
|
|
11
|
+
static propTypes: {|
|
|
12
|
+
correct: PropTypes.Requireable<any[]>,
|
|
13
|
+
layout: PropTypes.Requireable<string>,
|
|
14
|
+
padding: PropTypes.Requireable<boolean>,
|
|
15
|
+
|};
|
|
16
|
+
static widgetName: "sorter";
|
|
17
|
+
static defaultProps: Props;
|
|
18
|
+
onLayoutChange: (arg1: SyntheticInputEvent<HTMLInputElement>) => void;
|
|
19
|
+
serialize: (arg1: any) => void;
|
|
20
|
+
render(): React.Node;
|
|
21
|
+
}
|
|
22
|
+
declare export default typeof SorterEditor;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type Props = any;
|
|
4
|
+
declare class TableEditor extends React.Component<Props> {
|
|
5
|
+
static propTypes: {
|
|
6
|
+
rows: PropTypes.Requireable<number>;
|
|
7
|
+
columns: PropTypes.Requireable<number>;
|
|
8
|
+
headers: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
9
|
+
answers: PropTypes.Requireable<((string | null | undefined)[] | null | undefined)[]>;
|
|
10
|
+
};
|
|
11
|
+
static widgetName: "table";
|
|
12
|
+
static defaultProps: Props;
|
|
13
|
+
focus: () => void;
|
|
14
|
+
render(): React.ReactNode;
|
|
15
|
+
onSizeInput: (arg1: number, arg2: number) => void;
|
|
16
|
+
serialize: () => any;
|
|
17
|
+
}
|
|
18
|
+
export default TableEditor;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from "prop-types";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare type Props = any;
|
|
10
|
+
declare class TableEditor extends React.Component<Props> {
|
|
11
|
+
static propTypes: {|
|
|
12
|
+
rows: PropTypes.Requireable<number>,
|
|
13
|
+
columns: PropTypes.Requireable<number>,
|
|
14
|
+
headers: PropTypes.Requireable<(string | null | void)[]>,
|
|
15
|
+
answers: PropTypes.Requireable<((string | null | void)[] | null | void)[]>,
|
|
16
|
+
|};
|
|
17
|
+
static widgetName: "table";
|
|
18
|
+
static defaultProps: Props;
|
|
19
|
+
focus: () => void;
|
|
20
|
+
render(): React.Node;
|
|
21
|
+
onSizeInput: (arg1: number, arg2: number) => void;
|
|
22
|
+
serialize: () => any;
|
|
23
|
+
}
|
|
24
|
+
declare export default typeof TableEditor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare class TransformerEditor extends React.Component<any> {
|
|
3
|
+
static defaultProps: any;
|
|
4
|
+
static widgetName: "transformer";
|
|
5
|
+
render(): React.ReactNode;
|
|
6
|
+
changeGraph: (arg1: any, arg2: any) => void;
|
|
7
|
+
changeStarting: (arg1: any) => void;
|
|
8
|
+
changeTransformer: (arg1: any, arg2: any) => void;
|
|
9
|
+
serialize: () => any;
|
|
10
|
+
}
|
|
11
|
+
export default TransformerEditor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
declare class TransformerEditor extends React.Component<any> {
|
|
9
|
+
static defaultProps: any;
|
|
10
|
+
static widgetName: "transformer";
|
|
11
|
+
render(): React.Node;
|
|
12
|
+
changeGraph: (arg1: any, arg2: any) => void;
|
|
13
|
+
changeStarting: (arg1: any) => void;
|
|
14
|
+
changeTransformer: (arg1: any, arg2: any) => void;
|
|
15
|
+
serialize: () => any;
|
|
16
|
+
}
|
|
17
|
+
declare export default typeof TransformerEditor;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare const ALL: "all";
|
|
4
|
+
declare const SOME: "some";
|
|
5
|
+
type UnitExampleProps = any;
|
|
6
|
+
type UnitInputEditorProps = any;
|
|
7
|
+
declare class UnitInputEditor extends React.Component<UnitInputEditorProps> {
|
|
8
|
+
parsed: boolean | null | undefined;
|
|
9
|
+
groupId: string;
|
|
10
|
+
original: any | null | undefined;
|
|
11
|
+
static propTypes: {
|
|
12
|
+
value: PropTypes.Requireable<string>;
|
|
13
|
+
acceptingUnits: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
14
|
+
accepting: PropTypes.Requireable<"all" | "some">;
|
|
15
|
+
sigfigs: PropTypes.Requireable<number>;
|
|
16
|
+
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
17
|
+
};
|
|
18
|
+
static widgetName: "unit-input";
|
|
19
|
+
static defaultProps: UnitInputEditorProps;
|
|
20
|
+
constructor(props: UnitExampleProps);
|
|
21
|
+
UNSAFE_componentWillReceiveProps(nextProps: UnitInputEditorProps): void;
|
|
22
|
+
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
23
|
+
handleAcceptingUnitsChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
|
|
24
|
+
handleSigfigChange: (arg1: number) => void;
|
|
25
|
+
_checkSigfigValidity: (arg1: number) => boolean;
|
|
26
|
+
_setAccepting: (arg1: typeof SOME | typeof ALL) => void;
|
|
27
|
+
_doOriginal: (arg1: UnitExampleProps) => void;
|
|
28
|
+
onChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
|
|
29
|
+
getSaveWarnings: () => ReadonlyArray<string>;
|
|
30
|
+
serialize: () => any;
|
|
31
|
+
render(): React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
export default UnitInputEditor;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from "prop-types";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare var ALL: "all";
|
|
10
|
+
declare var SOME: "some";
|
|
11
|
+
declare type UnitExampleProps = any;
|
|
12
|
+
declare type UnitInputEditorProps = any;
|
|
13
|
+
declare class UnitInputEditor extends React.Component<UnitInputEditorProps> {
|
|
14
|
+
parsed: boolean | null | void;
|
|
15
|
+
groupId: string;
|
|
16
|
+
original: any | null | void;
|
|
17
|
+
static propTypes: {|
|
|
18
|
+
value: PropTypes.Requireable<string>,
|
|
19
|
+
acceptingUnits: PropTypes.Requireable<(string | null | void)[]>,
|
|
20
|
+
accepting: PropTypes.Requireable<"all" | "some">,
|
|
21
|
+
sigfigs: PropTypes.Requireable<number>,
|
|
22
|
+
onChange: PropTypes.Validator<(...args: any[]) => any>,
|
|
23
|
+
|};
|
|
24
|
+
static widgetName: "unit-input";
|
|
25
|
+
static defaultProps: UnitInputEditorProps;
|
|
26
|
+
constructor(props: UnitExampleProps): this;
|
|
27
|
+
UNSAFE_componentWillReceiveProps(nextProps: UnitInputEditorProps): void;
|
|
28
|
+
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
29
|
+
handleAcceptingUnitsChange: (
|
|
30
|
+
arg1: SyntheticInputEvent<HTMLInputElement>
|
|
31
|
+
) => void;
|
|
32
|
+
handleSigfigChange: (arg1: number) => void;
|
|
33
|
+
_checkSigfigValidity: (arg1: number) => boolean;
|
|
34
|
+
_setAccepting: (arg1: typeof SOME | typeof ALL) => void;
|
|
35
|
+
_doOriginal: (arg1: UnitExampleProps) => void;
|
|
36
|
+
onChange: (arg1: SyntheticInputEvent<HTMLInputElement>) => void;
|
|
37
|
+
getSaveWarnings: () => $ReadOnlyArray<string>;
|
|
38
|
+
serialize: () => any;
|
|
39
|
+
render(): React.Node;
|
|
40
|
+
}
|
|
41
|
+
declare export default typeof UnitInputEditor;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type Props = any;
|
|
4
|
+
/**
|
|
5
|
+
* This is the main editor for this widget, to specify all the options.
|
|
6
|
+
*/
|
|
7
|
+
declare class VideoEditor extends React.Component<Props> {
|
|
8
|
+
static propTypes: {
|
|
9
|
+
location: PropTypes.Requireable<string>;
|
|
10
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
|
+
};
|
|
12
|
+
static widgetName: "video";
|
|
13
|
+
static defaultProps: Props;
|
|
14
|
+
_handleUrlChange: (arg1: string) => void;
|
|
15
|
+
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
16
|
+
serialize: () => any;
|
|
17
|
+
render(): React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export default VideoEditor;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from "prop-types";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare type Props = any;
|
|
10
|
+
/**
|
|
11
|
+
* This is the main editor for this widget, to specify all the options.
|
|
12
|
+
*/
|
|
13
|
+
declare class VideoEditor extends React.Component<Props> {
|
|
14
|
+
static propTypes: {|
|
|
15
|
+
location: PropTypes.Requireable<string>,
|
|
16
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>,
|
|
17
|
+
|};
|
|
18
|
+
static widgetName: "video";
|
|
19
|
+
static defaultProps: Props;
|
|
20
|
+
_handleUrlChange: (arg1: string) => void;
|
|
21
|
+
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
22
|
+
serialize: () => any;
|
|
23
|
+
render(): React.Node;
|
|
24
|
+
}
|
|
25
|
+
declare export default typeof VideoEditor;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Perseus editors",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "2.0.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -16,14 +16,14 @@
|
|
|
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
|
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@khanacademy/kas": "^0.
|
|
25
|
-
"@khanacademy/kmath": "^0.0
|
|
26
|
-
"@khanacademy/perseus": "^
|
|
24
|
+
"@khanacademy/kas": "^0.3.0",
|
|
25
|
+
"@khanacademy/kmath": "^0.1.0",
|
|
26
|
+
"@khanacademy/perseus": "^4.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@khanacademy/wonder-blocks-button": "^4.0.8",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"classnames": "^1.1.4",
|
|
35
35
|
"create-react-class": "^15.6.3",
|
|
36
36
|
"jquery": "^2.1.1",
|
|
37
|
+
"katex": "^0.11.1",
|
|
37
38
|
"perseus-build-settings": "^0.0.5",
|
|
38
39
|
"prop-types": "^15.6.1",
|
|
39
40
|
"react": "16.14.0",
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {ApiOptions, Dependencies} from "@khanacademy/perseus";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
5
|
-
import {question1} from "../__testdata__/input-
|
|
6
|
-
import Editor from "../editor
|
|
7
|
-
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing
|
|
4
|
+
import {question1} from "../__testdata__/input-number.testdata";
|
|
5
|
+
import Editor from "../editor";
|
|
6
|
+
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing";
|
|
8
7
|
|
|
9
8
|
export default {
|
|
10
9
|
title: "Perseus/Editor",
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
export const Rational = (): React.
|
|
12
|
+
export const Rational = (): React.ReactElement => {
|
|
14
13
|
registerAllWidgetsAndEditorsForTesting();
|
|
15
14
|
Dependencies.getDependencies().shouldUseFutureKaTeX(false);
|
|
16
15
|
|
package/src/__stories__/{section-control-button.stories.jsx → section-control-button.stories.tsx}
RENAMED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {icons} from "@khanacademy/perseus";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
5
|
-
import SectionControlButton from "../section-control-button
|
|
4
|
+
import SectionControlButton from "../section-control-button";
|
|
6
5
|
|
|
7
|
-
type StoryArgs =
|
|
6
|
+
type StoryArgs = Record<any, any>;
|
|
8
7
|
|
|
9
|
-
type Story = {
|
|
10
|
-
title: string
|
|
11
|
-
|
|
8
|
+
type Story = {
|
|
9
|
+
title: string;
|
|
10
|
+
};
|
|
12
11
|
|
|
13
|
-
export default
|
|
12
|
+
export default {
|
|
14
13
|
title: "Perseus Editor/Widgets/Section Control Button",
|
|
15
|
-
}
|
|
14
|
+
} as Story;
|
|
16
15
|
|
|
17
|
-
export const ButtonForEditingSectionsOfContentWithInArticleEditor
|
|
18
|
-
|
|
19
|
-
): React.
|
|
16
|
+
export const ButtonForEditingSectionsOfContentWithInArticleEditor: React.FC<
|
|
17
|
+
StoryArgs
|
|
18
|
+
> = (args): React.ReactElement => {
|
|
20
19
|
return (
|
|
21
20
|
<SectionControlButton
|
|
22
21
|
icon={icons.iconTrash}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {PerseusRenderer, InputNumberWidget} from "@khanacademy/perseus";
|
|
3
2
|
|
|
4
3
|
export const question1: PerseusRenderer = {
|
|
@@ -6,7 +5,7 @@ export const question1: PerseusRenderer = {
|
|
|
6
5
|
"A sequence is defined recursively as follows:\n\n\n$\\qquad\\displaystyle{{a}_{n}}=-\\frac{1}{a_{n-1}-1} \n~~~~~~\\text{ with}\\qquad\\displaystyle{{a}_{0}}=\\frac{1}{2}\\,$\n\n\nFind the term $a_3$ in the sequence.\n\n[[\u2603 input-number 1]]",
|
|
7
6
|
images: {},
|
|
8
7
|
widgets: {
|
|
9
|
-
"input-number 1":
|
|
8
|
+
"input-number 1": {
|
|
10
9
|
graded: true,
|
|
11
10
|
version: {
|
|
12
11
|
major: 0,
|
|
@@ -23,6 +22,6 @@ export const question1: PerseusRenderer = {
|
|
|
23
22
|
size: "normal",
|
|
24
23
|
},
|
|
25
24
|
alignment: "default",
|
|
26
|
-
}
|
|
25
|
+
} as InputNumberWidget,
|
|
27
26
|
},
|
|
28
27
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {ApiOptions, Dependencies, Widgets} from "@khanacademy/perseus";
|
|
3
2
|
import {render, screen} from "@testing-library/react";
|
|
4
3
|
import userEvent from "@testing-library/user-event";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import "@testing-library/jest-dom"; // Imports custom mathers
|
|
7
6
|
|
|
8
|
-
import {testDependencies} from "../../../../testing/test-dependencies
|
|
9
|
-
import {question1} from "../__testdata__/input-
|
|
10
|
-
import Editor from "../editor
|
|
7
|
+
import {testDependencies} from "../../../../testing/test-dependencies";
|
|
8
|
+
import {question1} from "../__testdata__/input-number.testdata";
|
|
9
|
+
import Editor from "../editor";
|
|
11
10
|
|
|
12
11
|
describe("Editor", () => {
|
|
13
12
|
beforeEach(() => {
|
|
@@ -20,9 +19,7 @@ describe("Editor", () => {
|
|
|
20
19
|
beforeEach(async () => {
|
|
21
20
|
const [InputNumberWidget, InputNumberEditor] = await Promise.all([
|
|
22
21
|
import("@khanacademy/perseus").then((m) => m.InputNumber),
|
|
23
|
-
import("../widgets/input-number-editor
|
|
24
|
-
(m) => m.default,
|
|
25
|
-
),
|
|
22
|
+
import("../widgets/input-number-editor").then((m) => m.default),
|
|
26
23
|
]);
|
|
27
24
|
Widgets.registerWidgets([InputNumberWidget]);
|
|
28
25
|
Widgets.registerEditors([InputNumberEditor]);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {Dependencies} from "@khanacademy/perseus";
|
|
3
2
|
import _ from "underscore";
|
|
4
3
|
|
|
5
|
-
import {testDependencies} from "../../../../testing/test-dependencies
|
|
6
|
-
import i18n from "../i18n
|
|
7
|
-
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing
|
|
4
|
+
import {testDependencies} from "../../../../testing/test-dependencies";
|
|
5
|
+
import i18n from "../i18n";
|
|
6
|
+
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing";
|
|
8
7
|
|
|
9
8
|
const exerciseImagesEverywhere = {
|
|
10
9
|
question: {
|
|
@@ -443,13 +442,14 @@ const exerciseImagesEverywhere = {
|
|
|
443
442
|
},
|
|
444
443
|
},
|
|
445
444
|
],
|
|
446
|
-
};
|
|
445
|
+
} as const;
|
|
447
446
|
|
|
448
447
|
// Article perseus format is very similar to exercises and should parse the
|
|
449
448
|
// same way, but should just be a list of renders. So we reuse the test data
|
|
450
449
|
// from exerciseImagesEverywhere, but include the question and hints as if they
|
|
451
450
|
// were paragraphs in the article.
|
|
452
451
|
const articleImagesEverywhere = [exerciseImagesEverywhere.question].concat(
|
|
452
|
+
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
453
453
|
exerciseImagesEverywhere.hints,
|
|
454
454
|
);
|
|
455
455
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {traverse, Widgets} from "@khanacademy/perseus";
|
|
3
2
|
import _ from "underscore";
|
|
4
3
|
|
|
5
|
-
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing
|
|
4
|
+
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing";
|
|
6
5
|
|
|
7
6
|
const missingOptions = {
|
|
8
7
|
content: "[[☃ radio 1]]\n\n",
|
|
@@ -31,7 +30,7 @@ const missingOptions = {
|
|
|
31
30
|
alignment: "default",
|
|
32
31
|
},
|
|
33
32
|
},
|
|
34
|
-
};
|
|
33
|
+
} as const;
|
|
35
34
|
|
|
36
35
|
const clonedMissingOptions = JSON.parse(JSON.stringify(missingOptions));
|
|
37
36
|
|
|
@@ -59,7 +58,7 @@ const sampleOptions = {
|
|
|
59
58
|
alignment: "default",
|
|
60
59
|
},
|
|
61
60
|
},
|
|
62
|
-
};
|
|
61
|
+
} as const;
|
|
63
62
|
|
|
64
63
|
const clonedSampleOptions = JSON.parse(JSON.stringify(sampleOptions));
|
|
65
64
|
|
|
@@ -96,7 +95,7 @@ const sampleOptions2 = {
|
|
|
96
95
|
alignment: "default",
|
|
97
96
|
},
|
|
98
97
|
},
|
|
99
|
-
};
|
|
98
|
+
} as const;
|
|
100
99
|
|
|
101
100
|
const clonedSampleOptions2 = JSON.parse(JSON.stringify(sampleOptions2));
|
|
102
101
|
|
|
@@ -133,7 +132,7 @@ const sampleOptions2Upgraded = {
|
|
|
133
132
|
alignment: "default",
|
|
134
133
|
},
|
|
135
134
|
},
|
|
136
|
-
};
|
|
135
|
+
} as const;
|
|
137
136
|
|
|
138
137
|
const sampleGroup = {
|
|
139
138
|
content: "[[☃ group 1]]\n\n",
|
|
@@ -184,7 +183,7 @@ const sampleGroup = {
|
|
|
184
183
|
alignment: "default",
|
|
185
184
|
},
|
|
186
185
|
},
|
|
187
|
-
};
|
|
186
|
+
} as const;
|
|
188
187
|
|
|
189
188
|
const sampleGroupUpgraded = {
|
|
190
189
|
content: "[[☃ group 1]]\n\n",
|
|
@@ -236,7 +235,7 @@ const sampleGroupUpgraded = {
|
|
|
236
235
|
alignment: "default",
|
|
237
236
|
},
|
|
238
237
|
},
|
|
239
|
-
};
|
|
238
|
+
} as const;
|
|
240
239
|
|
|
241
240
|
const clonedSampleGroup = JSON.parse(JSON.stringify(sampleGroup));
|
|
242
241
|
|
|
@@ -276,7 +275,7 @@ describe("Traversal", () => {
|
|
|
276
275
|
});
|
|
277
276
|
|
|
278
277
|
it("should have access to widgets", () => {
|
|
279
|
-
const widgetMap = {};
|
|
278
|
+
const widgetMap: Record<string, any> = {};
|
|
280
279
|
traverse(sampleOptions, null, (widgetInfo) => {
|
|
281
280
|
widgetMap[widgetInfo.type] = (widgetMap[widgetInfo.type] || 0) + 1;
|
|
282
281
|
});
|
|
@@ -330,7 +329,7 @@ describe("Traversal", () => {
|
|
|
330
329
|
});
|
|
331
330
|
|
|
332
331
|
it("should be able to see group widgets", () => {
|
|
333
|
-
const widgetMap = {};
|
|
332
|
+
const widgetMap: Record<string, any> = {};
|
|
334
333
|
traverse(sampleGroup, null, (widgetInfo) => {
|
|
335
334
|
widgetMap[widgetInfo.type] = (widgetMap[widgetInfo.type] || 0) + 1;
|
|
336
335
|
});
|