diff --git a/packages/blocks/src/root-block/widgets/format-bar/format-bar.ts b/packages/blocks/src/root-block/widgets/format-bar/format-bar.ts index ccb688615f66..4b5457c324cf 100644 --- a/packages/blocks/src/root-block/widgets/format-bar/format-bar.ts +++ b/packages/blocks/src/root-block/widgets/format-bar/format-bar.ts @@ -161,7 +161,10 @@ export class AffineFormatBarWidget extends WidgetElement { let targetRect: DOMRect | null = null; if (this.displayType === 'text' || this.displayType === 'native') { const range = this.nativeRange; - assertExists(range); + if (!range) { + this._reset(); + return; + } targetRect = range.getBoundingClientRect(); } else if (this.displayType === 'block') { const blockElement = this._selectedBlockElements[0];