@wordpress/editor 13.32.0 → 13.34.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 +355 -20
- package/build/bindings/index.js.map +1 -1
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/bindings/post-meta.js +12 -30
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/autocompleters/index.js.map +1 -1
- package/build/components/autocompleters/user.js.map +1 -1
- package/build/components/autosave-monitor/index.js +24 -11
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/checklist.js.map +1 -1
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/block-removal-warnings/index.js.map +1 -1
- package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -1
- package/build/components/character-count/index.js +5 -0
- package/build/components/character-count/index.js.map +1 -1
- package/build/components/collapsible-block-toolbar/index.js +73 -0
- package/build/components/collapsible-block-toolbar/index.js.map +1 -0
- package/build/components/commands/index.js +19 -0
- package/build/components/commands/index.js.map +1 -1
- package/build/components/commands/index.native.js.map +1 -1
- package/build/components/deprecated.js.map +1 -1
- package/build/components/deprecated.native.js.map +1 -1
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/check.js +8 -0
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js +11 -0
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/document-tools/index.js +1 -8
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js +13 -2
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-canvas/index.js +2 -2
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/editor-help/add-blocks.native.js.map +1 -1
- package/build/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
- package/build/components/editor-help/help-section-title.native.js.map +1 -1
- package/build/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build/components/editor-help/icon-move-blocks.native.js.map +1 -1
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build/components/editor-help/move-blocks.native.js.map +1 -1
- package/build/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build/components/editor-help/view-sections.native.js.map +1 -1
- package/build/components/editor-history/redo.js +11 -0
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +11 -0
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-notices/index.js.map +1 -1
- package/build/components/editor-snackbars/index.js +6 -0
- package/build/components/editor-snackbars/index.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/index.native.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +31 -0
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +52 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +33 -1
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +1 -4
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +82 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +49 -0
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/index.js +126 -0
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +55 -0
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
- package/build/components/list-view-sidebar/index.js +1 -1
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/list-view-sidebar/list-view-outline.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/mode-switcher/index.js.map +1 -1
- package/build/components/more-menu/copy-content-menu-item.js +59 -0
- package/build/components/more-menu/copy-content-menu-item.js.map +1 -0
- package/build/components/more-menu/index.js +119 -0
- package/build/components/more-menu/index.js.map +1 -0
- package/build/components/more-menu/tools-more-menu-group.js +23 -0
- package/build/components/more-menu/tools-more-menu-group.js.map +1 -0
- package/build/components/more-menu/view-more-menu-group.js +24 -0
- package/build/components/more-menu/view-more-menu-group.js.map +1 -0
- package/build/components/offline-status/index.native.js.map +1 -1
- package/build/components/page-attributes/check.js +8 -0
- package/build/components/page-attributes/check.js.map +1 -1
- package/build/components/page-attributes/order.js +7 -0
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/panel.js +14 -8
- package/build/components/page-attributes/panel.js.map +1 -1
- package/build/components/page-attributes/parent.js +7 -0
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/pattern-overrides-panel/index.js.map +1 -1
- package/build/components/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/plugin-more-menu-item/index.js +78 -0
- package/build/components/plugin-more-menu-item/index.js.map +1 -0
- package/build/components/plugin-post-publish-panel/index.js +1 -1
- package/build/components/plugin-post-publish-panel/index.js.map +1 -1
- package/build/components/plugin-post-status-info/index.js +73 -0
- package/build/components/plugin-post-status-info/index.js.map +1 -0
- package/build/components/plugin-pre-publish-panel/index.js +1 -1
- package/build/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build/components/plugin-sidebar/index.js +108 -0
- package/build/components/plugin-sidebar/index.js.map +1 -0
- package/build/components/plugin-sidebar-more-menu-item/index.js +71 -0
- package/build/components/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build/components/post-actions/actions.js +316 -20
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +160 -0
- package/build/components/post-actions/index.js.map +1 -0
- package/build/components/post-author/check.js +9 -0
- package/build/components/post-author/check.js.map +1 -1
- package/build/components/post-author/combobox.js.map +1 -1
- package/build/components/post-author/constants.js.map +1 -1
- package/build/components/post-author/hook.js.map +1 -1
- package/build/components/post-author/index.js +6 -0
- package/build/components/post-author/index.js.map +1 -1
- package/build/components/post-author/panel.js +5 -0
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-author/select.js.map +1 -1
- package/build/components/post-card-panel/index.js +14 -15
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-content-information/index.js +72 -0
- package/build/components/post-content-information/index.js.map +1 -0
- package/build/components/post-discussion/panel.js +9 -7
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/check.js +7 -18
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/index.js +52 -12
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +118 -7
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-excerpt/plugin.js +2 -2
- package/build/components/post-excerpt/plugin.js.map +1 -1
- package/build/components/post-featured-image/check.js.map +1 -1
- package/build/components/post-featured-image/index.js +1 -1
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js.map +1 -1
- package/build/components/post-format/check.js.map +1 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-edited-panel/index.js +33 -0
- package/build/components/post-last-edited-panel/index.js.map +1 -0
- package/build/components/post-last-revision/check.js.map +1 -1
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-last-revision/panel.js.map +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-panel-row/index.js.map +1 -1
- package/build/components/post-pending-status/check.js.map +1 -1
- package/build/components/post-pending-status/index.js.map +1 -1
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +31 -31
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +51 -43
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-button/post-publish-button-or-toggle.js +100 -0
- package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-publish-panel/prepublish.js.map +1 -1
- package/build/components/post-saved-state/index.js +10 -6
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/check.js.map +1 -1
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-schedule/panel.js +9 -1
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-slug/check.js.map +1 -1
- package/build/components/post-slug/index.js +43 -68
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-status/index.js +239 -0
- package/build/components/post-status/index.js.map +1 -0
- package/build/components/post-sticky/check.js.map +1 -1
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +6 -1
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-taxonomies/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-taxonomies/panel.js.map +1 -1
- package/build/components/post-template/block-theme.js +8 -4
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +0 -1
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/create-new-template.js.map +1 -1
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/post-template/reset-default-template.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +2 -5
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-text-editor/index.js.map +1 -1
- package/build/components/post-title/constants.js.map +1 -1
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-title/use-post-title-focus.js.map +1 -1
- package/build/components/post-title/use-post-title.js.map +1 -1
- package/build/components/post-trash/check.js +23 -25
- package/build/components/post-trash/check.js.map +1 -1
- package/build/components/post-trash/index.js +2 -1
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/post-url/check.js.map +1 -1
- package/build/components/post-url/index.js +45 -19
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/post-url/label.js.map +1 -1
- package/build/components/post-url/panel.js +15 -8
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/post-view-link/index.js.map +1 -1
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/post-visibility/index.js +2 -1
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
- package/build/components/preferences-modal/enable-publish-sidebar.js +34 -0
- package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
- package/build/components/preferences-modal/index.js +26 -18
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +3 -1
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +23 -16
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/index.js +4 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +6 -1
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/navigation-block-editing-mode.js.map +1 -1
- package/build/components/provider/use-auto-switch-editor-sidebars.js +52 -0
- package/build/components/provider/use-auto-switch-editor-sidebars.js.map +1 -0
- package/build/components/provider/use-block-editor-settings.js +64 -43
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build/components/provider/with-registry-provider.js +1 -0
- package/build/components/provider/with-registry-provider.js.map +1 -1
- package/build/components/save-publish-panels/index.js +89 -0
- package/build/components/save-publish-panels/index.js.map +1 -0
- package/build/components/start-page-options/index.js +143 -0
- package/build/components/start-page-options/index.js.map +1 -0
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/table-of-contents/panel.js.map +1 -1
- package/build/components/template-areas/index.js.map +1 -1
- package/build/components/template-validation-notice/index.js +23 -29
- package/build/components/template-validation-notice/index.js.map +1 -1
- package/build/components/theme-support-check/index.js +10 -16
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/components/time-to-read/index.js.map +1 -1
- package/build/components/unsaved-changes-warning/index.js.map +1 -1
- package/build/components/word-count/index.js.map +1 -1
- package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build/hooks/default-autocompleters.js.map +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/pattern-overrides.js +22 -10
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/hooks/use-select-nearest-editable-block.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +38 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/actions.native.js.map +1 -1
- package/build/store/constants.js +8 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/local-autosave.js.map +1 -1
- package/build/store/private-actions.js +177 -4
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +1 -7
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +8 -11
- package/build/store/selectors.js.map +1 -1
- package/build/store/selectors.native.js.map +1 -1
- package/build/store/utils/get-filtered-template-parts.js.map +1 -1
- package/build/store/utils/is-template-revertable.js +28 -0
- package/build/store/utils/is-template-revertable.js.map +1 -0
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build/utils/get-template-part-icon.js.map +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/index.native.js.map +1 -1
- package/build/utils/media-upload/index.js.map +1 -1
- package/build/utils/media-upload/index.native.js.map +1 -1
- package/build/utils/terms.js.map +1 -1
- package/build/utils/url.js.map +1 -1
- package/build-module/bindings/index.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/bindings/post-meta.js +14 -31
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/autocompleters/index.js.map +1 -1
- package/build-module/components/autocompleters/user.js.map +1 -1
- package/build-module/components/autosave-monitor/index.js +24 -12
- package/build-module/components/autosave-monitor/index.js.map +1 -1
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/checklist.js.map +1 -1
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/block-removal-warnings/index.js.map +1 -1
- package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -1
- package/build-module/components/character-count/index.js +6 -0
- package/build-module/components/character-count/index.js.map +1 -1
- package/build-module/components/collapsible-block-toolbar/index.js +65 -0
- package/build-module/components/collapsible-block-toolbar/index.js.map +1 -0
- package/build-module/components/commands/index.js +20 -1
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/commands/index.native.js.map +1 -1
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/deprecated.native.js.map +1 -1
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/check.js +9 -0
- package/build-module/components/document-outline/check.js.map +1 -1
- package/build-module/components/document-outline/index.js +11 -0
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/document-tools/index.js +2 -9
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +13 -2
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +2 -2
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
- package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -1
- package/build-module/components/editor-help/help-section-title.native.js.map +1 -1
- package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build-module/components/editor-help/icon-move-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build-module/components/editor-help/view-sections.native.js.map +1 -1
- package/build-module/components/editor-history/redo.js +11 -0
- package/build-module/components/editor-history/redo.js.map +1 -1
- package/build-module/components/editor-history/undo.js +11 -0
- package/build-module/components/editor-history/undo.js.map +1 -1
- package/build-module/components/editor-notices/index.js.map +1 -1
- package/build-module/components/editor-snackbars/index.js +6 -0
- package/build-module/components/editor-snackbars/index.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/index.native.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +32 -0
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +53 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +4 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +2 -5
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +75 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js +118 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +48 -0
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
- package/build-module/components/list-view-sidebar/index.js +1 -1
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/mode-switcher/index.js.map +1 -1
- package/build-module/components/more-menu/copy-content-menu-item.js +52 -0
- package/build-module/components/more-menu/copy-content-menu-item.js.map +1 -0
- package/build-module/components/more-menu/index.js +111 -0
- package/build-module/components/more-menu/index.js.map +1 -0
- package/build-module/components/more-menu/tools-more-menu-group.js +16 -0
- package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -0
- package/build-module/components/more-menu/view-more-menu-group.js +17 -0
- package/build-module/components/more-menu/view-more-menu-group.js.map +1 -0
- package/build-module/components/offline-status/index.native.js.map +1 -1
- package/build-module/components/page-attributes/check.js +9 -0
- package/build-module/components/page-attributes/check.js.map +1 -1
- package/build-module/components/page-attributes/order.js +7 -0
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/page-attributes/panel.js +13 -6
- package/build-module/components/page-attributes/panel.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +7 -0
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/pattern-overrides-panel/index.js.map +1 -1
- package/build-module/components/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/plugin-more-menu-item/index.js +73 -0
- package/build-module/components/plugin-more-menu-item/index.js.map +1 -0
- package/build-module/components/plugin-post-publish-panel/index.js +1 -1
- package/build-module/components/plugin-post-publish-panel/index.js.map +1 -1
- package/build-module/components/plugin-post-status-info/index.js +66 -0
- package/build-module/components/plugin-post-status-info/index.js.map +1 -0
- package/build-module/components/plugin-pre-publish-panel/index.js +1 -1
- package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -1
- package/build-module/components/plugin-sidebar/index.js +102 -0
- package/build-module/components/plugin-sidebar/index.js.map +1 -0
- package/build-module/components/plugin-sidebar-more-menu-item/index.js +65 -0
- package/build-module/components/plugin-sidebar-more-menu-item/index.js.map +1 -0
- package/build-module/components/post-actions/actions.js +317 -19
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +153 -0
- package/build-module/components/post-actions/index.js.map +1 -0
- package/build-module/components/post-author/check.js +10 -0
- package/build-module/components/post-author/check.js.map +1 -1
- package/build-module/components/post-author/combobox.js.map +1 -1
- package/build-module/components/post-author/constants.js.map +1 -1
- package/build-module/components/post-author/hook.js.map +1 -1
- package/build-module/components/post-author/index.js +6 -0
- package/build-module/components/post-author/index.js.map +1 -1
- package/build-module/components/post-author/panel.js +6 -0
- package/build-module/components/post-author/panel.js.map +1 -1
- package/build-module/components/post-author/select.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +16 -17
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-content-information/index.js +66 -0
- package/build-module/components/post-content-information/index.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +8 -6
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/check.js +8 -18
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +52 -11
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +118 -8
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-excerpt/plugin.js +2 -2
- package/build-module/components/post-excerpt/plugin.js.map +1 -1
- package/build-module/components/post-featured-image/check.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +1 -1
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js.map +1 -1
- package/build-module/components/post-format/check.js.map +1 -1
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-last-edited-panel/index.js +26 -0
- package/build-module/components/post-last-edited-panel/index.js.map +1 -0
- package/build-module/components/post-last-revision/check.js.map +1 -1
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-last-revision/panel.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-panel-row/index.js.map +1 -1
- package/build-module/components/post-pending-status/check.js.map +1 -1
- package/build-module/components/post-pending-status/index.js.map +1 -1
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +31 -31
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +51 -42
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +91 -0
- package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
- package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +10 -6
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/check.js.map +1 -1
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +9 -1
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-slug/check.js.map +1 -1
- package/build-module/components/post-slug/index.js +44 -68
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-status/index.js +231 -0
- package/build-module/components/post-status/index.js.map +1 -0
- package/build-module/components/post-sticky/check.js.map +1 -1
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +7 -1
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/check.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-taxonomies/panel.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +9 -5
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +0 -1
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/create-new-template.js.map +1 -1
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/post-template/reset-default-template.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +3 -6
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-text-editor/index.js.map +1 -1
- package/build-module/components/post-title/constants.js.map +1 -1
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-title/use-post-title-focus.js.map +1 -1
- package/build-module/components/post-title/use-post-title.js.map +1 -1
- package/build-module/components/post-trash/check.js +24 -26
- package/build-module/components/post-trash/check.js.map +1 -1
- package/build-module/components/post-trash/index.js +2 -1
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/post-url/check.js.map +1 -1
- package/build-module/components/post-url/index.js +47 -21
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/post-url/label.js.map +1 -1
- package/build-module/components/post-url/panel.js +15 -8
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/post-view-link/index.js.map +1 -1
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/post-visibility/index.js +2 -1
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/post-visibility/utils.js.map +1 -1
- package/build-module/components/preferences-modal/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
- package/build-module/components/preferences-modal/enable-publish-sidebar.js +27 -0
- package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +26 -18
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +3 -1
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +24 -17
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/index.js +5 -3
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -1
- package/build-module/components/provider/use-auto-switch-editor-sidebars.js +46 -0
- package/build-module/components/provider/use-auto-switch-editor-sidebars.js.map +1 -0
- package/build-module/components/provider/use-block-editor-settings.js +66 -45
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build-module/components/provider/with-registry-provider.js +1 -0
- package/build-module/components/provider/with-registry-provider.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +80 -0
- package/build-module/components/save-publish-panels/index.js.map +1 -0
- package/build-module/components/start-page-options/index.js +136 -0
- package/build-module/components/start-page-options/index.js.map +1 -0
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/table-of-contents/panel.js.map +1 -1
- package/build-module/components/template-areas/index.js.map +1 -1
- package/build-module/components/template-validation-notice/index.js +25 -31
- package/build-module/components/template-validation-notice/index.js.map +1 -1
- package/build-module/components/theme-support-check/index.js +11 -16
- package/build-module/components/theme-support-check/index.js.map +1 -1
- package/build-module/components/time-to-read/index.js.map +1 -1
- package/build-module/components/unsaved-changes-warning/index.js.map +1 -1
- package/build-module/components/word-count/index.js.map +1 -1
- package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
- package/build-module/hooks/default-autocompleters.js.map +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +22 -10
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/hooks/use-select-nearest-editable-block.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +36 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/actions.native.js.map +1 -1
- package/build-module/store/constants.js +7 -0
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/local-autosave.js.map +1 -1
- package/build-module/store/private-actions.js +174 -4
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +4 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/selectors.native.js.map +1 -1
- package/build-module/store/utils/get-filtered-template-parts.js.map +1 -1
- package/build-module/store/utils/is-template-revertable.js +22 -0
- package/build-module/store/utils/is-template-revertable.js.map +1 -0
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-module/utils/get-template-part-icon.js.map +1 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/index.native.js.map +1 -1
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-module/utils/media-upload/index.native.js.map +1 -1
- package/build-module/utils/terms.js.map +1 -1
- package/build-module/utils/url.js.map +1 -1
- package/build-style/style-rtl.css +703 -53
- package/build-style/style.css +703 -53
- package/package.json +35 -35
- package/src/bindings/post-meta.js +11 -27
- package/src/components/autosave-monitor/index.js +23 -11
- package/src/components/character-count/index.js +5 -0
- package/src/components/collapsible-block-toolbar/index.js +77 -0
- package/src/components/collapsible-block-toolbar/style.scss +80 -0
- package/src/components/commands/index.js +20 -1
- package/src/components/document-outline/check.js +8 -0
- package/src/components/document-outline/index.js +10 -0
- package/src/components/document-tools/index.js +16 -19
- package/src/components/editor-canvas/edit-template-blocks-notification.js +16 -2
- package/src/components/editor-canvas/index.js +4 -4
- package/src/components/editor-history/redo.js +10 -0
- package/src/components/editor-history/undo.js +10 -0
- package/src/components/editor-snackbars/index.js +5 -0
- package/src/components/entities-saved-states/style.scss +7 -0
- package/src/components/error-boundary/style.native.scss +1 -1
- package/src/components/global-keyboard-shortcuts/index.js +32 -0
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +61 -0
- package/src/components/index.js +4 -0
- package/src/components/inserter-sidebar/index.js +2 -5
- package/src/components/keyboard-shortcut-help-modal/config.js +62 -0
- package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +43 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +160 -0
- package/src/components/keyboard-shortcut-help-modal/shortcut.js +67 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +61 -0
- package/src/components/list-view-sidebar/index.js +1 -1
- package/src/components/list-view-sidebar/style.scss +2 -2
- package/src/components/more-menu/copy-content-menu-item.js +51 -0
- package/src/components/more-menu/index.js +158 -0
- package/src/components/more-menu/tools-more-menu-group.js +11 -0
- package/src/components/more-menu/view-more-menu-group.js +13 -0
- package/src/components/page-attributes/check.js +8 -0
- package/src/components/page-attributes/order.js +6 -0
- package/src/components/page-attributes/panel.js +21 -17
- package/src/components/page-attributes/parent.js +6 -0
- package/src/components/plugin-more-menu-item/index.js +73 -0
- package/src/components/plugin-post-publish-panel/index.js +1 -1
- package/src/components/plugin-post-status-info/index.js +63 -0
- package/src/components/plugin-pre-publish-panel/index.js +1 -1
- package/src/components/plugin-sidebar/index.js +98 -0
- package/src/components/plugin-sidebar-more-menu-item/index.js +64 -0
- package/src/components/post-actions/actions.js +413 -18
- package/src/components/post-actions/index.js +190 -0
- package/src/components/post-actions/style.scss +3 -0
- package/src/components/post-author/check.js +9 -0
- package/src/components/post-author/index.js +5 -0
- package/src/components/post-author/panel.js +5 -0
- package/src/components/post-card-panel/index.js +28 -23
- package/src/components/post-card-panel/style.scss +2 -6
- package/src/components/post-content-information/index.js +83 -0
- package/src/components/post-content-information/style.scss +6 -0
- package/src/components/post-discussion/panel.js +24 -20
- package/src/components/post-excerpt/check.js +8 -18
- package/src/components/post-excerpt/index.js +66 -15
- package/src/components/post-excerpt/panel.js +196 -19
- package/src/components/post-excerpt/plugin.js +2 -2
- package/src/components/post-excerpt/style.scss +24 -0
- package/src/components/post-featured-image/index.js +1 -1
- package/src/components/post-featured-image/style.scss +2 -8
- package/src/components/post-last-edited-panel/index.js +35 -0
- package/src/components/post-last-edited-panel/style.scss +6 -0
- package/src/components/post-panel-row/style.scss +3 -3
- package/src/components/post-publish-button/index.js +23 -36
- package/src/components/post-publish-button/label.js +54 -39
- package/src/components/post-publish-button/post-publish-button-or-toggle.js +102 -0
- package/src/components/post-publish-button/test/index.js +15 -26
- package/src/components/post-publish-button/test/label.js +44 -21
- package/src/components/post-publish-button/test/post-publish-button-or-toggle.js +63 -0
- package/src/components/post-publish-panel/style.scss +43 -0
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +225 -75
- package/src/components/post-saved-state/index.js +13 -6
- package/src/components/post-saved-state/test/index.js +4 -0
- package/src/components/post-schedule/panel.js +23 -1
- package/src/components/post-schedule/style.scss +2 -4
- package/src/components/post-slug/index.js +50 -68
- package/src/components/post-slug/test/index.js +29 -6
- package/src/components/post-status/index.js +318 -0
- package/src/components/post-status/style.scss +74 -0
- package/src/components/post-switch-to-draft-button/index.js +5 -0
- package/src/components/post-template/block-theme.js +33 -24
- package/src/components/post-template/classic-theme.js +0 -1
- package/src/components/post-template/swap-template-button.js +3 -6
- package/src/components/post-text-editor/style.scss +1 -1
- package/src/components/post-title/style.scss +1 -1
- package/src/components/post-trash/check.js +19 -19
- package/src/components/post-trash/index.js +1 -0
- package/src/components/post-url/index.js +132 -101
- package/src/components/post-url/panel.js +21 -8
- package/src/components/post-url/style.scss +8 -6
- package/src/components/post-visibility/index.js +1 -0
- package/src/components/preferences-modal/enable-publish-sidebar.js +28 -0
- package/src/components/preferences-modal/index.js +40 -22
- package/src/components/preview-dropdown/index.js +3 -1
- package/src/components/provider/disable-non-page-content-blocks.js +23 -21
- package/src/components/provider/index.js +17 -8
- package/src/components/provider/use-auto-switch-editor-sidebars.js +49 -0
- package/src/components/provider/use-block-editor-settings.js +59 -33
- package/src/components/provider/with-registry-provider.js +1 -0
- package/src/components/save-publish-panels/index.js +96 -0
- package/src/components/save-publish-panels/style.scss +36 -0
- package/src/components/start-page-options/index.js +140 -0
- package/src/components/start-page-options/style.scss +26 -0
- package/src/components/template-validation-notice/index.js +48 -50
- package/src/components/theme-support-check/index.js +9 -16
- package/src/components/theme-support-check/test/index.js +44 -43
- package/src/hooks/pattern-overrides.js +25 -14
- package/src/private-apis.js +33 -2
- package/src/store/constants.js +7 -0
- package/src/store/private-actions.js +269 -4
- package/src/store/private-selectors.js +1 -6
- package/src/store/selectors.js +4 -7
- package/src/store/utils/is-template-revertable.js +23 -0
- package/src/style.scss +10 -2
- package/src/components/post-publish-button/style.scss +0 -8
- package/src/components/provider/test/disable-non-page-content-blocks.js +0 -111
- package/src/components/template-validation-notice/style.scss +0 -9
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import {
|
|
8
|
+
privateApis as componentsPrivateApis,
|
|
9
|
+
Button,
|
|
10
|
+
Modal,
|
|
11
|
+
} from '@wordpress/components';
|
|
12
|
+
import { moreVertical } from '@wordpress/icons';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
18
|
+
import { usePostActions } from './actions';
|
|
19
|
+
import { store as editorStore } from '../../store';
|
|
20
|
+
import {
|
|
21
|
+
TEMPLATE_POST_TYPE,
|
|
22
|
+
TEMPLATE_PART_POST_TYPE,
|
|
23
|
+
PATTERN_POST_TYPE,
|
|
24
|
+
} from '../../store/constants';
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
DropdownMenuV2: DropdownMenu,
|
|
28
|
+
DropdownMenuGroupV2: DropdownMenuGroup,
|
|
29
|
+
DropdownMenuItemV2: DropdownMenuItem,
|
|
30
|
+
DropdownMenuItemLabelV2: DropdownMenuItemLabel,
|
|
31
|
+
kebabCase,
|
|
32
|
+
} = unlock( componentsPrivateApis );
|
|
33
|
+
|
|
34
|
+
let POST_ACTIONS_WHILE_EDITING = [
|
|
35
|
+
'view-post',
|
|
36
|
+
'view-post-revisions',
|
|
37
|
+
'rename-post',
|
|
38
|
+
'move-to-trash',
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
42
|
+
POST_ACTIONS_WHILE_EDITING = [
|
|
43
|
+
'view-post',
|
|
44
|
+
'view-post-revisions',
|
|
45
|
+
'duplicate-post',
|
|
46
|
+
'rename-post',
|
|
47
|
+
'move-to-trash',
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default function PostActions( { onActionPerformed, buttonProps } ) {
|
|
52
|
+
const [ isActionsMenuOpen, setIsActionsMenuOpen ] = useState( false );
|
|
53
|
+
const { postType, item } = useSelect( ( select ) => {
|
|
54
|
+
const { getCurrentPostType, getCurrentPost } = select( editorStore );
|
|
55
|
+
return {
|
|
56
|
+
postType: getCurrentPostType(),
|
|
57
|
+
item: getCurrentPost(),
|
|
58
|
+
};
|
|
59
|
+
} );
|
|
60
|
+
const allActions = usePostActions(
|
|
61
|
+
onActionPerformed,
|
|
62
|
+
POST_ACTIONS_WHILE_EDITING
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const actions = useMemo( () => {
|
|
66
|
+
return allActions.filter( ( action ) => {
|
|
67
|
+
return ! action.isEligible || action.isEligible( item );
|
|
68
|
+
} );
|
|
69
|
+
}, [ allActions, item ] );
|
|
70
|
+
|
|
71
|
+
if (
|
|
72
|
+
[
|
|
73
|
+
TEMPLATE_POST_TYPE,
|
|
74
|
+
TEMPLATE_PART_POST_TYPE,
|
|
75
|
+
PATTERN_POST_TYPE,
|
|
76
|
+
].includes( postType )
|
|
77
|
+
) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return (
|
|
81
|
+
<DropdownMenu
|
|
82
|
+
open={ isActionsMenuOpen }
|
|
83
|
+
trigger={
|
|
84
|
+
<Button
|
|
85
|
+
size="small"
|
|
86
|
+
icon={ moreVertical }
|
|
87
|
+
label={ __( 'Actions' ) }
|
|
88
|
+
disabled={ ! actions.length }
|
|
89
|
+
className="editor-all-actions-button"
|
|
90
|
+
onClick={ () =>
|
|
91
|
+
setIsActionsMenuOpen( ! isActionsMenuOpen )
|
|
92
|
+
}
|
|
93
|
+
{ ...buttonProps }
|
|
94
|
+
/>
|
|
95
|
+
}
|
|
96
|
+
onOpenChange={ setIsActionsMenuOpen }
|
|
97
|
+
placement="bottom-end"
|
|
98
|
+
>
|
|
99
|
+
<ActionsDropdownMenuGroup
|
|
100
|
+
actions={ actions }
|
|
101
|
+
item={ item }
|
|
102
|
+
onClose={ () => {
|
|
103
|
+
setIsActionsMenuOpen( false );
|
|
104
|
+
} }
|
|
105
|
+
/>
|
|
106
|
+
</DropdownMenu>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// From now on all the functions on this file are copied as from the dataviews packages,
|
|
111
|
+
// The editor packages should not be using the dataviews packages directly,
|
|
112
|
+
// and the dataviews package should not be using the editor packages directly,
|
|
113
|
+
// so duplicating the code here seems like the least bad option.
|
|
114
|
+
|
|
115
|
+
// Copied as is from packages/dataviews/src/item-actions.js
|
|
116
|
+
function DropdownMenuItemTrigger( { action, onClick } ) {
|
|
117
|
+
return (
|
|
118
|
+
<DropdownMenuItem
|
|
119
|
+
onClick={ onClick }
|
|
120
|
+
hideOnClick={ ! action.RenderModal }
|
|
121
|
+
>
|
|
122
|
+
<DropdownMenuItemLabel>{ action.label }</DropdownMenuItemLabel>
|
|
123
|
+
</DropdownMenuItem>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Copied as is from packages/dataviews/src/item-actions.js
|
|
128
|
+
// With an added onClose prop.
|
|
129
|
+
function ActionWithModal( { action, item, ActionTrigger, onClose } ) {
|
|
130
|
+
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
131
|
+
const actionTriggerProps = {
|
|
132
|
+
action,
|
|
133
|
+
onClick: () => setIsModalOpen( true ),
|
|
134
|
+
};
|
|
135
|
+
const { RenderModal, hideModalHeader } = action;
|
|
136
|
+
return (
|
|
137
|
+
<>
|
|
138
|
+
<ActionTrigger { ...actionTriggerProps } />
|
|
139
|
+
{ isModalOpen && (
|
|
140
|
+
<Modal
|
|
141
|
+
title={ action.modalHeader || action.label }
|
|
142
|
+
__experimentalHideHeader={ !! hideModalHeader }
|
|
143
|
+
onRequestClose={ () => {
|
|
144
|
+
setIsModalOpen( false );
|
|
145
|
+
} }
|
|
146
|
+
overlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(
|
|
147
|
+
action.id
|
|
148
|
+
) }` }
|
|
149
|
+
>
|
|
150
|
+
<RenderModal
|
|
151
|
+
items={ [ item ] }
|
|
152
|
+
closeModal={ () => {
|
|
153
|
+
setIsModalOpen( false );
|
|
154
|
+
onClose();
|
|
155
|
+
} }
|
|
156
|
+
/>
|
|
157
|
+
</Modal>
|
|
158
|
+
) }
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Copied as is from packages/dataviews/src/item-actions.js
|
|
164
|
+
// With an added onClose prop.
|
|
165
|
+
function ActionsDropdownMenuGroup( { actions, item, onClose } ) {
|
|
166
|
+
return (
|
|
167
|
+
<DropdownMenuGroup>
|
|
168
|
+
{ actions.map( ( action ) => {
|
|
169
|
+
if ( action.RenderModal ) {
|
|
170
|
+
return (
|
|
171
|
+
<ActionWithModal
|
|
172
|
+
key={ action.id }
|
|
173
|
+
action={ action }
|
|
174
|
+
item={ item }
|
|
175
|
+
ActionTrigger={ DropdownMenuItemTrigger }
|
|
176
|
+
onClose={ onClose }
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return (
|
|
181
|
+
<DropdownMenuItemTrigger
|
|
182
|
+
key={ action.id }
|
|
183
|
+
action={ action }
|
|
184
|
+
onClick={ () => action.callback( [ item ] ) }
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
} ) }
|
|
188
|
+
</DropdownMenuGroup>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
@@ -11,6 +11,15 @@ import PostTypeSupportCheck from '../post-type-support-check';
|
|
|
11
11
|
import { store as editorStore } from '../../store';
|
|
12
12
|
import { AUTHORS_QUERY } from './constants';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Wrapper component that renders its children only if the post type supports the author.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object} props The component props.
|
|
18
|
+
* @param {Element} props.children Children to be rendered.
|
|
19
|
+
*
|
|
20
|
+
* @return {Component|null} The component to be rendered. Return `null` if the post type doesn't
|
|
21
|
+
* supports the author or if there are no authors available.
|
|
22
|
+
*/
|
|
14
23
|
export default function PostAuthorCheck( { children } ) {
|
|
15
24
|
const { hasAssignAuthorAction, hasAuthors } = useSelect( ( select ) => {
|
|
16
25
|
const post = select( editorStore ).getCurrentPost();
|
|
@@ -13,6 +13,11 @@ import { AUTHORS_QUERY } from './constants';
|
|
|
13
13
|
|
|
14
14
|
const minimumUsersForCombobox = 25;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Renders the component for selecting the post author.
|
|
18
|
+
*
|
|
19
|
+
* @return {Component} The component to be rendered.
|
|
20
|
+
*/
|
|
16
21
|
function PostAuthor() {
|
|
17
22
|
const showCombobox = useSelect( ( select ) => {
|
|
18
23
|
const authors = select( coreStore ).getUsers( AUTHORS_QUERY );
|
|
@@ -5,6 +5,11 @@ import PostAuthorCheck from './check';
|
|
|
5
5
|
import PostAuthorForm from './index';
|
|
6
6
|
import PostPanelRow from '../post-panel-row';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Renders the Post Author Panel component.
|
|
10
|
+
*
|
|
11
|
+
* @return {Component} The component to be rendered.
|
|
12
|
+
*/
|
|
8
13
|
export function PostAuthor() {
|
|
9
14
|
return (
|
|
10
15
|
<PostAuthorCheck>
|
|
@@ -15,20 +15,25 @@ import {
|
|
|
15
15
|
} from '@wordpress/components';
|
|
16
16
|
import { store as coreStore } from '@wordpress/core-data';
|
|
17
17
|
import { useSelect } from '@wordpress/data';
|
|
18
|
-
import { __
|
|
19
|
-
import { humanTimeDiff } from '@wordpress/date';
|
|
18
|
+
import { __ } from '@wordpress/i18n';
|
|
20
19
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Internal dependencies
|
|
24
23
|
*/
|
|
25
24
|
import { store as editorStore } from '../../store';
|
|
26
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
TEMPLATE_POST_TYPE,
|
|
27
|
+
TEMPLATE_PART_POST_TYPE,
|
|
28
|
+
PATTERN_POST_TYPE,
|
|
29
|
+
} from '../../store/constants';
|
|
30
|
+
import { PrivatePostExcerptPanel } from '../post-excerpt/panel';
|
|
31
|
+
import PostLastEditedPanel from '../post-last-edited-panel';
|
|
27
32
|
import { unlock } from '../../lock-unlock';
|
|
28
33
|
import TemplateAreas from '../template-areas';
|
|
29
34
|
|
|
30
35
|
export default function PostCardPanel( { className, actions } ) {
|
|
31
|
-
const {
|
|
36
|
+
const { title, showPostContentPanels, icon, postType } = useSelect(
|
|
32
37
|
( select ) => {
|
|
33
38
|
const {
|
|
34
39
|
getEditedPostAttribute,
|
|
@@ -40,33 +45,35 @@ export default function PostCardPanel( { className, actions } ) {
|
|
|
40
45
|
const _type = getCurrentPostType();
|
|
41
46
|
const _id = getCurrentPostId();
|
|
42
47
|
const _record = getEditedEntityRecord( 'postType', _type, _id );
|
|
43
|
-
const _templateInfo =
|
|
48
|
+
const _templateInfo =
|
|
49
|
+
[ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(
|
|
50
|
+
_type
|
|
51
|
+
) && __experimentalGetTemplateInfo( _record );
|
|
44
52
|
return {
|
|
45
53
|
title:
|
|
46
54
|
_templateInfo?.title || getEditedPostAttribute( 'title' ),
|
|
47
|
-
modified: getEditedPostAttribute( 'modified' ),
|
|
48
55
|
id: _id,
|
|
49
56
|
postType: _type,
|
|
50
|
-
templateInfo: _templateInfo,
|
|
51
57
|
icon: unlock( select( editorStore ) ).getPostIcon( _type, {
|
|
52
58
|
area: _record?.area,
|
|
53
59
|
} ),
|
|
60
|
+
// Post excerpt panel and Last Edited info are rendered in different place depending on the post type.
|
|
61
|
+
// So we cannot make this check inside the PostExcerpt or PostLastEditedPanel component based on the current edited entity.
|
|
62
|
+
showPostContentPanels: [
|
|
63
|
+
TEMPLATE_POST_TYPE,
|
|
64
|
+
TEMPLATE_PART_POST_TYPE,
|
|
65
|
+
PATTERN_POST_TYPE,
|
|
66
|
+
].includes( _type ),
|
|
54
67
|
};
|
|
55
|
-
}
|
|
68
|
+
},
|
|
69
|
+
[]
|
|
56
70
|
);
|
|
57
|
-
const description = templateInfo?.description;
|
|
58
|
-
const lastEditedText =
|
|
59
|
-
modified &&
|
|
60
|
-
sprintf(
|
|
61
|
-
// translators: %s: Human-readable time difference, e.g. "2 days ago".
|
|
62
|
-
__( 'Last edited %s.' ),
|
|
63
|
-
humanTimeDiff( modified )
|
|
64
|
-
);
|
|
65
|
-
|
|
66
71
|
return (
|
|
67
72
|
<PanelBody>
|
|
68
73
|
<div
|
|
69
|
-
className={ classnames( 'editor-post-card-panel', className
|
|
74
|
+
className={ classnames( 'editor-post-card-panel', className, {
|
|
75
|
+
'has-description': showPostContentPanels,
|
|
76
|
+
} ) }
|
|
70
77
|
>
|
|
71
78
|
<HStack
|
|
72
79
|
spacing={ 2 }
|
|
@@ -89,15 +96,13 @@ export default function PostCardPanel( { className, actions } ) {
|
|
|
89
96
|
{ actions }
|
|
90
97
|
</HStack>
|
|
91
98
|
<VStack className="editor-post-card-panel__content">
|
|
92
|
-
{
|
|
99
|
+
{ showPostContentPanels && (
|
|
93
100
|
<VStack
|
|
94
101
|
className="editor-post-card-panel__description"
|
|
95
102
|
spacing={ 2 }
|
|
96
103
|
>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<Text>{ lastEditedText }</Text>
|
|
100
|
-
) }
|
|
104
|
+
<PrivatePostExcerptPanel />
|
|
105
|
+
<PostLastEditedPanel />
|
|
101
106
|
</VStack>
|
|
102
107
|
) }
|
|
103
108
|
{ postType === TEMPLATE_POST_TYPE && <TemplateAreas /> }
|
|
@@ -20,13 +20,9 @@
|
|
|
20
20
|
&__header {
|
|
21
21
|
display: flex;
|
|
22
22
|
justify-content: space-between;
|
|
23
|
-
margin: 0 0 $grid-unit-10;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
&
|
|
27
|
-
|
|
28
|
-
& .components-text {
|
|
29
|
-
color: inherit;
|
|
30
|
-
}
|
|
25
|
+
&.has-description &__header {
|
|
26
|
+
margin-bottom: $grid-unit-10;
|
|
31
27
|
}
|
|
32
28
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalText as Text } from '@wordpress/components';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { __, _x, _n, sprintf } from '@wordpress/i18n';
|
|
7
|
+
import { count as wordCount } from '@wordpress/wordcount';
|
|
8
|
+
import { useMemo } from '@wordpress/element';
|
|
9
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { store as editorStore } from '../../store';
|
|
15
|
+
import {
|
|
16
|
+
TEMPLATE_POST_TYPE,
|
|
17
|
+
TEMPLATE_PART_POST_TYPE,
|
|
18
|
+
} from '../../store/constants';
|
|
19
|
+
|
|
20
|
+
// Taken from packages/editor/src/components/time-to-read/index.js.
|
|
21
|
+
const AVERAGE_READING_RATE = 189;
|
|
22
|
+
|
|
23
|
+
// This component renders the wordcount and reading time for the post.
|
|
24
|
+
export default function PostContentInformation() {
|
|
25
|
+
const { postContent } = useSelect( ( select ) => {
|
|
26
|
+
const { getEditedPostAttribute, getCurrentPostType, getCurrentPostId } =
|
|
27
|
+
select( editorStore );
|
|
28
|
+
const { getEntityRecord } = select( coreStore );
|
|
29
|
+
const siteSettings = getEntityRecord( 'root', 'site' );
|
|
30
|
+
const postType = getCurrentPostType();
|
|
31
|
+
const _id = getCurrentPostId();
|
|
32
|
+
const isPostsPage = +_id === siteSettings?.page_for_posts;
|
|
33
|
+
const showPostContentInfo =
|
|
34
|
+
! isPostsPage &&
|
|
35
|
+
! [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(
|
|
36
|
+
postType
|
|
37
|
+
);
|
|
38
|
+
return {
|
|
39
|
+
postContent:
|
|
40
|
+
showPostContentInfo && getEditedPostAttribute( 'content' ),
|
|
41
|
+
};
|
|
42
|
+
}, [] );
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* translators: If your word count is based on single characters (e.g. East Asian characters),
|
|
46
|
+
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
|
47
|
+
* Do not translate into your own language.
|
|
48
|
+
*/
|
|
49
|
+
const wordCountType = _x( 'words', 'Word count type. Do not translate!' );
|
|
50
|
+
const wordsCounted = useMemo(
|
|
51
|
+
() => ( postContent ? wordCount( postContent, wordCountType ) : 0 ),
|
|
52
|
+
[ postContent, wordCountType ]
|
|
53
|
+
);
|
|
54
|
+
if ( ! wordsCounted ) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );
|
|
58
|
+
const wordsCountText = sprintf(
|
|
59
|
+
// translators: %s: the number of words in the post.
|
|
60
|
+
_n( '%s word', '%s words', wordsCounted ),
|
|
61
|
+
wordsCounted.toLocaleString()
|
|
62
|
+
);
|
|
63
|
+
const minutesText =
|
|
64
|
+
readingTime <= 1
|
|
65
|
+
? __( '1 minute' )
|
|
66
|
+
: sprintf(
|
|
67
|
+
// translators: %s: the number of minutes to read the post.
|
|
68
|
+
_n( '%s minute', '%s minutes', readingTime ),
|
|
69
|
+
readingTime.toLocaleString()
|
|
70
|
+
);
|
|
71
|
+
return (
|
|
72
|
+
<div className="editor-post-content-information">
|
|
73
|
+
<Text>
|
|
74
|
+
{ sprintf(
|
|
75
|
+
/* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
|
|
76
|
+
__( '%1$s, %2$s read time.' ),
|
|
77
|
+
wordsCountText,
|
|
78
|
+
minutesText
|
|
79
|
+
) }
|
|
80
|
+
</Text>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -15,7 +15,7 @@ import PostPingbacks from '../post-pingbacks';
|
|
|
15
15
|
|
|
16
16
|
const PANEL_NAME = 'discussion-panel';
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function DiscussionPanel() {
|
|
19
19
|
const { isEnabled, isOpened } = useSelect( ( select ) => {
|
|
20
20
|
const { isEditorPanelEnabled, isEditorPanelOpened } =
|
|
21
21
|
select( editorStore );
|
|
@@ -31,27 +31,31 @@ function PostDiscussionPanel() {
|
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
return (
|
|
35
|
+
<PanelBody
|
|
36
|
+
title={ __( 'Discussion' ) }
|
|
37
|
+
opened={ isOpened }
|
|
38
|
+
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
|
|
39
|
+
>
|
|
40
|
+
<PostTypeSupportCheck supportKeys="comments">
|
|
41
|
+
<PanelRow>
|
|
42
|
+
<PostComments />
|
|
43
|
+
</PanelRow>
|
|
44
|
+
</PostTypeSupportCheck>
|
|
45
|
+
|
|
46
|
+
<PostTypeSupportCheck supportKeys="trackbacks">
|
|
47
|
+
<PanelRow>
|
|
48
|
+
<PostPingbacks />
|
|
49
|
+
</PanelRow>
|
|
50
|
+
</PostTypeSupportCheck>
|
|
51
|
+
</PanelBody>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default function PostDiscussionPanel() {
|
|
34
56
|
return (
|
|
35
57
|
<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>
|
|
36
|
-
<
|
|
37
|
-
title={ __( 'Discussion' ) }
|
|
38
|
-
opened={ isOpened }
|
|
39
|
-
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
|
|
40
|
-
>
|
|
41
|
-
<PostTypeSupportCheck supportKeys="comments">
|
|
42
|
-
<PanelRow>
|
|
43
|
-
<PostComments />
|
|
44
|
-
</PanelRow>
|
|
45
|
-
</PostTypeSupportCheck>
|
|
46
|
-
|
|
47
|
-
<PostTypeSupportCheck supportKeys="trackbacks">
|
|
48
|
-
<PanelRow>
|
|
49
|
-
<PostPingbacks />
|
|
50
|
-
</PanelRow>
|
|
51
|
-
</PostTypeSupportCheck>
|
|
52
|
-
</PanelBody>
|
|
58
|
+
<DiscussionPanel />
|
|
53
59
|
</PostTypeSupportCheck>
|
|
54
60
|
);
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
export default PostDiscussionPanel;
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
4
|
import PostTypeSupportCheck from '../post-type-support-check';
|
|
10
|
-
import { store as editorStore } from '../../store';
|
|
11
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Component for checking if the post type supports the excerpt field.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} props Props.
|
|
10
|
+
* @param {Element} props.children Children to be rendered.
|
|
11
|
+
*
|
|
12
|
+
* @return {Component} The component to be rendered.
|
|
13
|
+
*/
|
|
12
14
|
function PostExcerptCheck( { children } ) {
|
|
13
|
-
const postType = useSelect( ( select ) => {
|
|
14
|
-
const { getEditedPostAttribute } = select( editorStore );
|
|
15
|
-
return getEditedPostAttribute( 'type' );
|
|
16
|
-
}, [] );
|
|
17
|
-
|
|
18
|
-
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
19
|
-
// support the excerpt field throught the "description" field rather than "excerpt" which means
|
|
20
|
-
// the default ExcerptPanel won't work for these.
|
|
21
|
-
if ( [ 'wp_template', 'wp_template_part' ].includes( postType ) ) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
15
|
return (
|
|
26
16
|
<PostTypeSupportCheck supportKeys="excerpt">
|
|
27
17
|
{ children }
|
|
@@ -4,37 +4,88 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { ExternalLink, TextareaControl } from '@wordpress/components';
|
|
6
6
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
+
import { useState } from '@wordpress/element';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
10
11
|
*/
|
|
11
12
|
import { store as editorStore } from '../../store';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Renders an editable textarea for the post excerpt.
|
|
16
|
+
* Templates, template parts and patterns use the `excerpt` field as a description semantically.
|
|
17
|
+
* Additionally templates and template parts override the `excerpt` field as `description` in
|
|
18
|
+
* REST API. So this component handles proper labeling and updating the edited entity.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props - Component props.
|
|
21
|
+
* @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
|
|
22
|
+
* @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
|
|
23
|
+
*/
|
|
24
|
+
export default function PostExcerpt( {
|
|
25
|
+
hideLabelFromVision = false,
|
|
26
|
+
updateOnBlur = false,
|
|
27
|
+
} ) {
|
|
28
|
+
const { excerpt, shouldUseDescriptionLabel, usedAttribute } = useSelect(
|
|
29
|
+
( select ) => {
|
|
30
|
+
const { getCurrentPostType, getEditedPostAttribute } =
|
|
31
|
+
select( editorStore );
|
|
32
|
+
const postType = getCurrentPostType();
|
|
33
|
+
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
34
|
+
// support the excerpt field throught the "description" field rather than "excerpt".
|
|
35
|
+
const _usedAttribute = [
|
|
36
|
+
'wp_template',
|
|
37
|
+
'wp_template_part',
|
|
38
|
+
].includes( postType )
|
|
39
|
+
? 'description'
|
|
40
|
+
: 'excerpt';
|
|
41
|
+
return {
|
|
42
|
+
excerpt: getEditedPostAttribute( _usedAttribute ),
|
|
43
|
+
// There are special cases where we want to label the excerpt as a description.
|
|
44
|
+
shouldUseDescriptionLabel: [
|
|
45
|
+
'wp_template',
|
|
46
|
+
'wp_template_part',
|
|
47
|
+
'wp_block',
|
|
48
|
+
].includes( postType ),
|
|
49
|
+
usedAttribute: _usedAttribute,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
16
52
|
[]
|
|
17
53
|
);
|
|
18
54
|
const { editPost } = useDispatch( editorStore );
|
|
55
|
+
const [ localExcerpt, setLocalExcerpt ] = useState( excerpt );
|
|
56
|
+
const updatePost = ( value ) => {
|
|
57
|
+
editPost( { [ usedAttribute ]: value } );
|
|
58
|
+
};
|
|
59
|
+
const label = shouldUseDescriptionLabel
|
|
60
|
+
? __( 'Write a description (optional)' )
|
|
61
|
+
: __( 'Write an excerpt (optional)' );
|
|
19
62
|
|
|
20
63
|
return (
|
|
21
64
|
<div className="editor-post-excerpt">
|
|
22
65
|
<TextareaControl
|
|
23
66
|
__nextHasNoMarginBottom
|
|
24
|
-
label={
|
|
67
|
+
label={ label }
|
|
68
|
+
hideLabelFromVision={ hideLabelFromVision }
|
|
25
69
|
className="editor-post-excerpt__textarea"
|
|
26
|
-
onChange={
|
|
27
|
-
|
|
70
|
+
onChange={ updateOnBlur ? setLocalExcerpt : updatePost }
|
|
71
|
+
onBlur={
|
|
72
|
+
updateOnBlur ? () => updatePost( localExcerpt ) : undefined
|
|
73
|
+
}
|
|
74
|
+
value={ updateOnBlur ? localExcerpt : excerpt }
|
|
75
|
+
help={
|
|
76
|
+
! shouldUseDescriptionLabel ? (
|
|
77
|
+
<ExternalLink
|
|
78
|
+
href={ __(
|
|
79
|
+
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'
|
|
80
|
+
) }
|
|
81
|
+
>
|
|
82
|
+
{ __( 'Learn more about manual excerpts' ) }
|
|
83
|
+
</ExternalLink>
|
|
84
|
+
) : (
|
|
85
|
+
__( 'Write a description' )
|
|
86
|
+
)
|
|
87
|
+
}
|
|
28
88
|
/>
|
|
29
|
-
<ExternalLink
|
|
30
|
-
href={ __(
|
|
31
|
-
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'
|
|
32
|
-
) }
|
|
33
|
-
>
|
|
34
|
-
{ __( 'Learn more about manual excerpts' ) }
|
|
35
|
-
</ExternalLink>
|
|
36
89
|
</div>
|
|
37
90
|
);
|
|
38
91
|
}
|
|
39
|
-
|
|
40
|
-
export default PostExcerpt;
|