@wordpress/core-data 7.41.2-next.v.202603102151.0 → 7.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +19 -0
  3. package/build/actions.cjs +17 -25
  4. package/build/actions.cjs.map +2 -2
  5. package/build/awareness/post-editor-awareness.cjs +46 -6
  6. package/build/awareness/post-editor-awareness.cjs.map +2 -2
  7. package/build/awareness/types.cjs.map +1 -1
  8. package/build/entities.cjs +33 -7
  9. package/build/entities.cjs.map +2 -2
  10. package/build/hooks/use-entity-prop.cjs +2 -1
  11. package/build/hooks/use-entity-prop.cjs.map +2 -2
  12. package/build/hooks/use-post-editor-awareness-state.cjs +84 -3
  13. package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
  14. package/build/index.cjs +3 -0
  15. package/build/index.cjs.map +2 -2
  16. package/build/private-apis.cjs +3 -1
  17. package/build/private-apis.cjs.map +2 -2
  18. package/build/queried-data/get-query-parts.cjs +7 -0
  19. package/build/queried-data/get-query-parts.cjs.map +2 -2
  20. package/build/queried-data/selectors.cjs +19 -5
  21. package/build/queried-data/selectors.cjs.map +2 -2
  22. package/build/reducer.cjs +6 -0
  23. package/build/reducer.cjs.map +2 -2
  24. package/build/resolvers.cjs +110 -74
  25. package/build/resolvers.cjs.map +2 -2
  26. package/build/selectors.cjs +29 -0
  27. package/build/selectors.cjs.map +2 -2
  28. package/build/sync.cjs +3 -0
  29. package/build/sync.cjs.map +2 -2
  30. package/build/types.cjs +16 -0
  31. package/build/types.cjs.map +3 -3
  32. package/build/utils/block-selection-history.cjs +1 -1
  33. package/build/utils/block-selection-history.cjs.map +2 -2
  34. package/build/utils/crdt-blocks.cjs +17 -3
  35. package/build/utils/crdt-blocks.cjs.map +2 -2
  36. package/build/utils/crdt-selection.cjs +4 -1
  37. package/build/utils/crdt-selection.cjs.map +2 -2
  38. package/build/utils/crdt-user-selections.cjs +9 -6
  39. package/build/utils/crdt-user-selections.cjs.map +2 -2
  40. package/build/utils/crdt-utils.cjs +54 -2
  41. package/build/utils/crdt-utils.cjs.map +2 -2
  42. package/build/utils/crdt.cjs +4 -23
  43. package/build/utils/crdt.cjs.map +2 -2
  44. package/build/utils/index.cjs +3 -0
  45. package/build/utils/index.cjs.map +2 -2
  46. package/build/utils/normalize-query-for-resolution.cjs +35 -0
  47. package/build/utils/normalize-query-for-resolution.cjs.map +7 -0
  48. package/build-module/actions.mjs +17 -25
  49. package/build-module/actions.mjs.map +2 -2
  50. package/build-module/awareness/post-editor-awareness.mjs +46 -6
  51. package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
  52. package/build-module/entities.mjs +33 -7
  53. package/build-module/entities.mjs.map +2 -2
  54. package/build-module/hooks/use-entity-prop.mjs +2 -1
  55. package/build-module/hooks/use-entity-prop.mjs.map +2 -2
  56. package/build-module/hooks/use-post-editor-awareness-state.mjs +81 -2
  57. package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
  58. package/build-module/index.mjs +2 -0
  59. package/build-module/index.mjs.map +2 -2
  60. package/build-module/private-apis.mjs +6 -2
  61. package/build-module/private-apis.mjs.map +2 -2
  62. package/build-module/queried-data/get-query-parts.mjs +7 -0
  63. package/build-module/queried-data/get-query-parts.mjs.map +2 -2
  64. package/build-module/queried-data/selectors.mjs +19 -5
  65. package/build-module/queried-data/selectors.mjs.map +2 -2
  66. package/build-module/reducer.mjs +6 -0
  67. package/build-module/reducer.mjs.map +2 -2
  68. package/build-module/resolvers.mjs +112 -75
  69. package/build-module/resolvers.mjs.map +2 -2
  70. package/build-module/selectors.mjs +28 -0
  71. package/build-module/selectors.mjs.map +2 -2
  72. package/build-module/sync.mjs +2 -0
  73. package/build-module/sync.mjs.map +2 -2
  74. package/build-module/types.mjs +9 -0
  75. package/build-module/types.mjs.map +4 -4
  76. package/build-module/utils/block-selection-history.mjs +5 -2
  77. package/build-module/utils/block-selection-history.mjs.map +2 -2
  78. package/build-module/utils/crdt-blocks.mjs +17 -3
  79. package/build-module/utils/crdt-blocks.mjs.map +2 -2
  80. package/build-module/utils/crdt-selection.mjs +8 -2
  81. package/build-module/utils/crdt-selection.mjs.map +2 -2
  82. package/build-module/utils/crdt-user-selections.mjs +10 -7
  83. package/build-module/utils/crdt-user-selections.mjs.map +2 -2
  84. package/build-module/utils/crdt-utils.mjs +51 -1
  85. package/build-module/utils/crdt-utils.mjs.map +2 -2
  86. package/build-module/utils/crdt.mjs +4 -23
  87. package/build-module/utils/crdt.mjs.map +2 -2
  88. package/build-module/utils/index.mjs +2 -0
  89. package/build-module/utils/index.mjs.map +2 -2
  90. package/build-module/utils/normalize-query-for-resolution.mjs +14 -0
  91. package/build-module/utils/normalize-query-for-resolution.mjs.map +7 -0
  92. package/build-types/actions.d.ts.map +1 -1
  93. package/build-types/awareness/post-editor-awareness.d.ts +2 -2
  94. package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
  95. package/build-types/awareness/types.d.ts +1 -1
  96. package/build-types/awareness/types.d.ts.map +1 -1
  97. package/build-types/entities.d.ts +1 -1
  98. package/build-types/entities.d.ts.map +1 -1
  99. package/build-types/hooks/use-entity-prop.d.ts.map +1 -1
  100. package/build-types/hooks/use-post-editor-awareness-state.d.ts +34 -10
  101. package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
  102. package/build-types/index.d.ts +2 -0
  103. package/build-types/index.d.ts.map +1 -1
  104. package/build-types/private-apis.d.ts.map +1 -1
  105. package/build-types/queried-data/get-query-parts.d.ts +7 -0
  106. package/build-types/queried-data/get-query-parts.d.ts.map +1 -1
  107. package/build-types/queried-data/selectors.d.ts.map +1 -1
  108. package/build-types/reducer.d.ts.map +1 -1
  109. package/build-types/resolvers.d.ts +2 -1
  110. package/build-types/resolvers.d.ts.map +1 -1
  111. package/build-types/selectors.d.ts +17 -0
  112. package/build-types/selectors.d.ts.map +1 -1
  113. package/build-types/sync.d.ts +2 -2
  114. package/build-types/sync.d.ts.map +1 -1
  115. package/build-types/types.d.ts +18 -1
  116. package/build-types/types.d.ts.map +1 -1
  117. package/build-types/utils/block-selection-history.d.ts.map +1 -1
  118. package/build-types/utils/crdt-blocks.d.ts.map +1 -1
  119. package/build-types/utils/crdt-selection.d.ts.map +1 -1
  120. package/build-types/utils/crdt-user-selections.d.ts +9 -5
  121. package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
  122. package/build-types/utils/crdt-utils.d.ts +20 -0
  123. package/build-types/utils/crdt-utils.d.ts.map +1 -1
  124. package/build-types/utils/crdt.d.ts +6 -7
  125. package/build-types/utils/crdt.d.ts.map +1 -1
  126. package/build-types/utils/index.d.ts +1 -0
  127. package/build-types/utils/normalize-query-for-resolution.d.ts +12 -0
  128. package/build-types/utils/normalize-query-for-resolution.d.ts.map +1 -0
  129. package/build-types/utils/test/crdt-utils.d.ts +2 -0
  130. package/build-types/utils/test/crdt-utils.d.ts.map +1 -0
  131. package/package.json +18 -18
  132. package/src/actions.js +25 -40
  133. package/src/awareness/post-editor-awareness.ts +106 -7
  134. package/src/awareness/test/post-editor-awareness.ts +50 -10
  135. package/src/awareness/types.ts +1 -1
  136. package/src/entities.js +38 -6
  137. package/src/hooks/test/use-post-editor-awareness-state.ts +446 -3
  138. package/src/hooks/use-entity-prop.js +2 -0
  139. package/src/hooks/use-post-editor-awareness-state.ts +160 -8
  140. package/src/index.js +1 -0
  141. package/src/private-apis.js +6 -2
  142. package/src/queried-data/get-query-parts.js +13 -0
  143. package/src/queried-data/selectors.js +33 -8
  144. package/src/queried-data/test/get-query-parts.js +34 -0
  145. package/src/queried-data/test/selectors.js +183 -0
  146. package/src/reducer.js +11 -0
  147. package/src/resolvers.js +136 -88
  148. package/src/selectors.ts +56 -0
  149. package/src/sync.ts +2 -0
  150. package/src/test/entities.js +185 -1
  151. package/src/test/resolvers.js +64 -11
  152. package/src/test/selectors.js +150 -0
  153. package/src/test/store.js +66 -0
  154. package/src/types.ts +26 -1
  155. package/src/utils/block-selection-history.ts +5 -2
  156. package/src/utils/crdt-blocks.ts +32 -3
  157. package/src/utils/crdt-selection.ts +8 -2
  158. package/src/utils/crdt-user-selections.ts +20 -8
  159. package/src/utils/crdt-utils.ts +99 -0
  160. package/src/utils/crdt.ts +8 -32
  161. package/src/utils/index.js +1 -0
  162. package/src/utils/normalize-query-for-resolution.js +23 -0
  163. package/src/utils/test/crdt-blocks.ts +146 -0
  164. package/src/utils/test/crdt-user-selections.ts +5 -0
  165. package/src/utils/test/crdt-utils.ts +387 -0
  166. package/src/utils/test/crdt.ts +120 -53
