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:
@@ -51,6 +51,7 @@ const flatTableSchema = defineBlockSchema({
|
||||
textCols: {} as Record<string, Text>,
|
||||
rows: {} as Record<string, { color: string }>,
|
||||
labels: [] as Array<string>,
|
||||
optional: undefined as string | undefined,
|
||||
}),
|
||||
metadata: {
|
||||
role: 'content',
|
||||
@@ -494,6 +495,16 @@ describe('flat', () => {
|
||||
expect(model.props.textCols$.value.a.toDelta()).toEqual([
|
||||
{ insert: 'test' },
|
||||
]);
|
||||
|
||||
onChange.mockClear();
|
||||
expect(model.props).not.toHaveProperty('optional');
|
||||
expect(model.props).toHaveProperty('optional$');
|
||||
model.props.optional$.value = 'test';
|
||||
expect(model.props.optional).toBe('test');
|
||||
expect(model.props.optional$.value).toBe('test');
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'optional', true);
|
||||
expect(yBlock.get('prop:optional')).toBe('test');
|
||||
});
|
||||
|
||||
test('stash and pop', () => {
|
||||
|
||||
Reference in New Issue
Block a user