feat(research): download exact saved revisions (RP26)
This commit is contained in:
parent
6ce3b68b3d
commit
5434950263
7 changed files with 320 additions and 3 deletions
15
apps/stock/web-app/src/utils/downloadJsonText.ts
Normal file
15
apps/stock/web-app/src/utils/downloadJsonText.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/** Save inert JSON text and release the browser URL after it consumes the click. */
|
||||
export function downloadJsonText(text: string, filename: string): void {
|
||||
const url = URL.createObjectURL(new Blob([text], { type: 'application/json' }));
|
||||
let anchor: HTMLAnchorElement | undefined;
|
||||
try {
|
||||
anchor = document.createElement('a');
|
||||
anchor.href = url;
|
||||
anchor.download = filename;
|
||||
document.body.append(anchor);
|
||||
anchor.click();
|
||||
} finally {
|
||||
setTimeout(() => URL.revokeObjectURL(url), 0);
|
||||
anchor?.remove();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue