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
@@ -20,9 +20,7 @@ type SignaledProps<Props> = Props & {
* myBlock.foo = 'bar';
* ```
*/
function MagicProps(): {
new <Props>(): Props;
} {
function MagicProps(): { new <Props>(): Props } {
return class {} as never;
}
@@ -51,18 +51,6 @@ export type PropsGetter<Props> = (
internalPrimitives: InternalPrimitives
) => Props;
export type SchemaToModel<
Schema extends {
model: {
props: PropsGetter<object>;
flavour: string;
};
},
> = BlockModel<ReturnType<Schema['model']['props']>> &
ReturnType<Schema['model']['props']> & {
flavour: Schema['model']['flavour'];
};
export function defineBlockSchema<
Flavour extends string,
Role extends RoleType,
@@ -451,20 +451,6 @@ export class Store {
}
}
addBlock<Key extends BlockSuite.Flavour>(
flavour: Key,
blockProps?: BlockSuite.ModelProps<BlockSuite.BlockModels[Key]>,
parent?: BlockModel | string | null,
parentIndex?: number
): string;
addBlock(
flavour: never,
blockProps?: Partial<BlockProps & Omit<BlockProps, 'flavour'>>,
parent?: BlockModel | string | null,
parentIndex?: number
): string;
addBlock(
flavour: string,
blockProps: Partial<BlockProps & Omit<BlockProps, 'flavour'>> = {},