fix(editor): suface component can be null (#12270)

Closes: BS-3149

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Improved internal handling of surface components across various tools, resulting in safer and more consistent access patterns.
  - Enhanced code maintainability and reliability without altering any visible features or user workflows.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Saul-Mirone
2025-05-14 08:37:10 +00:00
parent 7e722957a9
commit f2164e4d70
6 changed files with 39 additions and 34 deletions
@@ -1,7 +1,7 @@
import {
getSurfaceComponent,
type Options,
type RoughCanvas,
type SurfaceBlockComponent,
ToolOverlay,
} from '@blocksuite/affine-block-surface';
import {
@@ -87,7 +87,8 @@ export class ShapeOverlay extends ToolOverlay {
shapeStyle
);
(this.gfx.surfaceComponent as SurfaceBlockComponent).refresh();
const surface = getSurfaceComponent(this.gfx.std);
surface?.refresh();
})
);
}