@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,9 +1,8 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
2
|
import jsdiff from "jsdiff";
|
|
4
3
|
import _ from "underscore";
|
|
5
4
|
|
|
6
|
-
const statusFor = function (chunk) {
|
|
5
|
+
const statusFor = function (chunk: any) {
|
|
7
6
|
if (chunk.added) {
|
|
8
7
|
return "added";
|
|
9
8
|
}
|
|
@@ -15,7 +14,7 @@ const statusFor = function (chunk) {
|
|
|
15
14
|
|
|
16
15
|
// Turn a chunk (which contains an array of values and a status)
|
|
17
16
|
// into an array of values, each with the same status
|
|
18
|
-
const splitUpChunk = (chunk) =>
|
|
17
|
+
const splitUpChunk = (chunk: any) =>
|
|
19
18
|
_.map(chunk.value, (value) => {
|
|
20
19
|
return {
|
|
21
20
|
value: value,
|
|
@@ -25,7 +24,7 @@ const splitUpChunk = (chunk) =>
|
|
|
25
24
|
|
|
26
25
|
// Apply `fn` to every element in `lst` and then concatenate all the results
|
|
27
26
|
// http://clojuredocs.org/clojure_core/clojure.core/mapcat
|
|
28
|
-
const mapcat = function (lst, fn) {
|
|
27
|
+
const mapcat = function (lst: any, fn: (chunk?: any) => any) {
|
|
29
28
|
return _.flatten(_.map(lst, fn), true /* only flatten one level */);
|
|
30
29
|
};
|
|
31
30
|
|
|
@@ -39,7 +38,7 @@ const ArrayDiff = new jsdiff.Diff();
|
|
|
39
38
|
ArrayDiff.tokenize = (array) => _.map(array, (elem) => [elem]);
|
|
40
39
|
// The default is `+` for string concatenation, which doesn't work for array
|
|
41
40
|
// concatenation.
|
|
42
|
-
ArrayDiff.join = (a, b) => a.concat(b);
|
|
41
|
+
ArrayDiff.join = (a, b: any) => a.concat(b);
|
|
43
42
|
// By default jsDiff uses ===
|
|
44
43
|
ArrayDiff.equals = _.isEqual;
|
|
45
44
|
|
|
@@ -54,15 +53,15 @@ ArrayDiff.equals = _.isEqual;
|
|
|
54
53
|
// { "value":2, "status":"unchanged"},
|
|
55
54
|
// { "value":3, "status":"unchanged"},
|
|
56
55
|
// { "value":4, "status":"added"}]
|
|
57
|
-
const flattenChunks = (chunks) => mapcat(chunks, splitUpChunk);
|
|
56
|
+
const flattenChunks = (chunks: any) => mapcat(chunks, splitUpChunk);
|
|
58
57
|
|
|
59
58
|
// Take two arrays and create a diff for them. The result is two arrays of
|
|
60
59
|
// objects, one for the things that should be included in a 'before', and one
|
|
61
60
|
// for 'after'
|
|
62
61
|
const stringArrayDiff = function (
|
|
63
|
-
a:
|
|
64
|
-
b:
|
|
65
|
-
):
|
|
62
|
+
a: ReadonlyArray<any>,
|
|
63
|
+
b: ReadonlyArray<any>,
|
|
64
|
+
): any {
|
|
66
65
|
const diffResult = ArrayDiff.diff(a, b);
|
|
67
66
|
const flattened = flattenChunks(diffResult);
|
|
68
67
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* A side by side diff view for Perseus exercise items
|
|
4
3
|
* that do not have the standard question layout.
|
|
@@ -11,12 +10,12 @@ import {
|
|
|
11
10
|
} from "@khanacademy/perseus";
|
|
12
11
|
import * as React from "react";
|
|
13
12
|
|
|
14
|
-
import RendererDiff from "./renderer-diff
|
|
15
|
-
import TagsDiff from "./tags-diff
|
|
13
|
+
import RendererDiff from "./renderer-diff";
|
|
14
|
+
import TagsDiff from "./tags-diff";
|
|
16
15
|
|
|
17
16
|
import type {Item, Path, Shape} from "@khanacademy/perseus";
|
|
18
17
|
|
|
19
|
-
type ItemList = [
|
|
18
|
+
type ItemList = [unknown, Path];
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Outputs true if path begins with beginPath, false otherwise.
|
|
@@ -53,11 +52,13 @@ function checkPath(beforePath: Path, afterPath: Path): boolean {
|
|
|
53
52
|
* Given a path, returns a title. Puts colons after numbers in the path.
|
|
54
53
|
*/
|
|
55
54
|
function getTitle(path: Path): string {
|
|
56
|
-
const title = [];
|
|
55
|
+
const title: Array<string> = [];
|
|
57
56
|
for (let i = 0; i < path.length; i++) {
|
|
58
57
|
if (typeof path[i] === "number") {
|
|
58
|
+
// @ts-expect-error [FEI-5003] - TS2365 - Operator '+' cannot be applied to types 'string | number' and 'number'.
|
|
59
59
|
title.push((path[i] + 1).toString() + ":");
|
|
60
60
|
} else {
|
|
61
|
+
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'string | number' is not assignable to parameter of type 'string'.
|
|
61
62
|
title.push(path[i]);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -65,18 +66,17 @@ function getTitle(path: Path): string {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
type Tag = {
|
|
68
|
-
idToName: (string) => string
|
|
69
|
-
nameToId: (string) => string
|
|
70
|
-
names:
|
|
71
|
-
...
|
|
69
|
+
idToName: (arg1: string) => string;
|
|
70
|
+
nameToId: (arg1: string) => string;
|
|
71
|
+
names: ReadonlyArray<string>;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
type Props = {
|
|
75
|
-
after: Item
|
|
76
|
-
before: Item
|
|
77
|
-
shape: Shape
|
|
78
|
-
tags: Tag
|
|
79
|
-
|
|
74
|
+
type Props = {
|
|
75
|
+
after: Item;
|
|
76
|
+
before: Item;
|
|
77
|
+
shape: Shape;
|
|
78
|
+
tags: Tag;
|
|
79
|
+
};
|
|
80
80
|
|
|
81
81
|
class StructuredItemDiff extends React.Component<Props> {
|
|
82
82
|
/**
|
|
@@ -86,14 +86,11 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
86
86
|
* from buildMapper(), is the same order they appear in in the shape.
|
|
87
87
|
*/
|
|
88
88
|
static generateCompletePathsList(
|
|
89
|
-
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
90
89
|
beforeList: Array<ItemList>,
|
|
91
|
-
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
92
90
|
afterList: Array<ItemList>,
|
|
93
|
-
// eslint-disable-next-line ft-flow/no-mutable-array
|
|
94
91
|
result: Array<Path>,
|
|
95
92
|
shape: Shape,
|
|
96
|
-
path:
|
|
93
|
+
path: ReadonlyArray<any>,
|
|
97
94
|
): void {
|
|
98
95
|
if (
|
|
99
96
|
shape.type === "content" ||
|
|
@@ -153,10 +150,10 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
153
150
|
}
|
|
154
151
|
}
|
|
155
152
|
|
|
156
|
-
render(): React.
|
|
153
|
+
render(): React.ReactNode {
|
|
157
154
|
const {before, after, shape, tags} = this.props;
|
|
158
155
|
|
|
159
|
-
const beforeList = [];
|
|
156
|
+
const beforeList: Array<ItemList> = [];
|
|
160
157
|
const afterList = [];
|
|
161
158
|
|
|
162
159
|
buildMapper()
|
|
@@ -166,8 +163,11 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
166
163
|
.mapTree(itemToTree(before), shape);
|
|
167
164
|
|
|
168
165
|
buildMapper()
|
|
166
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'unknown' is not assignable to type 'never'. | TS2322 - Type 'Path' is not assignable to type 'never'.
|
|
169
167
|
.setContentMapper((c, _, p) => afterList.push([c, p]))
|
|
168
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'unknown' is not assignable to type 'never'. | TS2322 - Type 'Path' is not assignable to type 'never'.
|
|
170
169
|
.setHintMapper((c, _, p) => afterList.push([c, p]))
|
|
170
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'unknown' is not assignable to type 'never'. | TS2322 - Type 'Path' is not assignable to type 'never'.
|
|
171
171
|
.setTagsMapper((c, _, p) => afterList.push([c, p]))
|
|
172
172
|
.mapTree(itemToTree(after), shape);
|
|
173
173
|
|
|
@@ -176,7 +176,7 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
176
176
|
const beforeListModified = beforeList.slice();
|
|
177
177
|
const afterListModified = afterList.slice();
|
|
178
178
|
|
|
179
|
-
const allDiffPaths = [];
|
|
179
|
+
const allDiffPaths: Array<Path> = [];
|
|
180
180
|
StructuredItemDiff.generateCompletePathsList(
|
|
181
181
|
beforeListModified,
|
|
182
182
|
afterListModified,
|
|
@@ -187,7 +187,7 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
187
187
|
|
|
188
188
|
const diffCount = allDiffPaths.length;
|
|
189
189
|
|
|
190
|
-
const diffs: React.
|
|
190
|
+
const diffs: React.ReactNode = allDiffPaths.map((path, n) => {
|
|
191
191
|
const isTag = path[path.length - 1] === "tags";
|
|
192
192
|
const currentTitle = getTitle(path);
|
|
193
193
|
|
|
@@ -203,10 +203,11 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
203
203
|
before = [[], path];
|
|
204
204
|
}
|
|
205
205
|
if (!after) {
|
|
206
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Path[]' is not assignable to type 'undefined'.
|
|
206
207
|
after = [[], path];
|
|
207
208
|
}
|
|
208
209
|
|
|
209
|
-
const beforeTags = [];
|
|
210
|
+
const beforeTags: Array<string> = [];
|
|
210
211
|
if (Array.isArray(before[0])) {
|
|
211
212
|
before[0].forEach((tagId) => {
|
|
212
213
|
if (typeof tagId === "string") {
|
|
@@ -214,8 +215,10 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
214
215
|
}
|
|
215
216
|
});
|
|
216
217
|
}
|
|
217
|
-
const afterTags = [];
|
|
218
|
+
const afterTags: Array<string> = [];
|
|
219
|
+
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'.
|
|
218
220
|
if (Array.isArray(after[0])) {
|
|
221
|
+
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'.
|
|
219
222
|
after[0].forEach((tagId) => {
|
|
220
223
|
if (typeof tagId === "string") {
|
|
221
224
|
afterTags.push(tags.idToName(tagId));
|
|
@@ -248,12 +251,14 @@ class StructuredItemDiff extends React.Component<Props> {
|
|
|
248
251
|
before = [buildEmptyItemTreeForShape(shapes.content), path];
|
|
249
252
|
}
|
|
250
253
|
if (!after) {
|
|
254
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'any[]' is not assignable to type 'undefined'.
|
|
251
255
|
after = [buildEmptyItemTreeForShape(shapes.content), path];
|
|
252
256
|
}
|
|
253
257
|
return (
|
|
254
258
|
<RendererDiff
|
|
255
|
-
before={
|
|
256
|
-
|
|
259
|
+
before={before[0] as any}
|
|
260
|
+
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'.
|
|
261
|
+
after={after[0] as any}
|
|
257
262
|
title={currentTitle}
|
|
258
263
|
showAlignmentOptions={false}
|
|
259
264
|
showSeparator={n < diffCount - 1}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* A side by side diff view for general passage layout tags.
|
|
4
3
|
*/
|
|
5
4
|
|
|
6
5
|
import * as React from "react";
|
|
7
6
|
|
|
8
|
-
import TextDiff from "./text-diff
|
|
7
|
+
import TextDiff from "./text-diff";
|
|
9
8
|
|
|
10
|
-
type Props = {
|
|
11
|
-
afterOnly:
|
|
12
|
-
beforeOnly:
|
|
13
|
-
intersection:
|
|
14
|
-
showSeparator: boolean
|
|
15
|
-
title: string
|
|
16
|
-
|
|
9
|
+
type Props = {
|
|
10
|
+
afterOnly: ReadonlyArray<string>;
|
|
11
|
+
beforeOnly: ReadonlyArray<string>;
|
|
12
|
+
intersection: ReadonlyArray<string>;
|
|
13
|
+
showSeparator: boolean;
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
17
16
|
|
|
18
17
|
class TagsDiff extends React.Component<Props> {
|
|
19
|
-
static defaultProps: {
|
|
20
|
-
afterOnly:
|
|
21
|
-
beforeOnly:
|
|
22
|
-
showSeparator: boolean
|
|
23
|
-
title: string
|
|
24
|
-
|
|
18
|
+
static defaultProps: {
|
|
19
|
+
afterOnly: ReadonlyArray<any>;
|
|
20
|
+
beforeOnly: ReadonlyArray<any>;
|
|
21
|
+
showSeparator: boolean;
|
|
22
|
+
title: string;
|
|
23
|
+
} = {
|
|
25
24
|
afterOnly: [],
|
|
26
25
|
beforeOnly: [],
|
|
27
26
|
showSeparator: false,
|
|
28
27
|
title: "Question tags",
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
render(): React.
|
|
30
|
+
render(): React.ReactNode {
|
|
32
31
|
const {afterOnly, beforeOnly, intersection, showSeparator} = this.props;
|
|
33
32
|
|
|
34
33
|
const beforeTags = intersection.concat(beforeOnly).join("\n") + "\n";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/no-unsafe */
|
|
2
|
-
// @flow
|
|
3
2
|
import {components} from "@khanacademy/perseus";
|
|
4
3
|
import classNames from "classnames";
|
|
5
4
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
@@ -8,8 +7,8 @@ import PropTypes from "prop-types";
|
|
|
8
7
|
import * as React from "react";
|
|
9
8
|
import _ from "underscore";
|
|
10
9
|
|
|
11
|
-
import splitDiff from "./split-diff
|
|
12
|
-
import stringArrayDiff from "./string-array-diff
|
|
10
|
+
import splitDiff from "./split-diff";
|
|
11
|
+
import stringArrayDiff from "./string-array-diff";
|
|
13
12
|
|
|
14
13
|
const {SvgImage} = components;
|
|
15
14
|
|
|
@@ -18,11 +17,11 @@ const AFTER = "after";
|
|
|
18
17
|
|
|
19
18
|
const IMAGE_REGEX = /http.*?\.png|web\+graphie[^)]*/g;
|
|
20
19
|
|
|
21
|
-
const imagesInString = function (str) {
|
|
20
|
+
const imagesInString = function (str: any) {
|
|
22
21
|
return str.match(IMAGE_REGEX) || [];
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
const classFor = function (entry, ifAdded, ifRemoved) {
|
|
24
|
+
const classFor = function (entry: any, ifAdded: string, ifRemoved: string) {
|
|
26
25
|
if (entry.added) {
|
|
27
26
|
return ifAdded;
|
|
28
27
|
}
|
|
@@ -32,12 +31,12 @@ const classFor = function (entry, ifAdded, ifRemoved) {
|
|
|
32
31
|
return "";
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
class ImageDiffSide extends React.Component
|
|
34
|
+
class ImageDiffSide extends React.Component<any> {
|
|
36
35
|
static propTypes = {
|
|
37
36
|
images: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
render(): React.
|
|
39
|
+
render(): React.ReactNode {
|
|
41
40
|
return (
|
|
42
41
|
<div>
|
|
43
42
|
{_.map(this.props.images, (entry, index) => {
|
|
@@ -51,6 +50,7 @@ class ImageDiffSide extends React.Component<$FlowFixMe> {
|
|
|
51
50
|
<div key={index}>
|
|
52
51
|
<div className={className}>
|
|
53
52
|
{/* $FlowFixMe[prop-missing]: the alt prop is missing */}
|
|
53
|
+
{/* @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; title: any; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'. */}
|
|
54
54
|
<SvgImage
|
|
55
55
|
src={entry.value}
|
|
56
56
|
title={entry.value}
|
|
@@ -64,23 +64,23 @@ class ImageDiffSide extends React.Component<$FlowFixMe> {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
class TextDiff extends React.Component
|
|
67
|
+
class TextDiff extends React.Component<any, any> {
|
|
68
68
|
static propTypes = {
|
|
69
69
|
after: PropTypes.string,
|
|
70
70
|
before: PropTypes.string,
|
|
71
71
|
title: PropTypes.string.isRequired,
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
static defaultProps:
|
|
74
|
+
static defaultProps: any = {
|
|
75
75
|
after: "",
|
|
76
76
|
before: "",
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
state:
|
|
79
|
+
state: any = {
|
|
80
80
|
collapsed: this.props.before === this.props.after,
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
UNSAFE_componentWillReceiveProps(nextProps:
|
|
83
|
+
UNSAFE_componentWillReceiveProps(nextProps: any) {
|
|
84
84
|
this.setState({
|
|
85
85
|
collapsed: nextProps.before === nextProps.after,
|
|
86
86
|
});
|
|
@@ -90,7 +90,7 @@ class TextDiff extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
90
90
|
this.setState({collapsed: false});
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
render(): React.
|
|
93
|
+
render(): React.ReactNode {
|
|
94
94
|
const diffed = jsdiff.diffWords(this.props.before, this.props.after);
|
|
95
95
|
|
|
96
96
|
const lines = splitDiff(diffed);
|
|
@@ -100,7 +100,7 @@ class TextDiff extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
100
100
|
const images = stringArrayDiff(beforeImages, afterImages);
|
|
101
101
|
|
|
102
102
|
const renderedLines = _.map(lines, (line) => {
|
|
103
|
-
const contents = {};
|
|
103
|
+
const contents: Record<string, any> = {};
|
|
104
104
|
|
|
105
105
|
contents.before = _(line).map(function (entry, i) {
|
|
106
106
|
return (
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import _ from "underscore";
|
|
3
2
|
|
|
4
3
|
const UNCHANGED = "unchanged";
|
|
@@ -8,7 +7,7 @@ const REMOVED = "removed";
|
|
|
8
7
|
|
|
9
8
|
// For values which do not have further values nested within them (strings,
|
|
10
9
|
// numbers, and booleans)
|
|
11
|
-
const valueEntry = function (before, after, key) {
|
|
10
|
+
const valueEntry = function (before: any, after: any, key) {
|
|
12
11
|
let status;
|
|
13
12
|
if (before === after) {
|
|
14
13
|
status = UNCHANGED;
|
|
@@ -30,7 +29,7 @@ const valueEntry = function (before, after, key) {
|
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
// For values which require a more granular diff (objects and arrays)
|
|
33
|
-
const objectEntry = function (before, after, key) {
|
|
32
|
+
const objectEntry = function (before: any, after: any, key) {
|
|
34
33
|
const beforeKeys = _.isObject(before) ? _(before).keys() : [];
|
|
35
34
|
const afterKeys = _.isObject(after) ? _(after).keys() : [];
|
|
36
35
|
const keys = _.union(beforeKeys, afterKeys);
|
|
@@ -60,11 +59,7 @@ const objectEntry = function (before, after, key) {
|
|
|
60
59
|
};
|
|
61
60
|
};
|
|
62
61
|
|
|
63
|
-
const performDiff = function (
|
|
64
|
-
before: $FlowFixMe,
|
|
65
|
-
after: $FlowFixMe,
|
|
66
|
-
key?: $FlowFixMe,
|
|
67
|
-
): $FlowFixMe {
|
|
62
|
+
const performDiff = function (before: any, after: any, key?: any): any {
|
|
68
63
|
if (typeof before === "object" || typeof after === "object") {
|
|
69
64
|
return objectEntry(before, after, key);
|
|
70
65
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {components} from "@khanacademy/perseus";
|
|
3
2
|
import classNames from "classnames";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import _ from "underscore";
|
|
7
6
|
|
|
8
|
-
import performDiff from "./widget-diff-performer
|
|
7
|
+
import performDiff from "./widget-diff-performer";
|
|
9
8
|
|
|
10
9
|
const {SvgImage} = components;
|
|
11
10
|
|
|
12
|
-
const indentationFromDepth = function (depth) {
|
|
11
|
+
const indentationFromDepth = function (depth: any) {
|
|
13
12
|
return (depth - 1) * 20;
|
|
14
13
|
};
|
|
15
14
|
|
|
@@ -18,7 +17,7 @@ const AFTER = "after";
|
|
|
18
17
|
|
|
19
18
|
const UNCHANGED = "unchanged";
|
|
20
19
|
|
|
21
|
-
class DiffSide extends React.Component
|
|
20
|
+
class DiffSide extends React.Component<any> {
|
|
22
21
|
static propTypes = {
|
|
23
22
|
className: PropTypes.string.isRequired,
|
|
24
23
|
depth: PropTypes.number.isRequired,
|
|
@@ -28,7 +27,7 @@ class DiffSide extends React.Component<$FlowFixMe> {
|
|
|
28
27
|
value: PropTypes.string,
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
render(): React.
|
|
30
|
+
render(): React.ReactNode {
|
|
32
31
|
const className = classNames(this.props.className, {
|
|
33
32
|
"diff-row": true,
|
|
34
33
|
before: this.props.side === BEFORE,
|
|
@@ -53,7 +52,7 @@ class DiffSide extends React.Component<$FlowFixMe> {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
class CollapsedRow extends React.Component
|
|
55
|
+
class CollapsedRow extends React.Component<any> {
|
|
57
56
|
static propTypes = {
|
|
58
57
|
depth: PropTypes.number,
|
|
59
58
|
onClick: PropTypes.func.isRequired,
|
|
@@ -63,7 +62,7 @@ class CollapsedRow extends React.Component<$FlowFixMe> {
|
|
|
63
62
|
depth: 0,
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
render(): React.
|
|
65
|
+
render(): React.ReactNode {
|
|
67
66
|
const self = this;
|
|
68
67
|
return (
|
|
69
68
|
<div onClick={self.props.onClick} style={{clear: "both"}}>
|
|
@@ -91,7 +90,7 @@ class CollapsedRow extends React.Component<$FlowFixMe> {
|
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
// Component representing a single property that may be nested.
|
|
94
|
-
class DiffEntry extends React.Component
|
|
93
|
+
class DiffEntry extends React.Component<any, any> {
|
|
95
94
|
static propTypes = {
|
|
96
95
|
depth: PropTypes.number,
|
|
97
96
|
entry: PropTypes.shape({
|
|
@@ -115,7 +114,7 @@ class DiffEntry extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
115
114
|
this.setState({expanded: true});
|
|
116
115
|
};
|
|
117
116
|
|
|
118
|
-
render(): React.
|
|
117
|
+
render(): React.ReactNode {
|
|
119
118
|
const entry = this.props.entry;
|
|
120
119
|
const propertyDeleted = entry.status === "removed";
|
|
121
120
|
const propertyAdded = entry.status === "added";
|
|
@@ -197,7 +196,7 @@ class DiffEntry extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
197
196
|
}
|
|
198
197
|
|
|
199
198
|
// For image widgets, show the actual image
|
|
200
|
-
class ImageWidgetDiff extends React.Component
|
|
199
|
+
class ImageWidgetDiff extends React.Component<any> {
|
|
201
200
|
static propTypes = {
|
|
202
201
|
after: PropTypes.shape({
|
|
203
202
|
options: PropTypes.objectOf(PropTypes.any),
|
|
@@ -207,7 +206,7 @@ class ImageWidgetDiff extends React.Component<$FlowFixMe> {
|
|
|
207
206
|
}).isRequired,
|
|
208
207
|
};
|
|
209
208
|
|
|
210
|
-
render(): React.
|
|
209
|
+
render(): React.ReactNode {
|
|
211
210
|
const {before, after} = this.props;
|
|
212
211
|
const beforeSrc =
|
|
213
212
|
before.options && before.options.backgroundImage
|
|
@@ -229,6 +228,7 @@ class ImageWidgetDiff extends React.Component<$FlowFixMe> {
|
|
|
229
228
|
})}
|
|
230
229
|
>
|
|
231
230
|
{/* $FlowFixMe[prop-missing]: the alt props is missing */}
|
|
231
|
+
{/* @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; title: any; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'. */}
|
|
232
232
|
<SvgImage src={beforeSrc} title={beforeSrc} />
|
|
233
233
|
</div>
|
|
234
234
|
)}
|
|
@@ -243,6 +243,7 @@ class ImageWidgetDiff extends React.Component<$FlowFixMe> {
|
|
|
243
243
|
})}
|
|
244
244
|
>
|
|
245
245
|
{/* $FlowFixMe[prop-missing]: the alt props is missing */}
|
|
246
|
+
{/* @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; title: any; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'. */}
|
|
246
247
|
<SvgImage src={afterSrc} title={afterSrc} />
|
|
247
248
|
</div>
|
|
248
249
|
)}
|
|
@@ -252,7 +253,7 @@ class ImageWidgetDiff extends React.Component<$FlowFixMe> {
|
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
|
|
255
|
-
class WidgetDiff extends React.Component
|
|
256
|
+
class WidgetDiff extends React.Component<any> {
|
|
256
257
|
static propTypes = {
|
|
257
258
|
after: PropTypes.shape({
|
|
258
259
|
options: PropTypes.objectOf(PropTypes.any),
|
|
@@ -264,13 +265,13 @@ class WidgetDiff extends React.Component<$FlowFixMe> {
|
|
|
264
265
|
type: PropTypes.string,
|
|
265
266
|
};
|
|
266
267
|
|
|
267
|
-
static defaultProps:
|
|
268
|
+
static defaultProps: any = {
|
|
268
269
|
after: {},
|
|
269
270
|
before: {},
|
|
270
271
|
type: "",
|
|
271
272
|
};
|
|
272
273
|
|
|
273
|
-
render(): React.
|
|
274
|
+
render(): React.ReactNode {
|
|
274
275
|
const {after, before, title, type} = this.props;
|
|
275
276
|
const diff = performDiff(before, after);
|
|
276
277
|
return (
|