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:
Linus Flood
2025-04-29 09:38:05 +00:00
parent fcf1cc8fbb
commit af2a3f42c8
2 changed files with 26 additions and 14 deletions

View File

@@ -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(

View File

@@ -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(