mirror of
https://github.com/pelican-dev/panel.git
synced 2025-09-25 09:08:00 +02:00
17 lines
679 B
JavaScript
17 lines
679 B
JavaScript
(() => {
|
|
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') return;
|
|
navigator.clipboard = navigator.clipboard || {};
|
|
navigator.clipboard.writeText = async (text) =>
|
|
new Promise((resolve, reject) => {
|
|
const textarea = document.createElement('textarea');
|
|
textarea.value = text;
|
|
textarea.style.position = 'fixed';
|
|
textarea.style.left = '-9999px';
|
|
textarea.style.opacity = '0';
|
|
document.body.appendChild(textarea);
|
|
textarea.select();
|
|
const success = document.execCommand('copy');
|
|
document.body.removeChild(textarea);
|
|
success ? resolve() : reject('Fallback copy failed');
|
|
});
|
|
})(); |