refactor(editor): remove selection global types (#9532)

Closes: [BS-2217](https://linear.app/affine-design/issue/BS-2217/remove-global-types-in-selection)
This commit is contained in:
Saul-Mirone
2025-01-06 03:45:10 +00:00
parent 8669936f2f
commit fc863e484c
105 changed files with 501 additions and 358 deletions

View File

@@ -28,10 +28,12 @@ import {
import {
type BaseSelection,
BlockComponent,
BlockSelection,
BlockServiceWatcher,
BlockStdScope,
type EditorHost,
LifeCycleWatcher,
TextSelection,
} from '@blocksuite/block-std';
import {
GfxBlockElementModel,
@@ -267,7 +269,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
private _focusBlock() {
this.selection.update(() => {
return [this.selection.create('block', { blockId: this.blockId })];
return [this.selection.create(BlockSelection, { blockId: this.blockId })];
});
}
@@ -287,9 +289,9 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
requestConnectedFrame(() => {
selection.update(selList => {
return selList
.filter<BaseSelection>(sel => !sel.is('block'))
.filter<BaseSelection>(sel => !sel.is(BlockSelection))
.concat(
selection.create('text', {
selection.create(TextSelection, {
from: {
blockId: model.id,
index: 0,
@@ -415,7 +417,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
this._disposables.add(
selection.slots.changed.on(selList => {
this._focused = selList.some(
sel => sel.blockId === this.blockId && sel.is('block')
sel => sel.blockId === this.blockId && sel.is(BlockSelection)
);
})
);