Render soft line breaks in paragraphs with buttons (RND-12359)

This commit is contained in:
Nolann Biron
2026-10-28 23:47:36 +01:00
parent e745c88166
commit 628c77068a
@@ -38,12 +38,21 @@ export function Text(props: { text: DocumentText }) {
{children}
</Mark>
);
}, leaf.text)}
}, withSoftBreaks(leaf.text))}
</React.Fragment>
);
});
}
// Paragraphs with buttons are flex containers, where a `\n` alone can't move the next items to a new line.
function withSoftBreaks(text: string): React.ReactNode {
return text
.split('\n')
.flatMap((line, index) =>
index === 0 ? line : ['\n', <span key={index} className="basis-full" />, line]
);
}
const MARK_STYLES = {
bold: Bold,
italic: Italic,