fix: Checking for children to decide if we should render paragraph vs div
Approved-by: Matilda Landström
This commit is contained in:
@@ -307,11 +307,18 @@ export const renderOptions: RenderOptions = {
|
|||||||
return next(node.children, embeds, fullRenderOptions)
|
return next(node.children, embeds, fullRenderOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine whether to use a div or p based on children.
|
||||||
|
// Some children use div or sections as wrappers and these are
|
||||||
|
// not allowed inside p tags.
|
||||||
|
const Elem = node.children.some((child) => 'children' in child)
|
||||||
|
? 'div'
|
||||||
|
: 'p'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Typography key={node.uid} variant="Body/Paragraph/mdRegular">
|
<Typography key={node.uid} variant="Body/Paragraph/mdRegular">
|
||||||
<p className={cx(styles.p, className)} {...props}>
|
<Elem className={cx(styles.p, className)} {...props}>
|
||||||
{next(node.children, embeds, fullRenderOptions)}
|
{next(node.children, embeds, fullRenderOptions)}
|
||||||
</p>
|
</Elem>
|
||||||
</Typography>
|
</Typography>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user