MISC: Remove file-saver (#1217)

Also refactor to dedup our own download code
This commit is contained in:
catloversg
2024-04-20 03:38:44 +07:00
committed by GitHub
parent 216500ed32
commit 7b993f3550
9 changed files with 20 additions and 62 deletions
-15
View File
@@ -24,21 +24,6 @@ export class TextFile implements ContentFile {
this.text = txt;
}
/** Serves the file to the user as a downloadable resource through the browser. */
download(): void {
const file: Blob = new Blob([this.text], { type: "text/plain" });
const a: HTMLAnchorElement = document.createElement("a");
const url: string = URL.createObjectURL(file);
a.href = url;
a.download = this.filename;
document.body.appendChild(a);
a.click();
setTimeout(() => {
document.body.removeChild(a);
URL.revokeObjectURL(url);
}, 0);
}
/** Serialize the current file to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("TextFile", this);