mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(editor): should clear selection when switching doc mode (#11545)
Closes: [BS-3050](https://linear.app/affine-design/issue/BS-3050/切换模式时,清除选区)
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
} from '@blocksuite/affine-gfx-text';
|
||||
import { NoteBlockSchema } from '@blocksuite/affine-model';
|
||||
import {
|
||||
AutoClearSelectionService,
|
||||
DNDAPIExtension,
|
||||
DocModeService,
|
||||
EmbedOptionService,
|
||||
@@ -77,6 +78,7 @@ export const CommonSpecs: ExtensionType[] = [
|
||||
DNDAPIExtension,
|
||||
FileDropExtension,
|
||||
ToolbarRegistryExtension,
|
||||
AutoClearSelectionService,
|
||||
...RootBlockAdapterExtensions,
|
||||
...clipboardConfigs,
|
||||
...EdgelessElementViews,
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { LifeCycleWatcher } from '@blocksuite/std';
|
||||
|
||||
// Auto Clear selection when switching doc mode.
|
||||
export class AutoClearSelectionService extends LifeCycleWatcher {
|
||||
static override readonly key = 'auto-clear-selection-service';
|
||||
|
||||
override unmounted() {
|
||||
if (this.std.store.readonly) return;
|
||||
|
||||
this.std.selection.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './auto-clear-selection-service';
|
||||
export * from './block-meta-service';
|
||||
export * from './doc-display-meta-service';
|
||||
export * from './doc-mode-service';
|
||||
|
||||
Reference in New Issue
Block a user