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.

feat(core): add error notification for block not found (#8254)

fundon46f8237a46e0
diff --git a/packages/frontend/core/src/modules/editor/utils/scroll-anchoring.ts b/packages/frontend/core/src/modules/editor/utils/scroll-anchoring.ts
index 8f51ea23ee..25c10cec2b 100644
--- a/packages/frontend/core/src/modules/editor/utils/scroll-anchoring.ts
+++ b/packages/frontend/core/src/modules/editor/utils/scroll-anchoring.ts
@@ -1,3 +1,5 @@
+import { notify } from '@affine/component';
+import { I18n } from '@affine/i18n';
import type { BlockStdScope, SelectionManager } from '@blocksuite/block-std';
import type {
DocMode,
@@ -38,7 +40,10 @@ function scrollAnchoringInEdgelessMode(
bounds = Bound.fromXYWH(deserializeXYWH(model.xywh));
}
- if (!bounds) return;
+ if (!bounds) {
+ notify.error({ title: I18n['Block not found']() });
+ return;
+ }
const { zoom, centerX, centerY } = service.getFitToScreenData(
[20, 20, 100, 20],
@@ -72,7 +77,10 @@ function scrollAnchoringInEdgelessMode(
function scrollAnchoringInPageMode(service: PageRootService, id: string) {
const blockComponent = service.std.view.getBlock(id);
- if (!blockComponent) return;
+ if (!blockComponent) {
+ notify.error({ title: I18n['Block not found']() });
+ return;
+ }
blockComponent.scrollIntoView({
behavior: 'instant',
diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json
index c4d77a05db..2163763e1a 100644
--- a/packages/frontend/i18n/src/resources/en.json
+++ b/packages/frontend/i18n/src/resources/en.json
@@ -1613,5 +1613,6 @@
"unnamed": "unnamed",
"upgradeBrowser": "Please upgrade to the latest version of Chrome for the best experience.",
"will be moved to Trash": "{{title}} will be moved to trash",
- "will delete member": "will delete member"
+ "will delete member": "will delete member",
+ "Block not found": "Block not found"
}