@wordpress/core-data 7.40.0 → 7.40.1-next.v.202602191100.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.
@@ -1 +1 @@
1
- {"version":3,"file":"private-selectors.d.ts","sourceRoot":"","sources":["../src/private-selectors.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAGN,KAAK,KAAK,EACV,KAAK,IAAI,EACT,MAAM,aAAa,CAAC;AAMrB,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAE,KAAK,EAAE,KAAK,6FAO3C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,KAAK,GACV,eAAe,GAAG,SAAS,CAE7B;AAED,eAAO,MAAM,2BAA2B;;;;CAcvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;CAwBvC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM;;;EAIV;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAEpE;AAqBD,eAAO,MAAM,WAAW;;;;;;;CAuCvB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;CAQxB,CAAC;AAEJ,eAAO,MAAM,aAAa;;;;CAmFzB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,KAAK,GACV,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,GAAG,IAAI,CAE9B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,KAAK,EAAE,KAAK,GAAI,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,GAAG,IA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AAEK,kEAEE;;;CAA2B,mBAUlC;AAEK,wEAEE;;;CAA2B,mBAUlC;AAKK,yDAEE;;;CAA2B,mBA6BlC;;IAEF,gDAOC;;AAEM,qCAEE;;CAAY,mBAGnB;AAEK,8CAEE;;CAAY,mBAKnB;AAEK,6CAEE;;;CAA2B,mBAsBlC;AAEK,4CAEE;;;;CAA8B,mBAwCrC;AAEK,mDAEE;;;;CAAqC,mBA6B5C;;IAEF,gDAMC;;AAYM,mCAPI,MAAM,QACN,MAAM,aACN,MAAM,GAAC,MAAM,UACb,MAAO,SAAS,IAMlB;;;;CAAqC,mBAkG5C;;IAGF,sFAK8B;;AAavB,kCARI,MAAM,QACN,MAAM,aACN,MAAM,GAAC,MAAM,eACb,MAAM,GAAC,MAAM,SACb,MAAO,SAAS,IAMlB;;;CAA2B,mBAyClC;AAOK,gDAFI,MAAM,IAIR;;;CAA2B,mBAsBlC;AAOK,wCAFI,MAAM,IAIR;;CAAY,mBAmBnB;AAKK,sCAEE;;CAAY,mBAKnB;AAKK,oCAEE;;CAAY,mBAKnB;AAKK,6BAEE;;CAAY,mBAKnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/core-data",
3
- "version": "7.40.0",
3
+ "version": "7.40.1-next.v.202602191100.0+2f8ac7442",
4
4
  "description": "Access to and manipulation of core WordPress entities.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -49,22 +49,22 @@
49
49
  "build-module/index.mjs"
50
50
  ],
51
51
  "dependencies": {
52
- "@wordpress/api-fetch": "^7.40.0",
53
- "@wordpress/block-editor": "^15.13.0",
54
- "@wordpress/blocks": "^15.13.0",
55
- "@wordpress/compose": "^7.40.0",
56
- "@wordpress/data": "^10.40.0",
57
- "@wordpress/deprecated": "^4.40.0",
58
- "@wordpress/element": "^6.40.0",
59
- "@wordpress/html-entities": "^4.40.0",
60
- "@wordpress/i18n": "^6.13.0",
61
- "@wordpress/is-shallow-equal": "^5.40.0",
62
- "@wordpress/private-apis": "^1.40.0",
63
- "@wordpress/rich-text": "^7.40.0",
64
- "@wordpress/sync": "^1.40.0",
65
- "@wordpress/undo-manager": "^1.40.0",
66
- "@wordpress/url": "^4.40.0",
67
- "@wordpress/warning": "^3.40.0",
52
+ "@wordpress/api-fetch": "^7.40.1-next.v.202602191100.0+2f8ac7442",
53
+ "@wordpress/block-editor": "^15.13.1-next.v.202602191100.0+2f8ac7442",
54
+ "@wordpress/blocks": "^15.13.1-next.v.202602191100.0+2f8ac7442",
55
+ "@wordpress/compose": "^7.40.1-next.v.202602191100.0+2f8ac7442",
56
+ "@wordpress/data": "^10.40.1-next.v.202602191100.0+2f8ac7442",
57
+ "@wordpress/deprecated": "^4.40.1-next.v.202602191100.0+2f8ac7442",
58
+ "@wordpress/element": "^6.40.1-next.v.202602191100.0+2f8ac7442",
59
+ "@wordpress/html-entities": "^4.40.1-next.v.202602191100.0+2f8ac7442",
60
+ "@wordpress/i18n": "^6.13.1-next.v.202602191100.0+2f8ac7442",
61
+ "@wordpress/is-shallow-equal": "^5.40.1-next.v.202602191100.0+2f8ac7442",
62
+ "@wordpress/private-apis": "^1.40.1-next.v.202602191100.0+2f8ac7442",
63
+ "@wordpress/rich-text": "^7.40.1-next.v.202602191100.0+2f8ac7442",
64
+ "@wordpress/sync": "^1.40.1-next.v.202602191100.0+2f8ac7442",
65
+ "@wordpress/undo-manager": "^1.40.1-next.v.202602191100.0+2f8ac7442",
66
+ "@wordpress/url": "^4.40.1-next.v.202602191100.0+2f8ac7442",
67
+ "@wordpress/warning": "^3.40.1-next.v.202602191100.0+2f8ac7442",
68
68
  "change-case": "^4.1.2",
69
69
  "equivalent-key-map": "^0.2.2",
70
70
  "fast-deep-equal": "^3.1.3",
@@ -84,5 +84,5 @@
84
84
  "publishConfig": {
85
85
  "access": "public"
86
86
  },
87
- "gitHead": "376124aa10dbc2cc0c81c964ec00b99fcfee5382"
87
+ "gitHead": "de48b2351a7efb8a33a83067612960a0cf239592"
88
88
  }
package/src/actions.js CHANGED
@@ -340,13 +340,11 @@ export const deleteEntityRecord =
340
340
 
341
341
  await dispatch( removeItems( kind, name, recordId, true ) );
342
342
 
343
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
344
- if ( entityConfig.syncConfig ) {
345
- const objectType = `${ kind }/${ name }`;
346
- const objectId = recordId;
343
+ if ( entityConfig.syncConfig ) {
344
+ const objectType = `${ kind }/${ name }`;
345
+ const objectId = recordId;
347
346
 
348
- getSyncManager()?.unload( objectType, objectId );
349
- }
347
+ getSyncManager()?.unload( objectType, objectId );
350
348
  }
351
349
  } catch ( _error ) {
352
350
  hasError = true;
@@ -427,35 +425,33 @@ export const editEntityRecord =
427
425
  return acc;
428
426
  }, {} ),
