We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cf82428 commit c18ae22Copy full SHA for c18ae22
src/js/components/CopyToClipboard.js
@@ -35,7 +35,15 @@ export default class extends React.PureComponent {
35
);
36
37
if (navigator.clipboard) {
38
- navigator.clipboard.writeText(textToCopy);
+ navigator.clipboard.writeText(textToCopy).catch(err => {
39
+ // Fallback for non-secure contexts (i.e. http)
40
+ const textArea = document.createElement('textarea');
41
+ textArea.value = textToCopy;
42
+ document.body.appendChild(textArea);
43
+ textArea.select();
44
+ document.execCommand('copy');
45
+ document.body.removeChild(textArea);
46
+ });
47
} else {
48
console.error(
49
'react-json-view error:',
0 commit comments