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(editor): surface ref find element error (#9508)

Saul-Mironeee5f13cd0371
diff --git a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
index 0926031b67..4743d6233d 100644
--- a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
+++ b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts
@@ -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) {
@@ -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];