1
0

feat: add copy code button

This commit is contained in:
Rokas Puzonas 2022-02-07 22:10:36 +02:00
parent b62b972e46
commit 8460dd5f9a

View File

@ -6,11 +6,21 @@ import { generate, TableMethodGeneratorOptions } from './TableMethodGenerator';
SyntaxHighlighter.registerLanguage('csharp', csharp);
function TableMethodCodeBlock(props: TableMethodGeneratorOptions) {
let script = generate(props)
const onClickCopy = () => {
navigator.clipboard.writeText(script)
}
return (
<SyntaxHighlighter language="csharp" style={vs2015}>
{generate(props)}
</SyntaxHighlighter>
<div>
<SyntaxHighlighter language="csharp" style={vs2015}>
{script}
</SyntaxHighlighter>
<button onClick={onClickCopy}>Copy code!</button>
</div>
)
}
export default TableMethodCodeBlock