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
@@ -10,7 +10,11 @@ import {
} from '@blocksuite/affine-components/toolbar';
import type { ImageBlockModel } from '@blocksuite/affine-model';
import { PAGE_HEADER_HEIGHT } from '@blocksuite/affine-shared/consts';
import { WidgetComponent } from '@blocksuite/block-std';
import {
BlockSelection,
TextSelection,
WidgetComponent,
} from '@blocksuite/block-std';
import { limitShift, shift } from '@floating-ui/dom';
import { html } from 'lit';
@@ -35,7 +39,7 @@ export class AffineImageToolbarWidget extends WidgetComponent<
const imageBlock = this.block;
const selection = this.host.selection;
const textSelection = selection.find('text');
const textSelection = selection.find(TextSelection);
if (
!!textSelection &&
(!!textSelection.to || !!textSelection.from.length)
@@ -43,7 +47,7 @@ export class AffineImageToolbarWidget extends WidgetComponent<
return null;
}
const blockSelections = selection.filter('block');
const blockSelections = selection.filter(BlockSelection);
if (
blockSelections.length > 1 ||
(blockSelections.length === 1 &&
@@ -3,6 +3,7 @@ import {
getBlockProps,
isInsidePageEditor,
} from '@blocksuite/affine-shared/utils';
import { BlockSelection } from '@blocksuite/block-std';
import { assertExists } from '@blocksuite/global/utils';
export function duplicate(
@@ -38,7 +39,7 @@ export function duplicate(
.then(() => {
const { selection } = editorHost;
selection.setGroup('note', [
selection.create('block', {
selection.create(BlockSelection, {
blockId: duplicateId,
}),
]);