mirror of
https://github.com/apache/superset.git
synced 2026-04-09 11:25:23 +00:00
[Feature] Copy-to-clipboard button in View Query (#3571)
* added copy-to-clipboard button to explore/view query * modified CopyToClipboard to deselect current before copying
This commit is contained in:
committed by
Maxime Beauchemin
parent
40fbf1c761
commit
7e64f2e988
@@ -4,8 +4,10 @@ import SyntaxHighlighter, { registerLanguage } from 'react-syntax-highlighter/di
|
||||
import html from 'react-syntax-highlighter/dist/languages/htmlbars';
|
||||
import markdown from 'react-syntax-highlighter/dist/languages/markdown';
|
||||
import github from 'react-syntax-highlighter/dist/styles/github';
|
||||
import CopyToClipboard from './../../components/CopyToClipboard';
|
||||
|
||||
import ModalTrigger from './../../components/ModalTrigger';
|
||||
import Button from '../../components/Button';
|
||||
import { t } from '../../locales';
|
||||
|
||||
registerLanguage('markdown', markdown);
|
||||
@@ -85,9 +87,21 @@ export default class DisplayQueryButton extends React.PureComponent {
|
||||
return <pre>{this.state.error}</pre>;
|
||||
} else if (this.state.query) {
|
||||
return (
|
||||
<SyntaxHighlighter language={this.state.language} style={github}>
|
||||
{this.state.query}
|
||||
</SyntaxHighlighter>);
|
||||
<div>
|
||||
<CopyToClipboard
|
||||
text={this.state.query}
|
||||
shouldShowText={false}
|
||||
copyNode={
|
||||
<Button style={{ position: 'absolute', right: 20 }}>
|
||||
<i className="fa fa-clipboard" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<SyntaxHighlighter language={this.state.language} style={github}>
|
||||
{this.state.query}
|
||||
</SyntaxHighlighter>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user