@wordpress/editor 13.27.1 → 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 +3 -4
- 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 +7 -23
- 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 +22 -13
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-canvas/index.js +16 -12
- 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 +24 -11
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +17 -13
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +20 -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 +13 -7
- 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 +38 -65
- 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-actions.js +1 -0
- package/build/store/private-actions.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 +82 -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/post-meta.js +2 -2
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/document-bar/index.js +7 -23
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +22 -13
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +15 -10
- 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 +24 -11
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +16 -11
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +20 -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 +11 -3
- 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 +7 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +10 -0
- package/build-module/store/selectors.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/post-meta.js +2 -2
- package/src/components/document-bar/index.js +24 -38
- package/src/components/editor-canvas/edit-template-blocks-notification.js +31 -14
- package/src/components/editor-canvas/index.js +16 -6
- 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 +33 -14
- package/src/components/post-template/classic-theme.js +17 -10
- package/src/components/post-template/create-new-template-modal.js +17 -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 +18 -6
- 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 +8 -3
- package/src/store/private-actions.js +1 -0
- package/src/store/selectors.js +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","Flex","FlexItem","__","useSelect","useDispatch","useCallback","useRef","store","coreStore","blockEditorStore","__experimentalUseDialog","useDialog","noticesStore","EntityTypeList","useIsDirty","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","EntitiesSavedStates","close","isDirtyProps","createElement","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","__unstableMarkLastChangeAsPersistent","createSuccessNotice","createErrorNotice","removeNotice","partitionedSavables","reduce","acc","record","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","homeUrl","select","getUnstableBase","home","saveCheckedEntities","saveNoticeId","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","id","actions","label","url","catch","error","dismissPanel","saveDialogRef","saveDialogProps","onClose","ref","className","gap","isBlock","as","variant","disabled","onClick","map","list"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible close={ close } { ...isDirtyProps } />\n\t);\n}\n\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice, removeNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\n\tconst { homeUrl } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\n\tconst saveCheckedEntities = () => {\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tremoveNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong className=\"entities-saved-states__text-prompt--header\">\n\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t</strong>\n\t\t\t\t{ additionalPrompt }\n\t\t\t\t<p>\n\t\t\t\t\t{ isDirty\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'The following changes have been made to your site, templates, and content.'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Select the items you want to save.' ) }\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC9D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,uBAAuB,IAAIC,SAAS,QAAQ,oBAAoB;AACzE,SAASJ,KAAK,IAAIK,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,UAAU,QAAQ,sBAAsB;AAEjD,MAAMC,wBAAwB,GAAG,CAChC;EACCC,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE;AACP,CAAC,CACD;AAED,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,OAAOA,MAAM;AACd;AAEA,eAAe,SAASC,mBAAmBA,CAAE;EAAEC;AAAM,CAAC,EAAG;EACxD,MAAMC,YAAY,GAAGR,UAAU,CAAC,CAAC;EACjC,OACCS,aAAA,CAACC,6BAA6B;IAACH,KAAK,EAAGA,KAAO;IAAA,GAAMC;EAAY,CAAI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,kBAAkB,EAAGA,kBAAoB;MACzCD,qBAAqB,EAAGA;IAAuB,CAC/C,CAAC;EAEJ,CAAE,CACE,CAAC;AAER"}
|
|
1
|
+
{"version":3,"names":["Button","Flex","FlexItem","__","_n","sprintf","useSelect","useDispatch","useCallback","useRef","createInterpolateElement","store","coreStore","blockEditorStore","__experimentalUseDialog","useDialog","noticesStore","EntityTypeList","useIsDirty","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","EntitiesSavedStates","close","isDirtyProps","createElement","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","__unstableMarkLastChangeAsPersistent","createSuccessNotice","createErrorNotice","removeNotice","partitionedSavables","reduce","acc","record","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","homeUrl","select","getUnstableBase","home","saveCheckedEntities","saveNoticeId","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","id","actions","label","url","catch","error","dismissPanel","saveDialogRef","saveDialogProps","onClose","ref","className","gap","isBlock","as","variant","disabled","onClick","strong","map","list"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseRef,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible close={ close } { ...isDirtyProps } />\n\t);\n}\n\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice, removeNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\n\tconst { homeUrl } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\n\tconst saveCheckedEntities = () => {\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tremoveNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong className=\"entities-saved-states__text-prompt--header\">\n\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t</strong>\n\t\t\t\t{ additionalPrompt }\n\t\t\t\t<p>\n\t\t\t\t\t{ isDirty\n\t\t\t\t\t\t? createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %d: number of site changes waiting to be saved. */\n\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t'There is <strong>%d site change</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\t'There are <strong>%d site changes</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\tsortedPartitionedSavables.length\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsortedPartitionedSavables.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{ strong: <strong /> }\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Select the items you want to save.' ) }\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ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,QAAQ;IACRkG,OAAO;IACPC,EAAE,EAAGrG,MAAQ;IACbiG,GAAG,EAAG1D,aAAe;IACrB+D,OAAO,EAAC,SAAS;IACjBC,QAAQ,EAAG,CAAEvE,WAAa;IAC1BwE,OAAO,EAAGnC,mBAAqB;IAC/B6B,SAAS,EAAC;EAA2C,GAEnDhE,SACO,CAAC,EACXP,aAAA,CAACzB,QAAQ;IACRkG,OAAO;IACPC,EAAE,EAAGrG,MAAQ;IACbsG,OAAO,EAAC,WAAW;IACnBE,OAAO,EAAGX;EAAc,GAEtB1F,EAAE,CAAE,QAAS,CACN,CACL,CAAC,EAEPwB,aAAA;IAAKuE,SAAS,EAAC;EAAoC,GAClDvE,aAAA;IAAQuE,SAAS,EAAC;EAA4C,GAC3D/F,EAAE,CAAE,wBAAyB,CACxB,CAAC,EACP0B,gBAAgB,EAClBF,aAAA,YACGS,OAAO,GACN1B,wBAAwB,CACxBL,OAAO,EACN;EACAD,EAAE,CACD,+DAA+D,EAC/D,iEAAiE,EACjEwD,yBAAyB,CAACqB,MAC3B,CAAC,EACDrB,yBAAyB,CAACqB,MAC3B,CAAC,EACD;IAAEwB,MAAM,EAAE9E,aAAA,eAAS;EAAE,CACrB,CAAC,GACDxB,EAAE,CAAE,oCAAqC,CAC1C,CACC,CAAC,EAEJyD,yBAAyB,CAAC8C,GAAG,CAAIC,IAAI,IAAM;IAC5C,OACChF,aAAA,CAACV,cAAc;MACduD,GAAG,EAAGmC,IAAI,CAAE,CAAC,CAAE,CAACtF,IAAM;MACtBsF,IAAI,EAAGA,IAAM;MACbrE,kBAAkB,EAAGA,kBAAoB;MACzCD,qBAAqB,EAAGA;IAAuB,CAC/C,CAAC;EAEJ,CAAE,CACE,CAAC;AAER"}
|
|
@@ -3,7 +3,7 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
6
|
-
import { Button,
|
|
6
|
+
import { Button, privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
7
7
|
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
8
8
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
9
9
|
import { focus } from '@wordpress/dom';
|
|
@@ -19,6 +19,9 @@ import { ESCAPE } from '@wordpress/keycodes';
|
|
|
19
19
|
import ListViewOutline from './list-view-outline';
|
|
20
20
|
import { unlock } from '../../lock-unlock';
|
|
21
21
|
import { store as editorStore } from '../../store';
|
|
22
|
+
const {
|
|
23
|
+
Tabs
|
|
24
|
+
} = unlock(componentsPrivateApis);
|
|
22
25
|
export default function ListViewSidebar() {
|
|
23
26
|
const {
|
|
24
27
|
setIsListViewOpened
|
|
@@ -51,7 +54,7 @@ export default function ListViewSidebar() {
|
|
|
51
54
|
// This ref refers to the sidebar as a whole.
|
|
52
55
|
const sidebarRef = useRef();
|
|
53
56
|
// This ref refers to the tab panel.
|
|
54
|
-
const
|
|
57
|
+
const tabsRef = useRef();
|
|
55
58
|
// This ref refers to the list view application area.
|
|
56
59
|
const listViewRef = useRef();
|
|
57
60
|
|
|
@@ -67,7 +70,7 @@ export default function ListViewSidebar() {
|
|
|
67
70
|
*/
|
|
68
71
|
function handleSidebarFocus(currentTab) {
|
|
69
72
|
// Tab panel focus.
|
|
70
|
-
const tabPanelFocus = focus.tabbable.find(
|
|
73
|
+
const tabPanelFocus = focus.tabbable.find(tabsRef.current)[0];
|
|
71
74
|
// List view tab is selected.
|
|
72
75
|
if (currentTab === 'list-view') {
|
|
73
76
|
// 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.
|
|
@@ -92,51 +95,55 @@ export default function ListViewSidebar() {
|
|
|
92
95
|
// This only fires when the sidebar is open because of the conditional rendering.
|
|
93
96
|
// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
|
|
94
97
|
useShortcut('core/editor/toggle-list-view', handleToggleListViewShortcut);
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Render tab content for a given tab name.
|
|
98
|
-
*
|
|
99
|
-
* @param {string} tabName The name of the tab to render.
|
|
100
|
-
*/
|
|
101
|
-
function renderTabContent(tabName) {
|
|
102
|
-
if (tabName === 'list-view') {
|
|
103
|
-
return createElement("div", {
|
|
104
|
-
className: "editor-list-view-sidebar__list-view-panel-content"
|
|
105
|
-
}, createElement(ListView, {
|
|
106
|
-
dropZoneElement: dropZoneElement
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
return createElement(ListViewOutline, null);
|
|
110
|
-
}
|
|
111
98
|
return (
|
|
112
99
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
113
100
|
createElement("div", {
|
|
114
101
|
className: "editor-list-view-sidebar",
|
|
115
102
|
onKeyDown: closeOnEscape,
|
|
116
103
|
ref: sidebarRef
|
|
104
|
+
}, createElement(Tabs, {
|
|
105
|
+
onSelect: tabName => setTab(tabName),
|
|
106
|
+
selectOnMove: false
|
|
107
|
+
// The initial tab value is set explicitly to avoid an initial
|
|
108
|
+
// render where no tab is selected. This ensures that the
|
|
109
|
+
// tabpanel height is correct so the relevant scroll container
|
|
110
|
+
// can be rendered internally.
|
|
111
|
+
,
|
|
112
|
+
initialTabId: "list-view"
|
|
113
|
+
}, createElement("div", {
|
|
114
|
+
className: "edit-post-editor__document-overview-panel__header"
|
|
117
115
|
}, createElement(Button, {
|
|
118
116
|
className: "editor-list-view-sidebar__close-button",
|
|
119
117
|
icon: closeSmall,
|
|
120
118
|
label: __('Close'),
|
|
121
119
|
onClick: closeListView
|
|
122
|
-
}), createElement(
|
|
123
|
-
className: "editor-list-view-
|
|
124
|
-
ref:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
className: "editor-list-view-sidebar__list-view-container"
|
|
138
|
-
|
|
139
|
-
|
|
120
|
+
}), createElement(Tabs.TabList, {
|
|
121
|
+
className: "editor-list-view-sidebar__tabs-tablist",
|
|
122
|
+
ref: tabsRef
|
|
123
|
+
}, createElement(Tabs.Tab, {
|
|
124
|
+
className: "editor-list-view-sidebar__tabs-tab",
|
|
125
|
+
tabId: "list-view"
|
|
126
|
+
}, _x('List View', 'Post overview')), createElement(Tabs.Tab, {
|
|
127
|
+
className: "editor-list-view-sidebar__tabs-tab",
|
|
128
|
+
tabId: "outline"
|
|
129
|
+
}, _x('Outline', 'Post overview')))), createElement(Tabs.TabPanel, {
|
|
130
|
+
ref: listViewContainerRef,
|
|
131
|
+
className: "editor-list-view-sidebar__tabs-tabpanel",
|
|
132
|
+
tabId: "list-view",
|
|
133
|
+
focusable: false
|
|
134
|
+
}, createElement("div", {
|
|
135
|
+
className: "editor-list-view-sidebar__list-view-container"
|
|
136
|
+
}, createElement("div", {
|
|
137
|
+
className: "editor-list-view-sidebar__list-view-panel-content"
|
|
138
|
+
}, createElement(ListView, {
|
|
139
|
+
dropZoneElement: dropZoneElement
|
|
140
|
+
})))), createElement(Tabs.TabPanel, {
|
|
141
|
+
className: "editor-list-view-sidebar__tabs-tabpanel",
|
|
142
|
+
tabId: "outline",
|
|
143
|
+
focusable: false
|
|
144
|
+
}, createElement("div", {
|
|
145
|
+
className: "editor-list-view-sidebar__list-view-container"
|
|
146
|
+
}, createElement(ListViewOutline, null)))))
|
|
140
147
|
);
|
|
141
148
|
}
|
|
142
149
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalListView","ListView","Button","TabPanel","useFocusOnMount","useMergeRefs","useDispatch","useSelect","focus","useCallback","useRef","useState","__","_x","closeSmall","useShortcut","ESCAPE","ListViewOutline","unlock","store","editorStore","ListViewSidebar","setIsListViewOpened","getListViewToggleRef","focusOnMountRef","closeListView","current","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","dropZoneElement","setDropZoneElement","tab","setTab","sidebarRef","tabPanelRef","listViewRef","listViewContainerRef","handleSidebarFocus","currentTab","tabPanelFocus","tabbable","find","listViewApplicationFocus","listViewFocusArea","contains","handleToggleListViewShortcut","ownerDocument","activeElement","renderTabContent","tabName","createElement","className","onKeyDown","ref","icon","label","onClick","onSelect","selectOnMove","tabs","name","title"],"sources":["@wordpress/editor/src/components/list-view-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalListView as ListView } from '@wordpress/block-editor';\nimport { Button, TabPanel } from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ListViewOutline from './list-view-outline';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editorStore );\n\tconst { getListViewToggleRef } = unlock( useSelect( editorStore ) );\n\n\t// This hook handles focus when the sidebar first renders.\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tgetListViewToggleRef().current?.focus();\n\t}, [ getListViewToggleRef, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\t// Tracks our current tab.\n\tconst [ tab, setTab ] = useState( 'list-view' );\n\n\t// This ref refers to the sidebar as a whole.\n\tconst sidebarRef = useRef();\n\t// This ref refers to the tab panel.\n\tconst tabPanelRef = useRef();\n\t// This ref refers to the list view application area.\n\tconst listViewRef = useRef();\n\n\t// Must merge the refs together so focus can be handled properly in the next function.\n\tconst listViewContainerRef = useMergeRefs( [\n\t\tfocusOnMountRef,\n\t\tlistViewRef,\n\t\tsetDropZoneElement,\n\t] );\n\n\t/*\n\t * Callback function to handle list view or outline focus.\n\t *\n\t * @param {string} currentTab The current tab. Either list view or outline.\n\t *\n\t * @return void\n\t */\n\tfunction handleSidebarFocus( currentTab ) {\n\t\t// Tab panel focus.\n\t\tconst tabPanelFocus = focus.tabbable.find( tabPanelRef.current )[ 0 ];\n\t\t// List view tab is selected.\n\t\tif ( currentTab === 'list-view' ) {\n\t\t\t// 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.\n\t\t\tconst listViewApplicationFocus = focus.tabbable.find(\n\t\t\t\tlistViewRef.current\n\t\t\t)[ 0 ];\n\t\t\tconst listViewFocusArea = sidebarRef.current.contains(\n\t\t\t\tlistViewApplicationFocus\n\t\t\t)\n\t\t\t\t? listViewApplicationFocus\n\t\t\t\t: tabPanelFocus;\n\t\t\tlistViewFocusArea.focus();\n\t\t\t// Outline tab is selected.\n\t\t} else {\n\t\t\ttabPanelFocus.focus();\n\t\t}\n\t}\n\n\tconst handleToggleListViewShortcut = useCallback( () => {\n\t\t// If the sidebar has focus, it is safe to close.\n\t\tif (\n\t\t\tsidebarRef.current.contains(\n\t\t\t\tsidebarRef.current.ownerDocument.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcloseListView();\n\t\t} else {\n\t\t\t// If the list view or outline does not have focus, focus should be moved to it.\n\t\t\thandleSidebarFocus( tab );\n\t\t}\n\t}, [ closeListView, tab ] );\n\n\t// This only fires when the sidebar is open because of the conditional rendering.\n\t// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.\n\tuseShortcut( 'core/editor/toggle-list-view', handleToggleListViewShortcut );\n\n\t/**\n\t * Render tab content for a given tab name.\n\t *\n\t * @param {string} tabName The name of the tab to render.\n\t */\n\tfunction renderTabContent( tabName ) {\n\t\tif ( tabName === 'list-view' ) {\n\t\t\treturn (\n\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-panel-content\">\n\t\t\t\t\t<ListView dropZoneElement={ dropZoneElement } />\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\t\treturn <ListViewOutline />;\n\t}\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"editor-list-view-sidebar\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t\tref={ sidebarRef }\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-list-view-sidebar__close-button\"\n\t\t\t\ticon={ closeSmall }\n\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\tonClick={ closeListView }\n\t\t\t/>\n\t\t\t<TabPanel\n\t\t\t\tclassName=\"editor-list-view-sidebar__tab-panel\"\n\t\t\t\tref={ tabPanelRef }\n\t\t\t\tonSelect={ ( tabName ) => setTab( tabName ) }\n\t\t\t\tselectOnMove={ false }\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'list-view',\n\t\t\t\t\t\ttitle: _x( 'List View', 'Post overview' ),\n\t\t\t\t\t\tclassName: 'editor-list-view-sidebar__panel-tab',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'outline',\n\t\t\t\t\t\ttitle: _x( 'Outline', 'Post overview' ),\n\t\t\t\t\t\tclassName: 'editor-list-view-sidebar__panel-tab',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( currentTab ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__list-view-container\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,SAAS,EAAE;MACZ,CAAC,EACD;QACCS,IAAI,EAAE,SAAS;QACfC,KAAK,EAAEnD,EAAE,CAAE,SAAS,EAAE,eAAgB,CAAC;QACvCyC,SAAS,EAAE;MACZ,CAAC;IACC,GAECb,UAAU,IACbY,aAAA;MACCC,SAAS,EAAC,+CAA+C;MACzDE,GAAG,EAAGjB;IAAsB,GAE1BY,gBAAgB,CAAEV,UAAU,CAACsB,IAAK,CAChC,CAEG,CACN;EAAC;AAER"}
|
|
1
|
+
{"version":3,"names":["__experimentalListView","ListView","Button","privateApis","componentsPrivateApis","useFocusOnMount","useMergeRefs","useDispatch","useSelect","focus","useCallback","useRef","useState","__","_x","closeSmall","useShortcut","ESCAPE","ListViewOutline","unlock","store","editorStore","Tabs","ListViewSidebar","setIsListViewOpened","getListViewToggleRef","focusOnMountRef","closeListView","current","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","dropZoneElement","setDropZoneElement","tab","setTab","sidebarRef","tabsRef","listViewRef","listViewContainerRef","handleSidebarFocus","currentTab","tabPanelFocus","tabbable","find","listViewApplicationFocus","listViewFocusArea","contains","handleToggleListViewShortcut","ownerDocument","activeElement","createElement","className","onKeyDown","ref","onSelect","tabName","selectOnMove","initialTabId","icon","label","onClick","TabList","Tab","tabId","TabPanel","focusable"],"sources":["@wordpress/editor/src/components/list-view-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalListView as ListView } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ListViewOutline from './list-view-outline';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editorStore );\n\tconst { getListViewToggleRef } = unlock( useSelect( editorStore ) );\n\n\t// This hook handles focus when the sidebar first renders.\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tgetListViewToggleRef().current?.focus();\n\t}, [ getListViewToggleRef, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\t// Tracks our current tab.\n\tconst [ tab, setTab ] = useState( 'list-view' );\n\n\t// This ref refers to the sidebar as a whole.\n\tconst sidebarRef = useRef();\n\t// This ref refers to the tab panel.\n\tconst tabsRef = useRef();\n\t// This ref refers to the list view application area.\n\tconst listViewRef = useRef();\n\n\t// Must merge the refs together so focus can be handled properly in the next function.\n\tconst listViewContainerRef = useMergeRefs( [\n\t\tfocusOnMountRef,\n\t\tlistViewRef,\n\t\tsetDropZoneElement,\n\t] );\n\n\t/*\n\t * Callback function to handle list view or outline focus.\n\t *\n\t * @param {string} currentTab The current tab. Either list view or outline.\n\t *\n\t * @return void\n\t */\n\tfunction handleSidebarFocus( currentTab ) {\n\t\t// Tab panel focus.\n\t\tconst tabPanelFocus = focus.tabbable.find( tabsRef.current )[ 0 ];\n\t\t// List view tab is selected.\n\t\tif ( currentTab === 'list-view' ) {\n\t\t\t// 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.\n\t\t\tconst listViewApplicationFocus = focus.tabbable.find(\n\t\t\t\tlistViewRef.current\n\t\t\t)[ 0 ];\n\t\t\tconst listViewFocusArea = sidebarRef.current.contains(\n\t\t\t\tlistViewApplicationFocus\n\t\t\t)\n\t\t\t\t? listViewApplicationFocus\n\t\t\t\t: tabPanelFocus;\n\t\t\tlistViewFocusArea.focus();\n\t\t\t// Outline tab is selected.\n\t\t} else {\n\t\t\ttabPanelFocus.focus();\n\t\t}\n\t}\n\n\tconst handleToggleListViewShortcut = useCallback( () => {\n\t\t// If the sidebar has focus, it is safe to close.\n\t\tif (\n\t\t\tsidebarRef.current.contains(\n\t\t\t\tsidebarRef.current.ownerDocument.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcloseListView();\n\t\t} else {\n\t\t\t// If the list view or outline does not have focus, focus should be moved to it.\n\t\t\thandleSidebarFocus( tab );\n\t\t}\n\t}, [ closeListView, tab ] );\n\n\t// This only fires when the sidebar is open because of the conditional rendering.\n\t// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.\n\tuseShortcut( 'core/editor/toggle-list-view', handleToggleListViewShortcut );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"editor-list-view-sidebar\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t\tref={ sidebarRef }\n\t\t>\n\t\t\t<Tabs\n\t\t\t\tonSelect={ ( tabName ) => setTab( tabName ) }\n\t\t\t\tselectOnMove={ false }\n\t\t\t\t// The initial tab value is set explicitly to avoid an initial\n\t\t\t\t// render where no tab is selected. This ensures that the\n\t\t\t\t// tabpanel height is correct so the relevant scroll container\n\t\t\t\t// can be rendered internally.\n\t\t\t\tinitialTabId=\"list-view\"\n\t\t\t>\n\t\t\t\t<div className=\"edit-post-editor__document-overview-panel__header\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__close-button\"\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\tonClick={ closeListView }\n\t\t\t\t\t/>\n\t\t\t\t\t<Tabs.TabList\n\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tablist\"\n\t\t\t\t\t\tref={ tabsRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tab\"\n\t\t\t\t\t\t\ttabId=\"list-view\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'List View', 'Post overview' ) }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tab\"\n\t\t\t\t\t\t\ttabId=\"outline\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Outline', 'Post overview' ) }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t</div>\n\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\tref={ listViewContainerRef }\n\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tabpanel\"\n\t\t\t\t\ttabId=\"list-view\"\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-container\">\n\t\t\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-panel-content\">\n\t\t\t\t\t\t\t<ListView dropZoneElement={ dropZoneElement } />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tabpanel\"\n\t\t\t\t\ttabId=\"outline\"\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-container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AS,GAEbpD,EAAE,CAAE,SAAS,EAAE,eAAgB,CACxB,CACG,CACV,CAAC,EAENuC,aAAA,CAAC/B,IAAI,CAAC6C,QAAQ;MACbX,GAAG,EAAGf,oBAAsB;MAC5Ba,SAAS,EAAC,yCAAyC;MACnDY,KAAK,EAAC,WAAW;MACjBE,SAAS,EAAG;IAAO,GAEnBf,aAAA;MAAKC,SAAS,EAAC;IAA+C,GAC7DD,aAAA;MAAKC,SAAS,EAAC;IAAmD,GACjED,aAAA,CAACpD,QAAQ;MAACiC,eAAe,EAAGA;IAAiB,CAAE,CAC3C,CACD,CACS,CAAC,EAChBmB,aAAA,CAAC/B,IAAI,CAAC6C,QAAQ;MACbb,SAAS,EAAC,yCAAyC;MACnDY,KAAK,EAAC,SAAS;MACfE,SAAS,EAAG;IAAO,GAEnBf,aAAA;MAAKC,SAAS,EAAC;IAA+C,GAC7DD,aAAA,CAACnC,eAAe,MAAE,CACd,CACS,CACV,CACF;EAAC;AAER"}
|
|
@@ -3,73 +3,25 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { debounce } from '@wordpress/compose';
|
|
6
|
-
import { useState
|
|
7
|
-
import {
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { ComboboxControl } from '@wordpress/components';
|
|
10
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
11
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Internal dependencies
|
|
15
13
|
*/
|
|
16
14
|
import { store as editorStore } from '../../store';
|
|
17
|
-
import {
|
|
18
|
-
function PostAuthorCombobox() {
|
|
15
|
+
import { useAuthorsQuery } from './hook';
|
|
16
|
+
export default function PostAuthorCombobox() {
|
|
19
17
|
const [fieldValue, setFieldValue] = useState();
|
|
20
|
-
const {
|
|
21
|
-
authorId,
|
|
22
|
-
isLoading,
|
|
23
|
-
authors,
|
|
24
|
-
postAuthor
|
|
25
|
-
} = useSelect(select => {
|
|
26
|
-
const {
|
|
27
|
-
getUser,
|
|
28
|
-
getUsers,
|
|
29
|
-
isResolving
|
|
30
|
-
} = select(coreStore);
|
|
31
|
-
const {
|
|
32
|
-
getEditedPostAttribute
|
|
33
|
-
} = select(editorStore);
|
|
34
|
-
const author = getUser(getEditedPostAttribute('author'), {
|
|
35
|
-
context: 'view'
|
|
36
|
-
});
|
|
37
|
-
const query = {
|
|
38
|
-
...AUTHORS_QUERY
|
|
39
|
-
};
|
|
40
|
-
if (fieldValue) {
|
|
41
|
-
query.search = fieldValue;
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
authorId: getEditedPostAttribute('author'),
|
|
45
|
-
postAuthor: author,
|
|
46
|
-
authors: getUsers(query),
|
|
47
|
-
isLoading: isResolving('core', 'getUsers', [query])
|
|
48
|
-
};
|
|
49
|
-
}, [fieldValue]);
|
|
50
18
|
const {
|
|
51
19
|
editPost
|
|
52
20
|
} = useDispatch(editorStore);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
label: decodeEntities(author.name)
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// Ensure the current author is included in the dropdown list.
|
|
62
|
-
const foundAuthor = fetchedAuthors.findIndex(({
|
|
63
|
-
value
|
|
64
|
-
}) => postAuthor?.id === value);
|
|
65
|
-
if (foundAuthor < 0 && postAuthor) {
|
|
66
|
-
return [{
|
|
67
|
-
value: postAuthor.id,
|
|
68
|
-
label: decodeEntities(postAuthor.name)
|
|
69
|
-
}, ...fetchedAuthors];
|
|
70
|
-
}
|
|
71
|
-
return fetchedAuthors;
|
|
72
|
-
}, [authors, postAuthor]);
|
|
21
|
+
const {
|
|
22
|
+
authorId,
|
|
23
|
+
authorOptions
|
|
24
|
+
} = useAuthorsQuery(fieldValue);
|
|
73
25
|
|
|
74
26
|
/**
|
|
75
27
|
* Handle author selection.
|
|
@@ -93,9 +45,6 @@ function PostAuthorCombobox() {
|
|
|
93
45
|
const handleKeydown = inputValue => {
|
|
94
46
|
setFieldValue(inputValue);
|
|
95
47
|
};
|
|
96
|
-
if (!postAuthor) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
48
|
return createElement(ComboboxControl, {
|
|
100
49
|
__nextHasNoMarginBottom: true,
|
|
101
50
|
__next40pxDefaultSize: true,
|
|
@@ -104,9 +53,7 @@ function PostAuthorCombobox() {
|
|
|
104
53
|
value: authorId,
|
|
105
54
|
onFilterValueChange: debounce(handleKeydown, 300),
|
|
106
55
|
onChange: handleSelect,
|
|
107
|
-
isLoading: isLoading,
|
|
108
56
|
allowReset: false
|
|
109
57
|
});
|
|
110
58
|
}
|
|
111
|
-
export default PostAuthorCombobox;
|
|
112
59
|
//# sourceMappingURL=combobox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["debounce","useState","
|
|
1
|
+
{"version":3,"names":["debounce","useState","useDispatch","__","ComboboxControl","store","editorStore","useAuthorsQuery","PostAuthorCombobox","fieldValue","setFieldValue","editPost","authorId","authorOptions","handleSelect","postAuthorId","author","handleKeydown","inputValue","createElement","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onFilterValueChange","onChange","allowReset"],"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery( fieldValue );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tallowReset={ false }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,uBAAuB;;AAEvD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,SAASC,eAAe,QAAQ,QAAQ;AAExC,eAAe,SAASC,kBAAkBA,CAAA,EAAG;EAC5C,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAGT,QAAQ,CAAC,CAAC;EAEhD,MAAM;IAAEU;EAAS,CAAC,GAAGT,WAAW,CAAEI,WAAY,CAAC;EAC/C,MAAM;IAAEM,QAAQ;IAAEC;EAAc,CAAC,GAAGN,eAAe,CAAEE,UAAW,CAAC;;EAEjE;AACD;AACA;AACA;AACA;EACC,MAAMK,YAAY,GAAKC,YAAY,IAAM;IACxC,IAAK,CAAEA,YAAY,EAAG;MACrB;IACD;IACAJ,QAAQ,CAAE;MAAEK,MAAM,EAAED;IAAa,CAAE,CAAC;EACrC,CAAC;;EAED;AACD;AACA;AACA;AACA;EACC,MAAME,aAAa,GAAKC,UAAU,IAAM;IACvCR,aAAa,CAAEQ,UAAW,CAAC;EAC5B,CAAC;EAED,OACCC,aAAA,CAACf,eAAe;IACfgB,uBAAuB;IACvBC,qBAAqB;IACrBC,KAAK,EAAGnB,EAAE,CAAE,QAAS,CAAG;IACxBoB,OAAO,EAAGV,aAAe;IACzBW,KAAK,EAAGZ,QAAU;IAClBa,mBAAmB,EAAGzB,QAAQ,CAAEiB,aAAa,EAAE,GAAI,CAAG;IACtDS,QAAQ,EAAGZ,YAAc;IACzBa,UAAU,EAAG;EAAO,CACpB,CAAC;AAEJ"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export const BASE_QUERY = {
|
|
2
|
+
_fields: 'id,name',
|
|
3
|
+
context: 'view' // Allows non-admins to perform requests.
|
|
4
|
+
};
|
|
1
5
|
export const AUTHORS_QUERY = {
|
|
2
6
|
who: 'authors',
|
|
3
7
|
per_page: 50,
|
|
4
|
-
|
|
5
|
-
context: 'view' // Allows non-admins to perform requests.
|
|
8
|
+
...BASE_QUERY
|
|
6
9
|
};
|
|
7
10
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BASE_QUERY","_fields","context","AUTHORS_QUERY","who","per_page"],"sources":["@wordpress/editor/src/components/post-author/constants.js"],"sourcesContent":["export const BASE_QUERY = {\n\t_fields: 'id,name',\n\tcontext: 'view', // Allows non-admins to perform requests.\n};\n\nexport const AUTHORS_QUERY = {\n\twho: 'authors',\n\tper_page: 50,\n\t...BASE_QUERY,\n};\n"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAG;EACzBC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,MAAM,CAAE;AAClB,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC5BC,GAAG,EAAE,SAAS;EACdC,QAAQ,EAAE,EAAE;EACZ,GAAGL;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
export function useAuthorsQuery(search) {
|
|
15
|
+
const {
|
|
16
|
+
authorId,
|
|
17
|
+
authors,
|
|
18
|
+
postAuthor
|
|
19
|
+
} = useSelect(select => {
|
|
20
|
+
const {
|
|
21
|
+
getUser,
|
|
22
|
+
getUsers
|
|
23
|
+
} = select(coreStore);
|
|
24
|
+
const {
|
|
25
|
+
getEditedPostAttribute
|
|
26
|
+
} = select(editorStore);
|
|
27
|
+
const _authorId = getEditedPostAttribute('author');
|
|
28
|
+
const query = {
|
|
29
|
+
...AUTHORS_QUERY
|
|
30
|
+
};
|
|
31
|
+
if (search) {
|
|
32
|
+
query.search = search;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
authorId: _authorId,
|
|
36
|
+
authors: getUsers(query),
|
|
37
|
+
postAuthor: getUser(_authorId, BASE_QUERY)
|
|
38
|
+
};
|
|
39
|
+
}, [search]);
|
|
40
|
+
const authorOptions = useMemo(() => {
|
|
41
|
+
const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
|
|
42
|
+
return {
|
|
43
|
+
value: author.id,
|
|
44
|
+
label: decodeEntities(author.name)
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Ensure the current author is included in the dropdown list.
|
|
49
|
+
const foundAuthor = fetchedAuthors.findIndex(({
|
|
50
|
+
value
|
|
51
|
+
}) => postAuthor?.id === value);
|
|
52
|
+
if (foundAuthor < 0 && postAuthor) {
|
|
53
|
+
return [{
|
|
54
|
+
value: postAuthor.id,
|
|
55
|
+
label: decodeEntities(postAuthor.name)
|
|
56
|
+
}, ...fetchedAuthors];
|
|
57
|
+
}
|
|
58
|
+
return fetchedAuthors;
|
|
59
|
+
}, [authors, postAuthor]);
|
|
60
|
+
return {
|
|
61
|
+
authorId,
|
|
62
|
+
authorOptions
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useSelect","decodeEntities","store","coreStore","editorStore","AUTHORS_QUERY","BASE_QUERY","useAuthorsQuery","search","authorId","authors","postAuthor","select","getUser","getUsers","getEditedPostAttribute","_authorId","query","authorOptions","fetchedAuthors","map","author","value","id","label","name","foundAuthor","findIndex"],"sources":["@wordpress/editor/src/components/post-author/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY, BASE_QUERY } from './constants';\n\nexport function useAuthorsQuery( search ) {\n\tconst { authorId, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst _authorId = getEditedPostAttribute( 'author' );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: _authorId,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tpostAuthor: getUser( _authorId, BASE_QUERY ),\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\tconst authorOptions = useMemo( () => {\n\t\tconst fetchedAuthors = ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\n\t\t// Ensure the current author is included in the dropdown list.\n\t\tconst foundAuthor = fetchedAuthors.findIndex(\n\t\t\t( { value } ) => postAuthor?.id === value\n\t\t);\n\n\t\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tvalue: postAuthor.id,\n\t\t\t\t\tlabel: decodeEntities( postAuthor.name ),\n\t\t\t\t},\n\t\t\t\t...fetchedAuthors,\n\t\t\t];\n\t\t}\n\n\t\treturn fetchedAuthors;\n\t}, [ authors, postAuthor ] );\n\n\treturn { authorId, authorOptions };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,SAASC,aAAa,EAAEC,UAAU,QAAQ,aAAa;AAEvD,OAAO,SAASC,eAAeA,CAAEC,MAAM,EAAG;EACzC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGX,SAAS,CAChDY,MAAM,IAAM;IACb,MAAM;MAAEC,OAAO;MAAEC;IAAS,CAAC,GAAGF,MAAM,CAAET,SAAU,CAAC;IACjD,MAAM;MAAEY;IAAuB,CAAC,GAAGH,MAAM,CAAER,WAAY,CAAC;IACxD,MAAMY,SAAS,GAAGD,sBAAsB,CAAE,QAAS,CAAC;IACpD,MAAME,KAAK,GAAG;MAAE,GAAGZ;IAAc,CAAC;IAElC,IAAKG,MAAM,EAAG;MACbS,KAAK,CAACT,MAAM,GAAGA,MAAM;IACtB;IAEA,OAAO;MACNC,QAAQ,EAAEO,SAAS;MACnBN,OAAO,EAAEI,QAAQ,CAAEG,KAAM,CAAC;MAC1BN,UAAU,EAAEE,OAAO,CAAEG,SAAS,EAAEV,UAAW;IAC5C,CAAC;EACF,CAAC,EACD,CAAEE,MAAM,CACT,CAAC;EAED,MAAMU,aAAa,GAAGnB,OAAO,CAAE,MAAM;IACpC,MAAMoB,cAAc,GAAG,CAAET,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE,EAAGU,GAAG,CAAIC,MAAM,IAAM;MAC3D,OAAO;QACNC,KAAK,EAAED,MAAM,CAACE,EAAE;QAChBC,KAAK,EAAEvB,cAAc,CAAEoB,MAAM,CAACI,IAAK;MACpC,CAAC;IACF,CAAE,CAAC;;IAEH;IACA,MAAMC,WAAW,GAAGP,cAAc,CAACQ,SAAS,CAC3C,CAAE;MAAEL;IAAM,CAAC,KAAMX,UAAU,EAAEY,EAAE,KAAKD,KACrC,CAAC;IAED,IAAKI,WAAW,GAAG,CAAC,IAAIf,UAAU,EAAG;MACpC,OAAO,CACN;QACCW,KAAK,EAAEX,UAAU,CAACY,EAAE;QACpBC,KAAK,EAAEvB,cAAc,CAAEU,UAAU,CAACc,IAAK;MACxC,CAAC,EACD,GAAGN,cAAc,CACjB;IACF;IAEA,OAAOA,cAAc;EACtB,CAAC,EAAE,CAAET,OAAO,EAAEC,UAAU,CAAG,CAAC;EAE5B,OAAO;IAAEF,QAAQ;IAAES;EAAc,CAAC;AACnC"}
|
|
@@ -3,38 +3,22 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
7
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
6
|
+
import { useDispatch } from '@wordpress/data';
|
|
9
7
|
import { SelectControl } from '@wordpress/components';
|
|
10
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
10
|
* Internal dependencies
|
|
14
11
|
*/
|
|
15
12
|
import { store as editorStore } from '../../store';
|
|
16
|
-
import {
|
|
17
|
-
function PostAuthorSelect() {
|
|
13
|
+
import { useAuthorsQuery } from './hook';
|
|
14
|
+
export default function PostAuthorSelect() {
|
|
18
15
|
const {
|
|
19
16
|
editPost
|
|
20
17
|
} = useDispatch(editorStore);
|
|
21
18
|
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} =
|
|
25
|
-
return {
|
|
26
|
-
postAuthor: select(editorStore).getEditedPostAttribute('author'),
|
|
27
|
-
authors: select(coreStore).getUsers(AUTHORS_QUERY)
|
|
28
|
-
};
|
|
29
|
-
}, []);
|
|
30
|
-
const authorOptions = useMemo(() => {
|
|
31
|
-
return (authors !== null && authors !== void 0 ? authors : []).map(author => {
|
|
32
|
-
return {
|
|
33
|
-
value: author.id,
|
|
34
|
-
label: decodeEntities(author.name)
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
}, [authors]);
|
|
19
|
+
authorId,
|
|
20
|
+
authorOptions
|
|
21
|
+
} = useAuthorsQuery();
|
|
38
22
|
const setAuthorId = value => {
|
|
39
23
|
const author = Number(value);
|
|
40
24
|
editPost({
|
|
@@ -48,8 +32,7 @@ function PostAuthorSelect() {
|
|
|
48
32
|
label: __('Author'),
|
|
49
33
|
options: authorOptions,
|
|
50
34
|
onChange: setAuthorId,
|
|
51
|
-
value:
|
|
35
|
+
value: authorId
|
|
52
36
|
});
|
|
53
37
|
}
|
|
54
|
-
export default PostAuthorSelect;
|
|
55
38
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","
|
|
1
|
+
{"version":3,"names":["__","useDispatch","SelectControl","store","editorStore","useAuthorsQuery","PostAuthorSelect","editPost","authorId","authorOptions","setAuthorId","value","author","Number","createElement","__next40pxDefaultSize","__nextHasNoMarginBottom","className","label","options","onChange"],"sources":["@wordpress/editor/src/components/post-author/select.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { SelectControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery();\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ authorId }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,aAAa,QAAQ,uBAAuB;;AAErD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,SAASC,eAAe,QAAQ,QAAQ;AAExC,eAAe,SAASC,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC;EAAS,CAAC,GAAGN,WAAW,CAAEG,WAAY,CAAC;EAC/C,MAAM;IAAEI,QAAQ;IAAEC;EAAc,CAAC,GAAGJ,eAAe,CAAC,CAAC;EAErD,MAAMK,WAAW,GAAKC,KAAK,IAAM;IAChC,MAAMC,MAAM,GAAGC,MAAM,CAAEF,KAAM,CAAC;IAC9BJ,QAAQ,CAAE;MAAEK;IAAO,CAAE,CAAC;EACvB,CAAC;EAED,OACCE,aAAA,CAACZ,aAAa;IACba,qBAAqB;IACrBC,uBAAuB;IACvBC,SAAS,EAAC,sBAAsB;IAChCC,KAAK,EAAGlB,EAAE,CAAE,QAAS,CAAG;IACxBmB,OAAO,EAAGV,aAAe;IACzBW,QAAQ,EAAGV,WAAa;IACxBC,KAAK,EAAGH;EAAU,CAClB,CAAC;AAEJ"}
|
|
@@ -2,7 +2,7 @@ import { createElement } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { sprintf,
|
|
5
|
+
import { sprintf, __ } from '@wordpress/i18n';
|
|
6
6
|
import { Button } from '@wordpress/components';
|
|
7
7
|
import { useSelect } from '@wordpress/data';
|
|
8
8
|
import { backup } from '@wordpress/icons';
|
|
@@ -32,9 +32,11 @@ function LastRevision() {
|
|
|
32
32
|
revision: lastRevisionId
|
|
33
33
|
}),
|
|
34
34
|
className: "editor-post-last-revision__title",
|
|
35
|
-
icon: backup
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
icon: backup,
|
|
36
|
+
iconPosition: "right",
|
|
37
|
+
text: sprintf( /* translators: %s: number of revisions */
|
|
38
|
+
__('Revisions (%s)'), revisionsCount)
|
|
39
|
+
}));
|
|
38
40
|
}
|
|
39
41
|
export default LastRevision;
|
|
40
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["sprintf","
|
|
1
|
+
{"version":3,"names":["sprintf","__","Button","useSelect","backup","addQueryArgs","PostLastRevisionCheck","store","editorStore","LastRevision","lastRevisionId","revisionsCount","select","getCurrentPostLastRevisionId","getCurrentPostRevisionsCount","createElement","href","revision","className","icon","iconPosition","text"],"sources":["@wordpress/editor/src/components/post-last-revision/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostLastRevisionCheck from './check';\nimport { store as editorStore } from '../../store';\n\nfunction LastRevision() {\n\tconst { lastRevisionId, revisionsCount } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tlastRevisionId: getCurrentPostLastRevisionId(),\n\t\t\trevisionsCount: getCurrentPostRevisionsCount(),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<Button\n\t\t\t\thref={ addQueryArgs( 'revision.php', {\n\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t} ) }\n\t\t\t\tclassName=\"editor-post-last-revision__title\"\n\t\t\t\ticon={ backup }\n\t\t\t\ticonPosition=\"right\"\n\t\t\t\ttext={ sprintf(\n\t\t\t\t\t/* translators: %s: number of revisions */\n\t\t\t\t\t__( 'Revisions (%s)' ),\n\t\t\t\t\trevisionsCount\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostLastRevisionCheck>\n\t);\n}\n\nexport default LastRevision;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,SAAS;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,SAASC,YAAYA,CAAA,EAAG;EACvB,MAAM;IAAEC,cAAc;IAAEC;EAAe,CAAC,GAAGR,SAAS,CAAIS,MAAM,IAAM;IACnE,MAAM;MAAEC,4BAA4B;MAAEC;IAA6B,CAAC,GACnEF,MAAM,CAAEJ,WAAY,CAAC;IACtB,OAAO;MACNE,cAAc,EAAEG,4BAA4B,CAAC,CAAC;MAC9CF,cAAc,EAAEG,4BAA4B,CAAC;IAC9C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OACCC,aAAA,CAACT,qBAAqB,QACrBS,aAAA,CAACb,MAAM;IACNc,IAAI,EAAGX,YAAY,CAAE,cAAc,EAAE;MACpCY,QAAQ,EAAEP;IACX,CAAE,CAAG;IACLQ,SAAS,EAAC,kCAAkC;IAC5CC,IAAI,EAAGf,MAAQ;IACfgB,YAAY,EAAC,OAAO;IACpBC,IAAI,EAAGrB,OAAO,EACb;IACAC,EAAE,CAAE,gBAAiB,CAAC,EACtBU,cACD;EAAG,CACH,CACqB,CAAC;AAE1B;AAEA,eAAeF,YAAY"}
|