@wordpress/core-data 7.38.0 → 7.39.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 (109) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/actions.cjs +17 -6
  3. package/build/actions.cjs.map +2 -2
  4. package/build/awareness/base-awareness.cjs +62 -0
  5. package/build/awareness/base-awareness.cjs.map +7 -0
  6. package/build/awareness/config.cjs +34 -0
  7. package/build/awareness/config.cjs.map +7 -0
  8. package/build/awareness/post-editor-awareness.cjs +130 -0
  9. package/build/awareness/post-editor-awareness.cjs.map +7 -0
  10. package/build/awareness/types.cjs +19 -0
  11. package/build/awareness/types.cjs.map +7 -0
  12. package/build/awareness/utils.cjs +116 -0
  13. package/build/awareness/utils.cjs.map +7 -0
  14. package/build/entities.cjs +27 -2
  15. package/build/entities.cjs.map +2 -2
  16. package/build/resolvers.cjs +43 -2
  17. package/build/resolvers.cjs.map +2 -2
  18. package/build/types.cjs.map +1 -1
  19. package/build/utils/block-selection-history.cjs +101 -0
  20. package/build/utils/block-selection-history.cjs.map +7 -0
  21. package/build/utils/crdt-selection.cjs +139 -0
  22. package/build/utils/crdt-selection.cjs.map +7 -0
  23. package/build/utils/crdt-user-selections.cjs +171 -0
  24. package/build/utils/crdt-user-selections.cjs.map +7 -0
  25. package/build/utils/crdt-utils.cjs +29 -0
  26. package/build/utils/crdt-utils.cjs.map +3 -3
  27. package/build/utils/crdt.cjs +16 -4
  28. package/build/utils/crdt.cjs.map +2 -2
  29. package/build-module/actions.mjs +17 -6
  30. package/build-module/actions.mjs.map +2 -2
  31. package/build-module/awareness/base-awareness.mjs +35 -0
  32. package/build-module/awareness/base-awareness.mjs.map +7 -0
  33. package/build-module/awareness/config.mjs +8 -0
  34. package/build-module/awareness/config.mjs.map +7 -0
  35. package/build-module/awareness/post-editor-awareness.mjs +111 -0
  36. package/build-module/awareness/post-editor-awareness.mjs.map +7 -0
  37. package/build-module/awareness/types.mjs +1 -0
  38. package/build-module/awareness/types.mjs.map +7 -0
  39. package/build-module/awareness/utils.mjs +90 -0
  40. package/build-module/awareness/utils.mjs.map +7 -0
  41. package/build-module/entities.mjs +28 -2
  42. package/build-module/entities.mjs.map +2 -2
  43. package/build-module/resolvers.mjs +43 -2
  44. package/build-module/resolvers.mjs.map +2 -2
  45. package/build-module/utils/block-selection-history.mjs +75 -0
  46. package/build-module/utils/block-selection-history.mjs.map +7 -0
  47. package/build-module/utils/crdt-selection.mjs +115 -0
  48. package/build-module/utils/crdt-selection.mjs.map +7 -0
  49. package/build-module/utils/crdt-user-selections.mjs +144 -0
  50. package/build-module/utils/crdt-user-selections.mjs.map +7 -0
  51. package/build-module/utils/crdt-utils.mjs +28 -0
  52. package/build-module/utils/crdt-utils.mjs.map +2 -2
  53. package/build-module/utils/crdt.mjs +18 -3
  54. package/build-module/utils/crdt.mjs.map +2 -2
  55. package/build-types/actions.d.ts.map +1 -1
  56. package/build-types/awareness/base-awareness.d.ts +19 -0
  57. package/build-types/awareness/base-awareness.d.ts.map +1 -0
  58. package/build-types/awareness/config.d.ts +9 -0
  59. package/build-types/awareness/config.d.ts.map +1 -0
  60. package/build-types/awareness/post-editor-awareness.d.ts +38 -0
  61. package/build-types/awareness/post-editor-awareness.d.ts.map +1 -0
  62. package/build-types/awareness/types.d.ts +32 -0
  63. package/build-types/awareness/types.d.ts.map +1 -0
  64. package/build-types/awareness/utils.d.ts +22 -0
  65. package/build-types/awareness/utils.d.ts.map +1 -0
  66. package/build-types/entities.d.ts.map +1 -1
  67. package/build-types/entity-types/test/attachment.test.d.ts +10 -0
  68. package/build-types/entity-types/test/attachment.test.d.ts.map +1 -0
  69. package/build-types/index.d.ts.map +1 -1
  70. package/build-types/resolvers.d.ts.map +1 -1
  71. package/build-types/types.d.ts +12 -2
  72. package/build-types/types.d.ts.map +1 -1
  73. package/build-types/utils/block-selection-history.d.ts +47 -0
  74. package/build-types/utils/block-selection-history.d.ts.map +1 -0
  75. package/build-types/utils/crdt-selection.d.ts +16 -0
  76. package/build-types/utils/crdt-selection.d.ts.map +1 -0
  77. package/build-types/utils/crdt-user-selections.d.ts +66 -0
  78. package/build-types/utils/crdt-user-selections.d.ts.map +1 -0
  79. package/build-types/utils/crdt-utils.d.ts +12 -0
  80. package/build-types/utils/crdt-utils.d.ts.map +1 -1
  81. package/build-types/utils/crdt.d.ts +8 -14
  82. package/build-types/utils/crdt.d.ts.map +1 -1
  83. package/build-types/utils/test/block-selection-history.test.d.ts +2 -0
  84. package/build-types/utils/test/block-selection-history.test.d.ts.map +1 -0
  85. package/build-types/utils/test/crdt-blocks.d.ts +2 -0
  86. package/build-types/utils/test/crdt-blocks.d.ts.map +1 -0
  87. package/build-types/utils/test/crdt.d.ts +2 -0
  88. package/build-types/utils/test/crdt.d.ts.map +1 -0
  89. package/package.json +21 -18
  90. package/src/actions.js +40 -7
  91. package/src/awareness/base-awareness.ts +50 -0
  92. package/src/awareness/config.ts +9 -0
  93. package/src/awareness/post-editor-awareness.ts +167 -0
  94. package/src/awareness/types.ts +38 -0
  95. package/src/awareness/utils.ts +159 -0
  96. package/src/entities.js +32 -2
  97. package/src/entity-types/test/attachment.test.ts +4 -4
  98. package/src/resolvers.js +53 -1
  99. package/src/test/actions.js +402 -0
  100. package/src/test/entity-provider.js +2 -0
  101. package/src/test/resolvers.js +4 -0
  102. package/src/types.ts +12 -3
  103. package/src/utils/block-selection-history.ts +176 -0
  104. package/src/utils/crdt-selection.ts +205 -0
  105. package/src/utils/crdt-user-selections.ts +336 -0
  106. package/src/utils/crdt-utils.ts +54 -0
  107. package/src/utils/crdt.ts +36 -3
  108. package/src/utils/test/block-selection-history.test.ts +764 -0
  109. package/src/utils/test/crdt-blocks.ts +11 -4
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { SelectionState } from '../utils/crdt-user-selections';
5
+ import type { User } from '../entity-types';
6
+ export type UserInfo = Pick<User<'view'>, 'id' | 'name' | 'slug' | 'avatar_urls'> & {
7
+ browserType: string;
8
+ color: string;
9
+ enteredAt: number;
10
+ };
11
+ /**
12
+ * This base state represents the presence of the user. We expect it to be
13
+ * extended to include additional state describing the user's current activity.
14
+ * This state must be serializable and compact.
15
+ */
16
+ export interface BaseState {
17
+ userInfo: UserInfo;
18
+ }
19
+ /**
20
+ * The editor state includes information about the user's current selection.
21
+ */
22
+ export interface EditorState {
23
+ selection: SelectionState;
24
+ }
25
+ /**
26
+ * The post editor state extends the base state with information used to render
27
+ * presence indicators in the post editor.
28
+ */
29
+ export interface PostEditorState extends BaseState {
30
+ editorState?: EditorState;
31
+ }
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/awareness/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,QAAQ,GAAG,IAAI,CAC1B,IAAI,CAAE,MAAM,CAAE,EACd,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CACtC,GAAG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,cAAc,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IACjD,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { User } from '../entity-types';
5
+ import type { UserInfo } from './types';
6
+ /**
7
+ * Check if two user infos are equal.
8
+ *
9
+ * @param userInfo1 - The first user info.
10
+ * @param userInfo2 - The second user info.
11
+ * @return True if the user infos are equal, false otherwise.
12
+ */
13
+ export declare function areUserInfosEqual(userInfo1?: UserInfo, userInfo2?: UserInfo): boolean;
14
+ /**
15
+ * Generate a user info object from a current user and a list of existing colors.
16
+ *
17
+ * @param currentUser - The current user.
18
+ * @param existingColors - The existing colors.
19
+ * @return The user info object.
20
+ */
21
+ export declare function generateUserInfo(currentUser: User<'view'>, existingColors: string[]): UserInfo;
22
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/awareness/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAgHxC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,CAAC,EAAE,QAAQ,EACpB,SAAS,CAAC,EAAE,QAAQ,GAClB,OAAO,CAaT;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,WAAW,EAAE,IAAI,CAAE,MAAM,CAAE,EAC3B,cAAc,EAAE,MAAM,EAAE,GACtB,QAAQ,CAOV"}
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAqBA,iCAAkC,IAAI,CAAC;AAYvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2LE;;;;;;;;;;;;AAcF;;;;;;;;;;KASE;AAWK,2EAJI,MAAM,cACN,OAAO,OA0CjB;AA2KM,oCANI,MAAM,QACN,MAAM,WACN,MAAM,GAEL,MAAM,CAMjB;AA7KD;;;;GAIG;AACH,sDAwFC;AAyBD;;;;GAIG;AACH,gDA0BC"}
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.js"],"names":[],"mappings":"AAuBA,iCAAkC,IAAI,CAAC;AAYvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoMI;;;;;;;;;;;;AAcJ;;;;;;;;;;KASE;AAWK,2EAJI,MAAM,cACN,OAAO,OA0CjB;AA8LM,oCANI,MAAM,QACN,MAAM,WACN,MAAM,GAEL,MAAM,CAMjB;AAhMD;;;;GAIG;AACH,sDAqGC;AA+BD;;;;GAIG;AACH,gDA0BC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Tests for the Attachment type against real REST API responses.
3
+ *
4
+ * These tests validate the Attachment type definition by comparing it with
5
+ * real JSON responses from the WordPress REST API's media endpoint. The fixtures
6
+ * are from the REST API's edit context, which includes edit-only fields like
7
+ * permalink_template, generated_slug, and missing_image_sizes.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=attachment.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.test.d.ts","sourceRoot":"","sources":["../../../src/entity-types/test/attachment.test.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A6BlC;;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"}
@@ -1,10 +1,20 @@
1
1
  export interface AnyFunction {
2
2
  (...args: any[]): any;
3
3
  }
