mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-30 17:17:06 +00:00
Render soft line breaks in paragraphs with buttons (RND-12359)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user