Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

zzj372018dfad28d748
diff --git a/blocksuite/framework/store/src/model/block/draft.ts b/blocksuite/framework/store/src/model/block/draft.ts
index e9e764c609..48baa54a95 100644
--- a/blocksuite/framework/store/src/model/block/draft.ts
+++ b/blocksuite/framework/store/src/model/block/draft.ts
@@ -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>);