@khanacademy/perseus-editor 1.1.1 → 2.0.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/.babelrc.js +1 -1
- package/.eslintrc.js +1 -0
- package/CHANGELOG.md +27 -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 +4006 -5409
- 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 +7 -6
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Some tests require some or all of the widgets and editors to be registered
|
|
4
3
|
* in order for them to work. Requiring this file will register all of the
|
|
@@ -6,8 +5,8 @@
|
|
|
6
5
|
*/
|
|
7
6
|
import {Widgets} from "@khanacademy/perseus";
|
|
8
7
|
|
|
9
|
-
import allEditors from "../all-editors
|
|
10
|
-
import allWidgets from "../all-widgets
|
|
8
|
+
import allEditors from "../all-editors";
|
|
9
|
+
import allWidgets from "../all-widgets";
|
|
11
10
|
|
|
12
11
|
export const registerAllWidgetsAndEditorsForTesting = () => {
|
|
13
12
|
Widgets.registerWidgets(allWidgets);
|
package/src/widgets/__stories__/{label-image-editor.stories.jsx → label-image-editor.stories.tsx}
RENAMED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {StyleSheet, css} from "aphrodite";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
5
|
-
import LabelImageEditor from "../label-image-editor
|
|
4
|
+
import LabelImageEditor from "../label-image-editor";
|
|
6
5
|
|
|
7
6
|
import type {MarkerType} from "@khanacademy/perseus";
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
9
|
+
type Empty = Record<string, never>;
|
|
10
10
|
|
|
11
|
-
type
|
|
12
|
-
title: string,
|
|
13
|
-
|};
|
|
11
|
+
type StoryArgs = Record<any, any>;
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
type Story = {
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default {
|
|
16
18
|
title: "Perseus/Editor/Widgets/Label Image Editor",
|
|
17
|
-
}
|
|
19
|
+
} as Story;
|
|
18
20
|
|
|
19
21
|
const styles = StyleSheet.create({
|
|
20
22
|
wrapper: {
|
|
@@ -23,16 +25,17 @@ const styles = StyleSheet.create({
|
|
|
23
25
|
},
|
|
24
26
|
});
|
|
25
27
|
|
|
26
|
-
type State = {
|
|
27
|
-
imageAlt: string
|
|
28
|
-
choices:
|
|
29
|
-
imageUrl: string
|
|
30
|
-
imageWidth: number
|
|
31
|
-
imageHeight: number
|
|
32
|
-
markers:
|
|
33
|
-
|
|
28
|
+
type State = {
|
|
29
|
+
imageAlt: string;
|
|
30
|
+
choices: ReadonlyArray<string>;
|
|
31
|
+
imageUrl: string;
|
|
32
|
+
imageWidth: number;
|
|
33
|
+
imageHeight: number;
|
|
34
|
+
markers: ReadonlyArray<MarkerType>;
|
|
35
|
+
};
|
|
34
36
|
|
|
35
37
|
class WithState extends React.Component<Empty, State> {
|
|
38
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property '_widget' has no initializer and is not definitely assigned in the constructor.
|
|
36
39
|
_widget: LabelImageEditor;
|
|
37
40
|
|
|
38
41
|
state = {
|
|
@@ -71,7 +74,7 @@ class WithState extends React.Component<Empty, State> {
|
|
|
71
74
|
],
|
|
72
75
|
};
|
|
73
76
|
|
|
74
|
-
render(): React.
|
|
77
|
+
render(): React.ReactNode {
|
|
75
78
|
return (
|
|
76
79
|
<div className={css(styles.wrapper)}>
|
|
77
80
|
<LabelImageEditor
|
|
@@ -85,6 +88,7 @@ class WithState extends React.Component<Empty, State> {
|
|
|
85
88
|
// TODO(mdr): We found a new Flow error when upgrading:
|
|
86
89
|
// "widget (null) This type is incompatible with this._widget (LabelImageEditor)"
|
|
87
90
|
// $FlowFixMe[incompatible-type](0.52.0->0.53.0)
|
|
91
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'LabelImageEditor | null' is not assignable to type 'LabelImageEditor'.
|
|
88
92
|
ref={(widget) => (this._widget = widget)}
|
|
89
93
|
/>
|
|
90
94
|
</div>
|
|
@@ -92,6 +96,6 @@ class WithState extends React.Component<Empty, State> {
|
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
export const Default = (args
|
|
99
|
+
export const Default: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
96
100
|
return <WithState />;
|
|
97
101
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {StyleSheet, css} from "aphrodite";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
5
|
-
import RadioEditor from "../radio/editor
|
|
4
|
+
import RadioEditor from "../radio/editor";
|
|
6
5
|
|
|
7
6
|
import type {
|
|
8
7
|
PerseusRadioWidgetOptions,
|
|
@@ -10,15 +9,18 @@ import type {
|
|
|
10
9
|
APIOptions,
|
|
11
10
|
} from "@khanacademy/perseus";
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
13
|
+
type Empty = Record<string, never>;
|
|
14
14
|
|
|
15
|
-
type
|
|
16
|
-
title: string,
|
|
17
|
-
|};
|
|
15
|
+
type StoryArgs = Record<any, any>;
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
type Story = {
|
|
18
|
+
title: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default {
|
|
20
22
|
title: "Perseus/Editor/Widgets/Radio Editor",
|
|
21
|
-
}
|
|
23
|
+
} as Story;
|
|
22
24
|
|
|
23
25
|
const styles = StyleSheet.create({
|
|
24
26
|
wrapper: {
|
|
@@ -79,14 +81,16 @@ const question: PerseusRenderer = {
|
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
class WithState extends React.Component<Empty, PerseusRadioWidgetOptions> {
|
|
84
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property '_widget' has no initializer and is not definitely assigned in the constructor.
|
|
82
85
|
_widget: RadioEditor;
|
|
83
86
|
|
|
84
87
|
//$FlowIgnore
|
|
88
|
+
// @ts-expect-error [FEI-5003] - TS2416 - Property 'state' in type 'WithState' is not assignable to the same property in base type 'Component<Empty, PerseusRadioWidgetOptions, any>'.
|
|
85
89
|
state = question.widgets["radio 1"];
|
|
86
90
|
|
|
87
91
|
apiOptions: APIOptions = Object.freeze({});
|
|
88
92
|
|
|
89
|
-
render(): React.
|
|
93
|
+
render(): React.ReactNode {
|
|
90
94
|
return (
|
|
91
95
|
<div className={css(styles.wrapper)}>
|
|
92
96
|
<RadioEditor
|
|
@@ -99,6 +103,7 @@ class WithState extends React.Component<Empty, PerseusRadioWidgetOptions> {
|
|
|
99
103
|
})
|
|
100
104
|
}
|
|
101
105
|
// $FlowFixMe[incompatible-type] - can be null
|
|
106
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'RadioEditor | null' is not assignable to type 'RadioEditor'.
|
|
102
107
|
ref={(widget) => (this._widget = widget)}
|
|
103
108
|
/>
|
|
104
109
|
</div>
|
|
@@ -106,6 +111,6 @@ class WithState extends React.Component<Empty, PerseusRadioWidgetOptions> {
|
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
export const Default = (args
|
|
114
|
+
export const Default: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
110
115
|
return <WithState />;
|
|
111
116
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {
|
|
3
2
|
components,
|
|
4
3
|
ApiOptions,
|
|
@@ -13,7 +12,7 @@ import _ from "underscore";
|
|
|
13
12
|
const {PropCheckBox, TextListEditor} = components;
|
|
14
13
|
const Categorizer = CategorizerWidget.widget;
|
|
15
14
|
|
|
16
|
-
type Props =
|
|
15
|
+
type Props = any;
|
|
17
16
|
|
|
18
17
|
class CategorizerEditor extends React.Component<Props> {
|
|
19
18
|
static propTypes = {
|
|
@@ -25,7 +24,7 @@ class CategorizerEditor extends React.Component<Props> {
|
|
|
25
24
|
randomizeItems: PropTypes.bool,
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
static widgetName
|
|
27
|
+
static widgetName = "categorizer" as const;
|
|
29
28
|
|
|
30
29
|
static defaultProps: Props = {
|
|
31
30
|
items: [],
|
|
@@ -34,15 +33,15 @@ class CategorizerEditor extends React.Component<Props> {
|
|
|
34
33
|
randomizeItems: false,
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
change: (
|
|
36
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
38
37
|
return Changeable.change.apply(this, args);
|
|
39
38
|
};
|
|
40
39
|
|
|
41
|
-
serialize: () =>
|
|
40
|
+
serialize: () => any = () => {
|
|
42
41
|
return EditorJsonify.serialize.call(this);
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
render(): React.
|
|
44
|
+
render(): React.ReactNode {
|
|
46
45
|
return (
|
|
47
46
|
<div>
|
|
48
47
|
<div className="perseus-widget-row">
|
|
@@ -57,6 +56,7 @@ class CategorizerEditor extends React.Component<Props> {
|
|
|
57
56
|
<TextListEditor
|
|
58
57
|
options={this.props.categories}
|
|
59
58
|
onChange={(cat) => {
|
|
59
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
|
|
60
60
|
this.change("categories", cat);
|
|
61
61
|
}}
|
|
62
62
|
layout="horizontal"
|
|
@@ -65,6 +65,7 @@ class CategorizerEditor extends React.Component<Props> {
|
|
|
65
65
|
<TextListEditor
|
|
66
66
|
options={this.props.items}
|
|
67
67
|
onChange={(items) => {
|
|
68
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
68
69
|
this.change({
|
|
69
70
|
items: items,
|
|
70
71
|
// TODO(eater): This truncates props.values so there
|
|
@@ -84,6 +85,7 @@ class CategorizerEditor extends React.Component<Props> {
|
|
|
84
85
|
via widget-container.jsx that we aren't passing to Categorizer here.
|
|
85
86
|
See perseus-all-package/types.js#WidgetProps for details. */}
|
|
86
87
|
{/* $FlowFixMe[prop-missing] */}
|
|
88
|
+
{/* @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call. */}
|
|
87
89
|
<Categorizer
|
|
88
90
|
apiOptions={this.props.apiOptions}
|
|
89
91
|
items={this.props.items}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable no-useless-escape */
|
|
2
|
-
// @flow
|
|
3
2
|
/**
|
|
4
3
|
* This editor is for embedding Khan Academy CS programs.
|
|
5
4
|
*/
|
|
@@ -17,7 +16,7 @@ import PropTypes from "prop-types";
|
|
|
17
16
|
import * as React from "react";
|
|
18
17
|
import _ from "underscore";
|
|
19
18
|
|
|
20
|
-
import BlurInput from "../components/blur-input
|
|
19
|
+
import BlurInput from "../components/blur-input";
|
|
21
20
|
|
|
22
21
|
const {InfoTip, PropCheckBox} = components;
|
|
23
22
|
|
|
@@ -27,7 +26,7 @@ const DEFAULT_HEIGHT = 400;
|
|
|
27
26
|
/**
|
|
28
27
|
* This is used for editing a name/value pair.
|
|
29
28
|
*/
|
|
30
|
-
class PairEditor extends React.Component
|
|
29
|
+
class PairEditor extends React.Component<any> {
|
|
31
30
|
static propTypes = {
|
|
32
31
|
...Changeable.propTypes,
|
|
33
32
|
name: PropTypes.string,
|
|
@@ -47,7 +46,7 @@ class PairEditor extends React.Component<$FlowFixMe> {
|
|
|
47
46
|
return EditorJsonify.serialize.call(this);
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
render(): React.
|
|
49
|
+
render(): React.ReactNode {
|
|
51
50
|
return (
|
|
52
51
|
<fieldset className="pair-editor">
|
|
53
52
|
<label>
|
|
@@ -75,7 +74,7 @@ class PairEditor extends React.Component<$FlowFixMe> {
|
|
|
75
74
|
/**
|
|
76
75
|
* This is used for editing a set of name/value pairs.
|
|
77
76
|
*/
|
|
78
|
-
class PairsEditor extends React.Component
|
|
77
|
+
class PairsEditor extends React.Component<any> {
|
|
79
78
|
static propTypes = {
|
|
80
79
|
...Changeable.propTypes,
|
|
81
80
|
pairs: PropTypes.arrayOf(
|
|
@@ -90,7 +89,7 @@ class PairsEditor extends React.Component<$FlowFixMe> {
|
|
|
90
89
|
return Changeable.change.apply(this, args);
|
|
91
90
|
};
|
|
92
91
|
|
|
93
|
-
handlePairChange = (pairIndex, pair) => {
|
|
92
|
+
handlePairChange = (pairIndex, pair: any) => {
|
|
94
93
|
// If they're both non empty, add a new one
|
|
95
94
|
const pairs = this.props.pairs.slice();
|
|
96
95
|
pairs[pairIndex] = pair;
|
|
@@ -106,7 +105,7 @@ class PairsEditor extends React.Component<$FlowFixMe> {
|
|
|
106
105
|
return EditorJsonify.serialize.call(this);
|
|
107
106
|
};
|
|
108
107
|
|
|
109
|
-
render(): React.
|
|
108
|
+
render(): React.ReactNode {
|
|
110
109
|
const editors = _.map(this.props.pairs, (pair, i) => {
|
|
111
110
|
return (
|
|
112
111
|
<PairEditor
|
|
@@ -129,7 +128,7 @@ const KA_PROGRAM_URL = /khanacademy\.org\/computer-programming\/[^\/]+\/(\d+)/;
|
|
|
129
128
|
* If the input does not match the known URL patterns, it is assumed to be
|
|
130
129
|
* a program ID.
|
|
131
130
|
*/
|
|
132
|
-
function isolateProgramID(programUrl) {
|
|
131
|
+
function isolateProgramID(programUrl: string) {
|
|
133
132
|
const match = KA_PROGRAM_URL.exec(programUrl);
|
|
134
133
|
if (match) {
|
|
135
134
|
programUrl = match[1];
|
|
@@ -141,14 +140,14 @@ function isolateProgramID(programUrl) {
|
|
|
141
140
|
/**
|
|
142
141
|
* This is the main editor for this widget, to specify all the options.
|
|
143
142
|
*/
|
|
144
|
-
class CSProgramEditor extends React.Component
|
|
143
|
+
class CSProgramEditor extends React.Component<any> {
|
|
145
144
|
static propTypes = {
|
|
146
145
|
...Changeable.propTypes,
|
|
147
146
|
};
|
|
148
147
|
|
|
149
|
-
static widgetName
|
|
148
|
+
static widgetName = "cs-program" as const;
|
|
150
149
|
|
|
151
|
-
static defaultProps:
|
|
150
|
+
static defaultProps: any = {
|
|
152
151
|
programID: "",
|
|
153
152
|
programType: null,
|
|
154
153
|
settings: [{name: "", value: ""}],
|
|
@@ -158,16 +157,16 @@ class CSProgramEditor extends React.Component<$FlowFixMe> {
|
|
|
158
157
|
height: DEFAULT_HEIGHT,
|
|
159
158
|
};
|
|
160
159
|
|
|
161
|
-
change: (...args:
|
|
162
|
-
//
|
|
160
|
+
change: (...args: ReadonlyArray<unknown>) => any = (...args) => {
|
|
161
|
+
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'readonly unknown[]' is not assignable to parameter of type 'any[]'.
|
|
163
162
|
return Changeable.change.apply(this, args);
|
|
164
163
|
};
|
|
165
164
|
|
|
166
|
-
_handleSettingsChange: (
|
|
165
|
+
_handleSettingsChange: (arg1: any) => void = (settings) => {
|
|
167
166
|
this.change({settings: settings.pairs});
|
|
168
167
|
};
|
|
169
168
|
|
|
170
|
-
_handleProgramIDChange: (string) => void = (programID) => {
|
|
169
|
+
_handleProgramIDChange: (arg1: string) => void = (programID) => {
|
|
171
170
|
programID = isolateProgramID(programID);
|
|
172
171
|
const {isDevServer, InitialRequestUrl} = Dependencies.getDependencies();
|
|
173
172
|
|
|
@@ -191,6 +190,7 @@ class CSProgramEditor extends React.Component<$FlowFixMe> {
|
|
|
191
190
|
"Error retrieving scratchpad info for program ID ",
|
|
192
191
|
Errors.TransientService,
|
|
193
192
|
{
|
|
193
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'string' is not assignable to type 'Error | null | undefined'.
|
|
194
194
|
cause: error,
|
|
195
195
|
loggedMetadata: {
|
|
196
196
|
textStatus,
|
|
@@ -207,11 +207,11 @@ class CSProgramEditor extends React.Component<$FlowFixMe> {
|
|
|
207
207
|
});
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
serialize: () =>
|
|
210
|
+
serialize: () => any = () => {
|
|
211
211
|
return EditorJsonify.serialize.call(this);
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
render(): React.
|
|
214
|
+
render(): React.ReactNode {
|
|
215
215
|
return (
|
|
216
216
|
<div>
|
|
217
217
|
<label>
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {components, Changeable, EditorJsonify} from "@khanacademy/perseus";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
import _ from "underscore";
|
|
6
5
|
|
|
7
|
-
import Editor from "../editor
|
|
6
|
+
import Editor from "../editor";
|
|
8
7
|
|
|
9
8
|
const {TextInput} = components;
|
|
10
9
|
|
|
11
|
-
type Props =
|
|
10
|
+
type Props = any;
|
|
12
11
|
|
|
13
12
|
class DefinitionEditor extends React.Component<Props> {
|
|
14
13
|
static propTypes = {
|
|
@@ -18,22 +17,22 @@ class DefinitionEditor extends React.Component<Props> {
|
|
|
18
17
|
apiOptions: PropTypes.any,
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
static widgetName
|
|
20
|
+
static widgetName = "definition" as const;
|
|
22
21
|
|
|
23
22
|
static defaultProps: Props = {
|
|
24
23
|
togglePrompt: "",
|
|
25
24
|
definition: "",
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
change: (
|
|
27
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
29
28
|
return Changeable.change.apply(this, args);
|
|
30
29
|
};
|
|
31
30
|
|
|
32
|
-
serialize: () =>
|
|
31
|
+
serialize: () => any = () => {
|
|
33
32
|
return EditorJsonify.serialize.call(this);
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
render(): React.
|
|
35
|
+
render(): React.ReactNode {
|
|
37
36
|
return (
|
|
38
37
|
<div className="perseus-widget-definition-editor">
|
|
39
38
|
<a
|
|
@@ -47,6 +46,7 @@ class DefinitionEditor extends React.Component<Props> {
|
|
|
47
46
|
Word to be defined:{" "}
|
|
48
47
|
<TextInput
|
|
49
48
|
value={this.props.togglePrompt}
|
|
49
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
50
50
|
onChange={this.change("togglePrompt")}
|
|
51
51
|
placeholder="define me"
|
|
52
52
|
/>
|
|
@@ -59,10 +59,11 @@ class DefinitionEditor extends React.Component<Props> {
|
|
|
59
59
|
widgetEnabled={false}
|
|
60
60
|
placeholder="definition goes here"
|
|
61
61
|
onChange={(props) => {
|
|
62
|
-
const newProps = {};
|
|
62
|
+
const newProps: Record<string, any> = {};
|
|
63
63
|
if (_.has(props, "content")) {
|
|
64
64
|
newProps.definition = props.content;
|
|
65
65
|
}
|
|
66
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
66
67
|
this.change(newProps);
|
|
67
68
|
}}
|
|
68
69
|
/>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {components, icons, EditorJsonify} from "@khanacademy/perseus";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
4
3
|
import * as React from "react";
|
|
@@ -8,7 +7,7 @@ import _ from "underscore";
|
|
|
8
7
|
const {InfoTip, InlineIcon} = components;
|
|
9
8
|
const {iconPlus, iconTrash} = icons;
|
|
10
9
|
|
|
11
|
-
type Props =
|
|
10
|
+
type Props = any;
|
|
12
11
|
|
|
13
12
|
class DropdownEditor extends React.Component<Props> {
|
|
14
13
|
static propTypes = {
|
|
@@ -21,7 +20,7 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
21
20
|
placeholder: PropTypes.string,
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
static widgetName
|
|
23
|
+
static widgetName = "dropdown" as const;
|
|
25
24
|
|
|
26
25
|
static defaultProps: Props = {
|
|
27
26
|
placeholder: "",
|
|
@@ -33,14 +32,17 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
33
32
|
],
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
onPlaceholderChange: (
|
|
35
|
+
onPlaceholderChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void = (
|
|
36
|
+
e,
|
|
37
|
+
) => {
|
|
37
38
|
const placeholder = e.target.value;
|
|
38
39
|
this.props.onChange({placeholder: placeholder});
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
onCorrectChange: (
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
onCorrectChange: (
|
|
43
|
+
arg1: number,
|
|
44
|
+
arg2: React.ChangeEvent<HTMLInputElement>,
|
|
45
|
+
) => void = (choiceIndex) => {
|
|
44
46
|
const choices = _.map(this.props.choices, function (choice, i) {
|
|
45
47
|
return _.extend({}, choice, {
|
|
46
48
|
correct: i === choiceIndex,
|
|
@@ -49,10 +51,10 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
49
51
|
this.props.onChange({choices: choices});
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
onContentChange: (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
) => {
|
|
54
|
+
onContentChange: (
|
|
55
|
+
arg1: number,
|
|
56
|
+
arg2: React.ChangeEvent<HTMLInputElement>,
|
|
57
|
+
) => void = (choiceIndex, e) => {
|
|
56
58
|
const choices = this.props.choices.slice();
|
|
57
59
|
const choice = _.clone(choices[choiceIndex]);
|
|
58
60
|
choice.content = e.target.value;
|
|
@@ -60,11 +62,11 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
60
62
|
this.props.onChange({choices: choices});
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
addChoice: (
|
|
65
|
+
addChoice: (arg1: React.MouseEvent) => void = (e) => {
|
|
64
66
|
e.preventDefault();
|
|
65
67
|
|
|
66
68
|
const choices = this.props.choices;
|
|
67
|
-
const blankChoice = {content: "", correct: false};
|
|
69
|
+
const blankChoice = {content: "", correct: false} as const;
|
|
68
70
|
this.props.onChange(
|
|
69
71
|
{
|
|
70
72
|
choices: choices.concat([blankChoice]),
|
|
@@ -73,7 +75,7 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
73
75
|
);
|
|
74
76
|
};
|
|
75
77
|
|
|
76
|
-
removeChoice: (number,
|
|
78
|
+
removeChoice: (arg1: number, arg2: React.MouseEvent) => void = (
|
|
77
79
|
choiceIndex,
|
|
78
80
|
e,
|
|
79
81
|
) => {
|
|
@@ -85,18 +87,17 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
85
87
|
});
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
focus: (number) => boolean = (i) => {
|
|
89
|
-
//
|
|
90
|
-
// $FlowFixMe[prop-missing]
|
|
90
|
+
focus: (arg1: number) => boolean = (i) => {
|
|
91
|
+
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
91
92
|
ReactDOM.findDOMNode(this.refs["editor" + i]).focus(); // eslint-disable-line react/no-string-refs
|
|
92
93
|
return true;
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
serialize: () =>
|
|
96
|
+
serialize: () => any = () => {
|
|
96
97
|
return EditorJsonify.serialize.call(this);
|
|
97
98
|
};
|
|
98
99
|
|
|
99
|
-
render(): React.
|
|
100
|
+
render(): React.ReactNode {
|
|
100
101
|
const dropdownGroupName = _.uniqueId("perseus_dropdown_");
|
|
101
102
|
return (
|
|
102
103
|
<div className="perseus-widget-dropdown">
|
|
@@ -142,11 +143,14 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
142
143
|
ref={"radio" + i}
|
|
143
144
|
type="radio"
|
|
144
145
|
name={dropdownGroupName}
|
|
146
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'string' is not assignable to type 'boolean | undefined'.
|
|
145
147
|
checked={
|
|
146
148
|
choice.correct ? "checked" : ""
|
|
147
149
|
}
|
|
148
150
|
// eslint-disable-next-line react/jsx-no-bind
|
|
151
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
149
152
|
onChange={this.onCorrectChange.bind(
|
|
153
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
150
154
|
this,
|
|
151
155
|
i,
|
|
152
156
|
)}
|
|
@@ -156,7 +160,9 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
156
160
|
type="text"
|
|
157
161
|
ref={"editor" + i}
|
|
158
162
|
// eslint-disable-next-line react/jsx-no-bind
|
|
163
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
159
164
|
onChange={this.onContentChange.bind(
|
|
165
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
160
166
|
this,
|
|
161
167
|
i,
|
|
162
168
|
)}
|
|
@@ -168,7 +174,9 @@ class DropdownEditor extends React.Component<Props> {
|
|
|
168
174
|
href="#"
|
|
169
175
|
className="simple-button orange"
|
|
170
176
|
// eslint-disable-next-line react/jsx-no-bind
|
|
177
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
171
178
|
onClick={this.removeChoice.bind(
|
|
179
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
172
180
|
this,
|
|
173
181
|
i,
|
|
174
182
|
)}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {Changeable, EditorJsonify} from "@khanacademy/perseus";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
5
|
-
import ExampleGraphie from "./example-graphie-widget
|
|
4
|
+
import ExampleGraphie from "./example-graphie-widget";
|
|
6
5
|
|
|
7
6
|
const ExampleGraphieWidget = ExampleGraphie.widget;
|
|
8
7
|
|
|
9
|
-
type Props =
|
|
8
|
+
type Props = any;
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* This is the widget's editor. This is what shows up on the left side
|
|
@@ -17,7 +16,7 @@ class ExampleGraphieWidgetEditor extends React.Component<Props> {
|
|
|
17
16
|
...Changeable.propTypes,
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
static widgetName
|
|
19
|
+
static widgetName = "example-graphie-widget" as const;
|
|
21
20
|
|
|
22
21
|
static defaultProps: Props = {
|
|
23
22
|
correct: [4, 4],
|
|
@@ -37,23 +36,24 @@ class ExampleGraphieWidgetEditor extends React.Component<Props> {
|
|
|
37
36
|
},
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
change: (
|
|
39
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
41
40
|
return Changeable.change.apply(this, args);
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
handleChange: (
|
|
43
|
+
handleChange: (arg1: any) => void = (newProps) => {
|
|
45
44
|
if (newProps.coord) {
|
|
45
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
46
46
|
this.change({
|
|
47
47
|
correct: newProps.coord,
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
serialize: () =>
|
|
52
|
+
serialize: () => any = () => {
|
|
53
53
|
return EditorJsonify.serialize.call(this);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
render(): React.
|
|
56
|
+
render(): React.ReactNode {
|
|
57
57
|
return (
|
|
58
58
|
<div>
|
|
59
59
|
<ExampleGraphieWidget
|