Upload robustness

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

View File

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