@khanacademy/perseus-editor 2.6.1 → 2.6.3
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 +373 -364
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +375 -366
- 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 +140 -139
- 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 +1 -1
- package/src/components/dropdown-option.tsx +12 -12
- package/src/components/form-wrapped-text-field.tsx +4 -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 +7 -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 +10 -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 +36 -36
- package/src/hint-editor.tsx +27 -27
- package/src/i18n.ts +4 -4
- package/src/iframe-content-renderer.tsx +10 -10
- package/src/item-editor.tsx +4 -4
- package/src/multirenderer-editor.tsx +17 -11
- package/src/widgets/categorizer-editor.tsx +3 -3
- package/src/widgets/cs-program-editor.tsx +2 -2
- package/src/widgets/definition-editor.tsx +2 -2
- package/src/widgets/dropdown-editor.tsx +8 -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 +3 -3
- package/src/widgets/explanation-editor.tsx +3 -3
- package/src/widgets/expression-editor.tsx +9 -9
- package/src/widgets/graded-group-editor.tsx +6 -6
- package/src/widgets/graded-group-set-editor.tsx +3 -3
- package/src/widgets/grapher-editor.tsx +2 -2
- package/src/widgets/group-editor.tsx +3 -3
- package/src/widgets/iframe-editor.tsx +4 -4
- package/src/widgets/input-number-editor.tsx +6 -6
- package/src/widgets/interaction-editor.tsx +102 -102
- package/src/widgets/interactive-graph-editor.tsx +12 -8
- package/src/widgets/label-image/marker.tsx +1 -1
- package/src/widgets/label-image/question-markers.tsx +1 -1
- package/src/widgets/lights-puzzle-editor.tsx +4 -4
- package/src/widgets/matrix-editor.tsx +2 -2
- package/src/widgets/measurer-editor.tsx +6 -6
- package/src/widgets/molecule-editor.tsx +2 -2
- package/src/widgets/number-line-editor.tsx +1 -1
- package/src/widgets/numeric-input-editor.tsx +2 -2
- package/src/widgets/orderer-editor.tsx +2 -2
- package/src/widgets/passage-editor.tsx +3 -3
- package/src/widgets/passage-ref-editor.tsx +3 -3
- package/src/widgets/passage-ref-target-editor.tsx +1 -1
- package/src/widgets/plotter-editor.tsx +4 -4
- 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 +3 -3
- package/src/widgets/simple-markdown-tester.tsx +2 -2
- package/src/widgets/simulator-editor.tsx +1 -1
- package/src/widgets/sorter-editor.tsx +1 -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 -75
- 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
package/src/diffs/text-diff.tsx
CHANGED
|
@@ -49,7 +49,7 @@ class ImageDiffSide extends React.Component<any> {
|
|
|
49
49
|
return (
|
|
50
50
|
<div key={index}>
|
|
51
51
|
<div className={className}>
|
|
52
|
-
{/* @ts-expect-error
|
|
52
|
+
{/* @ts-expect-error - 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">'. */}
|
|
53
53
|
<SvgImage
|
|
54
54
|
src={entry.value}
|
|
55
55
|
title={entry.value}
|
|
@@ -227,7 +227,7 @@ class ImageWidgetDiff extends React.Component<any> {
|
|
|
227
227
|
"image-removed": beforeSrc !== afterSrc,
|
|
228
228
|
})}
|
|
229
229
|
>
|
|
230
|
-
{/* @ts-expect-error
|
|
230
|
+
{/* @ts-expect-error - 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">'. */}
|
|
231
231
|
<SvgImage src={beforeSrc} title={beforeSrc} />
|
|
232
232
|
</div>
|
|
233
233
|
)}
|
|
@@ -241,7 +241,7 @@ class ImageWidgetDiff extends React.Component<any> {
|
|
|
241
241
|
"image-added": beforeSrc !== afterSrc,
|
|
242
242
|
})}
|
|
243
243
|
>
|
|
244
|
-
{/* @ts-expect-error
|
|
244
|
+
{/* @ts-expect-error - 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">'. */}
|
|
245
245
|
<SvgImage src={afterSrc} title={afterSrc} />
|
|
246
246
|
</div>
|
|
247
247
|
)}
|
package/src/editor-page.tsx
CHANGED
|
@@ -69,7 +69,7 @@ type State = {
|
|
|
69
69
|
|
|
70
70
|
class EditorPage extends React.Component<Props, State> {
|
|
71
71
|
_isMounted: boolean;
|
|
72
|
-
// @ts-expect-error
|
|
72
|
+
// @ts-expect-error - TS2564 - Property 'rendererMountNode' has no initializer and is not definitely assigned in the constructor.
|
|
73
73
|
rendererMountNode: HTMLDivElement;
|
|
74
74
|
renderer: RendererInterface | null | undefined;
|
|
75
75
|
|
|
@@ -87,7 +87,7 @@ class EditorPage extends React.Component<Props, State> {
|
|
|
87
87
|
super(props);
|
|
88
88
|
|
|
89
89
|
this.state = {
|
|
90
|
-
// @ts-expect-error
|
|
90
|
+
// @ts-expect-error - TS2322 - Type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "hints" | "question" | "answerArea" | "itemDataVersion">' is not assignable to type 'PerseusJson'.
|
|
91
91
|
json: _.pick(
|
|
92
92
|
this.props,
|
|
93
93
|
"question",
|
|
@@ -161,7 +161,7 @@ class EditorPage extends React.Component<Props, State> {
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
// eslint-disable-next-line react/no-string-refs
|
|
164
|
-
// @ts-expect-error
|
|
164
|
+
// @ts-expect-error - TS2339 - Property 'triggerPreviewUpdate' does not exist on type 'ReactInstance'.
|
|
165
165
|
this.refs.itemEditor.triggerPreviewUpdate({
|
|
166
166
|
type: "question",
|
|
167
167
|
data: _({
|
|
@@ -177,7 +177,7 @@ class EditorPage extends React.Component<Props, State> {
|
|
|
177
177
|
},
|
|
178
178
|
reviewMode: true,
|
|
179
179
|
// eslint-disable-next-line react/no-string-refs
|
|
180
|
-
// @ts-expect-error
|
|
180
|
+
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
181
181
|
legacyPerseusLint: this.refs.itemEditor.getSaveWarnings(),
|
|
182
182
|
}).extend(
|
|
183
183
|
_(this.props).pick(
|
|
@@ -199,10 +199,10 @@ class EditorPage extends React.Component<Props, State> {
|
|
|
199
199
|
|
|
200
200
|
getSaveWarnings(): any {
|
|
201
201
|
// eslint-disable-next-line react/no-string-refs
|
|
202
|
-
// @ts-expect-error
|
|
202
|
+
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
203
203
|
const issues1 = this.refs.itemEditor.getSaveWarnings();
|
|
204
204
|
// eslint-disable-next-line react/no-string-refs
|
|
205
|
-
// @ts-expect-error
|
|
205
|
+
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
206
206
|
const issues2 = this.refs.hintsEditor.getSaveWarnings();
|
|
207
207
|
return issues1.concat(issues2);
|
|
208
208
|
}
|
|
@@ -212,10 +212,10 @@ class EditorPage extends React.Component<Props, State> {
|
|
|
212
212
|
return this.state.json;
|
|
213
213
|
}
|
|
214
214
|
// eslint-disable-next-line react/no-string-refs
|
|
215
|
-
// @ts-expect-error
|
|
215
|
+
// @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
216
216
|
return _.extend(this.refs.itemEditor.serialize(options), {
|
|
217
217
|
// eslint-disable-next-line react/no-string-refs
|
|
218
|
-
// @ts-expect-error
|
|
218
|
+
// @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
219
219
|
hints: this.refs.hintsEditor.serialize(options),
|
|
220
220
|
});
|
|
221
221
|
}
|
package/src/editor.tsx
CHANGED
|
@@ -88,7 +88,7 @@ const IMAGE_REGEX = /!\[[^\]]*\]\(([^\s)]+)[^)]*\)/g;
|
|
|
88
88
|
* ignores captures. If you don't need captures, use String::match
|
|
89
89
|
*/
|
|
90
90
|
const allMatches = function (regex: RegExp, str: string) {
|
|
91
|
-
// @ts-expect-error
|
|
91
|
+
// @ts-expect-error - TS2702 - 'RegExp' only refers to a type, but is being used as a namespace here.
|
|
92
92
|
const result: Array<any | RegExp.matchResult> = [];
|
|
93
93
|
// eslint-disable-next-line no-constant-condition
|
|
94
94
|
while (true) {
|
|
@@ -184,9 +184,9 @@ class Editor extends React.Component<Props, State> {
|
|
|
184
184
|
// setState
|
|
185
185
|
this._sizeImages(this.props);
|
|
186
186
|
// eslint-disable-next-line react/no-string-refs
|
|
187
|
-
// @ts-expect-error
|
|
187
|
+
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
188
188
|
$(ReactDOM.findDOMNode(this.refs.textarea))
|
|
189
|
-
// @ts-expect-error
|
|
189
|
+
// @ts-expect-error - TS2339 - Property 'on' does not exist on type 'JQueryStatic'.
|
|
190
190
|
.on("copy cut", this._maybeCopyWidgets)
|
|
191
191
|
.on("paste", this._maybePasteWidgets);
|
|
192
192
|
}
|
|
@@ -216,13 +216,13 @@ class Editor extends React.Component<Props, State> {
|
|
|
216
216
|
* textarea should be refined with an instanceof check to
|
|
217
217
|
* HTMLTextAreaElement so that these props are available.
|
|
218
218
|
*/
|
|
219
|
-
// @ts-expect-error
|
|
219
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
220
220
|
textarea.focus();
|
|
221
|
-
// @ts-expect-error
|
|
221
|
+
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
222
222
|
textarea.value = this.lastUserValue;
|
|
223
|
-
// @ts-expect-error
|
|
223
|
+
// @ts-expect-error - TS2339 - Property 'selectionStart' does not exist on type 'Element | Text'.
|
|
224
224
|
textarea.selectionStart = 0;
|
|
225
|
-
// @ts-expect-error
|
|
225
|
+
// @ts-expect-error - TS2339 - Property 'select' does not exist on type 'Element | Text'.
|
|
226
226
|
textarea.select(0, prevProps.content.length);
|
|
227
227
|
if (
|
|
228
228
|
document.execCommand(
|
|
@@ -233,7 +233,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
233
233
|
) {
|
|
234
234
|
// This command is not implemented. Fall back to setting `value`
|
|
235
235
|
// directly.
|
|
236
|
-
// @ts-expect-error
|
|
236
|
+
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
237
237
|
textarea.value = this.props.content;
|
|
238
238
|
}
|
|
239
239
|
this.lastUserValue = null;
|
|
@@ -259,11 +259,11 @@ class Editor extends React.Component<Props, State> {
|
|
|
259
259
|
}
|
|
260
260
|
return (
|
|
261
261
|
<WidgetEditor
|
|
262
|
-
// @ts-expect-error
|
|
262
|
+
// @ts-expect-error - TS2322 - Type 'string' is not assignable to type 'number | undefined'.
|
|
263
263
|
key={id}
|
|
264
264
|
ref={id}
|
|
265
265
|
id={id}
|
|
266
|
-
// @ts-expect-error
|
|
266
|
+
// @ts-expect-error - TS2783 - 'type' is specified more than once, so this usage will be overwritten.
|
|
267
267
|
type={type}
|
|
268
268
|
// eslint-disable-next-line react/jsx-no-bind
|
|
269
269
|
onChange={this._handleWidgetEditorChange.bind(this, id)}
|
|
@@ -295,7 +295,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
295
295
|
// eslint-disable-next-line react/no-string-refs
|
|
296
296
|
const textarea = this.refs.textarea;
|
|
297
297
|
const re = new RegExp(widgetRegExp.replace("{id}", id), "gm");
|
|
298
|
-
// @ts-expect-error
|
|
298
|
+
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'ReactInstance'.
|
|
299
299
|
this.props.onChange({content: textarea.value.replace(re, "")});
|
|
300
300
|
};
|
|
301
301
|
|
|
@@ -335,7 +335,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
335
335
|
{
|
|
336
336
|
images: _.clone(images),
|
|
337
337
|
},
|
|
338
|
-
// @ts-expect-error
|
|
338
|
+
// @ts-expect-error - TS2345 - Argument of type 'null' is not assignable to parameter of type '(() => unknown) | undefined'.
|
|
339
339
|
null, // callback
|
|
340
340
|
true, // silent
|
|
341
341
|
);
|
|
@@ -411,13 +411,13 @@ class Editor extends React.Component<Props, State> {
|
|
|
411
411
|
this.props.onChange({content: content});
|
|
412
412
|
})
|
|
413
413
|
.each((fileAndSentinel) => {
|
|
414
|
-
// @ts-expect-error
|
|
414
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2345 - Argument of type 'File' is not assignable to parameter of type 'string'.
|
|
415
415
|
imageUploader(fileAndSentinel.file, (url) => {
|
|
416
416
|
// See componentDidUpdate() for how this flag is used
|
|
417
417
|
this.lastUserValue = origContent;
|
|
418
418
|
this.props.onChange({
|
|
419
419
|
content: this.state.textAreaValue.replace(
|
|
420
|
-
// @ts-expect-error
|
|
420
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
421
421
|
fileAndSentinel.sentinel,
|
|
422
422
|
url,
|
|
423
423
|
),
|
|
@@ -453,7 +453,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
453
453
|
const textarea = ReactDOM.findDOMNode(this.refs.textarea);
|
|
454
454
|
|
|
455
455
|
// findDOMNode can also return Text, but we know it's an element.
|
|
456
|
-
// @ts-expect-error
|
|
456
|
+
// @ts-expect-error - TS2345 - Argument of type 'Element | Text | null' is not assignable to parameter of type 'HTMLTextAreaElement'.
|
|
457
457
|
const word = Util.textarea.getWordBeforeCursor(textarea);
|
|
458
458
|
const matches = word.string.toLowerCase().match(shortcutRegexp);
|
|
459
459
|
|
|
@@ -493,10 +493,10 @@ class Editor extends React.Component<Props, State> {
|
|
|
493
493
|
);
|
|
494
494
|
|
|
495
495
|
const widgetNames = _.map(
|
|
496
|
-
// @ts-expect-error
|
|
496
|
+
// @ts-expect-error - TS2345 - Argument of type 'RegExpMatchArray | null' is not assignable to parameter of type 'Collection<any>'.
|
|
497
497
|
selectedText.match(rWidgetSplit),
|
|
498
498
|
(syntax) => {
|
|
499
|
-
// @ts-expect-error
|
|
499
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
500
500
|
return Util.rWidgetParts.exec(syntax)[1];
|
|
501
501
|
},
|
|
502
502
|
);
|
|
@@ -520,7 +520,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
520
520
|
const widgetJSON = localStorage.perseusLastCopiedWidgets;
|
|
521
521
|
const lastCopiedText = localStorage.perseusLastCopiedText;
|
|
522
522
|
const textToBePasted =
|
|
523
|
-
// @ts-expect-error
|
|
523
|
+
// @ts-expect-error - TS2339 - Property 'originalEvent' does not exist on type 'SyntheticEvent<HTMLTextAreaElement, Event>'.
|
|
524
524
|
e.originalEvent.clipboardData.getData("text");
|
|
525
525
|
|
|
526
526
|
// Only intercept if we have widget data to paste and the user is
|
|
@@ -551,9 +551,9 @@ class Editor extends React.Component<Props, State> {
|
|
|
551
551
|
rWidgetSplit,
|
|
552
552
|
(syntax) => {
|
|
553
553
|
const match = Util.rWidgetParts.exec(syntax);
|
|
554
|
-
// @ts-expect-error
|
|
554
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
555
555
|
const completeWidget = match[0];
|
|
556
|
-
// @ts-expect-error
|
|
556
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
557
557
|
const widget = match[1];
|
|
558
558
|
return completeWidget.replace(
|
|
559
559
|
widget,
|
|
@@ -650,12 +650,12 @@ class Editor extends React.Component<Props, State> {
|
|
|
650
650
|
// Note: we have to use _.map here instead of Array::map
|
|
651
651
|
// because the results of a .match might be null if no
|
|
652
652
|
// widgets were found.
|
|
653
|
-
// @ts-expect-error
|
|
653
|
+
// @ts-expect-error - TS2345 - Argument of type 'RegExpMatchArray | null' is not assignable to parameter of type 'Collection<any>'.
|
|
654
654
|
const allWidgetIds = _.map(oldContent.match(rWidgetSplit), (syntax) => {
|
|
655
655
|
const match = Util.rWidgetParts.exec(syntax);
|
|
656
|
-
// @ts-expect-error
|
|
656
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
657
657
|
const type = match[2];
|
|
658
|
-
// @ts-expect-error
|
|
658
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
659
659
|
const num = +match[3];
|
|
660
660
|
return [type, num];
|
|
661
661
|
});
|
|
@@ -693,12 +693,12 @@ class Editor extends React.Component<Props, State> {
|
|
|
693
693
|
const newWidgets = _.clone(this.props.widgets);
|
|
694
694
|
newWidgets[id] = {
|
|
695
695
|
options: Widgets.getEditor(widgetType)?.defaultProps,
|
|
696
|
-
// @ts-expect-error
|
|
696
|
+
// @ts-expect-error - TS2322 - Type 'string' is not assignable to type '"video" | "image" | "iframe" | "table" | "radio" | "definition" | "group" | "matrix" | "categorizer" | "cs-program" | "dropdown" | "example-graphie-widget" | "example-widget" | ... 26 more ... | "unit-input"'.
|
|
697
697
|
type: widgetType,
|
|
698
698
|
// Track widget version on creation, so that a widget editor
|
|
699
699
|
// without a valid version prop can only possibly refer to a
|
|
700
700
|
// pre-versioning creation time.
|
|
701
|
-
// @ts-expect-error
|
|
701
|
+
// @ts-expect-error - TS2322 - Type 'Version | null | undefined' is not assignable to type 'Version | undefined'.
|
|
702
702
|
version: Widgets.getVersion(widgetType),
|
|
703
703
|
};
|
|
704
704
|
|
|
@@ -712,7 +712,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
712
712
|
function () {
|
|
713
713
|
Util.textarea.moveCursor(
|
|
714
714
|
// findDOMNode can return Text but we know this is Element
|
|
715
|
-
// @ts-expect-error
|
|
715
|
+
// @ts-expect-error - TS2345 - Argument of type 'Element | Text | null' is not assignable to parameter of type 'HTMLTextAreaElement'.
|
|
716
716
|
textarea,
|
|
717
717
|
// We want to put the cursor after the widget
|
|
718
718
|
// and after any added newlines
|
|
@@ -728,11 +728,11 @@ class Editor extends React.Component<Props, State> {
|
|
|
728
728
|
|
|
729
729
|
this._addWidgetToContent(
|
|
730
730
|
this.props.content,
|
|
731
|
-
// @ts-expect-error
|
|
731
|
+
// @ts-expect-error - TS2339 - Property 'selectionStart' does not exist on type 'ReactInstance'. | TS2339 - Property 'selectionEnd' does not exist on type 'ReactInstance'.
|
|
732
732
|
[textarea.selectionStart, textarea.selectionEnd],
|
|
733
733
|
widgetType,
|
|
734
734
|
);
|
|
735
|
-
// @ts-expect-error
|
|
735
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
736
736
|
textarea.focus();
|
|
737
737
|
};
|
|
738
738
|
|
|
@@ -807,7 +807,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
807
807
|
.chain()
|
|
808
808
|
.map((id) => {
|
|
809
809
|
// eslint-disable-next-line react/no-string-refs
|
|
810
|
-
// @ts-expect-error
|
|
810
|
+
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
811
811
|
const issuesFunc = this.refs[id].getSaveWarnings;
|
|
812
812
|
const issues = issuesFunc ? issuesFunc() : [];
|
|
813
813
|
return _.map(issues, (issue) => id + ": " + issue);
|
|
@@ -827,7 +827,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
827
827
|
* textarea should be refined with an instanceof check to
|
|
828
828
|
* HTMLTextAreaElement so that these props are available.
|
|
829
829
|
*/
|
|
830
|
-
// @ts-expect-error
|
|
830
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
831
831
|
textarea.focus();
|
|
832
832
|
}
|
|
833
833
|
};
|
|
@@ -842,9 +842,9 @@ class Editor extends React.Component<Props, State> {
|
|
|
842
842
|
* textarea should be refined with an instanceof check to
|
|
843
843
|
* HTMLTextAreaElement so that these props are available.
|
|
844
844
|
*/
|
|
845
|
-
// @ts-expect-error
|
|
845
|
+
// @ts-expect-error - TS2339 - Property 'selectionStart' does not exist on type 'Element | Text'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
846
846
|
textarea.selectionStart = textarea.value.length;
|
|
847
|
-
// @ts-expect-error
|
|
847
|
+
// @ts-expect-error - TS2339 - Property 'selectionEnd' does not exist on type 'Element | Text'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
848
848
|
textarea.selectionEnd = textarea.value.length;
|
|
849
849
|
}
|
|
850
850
|
};
|
|
@@ -863,7 +863,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
863
863
|
const widgetIds = _.intersection(this.widgetIds, _.keys(this.refs));
|
|
864
864
|
_.each(widgetIds, (id) => {
|
|
865
865
|
// eslint-disable-next-line react/no-string-refs
|
|
866
|
-
// @ts-expect-error
|
|
866
|
+
// @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
867
867
|
widgets[id] = this.refs[id].serialize();
|
|
868
868
|
});
|
|
869
869
|
|
|
@@ -933,7 +933,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
933
933
|
// Normal text
|
|
934
934
|
underlayPieces.push(pieces[i]);
|
|
935
935
|
|
|
936
|
-
// @ts-expect-error
|
|
936
|
+
// @ts-expect-error - TS2554 - Expected 2 arguments, but got 1.
|
|
937
937
|
const ast = PerseusMarkdown.parse(pieces[i]);
|
|
938
938
|
|
|
939
939
|
PerseusMarkdown.traverseContent(ast, (node) => {
|
|
@@ -946,7 +946,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
946
946
|
} catch (e: any) {
|
|
947
947
|
katexErrorList.push({
|
|
948
948
|
math: content,
|
|
949
|
-
// @ts-expect-error
|
|
949
|
+
// @ts-expect-error - TS2322 - Type 'any' is not assignable to type 'never'.
|
|
950
950
|
message: e.message,
|
|
951
951
|
});
|
|
952
952
|
}
|
|
@@ -1002,7 +1002,7 @@ class Editor extends React.Component<Props, State> {
|
|
|
1002
1002
|
|
|
1003
1003
|
const insertTemplateString = "Insert template\u2026";
|
|
1004
1004
|
templatesDropDown = (
|
|
1005
|
-
// @ts-expect-error
|
|
1005
|
+
// @ts-expect-error - TS2322 - Type '(e: SyntheticEvent<HTMLTextAreaElement, Event>) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement>'.
|
|
1006
1006
|
<select onChange={this.addTemplate}>
|
|
1007
1007
|
<option value="">{insertTemplateString}</option>
|
|
1008
1008
|
<option disabled>--</option>
|
package/src/hint-editor.tsx
CHANGED
|
@@ -82,19 +82,19 @@ export class HintEditor extends React.Component<HintEditorProps> {
|
|
|
82
82
|
|
|
83
83
|
focus: () => void = () => {
|
|
84
84
|
// eslint-disable-next-line react/no-string-refs
|
|
85
|
-
// @ts-expect-error
|
|
85
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
86
86
|
this.refs.editor.focus();
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
getSaveWarnings: () => any = () => {
|
|
90
90
|
// eslint-disable-next-line react/no-string-refs
|
|
91
|
-
// @ts-expect-error
|
|
91
|
+
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
92
92
|
return this.refs.editor.getSaveWarnings();
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
serialize: (options?: any) => any = (options: any) => {
|
|
96
96
|
// eslint-disable-next-line react/no-string-refs
|
|
97
|
-
// @ts-expect-error
|
|
97
|
+
// @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
98
98
|
return this.refs.editor.serialize(options);
|
|
99
99
|
};
|
|
100
100
|
|
|
@@ -147,7 +147,7 @@ export class HintEditor extends React.Component<HintEditorProps> {
|
|
|
147
147
|
)}
|
|
148
148
|
<input
|
|
149
149
|
type="checkbox"
|
|
150
|
-
// @ts-expect-error
|
|
150
|
+
// @ts-expect-error - TS2322 - Type 'boolean | null | undefined' is not assignable to type 'boolean | undefined'.
|
|
151
151
|
checked={this.props.replace}
|
|
152
152
|
onChange={this.handleChange}
|
|
153
153
|
/>
|
|
@@ -205,7 +205,7 @@ class CombinedHintEditor extends React.Component<CombinedHintEditorProps> {
|
|
|
205
205
|
this.props.isLast && !/\*\*/.test(this.props.hint.content);
|
|
206
206
|
|
|
207
207
|
// eslint-disable-next-line react/no-string-refs
|
|
208
|
-
// @ts-expect-error
|
|
208
|
+
// @ts-expect-error - TS2339 - Property 'sendNewData' does not exist on type 'ReactInstance'.
|
|
209
209
|
this.refs.frame.sendNewData({
|
|
210
210
|
type: "hint",
|
|
211
211
|
data: {
|
|
@@ -224,19 +224,19 @@ class CombinedHintEditor extends React.Component<CombinedHintEditorProps> {
|
|
|
224
224
|
|
|
225
225
|
getSaveWarnings = () => {
|
|
226
226
|
// eslint-disable-next-line react/no-string-refs
|
|
227
|
-
// @ts-expect-error
|
|
227
|
+
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
228
228
|
return this.refs.editor.getSaveWarnings();
|
|
229
229
|
};
|
|
230
230
|
|
|
231
231
|
serialize = (options: any) => {
|
|
232
232
|
// eslint-disable-next-line react/no-string-refs
|
|
233
|
-
// @ts-expect-error
|
|
233
|
+
// @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
234
234
|
return this.refs.editor.serialize(options);
|
|
235
235
|
};
|
|
236
236
|
|
|
237
237
|
focus = () => {
|
|
238
238
|
// eslint-disable-next-line react/no-string-refs
|
|
239
|
-
// @ts-expect-error
|
|
239
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
240
240
|
this.refs.editor.focus();
|
|
241
241
|
};
|
|
242
242
|
|
|
@@ -341,15 +341,15 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
341
341
|
newProps,
|
|
342
342
|
);
|
|
343
343
|
|
|
344
|
-
// @ts-expect-error
|
|
344
|
+
// @ts-expect-error - TS2740 - Type 'Hint' is missing the following properties from type 'readonly Hint[]': length, concat, join, slice, and 18 more.
|
|
345
345
|
this.props.onChange({hints: hints}, cb, silent);
|
|
346
346
|
};
|
|
347
347
|
|
|
348
348
|
handleHintRemove: (i: number) => void = (i: number) => {
|
|
349
349
|
const hints = _(this.props.hints).clone();
|
|
350
|
-
// @ts-expect-error
|
|
350
|
+
// @ts-expect-error - TS2339 - Property 'splice' does not exist on type 'Hint'.
|
|
351
351
|
hints.splice(i, 1);
|
|
352
|
-
// @ts-expect-error
|
|
352
|
+
// @ts-expect-error - TS2322 - Type 'Hint' is not assignable to type 'readonly Hint[]'.
|
|
353
353
|
this.props.onChange({hints: hints});
|
|
354
354
|
};
|
|
355
355
|
|
|
@@ -358,14 +358,14 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
358
358
|
dir: number,
|
|
359
359
|
) => {
|
|
360
360
|
const hints = _(this.props.hints).clone();
|
|
361
|
-
// @ts-expect-error
|
|
361
|
+
// @ts-expect-error - TS2339 - Property 'splice' does not exist on type 'Hint'.
|
|
362
362
|
const hint = hints.splice(i, 1)[0];
|
|
363
|
-
// @ts-expect-error
|
|
363
|
+
// @ts-expect-error - TS2339 - Property 'splice' does not exist on type 'Hint'.
|
|
364
364
|
hints.splice(i + dir, 0, hint);
|
|
365
|
-
// @ts-expect-error
|
|
365
|
+
// @ts-expect-error - TS2322 - Type 'Hint' is not assignable to type 'readonly Hint[]'.
|
|
366
366
|
this.props.onChange({hints: hints}, () => {
|
|
367
367
|
// eslint-disable-next-line react/no-string-refs
|
|
368
|
-
// @ts-expect-error
|
|
368
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
369
369
|
this.refs["hintEditor" + (i + dir)].focus();
|
|
370
370
|
});
|
|
371
371
|
};
|
|
@@ -373,12 +373,12 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
373
373
|
addHint: () => void = () => {
|
|
374
374
|
const hints = _(this.props.hints)
|
|
375
375
|
.clone()
|
|
376
|
-
// @ts-expect-error
|
|
376
|
+
// @ts-expect-error - TS2339 - Property 'concat' does not exist on type 'Hint'.
|
|
377
377
|
.concat([{content: ""}]);
|
|
378
378
|
this.props.onChange({hints: hints}, () => {
|
|
379
379
|
const i = hints.length - 1;
|
|
380
380
|
// eslint-disable-next-line react/no-string-refs
|
|
381
|
-
// @ts-expect-error
|
|
381
|
+
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
382
382
|
this.refs["hintEditor" + i].focus();
|
|
383
383
|
});
|
|
384
384
|
};
|
|
@@ -388,7 +388,7 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
388
388
|
.map((hint, i) => {
|
|
389
389
|
return _.map(
|
|
390
390
|
// eslint-disable-next-line react/no-string-refs
|
|
391
|
-
// @ts-expect-error
|
|
391
|
+
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
392
392
|
this.refs["hintEditor" + i].getSaveWarnings(),
|
|
393
393
|
(issue) => "Hint " + (i + 1) + ": " + issue,
|
|
394
394
|
);
|
|
@@ -408,7 +408,7 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
408
408
|
options: any,
|
|
409
409
|
): string => {
|
|
410
410
|
// eslint-disable-next-line react/no-string-refs
|
|
411
|
-
// @ts-expect-error
|
|
411
|
+
// @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
412
412
|
return this.refs["hintEditor" + index].serialize(options);
|
|
413
413
|
};
|
|
414
414
|
|
|
@@ -426,24 +426,24 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
|
|
|
426
426
|
itemId={itemId}
|
|
427
427
|
hint={hint}
|
|
428
428
|
pos={i}
|
|
429
|
-
// @ts-expect-error
|
|
429
|
+
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
430
430
|
imageUploader={this.props.imageUploader}
|
|
431
431
|
// eslint-disable-next-line react/jsx-no-bind
|
|
432
|
-
// @ts-expect-error
|
|
432
|
+
// @ts-expect-error - 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.
|
|
433
433
|
onChange={this.handleHintChange.bind(this, i)}
|
|
434
434
|
// eslint-disable-next-line react/jsx-no-bind
|
|
435
|
-
// @ts-expect-error
|
|
435
|
+
// @ts-expect-error - 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.
|
|
436
436
|
onRemove={this.handleHintRemove.bind(this, i)}
|
|
437
437
|
// eslint-disable-next-line react/jsx-no-bind
|
|
438
|
-
// @ts-expect-error
|
|
438
|
+
// @ts-expect-error - 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.
|
|
439
439
|
onMove={this.handleHintMove.bind(this, i)}
|
|
440
|
-
// @ts-expect-error
|
|
440
|
+
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
441
441
|
deviceType={this.props.deviceType}
|
|
442
|
-
// @ts-expect-error
|
|
442
|
+
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
443
443
|
apiOptions={this.props.apiOptions}
|
|
444
|
-
// @ts-expect-error
|
|
444
|
+
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
445
445
|
highlightLint={this.props.highlightLint}
|
|
446
|
-
// @ts-expect-error
|
|
446
|
+
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
447
447
|
previewURL={this.props.previewURL}
|
|
448
448
|
// TODO(CP-4838): what should be passed here?
|
|
449
449
|
contentPaths={[]}
|
package/src/i18n.ts
CHANGED
|
@@ -9,7 +9,7 @@ const {findContentNodesInItem, findHintNodesInItem, inferItemShape} =
|
|
|
9
9
|
|
|
10
10
|
// Takes a renderer content and parses the markdown for images
|
|
11
11
|
function findImagesInContent(content: any, images: Array<any>) {
|
|
12
|
-
// @ts-expect-error
|
|
12
|
+
// @ts-expect-error - TS2554 - Expected 2 arguments, but got 1.
|
|
13
13
|
const parsed = PerseusMarkdown.parse(content);
|
|
14
14
|
|
|
15
15
|
PerseusMarkdown.traverseContent(parsed, function (node) {
|
|
@@ -119,12 +119,12 @@ function findImagesInItemData(itemData: any): any {
|
|
|
119
119
|
let renderers = [];
|
|
120
120
|
if (itemData._multi) {
|
|
121
121
|
const shape = inferItemShape(itemData);
|
|
122
|
-
// @ts-expect-error
|
|
122
|
+
// @ts-expect-error - TS2345 - Argument of type 'ContentNode' is not assignable to parameter of type 'never'.
|
|
123
123
|
findContentNodesInItem(itemData, shape, (node) => renderers.push(node));
|
|
124
|
-
// @ts-expect-error
|
|
124
|
+
// @ts-expect-error - TS2345 - Argument of type 'HintNode' is not assignable to parameter of type 'never'.
|
|
125
125
|
findHintNodesInItem(itemData, shape, (node) => renderers.push(node));
|
|
126
126
|
} else {
|
|
127
|
-
// @ts-expect-error
|
|
127
|
+
// @ts-expect-error - TS2322 - Type 'any' is not assignable to type 'never'. | TS2322 - Type 'any' is not assignable to type 'never'.
|
|
128
128
|
renderers = [itemData.question, ...itemData.hints];
|
|
129
129
|
}
|
|
130
130
|
return findImagesInRenderers(renderers);
|
|
@@ -17,7 +17,7 @@ import * as React from "react";
|
|
|
17
17
|
let nextIframeID = 0;
|
|
18
18
|
const requestIframeData: Record<string, any> = {};
|
|
19
19
|
const updateIframeHeight: Record<string, any> = {};
|
|
20
|
-
// @ts-expect-error
|
|
20
|
+
// @ts-expect-error - 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
|
|
@@ -66,12 +66,12 @@ type Props = {
|
|
|
66
66
|
|
|
67
67
|
class IframeContentRenderer extends React.Component<Props> {
|
|
68
68
|
_frame: HTMLIFrameElement | null | undefined;
|
|
69
|
-
// @ts-expect-error
|
|
69
|
+
// @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
|
|
70
70
|
_isMounted: boolean;
|
|
71
71
|
_lastData: any;
|
|
72
|
-
// @ts-expect-error
|
|
72
|
+
// @ts-expect-error - TS2564 - Property '_lastHeight' has no initializer and is not definitely assigned in the constructor.
|
|
73
73
|
_lastHeight: number;
|
|
74
|
-
// @ts-expect-error
|
|
74
|
+
// @ts-expect-error - TS2564 - Property 'iframeID' has no initializer and is not definitely assigned in the constructor.
|
|
75
75
|
iframeID: number;
|
|
76
76
|
|
|
77
77
|
componentDidMount() {
|
|
@@ -91,7 +91,7 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
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
|
|
94
|
+
// @ts-expect-error - TS2339 - Property 'style' does not exist on type 'ReactInstance'.
|
|
95
95
|
this.refs.container.style.height = height + "px";
|
|
96
96
|
}
|
|
97
97
|
};
|
|
@@ -107,11 +107,11 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
107
107
|
componentDidUpdate(prevProps: Props) {
|
|
108
108
|
if (!this.props.seamless) {
|
|
109
109
|
// eslint-disable-next-line react/no-string-refs
|
|
110
|
-
// @ts-expect-error
|
|
110
|
+
// @ts-expect-error - TS2339 - Property 'style' does not exist on type 'ReactInstance'.
|
|
111
111
|
this.refs.container.style.height = "100%";
|
|
112
112
|
} else {
|
|
113
113
|
// eslint-disable-next-line react/no-string-refs
|
|
114
|
-
// @ts-expect-error
|
|
114
|
+
// @ts-expect-error - TS2339 - Property 'style' does not exist on type 'ReactInstance'.
|
|
115
115
|
this.refs.container.style.height = this._lastHeight + "px";
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -132,7 +132,7 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
132
132
|
// Don't initialize the iframe until the page has loaded
|
|
133
133
|
if (this._frame) {
|
|
134
134
|
// eslint-disable-next-line react/no-string-refs
|
|
135
|
-
// @ts-expect-error
|
|
135
|
+
// @ts-expect-error - TS2339 - Property 'removeChild' does not exist on type 'ReactInstance'.
|
|
136
136
|
this.refs.container.removeChild(this._frame);
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -160,7 +160,7 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
// eslint-disable-next-line react/no-string-refs
|
|
163
|
-
// @ts-expect-error
|
|
163
|
+
// @ts-expect-error - TS2339 - Property 'appendChild' does not exist on type 'ReactInstance'.
|
|
164
164
|
this.refs.container.appendChild(frame);
|
|
165
165
|
|
|
166
166
|
this._frame = frame;
|
|
@@ -174,7 +174,7 @@ class IframeContentRenderer extends React.Component<Props> {
|
|
|
174
174
|
// We can't use JSON.stringify/parse for this because the apiOptions
|
|
175
175
|
// includes the functions GroupMetadataEditor, groupAnnotator,
|
|
176
176
|
// onFocusChange, and onInputError.
|
|
177
|
-
// @ts-expect-error
|
|
177
|
+
// @ts-expect-error - TS2339 - Property 'iframeDataStore' does not exist on type 'Window & typeof globalThis'.
|
|
178
178
|
window.iframeDataStore[this.iframeID] = data;
|
|
179
179
|
frame.contentWindow.postMessage(this.iframeID, "*");
|
|
180
180
|
}
|