Skip to content

Commit

Permalink
feat(core): add error notification for block not found (#8254)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Sep 18, 2024
1 parent eb47c03 commit 46f8237
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/i18n/src/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 46f8237

Please sign in to comment.