Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
frontend: fix undefined childrenType warning
Browse files Browse the repository at this point in the history
  • Loading branch information
horacioh committed Sep 20, 2023
1 parent c976a71 commit 30d386f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions frontend/packages/shared/src/client/server-to-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import {
Block,
BlockNode,
} from './.generated/documents/v1alpha/documents_pb'
import {EditorBlock, InlineContent, StyledText} from './editor-types'
import {
EditorBlock,
EditorHeadingBlock,
InlineContent,
StyledText,
} from './editor-types'
import {HMBlockChildrenType, TextAnnotation} from './hyperdocs-presentation'
// import {Annotation, Block, BlockNode, TextAnnotation} from '@mintter/shared'
// import {hmBlockSchema} from './schema'
Expand Down Expand Up @@ -201,7 +206,6 @@ export function serverBlockNodeToEditorParagraph(
content: serverBlockToEditorInline(block),
children: serverChildrenToEditorChildren(children, {
...opts,
// childrenType: extractChildrenType(block.attributes.childrenType),
childrenType: block.attributes.childrenType as HMBlockChildrenType,
}),
props: {
Expand All @@ -218,18 +222,25 @@ export function serverBlockToHeading(
throw new Error('Server BlockNode is missing Block data')
}
const {block, children} = serverBlock
return {

let res: EditorHeadingBlock = {
type: 'heading',
id: block.id,
content: serverBlockToEditorInline(block),
children: serverChildrenToEditorChildren(children, {
headingLevel: (opts?.headingLevel || 0) + 1,
childrenType: extractChildrenType(block.attributes.childrenType),
childrenType: block.attributes.childrenType as HMBlockChildrenType,
}),
props: {
level: '2',
},
}

if (block.attributes.childrenType) {
res.props.childrenType = block.attributes
.childrenType as HMBlockChildrenType
}
return res
}

export function serverChildrenToEditorChildren(
Expand Down

0 comments on commit 30d386f

Please sign in to comment.