mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 23:56:36 +08:00
fix(editor): slice to snapshot supports flat data structures
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { BlockModel } from '../model/block/block-model';
|
||||
import { BlockModel } from '../model/block/block-model';
|
||||
import type { DraftModel } from '../model/block/draft';
|
||||
import {
|
||||
type InternalPrimitives,
|
||||
@@ -43,9 +43,15 @@ export class BaseBlockTransformer<Props extends object = object> {
|
||||
}
|
||||
|
||||
protected _propsToSnapshot(model: DraftModel) {
|
||||
const props =
|
||||
model instanceof BlockModel
|
||||
? model.schema.model.isFlatData
|
||||
? model.props
|
||||
: model
|
||||
: model;
|
||||
return Object.fromEntries(
|
||||
model.keys.map(key => {
|
||||
const value = model[key as keyof typeof model];
|
||||
const value = props[key as keyof typeof model];
|
||||
return [key, toJSON(value)];
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user