mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 18:16:15 +08:00
fix(editor): missing signal of optional flat props (#13762)
Close https://github.com/toeverything/AFFiNE/issues/13750 #### PR Dependency Tree * **PR #13762** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Optional block properties are now supported (e.g., flat-table), with default values applied automatically when not set. * **Bug Fixes** * More reliable initialization and syncing of block properties, ensuring defaults appear consistently. * Change notifications now correctly reflect updates to optional/defaulted properties. * **Tests** * Added tests verifying optional property behavior, default application, syncing, and change events. <!-- end of auto-generated comment: release notes by coderabbit.ai --> #### PR Dependency Tree * **PR #13762** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -47,6 +47,7 @@ export class FlatSyncController {
|
||||
}
|
||||
|
||||
const model = schema.model.toModel?.() ?? new BlockModel<object>();
|
||||
const defaultProps = schema.model.props?.(internalPrimitives);
|
||||
model.schema = schema;
|
||||
|
||||
model.id = this.id;
|
||||
@@ -55,7 +56,8 @@ export class FlatSyncController {
|
||||
const reactive = new ReactiveFlatYMap(
|
||||
this.yBlock,
|
||||
model.deleted,
|
||||
this.onChange
|
||||
this.onChange,
|
||||
defaultProps
|
||||
);
|
||||
this._reactive = reactive;
|
||||
const proxy = reactive.proxy;
|
||||
@@ -66,17 +68,6 @@ export class FlatSyncController {
|
||||
model.store = this.doc;
|
||||
}
|
||||
|
||||
const defaultProps = schema.model.props?.(internalPrimitives);
|
||||
if (defaultProps) {
|
||||
Object.entries(defaultProps).forEach(([key, value]) => {
|
||||
if (key in proxy) {
|
||||
return;
|
||||
}
|
||||
if (value === undefined) return;
|
||||
proxy[key] = value;
|
||||
});
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user