@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,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @babel/no-invalid-this */
|
|
2
|
-
// @flow
|
|
3
2
|
/**
|
|
4
3
|
* Collection of classes for rendering the hint editor area,
|
|
5
4
|
* hint editor boxes, and hint previews
|
|
@@ -8,9 +7,9 @@ import {components, icons} from "@khanacademy/perseus";
|
|
|
8
7
|
import * as React from "react";
|
|
9
8
|
import _ from "underscore";
|
|
10
9
|
|
|
11
|
-
import DeviceFramer from "./components/device-framer
|
|
12
|
-
import Editor from "./editor
|
|
13
|
-
import IframeContentRenderer from "./iframe-content-renderer
|
|
10
|
+
import DeviceFramer from "./components/device-framer";
|
|
11
|
+
import Editor from "./editor";
|
|
12
|
+
import IframeContentRenderer from "./iframe-content-renderer";
|
|
14
13
|
|
|
15
14
|
import type {
|
|
16
15
|
APIOptions,
|
|
@@ -24,27 +23,30 @@ import type {
|
|
|
24
23
|
const {InfoTip, InlineIcon} = components;
|
|
25
24
|
const {iconCircleArrowDown, iconCircleArrowUp, iconPlus, iconTrash} = icons;
|
|
26
25
|
|
|
27
|
-
type ImageUploader = (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
type ImageUploader = (
|
|
27
|
+
file: string,
|
|
28
|
+
callback: (url: string) => unknown,
|
|
29
|
+
) => unknown;
|
|
30
|
+
|
|
31
|
+
type HintEditorProps = {
|
|
32
|
+
itemId?: string;
|
|
33
|
+
apiOptions?: APIOptions;
|
|
34
|
+
className: string;
|
|
35
|
+
imageUploader?: ImageUploader;
|
|
36
|
+
showMoveButtons?: boolean;
|
|
37
|
+
showRemoveButton?: boolean;
|
|
38
|
+
showTitle?: boolean;
|
|
39
|
+
content?: string | null | undefined;
|
|
40
|
+
replace?: boolean | null | undefined;
|
|
41
|
+
widgets?: WidgetDict | null | undefined;
|
|
42
|
+
images?: ImageDict | null | undefined;
|
|
43
|
+
isLast: boolean;
|
|
44
|
+
isFirst: boolean;
|
|
45
|
+
onMove: (direction: number) => unknown;
|
|
46
|
+
onRemove: () => unknown;
|
|
47
|
+
onChange: ChangeHandler;
|
|
48
|
+
__type?: "hint";
|
|
49
|
+
};
|
|
48
50
|
|
|
49
51
|
/* Renders a hint editor box
|
|
50
52
|
*
|
|
@@ -55,14 +57,14 @@ type HintEditorProps = {|
|
|
|
55
57
|
* ~ the move hint up/down arrows
|
|
56
58
|
*/
|
|
57
59
|
export class HintEditor extends React.Component<HintEditorProps> {
|
|
58
|
-
static defaultProps: {
|
|
59
|
-
className: string
|
|
60
|
-
content: string
|
|
61
|
-
replace: boolean
|
|
62
|
-
showMoveButtons: boolean
|
|
63
|
-
showRemoveButton: boolean
|
|
64
|
-
showTitle: boolean
|
|
65
|
-
|
|
60
|
+
static defaultProps: {
|
|
61
|
+
className: string;
|
|
62
|
+
content: string;
|
|
63
|
+
replace: boolean;
|
|
64
|
+
showMoveButtons: boolean;
|
|
65
|
+
showRemoveButton: boolean;
|
|
66
|
+
showTitle: boolean;
|
|
67
|
+
} = {
|
|
66
68
|
className: "",
|
|
67
69
|
content: "",
|
|
68
70
|
replace: false,
|
|
@@ -71,28 +73,31 @@ export class HintEditor extends React.Component<HintEditorProps> {
|
|
|
71
73
|
showRemoveButton: true,
|
|
72
74
|
};
|
|
73
75
|
|
|
74
|
-
handleChange: (e:
|
|
75
|
-
e:
|
|
76
|
+
handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void = (
|
|
77
|
+
e: React.ChangeEvent<HTMLInputElement>,
|
|
76
78
|
) => {
|
|
77
79
|
this.props.onChange({replace: e.target.checked});
|
|
78
80
|
};
|
|
79
81
|
|
|
80
82
|
focus: () => void = () => {
|
|
81
83
|
// eslint-disable-next-line react/no-string-refs
|
|
84
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
82
85
|
this.refs.editor.focus();
|
|
83
86
|
};
|
|
84
87
|
|
|
85
88
|
getSaveWarnings: () => any = () => {
|
|
86
89
|
// eslint-disable-next-line react/no-string-refs
|
|
90
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
87
91
|
return this.refs.editor.getSaveWarnings();
|
|
88
92
|
};
|
|
89
93
|
|
|
90
|
-
serialize: (options
|
|
94
|
+
serialize: (options?: any) => any = (options: any) => {
|
|
91
95
|
// eslint-disable-next-line react/no-string-refs
|
|
96
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
92
97
|
return this.refs.editor.serialize(options);
|
|
93
98
|
};
|
|
94
99
|
|
|
95
|
-
render(): React.
|
|
100
|
+
render(): React.ReactNode {
|
|
96
101
|
return (
|
|
97
102
|
<div className={"perseus-hint-editor " + this.props.className}>
|
|
98
103
|
{this.props.showTitle && <div className="pod-title">Hint</div>}
|
|
@@ -141,6 +146,7 @@ export class HintEditor extends React.Component<HintEditorProps> {
|
|
|
141
146
|
)}
|
|
142
147
|
<input
|
|
143
148
|
type="checkbox"
|
|
149
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'boolean | null | undefined' is not assignable to type 'boolean | undefined'.
|
|
144
150
|
checked={this.props.replace}
|
|
145
151
|
onChange={this.handleChange}
|
|
146
152
|
/>
|
|
@@ -161,23 +167,23 @@ export class HintEditor extends React.Component<HintEditorProps> {
|
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
|
|
164
|
-
type CombinedHintEditorProps = {
|
|
165
|
-
itemId?: string
|
|
166
|
-
apiOptions?: APIOptions
|
|
167
|
-
deviceType: DeviceType
|
|
168
|
-
imageUploader?: ImageUploader
|
|
169
|
-
highlightLint?: boolean
|
|
170
|
-
isLast: boolean
|
|
171
|
-
isFirst: boolean
|
|
172
|
-
hint: Hint
|
|
173
|
-
pos: number
|
|
174
|
-
contentPaths:
|
|
170
|
+
type CombinedHintEditorProps = {
|
|
171
|
+
itemId?: string;
|
|
172
|
+
apiOptions?: APIOptions;
|
|
173
|
+
deviceType: DeviceType;
|
|
174
|
+
imageUploader?: ImageUploader;
|
|
175
|
+
highlightLint?: boolean;
|
|
176
|
+
isLast: boolean;
|
|
177
|
+
isFirst: boolean;
|
|
178
|
+
hint: Hint;
|
|
179
|
+
pos: number; // position,
|
|
180
|
+
contentPaths: ReadonlyArray<string>;
|
|
175
181
|
// URL of the route to show on initial load of the preview frames.
|
|
176
|
-
previewURL: string
|
|
177
|
-
onMove: (direction: number) =>
|
|
178
|
-
onRemove: () =>
|
|
179
|
-
onChange: ChangeHandler
|
|
180
|
-
|
|
182
|
+
previewURL: string;
|
|
183
|
+
onMove: (direction: number) => unknown;
|
|
184
|
+
onRemove: () => unknown;
|
|
185
|
+
onChange: ChangeHandler;
|
|
186
|
+
};
|
|
181
187
|
|
|
182
188
|
/* A single hint-row containing a hint editor and preview */
|
|
183
189
|
class CombinedHintEditor extends React.Component<CombinedHintEditorProps> {
|
|
@@ -198,6 +204,7 @@ class CombinedHintEditor extends React.Component<CombinedHintEditorProps> {
|
|
|
198
204
|
this.props.isLast && !/\*\*/.test(this.props.hint.content);
|
|
199
205
|
|
|
200
206
|
// eslint-disable-next-line react/no-string-refs
|
|
207
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'sendNewData' does not exist on type 'ReactInstance'.
|
|
201
208
|
this.refs.frame.sendNewData({
|
|
202
209
|
type: "hint",
|
|
203
210
|
data: {
|
|
@@ -216,20 +223,23 @@ class CombinedHintEditor extends React.Component<CombinedHintEditorProps> {
|
|
|
216
223
|
|
|
217
224
|
getSaveWarnings = () => {
|
|
218
225
|
// eslint-disable-next-line react/no-string-refs
|
|
226
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
219
227
|
return this.refs.editor.getSaveWarnings();
|
|
220
228
|
};
|
|
221
229
|
|
|
222
|
-
serialize = (options:
|
|
230
|
+
serialize = (options: any) => {
|
|
223
231
|
// eslint-disable-next-line react/no-string-refs
|
|
232
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
224
233
|
return this.refs.editor.serialize(options);
|
|
225
234
|
};
|
|
226
235
|
|
|
227
236
|
focus = () => {
|
|
228
237
|
// eslint-disable-next-line react/no-string-refs
|
|
238
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
229
239
|
this.refs.editor.focus();
|
|
230
240
|
};
|
|
231
241
|
|
|
232
|
-
render(): React.
|
|
242
|
+
render(): React.ReactNode {
|
|
233
243
|
const isMobile =
|
|
234
244
|
this.props.deviceType === "phone" ||
|
|
235
245
|
this.props.deviceType === "tablet";
|
|
@@ -277,20 +287,19 @@ class CombinedHintEditor extends React.Component<CombinedHintEditorProps> {
|
|
|
277
287
|
}
|
|
278
288
|
}
|
|
279
289
|
|
|
280
|
-
type CombinedHintsEditorProps = {
|
|
281
|
-
apiOptions?: APIOptions
|
|
282
|
-
deviceType: DeviceType
|
|
283
|
-
imageUploader?: ImageUploader
|
|
284
|
-
highlightLint?: boolean
|
|
285
|
-
hints:
|
|
290
|
+
type CombinedHintsEditorProps = {
|
|
291
|
+
apiOptions?: APIOptions;
|
|
292
|
+
deviceType: DeviceType;
|
|
293
|
+
imageUploader?: ImageUploader;
|
|
294
|
+
highlightLint?: boolean;
|
|
295
|
+
hints: ReadonlyArray<Hint>;
|
|
286
296
|
// URL of the route to show on initial load of the preview frames.
|
|
287
|
-
previewURL: string
|
|
288
|
-
onChange: ChangeHandler
|
|
289
|
-
|
|
297
|
+
previewURL: string;
|
|
298
|
+
onChange: ChangeHandler;
|
|
290
299
|
// The content ID of the AssessmentItem being edited. It may not be set
|
|
291
300
|
// for non-content library exercise questions.
|
|
292
|
-
itemId?: string
|
|
293
|
-
|
|
301
|
+
itemId?: string;
|
|
302
|
+
};
|
|
294
303
|
|
|
295
304
|
/* The entire hints editing/preview area
|
|
296
305
|
*
|
|
@@ -302,11 +311,11 @@ type CombinedHintsEditorProps = {|
|
|
|
302
311
|
class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
303
312
|
static HintEditor: typeof HintEditor = HintEditor;
|
|
304
313
|
|
|
305
|
-
static defaultProps: {
|
|
306
|
-
highlightLint: boolean
|
|
307
|
-
hints:
|
|
308
|
-
onChange: () => void
|
|
309
|
-
|
|
314
|
+
static defaultProps: {
|
|
315
|
+
highlightLint: boolean;
|
|
316
|
+
hints: ReadonlyArray<any>;
|
|
317
|
+
onChange: () => void;
|
|
318
|
+
} = {
|
|
310
319
|
onChange: () => {},
|
|
311
320
|
hints: [],
|
|
312
321
|
highlightLint: false,
|
|
@@ -315,12 +324,12 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
315
324
|
handleHintChange: (
|
|
316
325
|
i: number,
|
|
317
326
|
newProps: CombinedHintsEditorProps,
|
|
318
|
-
cb: () =>
|
|
327
|
+
cb: () => unknown,
|
|
319
328
|
silent: boolean,
|
|
320
329
|
) => void = (
|
|
321
330
|
i: number,
|
|
322
331
|
newProps: CombinedHintsEditorProps,
|
|
323
|
-
cb: () =>
|
|
332
|
+
cb: () => unknown,
|
|
324
333
|
silent: boolean,
|
|
325
334
|
) => {
|
|
326
335
|
// TODO(joel) - lens
|
|
@@ -331,12 +340,15 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
331
340
|
newProps,
|
|
332
341
|
);
|
|
333
342
|
|
|
343
|
+
// @ts-expect-error [FEI-5003] - TS2740 - Type 'Hint' is missing the following properties from type 'readonly Hint[]': length, concat, join, slice, and 18 more.
|
|
334
344
|
this.props.onChange({hints: hints}, cb, silent);
|
|
335
345
|
};
|
|
336
346
|
|
|
337
347
|
handleHintRemove: (i: number) => void = (i: number) => {
|
|
338
348
|
const hints = _(this.props.hints).clone();
|
|
349
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'splice' does not exist on type 'Hint'.
|
|
339
350
|
hints.splice(i, 1);
|
|
351
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Hint' is not assignable to type 'readonly Hint[]'.
|
|
340
352
|
this.props.onChange({hints: hints});
|
|
341
353
|
};
|
|
342
354
|
|
|
@@ -345,10 +357,14 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
345
357
|
dir: number,
|
|
346
358
|
) => {
|
|
347
359
|
const hints = _(this.props.hints).clone();
|
|
360
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'splice' does not exist on type 'Hint'.
|
|
348
361
|
const hint = hints.splice(i, 1)[0];
|
|
362
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'splice' does not exist on type 'Hint'.
|
|
349
363
|
hints.splice(i + dir, 0, hint);
|
|
364
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Hint' is not assignable to type 'readonly Hint[]'.
|
|
350
365
|
this.props.onChange({hints: hints}, () => {
|
|
351
366
|
// eslint-disable-next-line react/no-string-refs
|
|
367
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
352
368
|
this.refs["hintEditor" + (i + dir)].focus();
|
|
353
369
|
});
|
|
354
370
|
};
|
|
@@ -356,10 +372,12 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
356
372
|
addHint: () => void = () => {
|
|
357
373
|
const hints = _(this.props.hints)
|
|
358
374
|
.clone()
|
|
375
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'concat' does not exist on type 'Hint'.
|
|
359
376
|
.concat([{content: ""}]);
|
|
360
377
|
this.props.onChange({hints: hints}, () => {
|
|
361
378
|
const i = hints.length - 1;
|
|
362
379
|
// eslint-disable-next-line react/no-string-refs
|
|
380
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
363
381
|
this.refs["hintEditor" + i].focus();
|
|
364
382
|
});
|
|
365
383
|
};
|
|
@@ -369,6 +387,7 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
369
387
|
.map((hint, i) => {
|
|
370
388
|
return _.map(
|
|
371
389
|
// eslint-disable-next-line react/no-string-refs
|
|
390
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
372
391
|
this.refs["hintEditor" + i].getSaveWarnings(),
|
|
373
392
|
(issue) => "Hint " + (i + 1) + ": " + issue,
|
|
374
393
|
);
|
|
@@ -377,23 +396,22 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
377
396
|
.value();
|
|
378
397
|
};
|
|
379
398
|
|
|
380
|
-
serialize: (options
|
|
381
|
-
options: $FlowFixMe,
|
|
382
|
-
) => {
|
|
399
|
+
serialize: (options?: any) => ReadonlyArray<string> = (options: any) => {
|
|
383
400
|
return this.props.hints.map((hint, i) => {
|
|
384
401
|
return this.serializeHint(i, options);
|
|
385
402
|
});
|
|
386
403
|
};
|
|
387
404
|
|
|
388
|
-
serializeHint: (index: number, options
|
|
405
|
+
serializeHint: (index: number, options?: any) => string = (
|
|
389
406
|
index: number,
|
|
390
|
-
options:
|
|
407
|
+
options: any,
|
|
391
408
|
): string => {
|
|
392
409
|
// eslint-disable-next-line react/no-string-refs
|
|
410
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
393
411
|
return this.refs["hintEditor" + index].serialize(options);
|
|
394
412
|
};
|
|
395
413
|
|
|
396
|
-
render(): React.
|
|
414
|
+
render(): React.ReactNode {
|
|
397
415
|
const {itemId, hints} = this.props;
|
|
398
416
|
const hintElems = _.map(
|
|
399
417
|
hints,
|
|
@@ -407,16 +425,24 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
407
425
|
itemId={itemId}
|
|
408
426
|
hint={hint}
|
|
409
427
|
pos={i}
|
|
428
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
410
429
|
imageUploader={this.props.imageUploader}
|
|
411
430
|
// eslint-disable-next-line react/jsx-no-bind
|
|
431
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
412
432
|
onChange={this.handleHintChange.bind(this, i)}
|
|
413
433
|
// eslint-disable-next-line react/jsx-no-bind
|
|
434
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
414
435
|
onRemove={this.handleHintRemove.bind(this, i)}
|
|
415
436
|
// eslint-disable-next-line react/jsx-no-bind
|
|
437
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
416
438
|
onMove={this.handleHintMove.bind(this, i)}
|
|
439
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
417
440
|
deviceType={this.props.deviceType}
|
|
441
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
418
442
|
apiOptions={this.props.apiOptions}
|
|
443
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
419
444
|
highlightLint={this.props.highlightLint}
|
|
445
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
420
446
|
previewURL={this.props.previewURL}
|
|
421
447
|
// TODO(CP-4838): what should be passed here?
|
|
422
448
|
contentPaths={[]}
|
package/src/{i18n.jsx → i18n.ts}
RENAMED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Functions for extracting data from items for use in i18n.
|
|
4
3
|
*/
|
|
@@ -9,7 +8,8 @@ const {findContentNodesInItem, findHintNodesInItem, inferItemShape} =
|
|
|
9
8
|
MultiItems;
|
|
10
9
|
|
|
11
10
|
// Takes a renderer content and parses the markdown for images
|
|
12
|
-
function findImagesInContent(content, images) {
|
|
11
|
+
function findImagesInContent(content: any, images: Array<any>) {
|
|
12
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 2 arguments, but got 1.
|
|
13
13
|
const parsed = PerseusMarkdown.parse(content);
|
|
14
14
|
|
|
15
15
|
PerseusMarkdown.traverseContent(parsed, function (node) {
|
|
@@ -22,7 +22,7 @@ function findImagesInContent(content, images) {
|
|
|
22
22
|
// Background images in some widgets are annoying to deal with because
|
|
23
23
|
// sometimes the objects aren't full when there isn't an image. So, we do some
|
|
24
24
|
// extra checking to make sure we don't cause an error or push an empty image.
|
|
25
|
-
function handleBackgroundImage(graph, images) {
|
|
25
|
+
function handleBackgroundImage(graph, images: Array<any>) {
|
|
26
26
|
if (graph && graph.backgroundImage && graph.backgroundImage.url) {
|
|
27
27
|
images.push(graph.backgroundImage.url);
|
|
28
28
|
}
|
|
@@ -32,7 +32,7 @@ function handleBackgroundImage(graph, images) {
|
|
|
32
32
|
// widget where they contain a renderer for images by calling
|
|
33
33
|
// findImagesInContent. We don't have to recurse through child widgets, because
|
|
34
34
|
// traverseRendererDeep does that for us.
|
|
35
|
-
function widgetCallback(widgetInfo, images) {
|
|
35
|
+
function widgetCallback(widgetInfo: any, images: Array<any>) {
|
|
36
36
|
if (!widgetInfo.options) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -115,13 +115,16 @@ function findImagesInRenderers(renderers) {
|
|
|
115
115
|
|
|
116
116
|
// Calls findImagesInContent on all of the different content areas for
|
|
117
117
|
// assessment items
|
|
118
|
-
function findImagesInItemData(itemData:
|
|
118
|
+
function findImagesInItemData(itemData: any): any {
|
|
119
119
|
let renderers = [];
|
|
120
120
|
if (itemData._multi) {
|
|
121
121
|
const shape = inferItemShape(itemData);
|
|
122
|
+
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'ContentNode' is not assignable to parameter of type 'never'.
|
|
122
123
|
findContentNodesInItem(itemData, shape, (node) => renderers.push(node));
|
|
124
|
+
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'HintNode' is not assignable to parameter of type 'never'.
|
|
123
125
|
findHintNodesInItem(itemData, shape, (node) => renderers.push(node));
|
|
124
126
|
} else {
|
|
127
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'any' is not assignable to type 'never'. | TS2322 - Type 'any' is not assignable to type 'never'.
|
|
125
128
|
renderers = [itemData.question, ...itemData.hints];
|
|
126
129
|
}
|
|
127
130
|
return findImagesInRenderers(renderers);
|
|
@@ -129,7 +132,7 @@ function findImagesInItemData(itemData: $FlowFixMe): $FlowFixMe {
|
|
|
129
132
|
|
|
130
133
|
// Calls findImagesInContent on all of the different content areas for
|
|
131
134
|
// articles
|
|
132
|
-
function findImagesInArticles(perseusContent:
|
|
135
|
+
function findImagesInArticles(perseusContent: any): any {
|
|
133
136
|
return findImagesInRenderers(perseusContent);
|
|
134
137
|
}
|
|
135
138
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Displays the given content in an iframe, isolating it from the parent page
|
|
4
3
|
*
|
|
@@ -16,8 +15,9 @@ import {Log} from "@khanacademy/perseus";
|
|
|
16
15
|
import * as React from "react";
|
|
17
16
|
|
|
18
17
|
let nextIframeID = 0;
|
|
19
|
-
const requestIframeData = {};
|
|
20
|
-
const updateIframeHeight = {};
|
|
18
|
+
const requestIframeData: Record<string, any> = {};
|
|
19
|
+
const updateIframeHeight: Record<string, any> = {};
|
|
20
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'iframeDataStore' does not exist on type 'Window & typeof globalThis'.
|
|
21
21
|
window.iframeDataStore = {};
|
|
22
22
|
|
|
23
23
|
// This is called once after Perseus is loaded and the iframe
|
|
@@ -49,29 +49,29 @@ window.addEventListener("message", (event) => {
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
type Props = {
|
|
52
|
+
type Props = {
|
|
53
53
|
// The HTML content to render to the iframe
|
|
54
54
|
// content?: string,
|
|
55
55
|
|
|
56
56
|
// The URL that the iframe should load
|
|
57
|
-
url: string
|
|
58
|
-
|
|
57
|
+
url: string;
|
|
59
58
|
// The data-* suffix for passing information to the iframe's JS
|
|
60
|
-
datasetKey: string
|
|
61
|
-
|
|
59
|
+
datasetKey: string;
|
|
62
60
|
// The value of the data-* attribute
|
|
63
|
-
datasetValue:
|
|
64
|
-
|
|
61
|
+
datasetValue: any;
|
|
65
62
|
// Whether to make the iframe's height match its content's height,
|
|
66
63
|
// used to prevent scrolling inside the iframe.
|
|
67
|
-
seamless: boolean
|
|
68
|
-
|
|
64
|
+
seamless: boolean;
|
|
65
|
+
};
|
|
69
66
|
|
|
70
67
|
class IframeContentRenderer extends React.Component<Props> {
|
|
71
|
-
_frame:
|
|
68
|
+
_frame: HTMLIFrameElement | null | undefined;
|
|
69
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
|
|
72
70
|
_isMounted: boolean;
|
|
73
|
-
_lastData:
|
|
71
|
+
_lastData: any;
|
|
72
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property '_lastHeight' has no initializer and is not definitely assigned in the constructor.
|
|
74
73
|
_lastHeight: number;
|
|
74
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property 'iframeID' has no initializer and is not definitely assigned in the constructor.
|
|
75
75
|
iframeID: number;
|
|
76
76
|
|
|
77
77
|
componentDidMount() {
|
|
@@ -87,10 +87,11 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
87
87
|
this.sendNewData(this._lastData);
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
updateIframeHeight[this.iframeID] = (height) => {
|
|
90
|
+
updateIframeHeight[this.iframeID] = (height: any) => {
|
|
91
91
|
this._lastHeight = height;
|
|
92
92
|
if (this._isMounted && this.props.seamless) {
|
|
93
93
|
// eslint-disable-next-line react/no-string-refs
|
|
94
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'style' does not exist on type 'ReactInstance'.
|
|
94
95
|
this.refs.container.style.height = height + "px";
|
|
95
96
|
}
|
|
96
97
|
};
|
|
@@ -106,9 +107,11 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
106
107
|
componentDidUpdate(prevProps: Props) {
|
|
107
108
|
if (!this.props.seamless) {
|
|
108
109
|
// eslint-disable-next-line react/no-string-refs
|
|
110
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'style' does not exist on type 'ReactInstance'.
|
|
109
111
|
this.refs.container.style.height = "100%";
|
|
110
112
|
} else {
|
|
111
113
|
// eslint-disable-next-line react/no-string-refs
|
|
114
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'style' does not exist on type 'ReactInstance'.
|
|
112
115
|
this.refs.container.style.height = this._lastHeight + "px";
|
|
113
116
|
}
|
|
114
117
|
|
|
@@ -129,6 +132,7 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
129
132
|
// Don't initialize the iframe until the page has loaded
|
|
130
133
|
if (this._frame) {
|
|
131
134
|
// eslint-disable-next-line react/no-string-refs
|
|
135
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'removeChild' does not exist on type 'ReactInstance'.
|
|
132
136
|
this.refs.container.removeChild(this._frame);
|
|
133
137
|
}
|
|
134
138
|
|
|
@@ -156,12 +160,13 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
// eslint-disable-next-line react/no-string-refs
|
|
163
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'appendChild' does not exist on type 'ReactInstance'.
|
|
159
164
|
this.refs.container.appendChild(frame);
|
|
160
165
|
|
|
161
166
|
this._frame = frame;
|
|
162
167
|
}
|
|
163
168
|
|
|
164
|
-
sendNewData(data:
|
|
169
|
+
sendNewData(data: any) {
|
|
165
170
|
const frame = this._frame;
|
|
166
171
|
if (this._isMounted && data && frame?.contentWindow) {
|
|
167
172
|
this._lastData = data;
|
|
@@ -169,12 +174,13 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
169
174
|
// We can't use JSON.stringify/parse for this because the apiOptions
|
|
170
175
|
// includes the functions GroupMetadataEditor, groupAnnotator,
|
|
171
176
|
// onFocusChange, and onInputError.
|
|
177
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'iframeDataStore' does not exist on type 'Window & typeof globalThis'.
|
|
172
178
|
window.iframeDataStore[this.iframeID] = data;
|
|
173
179
|
frame.contentWindow.postMessage(this.iframeID, "*");
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
182
|
|
|
177
|
-
render(): React.
|
|
183
|
+
render(): React.ReactNode {
|
|
178
184
|
// eslint-disable-next-line react/no-string-refs
|
|
179
185
|
return <div ref="container" style={{width: "100%", height: "100%"}} />;
|
|
180
186
|
}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
export {default as
|
|
3
|
-
export {default as
|
|
4
|
-
export {default as
|
|
5
|
-
export {default as
|
|
6
|
-
export {default as
|
|
7
|
-
export {default as
|
|
8
|
-
export {default as
|
|
9
|
-
export {default as
|
|
10
|
-
export {default as
|
|
11
|
-
export {default as
|
|
12
|
-
export {default as
|
|
13
|
-
export {default as
|
|
14
|
-
export {default as StatefulEditorPage} from "./stateful-editor-page.jsx";
|
|
1
|
+
export {default as ArticleEditor} from "./article-editor";
|
|
2
|
+
export {default as DeviceFramer} from "./components/device-framer";
|
|
3
|
+
export {default as ViewportResizer} from "./components/viewport-resizer";
|
|
4
|
+
export {default as ArticleDiff} from "./diffs/article-diff";
|
|
5
|
+
export {default as ItemDiff} from "./diffs/item-diff";
|
|
6
|
+
export {default as StructuredItemDiff} from "./diffs/structured-item-diff";
|
|
7
|
+
export {default as EditorPage} from "./editor-page";
|
|
8
|
+
export {default as Editor} from "./editor";
|
|
9
|
+
export {default as i18n} from "./i18n";
|
|
10
|
+
export {default as IframeContentRenderer} from "./iframe-content-renderer";
|
|
11
|
+
export {default as MultiRendererEditor} from "./multirenderer-editor";
|
|
12
|
+
export {default as StatefulArticleEditor} from "./stateful-article-editor";
|
|
13
|
+
export {default as StatefulEditorPage} from "./stateful-editor-page";
|
|
15
14
|
|
|
16
15
|
import "./styles/perseus-editor.less";
|
|
17
16
|
|
|
18
17
|
// eslint-disable-next-line import/order
|
|
19
18
|
import {Widgets} from "@khanacademy/perseus";
|
|
20
|
-
import AllEditors from "./all-editors
|
|
21
|
-
import AllWidgets from "./all-widgets
|
|
19
|
+
import AllEditors from "./all-editors";
|
|
20
|
+
import AllWidgets from "./all-widgets";
|
|
22
21
|
|
|
23
22
|
Widgets.registerEditors(AllEditors);
|
|
24
23
|
Widgets.registerWidgets(AllWidgets);
|