@wordpress/editor 14.5.0 → 14.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +37 -0
- package/build/bindings/post-meta.js +12 -10
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-manager/index.js +4 -1
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +5 -8
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +1 -0
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/document-bar/index.js +4 -4
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/editor-history/redo.js +4 -1
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +4 -1
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-interface/index.js +2 -3
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/error-boundary/index.js +4 -1
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +17 -4
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/index.js +8 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +8 -7
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +5 -5
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/page-attributes/parent.js +10 -6
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/plugin-preview-menu-item/index.js +57 -0
- package/build/components/plugin-preview-menu-item/index.js.map +1 -0
- package/build/components/post-actions/actions.js +4 -499
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +13 -25
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-card-panel/index.js +20 -20
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +4 -1
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-featured-image/index.js +14 -3
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-format/index.js +4 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-revision/index.js +4 -1
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-locked-modal/index.js +12 -3
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +4 -1
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +4 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +14 -8
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js +4 -0
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-slug/index.js +1 -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-taxonomies/hierarchical-term-selector.js +6 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +4 -1
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-template/block-theme.js +13 -4
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +4 -1
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-title/index.js +32 -46
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-url/index.js +10 -6
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +26 -14
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +5 -6
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/save-publish-panels/index.js +8 -2
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build/components/sidebar/post-summary.js +10 -7
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/start-template-options/index.js +4 -1
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/table-of-contents/index.js +4 -1
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/template-content-panel/index.js +1 -1
- package/build/components/template-content-panel/index.js.map +1 -1
- package/build/components/text-editor/index.js +4 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/index.js +1 -6
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/dataviews/actions/duplicate-pattern.js +48 -0
- package/build/dataviews/actions/duplicate-pattern.js.map +1 -0
- package/build/dataviews/actions/duplicate-post.js +146 -0
- package/build/dataviews/actions/duplicate-post.js.map +1 -0
- package/build/dataviews/actions/duplicate-post.native.js +9 -0
- package/build/dataviews/actions/duplicate-post.native.js.map +1 -0
- package/build/dataviews/actions/duplicate-template-part.js +67 -0
- package/build/dataviews/actions/duplicate-template-part.js.map +1 -0
- package/build/dataviews/actions/export-pattern.js +2 -0
- package/build/dataviews/actions/export-pattern.js.map +1 -1
- package/build/dataviews/actions/permanently-delete-post.js +2 -0
- package/build/dataviews/actions/permanently-delete-post.js.map +1 -1
- package/build/dataviews/actions/rename-post.js +125 -0
- package/build/dataviews/actions/rename-post.js.map +1 -0
- package/build/dataviews/actions/reorder-page.js +116 -0
- package/build/dataviews/actions/reorder-page.js.map +1 -0
- package/build/dataviews/actions/reorder-page.native.js +9 -0
- package/build/dataviews/actions/reorder-page.native.js.map +1 -0
- package/build/dataviews/actions/reset-post.js +9 -3
- package/build/dataviews/actions/reset-post.js.map +1 -1
- package/build/dataviews/actions/trash-post.js +8 -2
- package/build/dataviews/actions/trash-post.js.map +1 -1
- package/build/dataviews/actions/utils.js +9 -1
- package/build/dataviews/actions/utils.js.map +1 -1
- package/build/dataviews/actions/view-post-revisions.js +49 -0
- package/build/dataviews/actions/view-post-revisions.js.map +1 -0
- package/build/dataviews/actions/view-post.js +36 -0
- package/build/dataviews/actions/view-post.js.map +1 -0
- package/build/dataviews/fields/index.js +32 -0
- package/build/dataviews/fields/index.js.map +1 -0
- package/build/dataviews/store/private-actions.js +16 -2
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/dataviews/types.js.map +1 -1
- package/build/private-apis.js +2 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +2 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/store/utils/is-template-revertable.js +1 -1
- package/build/store/utils/is-template-revertable.js.map +1 -1
- package/build-module/bindings/post-meta.js +12 -10
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-manager/index.js +4 -1
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +6 -9
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +1 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +4 -4
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-history/redo.js +4 -1
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +4 -1
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/editor-interface/index.js +2 -3
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +4 -1
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +17 -4
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +8 -7
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js +5 -5
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +10 -6
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/plugin-preview-menu-item/index.js +52 -0
- package/build-module/components/plugin-preview-menu-item/index.js.map +1 -0
- package/build-module/components/post-actions/actions.js +5 -501
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +13 -25
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +20 -20
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +4 -1
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +14 -3
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-format/index.js +4 -1
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +4 -1
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +12 -3
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +4 -1
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +4 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +14 -8
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.js +4 -0
- package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
- package/build-module/components/post-slug/index.js +1 -0
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-status/index.js +4 -2
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +7 -3
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +4 -1
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +13 -4
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +4 -1
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-title/index.js +33 -47
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-url/index.js +11 -7
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +26 -14
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +6 -7
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +8 -2
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +10 -7
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/start-template-options/index.js +4 -1
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/table-of-contents/index.js +4 -1
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/template-content-panel/index.js +1 -1
- package/build-module/components/template-content-panel/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +4 -1
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +1 -6
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/dataviews/actions/duplicate-pattern.js +39 -0
- package/build-module/dataviews/actions/duplicate-pattern.js.map +1 -0
- package/build-module/dataviews/actions/duplicate-post.js +139 -0
- package/build-module/dataviews/actions/duplicate-post.js.map +1 -0
- package/build-module/dataviews/actions/duplicate-post.native.js +3 -0
- package/build-module/dataviews/actions/duplicate-post.native.js.map +1 -0
- package/build-module/dataviews/actions/duplicate-template-part.js +58 -0
- package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -0
- package/build-module/dataviews/actions/export-pattern.js +2 -0
- package/build-module/dataviews/actions/export-pattern.js.map +1 -1
- package/build-module/dataviews/actions/permanently-delete-post.js +3 -0
- package/build-module/dataviews/actions/permanently-delete-post.js.map +1 -1
- package/build-module/dataviews/actions/rename-post.js +118 -0
- package/build-module/dataviews/actions/rename-post.js.map +1 -0
- package/build-module/dataviews/actions/reorder-page.js +111 -0
- package/build-module/dataviews/actions/reorder-page.js.map +1 -0
- package/build-module/dataviews/actions/reorder-page.native.js +3 -0
- package/build-module/dataviews/actions/reorder-page.native.js.map +1 -0
- package/build-module/dataviews/actions/reset-post.js +9 -3
- package/build-module/dataviews/actions/reset-post.js.map +1 -1
- package/build-module/dataviews/actions/trash-post.js +8 -2
- package/build-module/dataviews/actions/trash-post.js.map +1 -1
- package/build-module/dataviews/actions/utils.js +7 -1
- package/build-module/dataviews/actions/utils.js.map +1 -1
- package/build-module/dataviews/actions/view-post-revisions.js +43 -0
- package/build-module/dataviews/actions/view-post-revisions.js.map +1 -0
- package/build-module/dataviews/actions/view-post.js +30 -0
- package/build-module/dataviews/actions/view-post.js.map +1 -0
- package/build-module/dataviews/fields/index.js +26 -0
- package/build-module/dataviews/fields/index.js.map +1 -0
- package/build-module/dataviews/store/private-actions.js +16 -2
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/dataviews/types.js.map +1 -1
- package/build-module/private-apis.js +2 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +2 -2
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/utils/is-template-revertable.js +1 -1
- package/build-module/store/utils/is-template-revertable.js.map +1 -1
- package/build-style/style-rtl.css +14 -38
- package/build-style/style.css +14 -38
- package/build-types/bindings/post-meta.d.ts +0 -3
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +1 -1
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
- package/build-types/components/editor-history/redo.d.ts.map +1 -1
- package/build-types/components/editor-history/undo.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/index.d.ts +1 -0
- package/build-types/components/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/plugin-preview-menu-item/index.d.ts +3 -0
- package/build-types/components/plugin-preview-menu-item/index.d.ts.map +1 -0
- package/build-types/components/post-actions/actions.d.ts +1 -26
- package/build-types/components/post-actions/actions.d.ts.map +1 -1
- package/build-types/components/post-actions/index.d.ts +3 -2
- package/build-types/components/post-actions/index.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts +4 -2
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-format/index.d.ts.map +1 -1
- package/build-types/components/post-last-revision/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-post-format-panel.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
- package/build-types/components/post-slug/index.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -17
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/start-template-options/index.d.ts.map +1 -1
- package/build-types/components/template-content-panel/index.d.ts.map +1 -1
- package/build-types/components/text-editor/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/dataviews/actions/duplicate-pattern.d.ts +5 -0
- package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +1 -0
- package/build-types/dataviews/actions/duplicate-post.d.ts +5 -0
- package/build-types/dataviews/actions/duplicate-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/duplicate-post.native.d.ts +3 -0
- package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +1 -0
- package/build-types/dataviews/actions/duplicate-template-part.d.ts +5 -0
- package/build-types/dataviews/actions/duplicate-template-part.d.ts.map +1 -0
- package/build-types/dataviews/actions/export-pattern.d.ts.map +1 -1
- package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/rename-post.d.ts +5 -0
- package/build-types/dataviews/actions/rename-post.d.ts.map +1 -0
- package/build-types/dataviews/actions/reorder-page.d.ts +8 -0
- package/build-types/dataviews/actions/reorder-page.d.ts.map +1 -0
- package/build-types/dataviews/actions/reorder-page.native.d.ts +3 -0
- package/build-types/dataviews/actions/reorder-page.native.d.ts.map +1 -0
- package/build-types/dataviews/actions/reset-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/trash-post.d.ts.map +1 -1
- package/build-types/dataviews/actions/utils.d.ts +5 -3
- package/build-types/dataviews/actions/utils.d.ts.map +1 -1
- package/build-types/dataviews/actions/view-post-revisions.d.ts +8 -0
- package/build-types/dataviews/actions/view-post-revisions.d.ts.map +1 -0
- package/build-types/dataviews/actions/view-post.d.ts +8 -0
- package/build-types/dataviews/actions/view-post.d.ts.map +1 -0
- package/build-types/dataviews/fields/index.d.ts +8 -0
- package/build-types/dataviews/fields/index.d.ts.map +1 -0
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/dataviews/types.d.ts +57 -8
- package/build-types/dataviews/types.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/utils/is-template-revertable.d.ts.map +1 -1
- package/package.json +36 -36
- package/src/bindings/post-meta.js +14 -8
- package/src/components/block-manager/index.js +2 -0
- package/src/components/block-manager/style.scss +2 -2
- package/src/components/block-settings-menu/content-only-settings-menu.js +5 -9
- package/src/components/create-template-part-modal/index.js +1 -0
- package/src/components/create-template-part-modal/style.scss +1 -1
- package/src/components/document-bar/index.js +4 -4
- package/src/components/document-outline/style.scss +1 -1
- package/src/components/editor-history/redo.js +2 -0
- package/src/components/editor-history/undo.js +2 -0
- package/src/components/editor-interface/index.js +2 -4
- package/src/components/error-boundary/index.js +6 -1
- package/src/components/error-boundary/style.native.scss +1 -1
- package/src/components/error-boundary/style.scss +1 -1
- package/src/components/global-styles-provider/index.js +16 -3
- package/src/components/header/style.scss +6 -3
- package/src/components/index.js +1 -0
- package/src/components/inserter-sidebar/index.js +12 -5
- package/src/components/local-autosave-monitor/index.js +6 -6
- package/src/components/page-attributes/parent.js +18 -13
- package/src/components/plugin-preview-menu-item/index.js +52 -0
- package/src/components/post-actions/actions.js +5 -616
- package/src/components/post-actions/index.js +24 -34
- package/src/components/post-card-panel/index.js +28 -27
- package/src/components/post-card-panel/style.scss +1 -1
- package/src/components/post-discussion/style.scss +0 -9
- package/src/components/post-excerpt/panel.js +2 -0
- package/src/components/post-featured-image/index.js +8 -0
- package/src/components/post-featured-image/style.scss +1 -2
- package/src/components/post-format/index.js +2 -0
- package/src/components/post-format/style.scss +0 -6
- package/src/components/post-last-revision/index.js +2 -0
- package/src/components/post-locked-modal/index.js +14 -2
- package/src/components/post-locked-modal/style.scss +1 -1
- package/src/components/post-publish-panel/index.js +2 -0
- package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -0
- package/src/components/post-publish-panel/maybe-upload-media.js +37 -29
- package/src/components/post-publish-panel/postpublish.js +8 -2
- package/src/components/post-publish-panel/style.scss +3 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +8 -8
- package/src/components/post-slug/index.js +1 -0
- package/src/components/post-status/index.js +3 -2
- package/src/components/post-status/style.scss +0 -19
- package/src/components/post-taxonomies/hierarchical-term-selector.js +5 -1
- package/src/components/post-taxonomies/most-used-terms.js +2 -0
- package/src/components/post-template/block-theme.js +15 -9
- package/src/components/post-template/classic-theme.js +2 -0
- package/src/components/post-title/index.js +30 -41
- package/src/components/post-url/index.js +17 -9
- package/src/components/preview-dropdown/index.js +28 -20
- package/src/components/provider/use-block-editor-settings.js +5 -5
- package/src/components/resizable-editor/style.scss +2 -2
- package/src/components/save-publish-panels/index.js +4 -0
- package/src/components/save-publish-panels/style.scss +3 -3
- package/src/components/sidebar/post-summary.js +20 -16
- package/src/components/site-discussion/style.scss +0 -14
- package/src/components/start-template-options/index.js +6 -1
- package/src/components/table-of-contents/index.js +2 -0
- package/src/components/template-content-panel/index.js +4 -1
- package/src/components/text-editor/index.js +2 -0
- package/src/components/visual-editor/index.js +2 -9
- package/src/dataviews/actions/duplicate-pattern.tsx +40 -0
- package/src/dataviews/actions/duplicate-post.native.tsx +3 -0
- package/src/dataviews/actions/duplicate-post.tsx +174 -0
- package/src/dataviews/actions/duplicate-template-part.tsx +70 -0
- package/src/dataviews/actions/export-pattern.tsx +2 -0
- package/src/dataviews/actions/permanently-delete-post.tsx +2 -0
- package/src/dataviews/actions/rename-post.tsx +146 -0
- package/src/dataviews/actions/reorder-page.native.tsx +3 -0
- package/src/dataviews/actions/reorder-page.tsx +125 -0
- package/src/dataviews/actions/reset-post.tsx +6 -1
- package/src/dataviews/actions/trash-post.tsx +4 -0
- package/src/dataviews/actions/utils.ts +14 -4
- package/src/dataviews/actions/view-post-revisions.tsx +47 -0
- package/src/dataviews/actions/view-post.tsx +30 -0
- package/src/dataviews/fields/index.ts +26 -0
- package/src/dataviews/store/private-actions.ts +42 -1
- package/src/dataviews/types.ts +47 -6
- package/src/private-apis.js +2 -2
- package/src/store/private-actions.js +4 -2
- package/src/store/utils/is-template-revertable.js +2 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,637 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { external } from '@wordpress/icons';
|
|
5
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
6
4
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
-
import {
|
|
8
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
-
import { __, sprintf, _x } from '@wordpress/i18n';
|
|
10
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
-
import { useMemo, useState, useEffect } from '@wordpress/element';
|
|
12
|
-
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
13
|
-
import { parse } from '@wordpress/blocks';
|
|
14
|
-
import { DataForm, isItemValid } from '@wordpress/dataviews';
|
|
15
|
-
import {
|
|
16
|
-
Button,
|
|
17
|
-
TextControl,
|
|
18
|
-
__experimentalHStack as HStack,
|
|
19
|
-
__experimentalVStack as VStack,
|
|
20
|
-
} from '@wordpress/components';
|
|
5
|
+
import { useMemo, useEffect } from '@wordpress/element';
|
|
21
6
|
|
|
22
7
|
/**
|
|
23
8
|
* Internal dependencies
|
|
24
9
|
*/
|
|
25
|
-
import {
|
|
26
|
-
TEMPLATE_ORIGINS,
|
|
27
|
-
TEMPLATE_PART_POST_TYPE,
|
|
28
|
-
TEMPLATE_POST_TYPE,
|
|
29
|
-
PATTERN_POST_TYPE,
|
|
30
|
-
} from '../../store/constants';
|
|
31
10
|
import { store as editorStore } from '../../store';
|
|
32
11
|
import { unlock } from '../../lock-unlock';
|
|
33
|
-
import { CreateTemplatePartModalContents } from '../create-template-part-modal';
|
|
34
|
-
import { getItemTitle } from '../../dataviews/actions/utils';
|
|
35
|
-
|
|
36
|
-
// Patterns.
|
|
37
|
-
const { PATTERN_TYPES, CreatePatternModalContents, useDuplicatePatternProps } =
|
|
38
|
-
unlock( patternsPrivateApis );
|
|
39
|
-
|
|
40
|
-
// TODO: this should be shared with other components (see post-fields in edit-site).
|
|
41
|
-
const fields = [
|
|
42
|
-
{
|
|
43
|
-
type: 'text',
|
|
44
|
-
id: 'title',
|
|
45
|
-
label: __( 'Title' ),
|
|
46
|
-
placeholder: __( 'No title' ),
|
|
47
|
-
getValue: ( { item } ) => item.title,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
type: 'integer',
|
|
51
|
-
id: 'menu_order',
|
|
52
|
-
label: __( 'Order' ),
|
|
53
|
-
description: __( 'Determines the order of pages.' ),
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
const formDuplicateAction = {
|
|
58
|
-
fields: [ 'title' ],
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const formOrderAction = {
|
|
62
|
-
fields: [ 'menu_order' ],
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Check if a template is removable.
|
|
67
|
-
*
|
|
68
|
-
* @param {Object} template The template entity to check.
|
|
69
|
-
* @return {boolean} Whether the template is removable.
|
|
70
|
-
*/
|
|
71
|
-
function isTemplateRemovable( template ) {
|
|
72
|
-
if ( ! template ) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
// In patterns list page we map the templates parts to a different object
|
|
76
|
-
// than the one returned from the endpoint. This is why we need to check for
|
|
77
|
-
// two props whether is custom or has a theme file.
|
|
78
|
-
return (
|
|
79
|
-
template?.source === TEMPLATE_ORIGINS.custom &&
|
|
80
|
-
! template?.has_theme_file
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const viewPostAction = {
|
|
85
|
-
id: 'view-post',
|
|
86
|
-
label: __( 'View' ),
|
|
87
|
-
isPrimary: true,
|
|
88
|
-
icon: external,
|
|
89
|
-
isEligible( post ) {
|
|
90
|
-
return post.status !== 'trash';
|
|
91
|
-
},
|
|
92
|
-
callback( posts, { onActionPerformed } ) {
|
|
93
|
-
const post = posts[ 0 ];
|
|
94
|
-
window.open( post.link, '_blank' );
|
|
95
|
-
if ( onActionPerformed ) {
|
|
96
|
-
onActionPerformed( posts );
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const postRevisionsAction = {
|
|
102
|
-
id: 'view-post-revisions',
|
|
103
|
-
context: 'list',
|
|
104
|
-
label( items ) {
|
|
105
|
-
const revisionsCount =
|
|
106
|
-
items[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
107
|
-
return sprintf(
|
|
108
|
-
/* translators: %s: number of revisions */
|
|
109
|
-
__( 'View revisions (%s)' ),
|
|
110
|
-
revisionsCount
|
|
111
|
-
);
|
|
112
|
-
},
|
|
113
|
-
isEligible: ( post ) => {
|
|
114
|
-
if ( post.status === 'trash' ) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
const lastRevisionId =
|
|
118
|
-
post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;
|
|
119
|
-
const revisionsCount =
|
|
120
|
-
post?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;
|
|
121
|
-
return lastRevisionId && revisionsCount > 1;
|
|
122
|
-
},
|
|
123
|
-
callback( posts, { onActionPerformed } ) {
|
|
124
|
-
const post = posts[ 0 ];
|
|
125
|
-
const href = addQueryArgs( 'revision.php', {
|
|
126
|
-
revision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,
|
|
127
|
-
} );
|
|
128
|
-
document.location.href = href;
|
|
129
|
-
if ( onActionPerformed ) {
|
|
130
|
-
onActionPerformed( posts );
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const renamePostAction = {
|
|
136
|
-
id: 'rename-post',
|
|
137
|
-
label: __( 'Rename' ),
|
|
138
|
-
isEligible( post ) {
|
|
139
|
-
if ( post.status === 'trash' ) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
// Templates, template parts and patterns have special checks for renaming.
|
|
143
|
-
if (
|
|
144
|
-
! [
|
|
145
|
-
TEMPLATE_POST_TYPE,
|
|
146
|
-
TEMPLATE_PART_POST_TYPE,
|
|
147
|
-
...Object.values( PATTERN_TYPES ),
|
|
148
|
-
].includes( post.type )
|
|
149
|
-
) {
|
|
150
|
-
return post.permissions?.update;
|
|
151
|
-
}
|
|
152
|
-
// In the case of templates, we can only rename custom templates.
|
|
153
|
-
if ( post.type === TEMPLATE_POST_TYPE ) {
|
|
154
|
-
return (
|
|
155
|
-
isTemplateRemovable( post ) &&
|
|
156
|
-
post.is_custom &&
|
|
157
|
-
post.permissions?.update
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
// Make necessary checks for template parts and patterns.
|
|
161
|
-
const isTemplatePart = post.type === TEMPLATE_PART_POST_TYPE;
|
|
162
|
-
const isUserPattern = post.type === PATTERN_TYPES.user;
|
|
163
|
-
// In patterns list page we map the templates parts to a different object
|
|
164
|
-
// than the one returned from the endpoint. This is why we need to check for
|
|
165
|
-
// two props whether is custom or has a theme file.
|
|
166
|
-
const isCustomPattern =
|
|
167
|
-
isUserPattern ||
|
|
168
|
-
( isTemplatePart && post.source === TEMPLATE_ORIGINS.custom );
|
|
169
|
-
const hasThemeFile = post?.has_theme_file;
|
|
170
|
-
return isCustomPattern && ! hasThemeFile && post.permissions?.update;
|
|
171
|
-
},
|
|
172
|
-
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
173
|
-
const [ item ] = items;
|
|
174
|
-
const [ title, setTitle ] = useState( () => getItemTitle( item ) );
|
|
175
|
-
const { editEntityRecord, saveEditedEntityRecord } =
|
|
176
|
-
useDispatch( coreStore );
|
|
177
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
178
|
-
useDispatch( noticesStore );
|
|
179
|
-
|
|
180
|
-
async function onRename( event ) {
|
|
181
|
-
event.preventDefault();
|
|
182
|
-
try {
|
|
183
|
-
await editEntityRecord( 'postType', item.type, item.id, {
|
|
184
|
-
title,
|
|
185
|
-
} );
|
|
186
|
-
// Update state before saving rerenders the list.
|
|
187
|
-
setTitle( '' );
|
|
188
|
-
closeModal();
|
|
189
|
-
// Persist edited entity.
|
|
190
|
-
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
191
|
-
throwOnError: true,
|
|
192
|
-
} );
|
|
193
|
-
createSuccessNotice( __( 'Name updated' ), {
|
|
194
|
-
type: 'snackbar',
|
|
195
|
-
} );
|
|
196
|
-
onActionPerformed?.( items );
|
|
197
|
-
} catch ( error ) {
|
|
198
|
-
const errorMessage =
|
|
199
|
-
error.message && error.code !== 'unknown_error'
|
|
200
|
-
? error.message
|
|
201
|
-
: __( 'An error occurred while updating the name' );
|
|
202
|
-
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<form onSubmit={ onRename }>
|
|
208
|
-
<VStack spacing="5">
|
|
209
|
-
<TextControl
|
|
210
|
-
__nextHasNoMarginBottom
|
|
211
|
-
__next40pxDefaultSize
|
|
212
|
-
label={ __( 'Name' ) }
|
|
213
|
-
value={ title }
|
|
214
|
-
onChange={ setTitle }
|
|
215
|
-
required
|
|
216
|
-
/>
|
|
217
|
-
<HStack justify="right">
|
|
218
|
-
<Button
|
|
219
|
-
__next40pxDefaultSize
|
|
220
|
-
variant="tertiary"
|
|
221
|
-
onClick={ () => {
|
|
222
|
-
closeModal();
|
|
223
|
-
} }
|
|
224
|
-
>
|
|
225
|
-
{ __( 'Cancel' ) }
|
|
226
|
-
</Button>
|
|
227
|
-
<Button
|
|
228
|
-
__next40pxDefaultSize
|
|
229
|
-
variant="primary"
|
|
230
|
-
type="submit"
|
|
231
|
-
>
|
|
232
|
-
{ __( 'Save' ) }
|
|
233
|
-
</Button>
|
|
234
|
-
</HStack>
|
|
235
|
-
</VStack>
|
|
236
|
-
</form>
|
|
237
|
-
);
|
|
238
|
-
},
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
function ReorderModal( { items, closeModal, onActionPerformed } ) {
|
|
242
|
-
const [ item, setItem ] = useState( items[ 0 ] );
|
|
243
|
-
const orderInput = item.menu_order;
|
|
244
|
-
const { editEntityRecord, saveEditedEntityRecord } =
|
|
245
|
-
useDispatch( coreStore );
|
|
246
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
247
|
-
useDispatch( noticesStore );
|
|
248
|
-
|
|
249
|
-
async function onOrder( event ) {
|
|
250
|
-
event.preventDefault();
|
|
251
|
-
|
|
252
|
-
if ( ! isItemValid( item, fields, formOrderAction ) ) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
try {
|
|
257
|
-
await editEntityRecord( 'postType', item.type, item.id, {
|
|
258
|
-
menu_order: orderInput,
|
|
259
|
-
} );
|
|
260
|
-
closeModal();
|
|
261
|
-
// Persist edited entity.
|
|
262
|
-
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
263
|
-
throwOnError: true,
|
|
264
|
-
} );
|
|
265
|
-
createSuccessNotice( __( 'Order updated' ), {
|
|
266
|
-
type: 'snackbar',
|
|
267
|
-
} );
|
|
268
|
-
onActionPerformed?.( items );
|
|
269
|
-
} catch ( error ) {
|
|
270
|
-
const errorMessage =
|
|
271
|
-
error.message && error.code !== 'unknown_error'
|
|
272
|
-
? error.message
|
|
273
|
-
: __( 'An error occurred while updating the order' );
|
|
274
|
-
createErrorNotice( errorMessage, {
|
|
275
|
-
type: 'snackbar',
|
|
276
|
-
} );
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
const isSaveDisabled = ! isItemValid( item, fields, formOrderAction );
|
|
280
|
-
return (
|
|
281
|
-
<form onSubmit={ onOrder }>
|
|
282
|
-
<VStack spacing="5">
|
|
283
|
-
<div>
|
|
284
|
-
{ __(
|
|
285
|
-
'Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.'
|
|
286
|
-
) }
|
|
287
|
-
</div>
|
|
288
|
-
<DataForm
|
|
289
|
-
data={ item }
|
|
290
|
-
fields={ fields }
|
|
291
|
-
form={ formOrderAction }
|
|
292
|
-
onChange={ setItem }
|
|
293
|
-
/>
|
|
294
|
-
<HStack justify="right">
|
|
295
|
-
<Button
|
|
296
|
-
__next40pxDefaultSize
|
|
297
|
-
variant="tertiary"
|
|
298
|
-
onClick={ () => {
|
|
299
|
-
closeModal();
|
|
300
|
-
} }
|
|
301
|
-
>
|
|
302
|
-
{ __( 'Cancel' ) }
|
|
303
|
-
</Button>
|
|
304
|
-
<Button
|
|
305
|
-
__next40pxDefaultSize
|
|
306
|
-
variant="primary"
|
|
307
|
-
type="submit"
|
|
308
|
-
accessibleWhenDisabled
|
|
309
|
-
disabled={ isSaveDisabled }
|
|
310
|
-
__experimentalIsFocusable
|
|
311
|
-
>
|
|
312
|
-
{ __( 'Save' ) }
|
|
313
|
-
</Button>
|
|
314
|
-
</HStack>
|
|
315
|
-
</VStack>
|
|
316
|
-
</form>
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function useReorderPagesAction( postType ) {
|
|
321
|
-
const supportsPageAttributes = useSelect(
|
|
322
|
-
( select ) => {
|
|
323
|
-
const { getPostType } = select( coreStore );
|
|
324
|
-
const postTypeObject = getPostType( postType );
|
|
325
|
-
|
|
326
|
-
return !! postTypeObject?.supports?.[ 'page-attributes' ];
|
|
327
|
-
},
|
|
328
|
-
[ postType ]
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
return useMemo(
|
|
332
|
-
() =>
|
|
333
|
-
supportsPageAttributes && {
|
|
334
|
-
id: 'order-pages',
|
|
335
|
-
label: __( 'Order' ),
|
|
336
|
-
isEligible( { status } ) {
|
|
337
|
-
return status !== 'trash';
|
|
338
|
-
},
|
|
339
|
-
RenderModal: ReorderModal,
|
|
340
|
-
},
|
|
341
|
-
[ supportsPageAttributes ]
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const useDuplicatePostAction = ( postType ) => {
|
|
346
|
-
const userCanCreatePost = useSelect(
|
|
347
|
-
( select ) => {
|
|
348
|
-
return select( coreStore ).canUser( 'create', {
|
|
349
|
-
kind: 'postType',
|
|
350
|
-
name: postType,
|
|
351
|
-
} );
|
|
352
|
-
},
|
|
353
|
-
[ postType ]
|
|
354
|
-
);
|
|
355
|
-
return useMemo(
|
|
356
|
-
() =>
|
|
357
|
-
userCanCreatePost && {
|
|
358
|
-
id: 'duplicate-post',
|
|
359
|
-
label: _x( 'Duplicate', 'action label' ),
|
|
360
|
-
isEligible( { status } ) {
|
|
361
|
-
return status !== 'trash';
|
|
362
|
-
},
|
|
363
|
-
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
364
|
-
const [ item, setItem ] = useState( {
|
|
365
|
-
...items[ 0 ],
|
|
366
|
-
title: sprintf(
|
|
367
|
-
/* translators: %s: Existing template title */
|
|
368
|
-
__( '%s (Copy)' ),
|
|
369
|
-
getItemTitle( items[ 0 ] )
|
|
370
|
-
),
|
|
371
|
-
} );
|
|
372
|
-
|
|
373
|
-
const [ isCreatingPage, setIsCreatingPage ] =
|
|
374
|
-
useState( false );
|
|
375
|
-
|
|
376
|
-
const { saveEntityRecord } = useDispatch( coreStore );
|
|
377
|
-
const { createSuccessNotice, createErrorNotice } =
|
|
378
|
-
useDispatch( noticesStore );
|
|
379
|
-
|
|
380
|
-
async function createPage( event ) {
|
|
381
|
-
event.preventDefault();
|
|
382
|
-
|
|
383
|
-
if ( isCreatingPage ) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const newItemOject = {
|
|
388
|
-
status: 'draft',
|
|
389
|
-
title: item.title,
|
|
390
|
-
slug: item.title || __( 'No title' ),
|
|
391
|
-
comment_status: item.comment_status,
|
|
392
|
-
content:
|
|
393
|
-
typeof item.content === 'string'
|
|
394
|
-
? item.content
|
|
395
|
-
: item.content.raw,
|
|
396
|
-
excerpt: item.excerpt.raw,
|
|
397
|
-
meta: item.meta,
|
|
398
|
-
parent: item.parent,
|
|
399
|
-
password: item.password,
|
|
400
|
-
template: item.template,
|
|
401
|
-
format: item.format,
|
|
402
|
-
featured_media: item.featured_media,
|
|
403
|
-
menu_order: item.menu_order,
|
|
404
|
-
ping_status: item.ping_status,
|
|
405
|
-
};
|
|
406
|
-
const assignablePropertiesPrefix = 'wp:action-assign-';
|
|
407
|
-
// Get all the properties that the current user is able to assign normally author, categories, tags,
|
|
408
|
-
// and custom taxonomies.
|
|
409
|
-
const assignableProperties = Object.keys(
|
|
410
|
-
item?._links || {}
|
|
411
|
-
)
|
|
412
|
-
.filter( ( property ) =>
|
|
413
|
-
property.startsWith(
|
|
414
|
-
assignablePropertiesPrefix
|
|
415
|
-
)
|
|
416
|
-
)
|
|
417
|
-
.map( ( property ) =>
|
|
418
|
-
property.slice(
|
|
419
|
-
assignablePropertiesPrefix.length
|
|
420
|
-
)
|
|
421
|
-
);
|
|
422
|
-
assignableProperties.forEach( ( property ) => {
|
|
423
|
-
if ( item[ property ] ) {
|
|
424
|
-
newItemOject[ property ] = item[ property ];
|
|
425
|
-
}
|
|
426
|
-
} );
|
|
427
|
-
setIsCreatingPage( true );
|
|
428
|
-
try {
|
|
429
|
-
const newItem = await saveEntityRecord(
|
|
430
|
-
'postType',
|
|
431
|
-
item.type,
|
|
432
|
-
newItemOject,
|
|
433
|
-
{ throwOnError: true }
|
|
434
|
-
);
|
|
435
|
-
|
|
436
|
-
createSuccessNotice(
|
|
437
|
-
sprintf(
|
|
438
|
-
// translators: %s: Title of the created template e.g: "Category".
|
|
439
|
-
__( '"%s" successfully created.' ),
|
|
440
|
-
decodeEntities(
|
|
441
|
-
newItem.title?.rendered || item.title
|
|
442
|
-
)
|
|
443
|
-
),
|
|
444
|
-
{
|
|
445
|
-
id: 'duplicate-post-action',
|
|
446
|
-
type: 'snackbar',
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
if ( onActionPerformed ) {
|
|
451
|
-
onActionPerformed( [ newItem ] );
|
|
452
|
-
}
|
|
453
|
-
} catch ( error ) {
|
|
454
|
-
const errorMessage =
|
|
455
|
-
error.message && error.code !== 'unknown_error'
|
|
456
|
-
? error.message
|
|
457
|
-
: __(
|
|
458
|
-
'An error occurred while duplicating the page.'
|
|
459
|
-
);
|
|
460
|
-
|
|
461
|
-
createErrorNotice( errorMessage, {
|
|
462
|
-
type: 'snackbar',
|
|
463
|
-
} );
|
|
464
|
-
} finally {
|
|
465
|
-
setIsCreatingPage( false );
|
|
466
|
-
closeModal();
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return (
|
|
471
|
-
<form onSubmit={ createPage }>
|
|
472
|
-
<VStack spacing={ 3 }>
|
|
473
|
-
<DataForm
|
|
474
|
-
data={ item }
|
|
475
|
-
fields={ fields }
|
|
476
|
-
form={ formDuplicateAction }
|
|
477
|
-
onChange={ setItem }
|
|
478
|
-
/>
|
|
479
|
-
<HStack spacing={ 2 } justify="end">
|
|
480
|
-
<Button
|
|
481
|
-
variant="tertiary"
|
|
482
|
-
onClick={ closeModal }
|
|
483
|
-
__next40pxDefaultSize
|
|
484
|
-
>
|
|
485
|
-
{ __( 'Cancel' ) }
|
|
486
|
-
</Button>
|
|
487
|
-
<Button
|
|
488
|
-
variant="primary"
|
|
489
|
-
type="submit"
|
|
490
|
-
isBusy={ isCreatingPage }
|
|
491
|
-
aria-disabled={ isCreatingPage }
|
|
492
|
-
__next40pxDefaultSize
|
|
493
|
-
>
|
|
494
|
-
{ _x( 'Duplicate', 'action label' ) }
|
|
495
|
-
</Button>
|
|
496
|
-
</HStack>
|
|
497
|
-
</VStack>
|
|
498
|
-
</form>
|
|
499
|
-
);
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
[ userCanCreatePost ]
|
|
503
|
-
);
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
export const duplicatePatternAction = {
|
|
507
|
-
id: 'duplicate-pattern',
|
|
508
|
-
label: _x( 'Duplicate', 'action label' ),
|
|
509
|
-
isEligible: ( item ) => item.type !== TEMPLATE_PART_POST_TYPE,
|
|
510
|
-
modalHeader: _x( 'Duplicate pattern', 'action label' ),
|
|
511
|
-
RenderModal: ( { items, closeModal } ) => {
|
|
512
|
-
const [ item ] = items;
|
|
513
|
-
const duplicatedProps = useDuplicatePatternProps( {
|
|
514
|
-
pattern: item,
|
|
515
|
-
onSuccess: () => closeModal(),
|
|
516
|
-
} );
|
|
517
|
-
return (
|
|
518
|
-
<CreatePatternModalContents
|
|
519
|
-
onClose={ closeModal }
|
|
520
|
-
confirmLabel={ _x( 'Duplicate', 'action label' ) }
|
|
521
|
-
{ ...duplicatedProps }
|
|
522
|
-
/>
|
|
523
|
-
);
|
|
524
|
-
},
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
export const duplicateTemplatePartAction = {
|
|
528
|
-
id: 'duplicate-template-part',
|
|
529
|
-
label: _x( 'Duplicate', 'action label' ),
|
|
530
|
-
isEligible: ( item ) => item.type === TEMPLATE_PART_POST_TYPE,
|
|
531
|
-
modalHeader: _x( 'Duplicate template part', 'action label' ),
|
|
532
|
-
RenderModal: ( { items, closeModal } ) => {
|
|
533
|
-
const [ item ] = items;
|
|
534
|
-
const blocks = useMemo( () => {
|
|
535
|
-
return (
|
|
536
|
-
item.blocks ??
|
|
537
|
-
parse(
|
|
538
|
-
typeof item.content === 'string'
|
|
539
|
-
? item.content
|
|
540
|
-
: item.content.raw,
|
|
541
|
-
{
|
|
542
|
-
__unstableSkipMigrationLogs: true,
|
|
543
|
-
}
|
|
544
|
-
)
|
|
545
|
-
);
|
|
546
|
-
}, [ item.content, item.blocks ] );
|
|
547
|
-
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
548
|
-
function onTemplatePartSuccess() {
|
|
549
|
-
createSuccessNotice(
|
|
550
|
-
sprintf(
|
|
551
|
-
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
552
|
-
__( '"%s" duplicated.' ),
|
|
553
|
-
getItemTitle( item )
|
|
554
|
-
),
|
|
555
|
-
{ type: 'snackbar', id: 'edit-site-patterns-success' }
|
|
556
|
-
);
|
|
557
|
-
closeModal();
|
|
558
|
-
}
|
|
559
|
-
return (
|
|
560
|
-
<CreateTemplatePartModalContents
|
|
561
|
-
blocks={ blocks }
|
|
562
|
-
defaultArea={ item.area }
|
|
563
|
-
defaultTitle={ sprintf(
|
|
564
|
-
/* translators: %s: Existing template part title */
|
|
565
|
-
__( '%s (Copy)' ),
|
|
566
|
-
getItemTitle( item )
|
|
567
|
-
) }
|
|
568
|
-
onCreate={ onTemplatePartSuccess }
|
|
569
|
-
onError={ closeModal }
|
|
570
|
-
confirmLabel={ _x( 'Duplicate', 'action label' ) }
|
|
571
|
-
/>
|
|
572
|
-
);
|
|
573
|
-
},
|
|
574
|
-
};
|
|
575
12
|
|
|
576
13
|
export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
577
|
-
const { defaultActions
|
|
14
|
+
const { defaultActions } = useSelect(
|
|
578
15
|
( select ) => {
|
|
579
|
-
const { getPostType, canUser } = select( coreStore );
|
|
580
16
|
const { getEntityActions } = unlock( select( editorStore ) );
|
|
581
17
|
return {
|
|
582
|
-
postTypeObject: getPostType( postType ),
|
|
583
18
|
defaultActions: getEntityActions( 'postType', postType ),
|
|
584
|
-
userCanCreatePostType: canUser( 'create', {
|
|
585
|
-
kind: 'postType',
|
|
586
|
-
name: postType,
|
|
587
|
-
} ),
|
|
588
19
|
};
|
|
589
20
|
},
|
|
590
21
|
[ postType ]
|
|
591
22
|
);
|
|
23
|
+
|
|
592
24
|
const { registerPostTypeActions } = unlock( useDispatch( editorStore ) );
|
|
593
25
|
useEffect( () => {
|
|
594
26
|
registerPostTypeActions( postType );
|
|
595
27
|
}, [ registerPostTypeActions, postType ] );
|
|
596
28
|
|
|
597
|
-
const duplicatePostAction = useDuplicatePostAction( postType );
|
|
598
|
-
const reorderPagesAction = useReorderPagesAction( postType );
|
|
599
|
-
const isTemplateOrTemplatePart = [
|
|
600
|
-
TEMPLATE_POST_TYPE,
|
|
601
|
-
TEMPLATE_PART_POST_TYPE,
|
|
602
|
-
].includes( postType );
|
|
603
|
-
const isPattern = postType === PATTERN_POST_TYPE;
|
|
604
|
-
const isLoaded = !! postTypeObject;
|
|
605
|
-
const supportsRevisions = !! postTypeObject?.supports?.revisions;
|
|
606
|
-
const supportsTitle = !! postTypeObject?.supports?.title;
|
|
607
29
|
return useMemo( () => {
|
|
608
|
-
if ( ! isLoaded ) {
|
|
609
|
-
return [];
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
let actions = [
|
|
613
|
-
postTypeObject?.viewable && viewPostAction,
|
|
614
|
-
supportsRevisions && postRevisionsAction,
|
|
615
|
-
globalThis.IS_GUTENBERG_PLUGIN
|
|
616
|
-
? ! isTemplateOrTemplatePart &&
|
|
617
|
-
! isPattern &&
|
|
618
|
-
duplicatePostAction
|
|
619
|
-
: false,
|
|
620
|
-
isTemplateOrTemplatePart &&
|
|
621
|
-
userCanCreatePostType &&
|
|
622
|
-
duplicateTemplatePartAction,
|
|
623
|
-
isPattern && userCanCreatePostType && duplicatePatternAction,
|
|
624
|
-
supportsTitle && renamePostAction,
|
|
625
|
-
reorderPagesAction,
|
|
626
|
-
...defaultActions,
|
|
627
|
-
].filter( Boolean );
|
|
628
30
|
// Filter actions based on provided context. If not provided
|
|
629
31
|
// all actions are returned. We'll have a single entry for getting the actions
|
|
630
32
|
// and the consumer should provide the context to filter the actions, if needed.
|
|
631
33
|
// Actions should also provide the `context` they support, if it's specific, to
|
|
632
34
|
// compare with the provided context to get all the actions.
|
|
633
35
|
// Right now the only supported context is `list`.
|
|
634
|
-
actions =
|
|
36
|
+
const actions = defaultActions.filter( ( action ) => {
|
|
635
37
|
if ( ! action.context ) {
|
|
636
38
|
return true;
|
|
637
39
|
}
|
|
@@ -686,18 +88,5 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
|
|
|
686
88
|
}
|
|
687
89
|
|
|
688
90
|
return actions;
|
|
689
|
-
}, [
|
|
690
|
-
defaultActions,
|
|
691
|
-
userCanCreatePostType,
|
|
692
|
-
isTemplateOrTemplatePart,
|
|
693
|
-
isPattern,
|
|
694
|
-
postTypeObject?.viewable,
|
|
695
|
-
duplicatePostAction,
|
|
696
|
-
reorderPagesAction,
|
|
697
|
-
onActionPerformed,
|
|
698
|
-
isLoaded,
|
|
699
|
-
supportsRevisions,
|
|
700
|
-
supportsTitle,
|
|
701
|
-
context,
|
|
702
|
-
] );
|
|
91
|
+
}, [ defaultActions, onActionPerformed, context ] );
|
|
703
92
|
}
|