429
427
  };
430
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
431
- if ( entityConfig.syncConfig ) {
432
- const objectType = `${ kind }/${ name }`;
433
- const objectId = recordId;
434
-
435
- // Determine whether this edit should create a new undo level.
436
- //
437
- // In Gutenberg, block changes flow through two callbacks:
438
- // - `onInput`: For transient/in-progress changes (e.g., typing each
439
- // character). These use `isCached: true` and get merged into
440
- // the current undo item.
441
- // - `onChange`: For persistent/completed changes (e.g., formatting
442
- // transforms, block insertions). These use `isCached: false` and
443
- // should create a new undo level.
444
- //
445
- // Additionally, `undoIgnore: true` means the change should not
446
- // affect the undo history at all (e.g., selection-only changes).
447
- const isNewUndoLevel = options.undoIgnore
448
- ? false
449
- : ! options.isCached;
450
-
451
- getSyncManager()?.update(
452
- objectType,
453
- objectId,
454
- editsWithMerges,
455
- LOCAL_EDITOR_ORIGIN,
456
- { isNewUndoLevel }
457
- );
458
- }
428
+ if ( entityConfig.syncConfig ) {
429
+ const objectType = `${ kind }/${ name }`;
430
+ const objectId = recordId;
431
+
432
+ // Determine whether this edit should create a new undo level.
433
+ //
434
+ // In Gutenberg, block changes flow through two callbacks:
435
+ // - `onInput`: For transient/in-progress changes (e.g., typing each
436
+ // character). These use `isCached: true` and get merged into
437
+ // the current undo item.
438
+ // - `onChange`: For persistent/completed changes (e.g., formatting
439
+ // transforms, block insertions). These use `isCached: false` and
440
+ // should create a new undo level.
441
+ //
442
+ // Additionally, `undoIgnore: true` means the change should not
443
+ // affect the undo history at all (e.g., selection-only changes).
444
+ const isNewUndoLevel = options.undoIgnore
445
+ ? false
446
+ : ! options.isCached;
447
+
448
+ getSyncManager()?.update(
449
+ objectType,
450
+ objectId,
451
+ editsWithMerges,
452
+ LOCAL_EDITOR_ORIGIN,
453
+ { isNewUndoLevel }
454
+ );
459
455
  }
