fix: split view focus (#11217)
# After: https://github.com/user-attachments/assets/990d500d-2da7-488e-ac32-dd7bd229f896 # Before: https://github.com/user-attachments/assets/6676766a-c76a-414b-a35e-53d2cda10c24
This commit is contained in:
@@ -82,8 +82,10 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {
|
||||
|
||||
private readonly _onTitleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.isComposing || this.doc.readonly) return;
|
||||
if (!this._std) return;
|
||||
|
||||
if (event.key === 'Enter') {
|
||||
this._std.event.active = true;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -99,6 +101,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {
|
||||
if (this._std) focusTextModel(this._std, newFirstParagraphId);
|
||||
}
|
||||
} else if (event.key === 'ArrowDown') {
|
||||
this._std.event.active = true;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { changeNoteDisplayMode } from '@blocksuite/affine-block-note';
|
||||
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
||||
import { DocModeProvider } from '@blocksuite/affine-shared/services';
|
||||
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||
import { ShadowlessElement, SurfaceSelection } from '@blocksuite/block-std';
|
||||
import { focusTitle, matchModels } from '@blocksuite/affine-shared/utils';
|
||||
import {
|
||||
BlockSelection,
|
||||
ShadowlessElement,
|
||||
SurfaceSelection,
|
||||
} from '@blocksuite/block-std';
|
||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||
import { Bound } from '@blocksuite/global/gfx';
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
|
||||
@@ -170,6 +174,19 @@ export class OutlinePanelBody extends SignalWatcher(
|
||||
}
|
||||
|
||||
private async _scrollToBlock(blockId: string) {
|
||||
// if focus title
|
||||
if (blockId === this.doc.root?.id) {
|
||||
this.editor.std.selection.setGroup('note', []);
|
||||
this.editor.std.event.active = false;
|
||||
focusTitle(this.editor);
|
||||
} else {
|
||||
this.editor.std.event.active = true;
|
||||
this.editor.std.selection.setGroup('note', [
|
||||
this.editor.std.selection.create(BlockSelection, {
|
||||
blockId,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
this._lockActiveHeadingId = true;
|
||||
this._activeHeadingId$.value = blockId;
|
||||
this._clearHighlightMask = await scrollToBlockWithHighlight(
|
||||
|
||||
Reference in New Issue
Block a user