feat: add copy code button
This commit is contained in:
parent
b62b972e46
commit
8460dd5f9a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user