Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): image block size limits were not enforced as expected (#8908)

JimmFly4ce8a180aa54
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')]
+ );
},
},
];