refactor(editor): remove global types in model (#10082)

Closes: [BS-2249](https://linear.app/affine-design/issue/BS-2249/remove-global-types-in-model)

```ts
// before
matchFlavours(model, ['affine:page']);
// after
matchFlavours(model, [PageBlockModel]);
```
This commit is contained in:
Saul-Mirone
2025-02-11 08:18:57 +00:00
parent 64bb6c5a71
commit 652865c7cf
97 changed files with 492 additions and 323 deletions

View File

@@ -11,6 +11,7 @@ import {
BookmarkStyles,
DEFAULT_NOTE_HEIGHT,
DEFAULT_NOTE_WIDTH,
FrameBlockModel,
MAX_IMAGE_WIDTH,
ReferenceInfoSchema,
} from '@blocksuite/affine-model';
@@ -994,7 +995,7 @@ export class EdgelessClipboardController extends PageClipboard {
for (const nodeElement of nodeElements) {
await _drawTopLevelBlock(nodeElement);
if (matchFlavours(nodeElement, ['affine:frame'])) {
if (matchFlavours(nodeElement, [FrameBlockModel])) {
const blocksInsideFrame: BlockSuite.EdgelessBlockModelType[] = [];
this.edgeless.service.frame
.getElementsInFrameBound(nodeElement, false)

View File

@@ -9,6 +9,7 @@ import {
GroupElementModel,
LayoutType,
MindmapElementModel,
NoteBlockModel,
NoteDisplayMode,
type ShapeElementModel,
} from '@blocksuite/affine-model';
@@ -134,7 +135,7 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
selection.selectedElements.length === 1 &&
selection.firstElement instanceof GfxBlockElementModel &&
matchFlavours(selection.firstElement as GfxBlockElementModel, [
'affine:note',
NoteBlockModel,
])
) {
rootComponent.slots.toggleNoteSlicer.emit();
@@ -259,7 +260,7 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
block =>
block.group === null &&
!(
matchFlavours(block, ['affine:note']) &&
matchFlavours(block, [NoteBlockModel]) &&
block.displayMode === NoteDisplayMode.DocOnly
)
)

View File

@@ -7,7 +7,7 @@ import {
normalizeWheelDeltaY,
} from '@blocksuite/affine-block-surface';
import {
type NoteBlockModel,
NoteBlockModel,
NoteDisplayMode,
type RootBlockModel,
type ShapeElementModel,
@@ -350,7 +350,7 @@ export class EdgelessRootBlockComponent extends BlockComponent<
const primaryMode = std.get(DocModeProvider).getPrimaryMode(this.doc.id);
const note = this.model.children.find(
(child): child is NoteBlockModel =>
matchFlavours(child, ['affine:note']) &&
matchFlavours(child, [NoteBlockModel]) &&
child.displayMode !== NoteDisplayMode.EdgelessOnly
);