@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["exportPattern","undefined"],"sources":["@wordpress/editor/src/dataviews/actions/export-pattern.native.tsx"],"sourcesContent":["const exportPattern = undefined;\n\nexport default exportPattern;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGC,SAAS;AAE/B,eAAeD,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
11
|
+
const permanentlyDeletePost = {
|
|
12
|
+
id: 'permanently-delete',
|
|
13
|
+
label: __('Permanently delete'),
|
|
14
|
+
supportsBulk: true,
|
|
15
|
+
isEligible(item) {
|
|
16
|
+
if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
status,
|
|
21
|
+
permissions
|
|
22
|
+
} = item;
|
|
23
|
+
return status === 'trash' && permissions?.delete;
|
|
24
|
+
},
|
|
25
|
+
async callback(posts, {
|
|
26
|
+
registry,
|
|
27
|
+
onActionPerformed
|
|
28
|
+
}) {
|
|
29
|
+
const {
|
|
30
|
+
createSuccessNotice,
|
|
31
|
+
createErrorNotice
|
|
32
|
+
} = registry.dispatch(noticesStore);
|
|
33
|
+
const {
|
|
34
|
+
deleteEntityRecord
|
|
35
|
+
} = registry.dispatch(coreStore);
|
|
36
|
+
const promiseResult = await Promise.allSettled(posts.map(post => {
|
|
37
|
+
return deleteEntityRecord('postType', post.type, post.id, {
|
|
38
|
+
force: true
|
|
39
|
+
}, {
|
|
40
|
+
throwOnError: true
|
|
41
|
+
});
|
|
42
|
+
}));
|
|
43
|
+
// If all the promises were fulfilled with success.
|
|
44
|
+
if (promiseResult.every(({
|
|
45
|
+
status
|
|
46
|
+
}) => status === 'fulfilled')) {
|
|
47
|
+
let successMessage;
|
|
48
|
+
if (promiseResult.length === 1) {
|
|
49
|
+
successMessage = sprintf( /* translators: The posts's title. */
|
|
50
|
+
__('"%s" permanently deleted.'), getItemTitle(posts[0]));
|
|
51
|
+
} else {
|
|
52
|
+
successMessage = __('The items were permanently deleted.');
|
|
53
|
+
}
|
|
54
|
+
createSuccessNotice(successMessage, {
|
|
55
|
+
type: 'snackbar',
|
|
56
|
+
id: 'permanently-delete-post-action'
|
|
57
|
+
});
|
|
58
|
+
onActionPerformed?.(posts);
|
|
59
|
+
} else {
|
|
60
|
+
// If there was at lease one failure.
|
|
61
|
+
let errorMessage;
|
|
62
|
+
// If we were trying to permanently delete a single post.
|
|
63
|
+
if (promiseResult.length === 1) {
|
|
64
|
+
const typedError = promiseResult[0];
|
|
65
|
+
if (typedError.reason?.message) {
|
|
66
|
+
errorMessage = typedError.reason.message;
|
|
67
|
+
} else {
|
|
68
|
+
errorMessage = __('An error occurred while permanently deleting the item.');
|
|
69
|
+
}
|
|
70
|
+
// If we were trying to permanently delete multiple posts
|
|
71
|
+
} else {
|
|
72
|
+
const errorMessages = new Set();
|
|
73
|
+
const failedPromises = promiseResult.filter(({
|
|
74
|
+
status
|
|
75
|
+
}) => status === 'rejected');
|
|
76
|
+
for (const failedPromise of failedPromises) {
|
|
77
|
+
const typedError = failedPromise;
|
|
78
|
+
if (typedError.reason?.message) {
|
|
79
|
+
errorMessages.add(typedError.reason.message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (errorMessages.size === 0) {
|
|
83
|
+
errorMessage = __('An error occurred while permanently deleting the items.');
|
|
84
|
+
} else if (errorMessages.size === 1) {
|
|
85
|
+
errorMessage = sprintf( /* translators: %s: an error message */
|
|
86
|
+
__('An error occurred while permanently deleting the items: %s'), [...errorMessages][0]);
|
|
87
|
+
} else {
|
|
88
|
+
errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
|
|
89
|
+
__('Some errors occurred while permanently deleting the items: %s'), [...errorMessages].join(','));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
createErrorNotice(errorMessage, {
|
|
93
|
+
type: 'snackbar'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export default permanentlyDeletePost;
|
|
99
|
+
//# sourceMappingURL=permanently-delete-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["store","coreStore","__","sprintf","noticesStore","getItemTitle","isTemplateOrTemplatePart","permanentlyDeletePost","id","label","supportsBulk","isEligible","item","type","status","permissions","delete","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","deleteEntityRecord","promiseResult","Promise","allSettled","map","post","force","throwOnError","every","successMessage","length","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/dataviews/actions/permanently-delete-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst permanentlyDeletePost: Action< PostWithPermissions > = {\n\tid: 'permanently-delete',\n\tlabel: __( 'Permanently delete' ),\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst { status, permissions } = item;\n\t\treturn status === 'trash' && permissions?.delete;\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = registry.dispatch( coreStore );\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn deleteEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpost.type,\n\t\t\t\t\tpost.id,\n\t\t\t\t\t{ force: true },\n\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'The items were permanently deleted.' );\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'permanently-delete-post-action',\n\t\t\t} );\n\t\t\tonActionPerformed?.( posts );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to permanently delete a single post.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to permanently delete multiple posts\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while permanently deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'An error occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while permanently deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t}\n\t},\n};\n\nexport default permanentlyDeletePost;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASH,KAAK,IAAII,YAAY,QAAQ,oBAAoB;AAG1D;AACA;AACA;AACA,SAASC,YAAY,EAAEC,wBAAwB,QAAQ,SAAS;AAGhE,MAAMC,qBAAoD,GAAG;EAC5DC,EAAE,EAAE,oBAAoB;EACxBC,KAAK,EAAEP,EAAE,CAAE,oBAAqB,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CAAC;QACF;MACD;MACAxB,iBAAiB,CAAEa,YAAY,EAAE;QAChCtB,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAED,eAAeN,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { backup } from '@wordpress/icons';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
12
|
+
const restorePost = {
|
|
13
|
+
id: 'restore',
|
|
14
|
+
label: __('Restore'),
|
|
15
|
+
isPrimary: true,
|
|
16
|
+
icon: backup,
|
|
17
|
+
supportsBulk: true,
|
|
18
|
+
isEligible(item) {
|
|
19
|
+
return !isTemplateOrTemplatePart(item) && item.type !== 'wp_block' && item.status === 'trash' && item.permissions?.update;
|
|
20
|
+
},
|
|
21
|
+
async callback(posts, {
|
|
22
|
+
registry,
|
|
23
|
+
onActionPerformed
|
|
24
|
+
}) {
|
|
25
|
+
const {
|
|
26
|
+
createSuccessNotice,
|
|
27
|
+
createErrorNotice
|
|
28
|
+
} = registry.dispatch(noticesStore);
|
|
29
|
+
const {
|
|
30
|
+
editEntityRecord,
|
|
31
|
+
saveEditedEntityRecord
|
|
32
|
+
} = registry.dispatch(coreStore);
|
|
33
|
+
await Promise.allSettled(posts.map(post => {
|
|
34
|
+
return editEntityRecord('postType', post.type, post.id, {
|
|
35
|
+
status: 'draft'
|
|
36
|
+
});
|
|
37
|
+
}));
|
|
38
|
+
const promiseResult = await Promise.allSettled(posts.map(post => {
|
|
39
|
+
return saveEditedEntityRecord('postType', post.type, post.id, {
|
|
40
|
+
throwOnError: true
|
|
41
|
+
});
|
|
42
|
+
}));
|
|
43
|
+
if (promiseResult.every(({
|
|
44
|
+
status
|
|
45
|
+
}) => status === 'fulfilled')) {
|
|
46
|
+
let successMessage;
|
|
47
|
+
if (posts.length === 1) {
|
|
48
|
+
successMessage = sprintf( /* translators: The number of posts. */
|
|
49
|
+
__('"%s" has been restored.'), getItemTitle(posts[0]));
|
|
50
|
+
} else if (posts[0].type === 'page') {
|
|
51
|
+
successMessage = sprintf( /* translators: The number of posts. */
|
|
52
|
+
__('%d pages have been restored.'), posts.length);
|
|
53
|
+
} else {
|
|
54
|
+
successMessage = sprintf( /* translators: The number of posts. */
|
|
55
|
+
__('%d posts have been restored.'), posts.length);
|
|
56
|
+
}
|
|
57
|
+
createSuccessNotice(successMessage, {
|
|
58
|
+
type: 'snackbar',
|
|
59
|
+
id: 'restore-post-action'
|
|
60
|
+
});
|
|
61
|
+
if (onActionPerformed) {
|
|
62
|
+
onActionPerformed(posts);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
// If there was at lease one failure.
|
|
66
|
+
let errorMessage;
|
|
67
|
+
// If we were trying to move a single post to the trash.
|
|
68
|
+
if (promiseResult.length === 1) {
|
|
69
|
+
const typedError = promiseResult[0];
|
|
70
|
+
if (typedError.reason?.message) {
|
|
71
|
+
errorMessage = typedError.reason.message;
|
|
72
|
+
} else {
|
|
73
|
+
errorMessage = __('An error occurred while restoring the post.');
|
|
74
|
+
}
|
|
75
|
+
// If we were trying to move multiple posts to the trash
|
|
76
|
+
} else {
|
|
77
|
+
const errorMessages = new Set();
|
|
78
|
+
const failedPromises = promiseResult.filter(({
|
|
79
|
+
status
|
|
80
|
+
}) => status === 'rejected');
|
|
81
|
+
for (const failedPromise of failedPromises) {
|
|
82
|
+
const typedError = failedPromise;
|
|
83
|
+
if (typedError.reason?.message) {
|
|
84
|
+
errorMessages.add(typedError.reason.message);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (errorMessages.size === 0) {
|
|
88
|
+
errorMessage = __('An error occurred while restoring the posts.');
|
|
89
|
+
} else if (errorMessages.size === 1) {
|
|
90
|
+
errorMessage = sprintf( /* translators: %s: an error message */
|
|
91
|
+
__('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
|
|
92
|
+
} else {
|
|
93
|
+
errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
|
|
94
|
+
__('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
createErrorNotice(errorMessage, {
|
|
98
|
+
type: 'snackbar'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export default restorePost;
|
|
104
|
+
//# sourceMappingURL=restore-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["backup","store","coreStore","__","sprintf","noticesStore","getItemTitle","isTemplateOrTemplatePart","restorePost","id","label","isPrimary","icon","supportsBulk","isEligible","item","type","status","permissions","update","callback","posts","registry","onActionPerformed","createSuccessNotice","createErrorNotice","dispatch","editEntityRecord","saveEditedEntityRecord","Promise","allSettled","map","post","promiseResult","throwOnError","every","successMessage","length","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/dataviews/actions/restore-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst restorePost: Action< PostWithPermissions > = {\n\tid: 'restore',\n\tlabel: __( 'Restore' ),\n\tisPrimary: true,\n\ticon: backup,\n\tsupportsBulk: true,\n\tisEligible( item ) {\n\t\treturn (\n\t\t\t! isTemplateOrTemplatePart( item ) &&\n\t\t\titem.type !== 'wp_block' &&\n\t\t\titem.status === 'trash' &&\n\t\t\titem.permissions?.update\n\t\t);\n\t},\n\tasync callback( posts, { registry, onActionPerformed } ) {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tregistry.dispatch( noticesStore );\n\t\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\t\tregistry.dispatch( coreStore );\n\t\tawait Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\tposts.map( ( post ) => {\n\t\t\t\treturn saveEditedEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} )\n\t\t);\n\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\t\t\tif ( posts.length === 1 ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\tgetItemTitle( posts[ 0 ] )\n\t\t\t\t);\n\t\t\t} else if ( posts[ 0 ].type === 'page' ) {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d pages have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The number of posts. */\n\t\t\t\t\t__( '%d posts have been restored.' ),\n\t\t\t\t\tposts.length\n\t\t\t\t);\n\t\t\t}\n\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'restore-post-action',\n\t\t\t} );\n\t\t\tif ( onActionPerformed ) {\n\t\t\t\tonActionPerformed( posts );\n\t\t\t}\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to move a single post to the trash.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t};\n\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\terrorMessage = typedError.reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to move multiple posts to the trash\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t};\n\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while restoring the posts.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while restoring the posts: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while restoring the posts: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ','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AAM,EAAEC,OAAO,EAAG;UACjCH,YAAY,GAAGC,UAAU,CAACC,MAAM,CAACC,OAAO;QACzC,CAAC,MAAM;UACNH,YAAY,GAAGnC,EAAE,CAChB,6CACD,CAAC;QACF;QACA;MACD,CAAC,MAAM;QACN,MAAMuC,aAAa,GAAG,IAAIC,GAAG,CAAC,CAAC;QAC/B,MAAMC,cAAc,GAAGX,aAAa,CAACY,MAAM,CAC1C,CAAE;UAAE5B;QAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;QACD,KAAM,MAAM6B,aAAa,IAAIF,cAAc,EAAG;UAC7C,MAAML,UAAU,GAAGO,aAElB;UACD,IAAKP,UAAU,CAACC,MAAM,EAAEC,OAAO,EAAG;YACjCC,aAAa,CAACK,GAAG,CAAER,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;UAC/C;QACD;QACA,IAAKC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UAC/BV,YAAY,GAAGnC,EAAE,CAChB,8CACD,CAAC;QACF,CAAC,MAAM,IAAKuC,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;UACtCV,YAAY,GAAGlC,OAAO,EACrB;UACAD,EAAE,CAAE,iDAAkD,CAAC,EACvD,CAAE,GAAGuC,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;QACF,CAAC,MAAM;UACNJ,YAAY,GAAGlC,OAAO,EACrB;UACAD,EAAE,CACD,oDACD,CAAC,EACD,CAAE,GAAGuC,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;QACF;MACD;MACAxB,iBAAiB,CAAEa,YAAY,EAAE;QAChCtB,IAAI,EAAE;MACP,CAAE,CAAC;IACJ;EACD;AACD,CAAC;AAED,eAAeR,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { trash } from '@wordpress/icons';
|
|
5
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { __, _n, sprintf, _x } from '@wordpress/i18n';
|
|
8
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { Button, __experimentalText as Text, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { getItemTitle, isTemplateOrTemplatePart } from './utils';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const trashPost = {
|
|
18
|
+
id: 'move-to-trash',
|
|
19
|
+
label: __('Move to trash'),
|
|
20
|
+
isPrimary: true,
|
|
21
|
+
icon: trash,
|
|
22
|
+
isEligible(item) {
|
|
23
|
+
if (isTemplateOrTemplatePart(item) || item.type === 'wp_block') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return !!item.status && !['auto-draft', 'trash'].includes(item.status) && item.permissions?.delete;
|
|
27
|
+
},
|
|
28
|
+
supportsBulk: true,
|
|
29
|
+
hideModalHeader: true,
|
|
30
|
+
RenderModal: ({
|
|
31
|
+
items,
|
|
32
|
+
closeModal,
|
|
33
|
+
onActionPerformed
|
|
34
|
+
}) => {
|
|
35
|
+
const [isBusy, setIsBusy] = useState(false);
|
|
36
|
+
const {
|
|
37
|
+
createSuccessNotice,
|
|
38
|
+
createErrorNotice
|
|
39
|
+
} = useDispatch(noticesStore);
|
|
40
|
+
const {
|
|
41
|
+
deleteEntityRecord
|
|
42
|
+
} = useDispatch(coreStore);
|
|
43
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
44
|
+
spacing: "5",
|
|
45
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
46
|
+
children: items.length === 1 ? sprintf(
|
|
47
|
+
// translators: %s: The item's title.
|
|
48
|
+
__('Are you sure you want to move "%s" to the trash?'), getItemTitle(items[0])) : sprintf(
|
|
49
|
+
// translators: %d: The number of items (2 or more).
|
|
50
|
+
_n('Are you sure you want to move %d item to the trash ?', 'Are you sure you want to move %d items to the trash ?', items.length), items.length)
|
|
51
|
+
}), /*#__PURE__*/_jsxs(HStack, {
|
|
52
|
+
justify: "right",
|
|
53
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
54
|
+
variant: "tertiary",
|
|
55
|
+
onClick: closeModal,
|
|
56
|
+
disabled: isBusy,
|
|
57
|
+
accessibleWhenDisabled: true,
|
|
58
|
+
children: __('Cancel')
|
|
59
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
60
|
+
variant: "primary",
|
|
61
|
+
onClick: async () => {
|
|
62
|
+
setIsBusy(true);
|
|
63
|
+
const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id.toString(), {}, {
|
|
64
|
+
throwOnError: true
|
|
65
|
+
})));
|
|
66
|
+
// If all the promises were fulfilled with success.
|
|
67
|
+
if (promiseResult.every(({
|
|
68
|
+
status
|
|
69
|
+
}) => status === 'fulfilled')) {
|
|
70
|
+
let successMessage;
|
|
71
|
+
if (promiseResult.length === 1) {
|
|
72
|
+
successMessage = sprintf( /* translators: The item's title. */
|
|
73
|
+
__('"%s" moved to the trash.'), getItemTitle(items[0]));
|
|
74
|
+
} else {
|
|
75
|
+
successMessage = sprintf( /* translators: The number of items. */
|
|
76
|
+
_n('%s item moved to the trash.', '%s items moved to the trash.', items.length), items.length);
|
|
77
|
+
}
|
|
78
|
+
createSuccessNotice(successMessage, {
|
|
79
|
+
type: 'snackbar',
|
|
80
|
+
id: 'move-to-trash-action'
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
// If there was at least one failure.
|
|
84
|
+
let errorMessage;
|
|
85
|
+
// If we were trying to delete a single item.
|
|
86
|
+
if (promiseResult.length === 1) {
|
|
87
|
+
const typedError = promiseResult[0];
|
|
88
|
+
if (typedError.reason?.message) {
|
|
89
|
+
errorMessage = typedError.reason.message;
|
|
90
|
+
} else {
|
|
91
|
+
errorMessage = __('An error occurred while moving the item to the trash.');
|
|
92
|
+
}
|
|
93
|
+
// If we were trying to delete multiple items.
|
|
94
|
+
} else {
|
|
95
|
+
const errorMessages = new Set();
|
|
96
|
+
const failedPromises = promiseResult.filter(({
|
|
97
|
+
status
|
|
98
|
+
}) => status === 'rejected');
|
|
99
|
+
for (const failedPromise of failedPromises) {
|
|
100
|
+
const typedError = failedPromise;
|
|
101
|
+
if (typedError.reason?.message) {
|
|
102
|
+
errorMessages.add(typedError.reason.message);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (errorMessages.size === 0) {
|
|
106
|
+
errorMessage = __('An error occurred while moving the items to the trash.');
|
|
107
|
+
} else if (errorMessages.size === 1) {
|
|
108
|
+
errorMessage = sprintf( /* translators: %s: an error message */
|
|
109
|
+
__('An error occurred while moving the item to the trash: %s'), [...errorMessages][0]);
|
|
110
|
+
} else {
|
|
111
|
+
errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
|
|
112
|
+
__('Some errors occurred while moving the items to the trash: %s'), [...errorMessages].join(','));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
createErrorNotice(errorMessage, {
|
|
116
|
+
type: 'snackbar'
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (onActionPerformed) {
|
|
120
|
+
onActionPerformed(items);
|
|
121
|
+
}
|
|
122
|
+
setIsBusy(false);
|
|
123
|
+
closeModal?.();
|
|
124
|
+
},
|
|
125
|
+
isBusy: isBusy,
|
|
126
|
+
disabled: isBusy,
|
|
127
|
+
accessibleWhenDisabled: true,
|
|
128
|
+
children: _x('Trash', 'verb')
|
|
129
|
+
})]
|
|
130
|
+
})]
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
export default trashPost;
|
|
135
|
+
//# sourceMappingURL=trash-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["trash","useDispatch","store","coreStore","__","_n","sprintf","_x","noticesStore","useState","Button","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","getItemTitle","isTemplateOrTemplatePart","jsx","_jsx","jsxs","_jsxs","trashPost","id","label","isPrimary","icon","isEligible","item","type","status","includes","permissions","delete","supportsBulk","hideModalHeader","RenderModal","items","closeModal","onActionPerformed","isBusy","setIsBusy","createSuccessNotice","createErrorNotice","deleteEntityRecord","spacing","children","length","justify","variant","onClick","disabled","accessibleWhenDisabled","promiseResult","Promise","allSettled","map","toString","throwOnError","every","successMessage","errorMessage","typedError","reason","message","errorMessages","Set","failedPromises","filter","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/dataviews/actions/trash-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { trash } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _n, sprintf, _x } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle, isTemplateOrTemplatePart } from './utils';\nimport type { CoreDataError, PostWithPermissions } from '../types';\n\nconst trashPost: Action< PostWithPermissions > = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( item ) {\n\t\tif ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (\n\t\t\t!! item.status &&\n\t\t\t! [ 'auto-draft', 'trash' ].includes( item.status ) &&\n\t\t\titem.permissions?.delete\n\t\t);\n\t},\n\tsupportsBulk: true,\n\thideModalHeader: true,\n\tRenderModal: ( { items, closeModal, onActionPerformed } ) => {\n\t\tconst [ isBusy, setIsBusy ] = useState( false );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ items.length === 1\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The item's title.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move \"%s\" to the trash?'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t// translators: %d: The number of items (2 or more).\n\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d item to the trash ?',\n\t\t\t\t\t\t\t\t\t'Are you sure you want to move %d items to the trash ?',\n\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t ) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ closeModal }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\tsetIsBusy( true );\n\t\t\t\t\t\t\tconst promiseResult = await Promise.allSettled(\n\t\t\t\t\t\t\t\titems.map( ( item ) =>\n\t\t\t\t\t\t\t\t\tdeleteEntityRecord(\n\t\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\t\titem.type,\n\t\t\t\t\t\t\t\t\t\titem.id.toString(),\n\t\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t// If all the promises were fulfilled with success.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpromiseResult.every(\n\t\t\t\t\t\t\t\t\t( { status } ) => status === 'fulfilled'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tlet successMessage;\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The item's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the trash.' ),\n\t\t\t\t\t\t\t\t\t\tgetItemTitle( items[ 0 ] )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The number of items. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'%s item moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\t'%s items moved to the trash.',\n\t\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\titems.length\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateSuccessNotice( successMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tid: 'move-to-trash-action',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// If there was at least one failure.\n\t\t\t\t\t\t\t\tlet errorMessage;\n\t\t\t\t\t\t\t\t// If we were trying to delete a single item.\n\t\t\t\t\t\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\t\t\t\t\t\tconst typedError = promiseResult[ 0 ] as {\n\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage =\n\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// If we were trying to delete multiple items.\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst errorMessages = new Set();\n\t\t\t\t\t\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\t\t\t\t\t\tconst typedError = failedPromise as {\n\t\t\t\t\t\t\t\t\t\t\treason?: CoreDataError;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\t\t\t\t\t\t\t\terrorMessages.add(\n\t\t\t\t\t\t\t\t\t\t\t\ttypedError.reason.message\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the items to the trash.'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the item to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'Some errors occurred while moving the items to the trash: %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( onActionPerformed ) {\n\t\t\t\t\t\t\t\tonActionPerformed( items );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetIsBusy( false );\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x( 'Trash', 'verb' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport default trashPost;\n"],"mappings":"AAAA;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KAAK,CAAC,EAAG;kBAC/BV,YAAY,GAAG1D,EAAE,CAChB,wDACD,CAAC;gBACF,CAAC,MAAM,IAAK8D,aAAa,CAACM,IAAI,KAAK,CAAC,EAAG;kBACtCV,YAAY,GAAGxD,OAAO,EACrB;kBACAF,EAAE,CACD,0DACD,CAAC,EACD,CAAE,GAAG8D,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;gBACF,CAAC,MAAM;kBACNJ,YAAY,GAAGxD,OAAO,EACrB;kBACAF,EAAE,CACD,8DACD,CAAC,EACD,CAAE,GAAG8D,aAAa,CAAE,CAACO,IAAI,CAAE,GAAI,CAChC,CAAC;gBACF;cACD;cACA7B,iBAAiB,CAAEkB,YAAY,EAAE;gBAChChC,IAAI,EAAE;cACP,CAAE,CAAC;YACJ;YACA,IAAKU,iBAAiB,EAAG;cACxBA,iBAAiB,CAAEF,KAAM,CAAC;YAC3B;YACAI,SAAS,CAAE,KAAM,CAAC;YAClBH,UAAU,GAAG,CAAC;UACf,CAAG;UACHE,MAAM,EAAGA,MAAQ;UACjBW,QAAQ,EAAGX,MAAQ;UACnBY,sBAAsB;UAAAN,QAAA,EAEpBxC,EAAE,CAAE,OAAO,EAAE,MAAO;QAAC,CAChB,CAAC;MAAA,CACF,CAAC;IAAA,CACF,CAAC;EAEX;AACD,CAAC;AAED,eAAegB,SAAS","ignoreList":[]}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
5
|
+
import { doAction } from '@wordpress/hooks';
|
|
4
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import deletePost from '../actions/delete-post';
|
|
11
|
+
import exportPattern from '../actions/export-pattern';
|
|
12
|
+
import resetPost from '../actions/reset-post';
|
|
13
|
+
import trashPost from '../actions/trash-post';
|
|
14
|
+
import permanentlyDeletePost from '../actions/permanently-delete-post';
|
|
15
|
+
import restorePost from '../actions/restore-post';
|
|
16
|
+
import { store as editorStore } from '../../store';
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
5
18
|
export function registerEntityAction(kind, name, config) {
|
|
6
19
|
return {
|
|
7
20
|
type: 'REGISTER_ENTITY_ACTION',
|
|
@@ -18,4 +31,31 @@ export function unregisterEntityAction(kind, name, actionId) {
|
|
|
18
31
|
actionId
|
|
19
32
|
};
|
|
20
33
|
}
|
|
34
|
+
export function setIsReady(kind, name) {
|
|
35
|
+
return {
|
|
36
|
+
type: 'SET_IS_READY',
|
|
37
|
+
kind,
|
|
38
|
+
name
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export const registerPostTypeActions = postType => async ({
|
|
42
|
+
registry
|
|
43
|
+
}) => {
|
|
44
|
+
const isReady = unlock(registry.select(editorStore)).isEntityReady('postType', postType);
|
|
45
|
+
if (isReady) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
unlock(registry.dispatch(editorStore)).setIsReady('postType', postType);
|
|
49
|
+
const postTypeConfig = await registry.resolveSelect(coreStore).getPostType(postType);
|
|
50
|
+
const actions = [postTypeConfig.slug === 'wp_block' ? exportPattern : undefined, resetPost, restorePost, deletePost, trashPost, permanentlyDeletePost];
|
|
51
|
+
registry.batch(() => {
|
|
52
|
+
actions.forEach(action => {
|
|
53
|
+
if (action === undefined) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
unlock(registry.dispatch(editorStore)).registerEntityAction('postType', postType, action);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
doAction('core.registerPostTypeActions', postType);
|
|
60
|
+
};
|
|
21
61
|
//# sourceMappingURL=private-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Action } from '@wordpress/dataviews';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["store","coreStore","doAction","deletePost","exportPattern","resetPost","trashPost","permanentlyDeletePost","restorePost","editorStore","unlock","registerEntityAction","kind","name","config","type","unregisterEntityAction","actionId","setIsReady","registerPostTypeActions","postType","registry","isReady","select","isEntityReady","dispatch","postTypeConfig","resolveSelect","getPostType","actions","slug","undefined","batch","forEach","action"],"sources":["@wordpress/editor/src/dataviews/store/private-actions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Action } from '@wordpress/dataviews';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport deletePost from '../actions/delete-post';\nimport exportPattern from '../actions/export-pattern';\nimport resetPost from '../actions/reset-post';\nimport trashPost from '../actions/trash-post';\nimport permanentlyDeletePost from '../actions/permanently-delete-post';\nimport restorePost from '../actions/restore-post';\nimport type { PostType } from '../types';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport function registerEntityAction< Item >(\n\tkind: string,\n\tname: string,\n\tconfig: Action< Item >\n) {\n\treturn {\n\t\ttype: 'REGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tconfig,\n\t};\n}\n\nexport function unregisterEntityAction(\n\tkind: string,\n\tname: string,\n\tactionId: string\n) {\n\treturn {\n\t\ttype: 'UNREGISTER_ENTITY_ACTION' as const,\n\t\tkind,\n\t\tname,\n\t\tactionId,\n\t};\n}\n\nexport function setIsReady( kind: string, name: string ) {\n\treturn {\n\t\ttype: 'SET_IS_READY' as const,\n\t\tkind,\n\t\tname,\n\t};\n}\n\nexport const registerPostTypeActions =\n\t( postType: string ) =>\n\tasync ( { registry }: { registry: any } ) => {\n\t\tconst isReady = unlock( registry.select( editorStore ) ).isEntityReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tif ( isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\tunlock( registry.dispatch( editorStore ) ).setIsReady(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\n\t\tconst postTypeConfig = ( await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getPostType( postType ) ) as PostType;\n\n\t\tconst actions = [\n\t\t\tpostTypeConfig.slug === 'wp_block' ? exportPattern : undefined,\n\t\t\tresetPost,\n\t\t\trestorePost,\n\t\t\tdeletePost,\n\t\t\ttrashPost,\n\t\t\tpermanentlyDeletePost,\n\t\t];\n\n\t\tregistry.batch( () => {\n\t\t\tactions.forEach( ( action ) => {\n\t\t\t\tif ( action === undefined ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunlock( registry.dispatch( editorStore ) ).registerEntityAction(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\taction\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\n\t\tdoAction( 'core.registerPostTypeActions', postType );\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAEzD,SAASC,QAAQ,QAAQ,kBAAkB;;AAE3C;AACA;AACA;AACA,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,OAAOC,aAAa,MAAM,2BAA2B;AACrD,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,OAAOC,qBAAqB,MAAM,oCAAoC;AACtE,OAAOC,WAA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C,MAAM,IAAM;MAC9B,IAAKA,MAAM,KAAKH,SAAS,EAAG;QAC3B;MACD;MACArB,MAAM,CAAEW,QAAQ,CAACI,QAAQ,CAAEhB,WAAY,CAAE,CAAC,CAACE,oBAAoB,CAC9D,UAAU,EACVS,QAAQ,EACRc,MACD,CAAC;IACF,CAAE,CAAC;EACJ,CAAE,CAAC;EAEHhC,QAAQ,CAAE,8BAA8B,EAAEkB,QAAS,CAAC;AACrD,CAAC","ignoreList":[]}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createSelector } from '@wordpress/data';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const EMPTY_ARRAY = [];
|
|
6
|
+
export function getEntityActions(state, kind, name) {
|
|
7
|
+
var _state$actions$kind$n;
|
|
8
|
+
return (_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : EMPTY_ARRAY;
|
|
9
|
+
}
|
|
10
|
+
export function isEntityReady(state, kind, name) {
|
|
11
|
+
return state.isReady[kind]?.[name];
|
|
12
|
+
}
|
|
14
13
|
//# sourceMappingURL=private-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["EMPTY_ARRAY","getEntityActions","state","kind","name","_state$actions$kind$n","actions","isEntityReady","isReady"],"sources":["@wordpress/editor/src/dataviews/store/private-selectors.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { State } from './reducer';\n\nconst EMPTY_ARRAY = [] as [];\n\nexport function getEntityActions( state: State, kind: string, name: string ) {\n\treturn state.actions[ kind ]?.[ name ] ?? EMPTY_ARRAY;\n}\n\nexport function isEntityReady( state: State, kind: string, name: string ) {\n\treturn state.isReady[ kind ]?.[ name ];\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA,MAAMA,WAAW,GAAG,EAAQ;AAE5B,OAAO,SAASC,gBAAgBA,CAAEC,KAAY,EAAEC,IAAY,EAAEC,IAAY,EAAG;EAAA,IAAAC,qBAAA;EAC5E,QAAAA,qBAAA,GAAOH,KAAK,CAACI,OAAO,CAAEH,IAAI,CAAE,GAAIC,IAAI,CAAE,cAAAC,qBAAA,cAAAA,qBAAA,GAAIL,WAAW;AACtD;AAEA,OAAO,SAASO,aAAaA,CAAEL,KAAY,EAAEC,IAAY,EAAEC,IAAY,EAAG;EACzE,OAAOF,KAAK,CAACM,OAAO,CAAEL,IAAI,CAAE,GAAIC,IAAI,CAAE;AACvC","ignoreList":[]}
|
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { combineReducers } from '@wordpress/data';
|
|
5
|
+
function isReady(state = {}, action) {
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case 'SET_IS_READY':
|
|
8
|
+
return {
|
|
9
|
+
...state,
|
|
10
|
+
[action.kind]: {
|
|
11
|
+
...state[action.kind],
|
|
12
|
+
[action.name]: true
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
5
18
|
function actions(state = {}, action) {
|
|
6
19
|
var _state$action$kind$ac;
|
|
7
20
|
switch (action.type) {
|
|
@@ -28,6 +41,7 @@ function actions(state = {}, action) {
|
|
|
28
41
|
return state;
|
|
29
42
|
}
|
|
30
43
|
export default combineReducers({
|
|
31
|
-
actions
|
|
44
|
+
actions,
|
|
45
|
+
isReady
|
|
32
46
|
});
|
|
33
47
|
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["combineReducers","
|
|
1
|
+
{"version":3,"names":["combineReducers","isReady","state","action","type","kind","name","actions","_state$action$kind$ac","filter","_action","id","config","_state$action$kind$ac2","actionId"],"sources":["@wordpress/editor/src/dataviews/store/reducer.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport type { Action } from '@wordpress/dataviews';\n\ntype ReduxAction =\n\t| ReturnType< typeof import('./private-actions').registerEntityAction >\n\t| ReturnType< typeof import('./private-actions').unregisterEntityAction >\n\t| ReturnType< typeof import('./private-actions').setIsReady >;\n\nexport type ActionState = Record< string, Record< string, Action< any >[] > >;\nexport type ReadyState = Record< string, Record< string, boolean > >;\nexport type State = {\n\tactions: ActionState;\n\tisReady: ReadyState;\n};\n\nfunction isReady( state: ReadyState = {}, action: ReduxAction ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_READY':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: true,\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nfunction actions( state: ActionState = {}, action: ReduxAction ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_ENTITY_ACTION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: [\n\t\t\t\t\t\t...(\n\t\t\t\t\t\t\tstate[ action.kind ]?.[ action.name ] ?? []\n\t\t\t\t\t\t).filter(\n\t\t\t\t\t\t\t( _action ) => _action.id !== action.config.id\n\t\t\t\t\t\t),\n\t\t\t\t\t\taction.config,\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_ENTITY_ACTION': {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.kind ]: {\n\t\t\t\t\t...state[ action.kind ],\n\t\t\t\t\t[ action.name ]: (\n\t\t\t\t\t\tstate[ action.kind ]?.[ action.name ] ?? []\n\t\t\t\t\t).filter( ( _action ) => _action.id !== action.actionId ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tactions,\n\tisReady,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,iBAAiB;AAejD,SAASC,OAAOA,CAAEC,KAAiB,GAAG,CAAC,CAAC,EAAEC,MAAmB,EAAG;EAC/D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,cAAc;MAClB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChB,GAAGH,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE;UACvB,CAAEF,MAAM,CAACG,IAAI,GAAI;QAClB;MACD,CAAC;EACH;EAEA,OAAOJ,KAAK;AACb;AAEA,SAASK,OAAOA,CAAEL,KAAkB,GAAG,CAAC,CAAC,EAAEC,MAAmB,EAAG;EAAA,IAAAK,qBAAA;EAChE,QAASL,MAAM,CAACC,IAAI;IACnB,KAAK,wBAAwB;MAC5B,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChB,GAAGH,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE;UACvB,CAAEF,MAAM,CAACG,IAAI,GAAI,CAChB,GAAG,EAAAE,qBAAA,GACFN,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE,GAAIF,MAAM,CAACG,IAAI,CAAE,cAAAE,qBAAA,cAAAA,qBAAA,GAAI,EAAE,EAC1CC,MAAM,CACLC,OAAO,IAAMA,OAAO,CAACC,EAAE,KAAKR,MAAM,CAACS,MAAM,CAACD,EAC7C,CAAC,EACDR,MAAM,CAACS,MAAM;QAEf;MACD,CAAC;IACF,KAAK,0BAA0B;MAAE;QAAA,IAAAC,sBAAA;QAChC,OAAO;UACN,GAAGX,KAAK;UACR,CAAEC,MAAM,CAACE,IAAI,GAAI;YAChB,GAAGH,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE;YACvB,CAAEF,MAAM,CAACG,IAAI,GAAI,EAAAO,sBAAA,GAChBX,KAAK,CAAEC,MAAM,CAACE,IAAI,CAAE,GAAIF,MAAM,CAACG,IAAI,CAAE,cAAAO,sBAAA,cAAAA,sBAAA,GAAI,EAAE,EAC1CJ,MAAM,CAAIC,OAAO,IAAMA,OAAO,CAACC,EAAE,KAAKR,MAAM,CAACW,QAAS;UACzD;QACD,CAAC;MACF;EACD;EAEA,OAAOZ,KAAK;AACb;AAEA,eAAeF,eAAe,CAAE;EAC/BO,OAAO;EACPN;AACD,CAAE,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/editor/src/dataviews/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'published'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface BasePost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\ttype: string;\n\tid: string | number;\n}\nexport interface TemplateOrTemplatePart extends BasePost {\n\ttype: 'wp_template' | 'wp_template_part';\n\tsource: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface Pattern extends BasePost {\n\tslug: string;\n\ttitle: { raw: string };\n\tcontent: { raw: string } | string;\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = TemplateOrTemplatePart | Pattern | BasePost;\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/editor/src/dataviews/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'published'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface BasePost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\ttype: string;\n\tid: string | number;\n}\nexport interface TemplateOrTemplatePart extends BasePost {\n\ttype: 'wp_template' | 'wp_template_part';\n\tsource: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface Pattern extends BasePost {\n\tslug: string;\n\ttitle: { raw: string };\n\tcontent: { raw: string } | string;\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = TemplateOrTemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\nexport interface PostType {\n\tslug: string;\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -41,7 +41,7 @@ const withPatternOverrideControls = createHigherOrderComponent(BlockEdit => prop
|
|
|
41
41
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
42
42
|
children: [/*#__PURE__*/_jsx(BlockEdit, {
|
|
43
43
|
...props
|
|
44
|
-
}), props.isSelected && isSupportedBlock && /*#__PURE__*/_jsx(ControlsWithStoreSubscription, {
|
|
44
|
+
}, "edit"), props.isSelected && isSupportedBlock && /*#__PURE__*/_jsx(ControlsWithStoreSubscription, {
|
|
45
45
|
...props
|
|
46
46
|
}), isSupportedBlock && /*#__PURE__*/_jsx(PatternOverridesBlockControls, {})]
|
|
47
47
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","blocksStore","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","name","children","isSelected","ControlsWithStoreSubscription","blockEditingMode","hasPatternOverridesSource","isEditingSyncedPattern","select","getBlockBindingsSource","getCurrentPostType","getEditedPostAttribute","user","wp_pattern_sync_status","unsynced","bindings","attributes","metadata","hasPatternBindings","Object","values","some","binding","source","shouldShowPatternOverridesControls","shouldShowResetOverridesControl"],"sources":["@wordpress/editor/src/hooks/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useBlockEditingMode } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\nconst {\n\tPatternOverridesControls,\n\tResetOverridesControl,\n\tPatternOverridesBlockControls,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternsPrivateApis );\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning a partial syncing controls to supported blocks in the pattern editor.\n * Currently, only the `core/paragraph` block is supported.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withPatternOverrideControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isSupportedBlock =\n\t\t\t!! PARTIAL_SYNCING_SUPPORTED_BLOCKS[ props.name ];\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ props.isSelected && isSupportedBlock && (\n\t\t\t\t\t<ControlsWithStoreSubscription { ...props } />\n\t\t\t\t) }\n\t\t\t\t{ isSupportedBlock && <PatternOverridesBlockControls /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withPatternOverrideControls'\n);\n\n// Split into a separate component to avoid a store subscription\n// on every block.\nfunction ControlsWithStoreSubscription( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst { hasPatternOverridesSource, isEditingSyncedPattern } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockBindingsSource } = unlock( select( blocksStore ) );\n\t\t\tconst { getCurrentPostType, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\n\t\t\treturn {\n\t\t\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\t\t\thasPatternOverridesSource: !! getBlockBindingsSource(\n\t\t\t\t\t'core/pattern-overrides'\n\t\t\t\t),\n\t\t\t\tisEditingSyncedPattern:\n\t\t\t\t\tgetCurrentPostType() === PATTERN_TYPES.user &&\n\t\t\t\t\tgetEditedPostAttribute( 'meta' )?.wp_pattern_sync_status !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced &&\n\t\t\t\t\tgetEditedPostAttribute( 'wp_pattern_sync_status' ) !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst bindings = props.attributes.metadata?.bindings;\n\tconst hasPatternBindings =\n\t\t!! bindings &&\n\t\tObject.values( bindings ).some(\n\t\t\t( binding ) => binding.source === 'core/pattern-overrides'\n\t\t);\n\n\tconst shouldShowPatternOverridesControls =\n\t\tisEditingSyncedPattern && blockEditingMode === 'default';\n\tconst shouldShowResetOverridesControl =\n\t\t! isEditingSyncedPattern &&\n\t\t!! props.attributes.metadata?.name &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\tif ( ! hasPatternOverridesSource ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldShowPatternOverridesControls && (\n\t\t\t\t<PatternOverridesControls { ...props } />\n\t\t\t) }\n\t\t\t{ shouldShowResetOverridesControl && (\n\t\t\t\t<ResetOverridesControl { ...props } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/with-pattern-override-controls',\n\twithPatternOverrideControls\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,IAAIC,mBAAmB,QAAQ,qBAAqB;AACxE,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEA,MAAM;EACLC,wBAAwB;EACxBC,qBAAqB;EACrBC,6BAA6B;EAC7BC,aAAa;EACbC,gCAAgC;EAChCC;AACD,CAAC,GAAGZ,MAAM,CAAEP,mBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMoB,2BAA2B,GAAGnB,0BAA0B,CAC3DoB,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GACrB,CAAC,CAAEL,gCAAgC,CAAEI,KAAK,CAACE,IAAI,CAAE;EAElD,oBACCX,KAAA,CAAAF,SAAA;IAAAc,QAAA,gBACChB,IAAA,CAACY,SAAS;MAAA,
|
|
1
|
+
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","blocksStore","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","name","children","isSelected","ControlsWithStoreSubscription","blockEditingMode","hasPatternOverridesSource","isEditingSyncedPattern","select","getBlockBindingsSource","getCurrentPostType","getEditedPostAttribute","user","wp_pattern_sync_status","unsynced","bindings","attributes","metadata","hasPatternBindings","Object","values","some","binding","source","shouldShowPatternOverridesControls","shouldShowResetOverridesControl"],"sources":["@wordpress/editor/src/hooks/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useBlockEditingMode } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\nconst {\n\tPatternOverridesControls,\n\tResetOverridesControl,\n\tPatternOverridesBlockControls,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternsPrivateApis );\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning a partial syncing controls to supported blocks in the pattern editor.\n * Currently, only the `core/paragraph` block is supported.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withPatternOverrideControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isSupportedBlock =\n\t\t\t!! PARTIAL_SYNCING_SUPPORTED_BLOCKS[ props.name ];\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t{ props.isSelected && isSupportedBlock && (\n\t\t\t\t\t<ControlsWithStoreSubscription { ...props } />\n\t\t\t\t) }\n\t\t\t\t{ isSupportedBlock && <PatternOverridesBlockControls /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withPatternOverrideControls'\n);\n\n// Split into a separate component to avoid a store subscription\n// on every block.\nfunction ControlsWithStoreSubscription( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst { hasPatternOverridesSource, isEditingSyncedPattern } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockBindingsSource } = unlock( select( blocksStore ) );\n\t\t\tconst { getCurrentPostType, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\n\t\t\treturn {\n\t\t\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\t\t\thasPatternOverridesSource: !! getBlockBindingsSource(\n\t\t\t\t\t'core/pattern-overrides'\n\t\t\t\t),\n\t\t\t\tisEditingSyncedPattern:\n\t\t\t\t\tgetCurrentPostType() === PATTERN_TYPES.user &&\n\t\t\t\t\tgetEditedPostAttribute( 'meta' )?.wp_pattern_sync_status !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced &&\n\t\t\t\t\tgetEditedPostAttribute( 'wp_pattern_sync_status' ) !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst bindings = props.attributes.metadata?.bindings;\n\tconst hasPatternBindings =\n\t\t!! bindings &&\n\t\tObject.values( bindings ).some(\n\t\t\t( binding ) => binding.source === 'core/pattern-overrides'\n\t\t);\n\n\tconst shouldShowPatternOverridesControls =\n\t\tisEditingSyncedPattern && blockEditingMode === 'default';\n\tconst shouldShowResetOverridesControl =\n\t\t! isEditingSyncedPattern &&\n\t\t!! props.attributes.metadata?.name &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\tif ( ! hasPatternOverridesSource ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldShowPatternOverridesControls && (\n\t\t\t\t<PatternOverridesControls { ...props } />\n\t\t\t) }\n\t\t\t{ shouldShowResetOverridesControl && (\n\t\t\t\t<ResetOverridesControl { ...props } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/with-patt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