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:
@@ -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",
|
||||
|
||||
@@ -140,3 +140,8 @@ export type LintDiagnostic = {
|
||||
severity: "error" | "warning" | "info" | "hint";
|
||||
message: string;
|
||||
};
|
||||
|
||||
export type UploadFile = {
|
||||
name: string;
|
||||
content: Uint8Array;
|
||||
}
|
||||
Reference in New Issue
Block a user