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
@@ -1,3 +1,4 @@
import { NoteBlockModel } from '@blocksuite/affine-model';
import {
calcDropTarget,
type DropTarget,
@@ -11,6 +12,7 @@ import {
type EditorHost,
LifeCycleWatcher,
} from '@blocksuite/block-std';
import { SurfaceBlockModel } from '@blocksuite/block-std/gfx';
import { createIdentifier } from '@blocksuite/global/di';
import type { IVec } from '@blocksuite/global/utils';
import { Point, throttle } from '@blocksuite/global/utils';
@@ -57,7 +59,7 @@ export class FileDropExtension extends LifeCycleWatcher {
const model = element.model;
const parent = this.std.store.getParent(model);
if (!matchFlavours(parent, ['affine:surface' as BlockSuite.Flavour])) {
if (!matchFlavours(parent, [SurfaceBlockModel])) {
const point = this.point$.value;
target = point && calcDropTarget(point, model, element);
}
@@ -73,7 +75,7 @@ export class FileDropExtension extends LifeCycleWatcher {
if (!rootModel) return null;
let lastNote = rootModel.children[rootModel.children.length - 1];
if (!lastNote || !matchFlavours(lastNote, ['affine:note'])) {
if (!lastNote || !matchFlavours(lastNote, [NoteBlockModel])) {
const newNoteId = this.doc.addBlock('affine:note', {}, rootModel.id);
const newNote = this.doc.getBlock(newNoteId)?.model;
if (!newNote) return null;