@wordpress/core-data 7.51.0 → 7.53.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.
- package/CHANGELOG.md +22 -0
- package/README.md +1 -0
- package/build/actions.cjs +64 -2
- package/build/actions.cjs.map +3 -3
- package/build/awareness/awareness-state.cjs.map +2 -2
- package/build/awareness/base-awareness.cjs.map +2 -2
- package/build/awareness/block-lookup.cjs.map +2 -2
- package/build/awareness/post-editor-awareness.cjs +7 -0
- package/build/awareness/post-editor-awareness.cjs.map +2 -2
- package/build/awareness/typed-awareness.cjs.map +2 -2
- package/build/awareness/types.cjs.map +1 -1
- package/build/awareness/utils.cjs.map +2 -2
- package/build/batch/create-batch.cjs.map +2 -2
- package/build/batch/default-processor.cjs.map +2 -2
- package/build/components/entities-saved-states/entity-record-item.cjs +67 -0
- package/build/components/entities-saved-states/entity-record-item.cjs.map +7 -0
- package/build/components/entities-saved-states/entity-type-list.cjs +135 -0
- package/build/components/entities-saved-states/entity-type-list.cjs.map +7 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs +101 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.cjs.map +7 -0
- package/build/components/entities-saved-states/index.cjs +215 -0
- package/build/components/entities-saved-states/index.cjs.map +7 -0
- package/build/dynamic-entities.cjs.map +2 -2
- package/build/entities.cjs +2 -0
- package/build/entities.cjs.map +2 -2
- package/build/entity-context.cjs.map +2 -2
- package/build/entity-provider.cjs.map +2 -2
- package/build/entity-types/attachment.cjs.map +1 -1
- package/build/entity-types/base.cjs.map +1 -1
- package/build/entity-types/comment.cjs.map +1 -1
- package/build/entity-types/font-collection.cjs.map +1 -1
- package/build/entity-types/font-family.cjs.map +1 -1
- package/build/entity-types/global-styles-revision.cjs.map +1 -1
- package/build/entity-types/helpers.cjs.map +1 -1
- package/build/entity-types/icon.cjs.map +1 -1
- package/build/entity-types/index.cjs.map +1 -1
- package/build/entity-types/menu-location.cjs.map +1 -1
- package/build/entity-types/nav-menu-item.cjs.map +1 -1
- package/build/entity-types/nav-menu.cjs.map +1 -1
- package/build/entity-types/page.cjs.map +1 -1
- package/build/entity-types/plugin.cjs.map +1 -1
- package/build/entity-types/post-revision.cjs.map +1 -1
- package/build/entity-types/post-status.cjs.map +1 -1
- package/build/entity-types/post.cjs.map +1 -1
- package/build/entity-types/settings.cjs.map +1 -1
- package/build/entity-types/sidebar.cjs.map +1 -1
- package/build/entity-types/taxonomy.cjs.map +1 -1
- package/build/entity-types/term.cjs.map +1 -1
- package/build/entity-types/theme.cjs.map +1 -1
- package/build/entity-types/type.cjs.map +1 -1
- package/build/entity-types/user.cjs.map +1 -1
- package/build/entity-types/widget-type.cjs.map +1 -1
- package/build/entity-types/widget.cjs.map +1 -1
- package/build/entity-types/wp-template-part.cjs.map +1 -1
- package/build/entity-types/wp-template.cjs.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.cjs.map +2 -2
- package/build/fetch/__experimental-fetch-url-data.cjs.map +2 -2
- package/build/fetch/index.cjs.map +2 -2
- package/build/footnotes/get-footnotes-order.cjs.map +2 -2
- package/build/footnotes/get-rich-text-values-cached.cjs.map +2 -2
- package/build/footnotes/index.cjs +12 -1
- package/build/footnotes/index.cjs.map +3 -3
- package/build/hooks/index.cjs.map +2 -2
- package/build/hooks/use-entity-block-editor.cjs.map +2 -2
- package/build/hooks/use-entity-id.cjs.map +2 -2
- package/build/hooks/use-entity-prop.cjs.map +2 -2
- package/build/hooks/use-entity-record.cjs.map +2 -2
- package/build/hooks/use-entity-records.cjs +2 -2
- package/build/hooks/use-entity-records.cjs.map +2 -2
- package/build/hooks/use-post-editor-awareness-state.cjs.map +2 -2
- package/build/hooks/use-query-select.cjs.map +2 -2
- package/build/hooks/use-resource-permissions.cjs.map +2 -2
- package/build/hooks/utils.cjs.map +2 -2
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs.map +2 -2
- package/build/locks/actions.cjs.map +2 -2
- package/build/locks/engine.cjs.map +2 -2
- package/build/locks/reducer.cjs.map +2 -2
- package/build/locks/selectors.cjs.map +2 -2
- package/build/private-actions.cjs +132 -0
- package/build/private-actions.cjs.map +3 -3
- package/build/private-apis.cjs +22 -0
- package/build/private-apis.cjs.map +3 -3
- package/build/private-selectors.cjs +5 -0
- package/build/private-selectors.cjs.map +2 -2
- package/build/queried-data/get-query-parts.cjs.map +2 -2
- package/build/queried-data/reducer.cjs.map +2 -2
- package/build/queried-data/selectors.cjs.map +2 -2
- package/build/reducer.cjs.map +2 -2
- package/build/resolvers.cjs +21 -26
- package/build/resolvers.cjs.map +2 -2
- package/build/selectors.cjs.map +2 -2
- package/build/sync.cjs +26 -0
- package/build/sync.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/block-selection-history.cjs.map +2 -2
- package/build/utils/clear-unchanged-edits.cjs.map +2 -2
- package/build/utils/conservative-map-item.cjs.map +2 -2
- package/build/utils/crdt-blocks.cjs.map +2 -2
- package/build/utils/crdt-selection.cjs.map +2 -2
- package/build/utils/crdt-text.cjs.map +2 -2
- package/build/utils/crdt-user-selections.cjs +43 -16
- package/build/utils/crdt-user-selections.cjs.map +3 -3
- package/build/utils/crdt-utils.cjs.map +2 -2
- package/build/utils/crdt.cjs +4 -2
- package/build/utils/crdt.cjs.map +2 -2
- package/build/utils/get-template-info.cjs +53 -0
- package/build/utils/get-template-info.cjs.map +7 -0
- package/build/utils/get-template-part-icon.cjs +43 -0
- package/build/utils/get-template-part-icon.cjs.map +7 -0
- package/build/utils/log-entity-deprecation.cjs.map +2 -2
- package/build/utils/save-crdt-doc.cjs.map +2 -2
- package/build-module/actions.mjs +68 -2
- package/build-module/actions.mjs.map +2 -2
- package/build-module/awareness/awareness-state.mjs.map +2 -2
- package/build-module/awareness/base-awareness.mjs.map +2 -2
- package/build-module/awareness/block-lookup.mjs.map +2 -2
- package/build-module/awareness/post-editor-awareness.mjs +7 -0
- package/build-module/awareness/post-editor-awareness.mjs.map +2 -2
- package/build-module/awareness/typed-awareness.mjs.map +2 -2
- package/build-module/awareness/utils.mjs.map +2 -2
- package/build-module/batch/create-batch.mjs.map +2 -2
- package/build-module/batch/default-processor.mjs.map +2 -2
- package/build-module/components/entities-saved-states/entity-record-item.mjs +46 -0
- package/build-module/components/entities-saved-states/entity-record-item.mjs.map +7 -0
- package/build-module/components/entities-saved-states/entity-type-list.mjs +104 -0
- package/build-module/components/entities-saved-states/entity-type-list.mjs.map +7 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs +76 -0
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs.map +7 -0
- package/build-module/components/entities-saved-states/index.mjs +187 -0
- package/build-module/components/entities-saved-states/index.mjs.map +7 -0
- package/build-module/dynamic-entities.mjs.map +2 -2
- package/build-module/entities.mjs +2 -0
- package/build-module/entities.mjs.map +2 -2
- package/build-module/entity-context.mjs.map +2 -2
- package/build-module/entity-provider.mjs.map +2 -2
- package/build-module/fetch/__experimental-fetch-link-suggestions.mjs.map +2 -2
- package/build-module/fetch/__experimental-fetch-url-data.mjs.map +2 -2
- package/build-module/fetch/index.mjs.map +2 -2
- package/build-module/footnotes/get-footnotes-order.mjs.map +2 -2
- package/build-module/footnotes/get-rich-text-values-cached.mjs.map +2 -2
- package/build-module/footnotes/index.mjs +12 -1
- package/build-module/footnotes/index.mjs.map +2 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/use-entity-block-editor.mjs.map +2 -2
- package/build-module/hooks/use-entity-id.mjs.map +2 -2
- package/build-module/hooks/use-entity-prop.mjs.map +2 -2
- package/build-module/hooks/use-entity-record.mjs.map +2 -2
- package/build-module/hooks/use-entity-records.mjs +2 -2
- package/build-module/hooks/use-entity-records.mjs.map +2 -2
- package/build-module/hooks/use-post-editor-awareness-state.mjs.map +2 -2
- package/build-module/hooks/use-query-select.mjs.map +2 -2
- package/build-module/hooks/use-resource-permissions.mjs.map +2 -2
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/locks/actions.mjs.map +2 -2
- package/build-module/locks/engine.mjs.map +2 -2
- package/build-module/locks/reducer.mjs.map +2 -2
- package/build-module/locks/selectors.mjs.map +2 -2
- package/build-module/private-actions.mjs +131 -0
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/private-apis.mjs +21 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/private-selectors.mjs +4 -0
- package/build-module/private-selectors.mjs.map +2 -2
- package/build-module/queried-data/get-query-parts.mjs.map +2 -2
- package/build-module/queried-data/reducer.mjs.map +2 -2
- package/build-module/queried-data/selectors.mjs.map +2 -2
- package/build-module/reducer.mjs.map +2 -2
- package/build-module/resolvers.mjs +21 -26
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/selectors.mjs.map +2 -2
- package/build-module/sync.mjs +23 -0
- package/build-module/sync.mjs.map +2 -2
- package/build-module/utils/block-selection-history.mjs.map +2 -2
- package/build-module/utils/clear-unchanged-edits.mjs.map +2 -2
- package/build-module/utils/conservative-map-item.mjs.map +2 -2
- package/build-module/utils/crdt-blocks.mjs.map +2 -2
- package/build-module/utils/crdt-selection.mjs.map +2 -2
- package/build-module/utils/crdt-text.mjs.map +2 -2
- package/build-module/utils/crdt-user-selections.mjs +43 -16
- package/build-module/utils/crdt-user-selections.mjs.map +3 -3
- package/build-module/utils/crdt-utils.mjs.map +2 -2
- package/build-module/utils/crdt.mjs +2 -1
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-module/utils/get-template-info.mjs +28 -0
- package/build-module/utils/get-template-info.mjs.map +7 -0
- package/build-module/utils/get-template-part-icon.mjs +24 -0
- package/build-module/utils/get-template-part-icon.mjs.map +7 -0
- package/build-module/utils/log-entity-deprecation.mjs.map +2 -2
- package/build-module/utils/save-crdt-doc.mjs.map +2 -2
- package/build-types/actions.d.ts +4 -0
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/awareness/awareness-state.d.ts.map +1 -1
- package/build-types/awareness/base-awareness.d.ts +0 -3
- package/build-types/awareness/base-awareness.d.ts.map +1 -1
- package/build-types/awareness/block-lookup.d.ts +0 -3
- package/build-types/awareness/block-lookup.d.ts.map +1 -1
- package/build-types/awareness/post-editor-awareness.d.ts +0 -3
- package/build-types/awareness/post-editor-awareness.d.ts.map +1 -1
- package/build-types/awareness/typed-awareness.d.ts +0 -3
- package/build-types/awareness/typed-awareness.d.ts.map +1 -1
- package/build-types/awareness/types.d.ts +0 -6
- package/build-types/awareness/types.d.ts.map +1 -1
- package/build-types/awareness/utils.d.ts +0 -3
- package/build-types/awareness/utils.d.ts.map +1 -1
- package/build-types/batch/create-batch.d.ts.map +1 -1
- package/build-types/batch/default-processor.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts +11 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/index.d.ts +49 -0
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -0
- package/build-types/dynamic-entities.d.ts +0 -3
- package/build-types/dynamic-entities.d.ts.map +1 -1
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/entity-context.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/entity-types/attachment.d.ts +0 -3
- package/build-types/entity-types/attachment.d.ts.map +1 -1
- package/build-types/entity-types/base.d.ts +0 -3
- package/build-types/entity-types/base.d.ts.map +1 -1
- package/build-types/entity-types/comment.d.ts +0 -3
- package/build-types/entity-types/comment.d.ts.map +1 -1
- package/build-types/entity-types/font-collection.d.ts +0 -3
- package/build-types/entity-types/font-collection.d.ts.map +1 -1
- package/build-types/entity-types/font-family.d.ts +0 -3
- package/build-types/entity-types/font-family.d.ts.map +1 -1
- package/build-types/entity-types/global-styles-revision.d.ts +0 -3
- package/build-types/entity-types/global-styles-revision.d.ts.map +1 -1
- package/build-types/entity-types/helpers.d.ts +0 -3
- package/build-types/entity-types/helpers.d.ts.map +1 -1
- package/build-types/entity-types/icon.d.ts +0 -3
- package/build-types/entity-types/icon.d.ts.map +1 -1
- package/build-types/entity-types/index.d.ts +0 -3
- package/build-types/entity-types/index.d.ts.map +1 -1
- package/build-types/entity-types/menu-location.d.ts +0 -3
- package/build-types/entity-types/menu-location.d.ts.map +1 -1
- package/build-types/entity-types/nav-menu-item.d.ts +0 -3
- package/build-types/entity-types/nav-menu-item.d.ts.map +1 -1
- package/build-types/entity-types/nav-menu.d.ts +0 -3
- package/build-types/entity-types/nav-menu.d.ts.map +1 -1
- package/build-types/entity-types/page.d.ts +0 -3
- package/build-types/entity-types/page.d.ts.map +1 -1
- package/build-types/entity-types/plugin.d.ts +0 -3
- package/build-types/entity-types/plugin.d.ts.map +1 -1
- package/build-types/entity-types/post-revision.d.ts +0 -3
- package/build-types/entity-types/post-revision.d.ts.map +1 -1
- package/build-types/entity-types/post-status.d.ts +0 -3
- package/build-types/entity-types/post-status.d.ts.map +1 -1
- package/build-types/entity-types/post.d.ts +0 -3
- package/build-types/entity-types/post.d.ts.map +1 -1
- package/build-types/entity-types/settings.d.ts +0 -3
- package/build-types/entity-types/settings.d.ts.map +1 -1
- package/build-types/entity-types/sidebar.d.ts +0 -3
- package/build-types/entity-types/sidebar.d.ts.map +1 -1
- package/build-types/entity-types/taxonomy.d.ts +0 -3
- package/build-types/entity-types/taxonomy.d.ts.map +1 -1
- package/build-types/entity-types/term.d.ts +0 -3
- package/build-types/entity-types/term.d.ts.map +1 -1
- package/build-types/entity-types/test/attachment.test.d.ts +0 -8
- package/build-types/entity-types/test/attachment.test.d.ts.map +1 -1
- package/build-types/entity-types/theme.d.ts +0 -3
- package/build-types/entity-types/theme.d.ts.map +1 -1
- package/build-types/entity-types/type.d.ts +0 -3
- package/build-types/entity-types/type.d.ts.map +1 -1
- package/build-types/entity-types/user.d.ts +0 -3
- package/build-types/entity-types/user.d.ts.map +1 -1
- package/build-types/entity-types/widget-type.d.ts +0 -3
- package/build-types/entity-types/widget-type.d.ts.map +1 -1
- package/build-types/entity-types/widget.d.ts +0 -3
- package/build-types/entity-types/widget.d.ts.map +1 -1
- package/build-types/entity-types/wp-template-part.d.ts +0 -3
- package/build-types/entity-types/wp-template-part.d.ts.map +1 -1
- package/build-types/entity-types/wp-template.d.ts +0 -3
- package/build-types/entity-types/wp-template.d.ts.map +1 -1
- package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts.map +1 -1
- package/build-types/fetch/__experimental-fetch-url-data.d.ts.map +1 -1
- package/build-types/fetch/index.d.ts.map +1 -1
- package/build-types/footnotes/get-footnotes-order.d.ts.map +1 -1
- package/build-types/footnotes/get-rich-text-values-cached.d.ts.map +1 -1
- package/build-types/footnotes/index.d.ts.map +1 -1
- package/build-types/hooks/index.d.ts +0 -3
- package/build-types/hooks/index.d.ts.map +1 -1
- package/build-types/hooks/use-entity-block-editor.d.ts.map +1 -1
- package/build-types/hooks/use-entity-id.d.ts.map +1 -1
- package/build-types/hooks/use-entity-prop.d.ts.map +1 -1
- package/build-types/hooks/use-entity-record.d.ts.map +1 -1
- package/build-types/hooks/use-entity-records.d.ts.map +1 -1
- package/build-types/hooks/use-post-editor-awareness-state.d.ts.map +1 -1
- package/build-types/hooks/use-query-select.d.ts.map +1 -1
- package/build-types/hooks/use-resource-permissions.d.ts.map +1 -1
- package/build-types/hooks/utils.d.ts +0 -6
- package/build-types/hooks/utils.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/locks/actions.d.ts.map +1 -1
- package/build-types/locks/engine.d.ts.map +1 -1
- package/build-types/locks/reducer.d.ts.map +1 -1
- package/build-types/locks/selectors.d.ts.map +1 -1
- package/build-types/private-actions.d.ts +19 -0
- package/build-types/private-actions.d.ts.map +1 -1
- package/build-types/private-apis.d.ts +13 -3
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts +12 -3
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/queried-data/get-query-parts.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/queried-data/selectors.d.ts.map +1 -1
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +1 -2
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +31 -3
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -8
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/block-selection-history.d.ts +0 -6
- package/build-types/utils/block-selection-history.d.ts.map +1 -1
- package/build-types/utils/clear-unchanged-edits.d.ts.map +1 -1
- package/build-types/utils/conservative-map-item.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +0 -3
- package/build-types/utils/crdt-blocks.d.ts.map +1 -1
- package/build-types/utils/crdt-selection.d.ts +0 -3
- package/build-types/utils/crdt-selection.d.ts.map +1 -1
- package/build-types/utils/crdt-text.d.ts +0 -3
- package/build-types/utils/crdt-text.d.ts.map +1 -1
- package/build-types/utils/crdt-user-selections.d.ts.map +1 -1
- package/build-types/utils/crdt-utils.d.ts +0 -6
- package/build-types/utils/crdt-utils.d.ts.map +1 -1
- package/build-types/utils/crdt.d.ts +8 -0
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/get-template-info.d.ts +13 -0
- package/build-types/utils/get-template-info.d.ts.map +1 -0
- package/build-types/utils/get-template-part-icon.d.ts +9 -0
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -0
- package/build-types/utils/log-entity-deprecation.d.ts.map +1 -1
- package/build-types/utils/save-crdt-doc.d.ts.map +1 -1
- package/package.json +28 -22
- package/src/actions.js +120 -13
- package/src/awareness/awareness-state.ts +0 -3
- package/src/awareness/base-awareness.ts +0 -8
- package/src/awareness/block-lookup.ts +1 -8
- package/src/awareness/post-editor-awareness.ts +13 -10
- package/src/awareness/test/awareness-state.ts +0 -11
- package/src/awareness/test/base-awareness.ts +0 -7
- package/src/awareness/test/block-lookup.ts +0 -8
- package/src/awareness/test/post-editor-awareness.ts +0 -7
- package/src/awareness/test/typed-awareness.ts +0 -11
- package/src/awareness/test/utils.ts +0 -3
- package/src/awareness/typed-awareness.ts +0 -7
- package/src/awareness/types.ts +0 -7
- package/src/awareness/utils.ts +0 -3
- package/src/batch/create-batch.js +0 -3
- package/src/batch/default-processor.js +0 -4
- package/src/batch/test/create-batch.js +0 -3
- package/src/batch/test/default-processor.js +0 -7
- package/src/components/entities-saved-states/entity-record-item.js +53 -0
- package/src/components/entities-saved-states/entity-type-list.js +123 -0
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +98 -0
- package/src/components/entities-saved-states/index.js +231 -0
- package/src/components/entities-saved-states/style.scss +70 -0
- package/src/components/entities-saved-states/test/use-is-dirty.js +147 -0
- package/src/dynamic-entities.ts +0 -3
- package/src/entities.js +2 -11
- package/src/entity-context.js +0 -3
- package/src/entity-provider.js +0 -7
- package/src/entity-types/attachment.ts +0 -4
- package/src/entity-types/base.ts +0 -3
- package/src/entity-types/comment.ts +0 -3
- package/src/entity-types/font-collection.ts +0 -3
- package/src/entity-types/font-family.ts +0 -3
- package/src/entity-types/global-styles-revision.ts +0 -4
- package/src/entity-types/helpers.ts +0 -3
- package/src/entity-types/icon.ts +0 -4
- package/src/entity-types/index.ts +0 -3
- package/src/entity-types/menu-location.ts +0 -4
- package/src/entity-types/nav-menu-item.ts +0 -4
- package/src/entity-types/nav-menu.ts +0 -4
- package/src/entity-types/page.ts +0 -4
- package/src/entity-types/plugin.ts +0 -4
- package/src/entity-types/post-revision.ts +0 -4
- package/src/entity-types/post-status.ts +0 -3
- package/src/entity-types/post.ts +0 -4
- package/src/entity-types/settings.ts +0 -4
- package/src/entity-types/sidebar.ts +0 -4
- package/src/entity-types/taxonomy.ts +0 -4
- package/src/entity-types/term.ts +0 -4
- package/src/entity-types/test/attachment.test.ts +0 -4
- package/src/entity-types/theme.ts +0 -4
- package/src/entity-types/type.ts +0 -4
- package/src/entity-types/user.ts +0 -4
- package/src/entity-types/widget-type.ts +0 -4
- package/src/entity-types/widget.ts +0 -4
- package/src/entity-types/wp-template-part.ts +0 -4
- package/src/entity-types/wp-template.ts +0 -4
- package/src/fetch/__experimental-fetch-link-suggestions.ts +0 -3
- package/src/fetch/__experimental-fetch-url-data.js +0 -3
- package/src/fetch/index.js +0 -7
- package/src/fetch/test/__experimental-fetch-link-suggestions.js +0 -3
- package/src/fetch/test/__experimental-fetch-url-data.js +1 -7
- package/src/footnotes/get-footnotes-order.js +0 -3
- package/src/footnotes/get-rich-text-values-cached.js +0 -7
- package/src/footnotes/index.js +21 -8
- package/src/footnotes/test/index.js +57 -0
- package/src/hooks/index.ts +0 -3
- package/src/hooks/test/use-entity-record.js +0 -12
- package/src/hooks/test/use-entity-records.js +0 -12
- package/src/hooks/test/use-post-editor-awareness-state.ts +0 -7
- package/src/hooks/test/use-query-select.js +0 -11
- package/src/hooks/test/use-resource-permissions.js +0 -12
- package/src/hooks/use-entity-block-editor.js +0 -7
- package/src/hooks/use-entity-id.js +0 -7
- package/src/hooks/use-entity-prop.js +0 -7
- package/src/hooks/use-entity-record.ts +0 -7
- package/src/hooks/use-entity-records.ts +2 -9
- package/src/hooks/use-post-editor-awareness-state.ts +0 -7
- package/src/hooks/use-query-select.ts +0 -7
- package/src/hooks/use-resource-permissions.ts +0 -7
- package/src/hooks/utils.ts +0 -7
- package/src/index.js +0 -7
- package/src/lock-unlock.ts +0 -3
- package/src/locks/actions.js +0 -3
- package/src/locks/engine.js +0 -3
- package/src/locks/reducer.js +0 -3
- package/src/locks/selectors.js +0 -3
- package/src/locks/test/engine.js +0 -3
- package/src/locks/test/reducer.js +0 -7
- package/src/locks/test/selectors.js +0 -7
- package/src/locks/test/utils.js +0 -7
- package/src/private-actions.js +182 -7
- package/src/private-apis.ts +21 -4
- package/src/private-selectors.ts +22 -7
- package/src/queried-data/get-query-parts.js +0 -7
- package/src/queried-data/reducer.js +0 -7
- package/src/queried-data/selectors.js +0 -7
- package/src/queried-data/test/actions.js +0 -3
- package/src/queried-data/test/get-query-parts.js +0 -3
- package/src/queried-data/test/reducer.js +0 -7
- package/src/queried-data/test/selectors.js +0 -3
- package/src/reducer.js +0 -11
- package/src/resolvers.js +23 -40
- package/src/selectors.ts +0 -7
- package/src/style.scss +1 -0
- package/src/sync.ts +64 -7
- package/src/test/actions.js +843 -8
- package/src/test/deprecated-entity-logging.js +0 -7
- package/src/test/entities.js +0 -8
- package/src/test/entity-provider.js +0 -11
- package/src/test/private-actions.js +297 -7
- package/src/test/private-selectors.js +0 -3
- package/src/test/reducer.js +0 -7
- package/src/test/resolvers.js +0 -12
- package/src/test/rtc-rich-text-offset-space.test.js +0 -12
- package/src/test/selectors.js +0 -7
- package/src/test/store.js +8 -15
- package/src/types.ts +14 -12
- package/src/utils/block-selection-history.ts +0 -10
- package/src/utils/clear-unchanged-edits.ts +0 -3
- package/src/utils/conservative-map-item.js +0 -3
- package/src/utils/crdt-blocks.ts +0 -11
- package/src/utils/crdt-selection.ts +0 -7
- package/src/utils/crdt-text.ts +0 -3
- package/src/utils/crdt-user-selections.ts +85 -23
- package/src/utils/crdt-utils.ts +0 -7
- package/src/utils/crdt.ts +1 -12
- package/src/utils/get-template-info.js +46 -0
- package/src/utils/get-template-part-icon.js +27 -0
- package/src/utils/log-entity-deprecation.ts +0 -7
- package/src/utils/save-crdt-doc.js +0 -7
- package/src/utils/test/block-selection-history.test.ts +0 -7
- package/src/utils/test/clear-unchanged-edits.js +0 -3
- package/src/utils/test/conservative-map-item.js +0 -3
- package/src/utils/test/crdt-blocks.ts +0 -17
- package/src/utils/test/crdt-user-selections.ts +107 -30
- package/src/utils/test/crdt-utils.ts +0 -7
- package/src/utils/test/crdt.ts +0 -16
- package/src/utils/test/get-nested-value.js +0 -3
- package/src/utils/test/get-normalized-comma-separable.js +0 -3
- package/src/utils/test/get-template-info.js +218 -0
- package/src/utils/test/if-matching-action.js +0 -7
- package/src/utils/test/is-numeric-id.js +0 -3
- package/src/utils/test/log-entity-deprecation.js +0 -7
- package/src/utils/test/replace-action.js +0 -3
- package/src/utils/test/rtc-rich-text-cursor-scope.test.js +0 -14
- package/src/utils/test/rtc-rich-text-offset-space.test.js +0 -14
- package/src/utils/test/save-crdt-doc.js +0 -7
- package/src/utils/test/set-nested-value.js +0 -3
- package/src/utils/test/with-weak-map-cache.js +0 -3
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { select } from '@wordpress/data';
|
|
5
2
|
import { Y } from '@wordpress/sync';
|
|
6
|
-
// @ts-
|
|
3
|
+
// @ts-expect-error `@wordpress/block-editor` does not expose type declarations for its entry point.
|
|
7
4
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
5
|
import { CRDT_RECORD_MAP_KEY } from '../sync';
|
|
13
6
|
import type { YPostRecord } from './crdt';
|
|
14
7
|
import type { YBlock, YBlocks } from './crdt-blocks';
|
|
@@ -28,6 +21,7 @@ import type {
|
|
|
28
21
|
SelectionInMultipleBlocks,
|
|
29
22
|
SelectionWholeBlock,
|
|
30
23
|
CursorPosition,
|
|
24
|
+
SelectionEndpoint,
|
|
31
25
|
} from '../types';
|
|
32
26
|
|
|
33
27
|
/**
|
|
@@ -145,18 +139,20 @@ export function getSelectionState(
|
|
|
145
139
|
};
|
|
146
140
|
}
|
|
147
141
|
|
|
148
|
-
// Case 5: Selection in multiple blocks
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
// Case 5: Selection in multiple blocks.
|
|
143
|
+
// Each endpoint is resolved independently — text fields get a CursorEndpoint
|
|
144
|
+
// (character-level anchor), everything else gets a WholeBlockEndpoint
|
|
145
|
+
// (block-slot anchor). Mixed combinations across block types are valid.
|
|
146
|
+
const startEndpoint = getSelectionEndpoint( selectionStart, yBlocks );
|
|
147
|
+
const endEndpoint = getSelectionEndpoint( selectionEnd, yBlocks );
|
|
148
|
+
if ( ! startEndpoint || ! endEndpoint ) {
|
|
153
149
|
return noSelection;
|
|
154
150
|
}
|
|
155
151
|
|
|
156
152
|
return {
|
|
157
153
|
type: SelectionType.SelectionInMultipleBlocks,
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
startEndpoint,
|
|
155
|
+
endEndpoint,
|
|
160
156
|
selectionDirection,
|
|
161
157
|
};
|
|
162
158
|
}
|
|
@@ -207,6 +203,42 @@ function getCursorPosition(
|
|
|
207
203
|
};
|
|
208
204
|
}
|
|
209
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Build a SelectionEndpoint for one side of a multi-block selection.
|
|
208
|
+
*
|
|
209
|
+
* WHY two shapes: Yjs relative positions must be anchored to the right node
|
|
210
|
+
* type. If the block has a RichText field with a known character offset, we
|
|
211
|
+
* anchor to a Y.Text position (CursorEndpoint) so the cursor survives
|
|
212
|
+
* concurrent text edits. If there is no text offset (whole-block selection,
|
|
213
|
+
* or a block type with no RichText), we anchor to the block's index slot in
|
|
214
|
+
* its parent Y.Array (WholeBlockEndpoint) so it survives block insertions and
|
|
215
|
+
* deletions above or below it.
|
|
216
|
+
*
|
|
217
|
+
* @param selection - The WPBlockSelection for this side.
|
|
218
|
+
* @param blocks - The root-level Yjs blocks array.
|
|
219
|
+
* @return A SelectionEndpoint, or null if the block cannot be located in Yjs.
|
|
220
|
+
*/
|
|
221
|
+
function getSelectionEndpoint(
|
|
222
|
+
selection: WPBlockSelection,
|
|
223
|
+
blocks: YBlocks
|
|
224
|
+
): SelectionEndpoint | null {
|
|
225
|
+
const cursorPosition = getCursorPosition( selection, blocks );
|
|
226
|
+
if ( cursorPosition ) {
|
|
227
|
+
return { type: SelectionType.Cursor, cursorPosition };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// No character offset available — anchor to the block's slot in its
|
|
231
|
+
// parent Y.Array instead.
|
|
232
|
+
const path = getBlockPathForLocalClientId( selection.clientId );
|
|
233
|
+
const blockPosition = path
|
|
234
|
+
? createRelativePositionForBlockPath( path, blocks )
|
|
235
|
+
: null;
|
|
236
|
+
if ( blockPosition ) {
|
|
237
|
+
return { type: SelectionType.WholeBlock, blockPosition };
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
|
|
210
242
|
/**
|
|
211
243
|
* Resolves a local block-editor clientId to its index path relative to the
|
|
212
244
|
* post content blocks. This allows finding the corresponding block in the Yjs
|
|
@@ -349,15 +381,13 @@ export function areSelectionsStatesEqual(
|
|
|
349
381
|
|
|
350
382
|
case SelectionType.SelectionInMultipleBlocks:
|
|
351
383
|
return (
|
|
352
|
-
|
|
353
|
-
selection1.
|
|
354
|
-
( selection2 as SelectionInMultipleBlocks )
|
|
355
|
-
.cursorStartPosition
|
|
384
|
+
areEndpointsEqual(
|
|
385
|
+
selection1.startEndpoint,
|
|
386
|
+
( selection2 as SelectionInMultipleBlocks ).startEndpoint
|
|
356
387
|
) &&
|
|
357
|
-
|
|
358
|
-
selection1.
|
|
359
|
-
( selection2 as SelectionInMultipleBlocks )
|
|
360
|
-
.cursorEndPosition
|
|
388
|
+
areEndpointsEqual(
|
|
389
|
+
selection1.endEndpoint,
|
|
390
|
+
( selection2 as SelectionInMultipleBlocks ).endEndpoint
|
|
361
391
|
) &&
|
|
362
392
|
selection1.selectionDirection ===
|
|
363
393
|
( selection2 as SelectionInMultipleBlocks )
|
|
@@ -374,6 +404,38 @@ export function areSelectionsStatesEqual(
|
|
|
374
404
|
}
|
|
375
405
|
}
|
|
376
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Check if two SelectionEndpoints are equal.
|
|
409
|
+
*
|
|
410
|
+
* Endpoints of different kinds (cursor vs whole-block) are never equal.
|
|
411
|
+
*
|
|
412
|
+
* @param ep1 - First endpoint.
|
|
413
|
+
* @param ep2 - Second endpoint.
|
|
414
|
+
* @return True if the endpoints represent the same position.
|
|
415
|
+
*/
|
|
416
|
+
function areEndpointsEqual(
|
|
417
|
+
ep1: SelectionEndpoint,
|
|
418
|
+
ep2: SelectionEndpoint
|
|
419
|
+
): boolean {
|
|
420
|
+
if ( ep1.type !== ep2.type ) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
if (
|
|
424
|
+
ep1.type === SelectionType.Cursor &&
|
|
425
|
+
ep2.type === SelectionType.Cursor
|
|
426
|
+
) {
|
|
427
|
+
return areCursorPositionsEqual(
|
|
428
|
+
ep1.cursorPosition,
|
|
429
|
+
ep2.cursorPosition
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
// Both SelectionType.WholeBlock.
|
|
433
|
+
return Y.compareRelativePositions(
|
|
434
|
+
( ep1 as SelectionWholeBlock ).blockPosition,
|
|
435
|
+
( ep2 as SelectionWholeBlock ).blockPosition
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
377
439
|
/**
|
|
378
440
|
* Check if two cursor positions are equal.
|
|
379
441
|
*
|
package/src/utils/crdt-utils.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Y } from '@wordpress/sync';
|
|
5
2
|
import { create, insert, toHTMLString } from '@wordpress/rich-text';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import type { YBlock, YBlocks } from './crdt-blocks';
|
|
11
4
|
import type { YPostRecord } from './crdt';
|
|
12
5
|
import { CRDT_RECORD_MAP_KEY } from '../sync';
|
package/src/utils/crdt.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import fastDeepEqual from 'fast-deep-equal/es6/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import {
|
|
10
3
|
__unstableSerializeAndClean,
|
|
11
4
|
parse,
|
|
@@ -19,10 +12,6 @@ import {
|
|
|
19
12
|
type SyncConfig,
|
|
20
13
|
Y,
|
|
21
14
|
} from '@wordpress/sync';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Internal dependencies
|
|
25
|
-
*/
|
|
26
15
|
import { BaseAwareness } from '../awareness/base-awareness';
|
|
27
16
|
import {
|
|
28
17
|
type Block,
|
|
@@ -577,7 +566,7 @@ export const defaultCollectionSyncConfig: SyncConfig = {
|
|
|
577
566
|
* @param {unknown} value The value to extract from.
|
|
578
567
|
* @return {string|undefined} The raw string value, or undefined if it could not be determined.
|
|
579
568
|
*/
|
|
580
|
-
function getRawValue( value?: unknown ): string | undefined {
|
|
569
|
+
export function getRawValue( value?: unknown ): string | undefined {
|
|
581
570
|
// Value may be a string property or a nested object with a `raw` property.
|
|
582
571
|
if ( 'string' === typeof value ) {
|
|
583
572
|
return value;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { layout } from '@wordpress/icons';
|
|
2
|
+
import { getTemplatePartIcon } from './get-template-part-icon';
|
|
3
|
+
const EMPTY_OBJECT = {};
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to retrieve the corresponding template info for a given template.
|
|
7
|
+
* @param {Object} params
|
|
8
|
+
* @param {Array} params.templateTypes
|
|
9
|
+
* @param {Array} [params.templateAreas]
|
|
10
|
+
* @param {Object} params.template
|
|
11
|
+
*/
|
|
12
|
+
export const getTemplateInfo = ( params ) => {
|
|
13
|
+
if ( ! params ) {
|
|
14
|
+
return EMPTY_OBJECT;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { templateTypes, templateAreas, template } = params;
|
|
18
|
+
|
|
19
|
+
const { description, slug, title, area } = template;
|
|
20
|
+
|
|
21
|
+
const { title: defaultTitle, description: defaultDescription } =
|
|
22
|
+
Object.values( templateTypes ).find( ( type ) => type.slug === slug ) ??
|
|
23
|
+
EMPTY_OBJECT;
|
|
24
|
+
|
|
25
|
+
const templateTitle = typeof title === 'string' ? title : title?.rendered;
|
|
26
|
+
const templateDescription =
|
|
27
|
+
typeof description === 'string' ? description : description?.raw;
|
|
28
|
+
|
|
29
|
+
const templateAreasWithIcon = templateAreas?.map( ( item ) => ( {
|
|
30
|
+
...item,
|
|
31
|
+
icon: getTemplatePartIcon( item.icon ),
|
|
32
|
+
} ) );
|
|
33
|
+
|
|
34
|
+
const templateIcon =
|
|
35
|
+
templateAreasWithIcon?.find( ( item ) => area === item.area )?.icon ||
|
|
36
|
+
layout;
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
title:
|
|
40
|
+
templateTitle && templateTitle !== slug
|
|
41
|
+
? templateTitle
|
|
42
|
+
: defaultTitle || slug,
|
|
43
|
+
description: templateDescription || defaultDescription,
|
|
44
|
+
icon: templateIcon,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
header as headerIcon,
|
|
3
|
+
footer as footerIcon,
|
|
4
|
+
sidebar as sidebarIcon,
|
|
5
|
+
navigationOverlay as navigationOverlayIcon,
|
|
6
|
+
symbolFilled as symbolFilledIcon,
|
|
7
|
+
} from '@wordpress/icons';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to retrieve the corresponding icon by area name.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} areaOrIconName The area name (e.g., 'header', 'navigation-overlay').
|
|
13
|
+
*
|
|
14
|
+
* @return {Object} The corresponding icon.
|
|
15
|
+
*/
|
|
16
|
+
export function getTemplatePartIcon( areaOrIconName ) {
|
|
17
|
+
if ( 'header' === areaOrIconName ) {
|
|
18
|
+
return headerIcon;
|
|
19
|
+
} else if ( 'footer' === areaOrIconName ) {
|
|
20
|
+
return footerIcon;
|
|
21
|
+
} else if ( 'sidebar' === areaOrIconName ) {
|
|
22
|
+
return sidebarIcon;
|
|
23
|
+
} else if ( 'navigation-overlay' === areaOrIconName ) {
|
|
24
|
+
return navigationOverlayIcon;
|
|
25
|
+
}
|
|
26
|
+
return symbolFilledIcon;
|
|
27
|
+
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Y } from '@wordpress/sync';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* External dependencies
|
|
8
|
-
*/
|
|
9
2
|
import {
|
|
10
3
|
describe,
|
|
11
4
|
expect,
|
|
@@ -14,14 +7,12 @@ import {
|
|
|
14
7
|
beforeEach,
|
|
15
8
|
afterEach,
|
|
16
9
|
} from '@jest/globals';
|
|
17
|
-
|
|
18
10
|
/**
|
|
19
11
|
* Mock uuid module
|
|
20
12
|
*/
|
|
21
13
|
jest.mock( 'uuid', () => ( {
|
|
22
14
|
v4: () => 'mocked-uuid-' + Math.random(),
|
|
23
15
|
} ) );
|
|
24
|
-
|
|
25
16
|
/**
|
|
26
17
|
* Mock @wordpress/blocks module
|
|
27
18
|
*/
|
|
@@ -101,15 +92,7 @@ jest.mock( '@wordpress/blocks', () => ( {
|
|
|
101
92
|
},
|
|
102
93
|
],
|
|
103
94
|
} ) );
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* WordPress dependencies
|
|
107
|
-
*/
|
|
108
95
|
import { RichTextData } from '@wordpress/rich-text';
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Internal dependencies
|
|
112
|
-
*/
|
|
113
96
|
import {
|
|
114
97
|
mergeCrdtBlocks,
|
|
115
98
|
mergeRichTextUpdate,
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Y } from '@wordpress/sync';
|
|
5
2
|
import { select } from '@wordpress/data';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import {
|
|
11
4
|
areSelectionsStatesEqual,
|
|
12
5
|
getSelectionState,
|
|
13
6
|
SelectionType,
|
|
14
7
|
} from '../crdt-user-selections';
|
|
15
8
|
import { CRDT_RECORD_MAP_KEY } from '../../sync';
|
|
16
|
-
|
|
17
9
|
jest.mock( '@wordpress/data', () => ( {
|
|
18
10
|
select: jest.fn(),
|
|
19
11
|
// Needed because @wordpress/rich-text initialises its store at import time.
|
|
@@ -22,7 +14,6 @@ jest.mock( '@wordpress/data', () => ( {
|
|
|
22
14
|
register: jest.fn(),
|
|
23
15
|
createSelector: ( selector: Function ) => selector,
|
|
24
16
|
} ) );
|
|
25
|
-
|
|
26
17
|
jest.mock( '@wordpress/block-editor', () => ( {
|
|
27
18
|
store: 'core/block-editor',
|
|
28
19
|
} ) );
|
|
@@ -269,21 +260,49 @@ describe( 'areSelectionsStatesEqual', () => {
|
|
|
269
260
|
} );
|
|
270
261
|
|
|
271
262
|
describe( 'SelectionType.SelectionInMultipleBlocks', () => {
|
|
272
|
-
test( 'returns true when
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
5
|
|
263
|
+
test( 'returns true when both endpoints are identical cursor endpoints', () => {
|
|
264
|
+
const startEndpoint: SelectionCursor = {
|
|
265
|
+
type: SelectionType.Cursor,
|
|
266
|
+
cursorPosition: createCursorPosition( 'first block', 5 ),
|
|
267
|
+
};
|
|
268
|
+
const endEndpoint: SelectionCursor = {
|
|
269
|
+
type: SelectionType.Cursor,
|
|
270
|
+
cursorPosition: createCursorPosition( 'second block', 3 ),
|
|
271
|
+
};
|
|
272
|
+
const selection1: SelectionInMultipleBlocks = {
|
|
273
|
+
type: SelectionType.SelectionInMultipleBlocks,
|
|
274
|
+
startEndpoint,
|
|
275
|
+
endEndpoint,
|
|
276
|
+
};
|
|
277
|
+
const selection2: SelectionInMultipleBlocks = {
|
|
278
|
+
type: SelectionType.SelectionInMultipleBlocks,
|
|
279
|
+
startEndpoint,
|
|
280
|
+
endEndpoint,
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
expect( areSelectionsStatesEqual( selection1, selection2 ) ).toBe(
|
|
284
|
+
true
|
|
276
285
|
);
|
|
277
|
-
|
|
286
|
+
} );
|
|
287
|
+
|
|
288
|
+
test( 'returns true when both endpoints are identical whole-block endpoints', () => {
|
|
289
|
+
const startEndpoint: SelectionWholeBlock = {
|
|
290
|
+
type: SelectionType.WholeBlock,
|
|
291
|
+
blockPosition: createBlockPosition( 0 ),
|
|
292
|
+
};
|
|
293
|
+
const endEndpoint: SelectionWholeBlock = {
|
|
294
|
+
type: SelectionType.WholeBlock,
|
|
295
|
+
blockPosition: createBlockPosition( 1 ),
|
|
296
|
+
};
|
|
278
297
|
const selection1: SelectionInMultipleBlocks = {
|
|
279
298
|
type: SelectionType.SelectionInMultipleBlocks,
|
|
280
|
-
|
|
281
|
-
|
|
299
|
+
startEndpoint,
|
|
300
|
+
endEndpoint,
|
|
282
301
|
};
|
|
283
302
|
const selection2: SelectionInMultipleBlocks = {
|
|
284
303
|
type: SelectionType.SelectionInMultipleBlocks,
|
|
285
|
-
|
|
286
|
-
|
|
304
|
+
startEndpoint,
|
|
305
|
+
endEndpoint,
|
|
287
306
|
};
|
|
288
307
|
|
|
289
308
|
expect( areSelectionsStatesEqual( selection1, selection2 ) ).toBe(
|
|
@@ -291,16 +310,28 @@ describe( 'areSelectionsStatesEqual', () => {
|
|
|
291
310
|
);
|
|
292
311
|
} );
|
|
293
312
|
|
|
294
|
-
test( 'returns false when start cursor position differs', () => {
|
|
313
|
+
test( 'returns false when start cursor endpoint position differs', () => {
|
|
295
314
|
const selection1: SelectionInMultipleBlocks = {
|
|
296
315
|
type: SelectionType.SelectionInMultipleBlocks,
|
|
297
|
-
|
|
298
|
-
|
|
316
|
+
startEndpoint: {
|
|
317
|
+
type: SelectionType.Cursor,
|
|
318
|
+
cursorPosition: createCursorPosition( 'first block', 5 ),
|
|
319
|
+
},
|
|
320
|
+
endEndpoint: {
|
|
321
|
+
type: SelectionType.Cursor,
|
|
322
|
+
cursorPosition: createCursorPosition( 'second block', 3 ),
|
|
323
|
+
},
|
|
299
324
|
};
|
|
300
325
|
const selection2: SelectionInMultipleBlocks = {
|
|
301
326
|
type: SelectionType.SelectionInMultipleBlocks,
|
|
302
|
-
|
|
303
|
-
|
|
327
|
+
startEndpoint: {
|
|
328
|
+
type: SelectionType.Cursor,
|
|
329
|
+
cursorPosition: createCursorPosition( 'first block', 6 ),
|
|
330
|
+
},
|
|
331
|
+
endEndpoint: {
|
|
332
|
+
type: SelectionType.Cursor,
|
|
333
|
+
cursorPosition: createCursorPosition( 'second block', 3 ),
|
|
334
|
+
},
|
|
304
335
|
};
|
|
305
336
|
|
|
306
337
|
expect( areSelectionsStatesEqual( selection1, selection2 ) ).toBe(
|
|
@@ -308,16 +339,57 @@ describe( 'areSelectionsStatesEqual', () => {
|
|
|
308
339
|
);
|
|
309
340
|
} );
|
|
310
341
|
|
|
311
|
-
test( 'returns false when end cursor position differs', () => {
|
|
342
|
+
test( 'returns false when end cursor endpoint position differs', () => {
|
|
312
343
|
const selection1: SelectionInMultipleBlocks = {
|
|
313
344
|
type: SelectionType.SelectionInMultipleBlocks,
|
|
314
|
-
|
|
315
|
-
|
|
345
|
+
startEndpoint: {
|
|
346
|
+
type: SelectionType.Cursor,
|
|
347
|
+
cursorPosition: createCursorPosition( 'first block', 5 ),
|
|
348
|
+
},
|
|
349
|
+
endEndpoint: {
|
|
350
|
+
type: SelectionType.Cursor,
|
|
351
|
+
cursorPosition: createCursorPosition( 'second block', 3 ),
|
|
352
|
+
},
|
|
316
353
|
};
|
|
317
354
|
const selection2: SelectionInMultipleBlocks = {
|
|
318
355
|
type: SelectionType.SelectionInMultipleBlocks,
|
|
319
|
-
|
|
320
|
-
|
|
356
|
+
startEndpoint: {
|
|
357
|
+
type: SelectionType.Cursor,
|
|
358
|
+
cursorPosition: createCursorPosition( 'first block', 5 ),
|
|
359
|
+
},
|
|
360
|
+
endEndpoint: {
|
|
361
|
+
type: SelectionType.Cursor,
|
|
362
|
+
cursorPosition: createCursorPosition( 'second block', 4 ),
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
expect( areSelectionsStatesEqual( selection1, selection2 ) ).toBe(
|
|
367
|
+
false
|
|
368
|
+
);
|
|
369
|
+
} );
|
|
370
|
+
|
|
371
|
+
test( 'returns false when endpoint types differ (text vs block)', () => {
|
|
372
|
+
const selection1: SelectionInMultipleBlocks = {
|
|
373
|
+
type: SelectionType.SelectionInMultipleBlocks,
|
|
374
|
+
startEndpoint: {
|
|
375
|
+
type: SelectionType.Cursor,
|
|
376
|
+
cursorPosition: createCursorPosition( 'first block', 5 ),
|
|
377
|
+
},
|
|
378
|
+
endEndpoint: {
|
|
379
|
+
type: SelectionType.Cursor,
|
|
380
|
+
cursorPosition: createCursorPosition( 'second block', 3 ),
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
const selection2: SelectionInMultipleBlocks = {
|
|
384
|
+
type: SelectionType.SelectionInMultipleBlocks,
|
|
385
|
+
startEndpoint: {
|
|
386
|
+
type: SelectionType.WholeBlock,
|
|
387
|
+
blockPosition: createBlockPosition( 0 ),
|
|
388
|
+
},
|
|
389
|
+
endEndpoint: {
|
|
390
|
+
type: SelectionType.Cursor,
|
|
391
|
+
cursorPosition: createCursorPosition( 'second block', 3 ),
|
|
392
|
+
},
|
|
321
393
|
};
|
|
322
394
|
|
|
323
395
|
expect( areSelectionsStatesEqual( selection1, selection2 ) ).toBe(
|
|
@@ -732,12 +804,17 @@ describe( 'getSelectionState', () => {
|
|
|
732
804
|
expect( result.type ).toBe(
|
|
733
805
|
SelectionType.SelectionInMultipleBlocks
|
|
734
806
|
);
|
|
807
|
+
const multiBlock = result as SelectionInMultipleBlocks;
|
|
808
|
+
expect( multiBlock.startEndpoint.type ).toBe(
|
|
809
|
+
SelectionType.Cursor
|
|
810
|
+
);
|
|
811
|
+
expect( multiBlock.endEndpoint.type ).toBe( SelectionType.Cursor );
|
|
735
812
|
expect(
|
|
736
|
-
(
|
|
813
|
+
( multiBlock.startEndpoint as SelectionCursor ).cursorPosition
|
|
737
814
|
.absoluteOffset
|
|
738
815
|
).toBe( 5 );
|
|
739
816
|
expect(
|
|
740
|
-
(
|
|
817
|
+
( multiBlock.endEndpoint as SelectionCursor ).cursorPosition
|
|
741
818
|
.absoluteOffset
|
|
742
819
|
).toBe( 3 );
|
|
743
820
|
} );
|
package/src/utils/test/crdt.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Y } from '@wordpress/sync';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* External dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { describe, expect, it, jest, beforeEach } from '@jest/globals';
|
|
10
|
-
|
|
11
3
|
/**
|
|
12
4
|
* Mock getBlockTypes so CRDT merging can identify rich-text attributes.
|
|
13
5
|
* Also stub __unstableSerializeAndClean so we can assert how it's invoked
|
|
@@ -54,16 +46,8 @@ jest.mock( '@wordpress/blocks', () => {
|
|
|
54
46
|
),
|
|
55
47
|
};
|
|
56
48
|
} );
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* WordPress dependencies
|
|
60
|
-
*/
|
|
61
49
|
import { parse } from '@wordpress/blocks';
|
|
62
50
|
import { RichTextData } from '@wordpress/rich-text';
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Internal dependencies
|
|
66
|
-
*/
|
|
67
51
|
import { CRDT_RECORD_MAP_KEY } from '../../sync';
|
|
68
52
|
import {
|
|
69
53
|
applyPostChangesToCRDTDoc,
|