fix(editor): toDraftModal supports flat data structures (#10466)
fix: PD-2374 fix: BS-2703
This commit is contained in:
1 parent
f43a848e18
commit
18dfad28d7
1 file changed
+5
-1
@@ -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>);
|
||||
|
||||
|
||||
Reference in new issue
Block a user