@khanacademy/perseus-editor 1.1.0 → 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 +21 -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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Controlled component to display question image and create markers to
|
|
4
3
|
* label image with answers from list of choices.
|
|
@@ -8,48 +7,44 @@ import {Util, Dependencies, globalStyles} from "@khanacademy/perseus";
|
|
|
8
7
|
import {StyleSheet, css} from "aphrodite";
|
|
9
8
|
import * as React from "react";
|
|
10
9
|
|
|
11
|
-
import Marker from "./marker
|
|
10
|
+
import Marker from "./marker";
|
|
12
11
|
|
|
13
12
|
import type {MarkerType} from "@khanacademy/perseus";
|
|
14
13
|
|
|
15
14
|
const {colors, typography} = globalStyles;
|
|
16
15
|
|
|
17
|
-
type QuestionMarkersProps = {
|
|
16
|
+
type QuestionMarkersProps = {
|
|
18
17
|
// The list of possible answers in a specific order.
|
|
19
|
-
choices:
|
|
20
|
-
|
|
18
|
+
choices: ReadonlyArray<string>;
|
|
21
19
|
// The question image properties.
|
|
22
|
-
imageUrl: string
|
|
23
|
-
imageWidth: number
|
|
24
|
-
imageHeight: number
|
|
25
|
-
|
|
20
|
+
imageUrl: string;
|
|
21
|
+
imageWidth: number;
|
|
22
|
+
imageHeight: number;
|
|
26
23
|
// The list of markers placed on the question image.
|
|
27
|
-
markers:
|
|
28
|
-
|
|
24
|
+
markers: ReadonlyArray<MarkerType>;
|
|
29
25
|
// Callback for when any of markers change.
|
|
30
|
-
onChange: (markers:
|
|
31
|
-
|
|
26
|
+
onChange: (markers: ReadonlyArray<MarkerType>) => void;
|
|
27
|
+
};
|
|
32
28
|
|
|
33
29
|
export default class QuestionMarkers extends React.Component<QuestionMarkersProps> {
|
|
34
|
-
|
|
35
|
-
_markers: Array<?Marker> = [];
|
|
30
|
+
_markers: Array<Marker | null | undefined> = [];
|
|
36
31
|
|
|
37
|
-
openDropdownForMarkerIndices(indices:
|
|
32
|
+
openDropdownForMarkerIndices(indices: ReadonlyArray<number>) {
|
|
38
33
|
// Open answer selection dropdown for each of the specified markers.
|
|
39
34
|
indices.forEach((index) => {
|
|
40
35
|
if (this._markers[index]) {
|
|
36
|
+
// @ts-expect-error [FEI-5003] - TS2533 - Object is possibly 'null' or 'undefined'.
|
|
41
37
|
this._markers[index].openDropdown();
|
|
42
38
|
}
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
handleImageDoubleClick: (e:
|
|
47
|
-
e:
|
|
42
|
+
handleImageDoubleClick: (e: React.MouseEvent) => void = (
|
|
43
|
+
e: React.MouseEvent,
|
|
48
44
|
) => {
|
|
49
45
|
e.preventDefault();
|
|
50
46
|
|
|
51
|
-
const rect =
|
|
52
|
-
((e.currentTarget: any): HTMLElement).getBoundingClientRect();
|
|
47
|
+
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
|
53
48
|
|
|
54
49
|
// Calculate marker position on the question image as percentage offset
|
|
55
50
|
// rounded to one decimal place.
|
|
@@ -72,7 +67,7 @@ export default class QuestionMarkers extends React.Component<QuestionMarkersProp
|
|
|
72
67
|
]);
|
|
73
68
|
};
|
|
74
69
|
|
|
75
|
-
render(): React.
|
|
70
|
+
render(): React.ReactNode {
|
|
76
71
|
const {choices, imageUrl, imageWidth, imageHeight, markers, onChange} =
|
|
77
72
|
this.props;
|
|
78
73
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Controlled component for selecting the question image, for answer labeling.
|
|
4
3
|
*/
|
|
@@ -8,22 +7,21 @@ import Button from "@khanacademy/wonder-blocks-button";
|
|
|
8
7
|
import {StyleSheet, css} from "aphrodite";
|
|
9
8
|
import * as React from "react";
|
|
10
9
|
|
|
11
|
-
import FormWrappedTextField from "../../components/form-wrapped-text-field
|
|
10
|
+
import FormWrappedTextField from "../../components/form-wrapped-text-field";
|
|
12
11
|
|
|
13
12
|
const {colors, typography} = globalStyles;
|
|
14
13
|
|
|
15
14
|
type SelectImageProps = {
|
|
16
15
|
// Callback for when image URL is changed.
|
|
17
|
-
onChange: (url: string) => void
|
|
16
|
+
onChange: (url: string) => void;
|
|
18
17
|
// The selected image URL.
|
|
19
|
-
url: string
|
|
20
|
-
...
|
|
18
|
+
url: string;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
const SelectImage = ({
|
|
21
|
+
const SelectImage: React.FC<SelectImageProps> = ({
|
|
24
22
|
onChange,
|
|
25
23
|
url,
|
|
26
|
-
}
|
|
24
|
+
}): React.ReactElement => (
|
|
27
25
|
<div>
|
|
28
26
|
<div className={css(styles.title)}>Image</div>
|
|
29
27
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Direct image labeling widget editor.
|
|
4
3
|
*
|
|
@@ -11,51 +10,46 @@ import {EditorJsonify, Util} from "@khanacademy/perseus";
|
|
|
11
10
|
import {StyleSheet, css} from "aphrodite";
|
|
12
11
|
import * as React from "react";
|
|
13
12
|
|
|
14
|
-
import FormWrappedTextField from "../components/form-wrapped-text-field
|
|
13
|
+
import FormWrappedTextField from "../components/form-wrapped-text-field";
|
|
15
14
|
|
|
16
|
-
import AnswerChoices from "./label-image/answer-choices
|
|
17
|
-
import Behavior from "./label-image/behavior
|
|
18
|
-
import QuestionMarkers from "./label-image/question-markers
|
|
19
|
-
import SelectImage from "./label-image/select-image
|
|
15
|
+
import AnswerChoices from "./label-image/answer-choices";
|
|
16
|
+
import Behavior from "./label-image/behavior";
|
|
17
|
+
import QuestionMarkers from "./label-image/question-markers";
|
|
18
|
+
import SelectImage from "./label-image/select-image";
|
|
20
19
|
|
|
21
20
|
import type {MarkerType} from "@khanacademy/perseus";
|
|
22
21
|
|
|
23
|
-
type LabelImageEditorProps = {
|
|
22
|
+
type LabelImageEditorProps = {
|
|
24
23
|
// List of answer choices to label question image with.
|
|
25
|
-
choices:
|
|
26
|
-
|
|
24
|
+
choices: ReadonlyArray<string>;
|
|
27
25
|
// The question image properties.
|
|
28
|
-
imageAlt: string
|
|
29
|
-
imageUrl: string
|
|
30
|
-
imageWidth: number
|
|
31
|
-
imageHeight: number
|
|
32
|
-
|
|
26
|
+
imageAlt: string;
|
|
27
|
+
imageUrl: string;
|
|
28
|
+
imageWidth: number;
|
|
29
|
+
imageHeight: number;
|
|
33
30
|
// The list of label markers on the question image.
|
|
34
|
-
markers:
|
|
35
|
-
|
|
31
|
+
markers: ReadonlyArray<MarkerType>;
|
|
36
32
|
// Whether multiple answer choices may be selected for markers.
|
|
37
|
-
multipleAnswers: boolean
|
|
38
|
-
|
|
33
|
+
multipleAnswers: boolean;
|
|
39
34
|
// Whether to hide answer choices from user instructions.
|
|
40
|
-
hideChoicesFromInstructions: boolean
|
|
41
|
-
|
|
35
|
+
hideChoicesFromInstructions: boolean;
|
|
42
36
|
// Callback for when a widget prop is changed.
|
|
43
|
-
onChange: (options:
|
|
44
|
-
|
|
37
|
+
onChange: (options: any) => void;
|
|
38
|
+
};
|
|
45
39
|
|
|
46
40
|
class LabelImageEditor extends React.Component<LabelImageEditorProps> {
|
|
47
|
-
_questionMarkers:
|
|
48
|
-
|
|
49
|
-
static defaultProps: {
|
|
50
|
-
choices:
|
|
51
|
-
hideChoicesFromInstructions: boolean
|
|
52
|
-
imageAlt: string
|
|
53
|
-
imageHeight: number
|
|
54
|
-
imageUrl: string
|
|
55
|
-
imageWidth: number
|
|
56
|
-
markers:
|
|
57
|
-
multipleAnswers: boolean
|
|
58
|
-
|
|
41
|
+
_questionMarkers: QuestionMarkers | null | undefined;
|
|
42
|
+
|
|
43
|
+
static defaultProps: {
|
|
44
|
+
choices: ReadonlyArray<any>;
|
|
45
|
+
hideChoicesFromInstructions: boolean;
|
|
46
|
+
imageAlt: string;
|
|
47
|
+
imageHeight: number;
|
|
48
|
+
imageUrl: string;
|
|
49
|
+
imageWidth: number;
|
|
50
|
+
markers: ReadonlyArray<any>;
|
|
51
|
+
multipleAnswers: boolean;
|
|
52
|
+
} = {
|
|
59
53
|
choices: [],
|
|
60
54
|
imageAlt: "",
|
|
61
55
|
imageUrl: "",
|
|
@@ -66,10 +60,10 @@ class LabelImageEditor extends React.Component<LabelImageEditorProps> {
|
|
|
66
60
|
hideChoicesFromInstructions: false,
|
|
67
61
|
};
|
|
68
62
|
|
|
69
|
-
static widgetName
|
|
63
|
+
static widgetName = "label-image" as const;
|
|
70
64
|
|
|
71
65
|
componentDidUpdate(prevProps: LabelImageEditorProps) {
|
|
72
|
-
const coordsToMarkers = {};
|
|
66
|
+
const coordsToMarkers: Record<string, any> = {};
|
|
73
67
|
|
|
74
68
|
prevProps.markers.forEach(
|
|
75
69
|
(marker) => (coordsToMarkers[`${marker.x}.${marker.y}`] = marker),
|
|
@@ -92,10 +86,10 @@ class LabelImageEditor extends React.Component<LabelImageEditorProps> {
|
|
|
92
86
|
}
|
|
93
87
|
}
|
|
94
88
|
|
|
95
|
-
getSaveWarnings: () =>
|
|
89
|
+
getSaveWarnings: () => ReadonlyArray<any | string> = () => {
|
|
96
90
|
const {choices, imageAlt, imageUrl, markers} = this.props;
|
|
97
91
|
|
|
98
|
-
const warnings = [];
|
|
92
|
+
const warnings: Array<string> = [];
|
|
99
93
|
|
|
100
94
|
if (choices.length < 2) {
|
|
101
95
|
warnings.push("Question requires at least two answer choices");
|
|
@@ -168,23 +162,23 @@ class LabelImageEditor extends React.Component<LabelImageEditorProps> {
|
|
|
168
162
|
this.props.onChange({imageAlt: alt});
|
|
169
163
|
};
|
|
170
164
|
|
|
171
|
-
handleChoicesChange: (choices:
|
|
172
|
-
choices:
|
|
165
|
+
handleChoicesChange: (choices: ReadonlyArray<string>) => void = (
|
|
166
|
+
choices: ReadonlyArray<string>,
|
|
173
167
|
) => {
|
|
174
168
|
this.props.onChange({choices});
|
|
175
169
|
};
|
|
176
170
|
|
|
177
|
-
handleMarkersChange: (markers:
|
|
178
|
-
markers:
|
|
171
|
+
handleMarkersChange: (markers: ReadonlyArray<MarkerType>) => void = (
|
|
172
|
+
markers: ReadonlyArray<MarkerType>,
|
|
179
173
|
) => {
|
|
180
174
|
this.props.onChange({markers});
|
|
181
175
|
};
|
|
182
176
|
|
|
183
|
-
handleBehaviorChange: (options
|
|
177
|
+
handleBehaviorChange: (options?: any) => void = (options: any) => {
|
|
184
178
|
this.props.onChange(options);
|
|
185
179
|
};
|
|
186
180
|
|
|
187
|
-
render(): React.
|
|
181
|
+
render(): React.ReactNode {
|
|
188
182
|
const {
|
|
189
183
|
choices,
|
|
190
184
|
imageAlt,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {components, Changeable, EditorJsonify} from "@khanacademy/perseus";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
5
4
|
import * as React from "react";
|
|
@@ -15,21 +14,21 @@ const CELL_PADDING = 5;
|
|
|
15
14
|
const TABLE_STYLE = {
|
|
16
15
|
display: "table",
|
|
17
16
|
tableLayout: "fixed",
|
|
18
|
-
};
|
|
17
|
+
} as const;
|
|
19
18
|
|
|
20
19
|
const ROW_STYLE = {
|
|
21
20
|
display: "table-row",
|
|
22
|
-
};
|
|
21
|
+
} as const;
|
|
23
22
|
|
|
24
23
|
const CELL_STYLE = {
|
|
25
24
|
display: "table-cell",
|
|
26
25
|
padding: CELL_PADDING,
|
|
27
|
-
};
|
|
26
|
+
} as const;
|
|
28
27
|
|
|
29
28
|
const BASE_TILE_STYLE = {
|
|
30
29
|
borderRadius: 10,
|
|
31
30
|
cursor: "pointer",
|
|
32
|
-
};
|
|
31
|
+
} as const;
|
|
33
32
|
|
|
34
33
|
const PATTERNS = {
|
|
35
34
|
plus: () => [
|
|
@@ -45,12 +44,12 @@ const PATTERNS = {
|
|
|
45
44
|
"plus/x": (iter) => {
|
|
46
45
|
return iter % 2 ? PATTERNS.x() : PATTERNS.plus();
|
|
47
46
|
},
|
|
48
|
-
};
|
|
47
|
+
} as const;
|
|
49
48
|
|
|
50
49
|
/**
|
|
51
50
|
* Clamps value to an integer in the range [min, max]
|
|
52
51
|
*/
|
|
53
|
-
const clampToInt = function (value, min, max) {
|
|
52
|
+
const clampToInt = function (value: number, min: number, max: number) {
|
|
54
53
|
value = Math.floor(value);
|
|
55
54
|
value = Math.max(value, min);
|
|
56
55
|
value = Math.min(value, max);
|
|
@@ -59,7 +58,10 @@ const clampToInt = function (value, min, max) {
|
|
|
59
58
|
|
|
60
59
|
// Returns a copy of the tiles, with tiles flipped according to
|
|
61
60
|
// whether or not their y, x position satisfies the predicate
|
|
62
|
-
const flipTilesPredicate = (
|
|
61
|
+
const flipTilesPredicate = (
|
|
62
|
+
oldCells: any,
|
|
63
|
+
predicate: (y?: any, x?: any) => boolean,
|
|
64
|
+
) => {
|
|
63
65
|
return _.map(oldCells, (row, y) => {
|
|
64
66
|
return _.map(row, (cell, x) => {
|
|
65
67
|
return predicate(y, x) ? !cell : cell;
|
|
@@ -67,7 +69,7 @@ const flipTilesPredicate = (oldCells, predicate) => {
|
|
|
67
69
|
});
|
|
68
70
|
};
|
|
69
71
|
|
|
70
|
-
type TileProps =
|
|
72
|
+
type TileProps = any;
|
|
71
73
|
|
|
72
74
|
// A single glowy cell
|
|
73
75
|
class Tile extends React.Component<TileProps> {
|
|
@@ -76,7 +78,7 @@ class Tile extends React.Component<TileProps> {
|
|
|
76
78
|
size: PropTypes.number.isRequired,
|
|
77
79
|
};
|
|
78
80
|
|
|
79
|
-
render(): React.
|
|
81
|
+
render(): React.ReactNode {
|
|
80
82
|
const color = this.props.value ? "#55dd55" : "#115511";
|
|
81
83
|
const style = _.extend({}, BASE_TILE_STYLE, {
|
|
82
84
|
width: this.props.size,
|
|
@@ -91,7 +93,7 @@ class Tile extends React.Component<TileProps> {
|
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
type TileGridProps =
|
|
96
|
+
type TileGridProps = any;
|
|
95
97
|
|
|
96
98
|
// A grid of glowy cells
|
|
97
99
|
class TileGrid extends React.Component<TileGridProps> {
|
|
@@ -100,7 +102,7 @@ class TileGrid extends React.Component<TileGridProps> {
|
|
|
100
102
|
size: PropTypes.number.isRequired,
|
|
101
103
|
};
|
|
102
104
|
|
|
103
|
-
render(): React.
|
|
105
|
+
render(): React.ReactNode {
|
|
104
106
|
return (
|
|
105
107
|
<div style={TABLE_STYLE} className="no-select">
|
|
106
108
|
{_.map(this.props.cells, (row, y) => {
|
|
@@ -129,7 +131,7 @@ class TileGrid extends React.Component<TileGridProps> {
|
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
type LightsPuzzleEditorProps =
|
|
134
|
+
type LightsPuzzleEditorProps = any;
|
|
133
135
|
|
|
134
136
|
// The widget editor
|
|
135
137
|
class LightsPuzzleEditor extends React.Component<LightsPuzzleEditorProps> {
|
|
@@ -140,7 +142,7 @@ class LightsPuzzleEditor extends React.Component<LightsPuzzleEditorProps> {
|
|
|
140
142
|
gradeIncompleteAsWrong: PropTypes.bool.isRequired,
|
|
141
143
|
};
|
|
142
144
|
|
|
143
|
-
static widgetName
|
|
145
|
+
static widgetName = "lights-puzzle" as const;
|
|
144
146
|
|
|
145
147
|
static defaultProps: LightsPuzzleEditorProps = {
|
|
146
148
|
startCells: [
|
|
@@ -163,11 +165,11 @@ class LightsPuzzleEditor extends React.Component<LightsPuzzleEditorProps> {
|
|
|
163
165
|
return 0; // default to 0
|
|
164
166
|
};
|
|
165
167
|
|
|
166
|
-
change: (
|
|
168
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
167
169
|
return Changeable.change.apply(this, args);
|
|
168
170
|
};
|
|
169
171
|
|
|
170
|
-
render(): React.
|
|
172
|
+
render(): React.ReactNode {
|
|
171
173
|
return (
|
|
172
174
|
<div>
|
|
173
175
|
<div>
|
|
@@ -189,6 +191,7 @@ class LightsPuzzleEditor extends React.Component<LightsPuzzleEditorProps> {
|
|
|
189
191
|
Flip pattern:
|
|
190
192
|
<select
|
|
191
193
|
value={this.props.flipPattern}
|
|
194
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type '(arg1: ChangeEvent<HTMLInputElement>) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement>'.
|
|
192
195
|
onChange={this._handlePatternChange}
|
|
193
196
|
>
|
|
194
197
|
{_.map(_.keys(PATTERNS), (pattern, i) => {
|
|
@@ -224,21 +227,26 @@ class LightsPuzzleEditor extends React.Component<LightsPuzzleEditorProps> {
|
|
|
224
227
|
);
|
|
225
228
|
}
|
|
226
229
|
|
|
227
|
-
_handlePatternChange: (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
+
_handlePatternChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void =
|
|
231
|
+
(e) => {
|
|
232
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
|
|
233
|
+
this.change("flipPattern", e.target.value);
|
|
234
|
+
};
|
|
230
235
|
|
|
231
|
-
_changeWidth: (number) => void = (newWidth) => {
|
|
236
|
+
_changeWidth: (arg1: number) => void = (newWidth) => {
|
|
232
237
|
newWidth = clampToInt(newWidth, 1, MAX_SIZE);
|
|
233
238
|
this._truncateCells(newWidth, this._height());
|
|
234
239
|
};
|
|
235
240
|
|
|
236
|
-
_changeHeight: (number) => void = (newHeight) => {
|
|
241
|
+
_changeHeight: (arg1: number) => void = (newHeight) => {
|
|
237
242
|
newHeight = clampToInt(newHeight, 1, MAX_SIZE);
|
|
238
243
|
this._truncateCells(this._width(), newHeight);
|
|
239
244
|
};
|
|
240
245
|
|
|
241
|
-
_truncateCells: (number, number) => void = (
|
|
246
|
+
_truncateCells: (arg1: number, arg2: number) => void = (
|
|
247
|
+
newWidth,
|
|
248
|
+
newHeight,
|
|
249
|
+
) => {
|
|
242
250
|
const newCells = _.times(newHeight, (y) => {
|
|
243
251
|
return _.times(newWidth, (x) => {
|
|
244
252
|
// explicitly cast the result to a boolean with !!
|
|
@@ -248,18 +256,20 @@ class LightsPuzzleEditor extends React.Component<LightsPuzzleEditorProps> {
|
|
|
248
256
|
});
|
|
249
257
|
});
|
|
250
258
|
|
|
259
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
251
260
|
this.change({startCells: newCells});
|
|
252
261
|
};
|
|
253
262
|
|
|
254
|
-
_switchTile: (number, number) => void = (tileY, tileX) => {
|
|
263
|
+
_switchTile: (arg1: number, arg2: number) => void = (tileY, tileX) => {
|
|
255
264
|
const newCells = flipTilesPredicate(this.props.startCells, (y, x) => {
|
|
256
265
|
return y === tileY && x === tileX;
|
|
257
266
|
});
|
|
258
267
|
|
|
268
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
259
269
|
this.change({startCells: newCells});
|
|
260
270
|
};
|
|
261
271
|
|
|
262
|
-
serialize: () =>
|
|
272
|
+
serialize: () => any = () => {
|
|
263
273
|
return EditorJsonify.serialize.call(this);
|
|
264
274
|
};
|
|
265
275
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/forbid-prop-types, react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {components} from "@khanacademy/perseus";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
5
4
|
import * as React from "react";
|
|
@@ -7,7 +6,7 @@ import _ from "underscore";
|
|
|
7
6
|
|
|
8
7
|
const {InfoTip, PropCheckBox, TextListEditor} = components;
|
|
9
8
|
|
|
10
|
-
type Props =
|
|
9
|
+
type Props = any;
|
|
11
10
|
|
|
12
11
|
class MatcherEditor extends React.Component<Props> {
|
|
13
12
|
static propTypes = {
|
|
@@ -18,7 +17,7 @@ class MatcherEditor extends React.Component<Props> {
|
|
|
18
17
|
padding: PropTypes.bool,
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
static widgetName
|
|
20
|
+
static widgetName = "matcher" as const;
|
|
22
21
|
|
|
23
22
|
static defaultProps: Props = {
|
|
24
23
|
left: ["$x$", "$y$", "$z$"],
|
|
@@ -28,7 +27,7 @@ class MatcherEditor extends React.Component<Props> {
|
|
|
28
27
|
padding: true,
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
render(): React.
|
|
30
|
+
render(): React.ReactNode {
|
|
32
31
|
return (
|
|
33
32
|
<div className="perseus-matcher-editor">
|
|
34
33
|
<div>
|
|
@@ -116,13 +115,16 @@ class MatcherEditor extends React.Component<Props> {
|
|
|
116
115
|
);
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
onLabelChange: (
|
|
118
|
+
onLabelChange: (
|
|
119
|
+
arg1: number,
|
|
120
|
+
arg2: React.ChangeEvent<HTMLInputElement>,
|
|
121
|
+
) => void = (index, e) => {
|
|
120
122
|
const labels = _.clone(this.props.labels);
|
|
121
123
|
labels[index] = e.target.value;
|
|
122
124
|
this.props.onChange({labels: labels});
|
|
123
125
|
};
|
|
124
126
|
|
|
125
|
-
getSaveWarnings: () =>
|
|
127
|
+
getSaveWarnings: () => ReadonlyArray<string> = () => {
|
|
126
128
|
if (this.props.left.length !== this.props.right.length) {
|
|
127
129
|
return [
|
|
128
130
|
"The two halves of the matcher have different numbers" +
|
|
@@ -132,7 +134,7 @@ class MatcherEditor extends React.Component<Props> {
|
|
|
132
134
|
return [];
|
|
133
135
|
};
|
|
134
136
|
|
|
135
|
-
serialize:
|
|
137
|
+
serialize: any = () => {
|
|
136
138
|
return _.pick(
|
|
137
139
|
this.props,
|
|
138
140
|
"left",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {
|
|
4
3
|
components,
|
|
5
4
|
Changeable,
|
|
@@ -10,7 +9,7 @@ import PropTypes from "prop-types";
|
|
|
10
9
|
import * as React from "react";
|
|
11
10
|
import _ from "underscore";
|
|
12
11
|
|
|
13
|
-
import Editor from "../editor
|
|
12
|
+
import Editor from "../editor";
|
|
14
13
|
|
|
15
14
|
const {RangeInput} = components;
|
|
16
15
|
const Matrix = MatrixWidget.widget;
|
|
@@ -19,7 +18,7 @@ const Matrix = MatrixWidget.widget;
|
|
|
19
18
|
// have to cap it at some point.
|
|
20
19
|
const MAX_BOARD_SIZE = 6;
|
|
21
20
|
|
|
22
|
-
const getMatrixSize = function (matrix) {
|
|
21
|
+
const getMatrixSize = function (matrix: any) {
|
|
23
22
|
const matrixSize = [1, 1];
|
|
24
23
|
|
|
25
24
|
// We need to find the widest row and tallest column to get the correct
|
|
@@ -43,7 +42,7 @@ const getMatrixSize = function (matrix) {
|
|
|
43
42
|
return matrixSize;
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
type Props =
|
|
45
|
+
type Props = any;
|
|
47
46
|
|
|
48
47
|
class MatrixEditor extends React.Component<Props> {
|
|
49
48
|
static propTypes = {
|
|
@@ -55,7 +54,7 @@ class MatrixEditor extends React.Component<Props> {
|
|
|
55
54
|
cursorPosition: PropTypes.arrayOf(PropTypes.number),
|
|
56
55
|
};
|
|
57
56
|
|
|
58
|
-
static widgetName
|
|
57
|
+
static widgetName = "matrix" as const;
|
|
59
58
|
|
|
60
59
|
static defaultProps: Props = {
|
|
61
60
|
matrixBoardSize: [3, 3],
|
|
@@ -65,7 +64,7 @@ class MatrixEditor extends React.Component<Props> {
|
|
|
65
64
|
cursorPosition: [0, 0],
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
render(): React.
|
|
67
|
+
render(): React.ReactNode {
|
|
69
68
|
const matrixProps = _.extend(
|
|
70
69
|
{
|
|
71
70
|
numericInput: true,
|
|
@@ -100,6 +99,7 @@ class MatrixEditor extends React.Component<Props> {
|
|
|
100
99
|
content={this.props.prefix}
|
|
101
100
|
widgetEnabled={false}
|
|
102
101
|
onChange={(newProps) => {
|
|
102
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
103
103
|
this.change({prefix: newProps.content});
|
|
104
104
|
}}
|
|
105
105
|
/>
|
|
@@ -114,6 +114,7 @@ class MatrixEditor extends React.Component<Props> {
|
|
|
114
114
|
content={this.props.suffix}
|
|
115
115
|
widgetEnabled={false}
|
|
116
116
|
onChange={(newProps) => {
|
|
117
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
117
118
|
this.change({suffix: newProps.content});
|
|
118
119
|
}}
|
|
119
120
|
/>
|
|
@@ -122,11 +123,11 @@ class MatrixEditor extends React.Component<Props> {
|
|
|
122
123
|
);
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
change: (
|
|
126
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
126
127
|
return Changeable.change.apply(this, args);
|
|
127
128
|
};
|
|
128
129
|
|
|
129
|
-
onMatrixBoardSizeChange: ([number, number]) => void = (range) => {
|
|
130
|
+
onMatrixBoardSizeChange: (arg1: [number, number]) => void = (range) => {
|
|
130
131
|
const matrixSize = getMatrixSize(this.props.answers);
|
|
131
132
|
if (range[0] !== null && range[1] !== null) {
|
|
132
133
|
range = [
|
|
@@ -147,7 +148,7 @@ class MatrixEditor extends React.Component<Props> {
|
|
|
147
148
|
}
|
|
148
149
|
};
|
|
149
150
|
|
|
150
|
-
serialize: () =>
|
|
151
|
+
serialize: () => any = () => {
|
|
151
152
|
return EditorJsonify.serialize.call(this);
|
|
152
153
|
};
|
|
153
154
|
}
|