mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-15 01:02:35 +02:00
fix(v2): fix codeblock copy button not including blank lines (#2285)
This commit is contained in:
parent
8d804c662c
commit
7086c279e2
2 changed files with 8 additions and 0 deletions
|
@ -102,6 +102,10 @@ export default ({children, className: languageClassName, metastring}) => {
|
||||||
|
|
||||||
<code ref={target} className={styles.codeBlockLines} style={style}>
|
<code ref={target} className={styles.codeBlockLines} style={style}>
|
||||||
{tokens.map((line, i) => {
|
{tokens.map((line, i) => {
|
||||||
|
if (line.length === 1 && line[0].content === '') {
|
||||||
|
line[0].content = '\n'; // eslint-disable-line no-param-reassign
|
||||||
|
}
|
||||||
|
|
||||||
const lineProps = getLineProps({line, key: i});
|
const lineProps = getLineProps({line, key: i});
|
||||||
|
|
||||||
if (highlightLines.includes(i + 1)) {
|
if (highlightLines.includes(i + 1)) {
|
||||||
|
|
|
@ -121,6 +121,10 @@ export default ({
|
||||||
|
|
||||||
<code ref={target} className={styles.codeBlockLines} style={style}>
|
<code ref={target} className={styles.codeBlockLines} style={style}>
|
||||||
{tokens.map((line, i) => {
|
{tokens.map((line, i) => {
|
||||||
|
if (line.length === 1 && line[0].content === '') {
|
||||||
|
line[0].content = '\n'; // eslint-disable-line no-param-reassign
|
||||||
|
}
|
||||||
|
|
||||||
const lineProps = getLineProps({line, key: i});
|
const lineProps = getLineProps({line, key: i});
|
||||||
|
|
||||||
if (highlightLines.includes(i + 1)) {
|
if (highlightLines.includes(i + 1)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue