diff --git a/plugs/editor/upload.ts b/plugs/editor/upload.ts index f373f0e1..4269672e 100644 --- a/plugs/editor/upload.ts +++ b/plugs/editor/upload.ts @@ -1,8 +1,8 @@ import { readSetting } from "$sb/lib/settings_page.ts"; import { editor, space } from "$sb/syscalls.ts"; import { UploadFile } from "../../plug-api/types.ts"; +import { maximumAttachmentSize } from "../../web/constants.ts"; -const maximumAttachmentSize = 10; // MiB function folderName(path: string) { return path.split("/").slice(0, -1).join("/"); diff --git a/web/cm_plugins/editor_paste.ts b/web/cm_plugins/editor_paste.ts index 6b9b68da..e792584d 100644 --- a/web/cm_plugins/editor_paste.ts +++ b/web/cm_plugins/editor_paste.ts @@ -195,11 +195,10 @@ export function attachmentExtension(editor: Client) { suggestedName: string, mimeType: string, ) { - if (data!.byteLength > maximumAttachmentSize) { + const maxSize = editor.settings.maximumAttachmentSize || maximumAttachmentSize; + if (data!.byteLength > (maxSize * 1024 * 1024)) { editor.flashNotification( - `Attachment is too large, maximum is ${ - maximumAttachmentSize / 1024 / 1024 - }MB`, + `Attachment is too large, maximum is ${maxSize}MiB`, "error", ); return; diff --git a/web/constants.ts b/web/constants.ts index 26d93777..f152a7c5 100644 --- a/web/constants.ts +++ b/web/constants.ts @@ -1 +1 @@ -export const maximumAttachmentSize = 1024 * 1024 * 10; // 10MB +export const maximumAttachmentSize = 10; // MiB \ No newline at end of file