@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
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { useSelect } from '@wordpress/data';
|
|
3
|
+
import { PanelBody, PanelRow } from '@wordpress/components';
|
|
4
|
+
import { getGlobalStylesChanges } from '@wordpress/global-styles-engine';
|
|
5
|
+
import EntityRecordItem from './entity-record-item';
|
|
6
|
+
import { STORE_NAME } from '../../name';
|
|
7
|
+
|
|
8
|
+
function getEntityDescription( entity, count ) {
|
|
9
|
+
switch ( entity ) {
|
|
10
|
+
case 'site':
|
|
11
|
+
return 1 === count
|
|
12
|
+
? __( 'This change will affect your whole site.' )
|
|
13
|
+
: __( 'These changes will affect your whole site.' );
|
|
14
|
+
case 'wp_template':
|
|
15
|
+
return __(
|
|
16
|
+
'This change will affect other parts of your site that use this template.'
|
|
17
|
+
);
|
|
18
|
+
case 'page':
|
|
19
|
+
case 'post':
|
|
20
|
+
return __( 'The following has been modified.' );
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function GlobalStylesDescription( { record } ) {
|
|
25
|
+
const { editedRecord, savedRecord } = useSelect(
|
|
26
|
+
( select ) => {
|
|
27
|
+
const { getEditedEntityRecord, getEntityRecord } =
|
|
28
|
+
select( STORE_NAME );
|
|
29
|
+
return {
|
|
30
|
+
editedRecord: getEditedEntityRecord(
|
|
31
|
+
record.kind,
|
|
32
|
+
record.name,
|
|
33
|
+
record.key
|
|
34
|
+
),
|
|
35
|
+
savedRecord: getEntityRecord(
|
|
36
|
+
record.kind,
|
|
37
|
+
record.name,
|
|
38
|
+
record.key
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
[ record.kind, record.name, record.key ]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const globalStylesChanges = getGlobalStylesChanges(
|
|
46
|
+
editedRecord,
|
|
47
|
+
savedRecord,
|
|
48
|
+
{
|
|
49
|
+
maxResults: 10,
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
return globalStylesChanges.length ? (
|
|
53
|
+
<ul className="entities-saved-states__changes">
|
|
54
|
+
{ globalStylesChanges.map( ( change ) => (
|
|
55
|
+
<li key={ change }>{ change }</li>
|
|
56
|
+
) ) }
|
|
57
|
+
</ul>
|
|
58
|
+
) : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function EntityDescription( { record, count } ) {
|
|
62
|
+
if ( 'globalStyles' === record?.name ) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const description = getEntityDescription( record?.name, count );
|
|
66
|
+
return description ? <PanelRow>{ description }</PanelRow> : null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default function EntityTypeList( {
|
|
70
|
+
list,
|
|
71
|
+
unselectedEntities,
|
|
72
|
+
setUnselectedEntities,
|
|
73
|
+
} ) {
|
|
74
|
+
const count = list.length;
|
|
75
|
+
const firstRecord = list[ 0 ];
|
|
76
|
+
const entityConfig = useSelect(
|
|
77
|
+
( select ) =>
|
|
78
|
+
select( STORE_NAME ).getEntityConfig(
|
|
79
|
+
firstRecord.kind,
|
|
80
|
+
firstRecord.name
|
|
81
|
+
),
|
|
82
|
+
[ firstRecord.kind, firstRecord.name ]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
let entityLabel = entityConfig.label;
|
|
86
|
+
if ( firstRecord?.name === 'wp_template_part' ) {
|
|
87
|
+
entityLabel =
|
|
88
|
+
1 === count ? __( 'Template Part' ) : __( 'Template Parts' );
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<PanelBody
|
|
93
|
+
title={ entityLabel }
|
|
94
|
+
initialOpen
|
|
95
|
+
className="entities-saved-states__panel-body"
|
|
96
|
+
>
|
|
97
|
+
<EntityDescription record={ firstRecord } count={ count } />
|
|
98
|
+
{ list.map( ( record ) => {
|
|
99
|
+
return (
|
|
100
|
+
<EntityRecordItem
|
|
101
|
+
key={ record.key || record.property }
|
|
102
|
+
record={ record }
|
|
103
|
+
checked={
|
|
104
|
+
! unselectedEntities.some(
|
|
105
|
+
( elt ) =>
|
|
106
|
+
elt.kind === record.kind &&
|
|
107
|
+
elt.name === record.name &&
|
|
108
|
+
elt.key === record.key &&
|
|
109
|
+
elt.property === record.property
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
onChange={ ( value ) =>
|
|
113
|
+
setUnselectedEntities( record, value )
|
|
114
|
+
}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
} ) }
|
|
118
|
+
{ 'globalStyles' === firstRecord?.name && (
|
|
119
|
+
<GlobalStylesDescription record={ firstRecord } />
|
|
120
|
+
) }
|
|
121
|
+
</PanelBody>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useSelect } from '@wordpress/data';
|
|
2
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
3
|
+
import { STORE_NAME } from '../../../name';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Custom hook that determines if any entities are dirty (edited) and provides a way to manage selected/unselected entities.
|
|
7
|
+
*
|
|
8
|
+
* @return {Object} An object containing the following properties:
|
|
9
|
+
* - dirtyEntityRecords: An array of dirty entity records.
|
|
10
|
+
* - isDirty: A boolean indicating if there are any dirty entity records.
|
|
11
|
+
* - setUnselectedEntities: A function to set the unselected entities.
|
|
12
|
+
* - unselectedEntities: An array of unselected entities.
|
|
13
|
+
*/
|
|
14
|
+
export const useIsDirty = () => {
|
|
15
|
+
const { editedEntities, siteEdits, siteEntityConfig } = useSelect(
|
|
16
|
+
( select ) => {
|
|
17
|
+
const {
|
|
18
|
+
__experimentalGetDirtyEntityRecords,
|
|
19
|
+
getEntityRecordEdits,
|
|
20
|
+
getEntityConfig,
|
|
21
|
+
} = select( STORE_NAME );
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
editedEntities: __experimentalGetDirtyEntityRecords(),
|
|
25
|
+
siteEdits: getEntityRecordEdits( 'root', 'site' ),
|
|
26
|
+
siteEntityConfig: getEntityConfig( 'root', 'site' ),
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
[]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const dirtyEntityRecords = useMemo( () => {
|
|
33
|
+
// Remove site object and decouple into its edited pieces.
|
|
34
|
+
const editedEntitiesWithoutSite = editedEntities.filter(
|
|
35
|
+
( record ) => ! ( record.kind === 'root' && record.name === 'site' )
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const siteEntityLabels = siteEntityConfig?.meta?.labels ?? {};
|
|
39
|
+
const {
|
|
40
|
+
title: siteTitleEdit,
|
|
41
|
+
description: siteDescriptionEdit,
|
|
42
|
+
site_logo: siteLogoEdit,
|
|
43
|
+
site_icon: siteIconEdit,
|
|
44
|
+
...otherSiteEdits
|
|
45
|
+
} = siteEdits ?? {};
|
|
46
|
+
const orderedSiteProperties = [
|
|
47
|
+
siteTitleEdit !== undefined && 'title',
|
|
48
|
+
siteDescriptionEdit !== undefined && 'description',
|
|
49
|
+
siteLogoEdit !== undefined && 'site_logo',
|
|
50
|
+
siteIconEdit !== undefined && 'site_icon',
|
|
51
|
+
...Object.keys( otherSiteEdits ),
|
|
52
|
+
].filter( Boolean );
|
|
53
|
+
const editedSiteEntities = orderedSiteProperties.map(
|
|
54
|
+
( property ) => ( {
|
|
55
|
+
kind: 'root',
|
|
56
|
+
name: 'site',
|
|
57
|
+
title: siteEntityLabels[ property ] || property,
|
|
58
|
+
property,
|
|
59
|
+
} )
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return [ ...editedEntitiesWithoutSite, ...editedSiteEntities ];
|
|
63
|
+
}, [ editedEntities, siteEdits, siteEntityConfig ] );
|
|
64
|
+
|
|
65
|
+
// Unchecked entities to be ignored by save function.
|
|
66
|
+
const [ unselectedEntities, _setUnselectedEntities ] = useState( [] );
|
|
67
|
+
|
|
68
|
+
const setUnselectedEntities = (
|
|
69
|
+
{ kind, name, key, property },
|
|
70
|
+
checked
|
|
71
|
+
) => {
|
|
72
|
+
if ( checked ) {
|
|
73
|
+
_setUnselectedEntities(
|
|
74
|
+
unselectedEntities.filter(
|
|
75
|
+
( elt ) =>
|
|
76
|
+
elt.kind !== kind ||
|
|
77
|
+
elt.name !== name ||
|
|
78
|
+
elt.key !== key ||
|
|
79
|
+
elt.property !== property
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
_setUnselectedEntities( [
|
|
84
|
+
...unselectedEntities,
|
|
85
|
+
{ kind, name, key, property },
|
|
86
|
+
] );
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
dirtyEntityRecords,
|
|
94
|
+
isDirty,
|
|
95
|
+
setUnselectedEntities,
|
|
96
|
+
unselectedEntities,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { Button, Flex, FlexItem } from '@wordpress/components';
|
|
3
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
4
|
+
import {
|
|
5
|
+
useCallback,
|
|
6
|
+
useRef,
|
|
7
|
+
createInterpolateElement,
|
|
8
|
+
} from '@wordpress/element';
|
|
9
|
+
import {
|
|
10
|
+
__experimentalUseDialog as useDialog,
|
|
11
|
+
useInstanceId,
|
|
12
|
+
} from '@wordpress/compose';
|
|
13
|
+
import { useDispatch } from '@wordpress/data';
|
|
14
|
+
import EntityTypeList from './entity-type-list';
|
|
15
|
+
import { useIsDirty } from './hooks/use-is-dirty';
|
|
16
|
+
import { unlock } from '../../lock-unlock';
|
|
17
|
+
import { STORE_NAME } from '../../name';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Renders the component for managing saved states of entities.
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} props The component props.
|
|
23
|
+
* @param {Function} props.close The function to close the dialog.
|
|
24
|
+
* @param {boolean=} props.renderDialog Whether to render the component with modal dialog behavior.
|
|
25
|
+
* @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.
|
|
26
|
+
*
|
|
27
|
+
* @return {React.ReactNode} The rendered component.
|
|
28
|
+
*/
|
|
29
|
+
export default function EntitiesSavedStates( {
|
|
30
|
+
close,
|
|
31
|
+
renderDialog,
|
|
32
|
+
variant,
|
|
33
|
+
} ) {
|
|
34
|
+
const isDirtyProps = useIsDirty();
|
|
35
|
+
return (
|
|
36
|
+
<EntitiesSavedStatesExtensible
|
|
37
|
+
close={ close }
|
|
38
|
+
renderDialog={ renderDialog }
|
|
39
|
+
variant={ variant }
|
|
40
|
+
{ ...isDirtyProps }
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Renders a panel for saving entities with dirty records.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} props The component props.
|
|
49
|
+
* @param {string} props.additionalPrompt Additional prompt to display.
|
|
50
|
+
* @param {Function} props.close Function to close the panel.
|
|
51
|
+
* @param {Function} props.onSave Function to call when saving entities.
|
|
52
|
+
* @param {boolean} props.saveEnabled Flag indicating if save is enabled.
|
|
53
|
+
* @param {string} props.saveLabel Label for the save button.
|
|
54
|
+
* @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.
|
|
55
|
+
* @param {Array} props.dirtyEntityRecords Array of dirty entity records.
|
|
56
|
+
* @param {boolean} props.isDirty Flag indicating if there are dirty entities.
|
|
57
|
+
* @param {Function} props.setUnselectedEntities Function to set unselected entities.
|
|
58
|
+
* @param {Array} props.unselectedEntities Array of unselected entities.
|
|
59
|
+
* @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.
|
|
60
|
+
* @param {string} props.successNoticeContent Optional custom success notice content.
|
|
61
|
+
*
|
|
62
|
+
* @return {React.ReactNode} The rendered component.
|
|
63
|
+
*/
|
|
64
|
+
export function EntitiesSavedStatesExtensible( {
|
|
65
|
+
additionalPrompt = undefined,
|
|
66
|
+
close,
|
|
67
|
+
onSave = undefined,
|
|
68
|
+
saveEnabled: saveEnabledProp = undefined,
|
|
69
|
+
saveLabel = __( 'Save' ),
|
|
70
|
+
renderDialog,
|
|
71
|
+
dirtyEntityRecords,
|
|
72
|
+
isDirty,
|
|
73
|
+
setUnselectedEntities,
|
|
74
|
+
unselectedEntities,
|
|
75
|
+
variant = 'default',
|
|
76
|
+
successNoticeContent,
|
|
77
|
+
} ) {
|
|
78
|
+
const saveButtonRef = useRef();
|
|
79
|
+
const { saveDirtyEntities } = unlock( useDispatch( STORE_NAME ) );
|
|
80
|
+
// To group entities by type.
|
|
81
|
+
const partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {
|
|
82
|
+
const { name } = record;
|
|
83
|
+
if ( ! acc[ name ] ) {
|
|
84
|
+
acc[ name ] = [];
|
|
85
|
+
}
|
|
86
|
+
acc[ name ].push( record );
|
|
87
|
+
return acc;
|
|
88
|
+
}, {} );
|
|
89
|
+
|
|
90
|
+
// Sort entity groups.
|
|
91
|
+
const {
|
|
92
|
+
site: siteSavables,
|
|
93
|
+
wp_template: templateSavables,
|
|
94
|
+
wp_template_part: templatePartSavables,
|
|
95
|
+
...contentSavables
|
|
96
|
+
} = partitionedSavables;
|
|
97
|
+
const sortedPartitionedSavables = [
|
|
98
|
+
siteSavables,
|
|
99
|
+
templateSavables,
|
|
100
|
+
templatePartSavables,
|
|
101
|
+
...Object.values( contentSavables ),
|
|
102
|
+
].filter( Array.isArray );
|
|
103
|
+
|
|
104
|
+
const saveEnabled = saveEnabledProp ?? isDirty;
|
|
105
|
+
// Explicitly define this with no argument passed. Using `close` on
|
|
106
|
+
// its own will use the event object in place of the expected saved entities.
|
|
107
|
+
const dismissPanel = useCallback( () => close(), [ close ] );
|
|
108
|
+
|
|
109
|
+
const [ saveDialogRef, saveDialogProps ] = useDialog( {
|
|
110
|
+
onClose: () => dismissPanel(),
|
|
111
|
+
} );
|
|
112
|
+
const dialogLabelId = useInstanceId(
|
|
113
|
+
EntitiesSavedStatesExtensible,
|
|
114
|
+
'entities-saved-states__panel-label'
|
|
115
|
+
);
|
|
116
|
+
const dialogDescriptionId = useInstanceId(
|
|
117
|
+
EntitiesSavedStatesExtensible,
|
|
118
|
+
'entities-saved-states__panel-description'
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const selectItemsToSaveDescription = !! dirtyEntityRecords.length
|
|
122
|
+
? __( 'Select the items you want to save.' )
|
|
123
|
+
: undefined;
|
|
124
|
+
|
|
125
|
+
const isInline = variant === 'inline';
|
|
126
|
+
|
|
127
|
+
const actionButtons = (
|
|
128
|
+
<>
|
|
129
|
+
<FlexItem
|
|
130
|
+
isBlock={ isInline ? false : true }
|
|
131
|
+
as={ Button }
|
|
132
|
+
variant={ isInline ? 'tertiary' : 'secondary' }
|
|
133
|
+
size={ isInline ? undefined : 'compact' }
|
|
134
|
+
onClick={ dismissPanel }
|
|
135
|
+
>
|
|
136
|
+
{ __( 'Cancel' ) }
|
|
137
|
+
</FlexItem>
|
|
138
|
+
<FlexItem
|
|
139
|
+
isBlock={ isInline ? false : true }
|
|
140
|
+
as={ Button }
|
|
141
|
+
ref={ saveButtonRef }
|
|
142
|
+
variant="primary"
|
|
143
|
+
size={ isInline ? undefined : 'compact' }
|
|
144
|
+
disabled={ ! saveEnabled }
|
|
145
|
+
accessibleWhenDisabled
|
|
146
|
+
onClick={ () =>
|
|
147
|
+
saveDirtyEntities( {
|
|
148
|
+
onSave,
|
|
149
|
+
dirtyEntityRecords,
|
|
150
|
+
entitiesToSkip: unselectedEntities,
|
|
151
|
+
close,
|
|
152
|
+
successNoticeContent,
|
|
153
|
+
} )
|
|
154
|
+
}
|
|
155
|
+
className="entities-saved-states__save-button"
|
|
156
|
+
>
|
|
157
|
+
{ saveLabel }
|
|
158
|
+
</FlexItem>
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<div
|
|
164
|
+
ref={ renderDialog ? saveDialogRef : undefined }
|
|
165
|
+
{ ...( renderDialog && saveDialogProps ) }
|
|
166
|
+
className={ clsx( 'entities-saved-states__panel', {
|
|
167
|
+
'is-inline': isInline,
|
|
168
|
+
} ) }
|
|
169
|
+
role={ renderDialog ? 'dialog' : undefined }
|
|
170
|
+
aria-labelledby={ renderDialog ? dialogLabelId : undefined }
|
|
171
|
+
aria-describedby={ renderDialog ? dialogDescriptionId : undefined }
|
|
172
|
+
>
|
|
173
|
+
{ ! isInline && (
|
|
174
|
+
<Flex className="entities-saved-states__panel-header" gap={ 2 }>
|
|
175
|
+
{ actionButtons }
|
|
176
|
+
</Flex>
|
|
177
|
+
) }
|
|
178
|
+
|
|
179
|
+
<div className="entities-saved-states__text-prompt">
|
|
180
|
+
<div className="entities-saved-states__text-prompt--header-wrapper">
|
|
181
|
+
<strong
|
|
182
|
+
id={ renderDialog ? dialogLabelId : undefined }
|
|
183
|
+
className="entities-saved-states__text-prompt--header"
|
|
184
|
+
>
|
|
185
|
+
{ __( 'Are you ready to save?' ) }
|
|
186
|
+
</strong>
|
|
187
|
+
</div>
|
|
188
|
+
<div id={ renderDialog ? dialogDescriptionId : undefined }>
|
|
189
|
+
{ additionalPrompt }
|
|
190
|
+
<p className="entities-saved-states__text-prompt--changes-count">
|
|
191
|
+
{ isDirty
|
|
192
|
+
? createInterpolateElement(
|
|
193
|
+
sprintf(
|
|
194
|
+
/* translators: %d: number of site changes waiting to be saved. */
|
|
195
|
+
_n(
|
|
196
|
+
'There is <strong>%d site change</strong> waiting to be saved.',
|
|
197
|
+
'There are <strong>%d site changes</strong> waiting to be saved.',
|
|
198
|
+
dirtyEntityRecords.length
|
|
199
|
+
),
|
|
200
|
+
dirtyEntityRecords.length
|
|
201
|
+
),
|
|
202
|
+
{ strong: <strong /> }
|
|
203
|
+
)
|
|
204
|
+
: selectItemsToSaveDescription }
|
|
205
|
+
</p>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
{ sortedPartitionedSavables.map( ( list ) => {
|
|
210
|
+
return (
|
|
211
|
+
<EntityTypeList
|
|
212
|
+
key={ list[ 0 ].name }
|
|
213
|
+
list={ list }
|
|
214
|
+
unselectedEntities={ unselectedEntities }
|
|
215
|
+
setUnselectedEntities={ setUnselectedEntities }
|
|
216
|
+
/>
|
|
217
|
+
);
|
|
218
|
+
} ) }
|
|
219
|
+
|
|
220
|
+
{ isInline && (
|
|
221
|
+
<Flex
|
|
222
|
+
direction="row"
|
|
223
|
+
justify="flex-end"
|
|
224
|
+
className="entities-saved-states__panel-footer"
|
|
225
|
+
>
|
|
226
|
+
{ actionButtons }
|
|
227
|
+
</Flex>
|
|
228
|
+
) }
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
2
|
+
@use "@wordpress/base-styles/variables" as *;
|
|
3
|
+
|
|
4
|
+
.entities-saved-states__panel-header {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
background: $white;
|
|
7
|
+
padding-left: $grid-unit-20;
|
|
8
|
+
padding-right: $grid-unit-20;
|
|
9
|
+
height: $header-height;
|
|
10
|
+
border-bottom: $border-width solid $gray-300;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.entities-saved-states__text-prompt {
|
|
14
|
+
padding: $grid-unit-20;
|
|
15
|
+
padding-bottom: $grid-unit-05;
|
|
16
|
+
.entities-saved-states__text-prompt--header {
|
|
17
|
+
display: block;
|
|
18
|
+
margin-bottom: $grid-unit-15;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.entities-saved-states__panel.is-inline {
|
|
23
|
+
.entities-saved-states__text-prompt {
|
|
24
|
+
padding: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.entities-saved-states__panel-body {
|
|
28
|
+
padding-left: 0;
|
|
29
|
+
padding-right: 0;
|
|
30
|
+
border: 0;
|
|
31
|
+
|
|
32
|
+
> h2 {
|
|
33
|
+
margin-left: -1 * $grid-unit-20;
|
|
34
|
+
margin-right: -1 * $grid-unit-20;
|
|
35
|
+
margin-bottom: 0;
|
|
36
|
+
|
|
37
|
+
button {
|
|
38
|
+
font-size: $font-size-x-small;
|
|
39
|
+
text-transform: uppercase;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.entities-saved-states__text-prompt--header-wrapper {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.entities-saved-states__text-prompt--changes-count {
|
|
49
|
+
margin-top: 0;
|
|
50
|
+
margin-bottom: $grid-unit-10;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.entities-saved-states__panel-footer {
|
|
54
|
+
margin-top: $grid-unit-20;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.entities-saved-states__change-control {
|
|
59
|
+
flex: 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.entities-saved-states__changes {
|
|
63
|
+
font-size: $default-font-size;
|
|
64
|
+
margin: $grid-unit-05 $grid-unit-20 0 $grid-unit-30;
|
|
65
|
+
list-style: disc;
|
|
66
|
+
|
|
67
|
+
li {
|
|
68
|
+
margin-bottom: $grid-unit-05;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { act, renderHook } from '@testing-library/react';
|
|
2
|
+
import { useIsDirty } from '../hooks/use-is-dirty';
|
|
3
|
+
|
|
4
|
+
jest.mock( '@wordpress/data', () => {
|
|
5
|
+
return {
|
|
6
|
+
useSelect: jest.fn().mockImplementation( ( fn ) => {
|
|
7
|
+
const select = () => {
|
|
8
|
+
return {
|
|
9
|
+
__experimentalGetDirtyEntityRecords: jest
|
|
10
|
+
.fn()
|
|
11
|
+
.mockReturnValue( [
|
|
12
|
+
{
|
|
13
|
+
kind: 'root',
|
|
14
|
+
name: 'site',
|
|
15
|
+
title: 'title',
|
|
16
|
+
property: 'property',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
kind: 'postType',
|
|
20
|
+
name: 'post',
|
|
21
|
+
title: 'title',
|
|
22
|
+
property: 'property',
|
|
23
|
+
},
|
|
24
|
+
] ),
|
|
25
|
+
getEntityRecordEdits: jest.fn().mockReturnValue( {
|
|
26
|
+
title: 'My Site',
|
|
27
|
+
description: 'My Tagline',
|
|
28
|
+
site_logo: 123,
|
|
29
|
+
site_icon: 456,
|
|
30
|
+
} ),
|
|
31
|
+
getEntityConfig: jest.fn().mockReturnValue( {
|
|
32
|
+
meta: {
|
|
33
|
+
labels: {
|
|
34
|
+
title: 'Site Title',
|
|
35
|
+
description: 'Site Tagline',
|
|
36
|
+
site_logo: 'Site Logo',
|
|
37
|
+
site_icon: 'Site Icon',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
} ),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
return fn( select );
|
|
44
|
+
} ),
|
|
45
|
+
};
|
|
46
|
+
} );
|
|
47
|
+
|
|
48
|
+
describe( 'useIsDirty', () => {
|
|
49
|
+
it( 'should calculate dirtyEntityRecords in the expected order', () => {
|
|
50
|
+
const { result } = renderHook( () => useIsDirty() );
|
|
51
|
+
expect( result.current.dirtyEntityRecords ).toEqual( [
|
|
52
|
+
{
|
|
53
|
+
kind: 'postType',
|
|
54
|
+
name: 'post',
|
|
55
|
+
property: 'property',
|
|
56
|
+
title: 'title',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
kind: 'root',
|
|
60
|
+
name: 'site',
|
|
61
|
+
property: 'title',
|
|
62
|
+
title: 'Site Title',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
kind: 'root',
|
|
66
|
+
name: 'site',
|
|
67
|
+
property: 'description',
|
|
68
|
+
title: 'Site Tagline',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
kind: 'root',
|
|
72
|
+
name: 'site',
|
|
73
|
+
property: 'site_logo',
|
|
74
|
+
title: 'Site Logo',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
kind: 'root',
|
|
78
|
+
name: 'site',
|
|
79
|
+
property: 'site_icon',
|
|
80
|
+
title: 'Site Icon',
|
|
81
|
+
},
|
|
82
|
+
] );
|
|
83
|
+
} );
|
|
84
|
+
it( 'should return `isDirty: true` when there are changes', () => {
|
|
85
|
+
const { result } = renderHook( () => useIsDirty() );
|
|
86
|
+
expect( result.current.isDirty ).toBeTruthy();
|
|
87
|
+
} );
|
|
88
|
+
it( 'should return `isDirty: false` when there are NO changes', async () => {
|
|
89
|
+
const { result } = renderHook( () => useIsDirty() );
|
|
90
|
+
act( () => {
|
|
91
|
+
result.current.setUnselectedEntities(
|
|
92
|
+
{
|
|
93
|
+
kind: 'postType',
|
|
94
|
+
name: 'post',
|
|
95
|
+
key: 'key',
|
|
96
|
+
property: 'property',
|
|
97
|
+
},
|
|
98
|
+
false
|
|
99
|
+
);
|
|
100
|
+
} );
|
|
101
|
+
act( () => {
|
|
102
|
+
result.current.setUnselectedEntities(
|
|
103
|
+
{
|
|
104
|
+
kind: 'root',
|
|
105
|
+
name: 'site',
|
|
106
|
+
key: 'key',
|
|
107
|
+
property: 'title',
|
|
108
|
+
},
|
|
109
|
+
false
|
|
110
|
+
);
|
|
111
|
+
} );
|
|
112
|
+
act( () => {
|
|
113
|
+
result.current.setUnselectedEntities(
|
|
114
|
+
{
|
|
115
|
+
kind: 'root',
|
|
116
|
+
name: 'site',
|
|
117
|
+
key: 'key',
|
|
118
|
+
property: 'description',
|
|
119
|
+
},
|
|
120
|
+
false
|
|
121
|
+
);
|
|
122
|
+
} );
|
|
123
|
+
act( () => {
|
|
124
|
+
result.current.setUnselectedEntities(
|
|
125
|
+
{
|
|
126
|
+
kind: 'root',
|
|
127
|
+
name: 'site',
|
|
128
|
+
key: 'key',
|
|
129
|
+
property: 'site_logo',
|
|
130
|
+
},
|
|
131
|
+
false
|
|
132
|
+
);
|
|
133
|
+
} );
|
|
134
|
+
act( () => {
|
|
135
|
+
result.current.setUnselectedEntities(
|
|
136
|
+
{
|
|
137
|
+
kind: 'root',
|
|
138
|
+
name: 'site',
|
|
139
|
+
key: 'key',
|
|
140
|
+
property: 'site_icon',
|
|
141
|
+
},
|
|
142
|
+
false
|
|
143
|
+
);
|
|
144
|
+
} );
|
|
145
|
+
expect( result.current.isDirty ).toBeFalsy();
|
|
146
|
+
} );
|
|
147
|
+
} );
|
package/src/dynamic-entities.ts
CHANGED
package/src/entities.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { capitalCase, pascalCase } from 'change-case';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import apiFetch from '@wordpress/api-fetch';
|
|
10
3
|
import { __unstableSerializeAndClean, parse } from '@wordpress/blocks';
|
|
11
4
|
import { __ } from '@wordpress/i18n';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
5
|
import { PostEditorAwareness } from './awareness/post-editor-awareness';
|
|
17
6
|
import { getSyncManager } from './sync';
|
|
18
7
|
import {
|
|
@@ -49,8 +38,10 @@ export const rootEntitiesConfig = [
|
|
|
49
38
|
'description',
|
|
50
39
|
'gmt_offset',
|
|
51
40
|
'home',
|
|
41
|
+
'image_max_bit_depth',
|
|
52
42
|
'image_sizes',
|
|
53
43
|
'image_size_threshold',
|
|
44
|
+
'image_strip_meta',
|
|
54
45
|
'name',
|
|
55
46
|
'site_icon',
|
|
56
47
|
'site_icon_url',
|