blob: cfd3b31b2f5243e416c83000972ff9e1ed34538e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
export function downloadBlob({
blob,
filename,
}: {
blob: Blob;
filename: string;
}): void {
const url = URL.createObjectURL(blob);
const anchor = document.createElement("a");
anchor.href = url;
anchor.download = filename;
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
URL.revokeObjectURL(url);
}
export function isTypableDOMElement({
element,
}: {
element: HTMLElement;
}): boolean {
if (element.isContentEditable) return true;
if (element.tagName === "INPUT") {
return !(element as HTMLInputElement).disabled;
}
if (element.tagName === "TEXTAREA") {
return !(element as HTMLTextAreaElement).disabled;
}
return false;
}
|