Implement editor.uploadFile syscall (#570)

* Implement editor.attachFile syscall

* Refactor attachFile to uploadFile

returns a promise with an UploadFile now

* Fix style

* Reject promise with errors

* Another code style fix

---------

Co-authored-by: prcrst <p-github@prcr.st>
This commit is contained in:
prcrst
2023-11-22 15:33:25 +01:00
committed by GitHub
co-authored by prcrst
parent 9b89330ec9
commit ae1561ac90
3 changed files with 51 additions and 0 deletions
+5
View File
@@ -1,4 +1,5 @@
import type { FilterOption } from "../../web/types.ts";
import { UploadFile } from "../types.ts";
import { syscall } from "./syscall.ts";
export function getCurrentPage(): Promise<string> {
@@ -55,6 +56,10 @@ export function downloadFile(filename: string, dataUrl: string): Promise<void> {
return syscall("editor.downloadFile", filename, dataUrl);
}
export function uploadFile(accept?: string, capture?: string): Promise<UploadFile> {
return syscall("editor.uploadFile", accept, capture);
}
export function flashNotification(
message: string,
type: "info" | "error" = "info",