Skip to content

Commit

Permalink
fix(editor): surface ref find element error (#9508)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Jan 3, 2025
1 parent 51b109e commit ee5f13c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
.find(
doc =>
doc.getBlock(this.model.reference) ||
getSurfaceBlock(doc)!.getElementById(this.model.reference)
getSurfaceBlock(doc)?.getElementById(this.model.reference)
);

if (doc) {
Expand All @@ -355,11 +355,11 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
];
}

if (doc && getSurfaceBlock(doc)) {
return [
getSurfaceBlock(doc)!.getElementById(this.model.reference),
doc.id,
];
if (doc) {
const surfaceBlock = getSurfaceBlock(doc);
if (surfaceBlock) {
return [surfaceBlock.getElementById(this.model.reference), doc.id];
}
}

return [null, this.doc.id];
Expand Down

0 comments on commit ee5f13c

Please sign in to comment.