460
456
  if ( ! options.undoIgnore ) {
461
457
  select.getUndoManager().addRecord(
@@ -796,16 +792,14 @@ export const saveEntityRecord =
796
792
  true,
797
793
  edits
798
794
  );
799
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
800
- if ( entityConfig.syncConfig ) {
801
- getSyncManager()?.update(
802
- `${ kind }/${ name }`,
803
- recordId,
804
- updatedRecord,
805
- LOCAL_EDITOR_ORIGIN,
806
- { isSave: true }
807
- );
808
- }
795
+ if ( entityConfig.syncConfig ) {
796
+ getSyncManager()?.update(
797
+ `${ kind }/${ name }`,
798
+ recordId,
799
+ updatedRecord,
800
+ LOCAL_EDITOR_ORIGIN,
801
+ { isSave: true }
802
+ );
809
803
  }
810
804
  }
811
805
  } catch ( _error ) {
package/src/entities.js CHANGED
@@ -229,10 +229,8 @@ export const rootEntitiesConfig = [
229
229
  ].map( ( entity ) => {
230
230
  const syncEnabledRootEntities = new Set( [ 'comment' ] );
231
231
 
232
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
233
- if ( syncEnabledRootEntities.has( entity.name ) ) {
234
- entity.syncConfig = defaultSyncConfig;
235
- }
232
+ if ( syncEnabledRootEntities.has( entity.name ) ) {
233
+ entity.syncConfig = defaultSyncConfig;
236
234
  }
237
235
  return entity;
238
236
  } );
@@ -295,16 +293,14 @@ export const prePersistPostType = (
295
293
  }
296
294
 
297
295
  // Add meta for persisted CRDT document.
298
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
299
- if ( persistedRecord ) {
300
- const objectType = `postType/${ name }`;
301
- const objectId = persistedRecord.id;
302
- const meta = getSyncManager()?.createMeta( objectType, objectId );
303
- newEdits.meta = {
304
- ...edits.meta,
305
- ...meta,
306
- };
307
- }
296
+ if ( persistedRecord ) {
297
+ const objectType = `postType/${ name }`;
298
+ const objectId = persistedRecord.id;
299
+ const meta = getSyncManager()?.createMeta( objectType, objectId );
300
+ newEdits.meta = {
301
+ ...edits.meta,
302
+ ...meta,
303
+ };
308
304
  }
309
305
 
310
306
  return newEdits;
@@ -359,60 +355,54 @@ async function loadPostTypeEntities() {
359
355
  : DEFAULT_ENTITY_KEY,
360
356
  };
361
357
 
362
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
358
+ /**
359
+ * @type {import('@wordpress/sync').SyncConfig}
360
+ */
361
+ entity.syncConfig = {
363
362
  /**
364
- * @type {import('@wordpress/sync').SyncConfig}
363
+ * Apply changes from the local editor to the local CRDT document so
364
+ * that those changes can be synced to other peers (via the provider).
365
+ *
366
+ * @param {import('@wordpress/sync').CRDTDoc} crdtDoc
367
+ * @param {Partial< import('@wordpress/sync').ObjectData >} changes
368
+ * @return {void}
365
369
  */
366
- entity.syncConfig = {
367
- /**
368
- * Apply changes from the local editor to the local CRDT document so
369
- * that those changes can be synced to other peers (via the provider).
370
- *
371
- * @param {import('@wordpress/sync').CRDTDoc} crdtDoc
372
- * @param {Partial< import('@wordpress/sync').ObjectData >} changes
373
- * @return {void}
374
- */
375
- applyChangesToCRDTDoc: ( crdtDoc, changes ) =>
376
- applyPostChangesToCRDTDoc( crdtDoc, changes, postType ),
370
+ applyChangesToCRDTDoc: ( crdtDoc, changes ) =>
371
+ applyPostChangesToCRDTDoc( crdtDoc, changes, postType ),
377
372
 
378
- /**
379
- * Create the awareness instance for the entity's CRDT document.
380
- *
381
- * @param {import('@wordpress/sync').CRDTDoc} ydoc
382
- * @param {import('@wordpress/sync').ObjectID} objectId
383
- * @return {import('@wordpress/sync').Awareness} Awareness instance
384
- */
385
- createAwareness: ( ydoc, objectId ) => {
386
- const kind = 'postType';
387
- const id = parseInt( objectId, 10 );
388
- return new PostEditorAwareness( ydoc, kind, name, id );
389
- },
373
+ /**
374
+ * Create the awareness instance for the entity's CRDT document.
375
+ *
376
+ * @param {import('@wordpress/sync').CRDTDoc} ydoc
377
+ * @param {import('@wordpress/sync').ObjectID} objectId
378
+ * @return {import('@wordpress/sync').Awareness} Awareness instance
379
+ */
380
+ createAwareness: ( ydoc, objectId ) => {
381
+ const kind = 'postType';
382
+ const id = parseInt( objectId, 10 );
383
+ return new PostEditorAwareness( ydoc, kind, name, id );
384
+ },
390
385
 
391
- /**
392
- * Extract changes from a CRDT document that can be used to update the
393
- * local editor state.
394
- *
395
- * @param {import('@wordpress/sync').CRDTDoc} crdtDoc
396
- * @param {import('@wordpress/sync').ObjectData} editedRecord
397
- * @return {Partial< import('@wordpress/sync').ObjectData >} Changes to record
398
- */
399
- getChangesFromCRDTDoc: ( crdtDoc, editedRecord ) =>
400
- getPostChangesFromCRDTDoc(
401
- crdtDoc,
402
- editedRecord,
403
- postType
404
- ),
386
+ /**
387
+ * Extract changes from a CRDT document that can be used to update the
388
+ * local editor state.
389
+ *
390
+ * @param {import('@wordpress/sync').CRDTDoc} crdtDoc
391
+ * @param {import('@wordpress/sync').ObjectData} editedRecord
392
+ * @return {Partial< import('@wordpress/sync').ObjectData >} Changes to record
393
+ */
394
+ getChangesFromCRDTDoc: ( crdtDoc, editedRecord ) =>
395
+ getPostChangesFromCRDTDoc( crdtDoc, editedRecord, postType ),
405
396
 
406
- /**
407
- * Sync features supported by the entity.
408
- *
409
- * @type {Record< string, boolean >}
410
- */
411
- supports: {
412
- crdtPersistence: true,
413
- },
414
- };
415
- }
397
+ /**
398
+ * Sync features supported by the entity.
399
+ *
400
+ * @type {Record< string, boolean >}
401
+ */
402
+ supports: {
403
+ crdtPersistence: true,
404
+ },
405
+ };
416
406
 