@@ -22,7 +22,22 @@ import {
22
22
  import type { YBlock, YBlockRecord, YBlocks } from '../crdt-blocks';
23
23
  import { updateSelectionHistory } from '../crdt-selection';
24
24
  import { createYMap, getRootMap, type YMapWrap } from '../crdt-utils';
25
- import type { Post, Type } from '../../entity-types';
25
+ import type { Post } from '../../entity-types';
26
+
27
+ // Default synced properties matching the base set built in entities.js,
28
+ // plus 'categories' and 'tags' as example taxonomy rest_base values.
29
+ const defaultSyncedProperties = new Set< string >( [
30
+ 'blocks',
31
+ 'categories',
32
+ 'content',
33
+ 'date',
34
+ 'excerpt',
35
+ 'meta',
36
+ 'slug',
37
+ 'status',
38
+ 'tags',
39
+ 'title',
40
+ ] );
26
41
 
27
42
  describe( 'crdt', () => {
28
43
  let doc: Y.Doc;
@@ -37,8 +52,6 @@ describe( 'crdt', () => {
37
52
  } );
38
53
 
39
54
  describe( 'applyPostChangesToCRDTDoc', () => {
40
- const mockPostType = {} as Type;
41
-
42
55
  let map: YMapWrap< YPostRecord >;
43
56
 
44
57
  beforeEach( () => {
@@ -50,7 +63,7 @@ describe( 'crdt', () => {
50
63
  title: 'New Title',
51
64
  } as PostChanges;
52
65
 
53
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
66
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
54
67
 
55
68
  const title = map.get( 'title' );
56
69
  expect( title ).toBeInstanceOf( Y.Text );
@@ -63,7 +76,7 @@ describe( 'crdt', () => {
63
76
  unsyncedProperty: 'value',
64
77
  } as unknown as PostChanges;
65
78
 
66
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
79
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
67
80
 
68
81
  expect( map.has( 'unsyncedProperty' ) ).toBe( false );
69
82
  expect( map.get( 'title' )?.toString() ).toBe( 'New Title' );
@@ -74,7 +87,7 @@ describe( 'crdt', () => {
74
87
  title: () => 'function value',
75
88
  } as unknown as PostChanges;
76
89
 
77
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
90
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
78
91
 
79
92
  expect( map.has( 'title' ) ).toBe( false );
80
93
  } );
@@ -84,7 +97,7 @@ describe( 'crdt', () => {
84
97
  title: { raw: 'Raw Title', rendered: 'Rendered Title' },
85
98
  };
86
99
 
87
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
100
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
88
101
 
89
102
  const title = map.get( 'title' );
90
103
  expect( title ).toBeInstanceOf( Y.Text );
@@ -96,7 +109,7 @@ describe( 'crdt', () => {
96
109
  title: 'Auto Draft',
97
110
  } as PostChanges;
98
111
 
99
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
112
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
100
113
 
101
114
  const title = map.get( 'title' );
102
115
  expect( title ).toBeInstanceOf( Y.Text );
@@ -108,7 +121,7 @@ describe( 'crdt', () => {
108
121
  applyPostChangesToCRDTDoc(
109
122
  doc,
110
123
  { title: '' } as PostChanges,
111
- mockPostType
124
+ defaultSyncedProperties
112
125
  );
113
126
 
114
127
  const title = map.get( 'title' );
@@ -119,7 +132,7 @@ describe( 'crdt', () => {
119
132
  applyPostChangesToCRDTDoc(
120
133
  doc,
121
134
  { title: 'Auto Draft' } as PostChanges,
122
- mockPostType
135
+ defaultSyncedProperties
123
136
  );
124
137
 
125
138
  expect( map.get( 'title' )?.toString() ).toBe( '' );
@@ -134,7 +147,7 @@ describe( 'crdt', () => {
134
147
  },
135
148
  };
136
149
 
137
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
150
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
138
151
 
139
152
  const excerpt = map.get( 'excerpt' );
140
153
  expect( excerpt ).toBeInstanceOf( Y.Text );
@@ -146,7 +159,7 @@ describe( 'crdt', () => {
146
159
  slug: '',
147
160
  };
148
161
 
149
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
162
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
150
163
 
151
164
  expect( map.has( 'slug' ) ).toBe( false );
152
165
  } );
@@ -156,7 +169,7 @@ describe( 'crdt', () => {
156
169
  slug: 'my-post-slug',
157
170
  };
158
171
 
159
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
172
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
160
173
 
161
174
  expect( map.get( 'slug' ) ).toBe( 'my-post-slug' );
162
175
  } );
@@ -174,7 +187,7 @@ describe( 'crdt', () => {
174
187
  ],
175
188
  };
176
189
 
177
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
190
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
178
191
 
179
192
  expect( ( map.get( 'blocks' ) as YBlocks ).toJSON() ).toEqual(
180
193
  changes.blocks
@@ -186,7 +199,7 @@ describe( 'crdt', () => {
186
199
  blocks: [],
187
200
  };
188
201
 
189
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
202
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
190
203
 
191
204
  const blocks = map.get( 'blocks' );
192
205
  expect( blocks ).toBeInstanceOf( Y.Array );
@@ -200,7 +213,7 @@ describe( 'crdt', () => {
200
213
  blocks: undefined,
201
214
  };
202
215
 
203
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
216
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
204
217
 
205
218
  // The key should still exist, but the value should be undefined.
206
219
  expect( map.has( 'blocks' ) ).toBe( true );
@@ -212,7 +225,7 @@ describe( 'crdt', () => {
212
225
  content: 'Hello, world!',
213
226
  } as PostChanges;
214
227
 
215
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
228
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
216
229
 
217
230
  const content = map.get( 'content' );
218
231
  expect( content ).toBeInstanceOf( Y.Text );
@@ -227,7 +240,7 @@ describe( 'crdt', () => {
227
240
  },
228
241
  } as PostChanges;
229
242
 
230
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
243
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
231
244
 
232
245
  const content = map.get( 'content' );
233
246
  expect( content ).toBeInstanceOf( Y.Text );
@@ -241,7 +254,7 @@ describe( 'crdt', () => {
241
254
  applyPostChangesToCRDTDoc(
242
255
  doc,
243
256
  { title: 'Old Title' } as PostChanges,
244
- mockPostType
257
+ defaultSyncedProperties
245
258
  );
246
259
  const titleRef = map.get( 'title' );
247
260
 
@@ -249,7 +262,7 @@ describe( 'crdt', () => {
249
262
  applyPostChangesToCRDTDoc(
250
263
  doc,
251
264
  { title: 'New Title' } as PostChanges,
252
- mockPostType
265
+ defaultSyncedProperties
253
266
  );
254
267
 
255
268
  expect( map.get( 'title' ) ).toBe( titleRef );
@@ -261,7 +274,7 @@ describe( 'crdt', () => {
261
274
  applyPostChangesToCRDTDoc(
262
275
  doc,
263
276
  { content: 'Old content' } as PostChanges,
264
- mockPostType
277
+ defaultSyncedProperties
265
278
  );
266
279
  const contentRef = map.get( 'content' );
267
280
 
@@ -269,7 +282,7 @@ describe( 'crdt', () => {
269
282
  applyPostChangesToCRDTDoc(
270
283
  doc,
271
284
  { content: 'New content' } as PostChanges,
272
- mockPostType
285
+ defaultSyncedProperties
273
286
  );
274
287
 
275
288
  expect( map.get( 'content' ) ).toBe( contentRef );
@@ -281,7 +294,7 @@ describe( 'crdt', () => {
281
294
  applyPostChangesToCRDTDoc(
282
295
  doc,
283
296
  { excerpt: 'Old excerpt' } as PostChanges,
284
- mockPostType
297
+ defaultSyncedProperties
285
298
  );
286
299
  const excerptRef = map.get( 'excerpt' );
287
300
 
@@ -289,7 +302,7 @@ describe( 'crdt', () => {
289
302
  applyPostChangesToCRDTDoc(
290
303
  doc,
291
304
  { excerpt: 'New excerpt' } as PostChanges,
292
- mockPostType
305
+ defaultSyncedProperties
293
306
  );
294
307
 
295
308
  expect( map.get( 'excerpt' ) ).toBe( excerptRef );
@@ -307,7 +320,7 @@ describe( 'crdt', () => {
307
320
  metaMap.set( 'some_meta', 'old value' );
308
321
  map.set( 'meta', metaMap );
309
322
 
310
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
323
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
311
324
 
312
325
  expect( metaMap.get( 'some_meta' ) ).toBe( 'new value' );
313
326
  } );
@@ -323,7 +336,7 @@ describe( 'crdt', () => {
323
336
  metaMap.set( 'some_meta', 'old value' );
324
337
  map.set( 'meta', metaMap );
325
338
 
326
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
339
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
327
340
 
328
341
  expect( metaMap.get( 'some_meta' ) ).toStrictEqual( [
329
342
  'value',
@@ -338,23 +351,40 @@ describe( 'crdt', () => {
338
351
  },
339
352
  };
340
353
 
341
- applyPostChangesToCRDTDoc( doc, changes, mockPostType );
354
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
342
355
 
343
356
  const metaMap = map.get( 'meta' );
344
357
  expect( metaMap ).toBeInstanceOf( Y.Map );
345
358
  expect( metaMap?.get( 'custom_field' ) ).toBe( 'value' );
346
359
  } );
360
+
361
+ it( 'syncs taxonomy rest_base values included in syncedProperties', () => {
362
+ const changes = {
363
+ categories: [ 1, 2, 3 ],
364
+ genre: [ 10, 20 ], // should be ignored
365
+ tags: [ 4, 5 ],
366
+ } as unknown as PostChanges;
367
+
368
+ applyPostChangesToCRDTDoc( doc, changes, defaultSyncedProperties );
369
+
370
+ expect( map.get( 'categories' ) ).toEqual( [ 1, 2, 3 ] );
371
+ expect( map.get( 'genre' ) ).toBeUndefined();
372
+ expect( map.get( 'tags' ) ).toEqual( [ 4, 5 ] );
373
+
374
+ const customSyncedProperties = new Set( [
375
+ ...defaultSyncedProperties,
376
+ 'genre', // now included
377
+ ] );
378
+
379
+ applyPostChangesToCRDTDoc( doc, changes, customSyncedProperties );
380
+
381
+ expect( map.get( 'categories' ) ).toEqual( [ 1, 2, 3 ] );
382
+ expect( map.get( 'genre' ) ).toEqual( [ 10, 20 ] );
383
+ expect( map.get( 'tags' ) ).toEqual( [ 4, 5 ] );
384
+ } );
347
385
  } );
348
386
 
349
387
  describe( 'getPostChangesFromCRDTDoc', () => {
350
- const mockPostType = {
351
- slug: 'post',
352
- supports: {
353
- title: true,
354
- editor: true,
355
- },
356
- } as unknown as Type;
357
-
358
388
  let map: YMapWrap< YPostRecord >;
359
389
 
360
390
  beforeEach( () => {
@@ -373,7 +403,7 @@ describe( 'crdt', () => {
373
403
  const changes = getPostChangesFromCRDTDoc(
374
404
  doc,
375
405
  editedRecord,
376
- mockPostType
406
+ defaultSyncedProperties
377
407
  );
378
408
 
379
409
  expect( changes.title ).toBe( 'CRDT Title' );
@@ -388,7 +418,7 @@ describe( 'crdt', () => {
388
418
  const changes = getPostChangesFromCRDTDoc(
389
419
  doc,
390
420
  editedRecord,
391
- mockPostType
421
+ defaultSyncedProperties
392
422
  );
393
423
 
394
424
  expect( changes ).not.toHaveProperty( 'unsyncedProp' );
@@ -405,7 +435,7 @@ describe( 'crdt', () => {
405
435
  const changes = getPostChangesFromCRDTDoc(
406
436
  doc,
407
437
  editedRecord,
408
- mockPostType
438
+ defaultSyncedProperties
409
439
  );
410
440
 
411
441
  expect( changes ).not.toHaveProperty( 'status' );
@@ -424,7 +454,7 @@ describe( 'crdt', () => {
424
454
  const changesWithEmptyDate = getPostChangesFromCRDTDoc(
425
455
  doc,
426
456
  editedRecord,
427
- mockPostType
457
+ defaultSyncedProperties
428
458
  );
429
459
 
430
460
  expect( changesWithEmptyDate ).not.toHaveProperty( 'date' );
@@ -434,7 +464,7 @@ describe( 'crdt', () => {
434
464
  const changesWithDefinedDate = getPostChangesFromCRDTDoc(
435
465
  doc,
436
466
  editedRecord,
437
- mockPostType
467
+ defaultSyncedProperties
438
468
  );
439
469
 
440
470
  expect( changesWithDefinedDate ).not.toHaveProperty( 'date' );
@@ -453,7 +483,7 @@ describe( 'crdt', () => {
453
483
  const changesWithEmptyDate = getPostChangesFromCRDTDoc(
454
484
  doc,
455
485
  editedRecord,
456
- mockPostType
486
+ defaultSyncedProperties
457
487
  );
458
488
 
459
489
  expect( changesWithEmptyDate ).not.toHaveProperty( 'date' );
@@ -463,7 +493,7 @@ describe( 'crdt', () => {
463
493
  const changesWithDefinedDate = getPostChangesFromCRDTDoc(
464
494
  doc,
465
495
  editedRecord,
466
- mockPostType
496
+ defaultSyncedProperties
467
497
  );
468
498
 
469
499
  expect( changesWithDefinedDate ).not.toHaveProperty( 'date' );
@@ -479,7 +509,7 @@ describe( 'crdt', () => {
479
509
  const changes = getPostChangesFromCRDTDoc(
480
510
  doc,
481
511
  editedRecord,
482
- mockPostType
512
+ defaultSyncedProperties
483
513
  );
484
514
 
485
515
  expect( changes ).toHaveProperty( 'blocks' );
@@ -501,7 +531,7 @@ describe( 'crdt', () => {
501
531
  const changes = getPostChangesFromCRDTDoc(
502
532
  doc,
503
533
  editedRecord,
504
- mockPostType
534
+ defaultSyncedProperties
505
535
  );
506
536
 
507
537
  expect( changes ).toHaveProperty( 'blocks' );
@@ -518,7 +548,7 @@ describe( 'crdt', () => {
518
548
  const changes = getPostChangesFromCRDTDoc(
519
549
  doc,
520
550
  editedRecord,
521
- mockPostType
551
+ defaultSyncedProperties
522
552
  );
523
553
 
524
554
  expect( changes.content ).toBe( 'New content' );
@@ -534,7 +564,7 @@ describe( 'crdt', () => {
534
564
  const changes = getPostChangesFromCRDTDoc(
535
565
  doc,
536
566
  editedRecord,
537
- mockPostType
567
+ defaultSyncedProperties
538
568
  );
539
569
 
540
570
  expect( changes.content ).toBe( 'New content' );
@@ -550,7 +580,7 @@ describe( 'crdt', () => {
550
580
  const changes = getPostChangesFromCRDTDoc(
551
581
  doc,
552
582
  editedRecord,
553
- mockPostType
583
+ defaultSyncedProperties
554
584
  );
555
585
 
556
586
  expect( changes ).not.toHaveProperty( 'content' );
@@ -570,7 +600,7 @@ describe( 'crdt', () => {
570
600
  const changes = getPostChangesFromCRDTDoc(
571
601
  doc,
572
602
  editedRecord,
573
- mockPostType
603
+ defaultSyncedProperties
574
604
  );
575
605
 
576
606
  expect( changes.meta ).toEqual( {
@@ -592,7 +622,7 @@ describe( 'crdt', () => {
592
622
  const changes = getPostChangesFromCRDTDoc(
593
623
  doc,
594
624
  editedRecord,
595
- mockPostType
625
+ defaultSyncedProperties
596
626
  );
597
627
 
598
628
  expect( changes.meta ).toEqual( {
@@ -615,7 +645,7 @@ describe( 'crdt', () => {
615
645
  const changes = getPostChangesFromCRDTDoc(
616
646
  doc,
617
647
  editedRecord,
618
- mockPostType
648
+ defaultSyncedProperties
619
649
  );
620
650
 
621
651
  expect( changes.meta ).toEqual( {
@@ -626,6 +656,43 @@ describe( 'crdt', () => {
626
656
  );
627
657
  } );
628
658
 
659
+ it( 'returns taxonomy rest_base changes when in syncedProperties', () => {
660
+ map.set( 'categories', [ 1, 2 ] );
661
+ map.set( 'genre', [ 10, 20 ] );
662
+ map.set( 'tags', [ 3 ] );
663
+
664
+ const editedRecord = {
665
+ categories: [ 1 ],
666
+ genre: [ 10 ], // should be ignored
667
+ tags: [],
668
+ } as unknown as Post;
669
+
670
+ const changes = getPostChangesFromCRDTDoc(
671
+ doc,
672
+ editedRecord,
673
+ defaultSyncedProperties
674
+ ) as Record< string, unknown >;
675
+
676
+ expect( changes.categories ).toEqual( [ 1, 2 ] );
677
+ expect( changes.genre ).toBeUndefined();
678
+ expect( changes.tags ).toEqual( [ 3 ] );
679
+
680
+ const customSyncedProperties = new Set( [
681
+ ...defaultSyncedProperties,
682
+ 'genre', // now included
683
+ ] );
684
+
685
+ const changes2 = getPostChangesFromCRDTDoc(
686
+ doc,
687
+ editedRecord,
688
+ customSyncedProperties
689
+ ) as Record< string, unknown >;
690
+
691
+ expect( changes2.categories ).toEqual( [ 1, 2 ] );
692
+ expect( changes2.genre ).toEqual( [ 10, 20 ] );
693
+ expect( changes2.tags ).toEqual( [ 3 ] );
694
+ } );
695
+
629
696
  describe( 'selection recalculation', () => {
630
697
  it( 'includes recalculated selection when text is inserted before cursor', () => {
631
698
  const ytext = addBlockToDoc( map, 'block-1', 'Hello world' );
@@ -656,7 +723,7 @@ describe( 'crdt', () => {
656
723
  const changes = getPostChangesFromCRDTDoc(
657
724
  doc,
658
725
  editedRecord,
659
- mockPostType
726
+ defaultSyncedProperties
660
727
  );
661
728
 
662
729
  expect( changes.selection ).toBeDefined();
@@ -699,7 +766,7 @@ describe( 'crdt', () => {
699
766
  const changes = getPostChangesFromCRDTDoc(
700
767
  doc,
701
768
  editedRecord,
702
- mockPostType
769
+ defaultSyncedProperties
703
770
  );
704
771
 
705
772
  expect( changes.selection ).toBeDefined();
@@ -718,7 +785,7 @@ describe( 'crdt', () => {
718
785
  const changes = getPostChangesFromCRDTDoc(
719
786
  doc,
720
787
  editedRecord,
721
- mockPostType
788
+ defaultSyncedProperties
722
789
  );
723
790
 
724
791
  expect( changes.selection ).toBeUndefined();