4
+ /**
5
+ * Avoid a circular dependency with @wordpress/editor
6
+ *
7
+ * Additionaly, this type marks `attributeKey` and `offset` as possibly
8
+ * `undefined`, which can happen in two known scenarios:
9
+ *
10
+ * 1. If a user has an entire block highlighted (e.g., a `core/image` block).
11
+ * 2. If there's an intermediate selection state while inserting a block, those
12
+ * properties will be temporarily`undefined`.
13
+ */
4
14
  export interface WPBlockSelection {
5
15
  clientId: string;
6
- attributeKey: string;
7
- offset: number;
16
+ attributeKey?: string;
17
+ offset?: number;
8
18
  }
9
19
  export interface WPSelection {
10
20
  selectionEnd: WPBlockSelection;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAI,GAAG,CAAC;CACxB;AAGD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,cAAc,EAAE,gBAAgB,CAAC;CACjC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAI,GAAG,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,cAAc,EAAE,gBAAgB,CAAC;CACjC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ /**
5
+ * WordPress dependencies
6
+ */
7
+ import { Y } from '@wordpress/sync';
8
+ import type { WPSelection } from '../types';
9
+ export declare enum YSelectionType {
10
+ RelativeSelection = "RelativeSelection",
11
+ BlockSelection = "BlockSelection"
12
+ }
13
+ export interface YRelativeSelection {
14
+ type: YSelectionType.RelativeSelection;
15
+ attributeKey: string;
16
+ relativePosition: Y.RelativePosition;
17
+ clientId: string;
18
+ offset: number;
19
+ }
20
+ export interface YBlockSelection {
21
+ type: YSelectionType.BlockSelection;
22
+ clientId: string;
23
+ }
24
+ export type YSelection = YRelativeSelection | YBlockSelection;
25
+ export type YFullSelection = {
26
+ start: YSelection;
27
+ end: YSelection;
28
+ };
29
+ export interface YSelectionHistory {
30
+ selection: YFullSelection;
31
+ backupSelections?: YFullSelection[];
32
+ }
33
+ export interface BlockSelectionHistory {
34
+ getSelectionHistory: () => YFullSelection[];
35
+ updateSelection: (newSelection: WPSelection) => void;
36
+ }
37
+ /**
38
+ * This function is used to track recent block selections to help in restoring
39
+ * a user's selection after an undo or redo operation.
40
+ *
41
+ * Maintains a history array for previous selections, which can be used for
42
+ * backup restoration locations.
43
+ * @param ydoc
44
+ * @param historySize
45
+ */
46
+ export declare function createBlockSelectionHistory(ydoc: Y.Doc, historySize?: number): BlockSelectionHistory;
47
+ //# sourceMappingURL=block-selection-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-selection-history.d.ts","sourceRoot":"","sources":["../../src/utils/block-selection-history.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAMpC,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,UAAU,CAAC;AAK9D,oBAAY,cAAc;IACzB,iBAAiB,sBAAsB;IACvC,cAAc,mBAAmB;CACjC;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,cAAc,CAAC,iBAAiB,CAAC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,GAAG,EAAE,UAAU,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,cAAc,CAAC;IAC1B,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,qBAAqB;IACrC,mBAAmB,EAAE,MAAM,cAAc,EAAE,CAAC;IAC5C,eAAe,EAAE,CAAE,YAAY,EAAE,WAAW,KAAM,IAAI,CAAC;CACvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAC1C,IAAI,EAAE,CAAC,CAAC,GAAG,EACX,WAAW,GAAE,MAAuC,GAClD,qBAAqB,CAgEvB"}
@@ -0,0 +1,16 @@
1
+ import { type CRDTDoc, Y } from '@wordpress/sync';
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import { type YFullSelection } from './block-selection-history';
6
+ import type { WPSelection } from '../types';
7
+ export declare function getSelectionHistory(ydoc: CRDTDoc): YFullSelection[];
8
+ export declare function updateSelectionHistory(ydoc: CRDTDoc, wpSelection: WPSelection): void;
9
+ /**
10
+ * Restore the selection to the most recent selection in history that is
11
+ * available in the document.
12
+ * @param selectionHistory The selection history to restore
13
+ * @param ydoc The Y.Doc where blocks are stored
14
+ */
15
+ export declare function restoreSelection(selectionHistory: YFullSelection[], ydoc: Y.Doc): void;
16
+ //# sourceMappingURL=crdt-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crdt-selection.d.ts","sourceRoot":"","sources":["../../src/utils/crdt-selection.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,OAAO,EAIN,KAAK,cAAc,EAEnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,UAAU,CAAC;AAsB9D,wBAAgB,mBAAmB,CAAE,IAAI,EAAE,OAAO,GAAI,cAAc,EAAE,CAErE;AAED,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,WAAW,GACtB,IAAI,CAEN;AAkFD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,gBAAgB,EAAE,cAAc,EAAE,EAClC,IAAI,EAAE,CAAC,CAAC,GAAG,GACT,IAAI,CA6DN"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { Y } from '@wordpress/sync';
5
+ import type { WPBlockSelection } from '../types';
6
+ /**
7
+ * The type of selection.
8
+ */
9
+ export declare enum SelectionType {
10
+ None = "none",
11
+ Cursor = "cursor",
12
+ SelectionInOneBlock = "selection-in-one-block",
13
+ SelectionInMultipleBlocks = "selection-in-multiple-blocks",
14
+ WholeBlock = "whole-block"
15
+ }
16
+ /**
17
+ * The position of the cursor.
18
+ */
19
+ export type CursorPosition = {
20
+ relativePosition: Y.RelativePosition;
21
+ absoluteOffset: number;
22
+ };
23
+ export type SelectionNone = {
24
+ type: SelectionType.None;
25
+ };
26
+ export type SelectionCursor = {
27
+ type: SelectionType.Cursor;
28
+ blockId: string;
29
+ cursorPosition: CursorPosition;
30
+ };
31
+ export type SelectionInOneBlock = {
32
+ type: SelectionType.SelectionInOneBlock;
33
+ blockId: string;
34
+ cursorStartPosition: CursorPosition;
35
+ cursorEndPosition: CursorPosition;
36
+ };
37
+ export type SelectionInMultipleBlocks = {
38
+ type: SelectionType.SelectionInMultipleBlocks;
39
+ blockStartId: string;
40
+ blockEndId: string;
41
+ cursorStartPosition: CursorPosition;
42
+ cursorEndPosition: CursorPosition;
43
+ };
44
+ export type SelectionWholeBlock = {
45
+ type: SelectionType.WholeBlock;
46
+ blockId: string;
47
+ };
48
+ export type SelectionState = SelectionNone | SelectionCursor | SelectionInOneBlock | SelectionInMultipleBlocks | SelectionWholeBlock;
49
+ /**
50
+ * Converts WordPress block editor selection to a SelectionState.
51
+ *
52
+ * @param selectionStart - The start position of the selection
53
+ * @param selectionEnd - The end position of the selection
54
+ * @param yDoc - The Yjs document
55
+ * @return The SelectionState
56
+ */
57
+ export declare function getSelectionState(selectionStart: WPBlockSelection, selectionEnd: WPBlockSelection, yDoc: Y.Doc): SelectionState;
58
+ /**
59
+ * Check if two selection states are equal.
60
+ *
61
+ * @param selection1 - The first selection state.
62
+ * @param selection2 - The second selection state.
63
+ * @return True if the selection states are equal, false otherwise.
64
+ */
65
+ export declare function areSelectionsStatesEqual(selection1: SelectionState, selection2: SelectionState): boolean;
66
+ //# sourceMappingURL=crdt-user-selections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crdt-user-selections.d.ts","sourceRoot":"","sources":["../../src/utils/crdt-user-selections.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAuB,MAAM,iBAAiB,CAAC;AAQzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,oBAAY,aAAa;IACxB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,mBAAmB,2BAA2B;IAC9C,yBAAyB,iCAAiC;IAC1D,UAAU,gBAAgB;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,CAAC;IAYrC,cAAc,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAE3B,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAE7B,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,cAAc,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAEjC,IAAI,EAAE,aAAa,CAAC,mBAAmB,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,cAAc,CAAC;IACpC,iBAAiB,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IAEvC,IAAI,EAAE,aAAa,CAAC,yBAAyB,CAAC;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,cAAc,CAAC;IACpC,iBAAiB,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAEjC,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,cAAc,GACvB,aAAa,GACb,eAAe,GACf,mBAAmB,GACnB,yBAAyB,GACzB,mBAAmB,CAAC;AAEvB;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,cAAc,EAAE,gBAAgB,EAChC,YAAY,EAAE,gBAAgB,EAC9B,IAAI,EAAE,CAAC,CAAC,GAAG,GACT,cAAc,CAgFhB;AAkED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,cAAc,GACxB,OAAO,CA2DT"}
@@ -2,6 +2,10 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { Y } from '@wordpress/sync';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { YBlock } from './crdt-blocks';
5
9
  /**
6
10
  * A YMapRecord represents the shape of the data stored in a Y.Map.
7
11
  */
@@ -50,4 +54,12 @@ export declare function createYMap<T extends YMapRecord>(partial?: Partial<T>):
50
54
  * @param value Value to check.
51
55
  */
52
56
  export declare function isYMap<T extends YMapRecord>(value: YMapWrap<T> | undefined): value is YMapWrap<T>;
57
+ /**
58
+ * Given a block ID and a Y.Doc, find the block in the document.
59
+ *
60
+ * @param blockId The block ID to find
61
+ * @param ydoc The Y.Doc to find the block in
62
+ * @return The block, or null if the block is not found
63
+ */
64
+ export declare function findBlockByClientIdInDoc(blockId: string, ydoc: Y.Doc): YBlock | null;
53
65
  //# sourceMappingURL=crdt-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crdt-utils.d.ts","sourceRoot":"","sources":["../../src/utils/crdt-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAE,MAAM,EAA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AG,EAAE,MAAM,GACT,QAAQ,CAAE,CAAC,CAAE,CAEf;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAE,CAAC,SAAS,UAAU,EAC/C,OAAO,GAAE,OAAO,CAAE,CAAC,CAAO,GACxB,QAAQ,CAAE,CAAC,CAAE,CAEf;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAE,CAAC,SAAS,UAAU,EAC3C,KAAK,EAAE,QAAQ,CAAE,CAAC,CAAE,GAAG,SAAS,GAC9B,KAAK,IAAI,QAAQ,CAAE,CAAC,CAAE,CAExB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,CAAC,CAAC,GAAG,GACT,MAAM,GAAG,IAAI,CASf"}
@@ -1,7 +1,5 @@
1
- import { type CRDTDoc, type ObjectData } from '@wordpress/sync';
2
- /**
3
- * Internal dependencies
4
- */
1
+ import { type CRDTDoc, type SyncConfig } from '@wordpress/sync';
2
+ import { type BaseState } from '../awareness/types';
5
3
  import { type Block, type YBlocks } from './crdt-blocks';
6
4
  import { type Post } from '../entity-types/post';
7
5
  import { type Type } from '../entity-types';
@@ -16,6 +14,7 @@ export type PostChanges = Partial<Post> & {
16
14
  export interface YPostRecord extends YMapRecord {
17
15
  author: number;
18
16
  blocks: YBlocks;
17
+ categories: number[];
19
18
  comment_status: string;
20
19
  date: string | null;
21
20
  excerpt: string;
@@ -30,15 +29,6 @@ export interface YPostRecord extends YMapRecord {
30
29
  template: string;
31
30
  title: string;
32
31
  }
33
- /**
34
- * Given a set of local changes to a generic entity record, apply those changes
35
- * to the local Y.Doc.
36
- *
37
- * @param {CRDTDoc} ydoc
38
- * @param {Partial< ObjectData >} changes
39
- * @return {void}
40
- */
41
- export declare function defaultApplyChangesToCRDTDoc(ydoc: CRDTDoc, changes: ObjectData): void;
42
32
  /**
43
33
  * Given a set of local changes to a post record, apply those changes to the
44
34
  * local Y.Doc.
@@ -49,7 +39,6 @@ export declare function defaultApplyChangesToCRDTDoc(ydoc: CRDTDoc, changes: Obj
49
39
  * @return {void}
50
40
  */
51
41
  export declare function applyPostChangesToCRDTDoc(ydoc: CRDTDoc, changes: PostChanges, _postType: Type): void;
52
- export declare function defaultGetChangesFromCRDTDoc(crdtDoc: CRDTDoc): ObjectData;
53
42
  /**
54
43
  * Given a local Y.Doc that *may* contain changes from remote peers, compare
55
44
  * against the local record and determine if there are changes (edits) we want
@@ -61,4 +50,9 @@ export declare function defaultGetChangesFromCRDTDoc(crdtDoc: CRDTDoc): ObjectDa
61
50
  * @return {Partial<PostChanges>} The changes that should be applied to the local record.
62
51
  */
63
52
  export declare function getPostChangesFromCRDTDoc(ydoc: CRDTDoc, editedRecord: Post, _postType: Type): PostChanges;
53
+ /**
54
+ * This default sync config can be used for entities that are flat maps of
55
+ * primitive values and do not require custom logic to merge changes.
56
+ */
57
+ export declare const defaultSyncConfig: SyncConfig<BaseState>;
64
58
  //# sourceMappingURL=crdt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crdt.d.ts","sourceRoot":"","sources":["../../src/utils/crdt.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAK,MAAM,iBAAiB,CAAC;AAEnE;;GAEG;AACH,OAAO,EAEN,KAAK,KAAK,EAEV,KAAK,OAAO,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAM5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAIN,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,WAAW,GAAG,OAAO,CAAE,IAAI,CAAE,GAAG;IAC3C,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,I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K,EAAE,MAAM,CAAC;CACd;AA0DD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,IAAI,GACb,IAAI,CA2HN;AAMD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,OAAO,EACb,YAAY,EAAE,IAAI,EAClB,SAAS,EAAE,IAAI,GACb,WAAW,CAwHb;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAE,SAAS,CAIpD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=block-selection-history.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-selection-history.test.d.ts","sourceRoot":"","sources":["../../../src/utils/test/block-selection-history.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=crdt-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crdt-blocks.d.ts","sourceRoot":"","sources":["../../../src/utils/test/crdt-blocks.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=crdt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crdt.d.ts","sourceRoot":"","sources":["../../../src/utils/test/crdt.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/core-data",
3
- "version": "7.38.0",
3
+ "version": "7.39.0",
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.38.0",
53
- "@wordpress/block-editor": "^15.11.0",
54
- "@wordpress/blocks": "^15.11.0",
55
- "@wordpress/compose": "^7.38.0",
56
- "@wordpress/data": "^10.38.0",
57
- "@wordpress/deprecated": "^4.38.0",
58
- "@wordpress/element": "^6.38.0",
59
- "@wordpress/html-entities": "^4.38.0",
60
- "@wordpress/i18n": "^6.11.0",
61
- "@wordpress/is-shallow-equal": "^5.38.0",
62
- "@wordpress/private-apis": "^1.38.0",
63
- "@wordpress/rich-text": "^7.38.0",
64
- "@wordpress/sync": "^1.38.0",
65
- "@wordpress/undo-manager": "^1.38.0",
66
- "@wordpress/url": "^4.38.0",
67
- "@wordpress/warning": "^3.38.0",
52
+ "@wordpress/api-fetch": "^7.39.0",
53
+ "@wordpress/block-editor": "^15.12.0",
54
+ "@wordpress/blocks": "^15.12.0",
55
+ "@wordpress/compose": "^7.39.0",
56
+ "@wordpress/data": "^10.39.0",
57
+ "@wordpress/deprecated": "^4.39.0",
58
+ "@wordpress/element": "^6.39.0",
59
+ "@wordpress/html-entities": "^4.39.0",
60
+ "@wordpress/i18n": "^6.12.0",
61
+ "@wordpress/is-shallow-equal": "^5.39.0",
62
+ "@wordpress/private-apis": "^1.39.0",
63
+ "@wordpress/rich-text": "^7.39.0",
64
+ "@wordpress/sync": "^1.39.0",
65
+ "@wordpress/undo-manager": "^1.39.0",
66
+ "@wordpress/url": "^4.39.0",
67
+ "@wordpress/warning": "^3.39.0",
68
68
  "change-case": "^4.1.2",
69
69
  "equivalent-key-map": "^0.2.2",
70
70
  "fast-deep-equal": "^3.1.3",
@@ -72,6 +72,9 @@
72
72
  "uuid": "^9.0.1"
73
73
  },
74
74
  "devDependencies": {
75
+ "@jest/globals": "^30.2.0",
76
+ "@types/jest": "^29.5.14",
77
+ "@types/node": "^20.19.0",
75
78
  "deep-freeze": "0.0.1"
76
79
  },
77
80
  "peerDependencies": {
@@ -81,5 +84,5 @@
81
84
  "publishConfig": {
82
85
  "access": "public"
83
86
  },
84
- "gitHead": "50c4c0f51e4797c217946ce42adfaa5eb026f33f"
87
+ "gitHead": "eee1cfb1472f11183e40fb77465a5f13145df7ad"
85
88
  }
package/src/actions.js CHANGED
@@ -339,6 +339,15 @@ export const deleteEntityRecord =
339
339
  } );
