feat: implement show toast

This commit is contained in:
divocat
2025-10-18 01:07:10 +03:00
parent fd64eb5bcb
commit 96039f92a9
4 changed files with 129 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
import { showToast } from './showToast';
export function copyToClipboard(text: string) {
const textarea = document.createElement('textarea');
textarea.value = text;
@@ -5,7 +7,9 @@ export function copyToClipboard(text: string) {
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);