fix: preserve line breaks when copy code in Firefox (#5668)

This commit is contained in:
Alexey Pyltsyn 2021-10-13 20:40:16 +03:00 committed by GitHub
parent 7868df13f1
commit 99f6e665e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -223,8 +223,8 @@ export default function CodeBlock({
style={style}> style={style}>
<code className={styles.codeBlockLines}> <code className={styles.codeBlockLines}>
{tokens.map((line, i) => { {tokens.map((line, i) => {
if (line.length === 1 && line[0].content === '') { if (line.length === 1 && line[0].content === '\n') {
line[0].content = '\n'; line[0].content = '';
} }
const lineProps = getLineProps({line, key: i}); const lineProps = getLineProps({line, key: i});
@ -238,6 +238,7 @@ export default function CodeBlock({
{line.map((token, key) => ( {line.map((token, key) => (
<span key={key} {...getTokenProps({token, key})} /> <span key={key} {...getTokenProps({token, key})} />
))} ))}
<br />
</span> </span>
); );
})} })}

View file

@ -56,8 +56,6 @@
float: left; float: left;
min-width: 100%; min-width: 100%;
padding: var(--ifm-pre-padding); padding: var(--ifm-pre-padding);
display: flex;
flex-direction: column;
} }
@media print { @media print {