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

@@ -262,7 +262,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
const model = this.doc.getBlock(id)?.model;
const target = result.modelState.model;
let parent = this.doc.getParent(target.id);
const shouldInsertIn = result.type === 'in';
const shouldInsertIn = result.placement === 'in';
if (shouldInsertIn) {
parent = target;
}
@@ -274,7 +274,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
[model],
parent,
target,
result.type === 'before'
result.placement === 'before'
);
}
}