Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): allow state to be undefined/null in SerloRenderer #4302

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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