mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 19:46:52 +03:00
17 lines
483 B
TypeScript
17 lines
483 B
TypeScript
import { showToast } from './showToast';
|
|
|
|
export function copyToClipboard(text: string) {
|
|
const textarea = document.createElement('textarea');
|
|
textarea.value = text;
|
|
document.body.appendChild(textarea);
|
|
textarea.select();
|
|
try {
|
|
document.execCommand('copy');
|
|
showToast(_('Successfully copied!'), 'success');
|
|
} catch (_err) {
|
|
showToast(_('Failed to copy!'), 'error');
|
|
console.error('copyToClipboard - e', _err);
|
|
}
|
|
document.body.removeChild(textarea);
|
|
}
|