Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): cancel block not found alert #8310

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions packages/frontend/core/src/modules/editor/entities/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { paramsParseOptions, preprocessParams } from '../../navigation/utils';
import type { WorkbenchView } from '../../workbench';
import { EditorScope } from '../scopes/editor';
import type { EditorSelector } from '../types';
import { scrollAnchoring } from '../utils/scroll-anchoring';

export class Editor extends Entity {
readonly scope = this.framework.createScope(EditorScope, {
Expand Down Expand Up @@ -159,14 +158,21 @@ export class Editor extends Entity {

const focusAt$ = LiveData.computed(get => {
const selector = get(this.selector$);
const id =
get(this.mode$) === 'edgeless' && selector?.elementIds?.length
? selector?.elementIds?.[0]
: selector?.blockIds?.[0];
const mode = get(this.mode$);
let id = selector?.blockIds?.[0];
let key = 'blockIds';

if (mode === 'edgeless') {
const elementId = selector?.elementIds?.[0];
if (elementId) {
id = elementId;
key = 'elementIds';
}
}

if (!id) return null;

return { id, refreshKey: selector?.refreshKey };
return { id, key, mode, refreshKey: selector?.refreshKey };
});
if (focusAt$.value === null && docTitle) {
const title = docTitle.querySelector<
Expand All @@ -177,15 +183,25 @@ export class Editor extends Entity {

const subscription = focusAt$
.distinctUntilChanged(
(a, b) => a?.id === b?.id && a?.refreshKey === b?.refreshKey
(a, b) =>
a?.id === b?.id &&
a?.key === b?.key &&
a?.refreshKey === b?.refreshKey
)
.subscribe(params => {
if (!params?.id) return;
.subscribe(anchor => {
if (!anchor) return;

const selection = editorContainer.host?.std.selection;
if (!selection) return;

const std = editorContainer.host?.std;
if (!std) return;
const { id, key, mode } = anchor;

scrollAnchoring(std, this.mode$.value, params.id);
selection.setGroup('scene', [
selection.create('highlight', {
mode,
[key]: [id],
}),
]);
});
unsubs.push(subscription.unsubscribe.bind(subscription));

Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions packages/frontend/i18n/src/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
"Back Home": "Back home",
"Back to Quick Search": "Back to quick search",
"Back to all": "Back to all",
"Block not found": "Block not found",
"Block not found description": "The block you are trying to access does not exist or has been removed.",
"Body text": "Body text",
"Bold": "Bold",
"Cancel": "Cancel",
Expand Down
Loading