feat: add copy & download actions for modal

This commit is contained in:
divocat
2025-10-18 00:56:52 +03:00
parent d7235e8c06
commit fd64eb5bcb
5 changed files with 91 additions and 11 deletions

View File

@@ -0,0 +1,15 @@
export function downloadAsTxt(text: string, filename: string) {
const blob = new Blob([text], { type: 'text/plain;charset=utf-8' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
const safeName = filename.endsWith('.txt') ? filename : `${filename}.txt`;
link.download = safeName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(link.href);
}