@wordpress/editor 13.31.0 → 13.33.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 +4 -0
- package/README.md +1080 -0
- package/build/bindings/index.js.map +1 -1
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/bindings/post-meta.js +12 -30
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/autocompleters/index.js.map +1 -1
- package/build/components/autocompleters/user.js.map +1 -1
- package/build/components/autosave-monitor/index.js +10 -0
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/checklist.js.map +1 -1
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/block-removal-warnings/index.js.map +1 -1
- package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +107 -0
- package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
- package/build/components/character-count/index.js.map +1 -1
- package/build/components/commands/index.js +20 -1
- package/build/components/commands/index.js.map +1 -1
- package/build/components/commands/index.native.js.map +1 -1
- package/build/components/deprecated.js +158 -0
- package/build/components/deprecated.js.map +1 -1
- package/build/components/deprecated.native.js.map +1 -1
- package/build/components/document-bar/index.js +5 -8
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/document-tools/index.js +1 -1
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js +12 -38
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-canvas/index.js +5 -2
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/editor-help/add-blocks.native.js.map +1 -1
- package/build/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
- package/build/components/editor-help/help-section-title.native.js.map +1 -1
- package/build/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build/components/editor-help/icon-move-blocks.native.js.map +1 -1
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build/components/editor-help/move-blocks.native.js.map +1 -1
- package/build/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build/components/editor-help/view-sections.native.js.map +1 -1
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-notices/index.js.map +1 -1
- package/build/components/editor-snackbars/index.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build/components/entities-saved-states/index.js +11 -85
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/index.native.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +24 -0
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +57 -1
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +5 -1
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +78 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +49 -0
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/index.js +126 -0
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +55 -0
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
- package/build/components/list-view-sidebar/index.js +2 -1
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/list-view-sidebar/list-view-outline.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/mode-switcher/index.js.map +1 -1
- package/build/components/offline-status/index.native.js.map +1 -1
- package/build/components/page-attributes/check.js.map +1 -1
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/panel.js.map +1 -1
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/pattern-overrides-panel/index.js +30 -0
- package/build/components/pattern-overrides-panel/index.js.map +1 -0
- package/build/components/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/plugin-more-menu-item/index.js +78 -0
- package/build/components/plugin-more-menu-item/index.js.map +1 -0
- package/build/components/plugin-post-publish-panel/index.js +68 -0
- package/build/components/plugin-post-publish-panel/index.js.map +1 -0
- package/build/components/plugin-post-status-info/index.js +73 -0
- package/build/components/plugin-post-status-info/index.js.map +1 -0
- package/build/components/plugin-pre-publish-panel/index.js +71 -0
- package/build/components/plugin-pre-publish-panel/index.js.map +1 -0
- package/build/components/plugin-sidebar/index.js +108 -0
- package/build/components/plugin-sidebar/index.js.map +1 -0
- package/build/components/plugin-sidebar-more-menu-item/index.js +71 -0
- package/build/components/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build/components/post-actions/actions.js +656 -0
- package/build/components/post-actions/actions.js.map +1 -0
- package/build/components/post-actions/index.js +137 -0
- package/build/components/post-actions/index.js.map +1 -0
- package/build/components/post-author/check.js.map +1 -1
- package/build/components/post-author/combobox.js.map +1 -1
- package/build/components/post-author/constants.js.map +1 -1
- package/build/components/post-author/hook.js.map +1 -1
- package/build/components/post-author/index.js.map +1 -1
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-author/select.js.map +1 -1
- package/build/components/post-card-panel/index.js +127 -0
- package/build/components/post-card-panel/index.js.map +1 -0
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/check.js +8 -0
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-excerpt/plugin.js.map +1 -1
- package/build/components/post-featured-image/check.js.map +1 -1
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js.map +1 -1
- package/build/components/post-format/check.js.map +1 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-revision/check.js.map +1 -1
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-last-revision/panel.js.map +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-panel-row/index.js.map +1 -1
- package/build/components/post-pending-status/check.js.map +1 -1
- package/build/components/post-pending-status/index.js.map +1 -1
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +31 -31
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +51 -43
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-publish-panel/prepublish.js.map +1 -1
- package/build/components/post-saved-state/index.js +10 -6
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/check.js.map +1 -1
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-schedule/panel.js +8 -0
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-slug/check.js.map +1 -1
- package/build/components/post-slug/index.js +43 -68
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-status/index.js +239 -0
- package/build/components/post-status/index.js.map +1 -0
- package/build/components/post-sticky/check.js.map +1 -1
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +6 -1
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-taxonomies/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-taxonomies/panel.js.map +1 -1
- package/build/components/post-template/block-theme.js +6 -2
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/create-new-template.js.map +1 -1
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/post-template/reset-default-template.js.map +1 -1
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-text-editor/index.js.map +1 -1
- package/build/components/post-title/constants.js.map +1 -1
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-title/use-post-title-focus.js.map +1 -1
- package/build/components/post-title/use-post-title.js.map +1 -1
- package/build/components/post-trash/check.js +23 -25
- package/build/components/post-trash/check.js.map +1 -1
- package/build/components/post-trash/index.js +2 -1
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/post-url/check.js.map +1 -1
- package/build/components/post-url/index.js +44 -19
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/post-url/label.js.map +1 -1
- package/build/components/post-url/panel.js +14 -7
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/post-view-link/index.js.map +1 -1
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/post-visibility/index.js +2 -1
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
- package/build/components/preferences-modal/index.js +19 -17
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +36 -20
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/index.js +4 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +6 -1
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/navigation-block-editing-mode.js.map +1 -1
- package/build/components/provider/use-auto-switch-editor-sidebars.js +52 -0
- package/build/components/provider/use-auto-switch-editor-sidebars.js.map +1 -0
- package/build/components/provider/use-block-editor-settings.js +70 -50
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build/components/provider/with-registry-provider.js +1 -0
- package/build/components/provider/with-registry-provider.js.map +1 -1
- package/build/components/start-page-options/index.js +139 -0
- package/build/components/start-page-options/index.js.map +1 -0
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/table-of-contents/panel.js.map +1 -1
- package/build/components/template-areas/index.js +70 -0
- package/build/components/template-areas/index.js.map +1 -0
- package/build/components/template-validation-notice/index.js +23 -29
- package/build/components/template-validation-notice/index.js.map +1 -1
- package/build/components/theme-support-check/index.js +10 -16
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/components/time-to-read/index.js.map +1 -1
- package/build/components/unsaved-changes-warning/index.js.map +1 -1
- package/build/components/word-count/index.js.map +1 -1
- package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build/hooks/default-autocompleters.js.map +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/pattern-overrides.js +22 -10
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/hooks/use-select-nearest-editable-block.js +87 -0
- package/build/hooks/use-select-nearest-editable-block.js.map +1 -0
- package/build/index.js.map +1 -1
- package/build/index.native.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +26 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +46 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/actions.native.js.map +1 -1
- package/build/store/constants.js +10 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/local-autosave.js.map +1 -1
- package/build/store/private-actions.js +253 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +50 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +14 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +25 -20
- package/build/store/selectors.js.map +1 -1
- package/build/store/selectors.native.js.map +1 -1
- package/build/store/utils/get-filtered-template-parts.js +71 -0
- package/build/store/utils/get-filtered-template-parts.js.map +1 -0
- package/build/store/utils/is-template-revertable.js +28 -0
- package/build/store/utils/is-template-revertable.js.map +1 -0
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build/utils/get-template-part-icon.js.map +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/index.native.js.map +1 -1
- package/build/utils/media-upload/index.js.map +1 -1
- package/build/utils/media-upload/index.native.js.map +1 -1
- package/build/utils/terms.js.map +1 -1
- package/build/utils/url.js.map +1 -1
- package/build-module/bindings/index.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/bindings/post-meta.js +14 -31
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/autocompleters/index.js.map +1 -1
- package/build-module/components/autocompleters/user.js.map +1 -1
- package/build-module/components/autosave-monitor/index.js +10 -0
- package/build-module/components/autosave-monitor/index.js.map +1 -1
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/checklist.js.map +1 -1
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/block-removal-warnings/index.js.map +1 -1
- package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +100 -0
- package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
- package/build-module/components/character-count/index.js.map +1 -1
- package/build-module/components/commands/index.js +21 -2
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/commands/index.native.js.map +1 -1
- package/build-module/components/deprecated.js +159 -0
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/deprecated.native.js.map +1 -1
- package/build-module/components/document-bar/index.js +6 -9
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/check.js.map +1 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/document-tools/index.js +1 -1
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +14 -40
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +5 -2
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -1
- package/build-module/components/editor-help/help-section-title.native.js.map +1 -1
- package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build-module/components/editor-help/icon-move-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/view-sections.native.js.map +1 -1
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/editor-notices/index.js.map +1 -1
- package/build-module/components/editor-snackbars/index.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +11 -85
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/index.native.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +24 -0
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +7 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +5 -1
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +71 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js +118 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +48 -0
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
- package/build-module/components/list-view-sidebar/index.js +2 -1
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/mode-switcher/index.js.map +1 -1
- package/build-module/components/offline-status/index.native.js.map +1 -1
- package/build-module/components/page-attributes/check.js.map +1 -1
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/page-attributes/panel.js.map +1 -1
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/pattern-overrides-panel/index.js +23 -0
- package/build-module/components/pattern-overrides-panel/index.js.map +1 -0
- package/build-module/components/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/plugin-more-menu-item/index.js +73 -0
- package/build-module/components/plugin-more-menu-item/index.js.map +1 -0
- package/build-module/components/plugin-post-publish-panel/index.js +61 -0
- package/build-module/components/plugin-post-publish-panel/index.js.map +1 -0
- package/build-module/components/plugin-post-status-info/index.js +66 -0
- package/build-module/components/plugin-post-status-info/index.js.map +1 -0
- package/build-module/components/plugin-pre-publish-panel/index.js +64 -0
- package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -0
- package/build-module/components/plugin-sidebar/index.js +102 -0
- package/build-module/components/plugin-sidebar/index.js.map +1 -0
- package/build-module/components/plugin-sidebar-more-menu-item/index.js +65 -0
- package/build-module/components/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build-module/components/post-actions/actions.js +648 -0
- package/build-module/components/post-actions/actions.js.map +1 -0
- package/build-module/components/post-actions/index.js +130 -0
- package/build-module/components/post-actions/index.js.map +1 -0
- package/build-module/components/post-author/check.js.map +1 -1
- package/build-module/components/post-author/combobox.js.map +1 -1
- package/build-module/components/post-author/constants.js.map +1 -1
- package/build-module/components/post-author/hook.js.map +1 -1
- package/build-module/components/post-author/index.js.map +1 -1
- package/build-module/components/post-author/panel.js.map +1 -1
- package/build-module/components/post-author/select.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +119 -0
- package/build-module/components/post-card-panel/index.js.map +1 -0
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/check.js +9 -0
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-excerpt/plugin.js.map +1 -1
- package/build-module/components/post-featured-image/check.js.map +1 -1
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js.map +1 -1
- package/build-module/components/post-format/check.js.map +1 -1
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-last-revision/check.js.map +1 -1
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-last-revision/panel.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-panel-row/index.js.map +1 -1
- package/build-module/components/post-pending-status/check.js.map +1 -1
- package/build-module/components/post-pending-status/index.js.map +1 -1
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +31 -31
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +51 -42
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
- package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +10 -6
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/check.js.map +1 -1
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +8 -0
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-slug/check.js.map +1 -1
- package/build-module/components/post-slug/index.js +44 -68
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-status/index.js +231 -0
- package/build-module/components/post-status/index.js.map +1 -0
- package/build-module/components/post-sticky/check.js.map +1 -1
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +7 -1
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/check.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-taxonomies/panel.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +7 -3
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/create-new-template.js.map +1 -1
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/post-template/reset-default-template.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-text-editor/index.js.map +1 -1
- package/build-module/components/post-title/constants.js.map +1 -1
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/index.native.js +1 -1
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-title/use-post-title-focus.js.map +1 -1
- package/build-module/components/post-title/use-post-title.js.map +1 -1
- package/build-module/components/post-trash/check.js +24 -26
- package/build-module/components/post-trash/check.js.map +1 -1
- package/build-module/components/post-trash/index.js +2 -1
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/post-url/check.js.map +1 -1
- package/build-module/components/post-url/index.js +46 -21
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/post-url/label.js.map +1 -1
- package/build-module/components/post-url/panel.js +14 -7
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/post-view-link/index.js.map +1 -1
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/post-visibility/index.js +2 -1
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/post-visibility/utils.js.map +1 -1
- package/build-module/components/preferences-modal/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +19 -17
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +36 -20
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/index.js +5 -3
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -1
- package/build-module/components/provider/use-auto-switch-editor-sidebars.js +46 -0
- package/build-module/components/provider/use-auto-switch-editor-sidebars.js.map +1 -0
- package/build-module/components/provider/use-block-editor-settings.js +73 -53
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build-module/components/provider/with-registry-provider.js +1 -0
- package/build-module/components/provider/with-registry-provider.js.map +1 -1
- package/build-module/components/start-page-options/index.js +132 -0
- package/build-module/components/start-page-options/index.js.map +1 -0
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/table-of-contents/panel.js.map +1 -1
- package/build-module/components/template-areas/index.js +63 -0
- package/build-module/components/template-areas/index.js.map +1 -0
- package/build-module/components/template-validation-notice/index.js +25 -31
- package/build-module/components/template-validation-notice/index.js.map +1 -1
- package/build-module/components/theme-support-check/index.js +11 -16
- package/build-module/components/theme-support-check/index.js.map +1 -1
- package/build-module/components/time-to-read/index.js.map +1 -1
- package/build-module/components/unsaved-changes-warning/index.js.map +1 -1
- package/build-module/components/word-count/index.js.map +1 -1
- package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build-module/hooks/default-autocompleters.js.map +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +22 -10
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/hooks/use-select-nearest-editable-block.js +80 -0
- package/build-module/hooks/use-select-nearest-editable-block.js.map +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +24 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +37 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/actions.native.js.map +1 -1
- package/build-module/store/constants.js +9 -0
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/local-autosave.js.map +1 -1
- package/build-module/store/private-actions.js +249 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +50 -4
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +13 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +20 -16
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/selectors.native.js.map +1 -1
- package/build-module/store/utils/get-filtered-template-parts.js +64 -0
- package/build-module/store/utils/get-filtered-template-parts.js.map +1 -0
- package/build-module/store/utils/is-template-revertable.js +22 -0
- package/build-module/store/utils/is-template-revertable.js.map +1 -0
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-module/utils/get-template-part-icon.js.map +1 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/index.native.js.map +1 -1
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-module/utils/media-upload/index.native.js.map +1 -1
- package/build-module/utils/terms.js.map +1 -1
- package/build-module/utils/url.js.map +1 -1
- package/build-style/style-rtl.css +565 -49
- package/build-style/style.css +565 -49
- package/package.json +36 -36
- package/src/bindings/post-meta.js +11 -27
- package/src/components/autosave-monitor/index.js +9 -0
- package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +108 -0
- package/src/components/commands/index.js +21 -2
- package/src/components/deprecated.js +157 -0
- package/src/components/document-bar/index.js +9 -15
- package/src/components/document-bar/style.scss +9 -12
- package/src/components/document-tools/index.js +16 -14
- package/src/components/document-tools/style.scss +4 -11
- package/src/components/editor-canvas/edit-template-blocks-notification.js +17 -53
- package/src/components/editor-canvas/index.js +8 -4
- package/src/components/entities-saved-states/index.js +12 -113
- package/src/components/error-boundary/style.native.scss +1 -1
- package/src/components/global-keyboard-shortcuts/index.js +25 -0
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +20 -0
- package/src/components/index.js +7 -0
- package/src/components/inserter-sidebar/index.js +7 -1
- package/src/components/keyboard-shortcut-help-modal/config.js +53 -0
- package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +43 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +160 -0
- package/src/components/keyboard-shortcut-help-modal/shortcut.js +67 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +61 -0
- package/src/components/list-view-sidebar/index.js +1 -0
- package/src/components/list-view-sidebar/style.scss +1 -1
- package/src/components/pattern-overrides-panel/index.js +26 -0
- package/src/components/plugin-more-menu-item/index.js +73 -0
- package/src/components/plugin-post-publish-panel/index.js +64 -0
- package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +39 -0
- package/src/components/plugin-post-publish-panel/test/index.js +33 -0
- package/src/components/plugin-post-status-info/index.js +63 -0
- package/src/components/plugin-pre-publish-panel/index.js +67 -0
- package/src/components/plugin-pre-publish-panel/test/index.js +33 -0
- package/src/components/plugin-sidebar/index.js +98 -0
- package/src/components/plugin-sidebar-more-menu-item/index.js +64 -0
- package/src/components/post-actions/actions.js +862 -0
- package/src/components/post-actions/index.js +156 -0
- package/src/components/post-actions/style.scss +3 -0
- package/src/components/post-card-panel/index.js +168 -0
- package/src/components/post-card-panel/style.scss +32 -0
- package/src/components/post-excerpt/check.js +8 -0
- package/src/components/post-featured-image/style.scss +3 -2
- package/src/components/post-publish-button/index.js +23 -36
- package/src/components/post-publish-button/label.js +54 -39
- package/src/components/post-publish-button/test/index.js +15 -26
- package/src/components/post-publish-button/test/label.js +44 -21
- package/src/components/post-saved-state/index.js +13 -6
- package/src/components/post-saved-state/test/index.js +4 -0
- package/src/components/post-schedule/panel.js +22 -0
- package/src/components/post-slug/index.js +50 -68
- package/src/components/post-slug/test/index.js +29 -6
- package/src/components/post-status/index.js +310 -0
- package/src/components/post-status/style.scss +75 -0
- package/src/components/post-switch-to-draft-button/index.js +5 -0
- package/src/components/post-template/block-theme.js +31 -22
- package/src/components/post-title/index.native.js +1 -1
- package/src/components/post-trash/check.js +19 -19
- package/src/components/post-trash/index.js +1 -0
- package/src/components/post-url/index.js +131 -101
- package/src/components/post-url/panel.js +20 -7
- package/src/components/post-url/style.scss +8 -6
- package/src/components/post-visibility/index.js +1 -0
- package/src/components/preferences-modal/index.js +26 -22
- package/src/components/provider/disable-non-page-content-blocks.js +40 -20
- package/src/components/provider/index.js +17 -8
- package/src/components/provider/use-auto-switch-editor-sidebars.js +49 -0
- package/src/components/provider/use-block-editor-settings.js +70 -44
- package/src/components/provider/with-registry-provider.js +1 -0
- package/src/components/start-page-options/index.js +135 -0
- package/src/components/start-page-options/style.scss +26 -0
- package/src/components/template-areas/index.js +85 -0
- package/src/components/template-areas/style.scss +23 -0
- package/src/components/template-validation-notice/index.js +48 -50
- package/src/components/theme-support-check/index.js +9 -16
- package/src/components/theme-support-check/test/index.js +44 -43
- package/src/hooks/pattern-overrides.js +25 -14
- package/src/hooks/use-select-nearest-editable-block.js +95 -0
- package/src/private-apis.js +21 -0
- package/src/store/actions.js +37 -3
- package/src/store/constants.js +9 -0
- package/src/store/private-actions.js +377 -1
- package/src/store/private-selectors.js +101 -18
- package/src/store/reducer.js +13 -0
- package/src/store/selectors.js +51 -46
- package/src/store/utils/get-filtered-template-parts.js +69 -0
- package/src/store/utils/is-template-revertable.js +23 -0
- package/src/store/utils/test/get-filtered-template-parts.js +189 -0
- package/src/style.scss +8 -2
- package/src/components/post-publish-button/style.scss +0 -8
- package/src/components/provider/test/disable-non-page-content-blocks.js +0 -90
- package/src/components/template-validation-notice/style.scss +0 -9
|
@@ -0,0 +1,862 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { external, trash, edit, backup } from '@wordpress/icons';
|
|
5
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
6
|
+
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
10
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
Button,
|
|
15
|
+
TextControl,
|
|
16
|
+
__experimentalText as Text,
|
|
17
|
+
__experimentalHStack as HStack,
|
|
18
|
+
__experimentalVStack as VStack,
|
|
19
|
+
} from '@wordpress/components';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import { TEMPLATE_ORIGINS, TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
25
|
+
import { store as editorStore } from '../../store';
|
|
26
|
+
import { unlock } from '../../lock-unlock';
|
|
27
|
+
import isTemplateRevertable from '../../store/utils/is-template-revertable';
|
|
28
|
+
|
|
29
|
+
function getItemTitle( item ) {
|
|
30
|
+
if ( typeof item.title === 'string' ) {
|
|
31
|
+
return decodeEntities( item.title );
|
|
32
|
+
}
|
|
33
|
+
return decodeEntities( item.title?.rendered || '' );
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const trashPostAction = {
|
|
37
|
+
id: 'move-to-trash',
|
|
38
|
+
label: __( 'Move to Trash' ),
|
|
39
|
+
isPrimary: true,
|
|
40
|
+
icon: trash,
|
|
41
|
+
isEligible( { status } ) {
|
|
42
|
+
return status !== 'trash';
|
|
43
|
+
},
|
|
44
|
+
supportsBulk: true,
|
|
45
|
+
hideModalHeader: true,
|
|
46
|
+
RenderModal: ( { items: posts, closeModal, onActionPerformed } ) => {
|
|
47
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
48
|
+
useDispatch( noticesStore );
|
|
49
|
+
const { deleteEntityRecord } = useDispatch( coreStore );
|
|
50
|
+
return (
|
|
51
|
+
<VStack spacing="5">
|
|
52
|
+
<Text>
|
|
53
|
+
{ posts.length === 1
|
|
54
|
+
? sprintf(
|
|
55
|
+
// translators: %s: The page's title.
|
|
56
|
+
__( 'Are you sure you want to delete "%s"?' ),
|
|
57
|
+
getItemTitle( posts[ 0 ] )
|
|
58
|
+
)
|
|
59
|
+
: sprintf(
|
|
60
|
+
// translators: %d: The number of pages (2 or more).
|
|
61
|
+
_n(
|
|
62
|
+
'Are you sure you want to delete %d page?',
|
|
63
|
+
'Are you sure you want to delete %d pages?',
|
|
64
|
+
posts.length
|
|
65
|
+
),
|
|
66
|
+
posts.length
|
|
67
|
+
) }
|
|
68
|
+
</Text>
|
|
69
|
+
<HStack justify="right">
|
|
70
|
+
<Button variant="tertiary" onClick={ closeModal }>
|
|
71
|
+
{ __( 'Cancel' ) }
|
|
72
|
+
</Button>
|
|
73
|
+
<Button
|
|
74
|
+
variant="primary"
|
|
75
|
+
onClick={ async () => {
|
|
76
|
+
const promiseResult = await Promise.allSettled(
|
|
77
|
+
posts.map( ( post ) => {
|
|
78
|
+
return deleteEntityRecord(
|
|
79
|
+
'postType',
|
|
80
|
+
post.type,
|
|
81
|
+
post.id,
|
|
82
|
+
{},
|
|
83
|
+
{ throwOnError: true }
|
|
84
|
+
);
|
|
85
|
+
} )
|
|
86
|
+
);
|
|
87
|
+
// If all the promises were fulfilled with success.
|
|
88
|
+
if (
|
|
89
|
+
promiseResult.every(
|
|
90
|
+
( { status } ) => status === 'fulfilled'
|
|
91
|
+
)
|
|
92
|
+
) {
|
|
93
|
+
let successMessage;
|
|
94
|
+
if ( promiseResult.length === 1 ) {
|
|
95
|
+
successMessage = sprintf(
|
|
96
|
+
/* translators: The posts's title. */
|
|
97
|
+
__( '"%s" moved to the Trash.' ),
|
|
98
|
+
getItemTitle( posts[ 0 ] )
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
successMessage = __(
|
|
102
|
+
'Pages moved to the Trash.'
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
createSuccessNotice( successMessage, {
|
|
106
|
+
type: 'snackbar',
|
|
107
|
+
id: 'edit-site-page-trashed',
|
|
108
|
+
} );
|
|
109
|
+
} else {
|
|
110
|
+
// If there was at lease one failure.
|
|
111
|
+
let errorMessage;
|
|
112
|
+
// If we were trying to move a single post to the trash.
|
|
113
|
+
if ( promiseResult.length === 1 ) {
|
|
114
|
+
if ( promiseResult[ 0 ].reason?.message ) {
|
|
115
|
+
errorMessage =
|
|
116
|
+
promiseResult[ 0 ].reason.message;
|
|
117
|
+
} else {
|
|
118
|
+
errorMessage = __(
|
|
119
|
+
'An error occurred while moving the post to the trash.'
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
// If we were trying to move multiple posts to the trash
|
|
123
|
+
} else {
|
|
124
|
+
const errorMessages = new Set();
|
|
125
|
+
const failedPromises = promiseResult.filter(
|
|
126
|
+
( { status } ) => status === 'rejected'
|
|
127
|
+
);
|
|
128
|
+
for ( const failedPromise of failedPromises ) {
|
|
129
|
+
if ( failedPromise.reason?.message ) {
|
|
130
|
+
errorMessages.add(
|
|
131
|
+
failedPromise.reason.message
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if ( errorMessages.size === 0 ) {
|
|
136
|
+
errorMessage = __(
|
|
137
|
+
'An error occurred while moving the posts to the trash.'
|
|
138
|
+
);
|
|
139
|
+
} else if ( errorMessages.size === 1 ) {
|
|
140
|
+
errorMessage = sprintf(
|
|
141
|
+
/* translators: %s: an error message */
|
|
142
|
+
__(
|
|
143
|
+
'An error occurred while moving the posts to the trash: %s'
|
|
144
|
+
),
|
|
145
|
+
[ ...errorMessages ][ 0 ]
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
errorMessage = sprintf(
|
|
149
|
+
/* translators: %s: a list of comma separated error messages */
|
|
150
|
+
__(
|
|
151
|
+
'Some errors occurred while moving the pages to the trash: %s'
|
|
152
|
+
),
|
|
153
|
+
[ ...errorMessages ].join( ',' )
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
createErrorNotice( errorMessage, {
|
|
158
|
+
type: 'snackbar',
|
|
159
|
+
} );
|
|
160
|
+
}
|
|
161
|
+
if ( onActionPerformed ) {
|
|
162
|
+
onActionPerformed( posts );
|
|
163
|
+
}
|
|
164
|
+
closeModal();
|
|
165
|
+
} }
|
|
166
|
+
>
|
|
167
|
+
{ __( 'Delete' ) }
|
|
168
|
+
</Button>
|
|
169
|
+
</HStack>
|
|
170
|
+
</VStack>
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
function usePermanentlyDeletePostAction() {
|
|
176
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
177
|
+
useDispatch( noticesStore );
|
|
178
|
+
const { deleteEntityRecord } = useDispatch( coreStore );
|
|
179
|
+
|
|
180
|
+
return useMemo(
|
|
181
|
+
() => ( {
|
|
182
|
+
id: 'permanently-delete',
|
|
183
|
+
label: __( 'Permanently delete' ),
|
|
184
|
+
supportsBulk: true,
|
|
185
|
+
isEligible( { status } ) {
|
|
186
|
+
return status === 'trash';
|
|
187
|
+
},
|
|
188
|
+
async callback( posts, onActionPerformed ) {
|
|
189
|
+
const promiseResult = await Promise.allSettled(
|
|
190
|
+
posts.map( ( post ) => {
|
|
191
|
+
return deleteEntityRecord(
|
|
192
|
+
'postType',
|
|
193
|
+
post.type,
|
|
194
|
+
post.id,
|
|
195
|
+
{ force: true },
|
|
196
|
+
{ throwOnError: true }
|
|
197
|
+
);
|
|
198
|
+
} )
|
|
199
|
+
);
|
|
200
|
+
// If all the promises were fulfilled with success.
|
|
201
|
+
if (
|
|
202
|
+
promiseResult.every(
|
|
203
|
+
( { status } ) => status === 'fulfilled'
|
|
204
|
+
)
|
|
205
|
+
) {
|
|
206
|
+
let successMessage;
|
|
207
|
+
if ( promiseResult.length === 1 ) {
|
|
208
|
+
successMessage = sprintf(
|
|
209
|
+
/* translators: The posts's title. */
|
|
210
|
+
__( '"%s" permanently deleted.' ),
|
|
211
|
+
getItemTitle( posts[ 0 ] )
|
|
212
|
+
);
|
|
213
|
+
} else {
|
|
214
|
+
successMessage = __(
|
|
215
|
+
'The posts were permanently deleted.'
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
createSuccessNotice( successMessage, {
|
|
219
|
+
type: 'snackbar',
|
|
220
|
+
id: 'edit-site-post-permanently-deleted',
|
|
221
|
+
} );
|
|
222
|
+
if ( onActionPerformed ) {
|
|
223
|
+
onActionPerformed( posts );
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
// If there was at lease one failure.
|
|
227
|
+
let errorMessage;
|
|
228
|
+
// If we were trying to permanently delete a single post.
|
|
229
|
+
if ( promiseResult.length === 1 ) {
|
|
230
|
+
if ( promiseResult[ 0 ].reason?.message ) {
|
|
231
|
+
errorMessage = promiseResult[ 0 ].reason.message;
|
|
232
|
+
} else {
|
|
233
|
+
errorMessage = __(
|
|
234
|
+
'An error occurred while permanently deleting the post.'
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
// If we were trying to permanently delete multiple posts
|
|
238
|
+
} else {
|
|
239
|
+
const errorMessages = new Set();
|
|
240
|
+
const failedPromises = promiseResult.filter(
|
|
241
|
+
( { status } ) => status === 'rejected'
|
|
242
|
+
);
|
|
243
|
+
for ( const failedPromise of failedPromises ) {
|
|
244
|
+
if ( failedPromise.reason?.message ) {
|
|
245
|
+
errorMessages.add(
|
|
246
|
+
failedPromise.reason.message
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if ( errorMessages.size === 0 ) {
|
|
251
|
+
errorMessage = __(
|
|
252
|
+
'An error occurred while permanently deleting the posts.'
|
|
253
|
+
);
|
|
254
|
+
} else if ( errorMessages.size === 1 ) {
|
|
255
|
+
errorMessage = sprintf(
|
|
256
|
+
/* translators: %s: an error message */
|
|
257
|
+
__(
|
|
258
|
+
'An error occurred while permanently deleting the posts: %s'
|
|
259
|
+
),
|
|
260
|
+
[ ...errorMessages ][ 0 ]
|
|
261
|
+
);
|
|
262
|
+
} else {
|
|
263
|
+
errorMessage = sprintf(
|
|
264
|
+
/* translators: %s: a list of comma separated error messages */
|
|
265
|
+
__(
|
|
266
|
+
'Some errors occurred while permanently deleting the posts: %s'
|
|
267
|
+
),
|
|
268
|
+
[ ...errorMessages ].join( ',' )
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
createErrorNotice( errorMessage, {
|
|
273
|
+
type: 'snackbar',
|
|
274
|
+
} );
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
} ),
|
|
278
|
+
[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function useRestorePostAction() {
|
|
283
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
284
|
+
useDispatch( noticesStore );
|
|
285
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
286
|
+
useDispatch( coreStore );
|
|
287
|
+
|
|
288
|
+
return useMemo(
|
|
289
|
+
() => ( {
|
|
290
|
+
id: 'restore',
|
|
291
|
+
label: __( 'Restore' ),
|
|
292
|
+
isPrimary: true,
|
|
293
|
+
icon: backup,
|
|
294
|
+
supportsBulk: true,
|
|
295
|
+
isEligible( { status } ) {
|
|
296
|
+
return status === 'trash';
|
|
297
|
+
},
|
|
298
|
+
async callback( posts, onActionPerformed ) {
|
|
299
|
+
try {
|
|
300
|
+
for ( const post of posts ) {
|
|
301
|
+
await editEntityRecord(
|
|
302
|
+
'postType',
|
|
303
|
+
post.type,
|
|
304
|
+
post.id,
|
|
305
|
+
{
|
|
306
|
+
status: 'draft',
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
await saveEditedEntityRecord(
|
|
310
|
+
'postType',
|
|
311
|
+
post.type,
|
|
312
|
+
post.id,
|
|
313
|
+
{ throwOnError: true }
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
createSuccessNotice(
|
|
318
|
+
posts.length > 1
|
|
319
|
+
? sprintf(
|
|
320
|
+
/* translators: The number of posts. */
|
|
321
|
+
__( '%d posts have been restored.' ),
|
|
322
|
+
posts.length
|
|
323
|
+
)
|
|
324
|
+
: sprintf(
|
|
325
|
+
/* translators: The number of posts. */
|
|
326
|
+
__( '"%s" has been restored.' ),
|
|
327
|
+
getItemTitle( posts[ 0 ] )
|
|
328
|
+
),
|
|
329
|
+
{
|
|
330
|
+
type: 'snackbar',
|
|
331
|
+
id: 'edit-site-post-restored',
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
if ( onActionPerformed ) {
|
|
335
|
+
onActionPerformed( posts );
|
|
336
|
+
}
|
|
337
|
+
} catch ( error ) {
|
|
338
|
+
let errorMessage;
|
|
339
|
+
if (
|
|
340
|
+
error.message &&
|
|
341
|
+
error.code !== 'unknown_error' &&
|
|
342
|
+
error.message
|
|
343
|
+
) {
|
|
344
|
+
errorMessage = error.message;
|
|
345
|
+
} else if ( posts.length > 1 ) {
|
|
346
|
+
errorMessage = __(
|
|
347
|
+
'An error occurred while restoring the posts.'
|
|
348
|
+
);
|
|
349
|
+
} else {
|
|
350
|
+
errorMessage = __(
|
|
351
|
+
'An error occurred while restoring the post.'
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
} ),
|
|
359
|
+
[
|
|
360
|
+
createSuccessNotice,
|
|
361
|
+
createErrorNotice,
|
|
362
|
+
editEntityRecord,
|
|
363
|
+
saveEditedEntityRecord,
|
|
364
|
+
]
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const viewPostAction = {
|
|
369
|
+
id: 'view-post',
|
|
370
|
+
label: __( 'View' ),
|
|
371
|
+
isPrimary: true,
|
|
372
|
+
icon: external,
|
|
373
|
+
isEligible( post ) {
|
|
374
|
+
return post.status !== 'trash';
|
|
375
|
+
},
|
|
376
|
+
callback( posts, onActionPerformed ) {
|
|
377
|
+
const post = posts[ 0 ];
|
|
378
|
+
window.open( post.link, '_blank' );
|
|
379
|
+
if ( onActionPerformed ) {
|
|
380
|
+
onActionPerformed( posts );
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const editPostAction = {
|
|
386
|
+
id: 'edit-post',
|
|
387
|
+
label: __( 'Edit' ),
|
|
388
|
+
isPrimary: true,
|
|
389
|
+
icon: edit,
|
|
390
|
+
isEligible( { status } ) {
|
|
391
|
+
return status !== 'trash';
|
|
392
|
+
},
|
|
393
|
+
callback( posts, onActionPerformed ) {
|
|
394
|
+
if ( onActionPerformed ) {
|
|
395
|
+
onActionPerformed( posts );
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
const postRevisionsAction = {
|
|
400
|
+
id: 'view-post-revisions',
|
|
401
|
+
label: __( 'View revisions' ),
|
|
402
|
+
isPrimary: false,
|
|
403
|
+
isEligible: ( post ) => {
|
|
404
|
+
if ( post.status === 'trash' ) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
const lastRevisionId =
|
|
408
|
+
post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;
|
|
409
|
+
const revisionsCount =
|
|
410
|
+
post?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
411
|
+
return lastRevisionId && revisionsCount > 1;
|
|
412
|
+
},
|
|
413
|
+
callback( posts, onActionPerformed ) {
|
|
414
|
+
const post = posts[ 0 ];
|
|
415
|
+
const href = addQueryArgs( 'revision.php', {
|
|
416
|
+
revision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,
|
|
417
|
+
} );
|
|
418
|
+
document.location.href = href;
|
|
419
|
+
if ( onActionPerformed ) {
|
|
420
|
+
onActionPerformed( posts );
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const renamePostAction = {
|
|
426
|
+
id: 'rename-post',
|
|
427
|
+
label: __( 'Rename' ),
|
|
428
|
+
isEligible( post ) {
|
|
429
|
+
return post.status !== 'trash';
|
|
430
|
+
},
|
|
431
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
432
|
+
const [ item ] = items;
|
|
433
|
+
const originalTitle = decodeEntities(
|
|
434
|
+
typeof item.title === 'string' ? item.title : item.title.rendered
|
|
435
|
+
);
|
|
436
|
+
const [ title, setTitle ] = useState( () => originalTitle );
|
|
437
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
438
|
+
useDispatch( coreStore );
|
|
439
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
440
|
+
useDispatch( noticesStore );
|
|
441
|
+
|
|
442
|
+
async function onRename( event ) {
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
try {
|
|
445
|
+
await editEntityRecord( 'postType', item.type, item.id, {
|
|
446
|
+
title,
|
|
447
|
+
} );
|
|
448
|
+
// Update state before saving rerenders the list.
|
|
449
|
+
setTitle( '' );
|
|
450
|
+
closeModal();
|
|
451
|
+
// Persist edited entity.
|
|
452
|
+
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
453
|
+
throwOnError: true,
|
|
454
|
+
} );
|
|
455
|
+
createSuccessNotice( __( 'Name updated' ), {
|
|
456
|
+
type: 'snackbar',
|
|
457
|
+
} );
|
|
458
|
+
onActionPerformed?.( items );
|
|
459
|
+
} catch ( error ) {
|
|
460
|
+
const errorMessage =
|
|
461
|
+
error.message && error.code !== 'unknown_error'
|
|
462
|
+
? error.message
|
|
463
|
+
: __( 'An error occurred while updating the name' );
|
|
464
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return (
|
|
469
|
+
<form onSubmit={ onRename }>
|
|
470
|
+
<VStack spacing="5">
|
|
471
|
+
<TextControl
|
|
472
|
+
__nextHasNoMarginBottom
|
|
473
|
+
__next40pxDefaultSize
|
|
474
|
+
label={ __( 'Name' ) }
|
|
475
|
+
value={ title }
|
|
476
|
+
onChange={ setTitle }
|
|
477
|
+
required
|
|
478
|
+
/>
|
|
479
|
+
<HStack justify="right">
|
|
480
|
+
<Button
|
|
481
|
+
__next40pxDefaultSize
|
|
482
|
+
variant="tertiary"
|
|
483
|
+
onClick={ () => {
|
|
484
|
+
closeModal();
|
|
485
|
+
} }
|
|
486
|
+
>
|
|
487
|
+
{ __( 'Cancel' ) }
|
|
488
|
+
</Button>
|
|
489
|
+
<Button
|
|
490
|
+
__next40pxDefaultSize
|
|
491
|
+
variant="primary"
|
|
492
|
+
type="submit"
|
|
493
|
+
>
|
|
494
|
+
{ __( 'Save' ) }
|
|
495
|
+
</Button>
|
|
496
|
+
</HStack>
|
|
497
|
+
</VStack>
|
|
498
|
+
</form>
|
|
499
|
+
);
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const resetTemplateAction = {
|
|
504
|
+
id: 'reset-template',
|
|
505
|
+
label: __( 'Reset' ),
|
|
506
|
+
isEligible: isTemplateRevertable,
|
|
507
|
+
supportsBulk: true,
|
|
508
|
+
hideModalHeader: true,
|
|
509
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
510
|
+
const { revertTemplate } = unlock( useDispatch( editorStore ) );
|
|
511
|
+
const { saveEditedEntityRecord } = useDispatch( coreStore );
|
|
512
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
513
|
+
useDispatch( noticesStore );
|
|
514
|
+
const onConfirm = async () => {
|
|
515
|
+
try {
|
|
516
|
+
for ( const template of items ) {
|
|
517
|
+
await revertTemplate( template, {
|
|
518
|
+
allowUndo: false,
|
|
519
|
+
} );
|
|
520
|
+
await saveEditedEntityRecord(
|
|
521
|
+
'postType',
|
|
522
|
+
template.type,
|
|
523
|
+
template.id
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
createSuccessNotice(
|
|
528
|
+
items.length > 1
|
|
529
|
+
? sprintf(
|
|
530
|
+
/* translators: The number of items. */
|
|
531
|
+
__( '%s items reset.' ),
|
|
532
|
+
items.length
|
|
533
|
+
)
|
|
534
|
+
: sprintf(
|
|
535
|
+
/* translators: The template/part's name. */
|
|
536
|
+
__( '"%s" reset.' ),
|
|
537
|
+
decodeEntities( items[ 0 ].title.rendered )
|
|
538
|
+
),
|
|
539
|
+
{
|
|
540
|
+
type: 'snackbar',
|
|
541
|
+
id: 'edit-site-template-reverted',
|
|
542
|
+
}
|
|
543
|
+
);
|
|
544
|
+
} catch ( error ) {
|
|
545
|
+
let fallbackErrorMessage;
|
|
546
|
+
if ( items[ 0 ].type === TEMPLATE_POST_TYPE ) {
|
|
547
|
+
fallbackErrorMessage =
|
|
548
|
+
items.length === 1
|
|
549
|
+
? __(
|
|
550
|
+
'An error occurred while reverting the template.'
|
|
551
|
+
)
|
|
552
|
+
: __(
|
|
553
|
+
'An error occurred while reverting the templates.'
|
|
554
|
+
);
|
|
555
|
+
} else {
|
|
556
|
+
fallbackErrorMessage =
|
|
557
|
+
items.length === 1
|
|
558
|
+
? __(
|
|
559
|
+
'An error occurred while reverting the template part.'
|
|
560
|
+
)
|
|
561
|
+
: __(
|
|
562
|
+
'An error occurred while reverting the template parts.'
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
const errorMessage =
|
|
566
|
+
error.message && error.code !== 'unknown_error'
|
|
567
|
+
? error.message
|
|
568
|
+
: fallbackErrorMessage;
|
|
569
|
+
|
|
570
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
return (
|
|
574
|
+
<VStack spacing="5">
|
|
575
|
+
<Text>
|
|
576
|
+
{ __( 'Reset to default and clear all customizations?' ) }
|
|
577
|
+
</Text>
|
|
578
|
+
<HStack justify="right">
|
|
579
|
+
<Button variant="tertiary" onClick={ closeModal }>
|
|
580
|
+
{ __( 'Cancel' ) }
|
|
581
|
+
</Button>
|
|
582
|
+
<Button
|
|
583
|
+
variant="primary"
|
|
584
|
+
onClick={ async () => {
|
|
585
|
+
await onConfirm( items );
|
|
586
|
+
onActionPerformed?.( items );
|
|
587
|
+
closeModal();
|
|
588
|
+
} }
|
|
589
|
+
>
|
|
590
|
+
{ __( 'Reset' ) }
|
|
591
|
+
</Button>
|
|
592
|
+
</HStack>
|
|
593
|
+
</VStack>
|
|
594
|
+
);
|
|
595
|
+
},
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Check if a template is removable.
|
|
600
|
+
* Copy from packages/edit-site/src/utils/is-template-removable.js.
|
|
601
|
+
*
|
|
602
|
+
* @param {Object} template The template entity to check.
|
|
603
|
+
* @return {boolean} Whether the template is revertable.
|
|
604
|
+
*/
|
|
605
|
+
function isTemplateRemovable( template ) {
|
|
606
|
+
if ( ! template ) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return (
|
|
611
|
+
template.source === TEMPLATE_ORIGINS.custom && ! template.has_theme_file
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const deleteTemplateAction = {
|
|
616
|
+
id: 'delete-template',
|
|
617
|
+
label: __( 'Delete' ),
|
|
618
|
+
isEligible: isTemplateRemovable,
|
|
619
|
+
supportsBulk: true,
|
|
620
|
+
hideModalHeader: true,
|
|
621
|
+
RenderModal: ( { items: templates, closeModal, onActionPerformed } ) => {
|
|
622
|
+
const { removeTemplates } = unlock( useDispatch( editorStore ) );
|
|
623
|
+
return (
|
|
624
|
+
<VStack spacing="5">
|
|
625
|
+
<Text>
|
|
626
|
+
{ templates.length > 1
|
|
627
|
+
? sprintf(
|
|
628
|
+
// translators: %d: number of items to delete.
|
|
629
|
+
_n(
|
|
630
|
+
'Delete %d item?',
|
|
631
|
+
'Delete %d items?',
|
|
632
|
+
templates.length
|
|
633
|
+
),
|
|
634
|
+
templates.length
|
|
635
|
+
)
|
|
636
|
+
: sprintf(
|
|
637
|
+
// translators: %s: The template or template part's titles
|
|
638
|
+
__( 'Delete "%s"?' ),
|
|
639
|
+
decodeEntities(
|
|
640
|
+
templates?.[ 0 ]?.title?.rendered
|
|
641
|
+
)
|
|
642
|
+
) }
|
|
643
|
+
</Text>
|
|
644
|
+
<HStack justify="right">
|
|
645
|
+
<Button variant="tertiary" onClick={ closeModal }>
|
|
646
|
+
{ __( 'Cancel' ) }
|
|
647
|
+
</Button>
|
|
648
|
+
<Button
|
|
649
|
+
variant="primary"
|
|
650
|
+
onClick={ async () => {
|
|
651
|
+
await removeTemplates( templates, {
|
|
652
|
+
allowUndo: false,
|
|
653
|
+
} );
|
|
654
|
+
onActionPerformed?.( templates );
|
|
655
|
+
closeModal();
|
|
656
|
+
} }
|
|
657
|
+
>
|
|
658
|
+
{ __( 'Delete' ) }
|
|
659
|
+
</Button>
|
|
660
|
+
</HStack>
|
|
661
|
+
</VStack>
|
|
662
|
+
);
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const renameTemplateAction = {
|
|
667
|
+
id: 'rename-template',
|
|
668
|
+
label: __( 'Rename' ),
|
|
669
|
+
isEligible: ( template ) => {
|
|
670
|
+
// We can only remove templates or template parts that can be removed.
|
|
671
|
+
// Additionally in the case of templates, we can only remove custom templates.
|
|
672
|
+
if (
|
|
673
|
+
! isTemplateRemovable( template ) ||
|
|
674
|
+
( template.type === TEMPLATE_POST_TYPE && ! template.is_custom )
|
|
675
|
+
) {
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
return true;
|
|
679
|
+
},
|
|
680
|
+
RenderModal: ( { items: templates, closeModal, onActionPerformed } ) => {
|
|
681
|
+
const template = templates[ 0 ];
|
|
682
|
+
const title = decodeEntities( template.title.rendered );
|
|
683
|
+
const [ editedTitle, setEditedTitle ] = useState( title );
|
|
684
|
+
const {
|
|
685
|
+
editEntityRecord,
|
|
686
|
+
__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,
|
|
687
|
+
} = useDispatch( coreStore );
|
|
688
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
689
|
+
useDispatch( noticesStore );
|
|
690
|
+
async function onTemplateRename( event ) {
|
|
691
|
+
event.preventDefault();
|
|
692
|
+
try {
|
|
693
|
+
await editEntityRecord(
|
|
694
|
+
'postType',
|
|
695
|
+
template.type,
|
|
696
|
+
template.id,
|
|
697
|
+
{
|
|
698
|
+
title: editedTitle,
|
|
699
|
+
}
|
|
700
|
+
);
|
|
701
|
+
// Update state before saving rerenders the list.
|
|
702
|
+
setEditedTitle( '' );
|
|
703
|
+
closeModal();
|
|
704
|
+
// Persist edited entity.
|
|
705
|
+
await saveSpecifiedEntityEdits(
|
|
706
|
+
'postType',
|
|
707
|
+
template.type,
|
|
708
|
+
template.id,
|
|
709
|
+
[ 'title' ], // Only save title to avoid persisting other edits.
|
|
710
|
+
{
|
|
711
|
+
throwOnError: true,
|
|
712
|
+
}
|
|
713
|
+
);
|
|
714
|
+
createSuccessNotice(
|
|
715
|
+
template.type === TEMPLATE_POST_TYPE
|
|
716
|
+
? __( 'Template renamed.' )
|
|
717
|
+
: __( 'Template part renamed.' ),
|
|
718
|
+
{
|
|
719
|
+
type: 'snackbar',
|
|
720
|
+
}
|
|
721
|
+
);
|
|
722
|
+
onActionPerformed?.( templates );
|
|
723
|
+
} catch ( error ) {
|
|
724
|
+
const fallbackErrorMessage =
|
|
725
|
+
template.type === TEMPLATE_POST_TYPE
|
|
726
|
+
? __( 'An error occurred while renaming the template.' )
|
|
727
|
+
: __(
|
|
728
|
+
'An error occurred while renaming the template part.'
|
|
729
|
+
);
|
|
730
|
+
const errorMessage =
|
|
731
|
+
error.message && error.code !== 'unknown_error'
|
|
732
|
+
? error.message
|
|
733
|
+
: fallbackErrorMessage;
|
|
734
|
+
|
|
735
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return (
|
|
739
|
+
<form onSubmit={ onTemplateRename }>
|
|
740
|
+
<VStack spacing="5">
|
|
741
|
+
<TextControl
|
|
742
|
+
__nextHasNoMarginBottom
|
|
743
|
+
__next40pxDefaultSize
|
|
744
|
+
label={ __( 'Name' ) }
|
|
745
|
+
value={ editedTitle }
|
|
746
|
+
onChange={ setEditedTitle }
|
|
747
|
+
required
|
|
748
|
+
/>
|
|
749
|
+
<HStack justify="right">
|
|
750
|
+
<Button
|
|
751
|
+
variant="tertiary"
|
|
752
|
+
onClick={ closeModal }
|
|
753
|
+
__next40pxDefaultSize
|
|
754
|
+
>
|
|
755
|
+
{ __( 'Cancel' ) }
|
|
756
|
+
</Button>
|
|
757
|
+
<Button
|
|
758
|
+
variant="primary"
|
|
759
|
+
type="submit"
|
|
760
|
+
__next40pxDefaultSize
|
|
761
|
+
>
|
|
762
|
+
{ __( 'Save' ) }
|
|
763
|
+
</Button>
|
|
764
|
+
</HStack>
|
|
765
|
+
</VStack>
|
|
766
|
+
</form>
|
|
767
|
+
);
|
|
768
|
+
},
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
export function usePostActions( onActionPerformed, actionIds = null ) {
|
|
772
|
+
const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
|
|
773
|
+
const restorePostAction = useRestorePostAction();
|
|
774
|
+
return useMemo(
|
|
775
|
+
() => {
|
|
776
|
+
// By default, return all actions...
|
|
777
|
+
const defaultActions = [
|
|
778
|
+
editPostAction,
|
|
779
|
+
resetTemplateAction,
|
|
780
|
+
viewPostAction,
|
|
781
|
+
restorePostAction,
|
|
782
|
+
deleteTemplateAction,
|
|
783
|
+
permanentlyDeletePostAction,
|
|
784
|
+
postRevisionsAction,
|
|
785
|
+
renamePostAction,
|
|
786
|
+
renameTemplateAction,
|
|
787
|
+
trashPostAction,
|
|
788
|
+
];
|
|
789
|
+
|
|
790
|
+
// ... unless `actionIds` was specified, in which case we find the
|
|
791
|
+
// actions matching the given IDs.
|
|
792
|
+
const actions = actionIds
|
|
793
|
+
? actionIds.map( ( actionId ) =>
|
|
794
|
+
defaultActions.find( ( { id } ) => actionId === id )
|
|
795
|
+
)
|
|
796
|
+
: defaultActions;
|
|
797
|
+
|
|
798
|
+
if ( onActionPerformed ) {
|
|
799
|
+
for ( let i = 0; i < actions.length; ++i ) {
|
|
800
|
+
if ( actions[ i ].callback ) {
|
|
801
|
+
const existingCallback = actions[ i ].callback;
|
|
802
|
+
actions[ i ] = {
|
|
803
|
+
...actions[ i ],
|
|
804
|
+
callback: ( items, _onActionPerformed ) => {
|
|
805
|
+
existingCallback( items, ( _items ) => {
|
|
806
|
+
if ( _onActionPerformed ) {
|
|
807
|
+
_onActionPerformed( _items );
|
|
808
|
+
}
|
|
809
|
+
onActionPerformed(
|
|
810
|
+
actions[ i ].id,
|
|
811
|
+
_items
|
|
812
|
+
);
|
|
813
|
+
} );
|
|
814
|
+
},
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
if ( actions[ i ].RenderModal ) {
|
|
818
|
+
const ExistingRenderModal = actions[ i ].RenderModal;
|
|
819
|
+
actions[ i ] = {
|
|
820
|
+
...actions[ i ],
|
|
821
|
+
RenderModal: ( props ) => {
|
|
822
|
+
return (
|
|
823
|
+
<ExistingRenderModal
|
|
824
|
+
items={ props.items }
|
|
825
|
+
closeModal={ props.closeModal }
|
|
826
|
+
onActionPerformed={ ( _items ) => {
|
|
827
|
+
if ( props.onActionPerformed ) {
|
|
828
|
+
props.onActionPerformed(
|
|
829
|
+
_items
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
onActionPerformed(
|
|
833
|
+
actions[ i ].id,
|
|
834
|
+
_items
|
|
835
|
+
);
|
|
836
|
+
} }
|
|
837
|
+
/>
|
|
838
|
+
);
|
|
839
|
+
},
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
return actions;
|
|
845
|
+
},
|
|
846
|
+
|
|
847
|
+
// Disable reason: if provided, `actionIds` is a shallow array of
|
|
848
|
+
// strings, and the strings themselves should be part of the useMemo
|
|
849
|
+
// dependencies. Two different disable statements are needed, as the
|
|
850
|
+
// first flags what it thinks are missing dependencies, and the second
|
|
851
|
+
// flags the array spread operation.
|
|
852
|
+
//
|
|
853
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
854
|
+
[
|
|
855
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
856
|
+
...( actionIds || [] ),
|
|
857
|
+
permanentlyDeletePostAction,
|
|
858
|
+
restorePostAction,
|
|
859
|
+
onActionPerformed,
|
|
860
|
+
]
|
|
861
|
+
);
|
|
862
|
+
}
|