mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 01:49:51 +08:00
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:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
type SurfaceBlockComponent,
|
||||
getSurfaceComponent,
|
||||
ToolOverlay,
|
||||
} from '@blocksuite/affine-block-surface';
|
||||
import { type Color, DefaultTheme } from '@blocksuite/affine-model';
|
||||
@@ -36,7 +36,8 @@ export class NoteOverlay extends ToolOverlay {
|
||||
if (this.gfx.tool.currentToolName$.value !== 'affine:note') return;
|
||||
const tool = this.gfx.tool.currentTool$.peek() as NoteTool;
|
||||
this.text = this._getOverlayText(tool.activatedOption.tip);
|
||||
(this.gfx.surfaceComponent as SurfaceBlockComponent).refresh();
|
||||
const surface = getSurfaceComponent(this.gfx.std);
|
||||
surface?.refresh();
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -139,7 +140,8 @@ export class DraggingNoteOverlay extends NoteOverlay {
|
||||
this.disposables.add(
|
||||
this.slots.draggingNoteUpdated.subscribe(({ xywh }) => {
|
||||
[this.x, this.y, this.width, this.height] = xywh;
|
||||
(this.gfx.surfaceComponent as SurfaceBlockComponent).refresh();
|
||||
const surface = getSurfaceComponent(this.gfx.std);
|
||||
surface?.refresh();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user