mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 05:12:31 +02:00
fix(v2): improve accessibility of code blocks (#4943)
This commit is contained in:
parent
52f19e15f0
commit
dfe32dac9e
2 changed files with 13 additions and 13 deletions
|
@ -207,13 +207,14 @@ export default function CodeBlock({
|
|||
</div>
|
||||
)}
|
||||
<div className={clsx(styles.codeBlockContent, language)}>
|
||||
<div
|
||||
<pre
|
||||
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
||||
tabIndex={0}
|
||||
className={clsx(className, styles.codeBlock, 'thin-scrollbar', {
|
||||
[styles.codeBlockWithTitle]: codeBlockTitle,
|
||||
})}>
|
||||
<div className={styles.codeBlockLines} style={style}>
|
||||
})}
|
||||
style={style}>
|
||||
<code className={styles.codeBlockLines}>
|
||||
{tokens.map((line, i) => {
|
||||
if (line.length === 1 && line[0].content === '') {
|
||||
line[0].content = '\n'; // eslint-disable-line no-param-reassign
|
||||
|
@ -222,19 +223,19 @@ export default function CodeBlock({
|
|||
const lineProps = getLineProps({line, key: i});
|
||||
|
||||
if (highlightLines.includes(i + 1)) {
|
||||
lineProps.className = `${lineProps.className} docusaurus-highlight-code-line`;
|
||||
lineProps.className += ' docusaurus-highlight-code-line';
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={i} {...lineProps}>
|
||||
<span key={i} {...lineProps}>
|
||||
{line.map((token, key) => (
|
||||
<span key={key} {...getTokenProps({token, key})} />
|
||||
))}
|
||||
</div>
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</code>
|
||||
</pre>
|
||||
|
||||
<button
|
||||
ref={button}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue