@wordpress/editor 14.1.0 → 14.3.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 +16 -12
- package/README.md +28 -7
- package/build/bindings/pattern-overrides.js +8 -5
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/bindings/post-meta.js +4 -0
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +2 -0
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/document-bar/index.js +11 -4
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/editor-interface/index.js +6 -3
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +4 -12
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/index.js +1 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +1 -1
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +6 -65
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/index.js +6 -2
- package/build/components/header/index.js.map +1 -1
- package/build/components/index.js +10 -2
- package/build/components/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +10 -21
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/list-view-sidebar/index.js +19 -47
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/page-attributes/parent.js +2 -1
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-actions/actions.js +371 -452
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +7 -2
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-excerpt/index.js +2 -1
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +3 -2
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-preview-button/index.js +1 -1
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +1 -1
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +11 -1
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/index.js +3 -0
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-slug/check.js +8 -1
- package/build/components/post-slug/check.js.map +1 -1
- package/build/components/post-slug/index.js +6 -0
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-status/index.js +4 -2
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-sticky/index.js +9 -13
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +2 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-title/index.js +5 -13
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +1 -1
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.native.js +0 -4
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +7 -4
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/save-publish-panels/index.js +30 -16
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build/components/sidebar/index.js +4 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-summary.js +2 -4
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/template-content-panel/index.js +29 -4
- package/build/components/template-content-panel/index.js.map +1 -1
- package/build/components/template-part-content-panel/index.js +70 -0
- package/build/components/template-part-content-panel/index.js.map +1 -0
- package/build/components/visual-editor/index.js +1 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/dataviews/actions/delete-post.js +96 -0
- package/build/dataviews/actions/delete-post.js.map +1 -0
- package/build/{components/post-actions/export-pattern-action.js → dataviews/actions/export-pattern.js} +11 -20
- package/build/dataviews/actions/export-pattern.js.map +1 -0
- package/build/dataviews/actions/index.js +32 -0
- package/build/dataviews/actions/index.js.map +1 -0
- package/build/dataviews/actions/reset-post.js +111 -0
- package/build/dataviews/actions/reset-post.js.map +1 -0
- package/build/dataviews/actions/utils.js +50 -0
- package/build/dataviews/actions/utils.js.map +1 -0
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/dataviews/store/private-selectors.js +6 -6
- package/build/dataviews/store/private-selectors.js.map +1 -1
- package/build/dataviews/store/reducer.js +6 -2
- package/build/dataviews/store/reducer.js.map +1 -1
- package/build/dataviews/types.js +6 -0
- package/build/dataviews/types.js.map +1 -0
- package/build/hooks/pattern-overrides.js +3 -3
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +0 -2
- package/build/private-apis.native.js.map +1 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/private-actions.js +9 -5
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -18
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/utils/is-template-revertable.js +6 -8
- package/build/store/utils/is-template-revertable.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +8 -5
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/bindings/post-meta.js +4 -0
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +2 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +11 -4
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-interface/index.js +6 -3
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +6 -14
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +1 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +7 -66
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/index.js +6 -2
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/index.js +11 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +11 -22
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/list-view-sidebar/index.js +20 -49
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +2 -1
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/post-actions/actions.js +370 -450
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +7 -2
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +2 -1
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +3 -2
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +1 -1
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +1 -1
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +11 -1
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/index.js +3 -0
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-slug/check.js +9 -0
- package/build-module/components/post-slug/check.js.map +1 -1
- package/build-module/components/post-slug/index.js +6 -0
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-status/index.js +3 -2
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-sticky/index.js +10 -14
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +2 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-title/index.js +5 -13
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +1 -1
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +0 -4
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +7 -4
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +30 -16
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +4 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +2 -4
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/template-content-panel/index.js +30 -5
- package/build-module/components/template-content-panel/index.js.map +1 -1
- package/build-module/components/template-part-content-panel/index.js +63 -0
- package/build-module/components/template-part-content-panel/index.js.map +1 -0
- package/build-module/components/visual-editor/index.js +1 -1
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/dataviews/actions/delete-post.js +87 -0
- package/build-module/dataviews/actions/delete-post.js.map +1 -0
- package/build-module/{components/post-actions/export-pattern-action.js → dataviews/actions/export-pattern.js} +10 -19
- package/build-module/dataviews/actions/export-pattern.js.map +1 -0
- package/build-module/dataviews/actions/index.js +24 -0
- package/build-module/dataviews/actions/index.js.map +1 -0
- package/build-module/dataviews/actions/reset-post.js +104 -0
- package/build-module/dataviews/actions/reset-post.js.map +1 -0
- package/build-module/dataviews/actions/utils.js +41 -0
- package/build-module/dataviews/actions/utils.js.map +1 -0
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/dataviews/store/private-selectors.js +5 -5
- package/build-module/dataviews/store/private-selectors.js.map +1 -1
- package/build-module/dataviews/store/reducer.js +6 -2
- package/build-module/dataviews/store/reducer.js.map +1 -1
- package/build-module/dataviews/types.js +2 -0
- package/build-module/dataviews/types.js.map +1 -0
- package/build-module/hooks/pattern-overrides.js +4 -2
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +0 -2
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/private-actions.js +9 -5
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -17
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/utils/is-template-revertable.js +6 -8
- package/build-module/store/utils/is-template-revertable.js.map +1 -1
- package/build-style/style-rtl.css +26 -76
- package/build-style/style.css +26 -76
- package/build-types/bindings/index.d.ts +2 -0
- package/build-types/bindings/index.d.ts.map +1 -0
- package/build-types/bindings/pattern-overrides.d.ts +18 -0
- package/build-types/bindings/pattern-overrides.d.ts.map +1 -0
- package/build-types/bindings/post-meta.d.ts +25 -0
- package/build-types/bindings/post-meta.d.ts.map +1 -0
- package/build-types/components/autocompleters/index.d.ts +2 -0
- package/build-types/components/autocompleters/index.d.ts.map +1 -0
- package/build-types/components/autocompleters/user.d.ts +6 -0
- package/build-types/components/autocompleters/user.d.ts.map +1 -0
- package/build-types/components/autosave-monitor/index.d.ts +15 -0
- package/build-types/components/autosave-monitor/index.d.ts.map +1 -0
- package/build-types/components/block-manager/category.d.ts +6 -0
- package/build-types/components/block-manager/category.d.ts.map +1 -0
- package/build-types/components/block-manager/checklist.d.ts +7 -0
- package/build-types/components/block-manager/checklist.d.ts.map +1 -0
- package/build-types/components/block-manager/index.d.ts +3 -0
- package/build-types/components/block-manager/index.d.ts.map +1 -0
- package/build-types/components/block-removal-warnings/index.d.ts +2 -0
- package/build-types/components/block-removal-warnings/index.d.ts.map +1 -0
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts +2 -0
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +1 -0
- package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts +65 -0
- package/build-types/components/block-settings-menu/plugin-block-settings-menu-item.d.ts.map +1 -0
- package/build-types/components/blog-title/index.d.ts +2 -0
- package/build-types/components/blog-title/index.d.ts.map +1 -0
- package/build-types/components/character-count/index.d.ts +7 -0
- package/build-types/components/character-count/index.d.ts.map +1 -0
- package/build-types/components/collapsible-block-toolbar/index.d.ts +6 -0
- package/build-types/components/collapsible-block-toolbar/index.d.ts.map +1 -0
- package/build-types/components/commands/index.d.ts +2 -0
- package/build-types/components/commands/index.d.ts.map +1 -0
- package/build-types/components/create-template-part-modal/index.d.ts +14 -0
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -0
- package/build-types/components/create-template-part-modal/utils.d.ts +4 -0
- package/build-types/components/create-template-part-modal/utils.d.ts.map +1 -0
- package/build-types/components/deprecated.d.ts +182 -0
- package/build-types/components/deprecated.d.ts.map +1 -0
- package/build-types/components/document-bar/index.d.ts +22 -0
- package/build-types/components/document-bar/index.d.ts.map +1 -0
- package/build-types/components/document-outline/check.d.ts +12 -0
- package/build-types/components/document-outline/check.d.ts.map +1 -0
- package/build-types/components/document-outline/index.d.ts +16 -0
- package/build-types/components/document-outline/index.d.ts.map +1 -0
- package/build-types/components/document-outline/item.d.ts +9 -0
- package/build-types/components/document-outline/item.d.ts.map +1 -0
- package/build-types/components/document-tools/index.d.ts +6 -0
- package/build-types/components/document-tools/index.d.ts.map +1 -0
- package/build-types/components/editor/index.d.ts +14 -0
- package/build-types/components/editor/index.d.ts.map +1 -0
- package/build-types/components/editor-history/redo.d.ts +4 -0
- package/build-types/components/editor-history/redo.d.ts.map +1 -0
- package/build-types/components/editor-history/undo.d.ts +4 -0
- package/build-types/components/editor-history/undo.d.ts.map +1 -0
- package/build-types/components/editor-interface/content-slot-fill.d.ts +3 -0
- package/build-types/components/editor-interface/content-slot-fill.d.ts.map +1 -0
- package/build-types/components/editor-interface/index.d.ts +17 -0
- package/build-types/components/editor-interface/index.d.ts.map +1 -0
- package/build-types/components/editor-notices/index.d.ts +13 -0
- package/build-types/components/editor-notices/index.d.ts.map +1 -0
- package/build-types/components/editor-snackbars/index.d.ts +7 -0
- package/build-types/components/editor-snackbars/index.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/entity-record-item.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts +6 -0
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts +2 -0
- package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts.map +1 -0
- package/build-types/components/entities-saved-states/index.d.ts +43 -0
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -0
- package/build-types/components/error-boundary/index.d.ts +14 -0
- package/build-types/components/error-boundary/index.d.ts.map +1 -0
- package/build-types/components/global-keyboard-shortcuts/index.d.ts +9 -0
- package/build-types/components/global-keyboard-shortcuts/index.d.ts.map +1 -0
- package/build-types/components/global-keyboard-shortcuts/register-shortcuts.d.ts +8 -0
- package/build-types/components/global-keyboard-shortcuts/register-shortcuts.d.ts.map +1 -0
- package/build-types/components/global-styles-provider/index.d.ts +20 -0
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -0
- package/build-types/components/header/back-button.d.ts +6 -0
- package/build-types/components/header/back-button.d.ts.map +1 -0
- package/build-types/components/header/index.d.ts +10 -0
- package/build-types/components/header/index.d.ts.map +1 -0
- package/build-types/components/index.d.ts +108 -0
- package/build-types/components/index.d.ts.map +1 -0
- package/build-types/components/inserter-sidebar/index.d.ts +2 -0
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +26 -0
- package/build-types/components/keyboard-shortcut-help-modal/config.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts +5 -0
- package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts +3 -0
- package/build-types/components/keyboard-shortcut-help-modal/index.d.ts.map +1 -0
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +8 -0
- package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts.map +1 -0
- package/build-types/components/list-view-sidebar/index.d.ts +2 -0
- package/build-types/components/list-view-sidebar/index.d.ts.map +1 -0
- package/build-types/components/list-view-sidebar/list-view-outline.d.ts +2 -0
- package/build-types/components/list-view-sidebar/list-view-outline.d.ts.map +1 -0
- package/build-types/components/local-autosave-monitor/index.d.ts +3 -0
- package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -0
- package/build-types/components/media-categories/index.d.ts +7 -0
- package/build-types/components/media-categories/index.d.ts.map +1 -0
- package/build-types/components/mode-switcher/index.d.ts +3 -0
- package/build-types/components/mode-switcher/index.d.ts.map +1 -0
- package/build-types/components/more-menu/copy-content-menu-item.d.ts +2 -0
- package/build-types/components/more-menu/copy-content-menu-item.d.ts.map +1 -0
- package/build-types/components/more-menu/index.d.ts +2 -0
- package/build-types/components/more-menu/index.d.ts.map +1 -0
- package/build-types/components/more-menu/tools-more-menu-group.d.ts +6 -0
- package/build-types/components/more-menu/tools-more-menu-group.d.ts.map +1 -0
- package/build-types/components/more-menu/view-more-menu-group.d.ts +6 -0
- package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -0
- package/build-types/components/page-attributes/check.d.ts +13 -0
- package/build-types/components/page-attributes/check.d.ts.map +1 -0
- package/build-types/components/page-attributes/order.d.ts +9 -0
- package/build-types/components/page-attributes/order.d.ts.map +1 -0
- package/build-types/components/page-attributes/panel.d.ts +7 -0
- package/build-types/components/page-attributes/panel.d.ts.map +1 -0
- package/build-types/components/page-attributes/parent.d.ts +11 -0
- package/build-types/components/page-attributes/parent.d.ts.map +1 -0
- package/build-types/components/pattern-duplicate-modal/index.d.ts +3 -0
- package/build-types/components/pattern-duplicate-modal/index.d.ts.map +1 -0
- package/build-types/components/pattern-overrides-panel/index.d.ts +2 -0
- package/build-types/components/pattern-overrides-panel/index.d.ts.map +1 -0
- package/build-types/components/pattern-rename-modal/index.d.ts +3 -0
- package/build-types/components/pattern-rename-modal/index.d.ts.map +1 -0
- package/build-types/components/plugin-document-setting-panel/index.d.ts +69 -0
- package/build-types/components/plugin-document-setting-panel/index.d.ts.map +1 -0
- package/build-types/components/plugin-more-menu-item/index.d.ts +3 -0
- package/build-types/components/plugin-more-menu-item/index.d.ts.map +1 -0
- package/build-types/components/plugin-post-publish-panel/index.d.ts +47 -0
- package/build-types/components/plugin-post-publish-panel/index.d.ts.map +1 -0
- package/build-types/components/plugin-post-status-info/index.d.ts +57 -0
- package/build-types/components/plugin-post-status-info/index.d.ts.map +1 -0
- package/build-types/components/plugin-pre-publish-panel/index.d.ts +50 -0
- package/build-types/components/plugin-pre-publish-panel/index.d.ts.map +1 -0
- package/build-types/components/plugin-sidebar/index.d.ts +73 -0
- package/build-types/components/plugin-sidebar/index.d.ts.map +1 -0
- package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts +52 -0
- package/build-types/components/plugin-sidebar-more-menu-item/index.d.ts.map +1 -0
- package/build-types/components/post-actions/actions.d.ts +31 -0
- package/build-types/components/post-actions/actions.d.ts.map +1 -0
- package/build-types/components/post-actions/index.d.ts +5 -0
- package/build-types/components/post-actions/index.d.ts.map +1 -0
- package/build-types/components/post-author/check.d.ts +13 -0
- package/build-types/components/post-author/check.d.ts.map +1 -0
- package/build-types/components/post-author/combobox.d.ts +2 -0
- package/build-types/components/post-author/combobox.d.ts.map +1 -0
- package/build-types/components/post-author/constants.d.ts +9 -0
- package/build-types/components/post-author/constants.d.ts.map +1 -0
- package/build-types/components/post-author/hook.d.ts +6 -0
- package/build-types/components/post-author/hook.d.ts.map +1 -0
- package/build-types/components/post-author/index.d.ts +8 -0
- package/build-types/components/post-author/index.d.ts.map +1 -0
- package/build-types/components/post-author/panel.d.ts +8 -0
- package/build-types/components/post-author/panel.d.ts.map +1 -0
- package/build-types/components/post-author/select.d.ts +2 -0
- package/build-types/components/post-author/select.d.ts.map +1 -0
- package/build-types/components/post-card-panel/index.d.ts +4 -0
- package/build-types/components/post-card-panel/index.d.ts.map +1 -0
- package/build-types/components/post-comments/index.d.ts +3 -0
- package/build-types/components/post-comments/index.d.ts.map +1 -0
- package/build-types/components/post-content-information/index.d.ts +2 -0
- package/build-types/components/post-content-information/index.d.ts.map +1 -0
- package/build-types/components/post-discussion/panel.d.ts +10 -0
- package/build-types/components/post-discussion/panel.d.ts.map +1 -0
- package/build-types/components/post-excerpt/check.d.ts +13 -0
- package/build-types/components/post-excerpt/check.d.ts.map +1 -0
- package/build-types/components/post-excerpt/index.d.ts +15 -0
- package/build-types/components/post-excerpt/index.d.ts.map +1 -0
- package/build-types/components/post-excerpt/panel.d.ts +8 -0
- package/build-types/components/post-excerpt/panel.d.ts.map +1 -0
- package/build-types/components/post-excerpt/plugin.d.ts +53 -0
- package/build-types/components/post-excerpt/plugin.d.ts.map +1 -0
- package/build-types/components/post-featured-image/check.d.ts +14 -0
- package/build-types/components/post-featured-image/check.d.ts.map +1 -0
- package/build-types/components/post-featured-image/index.d.ts +3 -0
- package/build-types/components/post-featured-image/index.d.ts.map +1 -0
- package/build-types/components/post-featured-image/panel.d.ts +13 -0
- package/build-types/components/post-featured-image/panel.d.ts.map +1 -0
- package/build-types/components/post-format/check.d.ts +5 -0
- package/build-types/components/post-format/check.d.ts.map +1 -0
- package/build-types/components/post-format/index.d.ts +16 -0
- package/build-types/components/post-format/index.d.ts.map +1 -0
- package/build-types/components/post-format/panel.d.ts +8 -0
- package/build-types/components/post-format/panel.d.ts.map +1 -0
- package/build-types/components/post-last-edited-panel/index.d.ts +2 -0
- package/build-types/components/post-last-edited-panel/index.d.ts.map +1 -0
- package/build-types/components/post-last-revision/check.d.ts +13 -0
- package/build-types/components/post-last-revision/check.d.ts.map +1 -0
- package/build-types/components/post-last-revision/index.d.ts +9 -0
- package/build-types/components/post-last-revision/index.d.ts.map +1 -0
- package/build-types/components/post-last-revision/panel.d.ts +8 -0
- package/build-types/components/post-last-revision/panel.d.ts.map +1 -0
- package/build-types/components/post-locked-modal/index.d.ts +8 -0
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -0
- package/build-types/components/post-panel-row/index.d.ts +3 -0
- package/build-types/components/post-panel-row/index.d.ts.map +1 -0
- package/build-types/components/post-panel-section/index.d.ts +6 -0
- package/build-types/components/post-panel-section/index.d.ts.map +1 -0
- package/build-types/components/post-pending-status/check.d.ts +15 -0
- package/build-types/components/post-pending-status/check.d.ts.map +1 -0
- package/build-types/components/post-pending-status/index.d.ts +8 -0
- package/build-types/components/post-pending-status/index.d.ts.map +1 -0
- package/build-types/components/post-pingbacks/index.d.ts +3 -0
- package/build-types/components/post-pingbacks/index.d.ts.map +1 -0
- package/build-types/components/post-preview-button/index.d.ts +23 -0
- package/build-types/components/post-preview-button/index.d.ts.map +1 -0
- package/build-types/components/post-publish-button/index.d.ts +17 -0
- package/build-types/components/post-publish-button/index.d.ts.map +1 -0
- package/build-types/components/post-publish-button/label.d.ts +7 -0
- package/build-types/components/post-publish-button/label.d.ts.map +1 -0
- package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts +17 -0
- package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts.map +1 -0
- package/build-types/components/post-publish-panel/index.d.ts +10 -0
- package/build-types/components/post-publish-panel/index.d.ts.map +1 -0
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts +3 -0
- package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -0
- package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts +2 -0
- package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts.map +1 -0
- package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts +3 -0
- package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -0
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts +2 -0
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -0
- package/build-types/components/post-publish-panel/postpublish.d.ts +3 -0
- package/build-types/components/post-publish-panel/postpublish.d.ts.map +1 -0
- package/build-types/components/post-publish-panel/prepublish.d.ts +5 -0
- package/build-types/components/post-publish-panel/prepublish.d.ts.map +1 -0
- package/build-types/components/post-saved-state/index.d.ts +13 -0
- package/build-types/components/post-saved-state/index.d.ts.map +1 -0
- package/build-types/components/post-schedule/check.d.ts +12 -0
- package/build-types/components/post-schedule/check.d.ts.map +1 -0
- package/build-types/components/post-schedule/index.d.ts +17 -0
- package/build-types/components/post-schedule/index.d.ts.map +1 -0
- package/build-types/components/post-schedule/label.d.ts +25 -0
- package/build-types/components/post-schedule/label.d.ts.map +1 -0
- package/build-types/components/post-schedule/panel.d.ts +7 -0
- package/build-types/components/post-schedule/panel.d.ts.map +1 -0
- package/build-types/components/post-slug/check.d.ts +12 -0
- package/build-types/components/post-slug/check.d.ts.map +1 -0
- package/build-types/components/post-slug/index.d.ts +7 -0
- package/build-types/components/post-slug/index.d.ts.map +1 -0
- package/build-types/components/post-slug/panel.d.ts +3 -0
- package/build-types/components/post-slug/panel.d.ts.map +1 -0
- package/build-types/components/post-status/index.d.ts +6 -0
- package/build-types/components/post-status/index.d.ts.map +1 -0
- package/build-types/components/post-sticky/check.d.ts +12 -0
- package/build-types/components/post-sticky/check.d.ts.map +1 -0
- package/build-types/components/post-sticky/index.d.ts +7 -0
- package/build-types/components/post-sticky/index.d.ts.map +1 -0
- package/build-types/components/post-sticky/panel.d.ts +3 -0
- package/build-types/components/post-sticky/panel.d.ts.map +1 -0
- package/build-types/components/post-switch-to-draft-button/index.d.ts +7 -0
- package/build-types/components/post-switch-to-draft-button/index.d.ts.map +1 -0
- package/build-types/components/post-sync-status/index.d.ts +7 -0
- package/build-types/components/post-sync-status/index.d.ts.map +1 -0
- package/build-types/components/post-taxonomies/check.d.ts +12 -0
- package/build-types/components/post-taxonomies/check.d.ts.map +1 -0
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts +64 -0
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -0
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +102 -0
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -0
- package/build-types/components/post-taxonomies/index.d.ts +5 -0
- package/build-types/components/post-taxonomies/index.d.ts.map +1 -0
- package/build-types/components/post-taxonomies/most-used-terms.d.ts +5 -0
- package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -0
- package/build-types/components/post-taxonomies/panel.d.ts +3 -0
- package/build-types/components/post-taxonomies/panel.d.ts.map +1 -0
- package/build-types/components/post-template/block-theme.d.ts +4 -0
- package/build-types/components/post-template/block-theme.d.ts.map +1 -0
- package/build-types/components/post-template/classic-theme.d.ts +3 -0
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -0
- package/build-types/components/post-template/create-new-template-modal.d.ts +4 -0
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -0
- package/build-types/components/post-template/create-new-template.d.ts +4 -0
- package/build-types/components/post-template/create-new-template.d.ts.map +1 -0
- package/build-types/components/post-template/hooks.d.ts +8 -0
- package/build-types/components/post-template/hooks.d.ts.map +1 -0
- package/build-types/components/post-template/panel.d.ts +7 -0
- package/build-types/components/post-template/panel.d.ts.map +1 -0
- package/build-types/components/post-template/reset-default-template.d.ts +4 -0
- package/build-types/components/post-template/reset-default-template.d.ts.map +1 -0
- package/build-types/components/post-template/swap-template-button.d.ts +4 -0
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -0
- package/build-types/components/post-text-editor/index.d.ts +7 -0
- package/build-types/components/post-text-editor/index.d.ts.map +1 -0
- package/build-types/components/post-title/constants.d.ts +3 -0
- package/build-types/components/post-title/constants.d.ts.map +1 -0
- package/build-types/components/post-title/index.d.ts +3 -0
- package/build-types/components/post-title/index.d.ts.map +1 -0
- package/build-types/components/post-title/post-title-raw.d.ts +3 -0
- package/build-types/components/post-title/post-title-raw.d.ts.map +1 -0
- package/build-types/components/post-title/use-post-title-focus.d.ts +9 -0
- package/build-types/components/post-title/use-post-title-focus.d.ts.map +1 -0
- package/build-types/components/post-title/use-post-title.d.ts +7 -0
- package/build-types/components/post-title/use-post-title.d.ts.map +1 -0
- package/build-types/components/post-transform-panel/hooks.d.ts +2 -0
- package/build-types/components/post-transform-panel/hooks.d.ts.map +1 -0
- package/build-types/components/post-transform-panel/index.d.ts +2 -0
- package/build-types/components/post-transform-panel/index.d.ts.map +1 -0
- package/build-types/components/post-trash/check.d.ts +12 -0
- package/build-types/components/post-trash/check.d.ts.map +1 -0
- package/build-types/components/post-trash/index.d.ts +7 -0
- package/build-types/components/post-trash/index.d.ts.map +1 -0
- package/build-types/components/post-type-support-check/index.d.ts +18 -0
- package/build-types/components/post-type-support-check/index.d.ts.map +1 -0
- package/build-types/components/post-url/check.d.ts +12 -0
- package/build-types/components/post-url/check.d.ts.map +1 -0
- package/build-types/components/post-url/index.d.ts +14 -0
- package/build-types/components/post-url/index.d.ts.map +1 -0
- package/build-types/components/post-url/label.d.ts +13 -0
- package/build-types/components/post-url/label.d.ts.map +1 -0
- package/build-types/components/post-url/panel.d.ts +7 -0
- package/build-types/components/post-url/panel.d.ts.map +1 -0
- package/build-types/components/post-view-link/index.d.ts +2 -0
- package/build-types/components/post-view-link/index.d.ts.map +1 -0
- package/build-types/components/post-visibility/check.d.ts +13 -0
- package/build-types/components/post-visibility/check.d.ts.map +1 -0
- package/build-types/components/post-visibility/index.d.ts +11 -0
- package/build-types/components/post-visibility/index.d.ts.map +1 -0
- package/build-types/components/post-visibility/label.d.ts +13 -0
- package/build-types/components/post-visibility/label.d.ts.map +1 -0
- package/build-types/components/post-visibility/utils.d.ts +21 -0
- package/build-types/components/post-visibility/utils.d.ts.map +1 -0
- package/build-types/components/posts-per-page/index.d.ts +2 -0
- package/build-types/components/posts-per-page/index.d.ts.map +1 -0
- package/build-types/components/preferences-modal/enable-panel.d.ts +3 -0
- package/build-types/components/preferences-modal/enable-panel.d.ts.map +1 -0
- package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts +14 -0
- package/build-types/components/preferences-modal/enable-plugin-document-setting-panel.d.ts.map +1 -0
- package/build-types/components/preferences-modal/enable-publish-sidebar.d.ts +3 -0
- package/build-types/components/preferences-modal/enable-publish-sidebar.d.ts.map +1 -0
- package/build-types/components/preferences-modal/index.d.ts +4 -0
- package/build-types/components/preferences-modal/index.d.ts.map +1 -0
- package/build-types/components/preview-dropdown/index.d.ts +5 -0
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -0
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts +6 -0
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -0
- package/build-types/components/provider/index.d.ts +65 -0
- package/build-types/components/provider/index.d.ts.map +1 -0
- package/build-types/components/provider/navigation-block-editing-mode.d.ts +9 -0
- package/build-types/components/provider/navigation-block-editing-mode.d.ts.map +1 -0
- package/build-types/components/provider/use-auto-switch-editor-sidebars.d.ts +7 -0
- package/build-types/components/provider/use-auto-switch-editor-sidebars.d.ts.map +1 -0
- package/build-types/components/provider/use-block-editor-settings.d.ts +13 -0
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -0
- package/build-types/components/provider/use-hide-blocks-from-inserter.d.ts +9 -0
- package/build-types/components/provider/use-hide-blocks-from-inserter.d.ts.map +1 -0
- package/build-types/components/provider/with-registry-provider.d.ts +3 -0
- package/build-types/components/provider/with-registry-provider.d.ts.map +1 -0
- package/build-types/components/resizable-editor/index.d.ts +8 -0
- package/build-types/components/resizable-editor/index.d.ts.map +1 -0
- package/build-types/components/resizable-editor/resize-handle.d.ts +5 -0
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -0
- package/build-types/components/save-publish-panels/index.d.ts +11 -0
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -0
- package/build-types/components/sidebar/constants.d.ts +5 -0
- package/build-types/components/sidebar/constants.d.ts.map +1 -0
- package/build-types/components/sidebar/header.d.ts +3 -0
- package/build-types/components/sidebar/header.d.ts.map +1 -0
- package/build-types/components/sidebar/index.d.ts +6 -0
- package/build-types/components/sidebar/index.d.ts.map +1 -0
- package/build-types/components/sidebar/post-summary.d.ts +4 -0
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -0
- package/build-types/components/site-discussion/index.d.ts +2 -0
- package/build-types/components/site-discussion/index.d.ts.map +1 -0
- package/build-types/components/start-page-options/index.d.ts +2 -0
- package/build-types/components/start-page-options/index.d.ts.map +1 -0
- package/build-types/components/start-template-options/index.d.ts +2 -0
- package/build-types/components/start-template-options/index.d.ts.map +1 -0
- package/build-types/components/table-of-contents/index.d.ts +7 -0
- package/build-types/components/table-of-contents/index.d.ts.map +1 -0
- package/build-types/components/table-of-contents/panel.d.ts +6 -0
- package/build-types/components/table-of-contents/panel.d.ts.map +1 -0
- package/build-types/components/template-content-panel/index.d.ts +4 -0
- package/build-types/components/template-content-panel/index.d.ts.map +1 -0
- package/build-types/components/template-part-content-panel/index.d.ts +2 -0
- package/build-types/components/template-part-content-panel/index.d.ts.map +1 -0
- package/build-types/components/template-part-menu-items/convert-to-regular.d.ts +5 -0
- package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -0
- package/build-types/components/template-part-menu-items/convert-to-template-part.d.ts +5 -0
- package/build-types/components/template-part-menu-items/convert-to-template-part.d.ts.map +1 -0
- package/build-types/components/template-part-menu-items/index.d.ts +2 -0
- package/build-types/components/template-part-menu-items/index.d.ts.map +1 -0
- package/build-types/components/template-validation-notice/index.d.ts +2 -0
- package/build-types/components/template-validation-notice/index.d.ts.map +1 -0
- package/build-types/components/text-editor/index.d.ts +4 -0
- package/build-types/components/text-editor/index.d.ts.map +1 -0
- package/build-types/components/theme-support-check/index.d.ts +14 -0
- package/build-types/components/theme-support-check/index.d.ts.map +1 -0
- package/build-types/components/time-to-read/index.d.ts +7 -0
- package/build-types/components/time-to-read/index.d.ts.map +1 -0
- package/build-types/components/unsaved-changes-warning/index.d.ts +8 -0
- package/build-types/components/unsaved-changes-warning/index.d.ts.map +1 -0
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts +18 -0
- package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -0
- package/build-types/components/visual-editor/index.d.ts +10 -0
- package/build-types/components/visual-editor/index.d.ts.map +1 -0
- package/build-types/components/word-count/index.d.ts +7 -0
- package/build-types/components/word-count/index.d.ts.map +1 -0
- package/build-types/dataviews/actions/delete-post.d.ts +5 -0
- package/build-types/dataviews/actions/delete-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/export-pattern.d.ts +8 -0
- package/build-types/dataviews/actions/export-pattern.d.ts.map +1 -0
- package/build-types/dataviews/actions/index.d.ts +2 -0
- package/build-types/dataviews/actions/index.d.ts.map +1 -0
- package/build-types/dataviews/actions/reset-post.d.ts +5 -0
- package/build-types/dataviews/actions/reset-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/utils.d.ts +11 -0
- package/build-types/dataviews/actions/utils.d.ts.map +1 -0
- package/build-types/dataviews/api.d.ts +27 -0
- package/build-types/dataviews/api.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts +2 -2
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/dataviews/store/private-selectors.d.ts +2 -5
- package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
- package/build-types/dataviews/store/reducer.d.ts +5 -1
- package/build-types/dataviews/store/reducer.d.ts.map +1 -1
- package/build-types/dataviews/types.d.ts +34 -0
- package/build-types/dataviews/types.d.ts.map +1 -0
- package/build-types/hooks/custom-sources-backwards-compatibility.d.ts +10 -0
- package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -0
- package/build-types/hooks/default-autocompleters.d.ts +2 -0
- package/build-types/hooks/default-autocompleters.d.ts.map +1 -0
- package/build-types/hooks/index.d.ts +2 -0
- package/build-types/hooks/index.d.ts.map +1 -0
- package/build-types/hooks/media-upload.d.ts +2 -0
- package/build-types/hooks/media-upload.d.ts.map +1 -0
- package/build-types/hooks/pattern-overrides.d.ts +2 -0
- package/build-types/hooks/pattern-overrides.d.ts.map +1 -0
- package/build-types/hooks/use-select-nearest-editable-block.d.ts +4 -0
- package/build-types/hooks/use-select-nearest-editable-block.d.ts.map +1 -0
- package/build-types/index.d.ts +6 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +3 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/private-apis.d.ts +2 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/store/actions.d.ts +367 -0
- package/build-types/store/actions.d.ts.map +1 -0
- package/build-types/store/constants.d.ts +31 -0
- package/build-types/store/constants.d.ts.map +1 -0
- package/build-types/store/defaults.d.ts +21 -0
- package/build-types/store/defaults.d.ts.map +1 -0
- package/build-types/store/index.d.ts +17 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/store/local-autosave.d.ts +4 -0
- package/build-types/store/local-autosave.d.ts.map +1 -0
- package/build-types/store/private-actions.d.ts +37 -0
- package/build-types/store/private-actions.d.ts.map +1 -0
- package/build-types/store/private-selectors.d.ts +24 -0
- package/build-types/store/private-selectors.d.ts.map +1 -0
- package/build-types/store/reducer.d.ts +228 -0
- package/build-types/store/reducer.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts +854 -0
- package/build-types/store/selectors.d.ts.map +1 -0
- package/build-types/store/utils/get-filtered-template-parts.d.ts +3 -0
- package/build-types/store/utils/get-filtered-template-parts.d.ts.map +1 -0
- package/build-types/store/utils/is-template-revertable.d.ts +8 -0
- package/build-types/store/utils/is-template-revertable.d.ts.map +1 -0
- package/build-types/store/utils/notice-builder.d.ts +27 -0
- package/build-types/store/utils/notice-builder.d.ts.map +1 -0
- package/build-types/utils/get-template-part-icon.d.ts +9 -0
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +5 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/media-upload/index.d.ts +21 -0
- package/build-types/utils/media-upload/index.d.ts.map +1 -0
- package/build-types/utils/set-nested-value.d.ts +20 -0
- package/build-types/utils/set-nested-value.d.ts.map +1 -0
- package/build-types/utils/terms.d.ts +12 -0
- package/build-types/utils/terms.d.ts.map +1 -0
- package/build-types/utils/url.d.ts +18 -0
- package/build-types/utils/url.d.ts.map +1 -0
- package/package.json +36 -35
- package/src/bindings/pattern-overrides.js +9 -10
- package/src/bindings/post-meta.js +5 -0
- package/src/components/create-template-part-modal/index.js +2 -0
- package/src/components/create-template-part-modal/style.scss +0 -6
- package/src/components/document-bar/index.js +11 -4
- package/src/components/editor-interface/index.js +19 -8
- package/src/components/entities-saved-states/entity-record-item.js +4 -14
- package/src/components/entities-saved-states/index.js +1 -1
- package/src/components/entities-saved-states/style.scss +0 -13
- package/src/components/global-keyboard-shortcuts/index.js +1 -1
- package/src/components/global-styles-provider/index.js +7 -90
- package/src/components/header/index.js +2 -1
- package/src/components/index.js +11 -2
- package/src/components/inserter-sidebar/index.js +4 -24
- package/src/components/list-view-sidebar/index.js +34 -62
- package/src/components/list-view-sidebar/style.scss +0 -34
- package/src/components/page-attributes/parent.js +6 -3
- package/src/components/post-actions/actions.js +495 -621
- package/src/components/post-actions/index.js +4 -2
- package/src/components/post-card-panel/style.scss +1 -0
- package/src/components/post-excerpt/index.js +4 -1
- package/src/components/post-excerpt/panel.js +3 -2
- package/src/components/post-featured-image/style.scss +15 -0
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-preview-button/index.js +1 -1
- package/src/components/post-publish-panel/index.js +1 -1
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-saved-state/index.js +11 -1
- package/src/components/post-schedule/index.js +5 -0
- package/src/components/post-slug/check.js +8 -0
- package/src/components/post-slug/index.js +5 -0
- package/src/components/post-status/index.js +3 -1
- package/src/components/post-sticky/index.js +10 -13
- package/src/components/post-sticky/style.scss +3 -2
- package/src/components/post-taxonomies/README.md +1 -1
- package/src/components/post-template/create-new-template-modal.js +2 -0
- package/src/components/post-title/index.js +5 -12
- package/src/components/post-url/style.scss +4 -0
- package/src/components/preview-dropdown/index.js +1 -1
- package/src/components/provider/index.native.js +3 -11
- package/src/components/provider/use-block-editor-settings.js +10 -5
- package/src/components/save-publish-panels/index.js +33 -23
- package/src/components/sidebar/index.js +3 -3
- package/src/components/sidebar/post-summary.js +0 -4
- package/src/components/template-content-panel/index.js +29 -5
- package/src/components/template-part-content-panel/index.js +62 -0
- package/src/components/visual-editor/index.js +1 -1
- package/src/components/visual-editor/style.scss +3 -1
- package/src/dataviews/actions/delete-post.tsx +107 -0
- package/src/{components/post-actions/export-pattern-action.js → dataviews/actions/export-pattern.tsx} +19 -19
- package/src/dataviews/actions/index.ts +25 -0
- package/src/dataviews/actions/reset-post.tsx +144 -0
- package/src/dataviews/actions/utils.ts +54 -0
- package/src/dataviews/store/private-actions.ts +2 -2
- package/src/dataviews/store/private-selectors.ts +13 -6
- package/src/dataviews/store/reducer.ts +12 -5
- package/src/dataviews/types.ts +33 -0
- package/src/hooks/pattern-overrides.js +6 -4
- package/src/lock-unlock.js +1 -1
- package/src/private-apis.js +2 -0
- package/src/private-apis.native.js +0 -2
- package/src/store/private-actions.js +49 -21
- package/src/store/private-selectors.js +0 -25
- package/src/store/utils/is-template-revertable.js +8 -8
- package/src/style.scss +0 -1
- package/tsconfig.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/post-actions/export-pattern-action.js.map +0 -1
- package/build/components/post-actions/export-pattern-action.native.js +0 -11
- package/build/components/post-actions/export-pattern-action.native.js.map +0 -1
- package/build/components/template-areas/index.js +0 -84
- package/build/components/template-areas/index.js.map +0 -1
- package/build-module/components/post-actions/export-pattern-action.js.map +0 -1
- package/build-module/components/post-actions/export-pattern-action.native.js +0 -5
- package/build-module/components/post-actions/export-pattern-action.native.js.map +0 -1
- package/build-module/components/template-areas/index.js +0 -78
- package/build-module/components/template-areas/index.js.map +0 -1
- package/src/components/post-actions/export-pattern-action.native.js +0 -4
- package/src/components/template-areas/index.js +0 -94
- package/src/components/template-areas/style.scss +0 -22
- /package/src/store/{constants.js → constants.ts} +0 -0
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { external, trash, backup } from '@wordpress/icons';
|
|
5
5
|
import { addQueryArgs } from '@wordpress/url';
|
|
6
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
|
|
7
7
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
8
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
9
|
import { __, _n, sprintf, _x } from '@wordpress/i18n';
|
|
10
10
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
11
|
import { useMemo, useState } from '@wordpress/element';
|
|
12
12
|
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
13
|
-
|
|
13
|
+
import { parse } from '@wordpress/blocks';
|
|
14
|
+
import { DataForm } from '@wordpress/dataviews';
|
|
14
15
|
import {
|
|
15
16
|
Button,
|
|
16
17
|
TextControl,
|
|
@@ -30,14 +31,28 @@ import {
|
|
|
30
31
|
} from '../../store/constants';
|
|
31
32
|
import { store as editorStore } from '../../store';
|
|
32
33
|
import { unlock } from '../../lock-unlock';
|
|
33
|
-
import isTemplateRevertable from '../../store/utils/is-template-revertable';
|
|
34
|
-
import { exportPatternAsJSONAction } from './export-pattern-action';
|
|
35
34
|
import { CreateTemplatePartModalContents } from '../create-template-part-modal';
|
|
35
|
+
import { getItemTitle } from '../../dataviews/actions/utils';
|
|
36
36
|
|
|
37
37
|
// Patterns.
|
|
38
38
|
const { PATTERN_TYPES, CreatePatternModalContents, useDuplicatePatternProps } =
|
|
39
39
|
unlock( patternsPrivateApis );
|
|
40
40
|
|
|
41
|
+
// TODO: this should be shared with other components (page-pages).
|
|
42
|
+
const fields = [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
header: __( 'Title' ),
|
|
46
|
+
id: 'title',
|
|
47
|
+
placeholder: __( 'No title' ),
|
|
48
|
+
getValue: ( { item } ) => item.title,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const form = {
|
|
53
|
+
visibleFields: [ 'title' ],
|
|
54
|
+
};
|
|
55
|
+
|
|
41
56
|
/**
|
|
42
57
|
* Check if a template is removable.
|
|
43
58
|
*
|
|
@@ -52,108 +67,10 @@ function isTemplateRemovable( template ) {
|
|
|
52
67
|
// than the one returned from the endpoint. This is why we need to check for
|
|
53
68
|
// two props whether is custom or has a theme file.
|
|
54
69
|
return (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
) &&
|
|
58
|
-
! template.has_theme_file &&
|
|
59
|
-
! template.templatePart?.has_theme_file
|
|
70
|
+
template?.source === TEMPLATE_ORIGINS.custom &&
|
|
71
|
+
! template?.has_theme_file
|
|
60
72
|
);
|
|
61
73
|
}
|
|
62
|
-
const canDeleteOrReset = ( item ) => {
|
|
63
|
-
const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
|
|
64
|
-
const isUserPattern = item.type === PATTERN_TYPES.user;
|
|
65
|
-
return isUserPattern || ( isTemplatePart && item.isCustom );
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
function getItemTitle( item ) {
|
|
69
|
-
if ( typeof item.title === 'string' ) {
|
|
70
|
-
return decodeEntities( item.title );
|
|
71
|
-
}
|
|
72
|
-
return decodeEntities( item.title?.rendered || '' );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// This action is used for templates, patterns and template parts.
|
|
76
|
-
// Every other post type uses the similar `trashPostAction` which
|
|
77
|
-
// moves the post to trash.
|
|
78
|
-
const deletePostAction = {
|
|
79
|
-
id: 'delete-post',
|
|
80
|
-
label: __( 'Delete' ),
|
|
81
|
-
isPrimary: true,
|
|
82
|
-
icon: trash,
|
|
83
|
-
isEligible( post ) {
|
|
84
|
-
if (
|
|
85
|
-
[ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(
|
|
86
|
-
post.type
|
|
87
|
-
)
|
|
88
|
-
) {
|
|
89
|
-
return isTemplateRemovable( post );
|
|
90
|
-
}
|
|
91
|
-
// We can only remove user patterns.
|
|
92
|
-
return post.type === PATTERN_TYPES.user;
|
|
93
|
-
},
|
|
94
|
-
supportsBulk: true,
|
|
95
|
-
hideModalHeader: true,
|
|
96
|
-
RenderModal: ( {
|
|
97
|
-
items,
|
|
98
|
-
closeModal,
|
|
99
|
-
onActionStart,
|
|
100
|
-
onActionPerformed,
|
|
101
|
-
} ) => {
|
|
102
|
-
const [ isBusy, setIsBusy ] = useState( false );
|
|
103
|
-
const { removeTemplates } = unlock( useDispatch( editorStore ) );
|
|
104
|
-
return (
|
|
105
|
-
<VStack spacing="5">
|
|
106
|
-
<Text>
|
|
107
|
-
{ items.length > 1
|
|
108
|
-
? sprintf(
|
|
109
|
-
// translators: %d: number of items to delete.
|
|
110
|
-
_n(
|
|
111
|
-
'Delete %d item?',
|
|
112
|
-
'Delete %d items?',
|
|
113
|
-
items.length
|
|
114
|
-
),
|
|
115
|
-
items.length
|
|
116
|
-
)
|
|
117
|
-
: sprintf(
|
|
118
|
-
// translators: %s: The template or template part's titles
|
|
119
|
-
__( 'Delete "%s"?' ),
|
|
120
|
-
getItemTitle( items[ 0 ] )
|
|
121
|
-
) }
|
|
122
|
-
</Text>
|
|
123
|
-
<HStack justify="right">
|
|
124
|
-
<Button
|
|
125
|
-
variant="tertiary"
|
|
126
|
-
onClick={ closeModal }
|
|
127
|
-
disabled={ isBusy }
|
|
128
|
-
__experimentalIsFocusable
|
|
129
|
-
>
|
|
130
|
-
{ __( 'Cancel' ) }
|
|
131
|
-
</Button>
|
|
132
|
-
<Button
|
|
133
|
-
variant="primary"
|
|
134
|
-
onClick={ async () => {
|
|
135
|
-
setIsBusy( true );
|
|
136
|
-
if ( onActionStart ) {
|
|
137
|
-
onActionStart( items );
|
|
138
|
-
}
|
|
139
|
-
await removeTemplates( items, {
|
|
140
|
-
allowUndo: false,
|
|
141
|
-
} );
|
|
142
|
-
onActionPerformed?.( items );
|
|
143
|
-
setIsBusy( false );
|
|
144
|
-
closeModal();
|
|
145
|
-
} }
|
|
146
|
-
isBusy={ isBusy }
|
|
147
|
-
disabled={ isBusy }
|
|
148
|
-
__experimentalIsFocusable
|
|
149
|
-
>
|
|
150
|
-
{ __( 'Delete' ) }
|
|
151
|
-
</Button>
|
|
152
|
-
</HStack>
|
|
153
|
-
</VStack>
|
|
154
|
-
);
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
74
|
|
|
158
75
|
const trashPostAction = {
|
|
159
76
|
id: 'move-to-trash',
|
|
@@ -165,12 +82,7 @@ const trashPostAction = {
|
|
|
165
82
|
},
|
|
166
83
|
supportsBulk: true,
|
|
167
84
|
hideModalHeader: true,
|
|
168
|
-
RenderModal: ( {
|
|
169
|
-
items,
|
|
170
|
-
closeModal,
|
|
171
|
-
onActionStart,
|
|
172
|
-
onActionPerformed,
|
|
173
|
-
} ) => {
|
|
85
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
174
86
|
const [ isBusy, setIsBusy ] = useState( false );
|
|
175
87
|
const { createSuccessNotice, createErrorNotice } =
|
|
176
88
|
useDispatch( noticesStore );
|
|
@@ -201,7 +113,7 @@ const trashPostAction = {
|
|
|
201
113
|
variant="tertiary"
|
|
202
114
|
onClick={ closeModal }
|
|
203
115
|
disabled={ isBusy }
|
|
204
|
-
|
|
116
|
+
accessibleWhenDisabled
|
|
205
117
|
>
|
|
206
118
|
{ __( 'Cancel' ) }
|
|
207
119
|
</Button>
|
|
@@ -209,9 +121,6 @@ const trashPostAction = {
|
|
|
209
121
|
variant="primary"
|
|
210
122
|
onClick={ async () => {
|
|
211
123
|
setIsBusy( true );
|
|
212
|
-
if ( onActionStart ) {
|
|
213
|
-
onActionStart( items );
|
|
214
|
-
}
|
|
215
124
|
const promiseResult = await Promise.allSettled(
|
|
216
125
|
items.map( ( item ) =>
|
|
217
126
|
deleteEntityRecord(
|
|
@@ -236,16 +145,14 @@ const trashPostAction = {
|
|
|
236
145
|
__( '"%s" moved to trash.' ),
|
|
237
146
|
getItemTitle( items[ 0 ] )
|
|
238
147
|
);
|
|
239
|
-
} else if ( items[ 0 ].type === 'page' ) {
|
|
240
|
-
successMessage = sprintf(
|
|
241
|
-
/* translators: The number of items. */
|
|
242
|
-
__( '%s items moved to trash.' ),
|
|
243
|
-
items.length
|
|
244
|
-
);
|
|
245
148
|
} else {
|
|
246
149
|
successMessage = sprintf(
|
|
247
|
-
/* translators: The number of
|
|
248
|
-
|
|
150
|
+
/* translators: The number of items. */
|
|
151
|
+
_n(
|
|
152
|
+
'%s item moved to trash.',
|
|
153
|
+
'%s items moved to trash.',
|
|
154
|
+
items.length
|
|
155
|
+
),
|
|
249
156
|
items.length
|
|
250
157
|
);
|
|
251
158
|
}
|
|
@@ -313,7 +220,7 @@ const trashPostAction = {
|
|
|
313
220
|
} }
|
|
314
221
|
isBusy={ isBusy }
|
|
315
222
|
disabled={ isBusy }
|
|
316
|
-
|
|
223
|
+
accessibleWhenDisabled
|
|
317
224
|
>
|
|
318
225
|
{ __( 'Trash' ) }
|
|
319
226
|
</Button>
|
|
@@ -323,244 +230,243 @@ const trashPostAction = {
|
|
|
323
230
|
},
|
|
324
231
|
};
|
|
325
232
|
|
|
326
|
-
function
|
|
327
|
-
const
|
|
328
|
-
useDispatch( noticesStore );
|
|
329
|
-
const { deleteEntityRecord } = useDispatch( coreStore );
|
|
330
|
-
|
|
233
|
+
function useCanUserEligibilityCheckPostType( capability, resource, action ) {
|
|
234
|
+
const registry = useRegistry();
|
|
331
235
|
return useMemo(
|
|
332
236
|
() => ( {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
237
|
+
...action,
|
|
238
|
+
isEligible( item ) {
|
|
239
|
+
return (
|
|
240
|
+
action.isEligible( item ) &&
|
|
241
|
+
registry
|
|
242
|
+
.select( coreStore )
|
|
243
|
+
.canUser( capability, resource, item.id )
|
|
244
|
+
);
|
|
338
245
|
},
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
246
|
+
} ),
|
|
247
|
+
[ action, registry, capability, resource ]
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function useTrashPostAction( resource ) {
|
|
252
|
+
return useCanUserEligibilityCheckPostType(
|
|
253
|
+
'delete',
|
|
254
|
+
resource,
|
|
255
|
+
trashPostAction
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const permanentlyDeletePostAction = {
|
|
260
|
+
id: 'permanently-delete',
|
|
261
|
+
label: __( 'Permanently delete' ),
|
|
262
|
+
supportsBulk: true,
|
|
263
|
+
isEligible( { status } ) {
|
|
264
|
+
return status === 'trash';
|
|
265
|
+
},
|
|
266
|
+
async callback( posts, { registry, onActionPerformed } ) {
|
|
267
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
268
|
+
registry.dispatch( noticesStore );
|
|
269
|
+
const { deleteEntityRecord } = registry.dispatch( coreStore );
|
|
270
|
+
const promiseResult = await Promise.allSettled(
|
|
271
|
+
posts.map( ( post ) => {
|
|
272
|
+
return deleteEntityRecord(
|
|
273
|
+
'postType',
|
|
274
|
+
post.type,
|
|
275
|
+
post.id,
|
|
276
|
+
{ force: true },
|
|
277
|
+
{ throwOnError: true }
|
|
350
278
|
);
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
279
|
+
} )
|
|
280
|
+
);
|
|
281
|
+
// If all the promises were fulfilled with success.
|
|
282
|
+
if ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {
|
|
283
|
+
let successMessage;
|
|
284
|
+
if ( promiseResult.length === 1 ) {
|
|
285
|
+
successMessage = sprintf(
|
|
286
|
+
/* translators: The posts's title. */
|
|
287
|
+
__( '"%s" permanently deleted.' ),
|
|
288
|
+
getItemTitle( posts[ 0 ] )
|
|
289
|
+
);
|
|
290
|
+
} else {
|
|
291
|
+
successMessage = __( 'The posts were permanently deleted.' );
|
|
292
|
+
}
|
|
293
|
+
createSuccessNotice( successMessage, {
|
|
294
|
+
type: 'snackbar',
|
|
295
|
+
id: 'permanently-delete-post-action',
|
|
296
|
+
} );
|
|
297
|
+
onActionPerformed?.( posts );
|
|
298
|
+
} else {
|
|
299
|
+
// If there was at lease one failure.
|
|
300
|
+
let errorMessage;
|
|
301
|
+
// If we were trying to permanently delete a single post.
|
|
302
|
+
if ( promiseResult.length === 1 ) {
|
|
303
|
+
if ( promiseResult[ 0 ].reason?.message ) {
|
|
304
|
+
errorMessage = promiseResult[ 0 ].reason.message;
|
|
376
305
|
} else {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
const errorMessages = new Set();
|
|
391
|
-
const failedPromises = promiseResult.filter(
|
|
392
|
-
( { status } ) => status === 'rejected'
|
|
393
|
-
);
|
|
394
|
-
for ( const failedPromise of failedPromises ) {
|
|
395
|
-
if ( failedPromise.reason?.message ) {
|
|
396
|
-
errorMessages.add(
|
|
397
|
-
failedPromise.reason.message
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
if ( errorMessages.size === 0 ) {
|
|
402
|
-
errorMessage = __(
|
|
403
|
-
'An error occurred while permanently deleting the posts.'
|
|
404
|
-
);
|
|
405
|
-
} else if ( errorMessages.size === 1 ) {
|
|
406
|
-
errorMessage = sprintf(
|
|
407
|
-
/* translators: %s: an error message */
|
|
408
|
-
__(
|
|
409
|
-
'An error occurred while permanently deleting the posts: %s'
|
|
410
|
-
),
|
|
411
|
-
[ ...errorMessages ][ 0 ]
|
|
412
|
-
);
|
|
413
|
-
} else {
|
|
414
|
-
errorMessage = sprintf(
|
|
415
|
-
/* translators: %s: a list of comma separated error messages */
|
|
416
|
-
__(
|
|
417
|
-
'Some errors occurred while permanently deleting the posts: %s'
|
|
418
|
-
),
|
|
419
|
-
[ ...errorMessages ].join( ',' )
|
|
420
|
-
);
|
|
421
|
-
}
|
|
306
|
+
errorMessage = __(
|
|
307
|
+
'An error occurred while permanently deleting the post.'
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
// If we were trying to permanently delete multiple posts
|
|
311
|
+
} else {
|
|
312
|
+
const errorMessages = new Set();
|
|
313
|
+
const failedPromises = promiseResult.filter(
|
|
314
|
+
( { status } ) => status === 'rejected'
|
|
315
|
+
);
|
|
316
|
+
for ( const failedPromise of failedPromises ) {
|
|
317
|
+
if ( failedPromise.reason?.message ) {
|
|
318
|
+
errorMessages.add( failedPromise.reason.message );
|
|
422
319
|
}
|
|
423
|
-
createErrorNotice( errorMessage, {
|
|
424
|
-
type: 'snackbar',
|
|
425
|
-
} );
|
|
426
320
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
321
|
+
if ( errorMessages.size === 0 ) {
|
|
322
|
+
errorMessage = __(
|
|
323
|
+
'An error occurred while permanently deleting the posts.'
|
|
324
|
+
);
|
|
325
|
+
} else if ( errorMessages.size === 1 ) {
|
|
326
|
+
errorMessage = sprintf(
|
|
327
|
+
/* translators: %s: an error message */
|
|
328
|
+
__(
|
|
329
|
+
'An error occurred while permanently deleting the posts: %s'
|
|
330
|
+
),
|
|
331
|
+
[ ...errorMessages ][ 0 ]
|
|
332
|
+
);
|
|
333
|
+
} else {
|
|
334
|
+
errorMessage = sprintf(
|
|
335
|
+
/* translators: %s: a list of comma separated error messages */
|
|
336
|
+
__(
|
|
337
|
+
'Some errors occurred while permanently deleting the posts: %s'
|
|
338
|
+
),
|
|
339
|
+
[ ...errorMessages ].join( ',' )
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
createErrorNotice( errorMessage, {
|
|
344
|
+
type: 'snackbar',
|
|
345
|
+
} );
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
function usePermanentlyDeletePostAction( resource ) {
|
|
351
|
+
return useCanUserEligibilityCheckPostType(
|
|
352
|
+
'delete',
|
|
353
|
+
resource,
|
|
354
|
+
permanentlyDeletePostAction
|
|
430
355
|
);
|
|
431
356
|
}
|
|
432
357
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
358
|
+
const restorePostAction = {
|
|
359
|
+
id: 'restore',
|
|
360
|
+
label: __( 'Restore' ),
|
|
361
|
+
isPrimary: true,
|
|
362
|
+
icon: backup,
|
|
363
|
+
supportsBulk: true,
|
|
364
|
+
isEligible( { status } ) {
|
|
365
|
+
return status === 'trash';
|
|
366
|
+
},
|
|
367
|
+
async callback( posts, { registry, onActionPerformed } ) {
|
|
368
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
369
|
+
registry.dispatch( noticesStore );
|
|
370
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
371
|
+
registry.dispatch( coreStore );
|
|
372
|
+
await Promise.allSettled(
|
|
373
|
+
posts.map( ( post ) => {
|
|
374
|
+
return editEntityRecord( 'postType', post.type, post.id, {
|
|
375
|
+
status: 'draft',
|
|
376
|
+
} );
|
|
377
|
+
} )
|
|
378
|
+
);
|
|
379
|
+
const promiseResult = await Promise.allSettled(
|
|
380
|
+
posts.map( ( post ) => {
|
|
381
|
+
return saveEditedEntityRecord( 'postType', post.type, post.id, {
|
|
382
|
+
throwOnError: true,
|
|
383
|
+
} );
|
|
384
|
+
} )
|
|
385
|
+
);
|
|
438
386
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
isEligible( { status } ) {
|
|
447
|
-
return status === 'trash';
|
|
448
|
-
},
|
|
449
|
-
async callback( posts, onActionPerformed ) {
|
|
450
|
-
await Promise.allSettled(
|
|
451
|
-
posts.map( ( post ) => {
|
|
452
|
-
return editEntityRecord(
|
|
453
|
-
'postType',
|
|
454
|
-
post.type,
|
|
455
|
-
post.id,
|
|
456
|
-
{
|
|
457
|
-
status: 'draft',
|
|
458
|
-
}
|
|
459
|
-
);
|
|
460
|
-
} )
|
|
387
|
+
if ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {
|
|
388
|
+
let successMessage;
|
|
389
|
+
if ( posts.length === 1 ) {
|
|
390
|
+
successMessage = sprintf(
|
|
391
|
+
/* translators: The number of posts. */
|
|
392
|
+
__( '"%s" has been restored.' ),
|
|
393
|
+
getItemTitle( posts[ 0 ] )
|
|
461
394
|
);
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
post.id,
|
|
468
|
-
{ throwOnError: true }
|
|
469
|
-
);
|
|
470
|
-
} )
|
|
395
|
+
} else if ( posts[ 0 ].type === 'page' ) {
|
|
396
|
+
successMessage = sprintf(
|
|
397
|
+
/* translators: The number of posts. */
|
|
398
|
+
__( '%d pages have been restored.' ),
|
|
399
|
+
posts.length
|
|
471
400
|
);
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
)
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
/* translators: The number of posts. */
|
|
494
|
-
__( '%d posts have been restored.' ),
|
|
495
|
-
posts.length
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
createSuccessNotice( successMessage, {
|
|
499
|
-
type: 'snackbar',
|
|
500
|
-
id: 'restore-post-action',
|
|
501
|
-
} );
|
|
502
|
-
if ( onActionPerformed ) {
|
|
503
|
-
onActionPerformed( posts );
|
|
504
|
-
}
|
|
401
|
+
} else {
|
|
402
|
+
successMessage = sprintf(
|
|
403
|
+
/* translators: The number of posts. */
|
|
404
|
+
__( '%d posts have been restored.' ),
|
|
405
|
+
posts.length
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
createSuccessNotice( successMessage, {
|
|
409
|
+
type: 'snackbar',
|
|
410
|
+
id: 'restore-post-action',
|
|
411
|
+
} );
|
|
412
|
+
if ( onActionPerformed ) {
|
|
413
|
+
onActionPerformed( posts );
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
// If there was at lease one failure.
|
|
417
|
+
let errorMessage;
|
|
418
|
+
// If we were trying to move a single post to the trash.
|
|
419
|
+
if ( promiseResult.length === 1 ) {
|
|
420
|
+
if ( promiseResult[ 0 ].reason?.message ) {
|
|
421
|
+
errorMessage = promiseResult[ 0 ].reason.message;
|
|
505
422
|
} else {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
const errorMessages = new Set();
|
|
520
|
-
const failedPromises = promiseResult.filter(
|
|
521
|
-
( { status } ) => status === 'rejected'
|
|
522
|
-
);
|
|
523
|
-
for ( const failedPromise of failedPromises ) {
|
|
524
|
-
if ( failedPromise.reason?.message ) {
|
|
525
|
-
errorMessages.add(
|
|
526
|
-
failedPromise.reason.message
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
if ( errorMessages.size === 0 ) {
|
|
531
|
-
errorMessage = __(
|
|
532
|
-
'An error occurred while restoring the posts.'
|
|
533
|
-
);
|
|
534
|
-
} else if ( errorMessages.size === 1 ) {
|
|
535
|
-
errorMessage = sprintf(
|
|
536
|
-
/* translators: %s: an error message */
|
|
537
|
-
__(
|
|
538
|
-
'An error occurred while restoring the posts: %s'
|
|
539
|
-
),
|
|
540
|
-
[ ...errorMessages ][ 0 ]
|
|
541
|
-
);
|
|
542
|
-
} else {
|
|
543
|
-
errorMessage = sprintf(
|
|
544
|
-
/* translators: %s: a list of comma separated error messages */
|
|
545
|
-
__(
|
|
546
|
-
'Some errors occurred while restoring the posts: %s'
|
|
547
|
-
),
|
|
548
|
-
[ ...errorMessages ].join( ',' )
|
|
549
|
-
);
|
|
550
|
-
}
|
|
423
|
+
errorMessage = __(
|
|
424
|
+
'An error occurred while restoring the post.'
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
// If we were trying to move multiple posts to the trash
|
|
428
|
+
} else {
|
|
429
|
+
const errorMessages = new Set();
|
|
430
|
+
const failedPromises = promiseResult.filter(
|
|
431
|
+
( { status } ) => status === 'rejected'
|
|
432
|
+
);
|
|
433
|
+
for ( const failedPromise of failedPromises ) {
|
|
434
|
+
if ( failedPromise.reason?.message ) {
|
|
435
|
+
errorMessages.add( failedPromise.reason.message );
|
|
551
436
|
}
|
|
552
|
-
createErrorNotice( errorMessage, {
|
|
553
|
-
type: 'snackbar',
|
|
554
|
-
} );
|
|
555
437
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
438
|
+
if ( errorMessages.size === 0 ) {
|
|
439
|
+
errorMessage = __(
|
|
440
|
+
'An error occurred while restoring the posts.'
|
|
441
|
+
);
|
|
442
|
+
} else if ( errorMessages.size === 1 ) {
|
|
443
|
+
errorMessage = sprintf(
|
|
444
|
+
/* translators: %s: an error message */
|
|
445
|
+
__( 'An error occurred while restoring the posts: %s' ),
|
|
446
|
+
[ ...errorMessages ][ 0 ]
|
|
447
|
+
);
|
|
448
|
+
} else {
|
|
449
|
+
errorMessage = sprintf(
|
|
450
|
+
/* translators: %s: a list of comma separated error messages */
|
|
451
|
+
__(
|
|
452
|
+
'Some errors occurred while restoring the posts: %s'
|
|
453
|
+
),
|
|
454
|
+
[ ...errorMessages ].join( ',' )
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
createErrorNotice( errorMessage, {
|
|
459
|
+
type: 'snackbar',
|
|
460
|
+
} );
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
function useRestorePostAction( resource ) {
|
|
466
|
+
return useCanUserEligibilityCheckPostType(
|
|
467
|
+
'update',
|
|
468
|
+
resource,
|
|
469
|
+
restorePostAction
|
|
564
470
|
);
|
|
565
471
|
}
|
|
566
472
|
|
|
@@ -572,7 +478,7 @@ const viewPostAction = {
|
|
|
572
478
|
isEligible( post ) {
|
|
573
479
|
return post.status !== 'trash';
|
|
574
480
|
},
|
|
575
|
-
callback( posts, onActionPerformed ) {
|
|
481
|
+
callback( posts, { onActionPerformed } ) {
|
|
576
482
|
const post = posts[ 0 ];
|
|
577
483
|
window.open( post.link, '_blank' );
|
|
578
484
|
if ( onActionPerformed ) {
|
|
@@ -583,6 +489,7 @@ const viewPostAction = {
|
|
|
583
489
|
|
|
584
490
|
const postRevisionsAction = {
|
|
585
491
|
id: 'view-post-revisions',
|
|
492
|
+
context: 'list',
|
|
586
493
|
label( items ) {
|
|
587
494
|
const revisionsCount =
|
|
588
495
|
items[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
@@ -602,7 +509,7 @@ const postRevisionsAction = {
|
|
|
602
509
|
post?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
603
510
|
return lastRevisionId && revisionsCount > 1;
|
|
604
511
|
},
|
|
605
|
-
callback( posts, onActionPerformed ) {
|
|
512
|
+
callback( posts, { onActionPerformed } ) {
|
|
606
513
|
const post = posts[ 0 ];
|
|
607
514
|
const href = addQueryArgs( 'revision.php', {
|
|
608
515
|
revision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,
|
|
@@ -643,19 +550,13 @@ const renamePostAction = {
|
|
|
643
550
|
// two props whether is custom or has a theme file.
|
|
644
551
|
const isCustomPattern =
|
|
645
552
|
isUserPattern ||
|
|
646
|
-
( isTemplatePart &&
|
|
647
|
-
|
|
648
|
-
const hasThemeFile =
|
|
649
|
-
isTemplatePart &&
|
|
650
|
-
( post.templatePart?.has_theme_file || post.has_theme_file );
|
|
553
|
+
( isTemplatePart && post.source === TEMPLATE_ORIGINS.custom );
|
|
554
|
+
const hasThemeFile = post?.has_theme_file;
|
|
651
555
|
return isCustomPattern && ! hasThemeFile;
|
|
652
556
|
},
|
|
653
557
|
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
654
558
|
const [ item ] = items;
|
|
655
|
-
const
|
|
656
|
-
typeof item.title === 'string' ? item.title : item.title.rendered
|
|
657
|
-
);
|
|
658
|
-
const [ title, setTitle ] = useState( () => originalTitle );
|
|
559
|
+
const [ title, setTitle ] = useState( () => getItemTitle( item ) );
|
|
659
560
|
const { editEntityRecord, saveEditedEntityRecord } =
|
|
660
561
|
useDispatch( coreStore );
|
|
661
562
|
const { createSuccessNotice, createErrorNotice } =
|
|
@@ -722,252 +623,174 @@ const renamePostAction = {
|
|
|
722
623
|
},
|
|
723
624
|
};
|
|
724
625
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const [ item ] = items;
|
|
733
|
-
const [ isCreatingPage, setIsCreatingPage ] = useState( false );
|
|
734
|
-
const [ title, setTitle ] = useState(
|
|
735
|
-
sprintf(
|
|
736
|
-
/* translators: %s: Existing item title */
|
|
737
|
-
__( '%s (Copy)' ),
|
|
738
|
-
getItemTitle( item )
|
|
739
|
-
)
|
|
740
|
-
);
|
|
626
|
+
function useRenamePostAction( resource ) {
|
|
627
|
+
return useCanUserEligibilityCheckPostType(
|
|
628
|
+
'update',
|
|
629
|
+
resource,
|
|
630
|
+
renamePostAction
|
|
631
|
+
);
|
|
632
|
+
}
|
|
741
633
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
634
|
+
const useDuplicatePostAction = ( postType ) => {
|
|
635
|
+
const { userCanCreatePost } = useSelect(
|
|
636
|
+
( select ) => {
|
|
637
|
+
const { getPostType, canUser } = select( coreStore );
|
|
638
|
+
const resource = getPostType( postType )?.rest_base || '';
|
|
639
|
+
return {
|
|
640
|
+
userCanCreatePost: canUser( 'create', resource ),
|
|
641
|
+
};
|
|
642
|
+
},
|
|
643
|
+
[ postType ]
|
|
644
|
+
);
|
|
645
|
+
return useMemo(
|
|
646
|
+
() =>
|
|
647
|
+
userCanCreatePost && {
|
|
648
|
+
id: 'duplicate-post',
|
|
649
|
+
label: _x( 'Duplicate', 'action label' ),
|
|
650
|
+
isEligible( { status } ) {
|
|
651
|
+
return status !== 'trash';
|
|
652
|
+
},
|
|
653
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
654
|
+
const [ item, setItem ] = useState( {
|
|
655
|
+
...items[ 0 ],
|
|
656
|
+
title: sprintf(
|
|
657
|
+
/* translators: %s: Existing template title */
|
|
658
|
+
__( '%s (Copy)' ),
|
|
659
|
+
getItemTitle( items[ 0 ] )
|
|
660
|
+
),
|
|
661
|
+
} );
|
|
745
662
|
|
|
746
|
-
|
|
747
|
-
|
|
663
|
+
const [ isCreatingPage, setIsCreatingPage ] =
|
|
664
|
+
useState( false );
|
|
748
665
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
setIsCreatingPage( true );
|
|
753
|
-
try {
|
|
754
|
-
const newItem = await saveEntityRecord(
|
|
755
|
-
'postType',
|
|
756
|
-
item.type,
|
|
757
|
-
{
|
|
758
|
-
status: 'draft',
|
|
759
|
-
title,
|
|
760
|
-
slug: title || __( 'No title' ),
|
|
761
|
-
author: item.author,
|
|
762
|
-
comment_status: item.comment_status,
|
|
763
|
-
content:
|
|
764
|
-
typeof item.content === 'string'
|
|
765
|
-
? item.content
|
|
766
|
-
: item.content.raw,
|
|
767
|
-
excerpt: item.excerpt.raw,
|
|
768
|
-
meta: item.meta,
|
|
769
|
-
parent: item.parent,
|
|
770
|
-
password: item.password,
|
|
771
|
-
template: item.template,
|
|
772
|
-
format: item.format,
|
|
773
|
-
featured_media: item.featured_media,
|
|
774
|
-
menu_order: item.menu_order,
|
|
775
|
-
ping_status: item.ping_status,
|
|
776
|
-
categories: item.categories,
|
|
777
|
-
tags: item.tags,
|
|
778
|
-
},
|
|
779
|
-
{ throwOnError: true }
|
|
780
|
-
);
|
|
666
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
667
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
668
|
+
useDispatch( noticesStore );
|
|
781
669
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
// translators: %s: Title of the created template e.g: "Category".
|
|
785
|
-
__( '"%s" successfully created.' ),
|
|
786
|
-
decodeEntities( newItem.title?.rendered || title )
|
|
787
|
-
),
|
|
788
|
-
{
|
|
789
|
-
id: 'duplicate-post-action',
|
|
790
|
-
type: 'snackbar',
|
|
791
|
-
}
|
|
792
|
-
);
|
|
670
|
+
async function createPage( event ) {
|
|
671
|
+
event.preventDefault();
|
|
793
672
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
} catch ( error ) {
|
|
798
|
-
const errorMessage =
|
|
799
|
-
error.message && error.code !== 'unknown_error'
|
|
800
|
-
? error.message
|
|
801
|
-
: __( 'An error occurred while duplicating the page.' );
|
|
673
|
+
if ( isCreatingPage ) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
802
676
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
677
|
+
const newItemOject = {
|
|
678
|
+
status: 'draft',
|
|
679
|
+
title: item.title,
|
|
680
|
+
slug: item.title || __( 'No title' ),
|
|
681
|
+
comment_status: item.comment_status,
|
|
682
|
+
content:
|
|
683
|
+
typeof item.content === 'string'
|
|
684
|
+
? item.content
|
|
685
|
+
: item.content.raw,
|
|
686
|
+
excerpt: item.excerpt.raw,
|
|
687
|
+
meta: item.meta,
|
|
688
|
+
parent: item.parent,
|
|
689
|
+
password: item.password,
|
|
690
|
+
template: item.template,
|
|
691
|
+
format: item.format,
|
|
692
|
+
featured_media: item.featured_media,
|
|
693
|
+
menu_order: item.menu_order,
|
|
694
|
+
ping_status: item.ping_status,
|
|
695
|
+
};
|
|
696
|
+
const assignablePropertiesPrefix = 'wp:action-assign-';
|
|
697
|
+
// Get all the properties that the current user is able to assign normally author, categories, tags,
|
|
698
|
+
// and custom taxonomies.
|
|
699
|
+
const assignableProperties = Object.keys(
|
|
700
|
+
item?._links || {}
|
|
701
|
+
)
|
|
702
|
+
.filter( ( property ) =>
|
|
703
|
+
property.startsWith(
|
|
704
|
+
assignablePropertiesPrefix
|
|
705
|
+
)
|
|
706
|
+
)
|
|
707
|
+
.map( ( property ) =>
|
|
708
|
+
property.slice(
|
|
709
|
+
assignablePropertiesPrefix.length
|
|
710
|
+
)
|
|
711
|
+
);
|
|
712
|
+
assignableProperties.forEach( ( property ) => {
|
|
713
|
+
if ( item[ property ] ) {
|
|
714
|
+
newItemOject[ property ] = item[ property ];
|
|
715
|
+
}
|
|
716
|
+
} );
|
|
717
|
+
setIsCreatingPage( true );
|
|
718
|
+
try {
|
|
719
|
+
const newItem = await saveEntityRecord(
|
|
720
|
+
'postType',
|
|
721
|
+
item.type,
|
|
722
|
+
newItemOject,
|
|
723
|
+
{ throwOnError: true }
|
|
724
|
+
);
|
|
838
725
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
726
|
+
createSuccessNotice(
|
|
727
|
+
sprintf(
|
|
728
|
+
// translators: %s: Title of the created template e.g: "Category".
|
|
729
|
+
__( '"%s" successfully created.' ),
|
|
730
|
+
decodeEntities(
|
|
731
|
+
newItem.title?.rendered || item.title
|
|
732
|
+
)
|
|
733
|
+
),
|
|
734
|
+
{
|
|
735
|
+
id: 'duplicate-post-action',
|
|
736
|
+
type: 'snackbar',
|
|
737
|
+
}
|
|
738
|
+
);
|
|
846
739
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
closeModal,
|
|
861
|
-
onActionStart,
|
|
862
|
-
onActionPerformed,
|
|
863
|
-
} ) => {
|
|
864
|
-
const [ isBusy, setIsBusy ] = useState( false );
|
|
865
|
-
const { revertTemplate, removeTemplates } = unlock(
|
|
866
|
-
useDispatch( editorStore )
|
|
867
|
-
);
|
|
868
|
-
const { saveEditedEntityRecord } = useDispatch( coreStore );
|
|
869
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
870
|
-
useDispatch( noticesStore );
|
|
871
|
-
const onConfirm = async () => {
|
|
872
|
-
try {
|
|
873
|
-
if ( items[ 0 ].type === TEMPLATE_PART_POST_TYPE ) {
|
|
874
|
-
await removeTemplates( items );
|
|
875
|
-
} else {
|
|
876
|
-
for ( const template of items ) {
|
|
877
|
-
if ( template.type === TEMPLATE_POST_TYPE ) {
|
|
878
|
-
await revertTemplate( template, {
|
|
879
|
-
allowUndo: false,
|
|
740
|
+
if ( onActionPerformed ) {
|
|
741
|
+
onActionPerformed( [ newItem ] );
|
|
742
|
+
}
|
|
743
|
+
} catch ( error ) {
|
|
744
|
+
const errorMessage =
|
|
745
|
+
error.message && error.code !== 'unknown_error'
|
|
746
|
+
? error.message
|
|
747
|
+
: __(
|
|
748
|
+
'An error occurred while duplicating the page.'
|
|
749
|
+
);
|
|
750
|
+
|
|
751
|
+
createErrorNotice( errorMessage, {
|
|
752
|
+
type: 'snackbar',
|
|
880
753
|
} );
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
template.id
|
|
885
|
-
);
|
|
754
|
+
} finally {
|
|
755
|
+
setIsCreatingPage( false );
|
|
756
|
+
closeModal();
|
|
886
757
|
}
|
|
887
758
|
}
|
|
888
|
-
createSuccessNotice(
|
|
889
|
-
items.length > 1
|
|
890
|
-
? sprintf(
|
|
891
|
-
/* translators: The number of items. */
|
|
892
|
-
__( '%s items reset.' ),
|
|
893
|
-
items.length
|
|
894
|
-
)
|
|
895
|
-
: sprintf(
|
|
896
|
-
/* translators: The template/part's name. */
|
|
897
|
-
__( '"%s" reset.' ),
|
|
898
|
-
decodeEntities( getItemTitle( items[ 0 ] ) )
|
|
899
|
-
),
|
|
900
|
-
{
|
|
901
|
-
type: 'snackbar',
|
|
902
|
-
id: 'revert-template-action',
|
|
903
|
-
}
|
|
904
|
-
);
|
|
905
|
-
}
|
|
906
|
-
} catch ( error ) {
|
|
907
|
-
let fallbackErrorMessage;
|
|
908
|
-
if ( items[ 0 ].type === TEMPLATE_POST_TYPE ) {
|
|
909
|
-
fallbackErrorMessage =
|
|
910
|
-
items.length === 1
|
|
911
|
-
? __(
|
|
912
|
-
'An error occurred while reverting the template.'
|
|
913
|
-
)
|
|
914
|
-
: __(
|
|
915
|
-
'An error occurred while reverting the templates.'
|
|
916
|
-
);
|
|
917
|
-
} else {
|
|
918
|
-
fallbackErrorMessage =
|
|
919
|
-
items.length === 1
|
|
920
|
-
? __(
|
|
921
|
-
'An error occurred while reverting the template part.'
|
|
922
|
-
)
|
|
923
|
-
: __(
|
|
924
|
-
'An error occurred while reverting the template parts.'
|
|
925
|
-
);
|
|
926
|
-
}
|
|
927
|
-
const errorMessage =
|
|
928
|
-
error.message && error.code !== 'unknown_error'
|
|
929
|
-
? error.message
|
|
930
|
-
: fallbackErrorMessage;
|
|
931
759
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
</Button>
|
|
967
|
-
</HStack>
|
|
968
|
-
</VStack>
|
|
969
|
-
);
|
|
970
|
-
},
|
|
760
|
+
return (
|
|
761
|
+
<form onSubmit={ createPage }>
|
|
762
|
+
<VStack spacing={ 3 }>
|
|
763
|
+
<DataForm
|
|
764
|
+
data={ item }
|
|
765
|
+
fields={ fields }
|
|
766
|
+
form={ form }
|
|
767
|
+
onChange={ setItem }
|
|
768
|
+
/>
|
|
769
|
+
<HStack spacing={ 2 } justify="end">
|
|
770
|
+
<Button
|
|
771
|
+
variant="tertiary"
|
|
772
|
+
onClick={ closeModal }
|
|
773
|
+
__next40pxDefaultSize
|
|
774
|
+
>
|
|
775
|
+
{ __( 'Cancel' ) }
|
|
776
|
+
</Button>
|
|
777
|
+
<Button
|
|
778
|
+
variant="primary"
|
|
779
|
+
type="submit"
|
|
780
|
+
isBusy={ isCreatingPage }
|
|
781
|
+
aria-disabled={ isCreatingPage }
|
|
782
|
+
__next40pxDefaultSize
|
|
783
|
+
>
|
|
784
|
+
{ _x( 'Duplicate', 'action label' ) }
|
|
785
|
+
</Button>
|
|
786
|
+
</HStack>
|
|
787
|
+
</VStack>
|
|
788
|
+
</form>
|
|
789
|
+
);
|
|
790
|
+
},
|
|
791
|
+
},
|
|
792
|
+
[ userCanCreatePost ]
|
|
793
|
+
);
|
|
971
794
|
};
|
|
972
795
|
|
|
973
796
|
export const duplicatePatternAction = {
|
|
@@ -977,10 +800,8 @@ export const duplicatePatternAction = {
|
|
|
977
800
|
modalHeader: _x( 'Duplicate pattern', 'action label' ),
|
|
978
801
|
RenderModal: ( { items, closeModal } ) => {
|
|
979
802
|
const [ item ] = items;
|
|
980
|
-
const isThemePattern = item.type === PATTERN_TYPES.theme;
|
|
981
803
|
const duplicatedProps = useDuplicatePatternProps( {
|
|
982
|
-
pattern:
|
|
983
|
-
isThemePattern || ! item.patternPost ? item : item.patternPost,
|
|
804
|
+
pattern: item,
|
|
984
805
|
onSuccess: () => closeModal(),
|
|
985
806
|
} );
|
|
986
807
|
return (
|
|
@@ -1000,13 +821,21 @@ export const duplicateTemplatePartAction = {
|
|
|
1000
821
|
modalHeader: _x( 'Duplicate template part', 'action label' ),
|
|
1001
822
|
RenderModal: ( { items, closeModal } ) => {
|
|
1002
823
|
const [ item ] = items;
|
|
824
|
+
const blocks = useMemo( () => {
|
|
825
|
+
return (
|
|
826
|
+
item.blocks ??
|
|
827
|
+
parse( item.content.raw, {
|
|
828
|
+
__unstableSkipMigrationLogs: true,
|
|
829
|
+
} )
|
|
830
|
+
);
|
|
831
|
+
}, [ item?.content?.raw, item.blocks ] );
|
|
1003
832
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
1004
833
|
function onTemplatePartSuccess() {
|
|
1005
834
|
createSuccessNotice(
|
|
1006
835
|
sprintf(
|
|
1007
836
|
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
1008
837
|
__( '"%s" duplicated.' ),
|
|
1009
|
-
item
|
|
838
|
+
getItemTitle( item )
|
|
1010
839
|
),
|
|
1011
840
|
{ type: 'snackbar', id: 'edit-site-patterns-success' }
|
|
1012
841
|
);
|
|
@@ -1014,12 +843,12 @@ export const duplicateTemplatePartAction = {
|
|
|
1014
843
|
}
|
|
1015
844
|
return (
|
|
1016
845
|
<CreateTemplatePartModalContents
|
|
1017
|
-
blocks={
|
|
1018
|
-
defaultArea={ item.
|
|
846
|
+
blocks={ blocks }
|
|
847
|
+
defaultArea={ item.area }
|
|
1019
848
|
defaultTitle={ sprintf(
|
|
1020
849
|
/* translators: %s: Existing template part title */
|
|
1021
850
|
__( '%s (Copy)' ),
|
|
1022
|
-
item
|
|
851
|
+
getItemTitle( item )
|
|
1023
852
|
) }
|
|
1024
853
|
onCreate={ onTemplatePartSuccess }
|
|
1025
854
|
onError={ closeModal }
|
|
@@ -1029,21 +858,37 @@ export const duplicateTemplatePartAction = {
|
|
|
1029
858
|
},
|
|
1030
859
|
};
|
|
1031
860
|
|
|
1032
|
-
export function usePostActions( postType, onActionPerformed ) {
|
|
1033
|
-
const {
|
|
861
|
+
export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
862
|
+
const {
|
|
863
|
+
defaultActions,
|
|
864
|
+
postTypeObject,
|
|
865
|
+
userCanCreatePostType,
|
|
866
|
+
resource,
|
|
867
|
+
cachedCanUserResolvers,
|
|
868
|
+
} = useSelect(
|
|
1034
869
|
( select ) => {
|
|
1035
|
-
const { getPostType } =
|
|
870
|
+
const { getPostType, canUser, getCachedResolvers } =
|
|
871
|
+
select( coreStore );
|
|
1036
872
|
const { getEntityActions } = unlock( select( editorStore ) );
|
|
873
|
+
const _postTypeObject = getPostType( postType );
|
|
874
|
+
const _resource = _postTypeObject?.rest_base || '';
|
|
1037
875
|
return {
|
|
1038
|
-
postTypeObject:
|
|
876
|
+
postTypeObject: _postTypeObject,
|
|
1039
877
|
defaultActions: getEntityActions( 'postType', postType ),
|
|
878
|
+
userCanCreatePostType: canUser( 'create', _resource ),
|
|
879
|
+
resource: _resource,
|
|
880
|
+
cachedCanUserResolvers: getCachedResolvers()?.canUser,
|
|
1040
881
|
};
|
|
1041
882
|
},
|
|
1042
883
|
[ postType ]
|
|
1043
884
|
);
|
|
1044
885
|
|
|
1045
|
-
const
|
|
1046
|
-
const
|
|
886
|
+
const duplicatePostAction = useDuplicatePostAction( postType );
|
|
887
|
+
const trashPostActionForPostType = useTrashPostAction( resource );
|
|
888
|
+
const permanentlyDeletePostActionForPostType =
|
|
889
|
+
usePermanentlyDeletePostAction( resource );
|
|
890
|
+
const renamePostActionForPostType = useRenamePostAction( resource );
|
|
891
|
+
const restorePostActionForPostType = useRestorePostAction( resource );
|
|
1047
892
|
const isTemplateOrTemplatePart = [
|
|
1048
893
|
TEMPLATE_POST_TYPE,
|
|
1049
894
|
TEMPLATE_PART_POST_TYPE,
|
|
@@ -1057,7 +902,7 @@ export function usePostActions( postType, onActionPerformed ) {
|
|
|
1057
902
|
return [];
|
|
1058
903
|
}
|
|
1059
904
|
|
|
1060
|
-
|
|
905
|
+
let actions = [
|
|
1061
906
|
postTypeObject?.viewable && viewPostAction,
|
|
1062
907
|
supportsRevisions && postRevisionsAction,
|
|
1063
908
|
globalThis.IS_GUTENBERG_PLUGIN
|
|
@@ -1065,17 +910,31 @@ export function usePostActions( postType, onActionPerformed ) {
|
|
|
1065
910
|
! isPattern &&
|
|
1066
911
|
duplicatePostAction
|
|
1067
912
|
: false,
|
|
1068
|
-
isTemplateOrTemplatePart &&
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
isPattern &&
|
|
1072
|
-
|
|
1073
|
-
isTemplateOrTemplatePart
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
913
|
+
isTemplateOrTemplatePart &&
|
|
914
|
+
userCanCreatePostType &&
|
|
915
|
+
duplicateTemplatePartAction,
|
|
916
|
+
isPattern && userCanCreatePostType && duplicatePatternAction,
|
|
917
|
+
supportsTitle && renamePostActionForPostType,
|
|
918
|
+
! isTemplateOrTemplatePart && restorePostActionForPostType,
|
|
919
|
+
! isTemplateOrTemplatePart &&
|
|
920
|
+
! isPattern &&
|
|
921
|
+
trashPostActionForPostType,
|
|
922
|
+
! isTemplateOrTemplatePart &&
|
|
923
|
+
permanentlyDeletePostActionForPostType,
|
|
1077
924
|
...defaultActions,
|
|
1078
925
|
].filter( Boolean );
|
|
926
|
+
// Filter actions based on provided context. If not provided
|
|
927
|
+
// all actions are returned. We'll have a single entry for getting the actions
|
|
928
|
+
// and the consumer should provide the context to filter the actions, if needed.
|
|
929
|
+
// Actions should also provide the `context` they support, if it's specific, to
|
|
930
|
+
// compare with the provided context to get all the actions.
|
|
931
|
+
// Right now the only supported context is `list`.
|
|
932
|
+
actions = actions.filter( ( action ) => {
|
|
933
|
+
if ( ! action.context ) {
|
|
934
|
+
return true;
|
|
935
|
+
}
|
|
936
|
+
return action.context === context;
|
|
937
|
+
} );
|
|
1079
938
|
|
|
1080
939
|
if ( onActionPerformed ) {
|
|
1081
940
|
for ( let i = 0; i < actions.length; ++i ) {
|
|
@@ -1083,12 +942,18 @@ export function usePostActions( postType, onActionPerformed ) {
|
|
|
1083
942
|
const existingCallback = actions[ i ].callback;
|
|
1084
943
|
actions[ i ] = {
|
|
1085
944
|
...actions[ i ],
|
|
1086
|
-
callback: ( items,
|
|
1087
|
-
existingCallback( items,
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
945
|
+
callback: ( items, argsObject ) => {
|
|
946
|
+
existingCallback( items, {
|
|
947
|
+
...argsObject,
|
|
948
|
+
onActionPerformed: ( _items ) => {
|
|
949
|
+
if ( argsObject.onActionPerformed ) {
|
|
950
|
+
argsObject.onActionPerformed( _items );
|
|
951
|
+
}
|
|
952
|
+
onActionPerformed(
|
|
953
|
+
actions[ i ].id,
|
|
954
|
+
_items
|
|
955
|
+
);
|
|
956
|
+
},
|
|
1092
957
|
} );
|
|
1093
958
|
},
|
|
1094
959
|
};
|
|
@@ -1119,16 +984,25 @@ export function usePostActions( postType, onActionPerformed ) {
|
|
|
1119
984
|
}
|
|
1120
985
|
|
|
1121
986
|
return actions;
|
|
987
|
+
// We are making this use memo depend on cachedCanUserResolvers as a way to make the component using this hook re-render
|
|
988
|
+
// when user capabilities are resolved. This makes sure the isEligible functions of actions dependent on capabilities are re-evaluated.
|
|
989
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1122
990
|
}, [
|
|
1123
991
|
defaultActions,
|
|
992
|
+
userCanCreatePostType,
|
|
1124
993
|
isTemplateOrTemplatePart,
|
|
1125
994
|
isPattern,
|
|
1126
995
|
postTypeObject?.viewable,
|
|
1127
|
-
|
|
1128
|
-
|
|
996
|
+
duplicatePostAction,
|
|
997
|
+
trashPostActionForPostType,
|
|
998
|
+
restorePostActionForPostType,
|
|
999
|
+
renamePostActionForPostType,
|
|
1000
|
+
permanentlyDeletePostActionForPostType,
|
|
1129
1001
|
onActionPerformed,
|
|
1130
1002
|
isLoaded,
|
|
1131
1003
|
supportsRevisions,
|
|
1132
1004
|
supportsTitle,
|
|
1005
|
+
context,
|
|
1006
|
+
cachedCanUserResolvers,
|
|
1133
1007
|
] );
|
|
1134
1008
|
}
|