perf(editor): optimize the search for the closest element (#9587)

Closes: [BS-2275](https://linear.app/affine-design/issue/BS-2275/拖拽-indicator-查找优化)
This commit is contained in:
fundon
2025-01-10 08:21:10 +00:00
parent 18ff7500c8
commit 0b3dba614d
11 changed files with 211 additions and 187 deletions

View File

@@ -21,12 +21,11 @@ export class AttachmentBlockService extends BlockService {
export const AttachmentDropOption = FileDropConfigExtension({
flavour: AttachmentBlockSchema.model.flavour,
onDrop: ({ files, targetModel, place, point, std }) => {
onDrop: ({ files, targetModel, placement, point, std }) => {
// generic attachment block for all files except images
const attachmentFiles = files.filter(
file => !file.type.startsWith('image/')
);
if (!attachmentFiles.length) return false;
if (targetModel && !matchFlavours(targetModel, ['affine:surface'])) {
@@ -36,7 +35,7 @@ export const AttachmentDropOption = FileDropConfigExtension({
// TODO: use max file size from service
maxFileSize,
targetModel,
place
placement
).catch(console.error);
return true;