mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 11:06:25 +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:
@@ -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'>> = {},
|
||||
|
||||
Reference in New Issue
Block a user