mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix(editor): toDraftModal supports flat data structures (#10466)
fix: PD-2374 fix: BS-2703
This commit is contained in:
@@ -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