mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 05:07:06 +08:00
fix(core): image block size limits were not enforced as expected (#8908)
This commit is contained in:
+15
@@ -7,6 +7,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
AttachmentBlockService,
|
AttachmentBlockService,
|
||||||
AttachmentBlockSpec,
|
AttachmentBlockSpec,
|
||||||
|
ImageBlockService,
|
||||||
} from '@blocksuite/affine/blocks';
|
} from '@blocksuite/affine/blocks';
|
||||||
import bytes from 'bytes';
|
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[] = [
|
export const CustomAttachmentBlockSpec: ExtensionType[] = [
|
||||||
...AttachmentBlockSpec,
|
...AttachmentBlockSpec,
|
||||||
{
|
{
|
||||||
@@ -28,6 +38,11 @@ export const CustomAttachmentBlockSpec: ExtensionType[] = [
|
|||||||
CustomAttachmentBlockService,
|
CustomAttachmentBlockService,
|
||||||
[StdIdentifier, BlockFlavourIdentifier('affine:attachment')]
|
[StdIdentifier, BlockFlavourIdentifier('affine:attachment')]
|
||||||
);
|
);
|
||||||
|
di.override(
|
||||||
|
BlockServiceIdentifier('affine:image'),
|
||||||
|
CustomImageBlockService,
|
||||||
|
[StdIdentifier, BlockFlavourIdentifier('affine:image')]
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user