340
340
 
341
341
  await dispatch( removeItems( kind, name, recordId, true ) );
342
+
343
+ if ( globalThis.IS_GUTENBERG_PLUGIN ) {
344
+ if ( entityConfig.syncConfig ) {
345
+ const objectType = `${ kind }/${ name }`;
346
+ const objectId = recordId;
347
+
348
+ getSyncManager()?.unload( objectType, objectId );
349
+ }
350
+ }
342
351
  } catch ( _error ) {
343
352
  hasError = true;
344
353
  error = _error;
@@ -393,6 +402,16 @@ export const editEntityRecord =
393
402
  recordId
394
403
  );
395
404
 
405
+ // Some fields are merged with the existing value instead of replaced.
406
+ // See `mergedEdits` definition on the entity config.
407
+ const editsWithMerges = Object.keys( edits ).reduce( ( acc, key ) => {
408
+ acc[ key ] = mergedEdits[ key ]
409
+ ? { ...editedRecord[ key ], ...edits[ key ] }
410
+ : edits[ key ];
411
+
412
+ return acc;
413
+ }, {} );
414
+
396
415
  const edit = {
397
416
  kind,
398
417
  name,
@@ -401,10 +420,7 @@ export const editEntityRecord =
401
420
  // so that the property is not considered dirty.
402
421
  edits: Object.keys( edits ).reduce( ( acc, key ) => {
403
422
  const recordValue = record[ key ];
404
- const editedRecordValue = editedRecord[ key ];
405
- const value = mergedEdits[ key ]
406
- ? { ...editedRecordValue, ...edits[ key ] }
407
- : edits[ key ];
423
+ const value = editsWithMerges[ key ];
408
424
  acc[ key ] = fastDeepEqual( recordValue, value )
409
425
  ? undefined
410
426
  : value;
@@ -416,11 +432,28 @@ export const editEntityRecord =
416
432
  const objectType = `${ kind }/${ name }`;
417
433
  const objectId = recordId;
418
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
+
419
451
  getSyncManager()?.update(
420
452
  objectType,
421
453
  objectId,
422
- edit.edits,
423
- LOCAL_EDITOR_ORIGIN
454
+ editsWithMerges,
455
+ LOCAL_EDITOR_ORIGIN,
456
+ { isNewUndoLevel }
424
457
  );
425
458
  }
426
459
  }
@@ -721,7 +754,7 @@ export const saveEntityRecord =
721
754
  recordId,
722
755
  updatedRecord,
723
756
  LOCAL_EDITOR_ORIGIN,
724
- true // isSave
757
+ { isSave: true }
725
758
  );
