fix(editor): toDraftModal supports flat data structures (#10466)

fix: PD-2374
fix: BS-2703
This commit is contained in:
zzj3720
2025-02-27 05:16:10 +00:00
parent f43a848e18
commit 18dfad28d7

View File

@@ -15,10 +15,14 @@ export function toDraftModel<Model extends BlockModel = BlockModel>(
origin: Model
): DraftModel<Model> {
const { id, version, flavour, role, keys, text, children } = origin;
const isFlatData = origin.schema.model.isFlatData;
const props = origin.keys.reduce((acc, key) => {
const target = isFlatData ? origin.props : origin;
const value = target[key as keyof typeof target];
return {
...acc,
[key]: origin[key as keyof Model],
[key]: value,
};
}, {} as ModelProps<Model>);