From db7305a20d0c984b4fb8aa1a5483c37419532b7d Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 20 Nov 2024 07:26:53 +0100 Subject: [PATCH] fix(editor): allow nullish state in `SerloRenderer` --- packages/editor/src/package/serlo-renderer.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/package/serlo-renderer.tsx b/packages/editor/src/package/serlo-renderer.tsx index 3c9ef5f7d3..0e92e9004e 100644 --- a/packages/editor/src/package/serlo-renderer.tsx +++ b/packages/editor/src/package/serlo-renderer.tsx @@ -9,7 +9,7 @@ import type { SupportedLanguage } from '@editor/types/language-data' import { defaultSerloEditorProps } from './config' import { editorData } from './editor-data' import { getEditorVersion } from './editor-version' -import { migrate, EditorVariant } from './storage-format' +import { migrate, EditorVariant, createEmptyDocument } from './storage-format' export interface SerloRendererProps { language?: SupportedLanguage @@ -19,11 +19,13 @@ export interface SerloRendererProps { } export function SerloRenderer(props: SerloRendererProps) { - const { language, _ltik, state, editorVariant } = { + const { language, _ltik, editorVariant } = { ...defaultSerloEditorProps, ...props, } + const state = !props.state ? createEmptyDocument(editorVariant) : props.state + // Side note: Migrated state will not be persisted since we cannot save in // static renderer view const { migratedState } = migrate(state, editorVariant)