@khanacademy/perseus-editor 2.6.0 → 2.6.2
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/CHANGELOG.md +24 -0
- package/dist/article-editor.d.ts +1 -2
- package/dist/components/form-wrapped-text-field.d.ts +1 -10
- package/dist/components/graph-points-count-selector.d.ts +1 -1
- package/dist/es/index.js +414 -436
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +411 -435
- package/dist/index.js.map +1 -1
- package/dist/widgets/input-number-editor.d.ts +1 -2
- package/dist/widgets/interactive-graph-editor.d.ts +48 -47
- package/dist/widgets/plotter-editor.d.ts +47 -23
- package/package.json +12 -12
- package/src/__stories__/editor.stories.tsx +3 -1
- package/src/__tests__/i18n.test.ts +1 -1
- package/src/article-editor.tsx +13 -14
- package/src/components/checkbox.tsx +2 -1
- package/src/components/dropdown-option.tsx +13 -12
- package/src/components/form-wrapped-text-field.tsx +5 -2
- package/src/components/graph-points-count-selector.tsx +3 -1
- package/src/components/graph-settings.tsx +1 -1
- package/src/components/hover-behavior.ts +2 -2
- package/src/components/json-editor.tsx +2 -2
- package/src/components/sortable.tsx +1 -1
- package/src/components/util.ts +1 -1
- package/src/components/widget-editor.tsx +8 -7
- package/src/diffs/__tests__/structured-item-diff.test.ts +8 -8
- package/src/diffs/renderer-diff.tsx +3 -3
- package/src/diffs/split-diff.ts +2 -2
- package/src/diffs/structured-item-diff.tsx +11 -10
- package/src/diffs/text-diff.tsx +1 -1
- package/src/diffs/widget-diff.tsx +2 -2
- package/src/editor-page.tsx +8 -8
- package/src/editor.tsx +37 -36
- package/src/hint-editor.tsx +28 -27
- package/src/i18n.ts +4 -4
- package/src/iframe-content-renderer.tsx +10 -10
- package/src/item-editor.tsx +4 -4
- package/src/katex-mhchem/parser.js +24 -24
- package/src/multirenderer-editor.tsx +11 -11
- package/src/widgets/__stories__/label-image-editor.stories.tsx +1 -0
- package/src/widgets/__stories__/radio-editor.stories.tsx +1 -0
- package/src/widgets/categorizer-editor.tsx +3 -3
- package/src/widgets/cs-program-editor.tsx +2 -2
- package/src/widgets/definition-editor.tsx +3 -2
- package/src/widgets/dropdown-editor.tsx +9 -8
- package/src/widgets/example-graphie-widget-editor.tsx +1 -1
- package/src/widgets/example-graphie-widget.tsx +2 -2
- package/src/widgets/example-widget-editor.tsx +2 -2
- package/src/widgets/example-widget.tsx +4 -3
- package/src/widgets/explanation-editor.tsx +4 -3
- package/src/widgets/expression-editor.tsx +9 -9
- package/src/widgets/graded-group-editor.tsx +7 -6
- package/src/widgets/graded-group-set-editor.tsx +3 -3
- package/src/widgets/grapher-editor.tsx +3 -2
- package/src/widgets/group-editor.tsx +4 -3
- package/src/widgets/iframe-editor.tsx +5 -4
- package/src/widgets/input-number-editor.tsx +6 -6
- package/src/widgets/interaction-editor.tsx +103 -102
- package/src/widgets/interactive-graph-editor.tsx +12 -8
- package/src/widgets/label-image/marker.tsx +2 -1
- package/src/widgets/label-image/question-markers.tsx +1 -1
- package/src/widgets/lights-puzzle-editor.tsx +5 -4
- package/src/widgets/matrix-editor.tsx +2 -2
- package/src/widgets/measurer-editor.tsx +7 -6
- package/src/widgets/molecule-editor.tsx +2 -2
- package/src/widgets/number-line-editor.tsx +2 -1
- package/src/widgets/numeric-input-editor.tsx +2 -2
- package/src/widgets/orderer-editor.tsx +3 -2
- package/src/widgets/passage-editor.tsx +3 -3
- package/src/widgets/passage-ref-editor.tsx +4 -3
- package/src/widgets/passage-ref-target-editor.tsx +1 -1
- package/src/widgets/plotter-editor.tsx +253 -243
- package/src/widgets/radio/editor.tsx +3 -3
- package/src/widgets/reaction-diagram-editor.tsx +5 -5
- package/src/widgets/sequence-editor.tsx +1 -1
- package/src/widgets/simple-markdown-tester-editor.tsx +4 -3
- package/src/widgets/simple-markdown-tester.tsx +2 -2
- package/src/widgets/simulator-editor.tsx +1 -1
- package/src/widgets/sorter-editor.tsx +2 -1
- package/src/widgets/table-editor.tsx +1 -1
- package/src/widgets/transformer-editor.tsx +10 -10
- package/src/widgets/unit-editor.tsx +5 -5
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/all-editors.js.flow +0 -8
- package/dist/all-widgets.js.flow +0 -34
- package/dist/article-editor.js.flow +0 -72
- package/dist/components/blur-input.js.flow +0 -25
- package/dist/components/checkbox.js.flow +0 -26
- package/dist/components/device-framer.js.flow +0 -20
- package/dist/components/drag-target.js.flow +0 -8
- package/dist/components/dropdown-option.js.flow +0 -49
- package/dist/components/form-wrapped-text-field.js.flow +0 -45
- package/dist/components/graph-points-count-selector.js.flow +0 -12
- package/dist/components/graph-settings.js.flow +0 -8
- package/dist/components/graph-type-selector.js.flow +0 -12
- package/dist/components/hover-behavior.js.flow +0 -48
- package/dist/components/json-editor.js.flow +0 -8
- package/dist/components/link.js.flow +0 -50
- package/dist/components/section-control-button.js.flow +0 -25
- package/dist/components/segment-count-selector.js.flow +0 -11
- package/dist/components/simple-button.js.flow +0 -18
- package/dist/components/sortable.js.flow +0 -8
- package/dist/components/util.js.flow +0 -9
- package/dist/components/viewport-resizer.js.flow +0 -22
- package/dist/components/widget-editor.js.flow +0 -91
- package/dist/components/widget-select.js.flow +0 -16
- package/dist/diffs/article-diff.js.flow +0 -71
- package/dist/diffs/item-diff.js.flow +0 -41
- package/dist/diffs/renderer-diff.js.flow +0 -25
- package/dist/diffs/split-diff.js.flow +0 -8
- package/dist/diffs/string-array-diff.js.flow +0 -11
- package/dist/diffs/structured-item-diff.js.flow +0 -37
- package/dist/diffs/tags-diff.js.flow +0 -24
- package/dist/diffs/text-diff.js.flow +0 -21
- package/dist/diffs/widget-diff-performer.js.flow +0 -8
- package/dist/diffs/widget-diff.js.flow +0 -31
- package/dist/editor-page.js.flow +0 -72
- package/dist/editor.js.flow +0 -96
- package/dist/hint-editor.js.flow +0 -87
- package/dist/i18n.js.flow +0 -13
- package/dist/iframe-content-renderer.js.flow +0 -28
- package/dist/index.js.flow +0 -23
- package/dist/item-editor.js.flow +0 -46
- package/dist/item-extras-editor.js.flow +0 -23
- package/dist/katex-error-view.js.flow +0 -24
- package/dist/multirenderer-editor.js.flow +0 -46
- package/dist/stateful-article-editor.js.flow +0 -16
- package/dist/stateful-editor-page.js.flow +0 -8
- package/dist/testing-widgets.js.flow +0 -34
- package/dist/util/points.js.flow +0 -9
- package/dist/util/register-all-widgets-and-editors-for-testing.js.flow +0 -7
- package/dist/widgets/categorizer-editor.js.flow +0 -62
- package/dist/widgets/cs-program-editor.js.flow +0 -25
- package/dist/widgets/definition-editor.js.flow +0 -23
- package/dist/widgets/dropdown-editor.js.flow +0 -37
- package/dist/widgets/example-graphie-widget-editor.js.flow +0 -25
- package/dist/widgets/example-graphie-widget.js.flow +0 -102
- package/dist/widgets/example-widget-editor.js.flow +0 -26
- package/dist/widgets/example-widget.js.flow +0 -86
- package/dist/widgets/explanation-editor.js.flow +0 -27
- package/dist/widgets/expression-editor.js.flow +0 -43
- package/dist/widgets/graded-group-editor.js.flow +0 -68
- package/dist/widgets/graded-group-set-editor.js.flow +0 -66
- package/dist/widgets/grapher-editor.js.flow +0 -21
- package/dist/widgets/group-editor.js.flow +0 -64
- package/dist/widgets/iframe-editor.js.flow +0 -24
- package/dist/widgets/image-editor.js.flow +0 -8
- package/dist/widgets/input-number-editor.js.flow +0 -77
- package/dist/widgets/interaction/constraint-editor.js.flow +0 -35
- package/dist/widgets/interaction-editor.js.flow +0 -36
- package/dist/widgets/interactive-graph-editor.js.flow +0 -5803
- package/dist/widgets/label-image/answer-choices.js.flow +0 -16
- package/dist/widgets/label-image/behavior.js.flow +0 -17
- package/dist/widgets/label-image/marker.js.flow +0 -32
- package/dist/widgets/label-image/question-markers.js.flow +0 -23
- package/dist/widgets/label-image/select-image.js.flow +0 -13
- package/dist/widgets/label-image-editor.js.flow +0 -44
- package/dist/widgets/lights-puzzle-editor.js.flow +0 -34
- package/dist/widgets/matcher-editor.js.flow +0 -28
- package/dist/widgets/matrix-editor.js.flow +0 -26
- package/dist/widgets/measurer-editor.js.flow +0 -42
- package/dist/widgets/molecule-editor.js.flow +0 -23
- package/dist/widgets/number-line-editor.js.flow +0 -45
- package/dist/widgets/numeric-input-editor.js.flow +0 -8
- package/dist/widgets/orderer-editor.js.flow +0 -30
- package/dist/widgets/passage-editor.js.flow +0 -24
- package/dist/widgets/passage-ref-editor.js.flow +0 -17
- package/dist/widgets/passage-ref-target-editor.js.flow +0 -22
- package/dist/widgets/plotter-editor.js.flow +0 -53
- package/dist/widgets/radio/editor.js.flow +0 -81
- package/dist/widgets/reaction-diagram-editor.js.flow +0 -26
- package/dist/widgets/sequence-editor.js.flow +0 -73
- package/dist/widgets/simple-markdown-tester-editor.js.flow +0 -23
- package/dist/widgets/simple-markdown-tester.js.flow +0 -61
- package/dist/widgets/simulator-editor.js.flow +0 -26
- package/dist/widgets/sorter-editor.js.flow +0 -22
- package/dist/widgets/table-editor.js.flow +0 -24
- package/dist/widgets/transformer-editor.js.flow +0 -17
- package/dist/widgets/unit-editor.js.flow +0 -41
- package/dist/widgets/video-editor.js.flow +0 -25
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
1
2
|
/* eslint-disable react/sort-comp */
|
|
2
3
|
/**
|
|
3
4
|
* This is the editor for the simple-markdown-tester widget. This is what shows
|
|
@@ -23,7 +24,7 @@ class TextArea extends React.Component<TextAreaProps> {
|
|
|
23
24
|
|
|
24
25
|
focus = () => {
|
|
25
26
|
// eslint-disable-next-line react/no-string-refs
|
|
26
|
-
// @ts-expect-error
|
|
27
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
27
28
|
this.refs.input.focus();
|
|
28
29
|
return true;
|
|
29
30
|
};
|
|
@@ -56,7 +57,7 @@ class SimpleMarkdownTesterEditor extends React.Component<SimpleMarkdownTesterEdi
|
|
|
56
57
|
<div>
|
|
57
58
|
<TextArea
|
|
58
59
|
value={this.props.value}
|
|
59
|
-
// @ts-expect-error
|
|
60
|
+
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
60
61
|
onChange={this.change("value")}
|
|
61
62
|
// eslint-disable-next-line react/no-string-refs
|
|
62
63
|
ref="input"
|
|
@@ -73,7 +74,7 @@ class SimpleMarkdownTesterEditor extends React.Component<SimpleMarkdownTesterEdi
|
|
|
73
74
|
|
|
74
75
|
focus: () => boolean = () => {
|
|
75
76
|
// eslint-disable-next-line react/no-string-refs
|
|
76
|
-
// @ts-expect-error
|
|
77
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
77
78
|
this.refs.input.focus();
|
|
78
79
|
return true;
|
|
79
80
|
};
|
|
@@ -45,7 +45,7 @@ class SimpleMarkdownTester extends React.Component<Props> {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
render(): React.ReactNode {
|
|
48
|
-
// @ts-expect-error
|
|
48
|
+
// @ts-expect-error - TS2554 - Expected 2 arguments, but got 1.
|
|
49
49
|
const parsed = mdParse(this.props.value);
|
|
50
50
|
const output = mdOutput(parsed);
|
|
51
51
|
return <div>{output}</div>;
|
|
@@ -58,7 +58,7 @@ class SimpleMarkdownTester extends React.Component<Props> {
|
|
|
58
58
|
*/
|
|
59
59
|
focus: () => boolean = () => {
|
|
60
60
|
// eslint-disable-next-line react/no-string-refs
|
|
61
|
-
// @ts-expect-error
|
|
61
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
62
62
|
this.refs.input.focus();
|
|
63
63
|
return true;
|
|
64
64
|
};
|
|
@@ -127,7 +127,7 @@ class SimulatorEditor extends React.Component<Props> {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
change: (...args: ReadonlyArray<unknown>) => any = (...args) => {
|
|
130
|
-
// @ts-expect-error
|
|
130
|
+
// @ts-expect-error - TS2345 - Argument of type 'readonly unknown[]' is not assignable to parameter of type 'any[]'.
|
|
131
131
|
return Changeable.change.apply(this, args);
|
|
132
132
|
};
|
|
133
133
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
1
2
|
/* eslint-disable react/forbid-prop-types */
|
|
2
3
|
import {components} from "@khanacademy/perseus";
|
|
3
4
|
import PropTypes from "prop-types";
|
|
@@ -67,7 +68,7 @@ class SorterEditor extends React.Component<Props> {
|
|
|
67
68
|
Layout:{" "}
|
|
68
69
|
<select
|
|
69
70
|
value={this.props.layout}
|
|
70
|
-
// @ts-expect-error
|
|
71
|
+
// @ts-expect-error - TS2322 - Type '(arg1: ChangeEvent<HTMLInputElement>) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement>'.
|
|
71
72
|
onChange={this.onLayoutChange}
|
|
72
73
|
>
|
|
73
74
|
<option value={HORIZONTAL}>Horizontal</option>
|
|
@@ -37,7 +37,7 @@ class TableEditor extends React.Component<Props> {
|
|
|
37
37
|
})();
|
|
38
38
|
|
|
39
39
|
focus: () => void = () => {
|
|
40
|
-
// @ts-expect-error
|
|
40
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
41
41
|
ReactDOM.findDOMNode(this.refs.numberOfColumns).focus(); // eslint-disable-line react/no-string-refs
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -652,7 +652,7 @@ const ShapeTypes: any = {
|
|
|
652
652
|
const coord0 = points[0].coord || points[0];
|
|
653
653
|
const coord1 = points[1].coord || points[1];
|
|
654
654
|
const radius = kpoint.distanceToPoint(coord0, coord1);
|
|
655
|
-
// @ts-expect-error
|
|
655
|
+
// @ts-expect-error - TS2554 - Expected 1 arguments, but got 0.
|
|
656
656
|
perimeter.remove();
|
|
657
657
|
perimeter = graphie.circle(
|
|
658
658
|
coord0,
|
|
@@ -677,7 +677,7 @@ const ShapeTypes: any = {
|
|
|
677
677
|
remove: function () {
|
|
678
678
|
// Not _.bind because the remove function changes
|
|
679
679
|
// when the perimeter is redrawn
|
|
680
|
-
// @ts-expect-error
|
|
680
|
+
// @ts-expect-error - TS2554 - Expected 1 arguments, but got 0.
|
|
681
681
|
perimeter.remove();
|
|
682
682
|
},
|
|
683
683
|
};
|
|
@@ -726,10 +726,10 @@ const ShapeTypes: any = {
|
|
|
726
726
|
const line2_2 = [points2[1], points2[2]];
|
|
727
727
|
|
|
728
728
|
const equalUnflipped =
|
|
729
|
-
// @ts-expect-error
|
|
729
|
+
// @ts-expect-error - TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'Ray'. | TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'Ray'.
|
|
730
730
|
kray.equal(line1_0, line2_0) && kray.equal(line1_2, line2_2);
|
|
731
731
|
const equalFlipped =
|
|
732
|
-
// @ts-expect-error
|
|
732
|
+
// @ts-expect-error - TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'Ray'. | TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'Ray'.
|
|
733
733
|
kray.equal(line1_0, line2_2) && kray.equal(line1_2, line2_0);
|
|
734
734
|
|
|
735
735
|
return equalUnflipped || equalFlipped;
|
|
@@ -817,7 +817,7 @@ class TransformationsShapeEditor extends React.Component<any> {
|
|
|
817
817
|
);
|
|
818
818
|
|
|
819
819
|
// eslint-disable-next-line react/no-string-refs
|
|
820
|
-
// @ts-expect-error
|
|
820
|
+
// @ts-expect-error - TS2339 - Property 'props' does not exist on type 'ReactInstance'.
|
|
821
821
|
const radius = scaleToRange(4, this.refs.graph.props.range);
|
|
822
822
|
const offset = (1 / 2 - 1 / pointCount) * 180;
|
|
823
823
|
const coords = _.times(pointCount, function (i) {
|
|
@@ -838,27 +838,27 @@ class TransformationsShapeEditor extends React.Component<any> {
|
|
|
838
838
|
|
|
839
839
|
componentDidMount() {
|
|
840
840
|
// eslint-disable-next-line react/no-string-refs
|
|
841
|
-
// @ts-expect-error
|
|
841
|
+
// @ts-expect-error - TS2339 - Property 'graphie' does not exist on type 'ReactInstance'.
|
|
842
842
|
this.setupGraphie(this.refs.graph.graphie());
|
|
843
843
|
}
|
|
844
844
|
|
|
845
845
|
componentDidUpdate(prevProps) {
|
|
846
846
|
if (!deepEq(prevProps.shape, this.props.shape)) {
|
|
847
847
|
// eslint-disable-next-line react/no-string-refs
|
|
848
|
-
// @ts-expect-error
|
|
848
|
+
// @ts-expect-error - TS2339 - Property 'reset' does not exist on type 'ReactInstance'.
|
|
849
849
|
this.refs.graph.reset();
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
852
|
|
|
853
853
|
updateCoords = () => {
|
|
854
854
|
this.props.onChange({
|
|
855
|
-
// @ts-expect-error
|
|
855
|
+
// @ts-expect-error - TS2339 - Property 'shape' does not exist on type 'TransformationsShapeEditor'.
|
|
856
856
|
shape: this.shape.toJSON(),
|
|
857
857
|
});
|
|
858
858
|
};
|
|
859
859
|
|
|
860
860
|
setupGraphie = (graphie: any) => {
|
|
861
|
-
// @ts-expect-error
|
|
861
|
+
// @ts-expect-error - TS2339 - Property 'shape' does not exist on type 'TransformationsShapeEditor'.
|
|
862
862
|
this.shape = ShapeTypes.addMovableShape(graphie, {
|
|
863
863
|
editable: true,
|
|
864
864
|
snap: graphie.snap,
|
|
@@ -996,7 +996,7 @@ class TransformerEditor extends React.Component<any> {
|
|
|
996
996
|
|
|
997
997
|
serialize: () => any = () => {
|
|
998
998
|
// eslint-disable-next-line react/no-string-refs
|
|
999
|
-
// @ts-expect-error
|
|
999
|
+
// @ts-expect-error - TS2339 - Property 'getEditorJSON' does not exist on type 'ReactInstance'.
|
|
1000
1000
|
const json = this.refs.explorer.getEditorJSON();
|
|
1001
1001
|
json.correct = json.answer;
|
|
1002
1002
|
delete json.answer;
|
|
@@ -43,7 +43,7 @@ type UnitExampleState = any;
|
|
|
43
43
|
class UnitExample extends React.Component<UnitExampleProps, UnitExampleState> {
|
|
44
44
|
// TODO(jangmi, CP-3288): Remove usage of `UNSAFE_componentWillMount`
|
|
45
45
|
UNSAFE_componentWillMount() {
|
|
46
|
-
// @ts-expect-error
|
|
46
|
+
// @ts-expect-error - TS2345 - Argument of type 'Readonly<any> & Readonly<{ children?: ReactNode; }>' is not assignable to parameter of type '{ name: any; original: any; sigfigs: any; }'.
|
|
47
47
|
this._checkValidity(this.props);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -158,12 +158,12 @@ class UnitInputEditor extends React.Component<UnitInputEditorProps> {
|
|
|
158
158
|
.split(",")
|
|
159
159
|
.map((str) => str.trim())
|
|
160
160
|
.filter((str) => str !== "");
|
|
161
|
-
// @ts-expect-error
|
|
161
|
+
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
162
162
|
this.change({acceptingUnits});
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
handleSigfigChange: (arg1: number) => void = (sigfigs) => {
|
|
166
|
-
// @ts-expect-error
|
|
166
|
+
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
167
167
|
this.change({sigfigs});
|
|
168
168
|
};
|
|
169
169
|
|
|
@@ -172,7 +172,7 @@ class UnitInputEditor extends React.Component<UnitInputEditorProps> {
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
_setAccepting: (arg1: typeof SOME | typeof ALL) => void = (val) => {
|
|
175
|
-
// @ts-expect-error
|
|
175
|
+
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
176
176
|
this.change({accepting: val});
|
|
177
177
|
};
|
|
178
178
|
|
|
@@ -226,7 +226,7 @@ class UnitInputEditor extends React.Component<UnitInputEditorProps> {
|
|
|
226
226
|
/>
|
|
227
227
|
));
|
|
228
228
|
|
|
229
|
-
// @ts-expect-error
|
|
229
|
+
// @ts-expect-error - TS2322 - Type 'Element' is not assignable to type 'null'.
|
|
230
230
|
acceptingElem = (
|
|
231
231
|
<div>
|
|
232
232
|
<input
|