mirror of
https://github.com/portainer/portainer.git
synced 2025-07-28 01:39:39 +02:00
This commit is contained in:
parent
4aea5690a8
commit
7cc28b10a0
1 changed files with 13 additions and 1 deletions
|
@ -32,7 +32,19 @@ export function CopyButton({
|
||||||
function onClick() {
|
function onClick() {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
|
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
|
||||||
// https://caniuse.com/?search=clipboard
|
// https://caniuse.com/?search=clipboard
|
||||||
navigator.clipboard.writeText(copyText);
|
if (navigator.clipboard) {
|
||||||
|
navigator.clipboard.writeText(copyText);
|
||||||
|
} else {
|
||||||
|
// https://stackoverflow.com/a/57192718
|
||||||
|
const inputEl = document.createElement('input');
|
||||||
|
inputEl.value = copyText;
|
||||||
|
inputEl.type = 'text';
|
||||||
|
document.body.appendChild(inputEl);
|
||||||
|
inputEl.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
inputEl.type = 'hidden';
|
||||||
|
document.body.removeChild(inputEl);
|
||||||
|
}
|
||||||
setIsFading(true);
|
setIsFading(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue