mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user