Skip to content

Commit

Permalink
Merge pull request #4302 from serlo/allow-nullish-state-in-serlo-rend…
Browse files Browse the repository at this point in the history
…erer

fix(editor): allow state to be undefined/null in `SerloRenderer`
  • Loading branch information
LarsTheGlidingSquirrel authored Nov 20, 2024
2 parents 4f90f60 + db7305a commit 98f2f76
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/editor/src/package/serlo-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 98f2f76

Please sign in to comment.