Merged in fix/rte-null-check (pull request #1901)
fix: null check on nodeChildrenToHtml to avoid rendering empty objects * fix: null check on nodeChildrenToHtml to avoid rendering empty objects Approved-by: Michael Zetterberg Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -33,13 +33,19 @@ export function nodeChildrenToHtml(
|
||||
embeds: EmbedByUid,
|
||||
fullRenderOptions: RenderOptions
|
||||
): any {
|
||||
return nodes.map((node, i) => {
|
||||
// This function either returns a JSX element or null
|
||||
return {
|
||||
...nodeToHtml(node, embeds, fullRenderOptions),
|
||||
key: `child-rte-${i}`,
|
||||
}
|
||||
})
|
||||
return nodes
|
||||
.map((node, i) => {
|
||||
// This function either returns a JSX element or null
|
||||
const element = nodeToHtml(node, embeds, fullRenderOptions)
|
||||
if (!element) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
...element,
|
||||
key: `child-rte-${i}`,
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
export function textNodeToHtml(
|
||||
|
||||
@@ -37,13 +37,19 @@ export function nodeChildrenToHtml(
|
||||
embeds: EmbedByUid,
|
||||
fullRenderOptions: RenderOptions
|
||||
): any {
|
||||
return nodes.map((node, i) => {
|
||||
// This function either returns a JSX element or null
|
||||
return {
|
||||
...nodeToHtml(node, embeds, fullRenderOptions),
|
||||
key: `child-rte-${i}`,
|
||||
}
|
||||
})
|
||||
return nodes
|
||||
.map((node, i) => {
|
||||
// This function either returns a JSX element or null
|
||||
const element = nodeToHtml(node, embeds, fullRenderOptions)
|
||||
if (!element) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
...element,
|
||||
key: `child-rte-${i}`,
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
export function textNodeToHtml(
|
||||
|
||||
Reference in New Issue
Block a user