726
759
  }
727
760
  }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { select } from '@wordpress/data';
5
+ import { AwarenessState } from '@wordpress/sync';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { STORE_NAME as coreStore } from '../name';
11
+ import { generateUserInfo, areUserInfosEqual } from './utils';
12
+
13
+ import type { BaseState } from './types';
14
+
15
+ export abstract class BaseAwarenessState<
16
+ State extends BaseState,
17
+ > extends AwarenessState< State > {
18
+ public setUp(): void {
19
+ super.setUp();
20
+
21
+ this.setCurrentUserInfo();
22
+ }
23
+
24
+ /**
25
+ * Set the current user info in the local state.
26
+ */
27
+ private setCurrentUserInfo(): void {
28
+ const states = this.getStates();
29
+ const otherUserColors = Array.from( states.entries() )
30
+ .filter(
31
+ ( [ clientId, state ] ) =>
32
+ state.userInfo && clientId !== this.clientID
33
+ )
34
+ .map( ( [ , state ] ) => state.userInfo.color )
35
+ .filter( Boolean );
36
+
37
+ // Get current user info and set it in local state.
38
+ const currentUser = select( coreStore ).getCurrentUser();
39
+ const userInfo = generateUserInfo( currentUser, otherUserColors );
40
+ this.setLocalStateField( 'userInfo', userInfo );
41
+ }
42
+ }
43
+
44
+ export const baseEqualityFieldChecks = {
45
+ userInfo: areUserInfosEqual,
46
+ };
47
+
48
+ export class BaseAwareness extends BaseAwarenessState< BaseState > {
49
+ protected equalityFieldChecks = baseEqualityFieldChecks;
50
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Delay in milliseconds before throttling the cursor position updates.
3
+ */
4
+ export const AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS = 100;
5
+
6
+ /**
7
+ * Delay in milliseconds before updating the cursor position.
8
+ */
9
+ export const LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS = 5;