mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
12 lines
397 B
JavaScript
12 lines
397 B
JavaScript
|
export default function copyTextToClipboard(text) {
|
||
|
let textarea = document.createElement('textarea');
|
||
|
textarea.value = text;
|
||
|
textarea.setAttribute('readonly', '');
|
||
|
textarea.style.position = 'absolute';
|
||
|
textarea.style.left = '-9999px';
|
||
|
document.body.appendChild(textarea);
|
||
|
textarea.select();
|
||
|
document.execCommand('copy');
|
||
|
document.body.removeChild(textarea);
|
||
|
}
|