Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(editor): should update icon status when formatting the entire block text (#10508)

fundon916134b1dad4
diff --git a/blocksuite/affine/widget-toolbar/src/toolbar.ts b/blocksuite/affine/widget-toolbar/src/toolbar.ts
index 44e9d2acdc..6e25674d67 100644
--- a/blocksuite/affine/widget-toolbar/src/toolbar.ts
+++ b/blocksuite/affine/widget-toolbar/src/toolbar.ts
@@ -257,6 +257,19 @@ export class AffineToolbarWidget extends WidgetComponent {
})
);
+ disposables.add(
+ std.store.slots.blockUpdated.on(record => {
+ if (
+ flags.isBlock() &&
+ record.type === 'update' &&
+ record.props.key === 'text'
+ ) {
+ flags.refresh(Flag.Block);
+ return;
+ }
+ })
+ );
+
// Handles `drag and drop`
const dragStart = () => flags.toggle(Flag.Hiding, true);
const dragEnd = () => flags.toggle(Flag.Hiding, false);
diff --git a/blocksuite/tests-legacy/e2e/format-bar.spec.ts b/blocksuite/tests-legacy/e2e/format-bar.spec.ts
index 7d996272da..28dfdfefec 100644
--- a/blocksuite/tests-legacy/e2e/format-bar.spec.ts
+++ b/blocksuite/tests-legacy/e2e/format-bar.spec.ts
@@ -27,7 +27,6 @@ import {
selectAllBlocksByKeyboard,
selectAllByKeyboard,
setInlineRangeInInlineEditor,
- setSelection,
switchReadonly,
type,
undoByKeyboard,
@@ -338,7 +337,6 @@ test('should format quick bar be able to link text', async ({
`${testInfo.title}_init.json`
);
- await setSelection(page, 3, 0, 3, 3);
// The link button should be active after click
await expect(linkBtn).toHaveAttribute('active', '');
await linkBtn.click();