feat: add file preview modal (#945)
This commit is contained in:
@@ -24,6 +24,8 @@ type ZippableData = {
|
||||
content: Blob;
|
||||
}[];
|
||||
|
||||
type ObjectURL = string;
|
||||
|
||||
export class ArchiveManager {
|
||||
private readonly application: WebApplication;
|
||||
private textFile?: string;
|
||||
@@ -32,6 +34,10 @@ export class ArchiveManager {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public async getMimeType(ext: string) {
|
||||
return (await import('@zip.js/zip.js')).getMimeType(ext);
|
||||
}
|
||||
|
||||
public async downloadBackup(encrypted: boolean): Promise<void> {
|
||||
const intent = encrypted
|
||||
? EncryptionIntent.FileEncrypted
|
||||
@@ -150,10 +156,10 @@ export class ArchiveManager {
|
||||
return this.textFile;
|
||||
}
|
||||
|
||||
downloadData(data: Blob, fileName: string) {
|
||||
downloadData(data: Blob | ObjectURL, fileName: string) {
|
||||
const link = document.createElement('a');
|
||||
link.setAttribute('download', fileName);
|
||||
link.href = this.hrefForData(data);
|
||||
link.href = typeof data === 'string' ? data : this.hrefForData(data);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
|
||||
Reference in New Issue
Block a user