417
407
  return entity;
418
408
  } );
@@ -439,9 +429,7 @@ async function loadTaxonomyEntities() {
439
429
  supportsPagination: true,
440
430
  };
441
431
 
442
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
443
- entity.syncConfig = defaultSyncConfig;
444
- }
432
+ entity.syncConfig = defaultSyncConfig;
445
433
 
446
434
  return entity;
447
435
  } );
@@ -40,12 +40,8 @@ type EntityRecordKey = string | number;
40
40
  * @return The undo manager.
41
41
  */
42
42
  export function getUndoManager( state: State ) {
43
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
44
- // undoManager is undefined until the first sync-enabled entity is loaded.
45
- return getSyncManager()?.undoManager ?? state.undoManager;
46
- }
47
-
48
- return state.undoManager;
43
+ // undoManager is undefined until the first sync-enabled entity is loaded.
44
+ return getSyncManager()?.undoManager ?? state.undoManager;
49
45
  }
50
46
 
51
47
  /**
package/src/resolvers.js CHANGED
@@ -156,126 +156,112 @@ export const getEntityRecord =
156
156
  }
157
157
 
158
158
  // Entity supports syncing.
159
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
160
- if (
161
- entityConfig.syncConfig &&
162
- isNumericID( key ) &&
163
- ! query
164
- ) {
165
- const objectType = `${ kind }/${ name }`;
166
- const objectId = key;
167
-
168
- // Use the new transient "read/write" config to compute transients for
169
- // the sync manager. Otherwise these transients are not available
170
- // if / until the record is edited. Use a copy of the record so that
171
- // it does not change the behavior outside this experimental flag.
172
- const recordWithTransients = { ...record };
173
- Object.entries( entityConfig.transientEdits ?? {} )
174
- .filter(
175
- ( [ propName, transientConfig ] ) =>
176
- undefined ===
177
- recordWithTransients[ propName ] &&
178
- transientConfig &&
179
- 'object' === typeof transientConfig &&
180
- 'read' in transientConfig &&
181
- 'function' === typeof transientConfig.read
182
- )
183
- .forEach( ( [ propName, transientConfig ] ) => {
184
- recordWithTransients[ propName ] =
185
- transientConfig.read( recordWithTransients );
186
- } );
187
-
188
- // Load the entity record for syncing. Do not await promise.
189
- void getSyncManager()?.load(
190
- entityConfig.syncConfig,
191
- objectType,
192
- objectId,
193
- recordWithTransients,
194
- {
195
- // Handle edits sourced from the sync manager.
196
- editRecord: ( edits, options = {} ) => {
197
- if ( ! Object.keys( edits ).length ) {
198
- return;
199
- }
200
-
201
- dispatch( {
202
- type: 'EDIT_ENTITY_RECORD',
203
- kind,
204
- name,
205
- recordId: key,
206
- edits,
207
- meta: {
208
- undo: undefined,
209
- },
210
- options,
211
- } );
212
- },
213
- // Get the current entity record (with edits)
214
- getEditedRecord: async () =>
215
- await resolveSelect.getEditedEntityRecord(
216
- kind,
217
- name,
218
- key
219
- ),
220
- // Handle sync connection status changes.
221
- onStatusChange: ( status ) => {
222
- dispatch.setSyncConnectionStatus(
223
- kind,
224
- name,
225
- key,
226
- status
227
- );
228
- },
229
- // Refetch the current entity record from the database.
230
- refetchRecord: async () => {
231
- dispatch.receiveEntityRecords(
232
- kind,
233
- name,
234
- await apiFetch( { path, parse: true } ),
235
- query
236
- );
237
- },
238
- // Save the current entity record's unsaved edits.
239
- saveRecord: () => {
240
- dispatch.saveEditedEntityRecord(
241
- kind,
242
- name,
243
- key
159
+ if ( entityConfig.syncConfig && isNumericID( key ) && ! query ) {
160
+ const objectType = `${ kind }/${ name }`;
161
+ const objectId = key;
162
+
163
+ // Use the new transient "read/write" config to compute transients for
164
+ // the sync manager. Otherwise these transients are not available
165
+ // if / until the record is edited. Use a copy of the record so that
166
+ // it does not change the behavior outside this experimental flag.
167
+ const recordWithTransients = { ...record };
168
+ Object.entries( entityConfig.transientEdits ?? {} )
169
+ .filter(
170
+ ( [ propName, transientConfig ] ) =>
171
+ undefined === recordWithTransients[ propName ] &&
172
+ transientConfig &&
173
+ 'object' === typeof transientConfig &&
174
+ 'read' in transientConfig &&
175
+ 'function' === typeof transientConfig.read
176
+ )
177
+ .forEach( ( [ propName, transientConfig ] ) => {
178
+ recordWithTransients[ propName ] =
179
+ transientConfig.read( recordWithTransients );
180
+ } );
181
+
182
+ // Load the entity record for syncing. Do not await promise.
183
+ void getSyncManager()?.load(
184
+ entityConfig.syncConfig,
185
+ objectType,
186
+ objectId,
187
+ recordWithTransients,
188
+ {
189
+ // Handle edits sourced from the sync manager.
190
+ editRecord: ( edits, options = {} ) => {
191
+ if ( ! Object.keys( edits ).length ) {
192
+ return;
193
+ }
194
+
195
+ dispatch( {
196
+ type: 'EDIT_ENTITY_RECORD',
197
+ kind,
198
+ name,
199
+ recordId: key,
200
+ edits,
201
+ meta: {
202
+ undo: undefined,
203
+ },
204
+ options,
205
+ } );
206
+ },
207
+ // Get the current entity record (with edits)
208
+ getEditedRecord: async () =>
209
+ await resolveSelect.getEditedEntityRecord(
210
+ kind,
211
+ name,
212
+ key
213
+ ),
214
+ // Handle sync connection status changes.
215
+ onStatusChange: ( status ) => {
216
+ dispatch.setSyncConnectionStatus(
217
+ kind,
218
+ name,
219
+ key,
220
+ status
221
+ );
222
+ },
223
+ // Refetch the current entity record from the database.
224
+ refetchRecord: async () => {
225
+ dispatch.receiveEntityRecords(
226
+ kind,
227
+ name,
228
+ await apiFetch( { path, parse: true } ),
229
+ query
230
+ );
231
+ },
232
+ // Save the current entity record's unsaved edits.
233
+ saveRecord: () => {
234
+ dispatch.saveEditedEntityRecord( kind, name, key );
235
+ },
236
+ addUndoMeta: ( ydoc, meta ) => {
237
+ const selectionHistory =
238
+ getSelectionHistory( ydoc );
239
+
240
+ if ( selectionHistory ) {
241
+ meta.set(
242
+ 'selectionHistory',
243
+ selectionHistory
244
244
  );
245
- },
246
- addUndoMeta: ( ydoc, meta ) => {
247
- const selectionHistory =
248
- getSelectionHistory( ydoc );
249
-
250
- if ( selectionHistory ) {
251
- meta.set(
252
- 'selectionHistory',
253
- selectionHistory
254
- );
255
- }
256
- },
257
- restoreUndoMeta: ( ydoc, meta ) => {
258
- const selectionHistory =
259
- meta.get( 'selectionHistory' );
260
-
261
- if ( selectionHistory ) {
262
- // Because Yjs initiates an undo, we need to
263
- // wait until the content is restored before
264
- // we can update the selection.
265
- // Use setTimeout() to wait until content is
266
- // finished updating, and then set the correct
267
- // selection.
268
- setTimeout( () => {
269
- restoreSelection(
270
- selectionHistory,
271
- ydoc
272
- );
273
- }, 0 );
274
- }
275
- },
276
- }
277
- );
278
- }
245
+ }
246
+ },
247
+ restoreUndoMeta: ( ydoc, meta ) => {
248
+ const selectionHistory =
249
+ meta.get( 'selectionHistory' );
250
+
251
+ if ( selectionHistory ) {
252
+ // Because Yjs initiates an undo, we need to
253
+ // wait until the content is restored before
254
+ // we can update the selection.
255
+ // Use setTimeout() to wait until content is
256
+ // finished updating, and then set the correct
257
+ // selection.
258
+ setTimeout( () => {
259
+ restoreSelection( selectionHistory, ydoc );
260
+ }, 0 );
261
+ }
262
+ },
263
+ }
264
+ );
279
265
  }
280
266
 
281
267
  registry.batch( () => {
@@ -471,32 +457,30 @@ export const getEntityRecords =
471
457
  };
472
458
  }
473
459
 
474
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
475
- if ( entityConfig.syncConfig && -1 === query.per_page ) {
476
- const objectType = `${ kind }/${ name }`;
477
- getSyncManager()?.loadCollection(
478
- entityConfig.syncConfig,
479
- objectType,
480
- {
481
- onStatusChange: ( status ) => {
482
- dispatch.setSyncConnectionStatus(
483
- kind,
484
- name,
485
- null,
486
- status
487
- );
488
- },
489
- refetchRecords: async () => {
490
- dispatch.receiveEntityRecords(
491
- kind,
492
- name,
493
- await apiFetch( { path, parse: true } ),
494
- query
495
- );
496
- },
497
- }
498
- );
499
- }
460
+ if ( entityConfig.syncConfig && -1 === query.per_page ) {
461
+ const objectType = `${ kind }/${ name }`;
462
+ getSyncManager()?.loadCollection(
463
+ entityConfig.syncConfig,
464
+ objectType,
465
+ {
466
+ onStatusChange: ( status ) => {
467
+ dispatch.setSyncConnectionStatus(
468
+ kind,
469
+ name,
470
+ null,
471
+ status
472
+ );
473
+ },
474
+ refetchRecords: async () => {
475
+ dispatch.receiveEntityRecords(
476
+ kind,
477
+ name,
478
+ await apiFetch( { path, parse: true } ),
479
+ query
480
+ );
481
+ },
482
+ }
483
+ );
500
484
  }
501
485
 
502
486
  // If we request fields but the result doesn't contain the fields,
@@ -128,7 +128,7 @@ describe( 'getEntityRecord', () => {
128
128
  );
129
129
  } );
130
130
 
131
- it( 'loads entity with sync manager when IS_GUTENBERG_PLUGIN is true', async () => {
131
+ it( 'loads entity with sync manager', async () => {
132
132
  const POST_RECORD = { id: 1, title: 'Test Post' };
133
133
  const POST_RESPONSE = {
134
134
  json: () => Promise.resolve( POST_RECORD ),