@wordpress/editor 13.27.2 → 13.28.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 +2 -0
- package/build/bindings/post-meta.js +1 -2
- 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 +14 -10
- 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 +31 -62
- 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 +1 -2
- 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/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 +13 -8
- 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-style/style-rtl.css +28 -22
- package/build-style/style.css +28 -22
- package/package.json +32 -32
- 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 +14 -4
- 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
|
@@ -27,27 +27,17 @@ import { store as editorStore } from '../../store';
|
|
|
27
27
|
* editor iframe canvas.
|
|
28
28
|
*/
|
|
29
29
|
export default function EditTemplateBlocksNotification( { contentRef } ) {
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
[]
|
|
44
|
-
);
|
|
45
|
-
const editTemplate = getPostLinkProps
|
|
46
|
-
? getPostLinkProps( {
|
|
47
|
-
postId: templateId,
|
|
48
|
-
postType: 'wp_template',
|
|
49
|
-
} )
|
|
50
|
-
: {};
|
|
30
|
+
const { onNavigateToEntityRecord, templateId } = useSelect( ( select ) => {
|
|
31
|
+
const { getEditorSettings, getCurrentTemplateId } =
|
|
32
|
+
select( editorStore );
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
onNavigateToEntityRecord:
|
|
36
|
+
getEditorSettings().onNavigateToEntityRecord,
|
|
37
|
+
templateId: getCurrentTemplateId(),
|
|
38
|
+
};
|
|
39
|
+
}, [] );
|
|
40
|
+
|
|
51
41
|
const { getNotices } = useSelect( noticesStore );
|
|
52
42
|
|
|
53
43
|
const { createInfoNotice, removeNotice } = useDispatch( noticesStore );
|
|
@@ -58,18 +48,17 @@ export default function EditTemplateBlocksNotification( { contentRef } ) {
|
|
|
58
48
|
|
|
59
49
|
useEffect( () => {
|
|
60
50
|
const handleClick = async ( event ) => {
|
|
61
|
-
if ( renderingMode !== 'template-locked' ) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
51
|
if ( ! event.target.classList.contains( 'is-root-container' ) ) {
|
|
65
52
|
return;
|
|
66
53
|
}
|
|
54
|
+
|
|
67
55
|
const isNoticeAlreadyShowing = getNotices().some(
|
|
68
56
|
( notice ) => notice.id === lastNoticeId.current
|
|
69
57
|
);
|
|
70
58
|
if ( isNoticeAlreadyShowing ) {
|
|
71
59
|
return;
|
|
72
60
|
}
|
|
61
|
+
|
|
73
62
|
const { notice } = await createInfoNotice(
|
|
74
63
|
__( 'Edit your template to edit this block.' ),
|
|
75
64
|
{
|
|
@@ -78,7 +67,11 @@ export default function EditTemplateBlocksNotification( { contentRef } ) {
|
|
|
78
67
|
actions: [
|
|
79
68
|
{
|
|
80
69
|
label: __( 'Edit template' ),
|
|
81
|
-
onClick: () =>
|
|
70
|
+
onClick: () =>
|
|
71
|
+
onNavigateToEntityRecord( {
|
|
72
|
+
postId: templateId,
|
|
73
|
+
postType: 'wp_template',
|
|
74
|
+
} ),
|
|
82
75
|
},
|
|
83
76
|
],
|
|
84
77
|
}
|
|
@@ -87,9 +80,6 @@ export default function EditTemplateBlocksNotification( { contentRef } ) {
|
|
|
87
80
|
};
|
|
88
81
|
|
|
89
82
|
const handleDblClick = ( event ) => {
|
|
90
|
-
if ( renderingMode !== 'template-locked' ) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
83
|
if ( ! event.target.classList.contains( 'is-root-container' ) ) {
|
|
94
84
|
return;
|
|
95
85
|
}
|
|
@@ -106,7 +96,15 @@ export default function EditTemplateBlocksNotification( { contentRef } ) {
|
|
|
106
96
|
canvas?.removeEventListener( 'click', handleClick );
|
|
107
97
|
canvas?.removeEventListener( 'dblclick', handleDblClick );
|
|
108
98
|
};
|
|
109
|
-
}, [
|
|
99
|
+
}, [
|
|
100
|
+
lastNoticeId,
|
|
101
|
+
contentRef,
|
|
102
|
+
getNotices,
|
|
103
|
+
createInfoNotice,
|
|
104
|
+
onNavigateToEntityRecord,
|
|
105
|
+
templateId,
|
|
106
|
+
removeNotice,
|
|
107
|
+
] );
|
|
110
108
|
|
|
111
109
|
return (
|
|
112
110
|
<ConfirmDialog
|
|
@@ -114,7 +112,10 @@ export default function EditTemplateBlocksNotification( { contentRef } ) {
|
|
|
114
112
|
confirmButtonText={ __( 'Edit template' ) }
|
|
115
113
|
onConfirm={ () => {
|
|
116
114
|
setIsDialogOpen( false );
|
|
117
|
-
|
|
115
|
+
onNavigateToEntityRecord( {
|
|
116
|
+
postId: templateId,
|
|
117
|
+
postType: 'wp_template',
|
|
118
|
+
} );
|
|
118
119
|
} }
|
|
119
120
|
onCancel={ () => setIsDialogOpen( false ) }
|
|
120
121
|
>
|
|
@@ -35,6 +35,7 @@ const {
|
|
|
35
35
|
useLayoutClasses,
|
|
36
36
|
useLayoutStyles,
|
|
37
37
|
ExperimentalBlockCanvas: BlockCanvas,
|
|
38
|
+
useFlashEditableBlocks,
|
|
38
39
|
} = unlock( blockEditorPrivateApis );
|
|
39
40
|
|
|
40
41
|
const noop = () => {};
|
|
@@ -138,7 +139,8 @@ function EditorCanvas( {
|
|
|
138
139
|
wrapperBlockName: _wrapperBlockName,
|
|
139
140
|
wrapperUniqueId: getCurrentPostId(),
|
|
140
141
|
deviceType: getDeviceType(),
|
|
141
|
-
showEditorPadding:
|
|
142
|
+
showEditorPadding:
|
|
143
|
+
!! editorSettings.onNavigateToPreviousEntityRecord,
|
|
142
144
|
};
|
|
143
145
|
}, [] );
|
|
144
146
|
const { isCleanNewPost } = useSelect( editorStore );
|
|
@@ -290,6 +292,9 @@ function EditorCanvas( {
|
|
|
290
292
|
const contentRef = useMergeRefs( [
|
|
291
293
|
localRef,
|
|
292
294
|
renderingMode === 'post-only' ? typewriterRef : noop,
|
|
295
|
+
useFlashEditableBlocks( {
|
|
296
|
+
isEnabled: renderingMode === 'template-locked',
|
|
297
|
+
} ),
|
|
293
298
|
] );
|
|
294
299
|
|
|
295
300
|
return (
|
|
@@ -364,8 +369,7 @@ function EditorCanvas( {
|
|
|
364
369
|
'is-' + deviceType.toLowerCase() + '-preview',
|
|
365
370
|
renderingMode !== 'post-only'
|
|
366
371
|
? 'wp-site-blocks'
|
|
367
|
-
: `${ blockListLayoutClass } wp-block-post-content
|
|
368
|
-
renderingMode !== 'all' && 'is-' + renderingMode
|
|
372
|
+
: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
369
373
|
) }
|
|
370
374
|
layout={ blockListLayout }
|
|
371
375
|
dropZoneElement={
|
|
@@ -376,8 +380,14 @@ function EditorCanvas( {
|
|
|
376
380
|
: localRef.current?.parentNode
|
|
377
381
|
}
|
|
378
382
|
renderAppender={ renderAppender }
|
|
383
|
+
__unstableDisableDropZone={
|
|
384
|
+
// In template preview mode, disable drop zones at the root of the template.
|
|
385
|
+
renderingMode === 'template-locked' ? true : false
|
|
386
|
+
}
|
|
379
387
|
/>
|
|
380
|
-
|
|
388
|
+
{ renderingMode === 'template-locked' && (
|
|
389
|
+
<EditTemplateBlocksNotification contentRef={ localRef } />
|
|
390
|
+
) }
|
|
381
391
|
</RecursionProvider>
|
|
382
392
|
{ children }
|
|
383
393
|
</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
|
+
}
|