@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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { _x } from '@wordpress/i18n';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
7
|
+
import type { Action } from '@wordpress/dataviews';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { unlock } from '../../lock-unlock';
|
|
13
|
+
import type { Pattern } from '../types';
|
|
14
|
+
|
|
15
|
+
// Patterns.
|
|
16
|
+
const { CreatePatternModalContents, useDuplicatePatternProps } =
|
|
17
|
+
unlock( patternsPrivateApis );
|
|
18
|
+
|
|
19
|
+
const duplicatePattern: Action< Pattern > = {
|
|
20
|
+
id: 'duplicate-pattern',
|
|
21
|
+
label: _x( 'Duplicate', 'action label' ),
|
|
22
|
+
isEligible: ( item ) => item.type !== 'wp_template_part',
|
|
23
|
+
modalHeader: _x( 'Duplicate pattern', 'action label' ),
|
|
24
|
+
RenderModal: ( { items, closeModal } ) => {
|
|
25
|
+
const [ item ] = items;
|
|
26
|
+
const duplicatedProps = useDuplicatePatternProps( {
|
|
27
|
+
pattern: item,
|
|
28
|
+
onSuccess: () => closeModal?.(),
|
|
29
|
+
} );
|
|
30
|
+
return (
|
|
31
|
+
<CreatePatternModalContents
|
|
32
|
+
onClose={ closeModal }
|
|
33
|
+
confirmLabel={ _x( 'Duplicate', 'action label' ) }
|
|
34
|
+
{ ...duplicatedProps }
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default duplicatePattern;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { __, sprintf, _x } from '@wordpress/i18n';
|
|
8
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { DataForm } from '@wordpress/dataviews';
|
|
11
|
+
import {
|
|
12
|
+
Button,
|
|
13
|
+
__experimentalHStack as HStack,
|
|
14
|
+
__experimentalVStack as VStack,
|
|
15
|
+
} from '@wordpress/components';
|
|
16
|
+
import type { Action } from '@wordpress/dataviews';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import { getItemTitle } from '../../dataviews/actions/utils';
|
|
22
|
+
import type { CoreDataError, BasePost } from '../types';
|
|
23
|
+
import { titleField } from '../fields';
|
|
24
|
+
|
|
25
|
+
const fields = [ titleField ];
|
|
26
|
+
const formDuplicateAction = {
|
|
27
|
+
fields: [ 'title' ],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const duplicatePost: Action< BasePost > = {
|
|
31
|
+
id: 'duplicate-post',
|
|
32
|
+
label: _x( 'Duplicate', 'action label' ),
|
|
33
|
+
isEligible( { status } ) {
|
|
34
|
+
return status !== 'trash';
|
|
35
|
+
},
|
|
36
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
37
|
+
const [ item, setItem ] = useState< BasePost >( {
|
|
38
|
+
...items[ 0 ],
|
|
39
|
+
title: sprintf(
|
|
40
|
+
/* translators: %s: Existing template title */
|
|
41
|
+
__( '%s (Copy)' ),
|
|
42
|
+
getItemTitle( items[ 0 ] )
|
|
43
|
+
),
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
const [ isCreatingPage, setIsCreatingPage ] = useState( false );
|
|
47
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
48
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
49
|
+
useDispatch( noticesStore );
|
|
50
|
+
|
|
51
|
+
async function createPage( event: React.FormEvent ) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
|
|
54
|
+
if ( isCreatingPage ) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const newItemOject = {
|
|
59
|
+
status: 'draft',
|
|
60
|
+
title: item.title,
|
|
61
|
+
slug: item.title || __( 'No title' ),
|
|
62
|
+
comment_status: item.comment_status,
|
|
63
|
+
content:
|
|
64
|
+
typeof item.content === 'string'
|
|
65
|
+
? item.content
|
|
66
|
+
: item.content.raw,
|
|
67
|
+
excerpt:
|
|
68
|
+
typeof item.excerpt === 'string'
|
|
69
|
+
? item.excerpt
|
|
70
|
+
: item.excerpt?.raw,
|
|
71
|
+
meta: item.meta,
|
|
72
|
+
parent: item.parent,
|
|
73
|
+
password: item.password,
|
|
74
|
+
template: item.template,
|
|
75
|
+
format: item.format,
|
|
76
|
+
featured_media: item.featured_media,
|
|
77
|
+
menu_order: item.menu_order,
|
|
78
|
+
ping_status: item.ping_status,
|
|
79
|
+
};
|
|
80
|
+
const assignablePropertiesPrefix = 'wp:action-assign-';
|
|
81
|
+
// Get all the properties that the current user is able to assign normally author, categories, tags,
|
|
82
|
+
// and custom taxonomies.
|
|
83
|
+
const assignableProperties = Object.keys( item?._links || {} )
|
|
84
|
+
.filter( ( property ) =>
|
|
85
|
+
property.startsWith( assignablePropertiesPrefix )
|
|
86
|
+
)
|
|
87
|
+
.map( ( property ) =>
|
|
88
|
+
property.slice( assignablePropertiesPrefix.length )
|
|
89
|
+
);
|
|
90
|
+
assignableProperties.forEach( ( property ) => {
|
|
91
|
+
if ( item.hasOwnProperty( property ) ) {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
newItemOject[ property ] = item[ property ];
|
|
94
|
+
}
|
|
95
|
+
} );
|
|
96
|
+
setIsCreatingPage( true );
|
|
97
|
+
try {
|
|
98
|
+
const newItem = await saveEntityRecord(
|
|
99
|
+
'postType',
|
|
100
|
+
item.type,
|
|
101
|
+
newItemOject,
|
|
102
|
+
{ throwOnError: true }
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
createSuccessNotice(
|
|
106
|
+
sprintf(
|
|
107
|
+
// translators: %s: Title of the created template e.g: "Category".
|
|
108
|
+
__( '"%s" successfully created.' ),
|
|
109
|
+
decodeEntities( newItem.title?.rendered || item.title )
|
|
110
|
+
),
|
|
111
|
+
{
|
|
112
|
+
id: 'duplicate-post-action',
|
|
113
|
+
type: 'snackbar',
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
if ( onActionPerformed ) {
|
|
118
|
+
onActionPerformed( [ newItem ] );
|
|
119
|
+
}
|
|
120
|
+
} catch ( error ) {
|
|
121
|
+
const typedError = error as CoreDataError;
|
|
122
|
+
const errorMessage =
|
|
123
|
+
typedError.message && typedError.code !== 'unknown_error'
|
|
124
|
+
? typedError.message
|
|
125
|
+
: __( 'An error occurred while duplicating the page.' );
|
|
126
|
+
|
|
127
|
+
createErrorNotice( errorMessage, {
|
|
128
|
+
type: 'snackbar',
|
|
129
|
+
} );
|
|
130
|
+
} finally {
|
|
131
|
+
setIsCreatingPage( false );
|
|
132
|
+
closeModal?.();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<form onSubmit={ createPage }>
|
|
138
|
+
<VStack spacing={ 3 }>
|
|
139
|
+
<DataForm
|
|
140
|
+
data={ item }
|
|
141
|
+
fields={ fields }
|
|
142
|
+
form={ formDuplicateAction }
|
|
143
|
+
onChange={ ( changes ) =>
|
|
144
|
+
setItem( ( prev ) => ( {
|
|
145
|
+
...prev,
|
|
146
|
+
...changes,
|
|
147
|
+
} ) )
|
|
148
|
+
}
|
|
149
|
+
/>
|
|
150
|
+
<HStack spacing={ 2 } justify="end">
|
|
151
|
+
<Button
|
|
152
|
+
variant="tertiary"
|
|
153
|
+
onClick={ closeModal }
|
|
154
|
+
__next40pxDefaultSize
|
|
155
|
+
>
|
|
156
|
+
{ __( 'Cancel' ) }
|
|
157
|
+
</Button>
|
|
158
|
+
<Button
|
|
159
|
+
variant="primary"
|
|
160
|
+
type="submit"
|
|
161
|
+
isBusy={ isCreatingPage }
|
|
162
|
+
aria-disabled={ isCreatingPage }
|
|
163
|
+
__next40pxDefaultSize
|
|
164
|
+
>
|
|
165
|
+
{ _x( 'Duplicate', 'action label' ) }
|
|
166
|
+
</Button>
|
|
167
|
+
</HStack>
|
|
168
|
+
</VStack>
|
|
169
|
+
</form>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export default duplicatePost;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { __, sprintf, _x } from '@wordpress/i18n';
|
|
6
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
+
import { useMemo } from '@wordpress/element';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { parse } from '@wordpress/blocks';
|
|
10
|
+
import type { Action } from '@wordpress/dataviews';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { TEMPLATE_PART_POST_TYPE } from '../../store/constants';
|
|
16
|
+
import { CreateTemplatePartModalContents } from '../../components/create-template-part-modal';
|
|
17
|
+
import { getItemTitle } from './utils';
|
|
18
|
+
import type { TemplatePart } from '../types';
|
|
19
|
+
|
|
20
|
+
const duplicateTemplatePart: Action< TemplatePart > = {
|
|
21
|
+
id: 'duplicate-template-part',
|
|
22
|
+
label: _x( 'Duplicate', 'action label' ),
|
|
23
|
+
isEligible: ( item ) => item.type === TEMPLATE_PART_POST_TYPE,
|
|
24
|
+
modalHeader: _x( 'Duplicate template part', 'action label' ),
|
|
25
|
+
RenderModal: ( { items, closeModal } ) => {
|
|
26
|
+
const [ item ] = items;
|
|
27
|
+
const blocks = useMemo( () => {
|
|
28
|
+
return (
|
|
29
|
+
item.blocks ??
|
|
30
|
+
parse(
|
|
31
|
+
typeof item.content === 'string'
|
|
32
|
+
? item.content
|
|
33
|
+
: item.content.raw,
|
|
34
|
+
{
|
|
35
|
+
__unstableSkipMigrationLogs: true,
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
}, [ item.content, item.blocks ] );
|
|
40
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
41
|
+
function onTemplatePartSuccess() {
|
|
42
|
+
createSuccessNotice(
|
|
43
|
+
sprintf(
|
|
44
|
+
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
45
|
+
__( '"%s" duplicated.' ),
|
|
46
|
+
getItemTitle( item )
|
|
47
|
+
),
|
|
48
|
+
{ type: 'snackbar', id: 'edit-site-patterns-success' }
|
|
49
|
+
);
|
|
50
|
+
closeModal?.();
|
|
51
|
+
}
|
|
52
|
+
return (
|
|
53
|
+
<CreateTemplatePartModalContents
|
|
54
|
+
blocks={ blocks }
|
|
55
|
+
defaultArea={ item.area }
|
|
56
|
+
defaultTitle={ sprintf(
|
|
57
|
+
/* translators: %s: Existing template part title */
|
|
58
|
+
__( '%s (Copy)' ),
|
|
59
|
+
getItemTitle( item )
|
|
60
|
+
) }
|
|
61
|
+
onCreate={ onTemplatePartSuccess }
|
|
62
|
+
onError={ closeModal }
|
|
63
|
+
confirmLabel={ _x( 'Duplicate', 'action label' ) }
|
|
64
|
+
closeModal={ closeModal }
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default duplicateTemplatePart;
|
|
@@ -9,6 +9,7 @@ import { downloadZip } from 'client-zip';
|
|
|
9
9
|
*/
|
|
10
10
|
import { downloadBlob } from '@wordpress/blob';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { download } from '@wordpress/icons';
|
|
12
13
|
import type { Action } from '@wordpress/dataviews';
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -36,6 +37,7 @@ function getJsonFromItem( item: Pattern ) {
|
|
|
36
37
|
const exportPattern: Action< Pattern > = {
|
|
37
38
|
id: 'export-pattern',
|
|
38
39
|
label: __( 'Export as JSON' ),
|
|
40
|
+
icon: download,
|
|
39
41
|
supportsBulk: true,
|
|
40
42
|
isEligible: ( item ) => item.type === 'wp_block',
|
|
41
43
|
callback: async ( items ) => {
|
|
@@ -5,6 +5,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { store as noticesStore } from '@wordpress/notices';
|
|
7
7
|
import type { Action } from '@wordpress/dataviews';
|
|
8
|
+
import { trash } from '@wordpress/icons';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -16,6 +17,7 @@ const permanentlyDeletePost: Action< PostWithPermissions > = {
|
|
|
16
17
|
id: 'permanently-delete',
|
|
17
18
|
label: __( 'Permanently delete' ),
|
|
18
19
|
supportsBulk: true,
|
|
20
|
+
icon: trash,
|
|
19
21
|
isEligible( item ) {
|
|
20
22
|
if ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {
|
|
21
23
|
return false;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { useState } from '@wordpress/element';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
TextControl,
|
|
13
|
+
__experimentalHStack as HStack,
|
|
14
|
+
__experimentalVStack as VStack,
|
|
15
|
+
} from '@wordpress/components';
|
|
16
|
+
import type { Action } from '@wordpress/dataviews';
|
|
17
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
import {
|
|
23
|
+
TEMPLATE_ORIGINS,
|
|
24
|
+
TEMPLATE_PART_POST_TYPE,
|
|
25
|
+
TEMPLATE_POST_TYPE,
|
|
26
|
+
} from '../../store/constants';
|
|
27
|
+
import { unlock } from '../../lock-unlock';
|
|
28
|
+
import {
|
|
29
|
+
getItemTitle,
|
|
30
|
+
isTemplateRemovable,
|
|
31
|
+
isTemplate,
|
|
32
|
+
isTemplatePart,
|
|
33
|
+
} from './utils';
|
|
34
|
+
import type { CoreDataError, PostWithPermissions } from '../types';
|
|
35
|
+
|
|
36
|
+
// Patterns.
|
|
37
|
+
const { PATTERN_TYPES } = unlock( patternsPrivateApis );
|
|
38
|
+
|
|
39
|
+
const renamePost: Action< PostWithPermissions > = {
|
|
40
|
+
id: 'rename-post',
|
|
41
|
+
label: __( 'Rename' ),
|
|
42
|
+
isEligible( post ) {
|
|
43
|
+
if ( post.status === 'trash' ) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// Templates, template parts and patterns have special checks for renaming.
|
|
47
|
+
if (
|
|
48
|
+
! [
|
|
49
|
+
TEMPLATE_POST_TYPE,
|
|
50
|
+
TEMPLATE_PART_POST_TYPE,
|
|
51
|
+
...Object.values( PATTERN_TYPES ),
|
|
52
|
+
].includes( post.type )
|
|
53
|
+
) {
|
|
54
|
+
return post.permissions?.update;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// In the case of templates, we can only rename custom templates.
|
|
58
|
+
if ( isTemplate( post ) ) {
|
|
59
|
+
return (
|
|
60
|
+
isTemplateRemovable( post ) &&
|
|
61
|
+
post.is_custom &&
|
|
62
|
+
post.permissions?.update
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if ( isTemplatePart( post ) ) {
|
|
67
|
+
return (
|
|
68
|
+
post.source === TEMPLATE_ORIGINS.custom &&
|
|
69
|
+
! post?.has_theme_file &&
|
|
70
|
+
post.permissions?.update
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return post.type === PATTERN_TYPES.user && post.permissions?.update;
|
|
75
|
+
},
|
|
76
|
+
RenderModal: ( { items, closeModal, onActionPerformed } ) => {
|
|
77
|
+
const [ item ] = items;
|
|
78
|
+
const [ title, setTitle ] = useState( () => getItemTitle( item ) );
|
|
79
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
80
|
+
useDispatch( coreStore );
|
|
81
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
82
|
+
useDispatch( noticesStore );
|
|
83
|
+
|
|
84
|
+
async function onRename( event: React.FormEvent ) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
try {
|
|
87
|
+
await editEntityRecord( 'postType', item.type, item.id, {
|
|
88
|
+
title,
|
|
89
|
+
} );
|
|
90
|
+
// Update state before saving rerenders the list.
|
|
91
|
+
setTitle( '' );
|
|
92
|
+
closeModal?.();
|
|
93
|
+
// Persist edited entity.
|
|
94
|
+
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
95
|
+
throwOnError: true,
|
|
96
|
+
} );
|
|
97
|
+
createSuccessNotice( __( 'Name updated' ), {
|
|
98
|
+
type: 'snackbar',
|
|
99
|
+
} );
|
|
100
|
+
onActionPerformed?.( items );
|
|
101
|
+
} catch ( error ) {
|
|
102
|
+
const typedError = error as CoreDataError;
|
|
103
|
+
const errorMessage =
|
|
104
|
+
typedError.message && typedError.code !== 'unknown_error'
|
|
105
|
+
? typedError.message
|
|
106
|
+
: __( 'An error occurred while updating the name' );
|
|
107
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<form onSubmit={ onRename }>
|
|
113
|
+
<VStack spacing="5">
|
|
114
|
+
<TextControl
|
|
115
|
+
__nextHasNoMarginBottom
|
|
116
|
+
__next40pxDefaultSize
|
|
117
|
+
label={ __( 'Name' ) }
|
|
118
|
+
value={ title }
|
|
119
|
+
onChange={ setTitle }
|
|
120
|
+
required
|
|
121
|
+
/>
|
|
122
|
+
<HStack justify="right">
|
|
123
|
+
<Button
|
|
124
|
+
__next40pxDefaultSize
|
|
125
|
+
variant="tertiary"
|
|
126
|
+
onClick={ () => {
|
|
127
|
+
closeModal?.();
|
|
128
|
+
} }
|
|
129
|
+
>
|
|
130
|
+
{ __( 'Cancel' ) }
|
|
131
|
+
</Button>
|
|
132
|
+
<Button
|
|
133
|
+
__next40pxDefaultSize
|
|
134
|
+
variant="primary"
|
|
135
|
+
type="submit"
|
|
136
|
+
>
|
|
137
|
+
{ __( 'Save' ) }
|
|
138
|
+
</Button>
|
|
139
|
+
</HStack>
|
|
140
|
+
</VStack>
|
|
141
|
+
</form>
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export default renamePost;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
+
import { useState } from '@wordpress/element';
|
|
9
|
+
import { DataForm, isItemValid } from '@wordpress/dataviews';
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
__experimentalHStack as HStack,
|
|
13
|
+
__experimentalVStack as VStack,
|
|
14
|
+
} from '@wordpress/components';
|
|
15
|
+
import type { Action, RenderModalProps } from '@wordpress/dataviews';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import type { CoreDataError, BasePost } from '../types';
|
|
21
|
+
import { orderField } from '../fields';
|
|
22
|
+
|
|
23
|
+
const fields = [ orderField ];
|
|
24
|
+
const formOrderAction = {
|
|
25
|
+
fields: [ 'menu_order' ],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function ReorderModal( {
|
|
29
|
+
items,
|
|
30
|
+
closeModal,
|
|
31
|
+
onActionPerformed,
|
|
32
|
+
}: RenderModalProps< BasePost > ) {
|
|
33
|
+
const [ item, setItem ] = useState( items[ 0 ] );
|
|
34
|
+
const orderInput = item.menu_order;
|
|
35
|
+
const { editEntityRecord, saveEditedEntityRecord } =
|
|
36
|
+
useDispatch( coreStore );
|
|
37
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
38
|
+
useDispatch( noticesStore );
|
|
39
|
+
|
|
40
|
+
async function onOrder( event: React.FormEvent ) {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
|
|
43
|
+
if ( ! isItemValid( item, fields, formOrderAction ) ) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
await editEntityRecord( 'postType', item.type, item.id, {
|
|
49
|
+
menu_order: orderInput,
|
|
50
|
+
} );
|
|
51
|
+
closeModal?.();
|
|
52
|
+
// Persist edited entity.
|
|
53
|
+
await saveEditedEntityRecord( 'postType', item.type, item.id, {
|
|
54
|
+
throwOnError: true,
|
|
55
|
+
} );
|
|
56
|
+
createSuccessNotice( __( 'Order updated.' ), {
|
|
57
|
+
type: 'snackbar',
|
|
58
|
+
} );
|
|
59
|
+
onActionPerformed?.( items );
|
|
60
|
+
} catch ( error ) {
|
|
61
|
+
const typedError = error as CoreDataError;
|
|
62
|
+
const errorMessage =
|
|
63
|
+
typedError.message && typedError.code !== 'unknown_error'
|
|
64
|
+
? typedError.message
|
|
65
|
+
: __( 'An error occurred while updating the order' );
|
|
66
|
+
createErrorNotice( errorMessage, {
|
|
67
|
+
type: 'snackbar',
|
|
68
|
+
} );
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const isSaveDisabled = ! isItemValid( item, fields, formOrderAction );
|
|
72
|
+
return (
|
|
73
|
+
<form onSubmit={ onOrder }>
|
|
74
|
+
<VStack spacing="5">
|
|
75
|
+
<div>
|
|
76
|
+
{ __(
|
|
77
|
+
'Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.'
|
|
78
|
+
) }
|
|
79
|
+
</div>
|
|
80
|
+
<DataForm
|
|
81
|
+
data={ item }
|
|
82
|
+
fields={ fields }
|
|
83
|
+
form={ formOrderAction }
|
|
84
|
+
onChange={ ( changes ) =>
|
|
85
|
+
setItem( {
|
|
86
|
+
...item,
|
|
87
|
+
...changes,
|
|
88
|
+
} )
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
91
|
+
<HStack justify="right">
|
|
92
|
+
<Button
|
|
93
|
+
__next40pxDefaultSize
|
|
94
|
+
variant="tertiary"
|
|
95
|
+
onClick={ () => {
|
|
96
|
+
closeModal?.();
|
|
97
|
+
} }
|
|
98
|
+
>
|
|
99
|
+
{ __( 'Cancel' ) }
|
|
100
|
+
</Button>
|
|
101
|
+
<Button
|
|
102
|
+
__next40pxDefaultSize
|
|
103
|
+
variant="primary"
|
|
104
|
+
type="submit"
|
|
105
|
+
accessibleWhenDisabled
|
|
106
|
+
disabled={ isSaveDisabled }
|
|
107
|
+
>
|
|
108
|
+
{ __( 'Save' ) }
|
|
109
|
+
</Button>
|
|
110
|
+
</HStack>
|
|
111
|
+
</VStack>
|
|
112
|
+
</form>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const reorderPage: Action< BasePost > = {
|
|
117
|
+
id: 'order-pages',
|
|
118
|
+
label: __( 'Order' ),
|
|
119
|
+
isEligible( { status } ) {
|
|
120
|
+
return status !== 'trash';
|
|
121
|
+
},
|
|
122
|
+
RenderModal: ReorderModal,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default reorderPage;
|
|
@@ -32,7 +32,8 @@ const resetPost: Action< Post > = {
|
|
|
32
32
|
return (
|
|
33
33
|
isTemplateOrTemplatePart( item ) &&
|
|
34
34
|
item?.source === TEMPLATE_ORIGINS.custom &&
|
|
35
|
-
item?.
|
|
35
|
+
( Boolean( item.type === 'wp_template' && item?.plugin ) ||
|
|
36
|
+
item?.has_theme_file )
|
|
36
37
|
);
|
|
37
38
|
},
|
|
38
39
|
icon: backup,
|
|
@@ -113,6 +114,8 @@ const resetPost: Action< Post > = {
|
|
|
113
114
|
</Text>
|
|
114
115
|
<HStack justify="right">
|
|
115
116
|
<Button
|
|
117
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
118
|
+
__next40pxDefaultSize={ false }
|
|
116
119
|
variant="tertiary"
|
|
117
120
|
onClick={ closeModal }
|
|
118
121
|
disabled={ isBusy }
|
|
@@ -121,6 +124,8 @@ const resetPost: Action< Post > = {
|
|
|
121
124
|
{ __( 'Cancel' ) }
|
|
122
125
|
</Button>
|
|
123
126
|
<Button
|
|
127
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
128
|
+
__next40pxDefaultSize={ false }
|
|
124
129
|
variant="primary"
|
|
125
130
|
onClick={ async () => {
|
|
126
131
|
setIsBusy( true );
|
|
@@ -67,6 +67,8 @@ const trashPost: Action< PostWithPermissions > = {
|
|
|
67
67
|
</Text>
|
|
68
68
|
<HStack justify="right">
|
|
69
69
|
<Button
|
|
70
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
71
|
+
__next40pxDefaultSize={ false }
|
|
70
72
|
variant="tertiary"
|
|
71
73
|
onClick={ closeModal }
|
|
72
74
|
disabled={ isBusy }
|
|
@@ -75,6 +77,8 @@ const trashPost: Action< PostWithPermissions > = {
|
|
|
75
77
|
{ __( 'Cancel' ) }
|
|
76
78
|
</Button>
|
|
77
79
|
<Button
|
|
80
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
81
|
+
__next40pxDefaultSize={ false }
|
|
78
82
|
variant="primary"
|
|
79
83
|
onClick={ async () => {
|
|
80
84
|
setIsBusy( true );
|
|
@@ -12,11 +12,19 @@ import {
|
|
|
12
12
|
TEMPLATE_POST_TYPE,
|
|
13
13
|
} from '../../store/constants';
|
|
14
14
|
|
|
15
|
-
import type { Post,
|
|
15
|
+
import type { Post, TemplatePart, Template } from '../types';
|
|
16
|
+
|
|
17
|
+
export function isTemplate( post: Post ): post is Template {
|
|
18
|
+
return post.type === TEMPLATE_POST_TYPE;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isTemplatePart( post: Post ): post is TemplatePart {
|
|
22
|
+
return post.type === TEMPLATE_PART_POST_TYPE;
|
|
23
|
+
}
|
|
16
24
|
|
|
17
25
|
export function isTemplateOrTemplatePart(
|
|
18
26
|
p: Post
|
|
19
|
-
): p is
|
|
27
|
+
): p is Template | TemplatePart {
|
|
20
28
|
return p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;
|
|
21
29
|
}
|
|
22
30
|
|
|
@@ -39,7 +47,7 @@ export function getItemTitle( item: Post ) {
|
|
|
39
47
|
* @param template The template entity to check.
|
|
40
48
|
* @return Whether the template is removable.
|
|
41
49
|
*/
|
|
42
|
-
export function isTemplateRemovable( template:
|
|
50
|
+
export function isTemplateRemovable( template: Template | TemplatePart ) {
|
|
43
51
|
if ( ! template ) {
|
|
44
52
|
return false;
|
|
45
53
|
}
|
|
@@ -49,6 +57,8 @@ export function isTemplateRemovable( template: TemplateOrTemplatePart ) {
|
|
|
49
57
|
return (
|
|
50
58
|
[ template.source, template.source ].includes(
|
|
51
59
|
TEMPLATE_ORIGINS.custom
|
|
52
|
-
) &&
|
|
60
|
+
) &&
|
|
61
|
+
! Boolean( template.type === 'wp_template' && template?.plugin ) &&
|
|
62
|
+
! template.has_theme_file
|
|
53
63
|
);
|
|
54
64
|
}
|