Skip to content

Commit

Permalink
Merge pull request #3331 from serlo/hide-empty-content-in-exercises
Browse files Browse the repository at this point in the history
fix(plugin-exercise): hide empty content in static view to avoid unexpected margins
  • Loading branch information
hejtful authored Feb 1, 2024
2 parents d3815c4 + c6a635a commit 39b2b6c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/editor/src/plugins/exercise/static.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import { StaticRenderer } from '@editor/static-renderer/static-renderer'
import { EditorExerciseDocument } from '@editor/types/editor-plugins'
import { isRowsDocument } from '@editor/types/plugin-type-guards'

import { isEmptyTextDocument } from '../text/utils/static-is-empty'

export function ExerciseStaticRenderer({ state }: EditorExerciseDocument) {
const { content, interactive, solution } = state
if (!content) return null

const isEmptyContent =
isRowsDocument(content) &&
content.state.length === 1 &&
isEmptyTextDocument(content.state[0])

return (
<>
<StaticRenderer document={content} />
{isEmptyContent ? (
<div className="mt-6"></div>
) : (
<StaticRenderer document={content} />
)}
<StaticRenderer document={interactive} />
<StaticRenderer document={solution} />
</>
Expand Down

0 comments on commit 39b2b6c

Please sign in to comment.