Skip to content

Commit 645108e

Browse files
committed
fix(editor): should udpate icon statu when formatting the entire block text
1 parent 52bfae3 commit 645108e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

blocksuite/affine/widget-toolbar/src/toolbar.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ import {
2424
WidgetComponent,
2525
} from '@blocksuite/block-std';
2626
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
27-
import {
28-
Bound,
29-
getCommonBound,
30-
nextTick,
31-
throttle,
32-
} from '@blocksuite/global/utils';
27+
import { Bound, getCommonBound, throttle } from '@blocksuite/global/utils';
3328
import type { Placement, ReferenceElement } from '@floating-ui/dom';
3429
import { batch, effect, signal } from '@preact/signals-core';
3530
import { css } from 'lit';
@@ -227,9 +222,7 @@ export class AffineToolbarWidget extends WidgetComponent {
227222
// 1. Prevents flickering effects.
228223
// 2. We cannot use `host.getUpdateComplete()` here
229224
// because it would cause excessive DOM queries, leading to UI jamming.
230-
nextTick()
231-
.then(() => flags.refresh(Flag.Text))
232-
.catch(console.error);
225+
flags.refresh(Flag.Text);
233226
})
234227
);
235228

@@ -240,6 +233,15 @@ export class AffineToolbarWidget extends WidgetComponent {
240233
flags.reset();
241234
return;
242235
}
236+
237+
if (
238+
flags.check(Flag.Block) &&
239+
record.type === 'update' &&
240+
record.props.key === 'text'
241+
) {
242+
flags.refresh(Flag.Block);
243+
return;
244+
}
243245
})
244246
);
245247

0 commit comments

Comments
 (0)