From 502f602c7fe0d2c66228f9967dc83e0536c39666 Mon Sep 17 00:00:00 2001 From: Sarah Third Date: Thu, 14 Nov 2024 14:28:20 -0800 Subject: [PATCH] Addressing PR Feedback --- .../perseus-editor/src/article-editor.tsx | 19 ++++++++++++------- packages/perseus-editor/src/editor-page.tsx | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/perseus-editor/src/article-editor.tsx b/packages/perseus-editor/src/article-editor.tsx index 5c9b812940..aa47755ae6 100644 --- a/packages/perseus-editor/src/article-editor.tsx +++ b/packages/perseus-editor/src/article-editor.tsx @@ -72,16 +72,21 @@ export default class ArticleEditor extends React.Component { super(props); // Check if the json needs to be converted - const conversionWarningRequired = conversionRequired( - props.json as PerseusRenderer, - ); + const conversionWarningRequired = + props.json instanceof Array + ? props.json + .map(conversionRequired) + .reduce((p, v) => p && v, false) + : conversionRequired(props.json); + let json = props.json; // Convert the json if needed if (conversionWarningRequired) { - json = Array.isArray(props.json) - ? props.json.map(convertDeprecatedWidgets) - : convertDeprecatedWidgets(props.json as PerseusRenderer); + json = + props.json instanceof Array + ? props.json.map(convertDeprecatedWidgets) + : convertDeprecatedWidgets(props.json); } this.state = { @@ -439,7 +444,7 @@ export default class ArticleEditor extends React.Component { {this.state.conversionWarningRequired && (
diff --git a/packages/perseus-editor/src/editor-page.tsx b/packages/perseus-editor/src/editor-page.tsx index 8c22d4f4e5..8d069f5c62 100644 --- a/packages/perseus-editor/src/editor-page.tsx +++ b/packages/perseus-editor/src/editor-page.tsx @@ -263,7 +263,7 @@ class EditorPage extends React.Component { {this.state.conversionWarningRequired && (