Skip to content

Commit 3879b6a

Browse files
committed
Introduce SerializeOptions to editor serialize() functions
1 parent 89a96d7 commit 3879b6a

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

packages/perseus-editor/src/editor-page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import CombinedHintsEditor from "./hint-editor";
88
import ItemEditor from "./item-editor";
99

1010
import type {Issue} from "./issues-panel";
11+
import type {SerializeOptions} from "./types";
1112
import type {
1213
APIOptions,
1314
APIOptionsWithDefaults,
@@ -188,7 +189,7 @@ class EditorPage extends React.Component<Props, State> {
188189
return issues1.concat(issues2);
189190
}
190191

191-
serialize(options?: {keepDeletedWidgets?: boolean}): any | PerseusItem {
192+
serialize(options?: SerializeOptions): PerseusItem {
192193
if (this.props.jsonMode) {
193194
return this.state.json;
194195
}

packages/perseus-editor/src/editor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import WidgetEditor from "./components/widget-editor";
2828
import WidgetSelect from "./components/widget-select";
2929
import TexErrorView from "./tex-error-view";
3030

31+
import type {SerializeOptions} from "./types";
3132
import type {ChangeHandler, ImageUploader} from "@khanacademy/perseus";
3233
import type {PerseusWidget, PerseusWidgetsMap} from "@khanacademy/perseus-core";
3334

@@ -833,12 +834,12 @@ class Editor extends React.Component<Props, State> {
833834
}
834835
};
835836

836-
serialize: (options?: any) => {
837+
serialize: (options?: SerializeOptions) => {
837838
content: string;
838839
images: any;
839840
replace: any | undefined;
840841
widgets: Record<any, any>;
841-
} = (options: any) => {
842+
} = (options) => {
842843
// need to serialize the widgets since the state might not be
843844
// completely represented in props. ahem //transformer// (and
844845
// interactive-graph and plotter).

packages/perseus-editor/src/hint-editor.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
iconPlus,
1818
} from "./styles/icon-paths";
1919

20+
import type {SerializeOptions} from "./types";
2021
import type {
2122
APIOptions,
2223
ImageDict,
@@ -90,7 +91,7 @@ class HintEditor extends React.Component<HintEditorProps> {
9091
return this.editor.current?.getSaveWarnings();
9192
};
9293

93-
serialize: (options?: any) => any = (options: any) => {
94+
serialize: (options?: SerializeOptions) => any = (options) => {
9495
return this.editor.current?.serialize(options);
9596
};
9697

@@ -224,7 +225,7 @@ class CombinedHintEditor extends React.Component<CombinedHintEditorProps> {
224225
return this.editor.current?.getSaveWarnings();
225226
};
226227

227-
serialize = (options: any) => {
228+
serialize = (options: SerializeOptions) => {
228229
return this.editor.current?.serialize(options);
229230
};
230231

@@ -387,7 +388,9 @@ class CombinedHintsEditor extends React.Component<CombinedHintsEditorProps> {
387388
.value();
388389
};
389390

390-
serialize: (options?: any) => ReadonlyArray<string> = (options: any) => {
391+
serialize: (options?: SerializeOptions) => ReadonlyArray<string> = (
392+
options,
393+
) => {
391394
return this.props.hints.map((hint, i) => {
392395
return this.serializeHint(i, options);
393396
});

packages/perseus-editor/src/item-editor.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ItemExtrasEditor from "./item-extras-editor";
1111
import {WARNINGS} from "./messages";
1212

1313
import type {Issue} from "./issues-panel";
14+
import type {SerializeOptions} from "./types";
1415
import type {
1516
APIOptions,
1617
ImageUploader,
@@ -130,7 +131,7 @@ class ItemEditor extends React.Component<Props, State> {
130131
return this.questionEditor.current?.getSaveWarnings();
131132
};
132133

133-
serialize: (options?: any) => {
134+
serialize: (options?: SerializeOptions) => {
134135
answerArea: PerseusAnswerArea | undefined;
135136
question: any;
136137
} = (options: any) => {

packages/perseus-editor/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type SerializeOptions = {keepDeletedWidgets?: boolean};

0 commit comments

Comments
 (0)