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,5 +1,11 @@
import { textConversionConfigs } from '@blocksuite/affine-components/rich-text';
import { NoteBlockSchema } from '@blocksuite/affine-model';
import {
CodeBlockModel,
ListBlockModel,
NoteBlockModel,
NoteBlockSchema,
ParagraphBlockModel,
} from '@blocksuite/affine-model';
import {
getBlockSelectionsCommand,
getNextBlockCommand,
@@ -149,7 +155,7 @@ export class NoteBlockService extends BlockService {
const doc = this._std.store;
let parent = doc.getBlock(blockId)?.model ?? null;
while (parent) {
if (matchFlavours(parent, [NoteBlockSchema.model.flavour])) {
if (matchFlavours(parent, [NoteBlockModel])) {
return parent;
}
parent = doc.getParent(parent);
@@ -189,9 +195,9 @@ export class NoteBlockService extends BlockService {
if (
!matchFlavours(nextBlock.model, [
'affine:paragraph',
'affine:list',
'affine:code',
ParagraphBlockModel,
ListBlockModel,
CodeBlockModel,
])
) {
this._std.command.exec(selectBlock, {
@@ -225,9 +231,9 @@ export class NoteBlockService extends BlockService {
event.preventDefault();
if (
matchFlavours(nextBlock.model, [
'affine:paragraph',
'affine:list',
'affine:code',
ParagraphBlockModel,
ListBlockModel,
CodeBlockModel,
])
) {
this._std.command.exec(focusBlockStart, {
@@ -279,9 +285,9 @@ export class NoteBlockService extends BlockService {
if (
!matchFlavours(prevBlock.model, [
'affine:paragraph',
'affine:list',
'affine:code',
ParagraphBlockModel,
ListBlockModel,
CodeBlockModel,
])
) {
this._std.command.exec(selectBlock, {
@@ -313,9 +319,9 @@ export class NoteBlockService extends BlockService {
if (
matchFlavours(prevBlock.model, [
'affine:paragraph',
'affine:list',
'affine:code',
ParagraphBlockModel,
ListBlockModel,
CodeBlockModel,
])
) {
event.preventDefault();