mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user