1
0

Upload robustness

This commit is contained in:
Zef Hemel 2023-11-25 13:40:27 +01:00
parent e3a9bc532f
commit cd27739336
2 changed files with 7 additions and 4 deletions

View File

@ -56,7 +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> {
export function uploadFile(
accept?: string,
capture?: string,
): Promise<UploadFile> {
return syscall("editor.uploadFile", accept, capture);
}
@ -77,7 +80,7 @@ export function filterBox(
}
export function showPanel(
id: "lhs" | "rhs" | "bhs" | "modal" | "ps",
id: "lhs" | "rhs" | "bhs" | "modal" | "ps" | "preface",
mode: number,
html: string,
script = "",
@ -86,7 +89,7 @@ export function showPanel(
}
export function hidePanel(
id: "lhs" | "rhs" | "bhs" | "modal" | "ps",
id: "lhs" | "rhs" | "bhs" | "modal" | "ps" | "preface",
): Promise<void> {
return syscall("editor.hidePanel", id);
}

View File

@ -37,7 +37,7 @@ async function saveFile(file: UploadFile) {
file.content,
);
let attachmentMarkdown = `[${finalFileName}](${encodeURI(finalFileName)})`;
if (file.contentType.startsWith("image/")) {
if (file.contentType?.startsWith("image/")) {
attachmentMarkdown = `![](${encodeURI(finalFileName)})`;
}
editor.insertAtCursor(attachmentMarkdown);