feat(editor): unify block props api (#10888)

Closes: [BS-2707](https://linear.app/affine-design/issue/BS-2707/统一使用props获取和更新block-prop)
This commit is contained in:
Saul-Mirone
2025-03-16 05:48:34 +00:00
parent 8f9e5bf0aa
commit 26285f7dcb
193 changed files with 1019 additions and 891 deletions

View File

@@ -363,7 +363,7 @@ export async function assertRichTextModelType(
if (!block) {
throw new Error('block component is undefined');
}
return (block.model as BlockModel<{ type: string }>).type;
return (block.model as BlockModel<{ type: string }>).props.type;
},
{ index, BLOCK_ID_ATTR }
);
@@ -509,7 +509,7 @@ export async function assertBlockType(
const model = element.model;
// @ts-ignore
return model.type;
return model.props.type;
},
{ id }
);
@@ -574,7 +574,7 @@ export async function assertBlockProps(
const model = element.model as BlockModel;
return Object.fromEntries(
// @ts-ignore
Object.keys(props).map(key => [key, (model[key] as unknown).toString()])
Object.keys(props).map(key => [key, model.props[key].toString()])
);
},
[id, props] as const
@@ -590,7 +590,7 @@ export async function assertBlockTypes(page: Page, blockTypes: string[]) {
Array.from(elements)
.slice(2)
// @ts-ignore
.map(el => el.model.type)
.map(el => el.model.props.type)
);
});
expect(actual).toEqual(blockTypes);