fix(editor): block can be null in widget (#10959)

Closes: [BS-2826](https://linear.app/affine-design/issue/BS-2826/typeerror-thisblock-is-null)
This commit is contained in:
Saul-Mirone
2025-03-18 10:58:19 +00:00
parent b7ab49a263
commit 321e3449ec
17 changed files with 118 additions and 55 deletions
@@ -144,6 +144,10 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
}
private _getCursorRect(selections: BaseSelection[]): SelectionRect | null {
if (!this.block) {
return null;
}
if (this.block.model.flavour !== 'affine:page') {
console.error('remote selection widget must be used in page component');
return null;
@@ -208,6 +212,10 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
private readonly _getSelectionRect = (
selections: BaseSelection[]
): SelectionRect[] => {
if (!this.block) {
return [];
}
if (this.block.model.flavour !== 'affine:page') {
console.error('remote selection widget must be used in page component');
return [];