From 4ce8a180aa54b5cffa060d9a712d0cc03e8189ac Mon Sep 17 00:00:00 2001 From: JimmFly Date: Mon, 25 Nov 2024 07:15:14 +0000 Subject: [PATCH] fix(core): image block size limits were not enforced as expected (#8908) --- .../specs/custom/attachment-block.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/attachment-block.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/attachment-block.ts index 17a938b228..ba4df99cf5 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/attachment-block.ts +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/attachment-block.ts @@ -7,6 +7,7 @@ import { import { AttachmentBlockService, AttachmentBlockSpec, + ImageBlockService, } from '@blocksuite/affine/blocks'; import bytes from 'bytes'; @@ -19,6 +20,15 @@ class CustomAttachmentBlockService extends AttachmentBlockService { } } +class CustomImageBlockService extends ImageBlockService { + override mounted(): void { + // blocksuite default max file size is 10MB, we override it to 2GB + // but the real place to limit blob size is CloudQuotaModal / LocalQuotaModal + this.maxFileSize = bytes.parse('2GB'); + super.mounted(); + } +} + export const CustomAttachmentBlockSpec: ExtensionType[] = [ ...AttachmentBlockSpec, { @@ -28,6 +38,11 @@ export const CustomAttachmentBlockSpec: ExtensionType[] = [ CustomAttachmentBlockService, [StdIdentifier, BlockFlavourIdentifier('affine:attachment')] ); + di.override( + BlockServiceIdentifier('affine:image'), + CustomImageBlockService, + [StdIdentifier, BlockFlavourIdentifier('affine:image')] + ); }, }, ];