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
@@ -16,6 +16,7 @@ import {
} from '@blocksuite/affine-shared/services';
import { LassoMode } from '@blocksuite/affine-shared/types';
import { matchFlavours } from '@blocksuite/affine-shared/utils';
import { SurfaceSelection, TextSelection } from '@blocksuite/block-std';
import {
GfxBlockElementModel,
type GfxToolsMap,
@@ -167,8 +168,8 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
const std = this.rootComponent.std;
if (
std.selection.getGroup('note').length > 0 ||
std.selection.find('text') ||
Boolean(std.selection.find('surface')?.editing)
std.selection.find(TextSelection) ||
Boolean(std.selection.find(SurfaceSelection)?.editing)
) {
return;
}
@@ -22,12 +22,12 @@ import {
requestConnectedFrame,
requestThrottledConnectedFrame,
} from '@blocksuite/affine-shared/utils';
import type {
GfxBlockComponent,
import {
BlockComponent,
type GfxBlockComponent,
SurfaceSelection,
UIEventHandler,
type UIEventHandler,
} from '@blocksuite/block-std';
import { BlockComponent } from '@blocksuite/block-std';
import {
GfxControllerIdentifier,
type GfxViewportElement,
@@ -454,7 +454,7 @@ export class EdgelessRootBlockComponent extends BlockComponent<
this.handleEvent('selectionChange', () => {
const surface = this.host.selection.value.find(
(sel): sel is SurfaceSelection => sel.is('surface')
(sel): sel is SurfaceSelection => sel.is(SurfaceSelection)
);
if (!surface) return;
@@ -9,11 +9,11 @@ import {
ThemeProvider,
} from '@blocksuite/affine-shared/services';
import { requestThrottledConnectedFrame } from '@blocksuite/affine-shared/utils';
import type {
GfxBlockComponent,
import {
BlockComponent,
type GfxBlockComponent,
SurfaceSelection,
} from '@blocksuite/block-std';
import { BlockComponent } from '@blocksuite/block-std';
import type { GfxViewportElement } from '@blocksuite/block-std/gfx';
import { assertExists } from '@blocksuite/global/utils';
import { css, html } from 'lit';
@@ -181,7 +181,7 @@ export class EdgelessRootPreviewBlockComponent
this.handleEvent('selectionChange', () => {
const surface = this.host.selection.value.find(
(sel): sel is SurfaceSelection => sel.is('surface')
(sel): sel is SurfaceSelection => sel.is(SurfaceSelection)
);
if (!surface) return;