@wordpress/editor 14.3.0 → 14.5.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 +8 -0
- package/README.md +2 -1
- package/build/bindings/api.js +65 -0
- package/build/bindings/api.js.map +1 -0
- package/build/bindings/pattern-overrides.js +23 -13
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/bindings/post-meta.js +35 -12
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +4 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/blog-title/index.js +7 -3
- package/build/components/blog-title/index.js.map +1 -1
- package/build/components/collapsible-block-toolbar/index.js +2 -3
- package/build/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build/components/commands/index.js +8 -2
- package/build/components/commands/index.js.map +1 -1
- package/build/components/document-bar/index.js +1 -1
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +15 -3
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/back-button.js +7 -8
- package/build/components/header/back-button.js.map +1 -1
- package/build/components/header/index.js +21 -20
- package/build/components/header/index.js.map +1 -1
- package/build/components/page-attributes/order.js +1 -67
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/panel.js +1 -4
- package/build/components/page-attributes/panel.js.map +1 -1
- package/build/components/page-attributes/parent.js +6 -2
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-actions/actions.js +131 -344
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +16 -6
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-author/hook.js +10 -3
- package/build/components/post-author/hook.js.map +1 -1
- package/build/components/post-author/panel.js +2 -1
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-card-panel/index.js +9 -3
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-comments/index.js +6 -20
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-content-information/index.js +7 -1
- package/build/components/post-content-information/index.js.map +1 -1
- package/build/components/post-discussion/panel.js +2 -2
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/panel.js +1 -1
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-featured-image/index.js +3 -1
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-last-revision/index.js +2 -1
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +4 -11
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +4 -1
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +2 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-status/index.js +47 -51
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +17 -6
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +7 -1
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-template/block-theme.js +4 -4
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +8 -2
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +3 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/create-new-template.js +4 -1
- package/build/components/post-template/create-new-template.js.map +1 -1
- package/build/components/post-template/hooks.js +5 -1
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/panel.js +8 -2
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/post-trash/check.js +6 -4
- package/build/components/post-trash/check.js.map +1 -1
- package/build/components/post-url/panel.js +9 -4
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/posts-per-page/index.js +6 -2
- package/build/components/posts-per-page/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +82 -17
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +14 -18
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +15 -6
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/save-publish-panels/index.js +1 -2
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build/components/sidebar/index.js +3 -9
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/site-discussion/index.js +12 -22
- package/build/components/site-discussion/index.js.map +1 -1
- package/build/components/template-content-panel/index.js +17 -15
- package/build/components/template-content-panel/index.js.map +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js +4 -4
- package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build/components/visual-editor/index.js +7 -3
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
- package/build/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
- package/build/dataviews/actions/delete-post.js +2 -0
- package/build/dataviews/actions/delete-post.js.map +1 -1
- package/build/dataviews/actions/export-pattern.native.js +9 -0
- package/build/dataviews/actions/export-pattern.native.js.map +1 -0
- package/build/dataviews/actions/permanently-delete-post.js +107 -0
- package/build/dataviews/actions/permanently-delete-post.js.map +1 -0
- package/build/dataviews/actions/restore-post.js +112 -0
- package/build/dataviews/actions/restore-post.js.map +1 -0
- package/build/dataviews/actions/trash-post.js +142 -0
- package/build/dataviews/actions/trash-post.js.map +1 -0
- package/build/dataviews/store/private-actions.js +45 -0
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/dataviews/store/private-selectors.js +10 -10
- package/build/dataviews/store/private-selectors.js.map +1 -1
- package/build/dataviews/store/reducer.js +15 -1
- package/build/dataviews/store/reducer.js.map +1 -1
- package/build/dataviews/types.js.map +1 -1
- package/build/hooks/pattern-overrides.js +1 -1
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/private-apis.js +3 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +16 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +8 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +33 -2
- package/build/store/private-selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +35 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/bindings/api.js +57 -0
- package/build-module/bindings/api.js.map +1 -0
- package/build-module/bindings/pattern-overrides.js +23 -13
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/bindings/post-meta.js +35 -12
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +4 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/blog-title/index.js +7 -3
- package/build-module/components/blog-title/index.js.map +1 -1
- package/build-module/components/collapsible-block-toolbar/index.js +1 -2
- package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build-module/components/commands/index.js +8 -2
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +1 -1
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +15 -3
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/back-button.js +5 -7
- package/build-module/components/header/back-button.js.map +1 -1
- package/build-module/components/header/index.js +21 -22
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/page-attributes/order.js +4 -70
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/page-attributes/panel.js +1 -6
- package/build-module/components/page-attributes/panel.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +7 -3
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/post-actions/actions.js +137 -350
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +16 -6
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-author/hook.js +10 -3
- package/build-module/components/post-author/hook.js.map +1 -1
- package/build-module/components/post-author/panel.js +2 -1
- package/build-module/components/post-author/panel.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +9 -3
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-comments/index.js +8 -24
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-content-information/index.js +7 -1
- package/build-module/components/post-content-information/index.js.map +1 -1
- package/build-module/components/post-discussion/panel.js +3 -3
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +1 -1
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +3 -1
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +2 -1
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +4 -11
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +4 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +2 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-status/index.js +49 -53
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +17 -6
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +7 -1
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +4 -4
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +8 -2
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +3 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/create-new-template.js +4 -1
- package/build-module/components/post-template/create-new-template.js.map +1 -1
- package/build-module/components/post-template/hooks.js +5 -1
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/panel.js +8 -2
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/post-trash/check.js +6 -4
- package/build-module/components/post-trash/check.js.map +1 -1
- package/build-module/components/post-url/panel.js +10 -7
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/posts-per-page/index.js +6 -2
- package/build-module/components/posts-per-page/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +84 -19
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +15 -19
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +15 -6
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +1 -2
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -9
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/site-discussion/index.js +14 -24
- package/build-module/components/site-discussion/index.js.map +1 -1
- package/build-module/components/template-content-panel/index.js +18 -16
- package/build-module/components/template-content-panel/index.js.map +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js +4 -4
- package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/visual-editor/index.js +7 -3
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
- package/build-module/components/visual-editor/use-select-nearest-editable-block.js.map +1 -0
- package/build-module/dataviews/actions/delete-post.js +2 -0
- package/build-module/dataviews/actions/delete-post.js.map +1 -1
- package/build-module/dataviews/actions/export-pattern.native.js +3 -0
- package/build-module/dataviews/actions/export-pattern.native.js.map +1 -0
- package/build-module/dataviews/actions/permanently-delete-post.js +99 -0
- package/build-module/dataviews/actions/permanently-delete-post.js.map +1 -0
- package/build-module/dataviews/actions/restore-post.js +104 -0
- package/build-module/dataviews/actions/restore-post.js.map +1 -0
- package/build-module/dataviews/actions/trash-post.js +135 -0
- package/build-module/dataviews/actions/trash-post.js.map +1 -0
- package/build-module/dataviews/store/private-actions.js +40 -0
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/dataviews/store/private-selectors.js +8 -9
- package/build-module/dataviews/store/private-selectors.js.map +1 -1
- package/build-module/dataviews/store/reducer.js +15 -1
- package/build-module/dataviews/store/reducer.js.map +1 -1
- package/build-module/dataviews/types.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +1 -1
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +3 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +16 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +8 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +32 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +36 -3
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +97 -45
- package/build-style/style.css +97 -45
- package/build-types/bindings/api.d.ts +25 -0
- package/build-types/bindings/api.d.ts.map +1 -0
- package/build-types/bindings/pattern-overrides.d.ts +5 -6
- package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
- package/build-types/bindings/post-meta.d.ts +11 -7
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/autocompleters/user.d.ts +2 -2
- package/build-types/components/autocompleters/user.d.ts.map +1 -1
- package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts.map +1 -1
- package/build-types/components/blog-title/index.d.ts.map +1 -1
- package/build-types/components/collapsible-block-toolbar/index.d.ts +1 -2
- package/build-types/components/collapsible-block-toolbar/index.d.ts.map +1 -1
- package/build-types/components/commands/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/document-outline/check.d.ts.map +1 -1
- package/build-types/components/document-outline/index.d.ts.map +1 -1
- package/build-types/components/editor-history/redo.d.ts +1 -1
- package/build-types/components/editor-history/undo.d.ts +1 -1
- package/build-types/components/editor-notices/index.d.ts.map +1 -1
- package/build-types/components/editor-snackbars/index.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/header/back-button.d.ts +1 -0
- package/build-types/components/header/back-button.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -1
- package/build-types/components/media-categories/index.d.ts.map +1 -1
- package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -1
- package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
- package/build-types/components/page-attributes/check.d.ts.map +1 -1
- package/build-types/components/page-attributes/order.d.ts +1 -1
- package/build-types/components/page-attributes/order.d.ts.map +1 -1
- package/build-types/components/page-attributes/panel.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/plugin-document-setting-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-post-status-info/index.d.ts.map +1 -1
- package/build-types/components/plugin-pre-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
- package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts.map +1 -1
- package/build-types/components/post-actions/actions.d.ts.map +1 -1
- package/build-types/components/post-actions/index.d.ts.map +1 -1
- package/build-types/components/post-author/check.d.ts.map +1 -1
- package/build-types/components/post-author/hook.d.ts +1 -1
- package/build-types/components/post-author/hook.d.ts.map +1 -1
- package/build-types/components/post-author/index.d.ts.map +1 -1
- package/build-types/components/post-author/panel.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-comments/index.d.ts.map +1 -1
- package/build-types/components/post-content-information/index.d.ts.map +1 -1
- package/build-types/components/post-discussion/panel.d.ts.map +1 -1
- package/build-types/components/post-excerpt/check.d.ts.map +1 -1
- package/build-types/components/post-excerpt/index.d.ts.map +1 -1
- package/build-types/components/post-excerpt/panel.d.ts.map +1 -1
- package/build-types/components/post-excerpt/plugin.d.ts.map +1 -1
- package/build-types/components/post-featured-image/check.d.ts.map +1 -1
- package/build-types/components/post-featured-image/panel.d.ts.map +1 -1
- package/build-types/components/post-format/index.d.ts.map +1 -1
- package/build-types/components/post-format/panel.d.ts.map +1 -1
- package/build-types/components/post-last-revision/check.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/panel.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-pending-status/check.d.ts.map +1 -1
- package/build-types/components/post-pending-status/index.d.ts.map +1 -1
- package/build-types/components/post-preview-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
- package/build-types/components/post-saved-state/index.d.ts +1 -1
- package/build-types/components/post-saved-state/index.d.ts.map +1 -1
- package/build-types/components/post-schedule/check.d.ts.map +1 -1
- package/build-types/components/post-schedule/index.d.ts.map +1 -1
- package/build-types/components/post-schedule/label.d.ts.map +1 -1
- package/build-types/components/post-schedule/panel.d.ts.map +1 -1
- package/build-types/components/post-slug/check.d.ts.map +1 -1
- package/build-types/components/post-slug/index.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts +2 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-sticky/check.d.ts.map +1 -1
- package/build-types/components/post-sticky/index.d.ts.map +1 -1
- package/build-types/components/post-switch-to-draft-button/index.d.ts.map +1 -1
- package/build-types/components/post-sync-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +9 -7
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +13 -11
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/panel.d.ts.map +1 -1
- package/build-types/components/post-text-editor/index.d.ts.map +1 -1
- package/build-types/components/post-trash/check.d.ts.map +1 -1
- package/build-types/components/post-trash/index.d.ts.map +1 -1
- package/build-types/components/post-type-support-check/index.d.ts.map +1 -1
- package/build-types/components/post-url/check.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/post-url/label.d.ts.map +1 -1
- package/build-types/components/post-url/panel.d.ts.map +1 -1
- package/build-types/components/post-visibility/check.d.ts.map +1 -1
- package/build-types/components/post-visibility/index.d.ts.map +1 -1
- package/build-types/components/posts-per-page/index.d.ts.map +1 -1
- package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/site-discussion/index.d.ts.map +1 -1
- package/build-types/components/template-content-panel/index.d.ts +1 -3
- package/build-types/components/template-content-panel/index.d.ts.map +1 -1
- package/build-types/components/theme-support-check/index.d.ts.map +1 -1
- package/build-types/components/time-to-read/index.d.ts.map +1 -1
- package/build-types/components/unsaved-changes-warning/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +1 -1
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/use-select-nearest-editable-block.d.ts.map +1 -0
- package/build-types/components/word-count/index.d.ts.map +1 -1
- package/build-types/dataviews/actions/delete-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/export-pattern.native.d.ts +3 -0
- package/build-types/dataviews/actions/export-pattern.native.d.ts.map +1 -0
- package/build-types/dataviews/actions/permanently-delete-post.d.ts +5 -0
- package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/restore-post.d.ts +5 -0
- package/build-types/dataviews/actions/restore-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/trash-post.d.ts +5 -0
- package/build-types/dataviews/actions/trash-post.d.ts.map +1 -0
- package/build-types/dataviews/api.d.ts +1 -1
- package/build-types/dataviews/api.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts +8 -3
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/dataviews/store/private-selectors.d.ts +2 -2
- package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
- package/build-types/dataviews/store/reducer.d.ts +4 -1
- package/build-types/dataviews/store/reducer.d.ts.map +1 -1
- package/build-types/dataviews/types.d.ts +9 -0
- package/build-types/dataviews/types.d.ts.map +1 -1
- package/build-types/hooks/custom-sources-backwards-compatibility.d.ts +1 -1
- package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
- package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +11 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +1 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +0 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +38 -37
- package/src/bindings/api.js +57 -0
- package/src/bindings/pattern-overrides.js +28 -17
- package/src/bindings/post-meta.js +39 -14
- package/src/components/block-settings-menu/content-only-settings-menu.js +4 -4
- package/src/components/blog-title/index.js +8 -3
- package/src/components/collapsible-block-toolbar/index.js +1 -3
- package/src/components/collapsible-block-toolbar/style.scss +0 -3
- package/src/components/commands/index.js +4 -2
- package/src/components/document-bar/index.js +1 -1
- package/src/components/document-bar/style.scss +2 -6
- package/src/components/document-tools/style.scss +4 -4
- package/src/components/editor-interface/style.scss +9 -0
- package/src/components/global-styles-provider/index.js +22 -11
- package/src/components/header/back-button.js +6 -6
- package/src/components/header/index.js +27 -27
- package/src/components/header/style.scss +64 -21
- package/src/components/inserter-sidebar/style.scss +1 -6
- package/src/components/list-view-sidebar/style.scss +4 -0
- package/src/components/page-attributes/order.js +3 -77
- package/src/components/page-attributes/panel.js +1 -7
- package/src/components/page-attributes/parent.js +25 -7
- package/src/components/post-actions/actions.js +158 -463
- package/src/components/post-actions/index.js +19 -7
- package/src/components/post-author/hook.js +11 -3
- package/src/components/post-author/panel.js +3 -1
- package/src/components/post-card-panel/index.js +9 -3
- package/src/components/post-comments/index.js +8 -21
- package/src/components/post-content-information/index.js +7 -1
- package/src/components/post-discussion/panel.js +5 -3
- package/src/components/post-excerpt/panel.js +2 -1
- package/src/components/post-featured-image/index.js +5 -1
- package/src/components/post-last-revision/index.js +1 -0
- package/src/components/post-panel-row/style.scss +0 -1
- package/src/components/post-publish-button/index.js +4 -17
- package/src/components/post-publish-panel/maybe-category-panel.js +4 -1
- package/src/components/post-publish-panel/maybe-tags-panel.js +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-status/index.js +29 -51
- package/src/components/post-taxonomies/flat-term-selector.js +19 -5
- package/src/components/post-taxonomies/index.js +8 -1
- package/src/components/post-template/block-theme.js +5 -1
- package/src/components/post-template/classic-theme.js +8 -3
- package/src/components/post-template/create-new-template-modal.js +7 -1
- package/src/components/post-template/create-new-template.js +4 -1
- package/src/components/post-template/hooks.js +8 -2
- package/src/components/post-template/panel.js +10 -2
- package/src/components/post-trash/check.js +9 -5
- package/src/components/post-url/panel.js +15 -4
- package/src/components/posts-per-page/index.js +7 -2
- package/src/components/preview-dropdown/index.js +113 -35
- package/src/components/preview-dropdown/style.scss +5 -0
- package/src/components/provider/disable-non-page-content-blocks.js +27 -24
- package/src/components/provider/use-block-editor-settings.js +15 -6
- package/src/components/save-publish-panels/index.js +1 -4
- package/src/components/sidebar/index.js +2 -5
- package/src/components/site-discussion/index.js +15 -22
- package/src/components/template-content-panel/index.js +37 -21
- package/src/components/visual-editor/edit-template-blocks-notification.js +5 -1
- package/src/components/visual-editor/index.js +13 -8
- package/src/components/visual-editor/style.scss +1 -4
- package/src/{hooks → components/visual-editor}/use-select-nearest-editable-block.js +1 -1
- package/src/dataviews/actions/delete-post.tsx +2 -0
- package/src/dataviews/actions/export-pattern.native.tsx +3 -0
- package/src/dataviews/actions/permanently-delete-post.tsx +116 -0
- package/src/dataviews/actions/restore-post.tsx +134 -0
- package/src/dataviews/actions/trash-post.tsx +196 -0
- package/src/dataviews/store/private-actions.ts +68 -0
- package/src/dataviews/store/private-selectors.ts +9 -17
- package/src/dataviews/store/reducer.ts +20 -1
- package/src/dataviews/types.ts +11 -0
- package/src/hooks/pattern-overrides.js +1 -1
- package/src/index.js +0 -1
- package/src/private-apis.js +6 -2
- package/src/store/actions.js +36 -13
- package/src/store/private-actions.js +8 -4
- package/src/store/private-selectors.js +45 -2
- package/src/store/test/actions.js +9 -3
- package/src/store/test/private-selectors.js +78 -0
- package/src/utils/media-upload/index.js +38 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/bindings/index.js +0 -22
- package/build/bindings/index.js.map +0 -1
- package/build/dataviews/actions/index.js +0 -32
- package/build/dataviews/actions/index.js.map +0 -1
- package/build/hooks/use-select-nearest-editable-block.js.map +0 -1
- package/build/store/utils/get-filtered-template-parts.js +0 -71
- package/build/store/utils/get-filtered-template-parts.js.map +0 -1
- package/build/utils/set-nested-value.js +0 -44
- package/build/utils/set-nested-value.js.map +0 -1
- package/build-module/bindings/index.js +0 -17
- package/build-module/bindings/index.js.map +0 -1
- package/build-module/dataviews/actions/index.js +0 -24
- package/build-module/dataviews/actions/index.js.map +0 -1
- package/build-module/hooks/use-select-nearest-editable-block.js.map +0 -1
- package/build-module/store/utils/get-filtered-template-parts.js +0 -64
- package/build-module/store/utils/get-filtered-template-parts.js.map +0 -1
- package/build-module/utils/set-nested-value.js +0 -38
- package/build-module/utils/set-nested-value.js.map +0 -1
- package/build-types/bindings/index.d.ts +0 -2
- package/build-types/bindings/index.d.ts.map +0 -1
- package/build-types/dataviews/actions/index.d.ts +0 -2
- package/build-types/dataviews/actions/index.d.ts.map +0 -1
- package/build-types/hooks/use-select-nearest-editable-block.d.ts.map +0 -1
- package/build-types/store/utils/get-filtered-template-parts.d.ts +0 -3
- package/build-types/store/utils/get-filtered-template-parts.d.ts.map +0 -1
- package/build-types/utils/set-nested-value.d.ts +0 -20
- package/build-types/utils/set-nested-value.d.ts.map +0 -1
- package/src/bindings/index.js +0 -15
- package/src/components/document-outline/test/__snapshots__/index.js.snap +0 -111
- package/src/components/document-outline/test/index.js +0 -185
- package/src/dataviews/actions/index.ts +0 -25
- package/src/store/utils/get-filtered-template-parts.js +0 -69
- package/src/store/utils/test/get-filtered-template-parts.js +0 -189
- package/src/utils/set-nested-value.js +0 -39
- /package/build-types/{hooks → components/visual-editor}/use-select-nearest-editable-block.d.ts +0 -0
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { external
|
|
4
|
+
import { external } from '@wordpress/icons';
|
|
5
5
|
import { addQueryArgs } from '@wordpress/url';
|
|
6
|
-
import { useDispatch, useSelect
|
|
6
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
7
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
-
import { __,
|
|
9
|
+
import { __, sprintf, _x } from '@wordpress/i18n';
|
|
10
10
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
-
import { useMemo, useState } from '@wordpress/element';
|
|
11
|
+
import { useMemo, useState, useEffect } from '@wordpress/element';
|
|
12
12
|
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
13
13
|
import { parse } from '@wordpress/blocks';
|
|
14
|
-
import { DataForm } from '@wordpress/dataviews';
|
|
14
|
+
import { DataForm, isItemValid } from '@wordpress/dataviews';
|
|
15
15
|
import {
|
|
16
16
|
Button,
|
|
17
17
|
TextControl,
|
|
18
|
-
__experimentalText as Text,
|
|
19
18
|
__experimentalHStack as HStack,
|
|
20
19
|
__experimentalVStack as VStack,
|
|
21
20
|
} from '@wordpress/components';
|
|
@@ -38,19 +37,29 @@ import { getItemTitle } from '../../dataviews/actions/utils';
|
|
|
38
37
|
const { PATTERN_TYPES, CreatePatternModalContents, useDuplicatePatternProps } =
|
|
39
38
|
unlock( patternsPrivateApis );
|
|
40
39
|
|
|
41
|
-
// TODO: this should be shared with other components (
|
|
40
|
+
// TODO: this should be shared with other components (see post-fields in edit-site).
|
|
42
41
|
const fields = [
|
|
43
42
|
{
|
|
44
43
|
type: 'text',
|
|
45
|
-
header: __( 'Title' ),
|
|
46
44
|
id: 'title',
|
|
45
|
+
label: __( 'Title' ),
|
|
47
46
|
placeholder: __( 'No title' ),
|
|
48
47
|
getValue: ( { item } ) => item.title,
|
|
49
48
|
},
|
|
49
|
+
{
|
|
50
|
+
type: 'integer',
|
|
51
|
+
id: 'menu_order',
|
|
52
|
+
label: __( 'Order' ),
|
|
53
|
+
description: __( 'Determines the order of pages.' ),
|
|
54
|
+
},
|
|
50
55
|
];
|
|
51
56
|
|
|
52
|
-
const
|
|
53
|
-
|
|
57
|
+
const formDuplicateAction = {
|
|
58
|
+
fields: [ 'title' ],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const formOrderAction = {
|
|
62
|
+
fields: [ 'menu_order' ],
|
|
54
63
|
};
|
|
55
64
|
|
|
56
65
|
/**
|
|
@@ -72,404 +81,6 @@ function isTemplateRemovable( template ) {
|
|
|
72
81
|
);
|
|
73
82
|
}
|
|
74
83
|
|
|
75
|
-
const trashPostAction = {
|
|
76
|
-
id: 'move-to-trash',
|
|
77
|
-
label: __( 'Move to Trash' ),
|
|
78
|
-
isPrimary: true,
|
|
79
|
-
icon: trash,
|
|
80
|
-
isEligible( item ) {
|
|
81
|
-
return ! [ 'auto-draft', 'trash' ].includes( item.status );
|
|
82
|
-
},
|
|
83
|
-
supportsBulk: true,
|
|
84
|
-
hideModalHeader: true,
|
|
85
|
-
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
86
|
-
const [ isBusy, setIsBusy ] = useState( false );
|
|
87
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
88
|
-
useDispatch( noticesStore );
|
|
89
|
-
const { deleteEntityRecord } = useDispatch( coreStore );
|
|
90
|
-
return (
|
|
91
|
-
<VStack spacing="5">
|
|
92
|
-
<Text>
|
|
93
|
-
{ items.length === 1
|
|
94
|
-
? sprintf(
|
|
95
|
-
// translators: %s: The item's title.
|
|
96
|
-
__(
|
|
97
|
-
'Are you sure you want to move to trash "%s"?'
|
|
98
|
-
),
|
|
99
|
-
getItemTitle( items[ 0 ] )
|
|
100
|
-
)
|
|
101
|
-
: sprintf(
|
|
102
|
-
// translators: %d: The number of items (2 or more).
|
|
103
|
-
_n(
|
|
104
|
-
'Are you sure you want to move to trash %d item?',
|
|
105
|
-
'Are you sure you want to move to trash %d items?',
|
|
106
|
-
items.length
|
|
107
|
-
),
|
|
108
|
-
items.length
|
|
109
|
-
) }
|
|
110
|
-
</Text>
|
|
111
|
-
<HStack justify="right">
|
|
112
|
-
<Button
|
|
113
|
-
variant="tertiary"
|
|
114
|
-
onClick={ closeModal }
|
|
115
|
-
disabled={ isBusy }
|
|
116
|
-
accessibleWhenDisabled
|
|
117
|
-
>
|
|
118
|
-
{ __( 'Cancel' ) }
|
|
119
|
-
</Button>
|
|
120
|
-
<Button
|
|
121
|
-
variant="primary"
|
|
122
|
-
onClick={ async () => {
|
|
123
|
-
setIsBusy( true );
|
|
124
|
-
const promiseResult = await Promise.allSettled(
|
|
125
|
-
items.map( ( item ) =>
|
|
126
|
-
deleteEntityRecord(
|
|
127
|
-
'postType',
|
|
128
|
-
item.type,
|
|
129
|
-
item.id,
|
|
130
|
-
{},
|
|
131
|
-
{ throwOnError: true }
|
|
132
|
-
)
|
|
133
|
-
)
|
|
134
|
-
);
|
|
135
|
-
// If all the promises were fulfilled with success.
|
|
136
|
-
if (
|
|
137
|
-
promiseResult.every(
|
|
138
|
-
( { status } ) => status === 'fulfilled'
|
|
139
|
-
)
|
|
140
|
-
) {
|
|
141
|
-
let successMessage;
|
|
142
|
-
if ( promiseResult.length === 1 ) {
|
|
143
|
-
successMessage = sprintf(
|
|
144
|
-
/* translators: The item's title. */
|
|
145
|
-
__( '"%s" moved to trash.' ),
|
|
146
|
-
getItemTitle( items[ 0 ] )
|
|
147
|
-
);
|
|
148
|
-
} else {
|
|
149
|
-
successMessage = sprintf(
|
|
150
|
-
/* translators: The number of items. */
|
|
151
|
-
_n(
|
|
152
|
-
'%s item moved to trash.',
|
|
153
|
-
'%s items moved to trash.',
|
|
154
|
-
items.length
|
|
155
|
-
),
|
|
156
|
-
items.length
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
createSuccessNotice( successMessage, {
|
|
160
|
-
type: 'snackbar',
|
|
161
|
-
id: 'move-to-trash-action',
|
|
162
|
-
} );
|
|
163
|
-
} else {
|
|
164
|
-
// If there was at least one failure.
|
|
165
|
-
let errorMessage;
|
|
166
|
-
// If we were trying to delete a single item.
|
|
167
|
-
if ( promiseResult.length === 1 ) {
|
|
168
|
-
if ( promiseResult[ 0 ].reason?.message ) {
|
|
169
|
-
errorMessage =
|
|
170
|
-
promiseResult[ 0 ].reason.message;
|
|
171
|
-
} else {
|
|
172
|
-
errorMessage = __(
|
|
173
|
-
'An error occurred while moving to trash the item.'
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
// If we were trying to delete multiple items.
|
|
177
|
-
} else {
|
|
178
|
-
const errorMessages = new Set();
|
|
179
|
-
const failedPromises = promiseResult.filter(
|
|
180
|
-
( { status } ) => status === 'rejected'
|
|
181
|
-
);
|
|
182
|
-
for ( const failedPromise of failedPromises ) {
|
|
183
|
-
if ( failedPromise.reason?.message ) {
|
|
184
|
-
errorMessages.add(
|
|
185
|
-
failedPromise.reason.message
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if ( errorMessages.size === 0 ) {
|
|
190
|
-
errorMessage = __(
|
|
191
|
-
'An error occurred while moving to trash the items.'
|
|
192
|
-
);
|
|
193
|
-
} else if ( errorMessages.size === 1 ) {
|
|
194
|
-
errorMessage = sprintf(
|
|
195
|
-
/* translators: %s: an error message */
|
|
196
|
-
__(
|
|
197
|
-
'An error occurred while moving to trash the item: %s'
|
|
198
|
-
),
|
|
199
|
-
[ ...errorMessages ][ 0 ]
|
|
200
|
-
);
|
|
201
|
-
} else {
|
|
202
|
-
errorMessage = sprintf(
|
|
203
|
-
/* translators: %s: a list of comma separated error messages */
|
|
204
|
-
__(
|
|
205
|
-
'Some errors occurred while moving to trash the items: %s'
|
|
206
|
-
),
|
|
207
|
-
[ ...errorMessages ].join( ',' )
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
createErrorNotice( errorMessage, {
|
|
212
|
-
type: 'snackbar',
|
|
213
|
-
} );
|
|
214
|
-
}
|
|
215
|
-
if ( onActionPerformed ) {
|
|
216
|
-
onActionPerformed( items );
|
|
217
|
-
}
|
|
218
|
-
setIsBusy( false );
|
|
219
|
-
closeModal();
|
|
220
|
-
} }
|
|
221
|
-
isBusy={ isBusy }
|
|
222
|
-
disabled={ isBusy }
|
|
223
|
-
accessibleWhenDisabled
|
|
224
|
-
>
|
|
225
|
-
{ __( 'Trash' ) }
|
|
226
|
-
</Button>
|
|
227
|
-
</HStack>
|
|
228
|
-
</VStack>
|
|
229
|
-
);
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
function useCanUserEligibilityCheckPostType( capability, resource, action ) {
|
|
234
|
-
const registry = useRegistry();
|
|
235
|
-
return useMemo(
|
|
236
|
-
() => ( {
|
|
237
|
-
...action,
|
|
238
|
-
isEligible( item ) {
|
|
239
|
-
return (
|
|
240
|
-
action.isEligible( item ) &&
|
|
241
|
-
registry
|
|
242
|
-
.select( coreStore )
|
|
243
|
-
.canUser( capability, resource, item.id )
|
|
244
|
-
);
|
|
245
|
-
},
|
|
246
|
-
} ),
|
|
247
|
-
[ action, registry, capability, resource ]
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function useTrashPostAction( resource ) {
|
|
252
|
-
return useCanUserEligibilityCheckPostType(
|
|
253
|
-
'delete',
|
|
254
|
-
resource,
|
|
255
|
-
trashPostAction
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const permanentlyDeletePostAction = {
|
|
260
|
-
id: 'permanently-delete',
|
|
261
|
-
label: __( 'Permanently delete' ),
|
|
262
|
-
supportsBulk: true,
|
|
263
|
-
isEligible( { status } ) {
|
|
264
|
-
return status === 'trash';
|
|
265
|
-
},
|
|
266
|
-
async callback( posts, { registry, onActionPerformed } ) {
|
|
267
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
268
|
-
registry.dispatch( noticesStore );
|
|
269
|
-
const { deleteEntityRecord } = registry.dispatch( coreStore );
|
|
270
|
-
const promiseResult = await Promise.allSettled(
|
|
271
|
-
posts.map( ( post ) => {
|
|
272
|
-
return deleteEntityRecord(
|
|
273
|
-
'postType',
|
|
274
|
-
post.type,
|
|
275
|
-
post.id,
|
|
276
|
-
{ force: true },
|
|
277
|
-
{ throwOnError: true }
|
|
278
|
-
);
|
|
279
|
-
} )
|
|
280
|
-
);
|
|
281
|
-
// If all the promises were fulfilled with success.
|
|
282
|
-
if ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {
|
|
283
|
-
let successMessage;
|
|
284
|
-
if ( promiseResult.length === 1 ) {
|
|
285
|
-
successMessage = sprintf(
|
|
286
|
-
/* translators: The posts's title. */
|
|
287
|
-
__( '"%s" permanently deleted.' ),
|
|
288
|
-
getItemTitle( posts[ 0 ] )
|
|
289
|
-
);
|
|
290
|
-
} else {
|
|
291
|
-
successMessage = __( 'The posts were permanently deleted.' );
|
|
292
|
-
}
|
|
293
|
-
createSuccessNotice( successMessage, {
|
|
294
|
-
type: 'snackbar',
|
|
295
|
-
id: 'permanently-delete-post-action',
|
|
296
|
-
} );
|
|
297
|
-
onActionPerformed?.( posts );
|
|
298
|
-
} else {
|
|
299
|
-
// If there was at lease one failure.
|
|
300
|
-
let errorMessage;
|
|
301
|
-
// If we were trying to permanently delete a single post.
|
|
302
|
-
if ( promiseResult.length === 1 ) {
|
|
303
|
-
if ( promiseResult[ 0 ].reason?.message ) {
|
|
304
|
-
errorMessage = promiseResult[ 0 ].reason.message;
|
|
305
|
-
} else {
|
|
306
|
-
errorMessage = __(
|
|
307
|
-
'An error occurred while permanently deleting the post.'
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
// If we were trying to permanently delete multiple posts
|
|
311
|
-
} else {
|
|
312
|
-
const errorMessages = new Set();
|
|
313
|
-
const failedPromises = promiseResult.filter(
|
|
314
|
-
( { status } ) => status === 'rejected'
|
|
315
|
-
);
|
|
316
|
-
for ( const failedPromise of failedPromises ) {
|
|
317
|
-
if ( failedPromise.reason?.message ) {
|
|
318
|
-
errorMessages.add( failedPromise.reason.message );
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
if ( errorMessages.size === 0 ) {
|
|
322
|
-
errorMessage = __(
|
|
323
|
-
'An error occurred while permanently deleting the posts.'
|
|
324
|
-
);
|
|
325
|
-
} else if ( errorMessages.size === 1 ) {
|
|
326
|
-
errorMessage = sprintf(
|
|
327
|
-
/* translators: %s: an error message */
|
|
328
|
-
__(
|
|
329
|
-
'An error occurred while permanently deleting the posts: %s'
|
|
330
|
-
),
|
|
331
|
-
[ ...errorMessages ][ 0 ]
|
|
332
|
-
);
|
|
333
|
-
} else {
|
|
334
|
-
errorMessage = sprintf(
|
|
335
|
-
/* translators: %s: a list of comma separated error messages */
|
|
336
|
-
__(
|
|
337
|
-
'Some errors occurred while permanently deleting the posts: %s'
|
|
338
|
-
),
|
|
339
|
-
[ ...errorMessages ].join( ',' )
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
createErrorNotice( errorMessage, {
|
|
344
|
-
type: 'snackbar',
|
|
345
|
-
} );
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
function usePermanentlyDeletePostAction( resource ) {
|
|
351
|
-
return useCanUserEligibilityCheckPostType(
|
|
352
|
-
'delete',
|
|
353
|
-
resource,
|
|
354
|
-
permanentlyDeletePostAction
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const restorePostAction = {
|
|
359
|
-
id: 'restore',
|
|
360
|
-
label: __( 'Restore' ),
|
|
361
|
-
isPrimary: true,
|
|
362
|
-
icon: backup,
|
|
363
|
-
supportsBulk: true,
|
|
364
|
-
isEligible( { status } ) {
|
|
365
|
-
return status === 'trash';
|
|
366
|
-
},
|
|
367
|
-
async callback( posts, { registry, onActionPerformed } ) {
|
|
368
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
369
|
-
registry.dispatch( noticesStore );
|
|
370
|
-
const { editEntityRecord, saveEditedEntityRecord } =
|
|
371
|
-
registry.dispatch( coreStore );
|
|
372
|
-
await Promise.allSettled(
|
|
373
|
-
posts.map( ( post ) => {
|
|
374
|
-
return editEntityRecord( 'postType', post.type, post.id, {
|
|
375
|
-
status: 'draft',
|
|
376
|
-
} );
|
|
377
|
-
} )
|
|
378
|
-
);
|
|
379
|
-
const promiseResult = await Promise.allSettled(
|
|
380
|
-
posts.map( ( post ) => {
|
|
381
|
-
return saveEditedEntityRecord( 'postType', post.type, post.id, {
|
|
382
|
-
throwOnError: true,
|
|
383
|
-
} );
|
|
384
|
-
} )
|
|
385
|
-
);
|
|
386
|
-
|
|
387
|
-
if ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {
|
|
388
|
-
let successMessage;
|
|
389
|
-
if ( posts.length === 1 ) {
|
|
390
|
-
successMessage = sprintf(
|
|
391
|
-
/* translators: The number of posts. */
|
|
392
|
-
__( '"%s" has been restored.' ),
|
|
393
|
-
getItemTitle( posts[ 0 ] )
|
|
394
|
-
);
|
|
395
|
-
} else if ( posts[ 0 ].type === 'page' ) {
|
|
396
|
-
successMessage = sprintf(
|
|
397
|
-
/* translators: The number of posts. */
|
|
398
|
-
__( '%d pages have been restored.' ),
|
|
399
|
-
posts.length
|
|
400
|
-
);
|
|
401
|
-
} else {
|
|
402
|
-
successMessage = sprintf(
|
|
403
|
-
/* translators: The number of posts. */
|
|
404
|
-
__( '%d posts have been restored.' ),
|
|
405
|
-
posts.length
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
createSuccessNotice( successMessage, {
|
|
409
|
-
type: 'snackbar',
|
|
410
|
-
id: 'restore-post-action',
|
|
411
|
-
} );
|
|
412
|
-
if ( onActionPerformed ) {
|
|
413
|
-
onActionPerformed( posts );
|
|
414
|
-
}
|
|
415
|
-
} else {
|
|
416
|
-
// If there was at lease one failure.
|
|
417
|
-
let errorMessage;
|
|
418
|
-
// If we were trying to move a single post to the trash.
|
|
419
|
-
if ( promiseResult.length === 1 ) {
|
|
420
|
-
if ( promiseResult[ 0 ].reason?.message ) {
|
|
421
|
-
errorMessage = promiseResult[ 0 ].reason.message;
|
|
422
|
-
} else {
|
|
423
|
-
errorMessage = __(
|
|
424
|
-
'An error occurred while restoring the post.'
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
// If we were trying to move multiple posts to the trash
|
|
428
|
-
} else {
|
|
429
|
-
const errorMessages = new Set();
|
|
430
|
-
const failedPromises = promiseResult.filter(
|
|
431
|
-
( { status } ) => status === 'rejected'
|
|
432
|
-
);
|
|
433
|
-
for ( const failedPromise of failedPromises ) {
|
|
434
|
-
if ( failedPromise.reason?.message ) {
|
|
435
|
-
errorMessages.add( failedPromise.reason.message );
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
if ( errorMessages.size === 0 ) {
|
|
439
|
-
errorMessage = __(
|
|
440
|
-
'An error occurred while restoring the posts.'
|
|
441
|
-
);
|
|
442
|
-
} else if ( errorMessages.size === 1 ) {
|
|
443
|
-
errorMessage = sprintf(
|
|
444
|
-
/* translators: %s: an error message */
|
|
445
|
-
__( 'An error occurred while restoring the posts: %s' ),
|
|
446
|
-
[ ...errorMessages ][ 0 ]
|
|
447
|
-
);
|
|
448
|
-
} else {
|
|
449
|
-
errorMessage = sprintf(
|
|
450
|
-
/* translators: %s: a list of comma separated error messages */
|
|
451
|
-
__(
|
|
452
|
-
'Some errors occurred while restoring the posts: %s'
|
|
453
|
-
),
|
|
454
|
-
[ ...errorMessages ].join( ',' )
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
createErrorNotice( errorMessage, {
|
|
459
|
-
type: 'snackbar',
|
|
460
|
-
} );
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
function useRestorePostAction( resource ) {
|
|
466
|
-
return useCanUserEligibilityCheckPostType(
|
|
467
|
-
'update',
|
|
468
|
-
resource,
|
|
469
|
-
restorePostAction
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
84
|
const viewPostAction = {
|
|
474
85
|
id: 'view-post',
|
|
475
86
|
label: __( 'View' ),
|
|
@@ -536,11 +147,15 @@ const renamePostAction = {
|
|
|
536
147
|
...Object.values( PATTERN_TYPES ),
|
|
537
148
|
].includes( post.type )
|
|
538
149
|
) {
|
|
539
|
-
return
|
|
150
|
+
return post.permissions?.update;
|
|
540
151
|
}
|
|
541
152
|
// In the case of templates, we can only rename custom templates.
|
|
542
153
|
if ( post.type === TEMPLATE_POST_TYPE ) {
|
|
543
|
-
return
|
|
154
|
+
return (
|
|
155
|
+
isTemplateRemovable( post ) &&
|
|
156
|
+
post.is_custom &&
|
|
157
|
+
post.permissions?.update
|
|
158
|
+
);
|
|
544
159
|
}
|
|
545
160
|
// Make necessary checks for template parts and patterns.
|
|
546
161
|
const isTemplatePart = post.type === TEMPLATE_PART_POST_TYPE;
|
|
@@ -552,7 +167,7 @@ const renamePostAction = {
|
|
|
552
167
|
isUserPattern ||
|
|
553
168
|
( isTemplatePart && post.source === TEMPLATE_ORIGINS.custom );
|
|
554
169
|
const hasThemeFile = post?.has_theme_file;
|
|
555
|
-
return isCustomPattern && ! hasThemeFile;
|
|
170
|
+
return isCustomPattern && ! hasThemeFile && post.permissions?.update;
|
|
556
171
|
},
|
|
557
172
|
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
558
173
|
const [ item ] = items;
|
|
@@ -623,22 +238,117 @@ const renamePostAction = {
|
|
|
623
238
|
},
|
|
624
239
|
};
|
|
625
240
|
|
|
626
|
-
function
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
241
|
+
function ReorderModal( { items, closeModal, onActionPerformed } ) {
|
|
242
|
+
const [ item, setItem ] = useState( items[ 0 ] );
|
|
243
|
+
const orderInput = item.menu_order;
|
|
244
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
245
|
+
useDispatch( coreStore );
|
|
246
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
247
|
+
useDispatch( noticesStore );
|
|
248
|
+
|
|
249
|
+
async function onOrder( event ) {
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
|
|
252
|
+
if ( ! isItemValid( item, fields, formOrderAction ) ) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
try {
|
|
257
|
+
await editEntityRecord( 'postType', item.type, item.id, {
|
|
258
|
+
menu_order: orderInput,
|
|
259
|
+
} );
|
|
260
|
+
closeModal();
|
|
261
|
+
// Persist edited entity.
|
|
262
|
+
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
263
|
+
throwOnError: true,
|
|
264
|
+
} );
|
|
265
|
+
createSuccessNotice( __( 'Order updated' ), {
|
|
266
|
+
type: 'snackbar',
|
|
267
|
+
} );
|
|
268
|
+
onActionPerformed?.( items );
|
|
269
|
+
} catch ( error ) {
|
|
270
|
+
const errorMessage =
|
|
271
|
+
error.message && error.code !== 'unknown_error'
|
|
272
|
+
? error.message
|
|
273
|
+
: __( 'An error occurred while updating the order' );
|
|
274
|
+
createErrorNotice( errorMessage, {
|
|
275
|
+
type: 'snackbar',
|
|
276
|
+
} );
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const isSaveDisabled = ! isItemValid( item, fields, formOrderAction );
|
|
280
|
+
return (
|
|
281
|
+
<form onSubmit={ onOrder }>
|
|
282
|
+
<VStack spacing="5">
|
|
283
|
+
<div>
|
|
284
|
+
{ __(
|
|
285
|
+
'Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.'
|
|
286
|
+
) }
|
|
287
|
+
</div>
|
|
288
|
+
<DataForm
|
|
289
|
+
data={ item }
|
|
290
|
+
fields={ fields }
|
|
291
|
+
form={ formOrderAction }
|
|
292
|
+
onChange={ setItem }
|
|
293
|
+
/>
|
|
294
|
+
<HStack justify="right">
|
|
295
|
+
<Button
|
|
296
|
+
__next40pxDefaultSize
|
|
297
|
+
variant="tertiary"
|
|
298
|
+
onClick={ () => {
|
|
299
|
+
closeModal();
|
|
300
|
+
} }
|
|
301
|
+
>
|
|
302
|
+
{ __( 'Cancel' ) }
|
|
303
|
+
</Button>
|
|
304
|
+
<Button
|
|
305
|
+
__next40pxDefaultSize
|
|
306
|
+
variant="primary"
|
|
307
|
+
type="submit"
|
|
308
|
+
accessibleWhenDisabled
|
|
309
|
+
disabled={ isSaveDisabled }
|
|
310
|
+
__experimentalIsFocusable
|
|
311
|
+
>
|
|
312
|
+
{ __( 'Save' ) }
|
|
313
|
+
</Button>
|
|
314
|
+
</HStack>
|
|
315
|
+
</VStack>
|
|
316
|
+
</form>
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function useReorderPagesAction( postType ) {
|
|
321
|
+
const supportsPageAttributes = useSelect(
|
|
322
|
+
( select ) => {
|
|
323
|
+
const { getPostType } = select( coreStore );
|
|
324
|
+
const postTypeObject = getPostType( postType );
|
|
325
|
+
|
|
326
|
+
return !! postTypeObject?.supports?.[ 'page-attributes' ];
|
|
327
|
+
},
|
|
328
|
+
[ postType ]
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
return useMemo(
|
|
332
|
+
() =>
|
|
333
|
+
supportsPageAttributes && {
|
|
334
|
+
id: 'order-pages',
|
|
335
|
+
label: __( 'Order' ),
|
|
336
|
+
isEligible( { status } ) {
|
|
337
|
+
return status !== 'trash';
|
|
338
|
+
},
|
|
339
|
+
RenderModal: ReorderModal,
|
|
340
|
+
},
|
|
341
|
+
[ supportsPageAttributes ]
|
|
631
342
|
);
|
|
632
343
|
}
|
|
633
344
|
|
|
634
345
|
const useDuplicatePostAction = ( postType ) => {
|
|
635
|
-
const
|
|
346
|
+
const userCanCreatePost = useSelect(
|
|
636
347
|
( select ) => {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
};
|
|
348
|
+
return select( coreStore ).canUser( 'create', {
|
|
349
|
+
kind: 'postType',
|
|
350
|
+
name: postType,
|
|
351
|
+
} );
|
|
642
352
|
},
|
|
643
353
|
[ postType ]
|
|
644
354
|
);
|
|
@@ -763,7 +473,7 @@ const useDuplicatePostAction = ( postType ) => {
|
|
|
763
473
|
<DataForm
|
|
764
474
|
data={ item }
|
|
765
475
|
fields={ fields }
|
|
766
|
-
form={
|
|
476
|
+
form={ formDuplicateAction }
|
|
767
477
|
onChange={ setItem }
|
|
768
478
|
/>
|
|
769
479
|
<HStack spacing={ 2 } justify="end">
|
|
@@ -824,11 +534,16 @@ export const duplicateTemplatePartAction = {
|
|
|
824
534
|
const blocks = useMemo( () => {
|
|
825
535
|
return (
|
|
826
536
|
item.blocks ??
|
|
827
|
-
parse(
|
|
828
|
-
|
|
829
|
-
|
|
537
|
+
parse(
|
|
538
|
+
typeof item.content === 'string'
|
|
539
|
+
? item.content
|
|
540
|
+
: item.content.raw,
|
|
541
|
+
{
|
|
542
|
+
__unstableSkipMigrationLogs: true,
|
|
543
|
+
}
|
|
544
|
+
)
|
|
830
545
|
);
|
|
831
|
-
}, [ item
|
|
546
|
+
}, [ item.content, item.blocks ] );
|
|
832
547
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
833
548
|
function onTemplatePartSuccess() {
|
|
834
549
|
createSuccessNotice(
|
|
@@ -859,36 +574,28 @@ export const duplicateTemplatePartAction = {
|
|
|
859
574
|
};
|
|
860
575
|
|
|
861
576
|
export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
862
|
-
const {
|
|
863
|
-
defaultActions,
|
|
864
|
-
postTypeObject,
|
|
865
|
-
userCanCreatePostType,
|
|
866
|
-
resource,
|
|
867
|
-
cachedCanUserResolvers,
|
|
868
|
-
} = useSelect(
|
|
577
|
+
const { defaultActions, postTypeObject, userCanCreatePostType } = useSelect(
|
|
869
578
|
( select ) => {
|
|
870
|
-
const { getPostType, canUser
|
|
871
|
-
select( coreStore );
|
|
579
|
+
const { getPostType, canUser } = select( coreStore );
|
|
872
580
|
const { getEntityActions } = unlock( select( editorStore ) );
|
|
873
|
-
const _postTypeObject = getPostType( postType );
|
|
874
|
-
const _resource = _postTypeObject?.rest_base || '';
|
|
875
581
|
return {
|
|
876
|
-
postTypeObject:
|
|
582
|
+
postTypeObject: getPostType( postType ),
|
|
877
583
|
defaultActions: getEntityActions( 'postType', postType ),
|
|
878
|
-
userCanCreatePostType: canUser( 'create',
|
|
879
|
-
|
|
880
|
-
|
|
584
|
+
userCanCreatePostType: canUser( 'create', {
|
|
585
|
+
kind: 'postType',
|
|
586
|
+
name: postType,
|
|
587
|
+
} ),
|
|
881
588
|
};
|
|
882
589
|
},
|
|
883
590
|
[ postType ]
|
|
884
591
|
);
|
|
592
|
+
const { registerPostTypeActions } = unlock( useDispatch( editorStore ) );
|
|
593
|
+
useEffect( () => {
|
|
594
|
+
registerPostTypeActions( postType );
|
|
595
|
+
}, [ registerPostTypeActions, postType ] );
|
|
885
596
|
|
|
886
597
|
const duplicatePostAction = useDuplicatePostAction( postType );
|
|
887
|
-
const
|
|
888
|
-
const permanentlyDeletePostActionForPostType =
|
|
889
|
-
usePermanentlyDeletePostAction( resource );
|
|
890
|
-
const renamePostActionForPostType = useRenamePostAction( resource );
|
|
891
|
-
const restorePostActionForPostType = useRestorePostAction( resource );
|
|
598
|
+
const reorderPagesAction = useReorderPagesAction( postType );
|
|
892
599
|
const isTemplateOrTemplatePart = [
|
|
893
600
|
TEMPLATE_POST_TYPE,
|
|
894
601
|
TEMPLATE_PART_POST_TYPE,
|
|
@@ -914,13 +621,8 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
|
914
621
|
userCanCreatePostType &&
|
|
915
622
|
duplicateTemplatePartAction,
|
|
916
623
|
isPattern && userCanCreatePostType && duplicatePatternAction,
|
|
917
|
-
supportsTitle &&
|
|
918
|
-
|
|
919
|
-
! isTemplateOrTemplatePart &&
|
|
920
|
-
! isPattern &&
|
|
921
|
-
trashPostActionForPostType,
|
|
922
|
-
! isTemplateOrTemplatePart &&
|
|
923
|
-
permanentlyDeletePostActionForPostType,
|
|
624
|
+
supportsTitle && renamePostAction,
|
|
625
|
+
reorderPagesAction,
|
|
924
626
|
...defaultActions,
|
|
925
627
|
].filter( Boolean );
|
|
926
628
|
// Filter actions based on provided context. If not provided
|
|
@@ -946,7 +648,7 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
|
946
648
|
existingCallback( items, {
|
|
947
649
|
...argsObject,
|
|
948
650
|
onActionPerformed: ( _items ) => {
|
|
949
|
-
if ( argsObject
|
|
651
|
+
if ( argsObject?.onActionPerformed ) {
|
|
950
652
|
argsObject.onActionPerformed( _items );
|
|
951
653
|
}
|
|
952
654
|
onActionPerformed(
|
|
@@ -984,9 +686,6 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
|
984
686
|
}
|
|
985
687
|
|
|
986
688
|
return actions;
|
|
987
|
-
// We are making this use memo depend on cachedCanUserResolvers as a way to make the component using this hook re-render
|
|
988
|
-
// when user capabilities are resolved. This makes sure the isEligible functions of actions dependent on capabilities are re-evaluated.
|
|
989
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
990
689
|
}, [
|
|
991
690
|
defaultActions,
|
|
992
691
|
userCanCreatePostType,
|
|
@@ -994,15 +693,11 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
|
994
693
|
isPattern,
|
|
995
694
|
postTypeObject?.viewable,
|
|
996
695
|
duplicatePostAction,
|
|
997
|
-
|
|
998
|
-
restorePostActionForPostType,
|
|
999
|
-
renamePostActionForPostType,
|
|
1000
|
-
permanentlyDeletePostActionForPostType,
|
|
696
|
+
reorderPagesAction,
|
|
1001
697
|
onActionPerformed,
|
|
1002
698
|
isLoaded,
|
|
1003
699
|
supportsRevisions,
|
|
1004
700
|
supportsTitle,
|
|
1005
701
|
context,
|
|
1006
|
-
cachedCanUserResolvers,
|
|
1007
702
|
] );
|
|
1008
703
|
}
|