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

View File

@@ -35,6 +35,10 @@ export class AffineCodeToolbarWidget extends WidgetComponent<
this,
({ abortController }) => {
const codeBlock = this.block;
if (!codeBlock) {
return null;
}
const selection = this.host.selection;
const textSelection = selection.find(TextSelection);
@@ -105,6 +109,9 @@ export class AffineCodeToolbarWidget extends WidgetComponent<
);
const codeBlock = this.block;
if (!codeBlock) {
return;
}
this._hoverController.setReference(codeBlock);
this._hoverController.onAbort = () => {
// If the more menu is opened, don't close it.