Skip to content

Commit 1be1eff

Browse files
committed
Replace react-clipboard.js with navigator.clipboard.writeText
We support only modern browsers!
1 parent 9afc470 commit 1be1eff

File tree

4 files changed

+10
-139
lines changed

4 files changed

+10
-139
lines changed

build/webpack.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ module.exports = (env = {}, { mode }) => ({
2323

2424
resolve: {
2525
extensions: ['.ts', '.tsx', '.mjs', '.js', '.json', '.css', '.svg'],
26-
alias: {
27-
clipboard: 'clipboard/dist/clipboard.min.js',
28-
},
2926
},
3027

3128
externals: env.lib

demo/IntrospectionModal.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
33

4+
import Grid from '@material-ui/core/Grid';
45
import Modal from '@material-ui/core/Modal';
56
import Tabs from '@material-ui/core/Tabs';
67
import Tab from '@material-ui/core/Tab';
78
import Button from '@material-ui/core/Button';
8-
import Clipboard from 'react-clipboard.js';
99

1010
import {
1111
buildSchema,
@@ -56,7 +56,8 @@ export class IntrospectionModal extends React.Component<IntrospectionModalProps>
5656
this.changeCurrent({ inputType: tabNames[activeTab] });
5757
};
5858

59-
copy() {
59+
async copyIntrospectionQuery() {
60+
await navigator.clipboard.writeText(getIntrospectionQuery());
6061
this.setState({ recentlyCopied: true });
6162
setTimeout(() => {
6263
this.setState({ recentlyCopied: false });
@@ -185,17 +186,15 @@ export class IntrospectionModal extends React.Component<IntrospectionModalProps>
185186
Run the introspection query against a GraphQL endpoint. Paste the
186187
result into the textarea below to view the model relationships.
187188
</div>
188-
<Clipboard
189-
component="a"
190-
className="copy-button"
191-
options={{ container: this.modalRef.current }}
192-
data-clipboard-text={getIntrospectionQuery()}
193-
onClick={() => this.copy()}
194-
>
195-
<Button color="primary" size="small">
189+
<Grid container justify="center">
190+
<Button
191+
color="primary"
192+
size="small"
193+
onClick={async () => this.copyIntrospectionQuery()}
194+
>
196195
{recentlyCopied ? 'Copied!' : 'Copy Introspection Query'}
197196
</Button>
198-
</Clipboard>
197+
</Grid>
199198
<textarea
200199
value={jsonText || ''}
201200
placeholder="Paste Introspection Here"

package-lock.json

Lines changed: 0 additions & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"prettier": "2.6.2",
4444
"raw-loader": "1.0.0",
4545
"react": "16.8.6",
46-
"react-clipboard.js": "2.0.16",
4746
"react-dom": "16.8.6",
4847
"react-svg-loader": "2.1.0",
4948
"style-loader": "0.23.1",

0 commit comments

Comments
 (0)