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,
|
embeds: EmbedByUid,
|
||||||
fullRenderOptions: RenderOptions
|
fullRenderOptions: RenderOptions
|
||||||
): any {
|
): any {
|
||||||
return nodes.map((node, i) => {
|
return nodes
|
||||||
// This function either returns a JSX element or null
|
.map((node, i) => {
|
||||||
return {
|
// This function either returns a JSX element or null
|
||||||
...nodeToHtml(node, embeds, fullRenderOptions),
|
const element = nodeToHtml(node, embeds, fullRenderOptions)
|
||||||
key: `child-rte-${i}`,
|
if (!element) {
|
||||||
}
|
return null
|
||||||
})
|
}
|
||||||
|
return {
|
||||||
|
...element,
|
||||||
|
key: `child-rte-${i}`,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function textNodeToHtml(
|
export function textNodeToHtml(
|
||||||
|
|||||||
@@ -37,13 +37,19 @@ export function nodeChildrenToHtml(
|
|||||||
embeds: EmbedByUid,
|
embeds: EmbedByUid,
|
||||||
fullRenderOptions: RenderOptions
|
fullRenderOptions: RenderOptions
|
||||||
): any {
|
): any {
|
||||||
return nodes.map((node, i) => {
|
return nodes
|
||||||
// This function either returns a JSX element or null
|
.map((node, i) => {
|
||||||
return {
|
// This function either returns a JSX element or null
|
||||||
...nodeToHtml(node, embeds, fullRenderOptions),
|
const element = nodeToHtml(node, embeds, fullRenderOptions)
|
||||||
key: `child-rte-${i}`,
|
if (!element) {
|
||||||
}
|
return null
|
||||||
})
|
}
|
||||||
|
return {
|
||||||
|
...element,
|
||||||
|
key: `child-rte-${i}`,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function textNodeToHtml(
|
export function textNodeToHtml(
|
||||||
|
|||||||
Reference in New Issue
Block a user