@wordpress/editor 13.27.2 → 13.28.1
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 +2 -0
- package/build/bindings/index.js +2 -0
- package/build/bindings/index.js.map +1 -1
- package/build/bindings/pattern-overrides.js +17 -0
- package/build/bindings/pattern-overrides.js.map +1 -0
- package/build/bindings/post-meta.js +3 -5
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/autocompleters/user.js +1 -2
- package/build/components/autocompleters/user.js.map +1 -1
- package/build/components/autosave-monitor/index.js +1 -2
- package/build/components/autosave-monitor/index.js.map +1 -1
- package/build/components/block-manager/category.js +1 -2
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/checklist.js +1 -2
- package/build/components/block-manager/checklist.js.map +1 -1
- package/build/components/block-manager/index.js +1 -2
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/deprecated.js +52 -104
- package/build/components/deprecated.js.map +1 -1
- package/build/components/document-bar/index.js +5 -6
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/check.js +1 -2
- package/build/components/document-outline/check.js.map +1 -1
- package/build/components/document-outline/index.js +1 -2
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js +1 -2
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/document-tools/index.js +1 -2
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js +11 -18
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-canvas/index.js +28 -16
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/editor-help/add-blocks.native.js +1 -2
- package/build/components/editor-help/add-blocks.native.js.map +1 -1
- package/build/components/editor-help/customize-blocks.native.js +1 -2
- package/build/components/editor-help/customize-blocks.native.js.map +1 -1
- package/build/components/editor-help/help-detail-navigation-screen.native.js +1 -2
- 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 +1 -2
- package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
- package/build/components/editor-help/help-section-title.native.js +1 -2
- package/build/components/editor-help/help-section-title.native.js.map +1 -1
- package/build/components/editor-help/help-topic-row.native.js +1 -2
- package/build/components/editor-help/help-topic-row.native.js.map +1 -1
- package/build/components/editor-help/icon-move-blocks.native.js +1 -2
- package/build/components/editor-help/icon-move-blocks.native.js.map +1 -1
- package/build/components/editor-help/index.native.js +1 -2
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/editor-help/intro-to-blocks.native.js +1 -2
- package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
- package/build/components/editor-help/move-blocks.native.js +1 -2
- package/build/components/editor-help/move-blocks.native.js.map +1 -1
- package/build/components/editor-help/remove-blocks.native.js +1 -2
- package/build/components/editor-help/remove-blocks.native.js.map +1 -1
- package/build/components/editor-history/redo.js +1 -2
- package/build/components/editor-history/redo.js.map +1 -1
- package/build/components/editor-history/undo.js +1 -2
- package/build/components/editor-history/undo.js.map +1 -1
- package/build/components/editor-notices/index.js +1 -2
- package/build/components/editor-notices/index.js.map +1 -1
- package/build/components/editor-snackbars/index.js +3 -1
- package/build/components/editor-snackbars/index.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +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 +7 -7
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +4 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/error-boundary/index.js +1 -2
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -2
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +4 -6
- package/build/components/index.js.map +1 -1
- package/build/components/list-view-sidebar/index.js +43 -36
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +1 -2
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/media-categories/index.js +1 -2
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/offline-status/index.native.js +1 -2
- package/build/components/offline-status/index.native.js.map +1 -1
- package/build/components/page-attributes/check.js +1 -2
- package/build/components/page-attributes/check.js.map +1 -1
- package/build/components/page-attributes/panel.js +1 -2
- package/build/components/page-attributes/panel.js.map +1 -1
- package/build/components/page-attributes/parent.js +1 -2
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-author/combobox.js +6 -60
- package/build/components/post-author/combobox.js.map +1 -1
- package/build/components/post-author/constants.js +7 -5
- package/build/components/post-author/constants.js.map +1 -1
- package/build/components/post-author/hook.js +72 -0
- package/build/components/post-author/hook.js.map +1 -0
- package/build/components/post-author/index.js +1 -2
- package/build/components/post-author/index.js.map +1 -1
- package/build/components/post-author/panel.js +1 -2
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-author/select.js +6 -24
- package/build/components/post-author/select.js.map +1 -1
- package/build/components/post-comments/index.js +1 -2
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-discussion/panel.js +1 -2
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/check.js +1 -2
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/index.js +1 -2
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-excerpt/plugin.js +1 -2
- package/build/components/post-excerpt/plugin.js.map +1 -1
- package/build/components/post-featured-image/check.js +1 -2
- package/build/components/post-featured-image/check.js.map +1 -1
- package/build/components/post-featured-image/index.js +1 -2
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +1 -2
- package/build/components/post-featured-image/panel.js.map +1 -1
- package/build/components/post-format/check.js +1 -2
- package/build/components/post-format/check.js.map +1 -1
- package/build/components/post-format/index.js +1 -2
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-last-revision/check.js +1 -2
- package/build/components/post-last-revision/check.js.map +1 -1
- package/build/components/post-last-revision/index.js +6 -5
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-last-revision/panel.js +1 -2
- package/build/components/post-last-revision/panel.js.map +1 -1
- package/build/components/post-panel-row/index.js +1 -2
- package/build/components/post-panel-row/index.js.map +1 -1
- package/build/components/post-pending-status/check.js +1 -2
- package/build/components/post-pending-status/check.js.map +1 -1
- package/build/components/post-pending-status/index.js +1 -2
- package/build/components/post-pending-status/index.js.map +1 -1
- package/build/components/post-pingbacks/index.js +1 -2
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +1 -2
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +1 -2
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js +1 -2
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +1 -2
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +22 -26
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js +1 -2
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-publish-panel/prepublish.js +1 -2
- package/build/components/post-publish-panel/prepublish.js.map +1 -1
- package/build/components/post-schedule/index.js +0 -1
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-schedule/label.js +1 -1
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-schedule/panel.js +1 -0
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-slug/index.js +1 -2
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +1 -0
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-sync-status/index.js +1 -1
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-taxonomies/check.js +8 -15
- package/build/components/post-taxonomies/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +1 -2
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +14 -15
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-taxonomies/panel.js +1 -2
- package/build/components/post-taxonomies/panel.js.map +1 -1
- package/build/components/post-template/block-theme.js +12 -11
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +10 -11
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +4 -5
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/panel.js +5 -1
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/post-title/constants.js +2 -4
- package/build/components/post-title/constants.js.map +1 -1
- package/build/components/post-title/index.js +2 -3
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -2
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-title/post-title-raw.js +1 -2
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-trash/check.js +1 -2
- package/build/components/post-trash/check.js.map +1 -1
- package/build/components/post-trash/index.js +1 -0
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-type-support-check/index.js +1 -2
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/post-url/panel.js +1 -0
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/post-visibility/utils.js +1 -2
- package/build/components/post-visibility/utils.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js +1 -2
- package/build/components/preferences-modal/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/enable-plugin-document-setting-panel.js +1 -2
- package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
- package/build/components/preferences-modal/index.js +0 -1
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/provider/constants.js +1 -2
- package/build/components/provider/constants.js.map +1 -1
- package/build/components/provider/index.js +12 -6
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +4 -6
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +2 -3
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.native.js +1 -2
- package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build/components/provider/with-registry-provider.js +1 -2
- package/build/components/provider/with-registry-provider.js.map +1 -1
- package/build/components/table-of-contents/index.js +1 -2
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/table-of-contents/panel.js +1 -2
- package/build/components/table-of-contents/panel.js.map +1 -1
- package/build/components/template-validation-notice/index.js +1 -2
- package/build/components/template-validation-notice/index.js.map +1 -1
- package/build/components/theme-support-check/index.js +1 -2
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/hooks/pattern-partial-syncing.js +9 -2
- package/build/hooks/pattern-partial-syncing.js.map +1 -1
- package/build/private-apis.js +1 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +32 -63
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +7 -14
- package/build/store/constants.js.map +1 -1
- package/build/store/defaults.js +1 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +4 -6
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +1 -2
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +2 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +2 -4
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +72 -144
- package/build/store/selectors.js.map +1 -1
- package/build/store/selectors.native.js +1 -2
- package/build/store/selectors.native.js.map +1 -1
- package/build-module/bindings/index.js +2 -0
- package/build-module/bindings/index.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +11 -0
- package/build-module/bindings/pattern-overrides.js.map +1 -0
- package/build-module/bindings/post-meta.js +3 -4
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/document-bar/index.js +5 -6
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +11 -18
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +27 -14
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/editor-snackbars/index.js +4 -1
- package/build-module/components/editor-snackbars/index.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +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 +8 -8
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +6 -3
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/list-view-sidebar/index.js +44 -37
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/post-author/combobox.js +8 -61
- package/build-module/components/post-author/combobox.js.map +1 -1
- package/build-module/components/post-author/constants.js +5 -2
- package/build-module/components/post-author/constants.js.map +1 -1
- package/build-module/components/post-author/hook.js +65 -0
- package/build-module/components/post-author/hook.js.map +1 -0
- package/build-module/components/post-author/select.js +7 -24
- package/build-module/components/post-author/select.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +6 -4
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +24 -27
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-schedule/index.js +0 -1
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +1 -1
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +1 -0
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +1 -0
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +1 -1
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/check.js +9 -14
- package/build-module/components/post-taxonomies/check.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +15 -15
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +12 -11
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +9 -9
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +4 -5
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/panel.js +5 -1
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/post-title/index.js +1 -2
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-trash/index.js +1 -0
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-url/panel.js +1 -0
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +0 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/provider/index.js +10 -2
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +1 -1
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/table-of-contents/panel.js +0 -1
- package/build-module/components/table-of-contents/panel.js.map +1 -1
- package/build-module/hooks/pattern-partial-syncing.js +9 -2
- package/build-module/hooks/pattern-partial-syncing.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +28 -22
- package/build-style/style.css +28 -22
- package/package.json +32 -32
- package/src/bindings/index.js +2 -0
- package/src/bindings/pattern-overrides.js +11 -0
- package/src/bindings/post-meta.js +2 -3
- package/src/components/document-bar/index.js +22 -17
- package/src/components/editor-canvas/edit-template-blocks-notification.js +31 -30
- package/src/components/editor-canvas/index.js +39 -10
- package/src/components/editor-snackbars/index.js +6 -3
- package/src/components/entities-saved-states/entity-record-item.js +1 -4
- package/src/components/entities-saved-states/entity-type-list.js +8 -8
- package/src/components/entities-saved-states/index.js +17 -4
- package/src/components/entities-saved-states/style.scss +5 -0
- package/src/components/list-view-sidebar/index.js +60 -47
- package/src/components/list-view-sidebar/style.scss +20 -20
- package/src/components/post-author/combobox.js +5 -61
- package/src/components/post-author/constants.js +6 -2
- package/src/components/post-author/hook.js +63 -0
- package/src/components/post-author/select.js +5 -25
- package/src/components/post-last-revision/index.js +6 -6
- package/src/components/post-last-revision/style.scss +3 -6
- package/src/components/post-panel-row/style.scss +3 -3
- package/src/components/post-publish-panel/maybe-tags-panel.js +27 -37
- package/src/components/post-publish-panel/style.scss +3 -1
- package/src/components/post-schedule/label.js +1 -1
- package/src/components/post-schedule/panel.js +1 -0
- package/src/components/post-schedule/test/label.js +19 -7
- package/src/components/post-switch-to-draft-button/index.js +1 -0
- package/src/components/post-sync-status/index.js +8 -2
- package/src/components/post-taxonomies/check.js +11 -15
- package/src/components/post-taxonomies/index.js +15 -22
- package/src/components/post-taxonomies/test/index.js +37 -51
- package/src/components/post-template/block-theme.js +29 -22
- package/src/components/post-template/classic-theme.js +10 -13
- package/src/components/post-template/create-new-template-modal.js +7 -9
- package/src/components/post-template/panel.js +5 -1
- package/src/components/post-trash/index.js +1 -0
- package/src/components/post-url/panel.js +1 -0
- package/src/components/provider/index.js +22 -2
- package/src/components/provider/use-block-editor-settings.js +1 -1
- package/src/hooks/pattern-partial-syncing.js +23 -4
- package/src/store/actions.js +1 -1
- package/src/store/reducer.js +1 -1
|
@@ -35,10 +35,22 @@ const {
|
|
|
35
35
|
useLayoutClasses,
|
|
36
36
|
useLayoutStyles,
|
|
37
37
|
ExperimentalBlockCanvas: BlockCanvas,
|
|
38
|
+
useFlashEditableBlocks,
|
|
38
39
|
} = unlock( blockEditorPrivateApis );
|
|
39
40
|
|
|
40
41
|
const noop = () => {};
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* These post types have a special editor where they don't allow you to fill the title
|
|
45
|
+
* and they don't apply the layout styles.
|
|
46
|
+
*/
|
|
47
|
+
const DESIGN_POST_TYPES = [
|
|
48
|
+
'wp_block',
|
|
49
|
+
'wp_template',
|
|
50
|
+
'wp_navigation',
|
|
51
|
+
'wp_template_part',
|
|
52
|
+
];
|
|
53
|
+
|
|
42
54
|
/**
|
|
43
55
|
* Given an array of nested blocks, find the first Post Content
|
|
44
56
|
* block inside it, recursing through any nesting levels,
|
|
@@ -92,6 +104,7 @@ function EditorCanvas( {
|
|
|
92
104
|
wrapperUniqueId,
|
|
93
105
|
deviceType,
|
|
94
106
|
showEditorPadding,
|
|
107
|
+
isDesignPostType,
|
|
95
108
|
} = useSelect( ( select ) => {
|
|
96
109
|
const {
|
|
97
110
|
getCurrentPostId,
|
|
@@ -109,7 +122,7 @@ function EditorCanvas( {
|
|
|
109
122
|
|
|
110
123
|
if ( postTypeSlug === 'wp_block' ) {
|
|
111
124
|
_wrapperBlockName = 'core/block';
|
|
112
|
-
} else if (
|
|
125
|
+
} else if ( _renderingMode === 'post-only' ) {
|
|
113
126
|
_wrapperBlockName = 'core/post-content';
|
|
114
127
|
}
|
|
115
128
|
|
|
@@ -129,6 +142,7 @@ function EditorCanvas( {
|
|
|
129
142
|
return {
|
|
130
143
|
renderingMode: _renderingMode,
|
|
131
144
|
postContentAttributes: editorSettings.postContentAttributes,
|
|
145
|
+
isDesignPostType: DESIGN_POST_TYPES.includes( postTypeSlug ),
|
|
132
146
|
// Post template fetch returns a 404 on classic themes, which
|
|
133
147
|
// messes with e2e tests, so check it's a block theme first.
|
|
134
148
|
editedPostTemplate:
|
|
@@ -138,7 +152,8 @@ function EditorCanvas( {
|
|
|
138
152
|
wrapperBlockName: _wrapperBlockName,
|
|
139
153
|
wrapperUniqueId: getCurrentPostId(),
|
|
140
154
|
deviceType: getDeviceType(),
|
|
141
|
-
showEditorPadding:
|
|
155
|
+
showEditorPadding:
|
|
156
|
+
!! editorSettings.onNavigateToPreviousEntityRecord,
|
|
142
157
|
};
|
|
143
158
|
}, [] );
|
|
144
159
|
const { isCleanNewPost } = useSelect( editorStore );
|
|
@@ -162,7 +177,7 @@ function EditorCanvas( {
|
|
|
162
177
|
// fallbackLayout is used if there is no Post Content,
|
|
163
178
|
// and for Post Title.
|
|
164
179
|
const fallbackLayout = useMemo( () => {
|
|
165
|
-
if ( renderingMode !== 'post-only' ) {
|
|
180
|
+
if ( renderingMode !== 'post-only' || isDesignPostType ) {
|
|
166
181
|
return { type: 'default' };
|
|
167
182
|
}
|
|
168
183
|
|
|
@@ -173,7 +188,12 @@ function EditorCanvas( {
|
|
|
173
188
|
}
|
|
174
189
|
// Set default layout for classic themes so all alignments are supported.
|
|
175
190
|
return { type: 'default' };
|
|
176
|
-
}, [
|
|
191
|
+
}, [
|
|
192
|
+
renderingMode,
|
|
193
|
+
themeSupportsLayout,
|
|
194
|
+
globalLayoutSettings,
|
|
195
|
+
isDesignPostType,
|
|
196
|
+
] );
|
|
177
197
|
|
|
178
198
|
const newestPostContentAttributes = useMemo( () => {
|
|
179
199
|
if (
|
|
@@ -290,6 +310,9 @@ function EditorCanvas( {
|
|
|
290
310
|
const contentRef = useMergeRefs( [
|
|
291
311
|
localRef,
|
|
292
312
|
renderingMode === 'post-only' ? typewriterRef : noop,
|
|
313
|
+
useFlashEditableBlocks( {
|
|
314
|
+
isEnabled: renderingMode === 'template-locked',
|
|
315
|
+
} ),
|
|
293
316
|
] );
|
|
294
317
|
|
|
295
318
|
return (
|
|
@@ -313,7 +336,8 @@ function EditorCanvas( {
|
|
|
313
336
|
>
|
|
314
337
|
{ themeSupportsLayout &&
|
|
315
338
|
! themeHasDisabledLayoutStyles &&
|
|
316
|
-
renderingMode === 'post-only' &&
|
|
339
|
+
renderingMode === 'post-only' &&
|
|
340
|
+
! isDesignPostType && (
|
|
317
341
|
<>
|
|
318
342
|
<LayoutStyle
|
|
319
343
|
selector=".editor-editor-canvas__post-title-wrapper"
|
|
@@ -332,7 +356,7 @@ function EditorCanvas( {
|
|
|
332
356
|
) }
|
|
333
357
|
</>
|
|
334
358
|
) }
|
|
335
|
-
{ renderingMode === 'post-only' && (
|
|
359
|
+
{ renderingMode === 'post-only' && ! isDesignPostType && (
|
|
336
360
|
<div
|
|
337
361
|
className={ classnames(
|
|
338
362
|
'editor-editor-canvas__post-title-wrapper',
|
|
@@ -362,10 +386,9 @@ function EditorCanvas( {
|
|
|
362
386
|
className={ classnames(
|
|
363
387
|
className,
|
|
364
388
|
'is-' + deviceType.toLowerCase() + '-preview',
|
|
365
|
-
renderingMode !== 'post-only'
|
|
389
|
+
renderingMode !== 'post-only' || isDesignPostType
|
|
366
390
|
? 'wp-site-blocks'
|
|
367
|
-
: `${ blockListLayoutClass } wp-block-post-content
|
|
368
|
-
renderingMode !== 'all' && 'is-' + renderingMode
|
|
391
|
+
: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
369
392
|
) }
|
|
370
393
|
layout={ blockListLayout }
|
|
371
394
|
dropZoneElement={
|
|
@@ -376,8 +399,14 @@ function EditorCanvas( {
|
|
|
376
399
|
: localRef.current?.parentNode
|
|
377
400
|
}
|
|
378
401
|
renderAppender={ renderAppender }
|
|
402
|
+
__unstableDisableDropZone={
|
|
403
|
+
// In template preview mode, disable drop zones at the root of the template.
|
|
404
|
+
renderingMode === 'template-locked' ? true : false
|
|
405
|
+
}
|
|
379
406
|
/>
|
|
380
|
-
|
|
407
|
+
{ renderingMode === 'template-locked' && (
|
|
408
|
+
<EditTemplateBlocksNotification contentRef={ localRef } />
|
|
409
|
+
) }
|
|
381
410
|
</RecursionProvider>
|
|
382
411
|
{ children }
|
|
383
412
|
</BlockCanvas>
|
|
@@ -5,15 +5,18 @@ import { SnackbarList } from '@wordpress/components';
|
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import { store as noticesStore } from '@wordpress/notices';
|
|
7
7
|
|
|
8
|
+
// Last three notices. Slices from the tail end of the list.
|
|
9
|
+
const MAX_VISIBLE_NOTICES = -3;
|
|
10
|
+
|
|
8
11
|
export default function EditorSnackbars() {
|
|
9
12
|
const notices = useSelect(
|
|
10
13
|
( select ) => select( noticesStore ).getNotices(),
|
|
11
14
|
[]
|
|
12
15
|
);
|
|
13
16
|
const { removeNotice } = useDispatch( noticesStore );
|
|
14
|
-
const snackbarNotices = notices
|
|
15
|
-
( { type } ) => type === 'snackbar'
|
|
16
|
-
|
|
17
|
+
const snackbarNotices = notices
|
|
18
|
+
.filter( ( { type } ) => type === 'snackbar' )
|
|
19
|
+
.slice( MAX_VISIBLE_NOTICES );
|
|
17
20
|
|
|
18
21
|
return (
|
|
19
22
|
<SnackbarList
|
|
@@ -39,10 +39,7 @@ export default function EntityRecordItem( { record, checked, onChange } ) {
|
|
|
39
39
|
<CheckboxControl
|
|
40
40
|
__nextHasNoMarginBottom
|
|
41
41
|
label={
|
|
42
|
-
|
|
43
|
-
{ decodeEntities( entityRecordTitle ) ||
|
|
44
|
-
__( 'Untitled' ) }
|
|
45
|
-
</strong>
|
|
42
|
+
decodeEntities( entityRecordTitle ) || __( 'Untitled' )
|
|
46
43
|
}
|
|
47
44
|
checked={ checked }
|
|
48
45
|
onChange={ onChange }
|
|
@@ -30,7 +30,7 @@ function getEntityDescription( entity, count ) {
|
|
|
30
30
|
);
|
|
31
31
|
case 'page':
|
|
32
32
|
case 'post':
|
|
33
|
-
return __( 'The following
|
|
33
|
+
return __( 'The following has been modified.' );
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -55,18 +55,15 @@ function GlobalStylesDescription( { record } ) {
|
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
return globalStylesChanges.length ? (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</h3>
|
|
62
|
-
<PanelRow>{ globalStylesChanges.join( ', ' ) }</PanelRow>
|
|
63
|
-
</>
|
|
58
|
+
<PanelRow className="entities-saved-states__change-summary">
|
|
59
|
+
{ globalStylesChanges.join( ', ' ) }.
|
|
60
|
+
</PanelRow>
|
|
64
61
|
) : null;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
function EntityDescription( { record, count } ) {
|
|
68
65
|
if ( 'globalStyles' === record?.name ) {
|
|
69
|
-
return
|
|
66
|
+
return null;
|
|
70
67
|
}
|
|
71
68
|
const description = getEntityDescription( record?.name, count );
|
|
72
69
|
return description ? <PanelRow>{ description }</PanelRow> : null;
|
|
@@ -117,6 +114,9 @@ export default function EntityTypeList( {
|
|
|
117
114
|
/>
|
|
118
115
|
);
|
|
119
116
|
} ) }
|
|
117
|
+
{ 'globalStyles' === firstRecord?.name && (
|
|
118
|
+
<GlobalStylesDescription record={ firstRecord } />
|
|
119
|
+
) }
|
|
120
120
|
</PanelBody>
|
|
121
121
|
);
|
|
122
122
|
}
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Button, Flex, FlexItem } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useCallback,
|
|
9
|
+
useRef,
|
|
10
|
+
createInterpolateElement,
|
|
11
|
+
} from '@wordpress/element';
|
|
8
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
13
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
14
|
import { __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
@@ -215,8 +219,17 @@ export function EntitiesSavedStatesExtensible( {
|
|
|
215
219
|
{ additionalPrompt }
|
|
216
220
|
<p>
|
|
217
221
|
{ isDirty
|
|
218
|
-
?
|
|
219
|
-
|
|
222
|
+
? createInterpolateElement(
|
|
223
|
+
sprintf(
|
|
224
|
+
/* translators: %d: number of site changes waiting to be saved. */
|
|
225
|
+
_n(
|
|
226
|
+
'There is <strong>%d site change</strong> waiting to be saved.',
|
|
227
|
+
'There are <strong>%d site changes</strong> waiting to be saved.',
|
|
228
|
+
sortedPartitionedSavables.length
|
|
229
|
+
),
|
|
230
|
+
sortedPartitionedSavables.length
|
|
231
|
+
),
|
|
232
|
+
{ strong: <strong /> }
|
|
220
233
|
)
|
|
221
234
|
: __( 'Select the items you want to save.' ) }
|
|
222
235
|
</p>
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
privateApis as componentsPrivateApis,
|
|
8
|
+
} from '@wordpress/components';
|
|
6
9
|
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
7
10
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
11
|
import { focus } from '@wordpress/dom';
|
|
@@ -19,6 +22,8 @@ import ListViewOutline from './list-view-outline';
|
|
|
19
22
|
import { unlock } from '../../lock-unlock';
|
|
20
23
|
import { store as editorStore } from '../../store';
|
|
21
24
|
|
|
25
|
+
const { Tabs } = unlock( componentsPrivateApis );
|
|
26
|
+
|
|
22
27
|
export default function ListViewSidebar() {
|
|
23
28
|
const { setIsListViewOpened } = useDispatch( editorStore );
|
|
24
29
|
const { getListViewToggleRef } = unlock( useSelect( editorStore ) );
|
|
@@ -51,7 +56,7 @@ export default function ListViewSidebar() {
|
|
|
51
56
|
// This ref refers to the sidebar as a whole.
|
|
52
57
|
const sidebarRef = useRef();
|
|
53
58
|
// This ref refers to the tab panel.
|
|
54
|
-
const
|
|
59
|
+
const tabsRef = useRef();
|
|
55
60
|
// This ref refers to the list view application area.
|
|
56
61
|
const listViewRef = useRef();
|
|
57
62
|
|
|
@@ -71,7 +76,7 @@ export default function ListViewSidebar() {
|
|
|
71
76
|
*/
|
|
72
77
|
function handleSidebarFocus( currentTab ) {
|
|
73
78
|
// Tab panel focus.
|
|
74
|
-
const tabPanelFocus = focus.tabbable.find(
|
|
79
|
+
const tabPanelFocus = focus.tabbable.find( tabsRef.current )[ 0 ];
|
|
75
80
|
// List view tab is selected.
|
|
76
81
|
if ( currentTab === 'list-view' ) {
|
|
77
82
|
// Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.
|
|
@@ -108,22 +113,6 @@ export default function ListViewSidebar() {
|
|
|
108
113
|
// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
|
|
109
114
|
useShortcut( 'core/editor/toggle-list-view', handleToggleListViewShortcut );
|
|
110
115
|
|
|
111
|
-
/**
|
|
112
|
-
* Render tab content for a given tab name.
|
|
113
|
-
*
|
|
114
|
-
* @param {string} tabName The name of the tab to render.
|
|
115
|
-
*/
|
|
116
|
-
function renderTabContent( tabName ) {
|
|
117
|
-
if ( tabName === 'list-view' ) {
|
|
118
|
-
return (
|
|
119
|
-
<div className="editor-list-view-sidebar__list-view-panel-content">
|
|
120
|
-
<ListView dropZoneElement={ dropZoneElement } />
|
|
121
|
-
</div>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
return <ListViewOutline />;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
116
|
return (
|
|
128
117
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
129
118
|
<div
|
|
@@ -131,39 +120,63 @@ export default function ListViewSidebar() {
|
|
|
131
120
|
onKeyDown={ closeOnEscape }
|
|
132
121
|
ref={ sidebarRef }
|
|
133
122
|
>
|
|
134
|
-
<
|
|
135
|
-
className="editor-list-view-sidebar__close-button"
|
|
136
|
-
icon={ closeSmall }
|
|
137
|
-
label={ __( 'Close' ) }
|
|
138
|
-
onClick={ closeListView }
|
|
139
|
-
/>
|
|
140
|
-
<TabPanel
|
|
141
|
-
className="editor-list-view-sidebar__tab-panel"
|
|
142
|
-
ref={ tabPanelRef }
|
|
123
|
+
<Tabs
|
|
143
124
|
onSelect={ ( tabName ) => setTab( tabName ) }
|
|
144
125
|
selectOnMove={ false }
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
name: 'outline',
|
|
153
|
-
title: _x( 'Outline', 'Post overview' ),
|
|
154
|
-
className: 'editor-list-view-sidebar__panel-tab',
|
|
155
|
-
},
|
|
156
|
-
] }
|
|
126
|
+
// The initial tab value is set explicitly to avoid an initial
|
|
127
|
+
// render where no tab is selected. This ensures that the
|
|
128
|
+
// tabpanel height is correct so the relevant scroll container
|
|
129
|
+
// can be rendered internally.
|
|
130
|
+
initialTabId="list-view"
|
|
157
131
|
>
|
|
158
|
-
|
|
159
|
-
<
|
|
160
|
-
className="editor-list-view-
|
|
161
|
-
|
|
132
|
+
<div className="edit-post-editor__document-overview-panel__header">
|
|
133
|
+
<Button
|
|
134
|
+
className="editor-list-view-sidebar__close-button"
|
|
135
|
+
icon={ closeSmall }
|
|
136
|
+
label={ __( 'Close' ) }
|
|
137
|
+
onClick={ closeListView }
|
|
138
|
+
/>
|
|
139
|
+
<Tabs.TabList
|
|
140
|
+
className="editor-list-view-sidebar__tabs-tablist"
|
|
141
|
+
ref={ tabsRef }
|
|
162
142
|
>
|
|
163
|
-
|
|
143
|
+
<Tabs.Tab
|
|
144
|
+
className="editor-list-view-sidebar__tabs-tab"
|
|
145
|
+
tabId="list-view"
|
|
146
|
+
>
|
|
147
|
+
{ _x( 'List View', 'Post overview' ) }
|
|
148
|
+
</Tabs.Tab>
|
|
149
|
+
<Tabs.Tab
|
|
150
|
+
className="editor-list-view-sidebar__tabs-tab"
|
|
151
|
+
tabId="outline"
|
|
152
|
+
>
|
|
153
|
+
{ _x( 'Outline', 'Post overview' ) }
|
|
154
|
+
</Tabs.Tab>
|
|
155
|
+
</Tabs.TabList>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<Tabs.TabPanel
|
|
159
|
+
ref={ listViewContainerRef }
|
|
160
|
+
className="editor-list-view-sidebar__tabs-tabpanel"
|
|
161
|
+
tabId="list-view"
|
|
162
|
+
focusable={ false }
|
|
163
|
+
>
|
|
164
|
+
<div className="editor-list-view-sidebar__list-view-container">
|
|
165
|
+
<div className="editor-list-view-sidebar__list-view-panel-content">
|
|
166
|
+
<ListView dropZoneElement={ dropZoneElement } />
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
</Tabs.TabPanel>
|
|
170
|
+
<Tabs.TabPanel
|
|
171
|
+
className="editor-list-view-sidebar__tabs-tabpanel"
|
|
172
|
+
tabId="outline"
|
|
173
|
+
focusable={ false }
|
|
174
|
+
>
|
|
175
|
+
<div className="editor-list-view-sidebar__list-view-container">
|
|
176
|
+
<ListViewOutline />
|
|
164
177
|
</div>
|
|
165
|
-
|
|
166
|
-
</
|
|
178
|
+
</Tabs.TabPanel>
|
|
179
|
+
</Tabs>
|
|
167
180
|
</div>
|
|
168
181
|
);
|
|
169
182
|
}
|
|
@@ -8,32 +8,31 @@
|
|
|
8
8
|
// @see packages/block-editor/src/components/inserter/style.scss
|
|
9
9
|
width: 350px;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
.edit-post-editor__document-overview-panel__header {
|
|
12
|
+
display: flex;
|
|
13
|
+
border-bottom: $border-width solid $gray-300;
|
|
14
|
+
}
|
|
12
15
|
.editor-list-view-sidebar__close-button {
|
|
13
|
-
position: absolute;
|
|
14
|
-
right: $grid-unit-10;
|
|
15
|
-
top: math.div($grid-unit-60 - $button-size, 2); // ( tab height - button size ) / 2
|
|
16
|
-
z-index: 1;
|
|
17
16
|
background: $white;
|
|
17
|
+
order: 1;
|
|
18
|
+
align-self: center;
|
|
19
|
+
margin-right: $grid-unit-10;
|
|
18
20
|
}
|
|
21
|
+
}
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
box-sizing: border-box;
|
|
24
|
-
display: flex;
|
|
25
|
-
width: 100%;
|
|
26
|
-
padding-right: $grid-unit-70;
|
|
23
|
+
.editor-list-view-sidebar__tabs-tablist {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
flex-grow: 1;
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
width: 50%;
|
|
30
|
-
margin-bottom: -$border-width;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
27
|
+
}
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
.editor-list-view-sidebar__tabs-tab {
|
|
30
|
+
width: 50%;
|
|
31
|
+
margin-bottom: -$border-width;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.editor-list-view-sidebar__tabs-tabpanel {
|
|
35
|
+
height: calc(100% - #{$grid-unit-60 - $border-width});
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
.editor-list-view-sidebar__list-view-panel-content,
|
|
@@ -82,3 +81,4 @@
|
|
|
82
81
|
color: $gray-700;
|
|
83
82
|
}
|
|
84
83
|
}
|
|
84
|
+
|
|
@@ -2,71 +2,22 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { debounce } from '@wordpress/compose';
|
|
5
|
-
import { useState
|
|
6
|
-
import {
|
|
5
|
+
import { useState } from '@wordpress/element';
|
|
6
|
+
import { useDispatch } from '@wordpress/data';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { ComboboxControl } from '@wordpress/components';
|
|
9
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
10
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Internal dependencies
|
|
14
12
|
*/
|
|
15
13
|
import { store as editorStore } from '../../store';
|
|
16
|
-
import {
|
|
14
|
+
import { useAuthorsQuery } from './hook';
|
|
17
15
|
|
|
18
|
-
function PostAuthorCombobox() {
|
|
16
|
+
export default function PostAuthorCombobox() {
|
|
19
17
|
const [ fieldValue, setFieldValue ] = useState();
|
|
20
18
|
|
|
21
|
-
const { authorId, isLoading, authors, postAuthor } = useSelect(
|
|
22
|
-
( select ) => {
|
|
23
|
-
const { getUser, getUsers, isResolving } = select( coreStore );
|
|
24
|
-
const { getEditedPostAttribute } = select( editorStore );
|
|
25
|
-
const author = getUser( getEditedPostAttribute( 'author' ), {
|
|
26
|
-
context: 'view',
|
|
27
|
-
} );
|
|
28
|
-
const query = { ...AUTHORS_QUERY };
|
|
29
|
-
|
|
30
|
-
if ( fieldValue ) {
|
|
31
|
-
query.search = fieldValue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
authorId: getEditedPostAttribute( 'author' ),
|
|
36
|
-
postAuthor: author,
|
|
37
|
-
authors: getUsers( query ),
|
|
38
|
-
isLoading: isResolving( 'core', 'getUsers', [ query ] ),
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
[ fieldValue ]
|
|
42
|
-
);
|
|
43
19
|
const { editPost } = useDispatch( editorStore );
|
|
44
|
-
|
|
45
|
-
const authorOptions = useMemo( () => {
|
|
46
|
-
const fetchedAuthors = ( authors ?? [] ).map( ( author ) => {
|
|
47
|
-
return {
|
|
48
|
-
value: author.id,
|
|
49
|
-
label: decodeEntities( author.name ),
|
|
50
|
-
};
|
|
51
|
-
} );
|
|
52
|
-
|
|
53
|
-
// Ensure the current author is included in the dropdown list.
|
|
54
|
-
const foundAuthor = fetchedAuthors.findIndex(
|
|
55
|
-
( { value } ) => postAuthor?.id === value
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
if ( foundAuthor < 0 && postAuthor ) {
|
|
59
|
-
return [
|
|
60
|
-
{
|
|
61
|
-
value: postAuthor.id,
|
|
62
|
-
label: decodeEntities( postAuthor.name ),
|
|
63
|
-
},
|
|
64
|
-
...fetchedAuthors,
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return fetchedAuthors;
|
|
69
|
-
}, [ authors, postAuthor ] );
|
|
20
|
+
const { authorId, authorOptions } = useAuthorsQuery( fieldValue );
|
|
70
21
|
|
|
71
22
|
/**
|
|
72
23
|
* Handle author selection.
|
|
@@ -89,10 +40,6 @@ function PostAuthorCombobox() {
|
|
|
89
40
|
setFieldValue( inputValue );
|
|
90
41
|
};
|
|
91
42
|
|
|
92
|
-
if ( ! postAuthor ) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
43
|
return (
|
|
97
44
|
<ComboboxControl
|
|
98
45
|
__nextHasNoMarginBottom
|
|
@@ -102,10 +49,7 @@ function PostAuthorCombobox() {
|
|
|
102
49
|
value={ authorId }
|
|
103
50
|
onFilterValueChange={ debounce( handleKeydown, 300 ) }
|
|
104
51
|
onChange={ handleSelect }
|
|
105
|
-
isLoading={ isLoading }
|
|
106
52
|
allowReset={ false }
|
|
107
53
|
/>
|
|
108
54
|
);
|
|
109
55
|
}
|
|
110
|
-
|
|
111
|
-
export default PostAuthorCombobox;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export const BASE_QUERY = {
|
|
2
|
+
_fields: 'id,name',
|
|
3
|
+
context: 'view', // Allows non-admins to perform requests.
|
|
4
|
+
};
|
|
5
|
+
|
|
1
6
|
export const AUTHORS_QUERY = {
|
|
2
7
|
who: 'authors',
|
|
3
8
|
per_page: 50,
|
|
4
|
-
|
|
5
|
-
context: 'view', // Allows non-admins to perform requests.
|
|
9
|
+
...BASE_QUERY,
|
|
6
10
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editorStore } from '../../store';
|
|
13
|
+
import { AUTHORS_QUERY, BASE_QUERY } from './constants';
|
|
14
|
+
|
|
15
|
+
export function useAuthorsQuery( search ) {
|
|
16
|
+
const { authorId, authors, postAuthor } = useSelect(
|
|
17
|
+
( select ) => {
|
|
18
|
+
const { getUser, getUsers } = select( coreStore );
|
|
19
|
+
const { getEditedPostAttribute } = select( editorStore );
|
|
20
|
+
const _authorId = getEditedPostAttribute( 'author' );
|
|
21
|
+
const query = { ...AUTHORS_QUERY };
|
|
22
|
+
|
|
23
|
+
if ( search ) {
|
|
24
|
+
query.search = search;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
authorId: _authorId,
|
|
29
|
+
authors: getUsers( query ),
|
|
30
|
+
postAuthor: getUser( _authorId, BASE_QUERY ),
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
[ search ]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const authorOptions = useMemo( () => {
|
|
37
|
+
const fetchedAuthors = ( authors ?? [] ).map( ( author ) => {
|
|
38
|
+
return {
|
|
39
|
+
value: author.id,
|
|
40
|
+
label: decodeEntities( author.name ),
|
|
41
|
+
};
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
// Ensure the current author is included in the dropdown list.
|
|
45
|
+
const foundAuthor = fetchedAuthors.findIndex(
|
|
46
|
+
( { value } ) => postAuthor?.id === value
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if ( foundAuthor < 0 && postAuthor ) {
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
value: postAuthor.id,
|
|
53
|
+
label: decodeEntities( postAuthor.name ),
|
|
54
|
+
},
|
|
55
|
+
...fetchedAuthors,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return fetchedAuthors;
|
|
60
|
+
}, [ authors, postAuthor ] );
|
|
61
|
+
|
|
62
|
+
return { authorId, authorOptions };
|
|
63
|
+
}
|