@wordpress/edit-site 5.22.0 → 5.23.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/components/actions/index.js +86 -4
- package/build/components/actions/index.js.map +1 -1
- package/build/components/add-new-template/new-template.js +0 -7
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +54 -63
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/dataviews/add-filter.js +90 -0
- package/build/components/dataviews/add-filter.js.map +1 -0
- package/build/components/dataviews/dataviews.js +23 -4
- package/build/components/dataviews/dataviews.js.map +1 -1
- package/build/components/dataviews/filters.js +36 -32
- package/build/components/dataviews/filters.js.map +1 -1
- package/build/components/dataviews/in-filter.js +22 -20
- package/build/components/dataviews/in-filter.js.map +1 -1
- package/build/components/dataviews/index.js +9 -2
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews/item-actions.js +81 -13
- package/build/components/dataviews/item-actions.js.map +1 -1
- package/build/components/dataviews/pagination.js +3 -2
- package/build/components/dataviews/pagination.js.map +1 -1
- package/build/components/dataviews/reset-filters.js +33 -0
- package/build/components/dataviews/reset-filters.js.map +1 -0
- package/build/components/dataviews/search.js +1 -0
- package/build/components/dataviews/search.js.map +1 -1
- package/build/components/dataviews/view-actions.js +27 -10
- package/build/components/dataviews/view-actions.js.map +1 -1
- package/build/components/dataviews/view-list.js +126 -5
- package/build/components/dataviews/view-list.js.map +1 -1
- package/build/components/dataviews/view-side-by-side.js +20 -0
- package/build/components/dataviews/view-side-by-side.js.map +1 -0
- package/build/components/editor/index.js +53 -53
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +42 -21
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-root.js +3 -3
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/ui.js +3 -3
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +1 -1
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/document-tools/index.js +160 -0
- package/build/components/header-edit-mode/document-tools/index.js.map +1 -0
- package/build/components/header-edit-mode/index.js +48 -116
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/site-export.js +2 -6
- package/build/components/header-edit-mode/more-menu/site-export.js.map +1 -1
- package/build/components/layout/index.js +4 -19
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +1 -0
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/page-content-focus-manager/back-to-page-notification.js +5 -10
- package/build/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +36 -23
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/page-main/index.js +2 -1
- package/build/components/page-main/index.js.map +1 -1
- package/build/components/page-pages/index.js +133 -78
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-pages/side-editor.js +25 -0
- package/build/components/page-pages/side-editor.js.map +1 -0
- package/build/components/page-patterns/grid-item.js +2 -2
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +3 -3
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +1 -1
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/dataviews-templates.js +201 -0
- package/build/components/page-templates/dataviews-templates.js.map +1 -0
- package/build/components/page-templates/template-actions.js +168 -0
- package/build/components/page-templates/template-actions.js.map +1 -0
- package/build/components/sidebar/index.js +1 -2
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +124 -0
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -0
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +189 -0
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -0
- package/build/components/sidebar-dataviews/dataview-item.js +71 -0
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -0
- package/build/components/sidebar-dataviews/default-views.js +60 -0
- package/build/components/sidebar-dataviews/default-views.js.map +1 -0
- package/build/components/sidebar-dataviews/index.js +21 -38
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/default-sidebar.js +2 -6
- package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js +11 -11
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +2 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +4 -12
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js +4 -12
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -1
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js +2 -6
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/hooks.js +3 -3
- package/build/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/page-details.js +3 -11
- package/build/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build/components/site-hub/index.js +18 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/start-template-options/index.js +12 -16
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +112 -49
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/template-part-converter/convert-to-regular.js +1 -1
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +3 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +6 -2
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +0 -3
- package/build/index.js.map +1 -1
- package/build/store/actions.js +35 -82
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +25 -63
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +3 -3
- package/build/utils/constants.js.map +1 -1
- package/build-module/components/actions/index.js +85 -5
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +0 -7
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +54 -62
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/dataviews/add-filter.js +83 -0
- package/build-module/components/dataviews/add-filter.js.map +1 -0
- package/build-module/components/dataviews/dataviews.js +22 -4
- package/build-module/components/dataviews/dataviews.js.map +1 -1
- package/build-module/components/dataviews/filters.js +34 -32
- package/build-module/components/dataviews/filters.js.map +1 -1
- package/build-module/components/dataviews/in-filter.js +20 -19
- package/build-module/components/dataviews/in-filter.js.map +1 -1
- package/build-module/components/dataviews/index.js +1 -1
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews/item-actions.js +84 -16
- package/build-module/components/dataviews/item-actions.js.map +1 -1
- package/build-module/components/dataviews/pagination.js +3 -2
- package/build-module/components/dataviews/pagination.js.map +1 -1
- package/build-module/components/dataviews/reset-filters.js +26 -0
- package/build-module/components/dataviews/reset-filters.js.map +1 -0
- package/build-module/components/dataviews/search.js +1 -0
- package/build-module/components/dataviews/search.js.map +1 -1
- package/build-module/components/dataviews/view-actions.js +28 -11
- package/build-module/components/dataviews/view-actions.js.map +1 -1
- package/build-module/components/dataviews/view-list.js +128 -7
- package/build-module/components/dataviews/view-list.js.map +1 -1
- package/build-module/components/dataviews/view-side-by-side.js +12 -0
- package/build-module/components/dataviews/view-side-by-side.js.map +1 -0
- package/build-module/components/editor/index.js +57 -57
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +42 -21
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +3 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/ui.js +3 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +1 -1
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/document-tools/index.js +152 -0
- package/build-module/components/header-edit-mode/document-tools/index.js.map +1 -0
- package/build-module/components/header-edit-mode/index.js +52 -120
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/site-export.js +2 -6
- package/build-module/components/header-edit-mode/more-menu/site-export.js.map +1 -1
- package/build-module/components/layout/index.js +5 -20
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +1 -1
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js +5 -10
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +36 -23
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/page-main/index.js +2 -1
- package/build-module/components/page-main/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +137 -80
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-pages/side-editor.js +17 -0
- package/build-module/components/page-pages/side-editor.js.map +1 -0
- package/build-module/components/page-patterns/grid-item.js +2 -2
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +4 -4
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +2 -2
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/dataviews-templates.js +193 -0
- package/build-module/components/page-templates/dataviews-templates.js.map +1 -0
- package/build-module/components/page-templates/template-actions.js +157 -0
- package/build-module/components/page-templates/template-actions.js.map +1 -0
- package/build-module/components/sidebar/index.js +1 -2
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +116 -0
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -0
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +180 -0
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -0
- package/build-module/components/sidebar-dataviews/dataview-item.js +63 -0
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -0
- package/build-module/components/sidebar-dataviews/default-views.js +52 -0
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -0
- package/build-module/components/sidebar-dataviews/index.js +22 -39
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/default-sidebar.js +2 -6
- package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +12 -12
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +3 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +5 -13
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js +5 -13
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js +2 -6
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/hooks.js +4 -4
- package/build-module/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/page-details.js +3 -11
- package/build-module/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
- package/build-module/components/site-hub/index.js +19 -7
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +13 -16
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +112 -50
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-regular.js +1 -1
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +6 -2
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +0 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +33 -79
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +19 -58
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +1 -1
- package/build-module/utils/constants.js.map +1 -1
- package/build-style/style-rtl.css +69 -119
- package/build-style/style.css +69 -119
- package/package.json +41 -41
- package/src/components/actions/index.js +113 -5
- package/src/components/add-new-template/new-template.js +0 -5
- package/src/components/block-editor/style.scss +0 -87
- package/src/components/block-editor/use-site-editor-settings.js +68 -89
- package/src/components/dataviews/README.md +77 -83
- package/src/components/dataviews/add-filter.js +111 -0
- package/src/components/dataviews/dataviews.js +20 -2
- package/src/components/dataviews/filters.js +56 -49
- package/src/components/dataviews/in-filter.js +35 -17
- package/src/components/dataviews/index.js +1 -1
- package/src/components/dataviews/item-actions.js +95 -20
- package/src/components/dataviews/pagination.js +5 -4
- package/src/components/dataviews/reset-filters.js +26 -0
- package/src/components/dataviews/search.js +1 -0
- package/src/components/dataviews/style.scss +5 -1
- package/src/components/dataviews/view-actions.js +39 -9
- package/src/components/dataviews/view-list.js +174 -3
- package/src/components/dataviews/view-side-by-side.js +9 -0
- package/src/components/editor/index.js +149 -121
- package/src/components/global-styles/screen-revisions/index.js +52 -25
- package/src/components/global-styles/screen-root.js +2 -1
- package/src/components/global-styles/ui.js +1 -1
- package/src/components/global-styles-renderer/index.js +1 -1
- package/src/components/header-edit-mode/document-tools/index.js +201 -0
- package/src/components/header-edit-mode/index.js +86 -184
- package/src/components/header-edit-mode/more-menu/site-export.js +2 -6
- package/src/components/header-edit-mode/style.scss +35 -2
- package/src/components/layout/index.js +4 -11
- package/src/components/layout/style.scss +6 -18
- package/src/components/list/added-by.js +1 -1
- package/src/components/page-content-focus-manager/back-to-page-notification.js +4 -15
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +38 -33
- package/src/components/page-main/index.js +6 -1
- package/src/components/page-pages/index.js +162 -81
- package/src/components/page-pages/side-editor.js +14 -0
- package/src/components/page-patterns/grid-item.js +3 -3
- package/src/components/page-patterns/patterns-list.js +10 -4
- package/src/components/page-patterns/use-patterns.js +3 -2
- package/src/components/page-templates/dataviews-templates.js +224 -0
- package/src/components/page-templates/template-actions.js +209 -0
- package/src/components/sidebar/index.js +1 -2
- package/src/components/sidebar-dataviews/add-new-view.js +141 -0
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +227 -0
- package/src/components/sidebar-dataviews/dataview-item.js +67 -0
- package/src/components/sidebar-dataviews/default-views.js +54 -0
- package/src/components/sidebar-dataviews/index.js +36 -45
- package/src/components/sidebar-dataviews/style.scss +22 -0
- package/src/components/sidebar-edit-mode/default-sidebar.js +6 -6
- package/src/components/sidebar-edit-mode/page-panels/edit-template.js +14 -21
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +3 -0
- package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +10 -9
- package/src/components/sidebar-edit-mode/page-panels/style.scss +5 -0
- package/src/components/sidebar-edit-mode/page-panels/swap-template-button.js +10 -9
- package/src/components/sidebar-edit-mode/plugin-sidebar/index.js +6 -6
- package/src/components/sidebar-edit-mode/template-panel/hooks.js +11 -7
- package/src/components/sidebar-navigation-screen-global-styles/index.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
- package/src/components/sidebar-navigation-screen-page/page-details.js +4 -17
- package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -2
- package/src/components/site-hub/index.js +9 -8
- package/src/components/start-template-options/index.js +14 -12
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +117 -50
- package/src/components/template-part-converter/convert-to-regular.js +1 -1
- package/src/hooks/push-changes-to-global-styles/index.js +13 -6
- package/src/hooks/template-part-edit.js +4 -2
- package/src/index.js +0 -8
- package/src/store/actions.js +37 -95
- package/src/store/selectors.js +31 -91
- package/src/store/test/actions.js +11 -137
- package/src/store/test/selectors.js +0 -82
- package/src/style.scss +1 -0
- package/src/utils/constants.js +1 -1
- package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -77
- package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +0 -1
- package/build/components/block-editor/block-editor-provider/index.js +0 -31
- package/build/components/block-editor/block-editor-provider/index.js.map +0 -1
- package/build/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -110
- package/build/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +0 -1
- package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -84
- package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +0 -1
- package/build/components/block-editor/index.js +0 -30
- package/build/components/block-editor/index.js.map +0 -1
- package/build/components/page-pages/default-views.js +0 -62
- package/build/components/page-pages/default-views.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -69
- package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/index.js +0 -23
- package/build-module/components/block-editor/block-editor-provider/index.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -102
- package/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +0 -1
- package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -78
- package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +0 -1
- package/build-module/components/block-editor/index.js +0 -22
- package/build-module/components/block-editor/index.js.map +0 -1
- package/build-module/components/page-pages/default-views.js +0 -55
- package/build-module/components/page-pages/default-views.js.map +0 -1
- package/src/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -75
- package/src/components/block-editor/block-editor-provider/index.js +0 -29
- package/src/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -114
- package/src/components/block-editor/block-editor-provider/test/use-page-content-blocks.js +0 -116
- package/src/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -90
- package/src/components/block-editor/index.js +0 -28
- package/src/components/page-pages/default-views.js +0 -60
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useCallback, useRef } from '@wordpress/element';
|
|
6
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
7
|
+
import { ToolSelector, NavigableToolbar, store as blockEditorStore, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
8
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
|
+
import { _x, __ } from '@wordpress/i18n';
|
|
10
|
+
import { listView, plus, chevronUpDown } from '@wordpress/icons';
|
|
11
|
+
import { Button, ToolbarItem } from '@wordpress/components';
|
|
12
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import UndoButton from '../undo-redo/undo';
|
|
18
|
+
import RedoButton from '../undo-redo/redo';
|
|
19
|
+
import { store as editSiteStore } from '../../../store';
|
|
20
|
+
import { unlock } from '../../../lock-unlock';
|
|
21
|
+
const {
|
|
22
|
+
useShouldContextualToolbarShow
|
|
23
|
+
} = unlock(blockEditorPrivateApis);
|
|
24
|
+
const preventDefault = event => {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
};
|
|
27
|
+
export default function DocumentTools({
|
|
28
|
+
blockEditorMode,
|
|
29
|
+
hasFixedToolbar,
|
|
30
|
+
isDistractionFree,
|
|
31
|
+
showIconLabels,
|
|
32
|
+
setListViewToggleElement
|
|
33
|
+
}) {
|
|
34
|
+
const inserterButton = useRef();
|
|
35
|
+
const {
|
|
36
|
+
isInserterOpen,
|
|
37
|
+
isListViewOpen,
|
|
38
|
+
listViewShortcut,
|
|
39
|
+
isVisualMode
|
|
40
|
+
} = useSelect(select => {
|
|
41
|
+
const {
|
|
42
|
+
__experimentalGetPreviewDeviceType,
|
|
43
|
+
isInserterOpened,
|
|
44
|
+
isListViewOpened,
|
|
45
|
+
getEditorMode
|
|
46
|
+
} = select(editSiteStore);
|
|
47
|
+
const {
|
|
48
|
+
getShortcutRepresentation
|
|
49
|
+
} = select(keyboardShortcutsStore);
|
|
50
|
+
return {
|
|
51
|
+
deviceType: __experimentalGetPreviewDeviceType(),
|
|
52
|
+
isInserterOpen: isInserterOpened(),
|
|
53
|
+
isListViewOpen: isListViewOpened(),
|
|
54
|
+
listViewShortcut: getShortcutRepresentation('core/edit-site/toggle-list-view'),
|
|
55
|
+
isVisualMode: getEditorMode() === 'visual'
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
const {
|
|
59
|
+
__experimentalSetPreviewDeviceType: setPreviewDeviceType,
|
|
60
|
+
setIsInserterOpened,
|
|
61
|
+
setIsListViewOpened
|
|
62
|
+
} = useDispatch(editSiteStore);
|
|
63
|
+
const {
|
|
64
|
+
__unstableSetEditorMode
|
|
65
|
+
} = useDispatch(blockEditorStore);
|
|
66
|
+
const isLargeViewport = useViewportMatch('medium');
|
|
67
|
+
const toggleInserter = useCallback(() => {
|
|
68
|
+
if (isInserterOpen) {
|
|
69
|
+
// Focusing the inserter button should close the inserter popover.
|
|
70
|
+
// However, there are some cases it won't close when the focus is lost.
|
|
71
|
+
// See https://github.com/WordPress/gutenberg/issues/43090 for more details.
|
|
72
|
+
inserterButton.current.focus();
|
|
73
|
+
setIsInserterOpened(false);
|
|
74
|
+
} else {
|
|
75
|
+
setIsInserterOpened(true);
|
|
76
|
+
}
|
|
77
|
+
}, [isInserterOpen, setIsInserterOpened]);
|
|
78
|
+
const toggleListView = useCallback(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
|
|
79
|
+
const {
|
|
80
|
+
shouldShowContextualToolbar,
|
|
81
|
+
canFocusHiddenToolbar,
|
|
82
|
+
fixedToolbarCanBeFocused
|
|
83
|
+
} = useShouldContextualToolbarShow();
|
|
84
|
+
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
|
|
85
|
+
// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
|
|
86
|
+
const blockToolbarCanBeFocused = shouldShowContextualToolbar || canFocusHiddenToolbar || fixedToolbarCanBeFocused;
|
|
87
|
+
|
|
88
|
+
/* translators: button label text should, if possible, be under 16 characters. */
|
|
89
|
+
const longLabel = _x('Toggle block inserter', 'Generic label for block inserter button');
|
|
90
|
+
const shortLabel = !isInserterOpen ? __('Add') : __('Close');
|
|
91
|
+
const isZoomedOutViewExperimentEnabled = window?.__experimentalEnableZoomedOutView && isVisualMode;
|
|
92
|
+
const isZoomedOutView = blockEditorMode === 'zoom-out';
|
|
93
|
+
return createElement(NavigableToolbar, {
|
|
94
|
+
className: "edit-site-header-edit-mode__document-tools",
|
|
95
|
+
"aria-label": __('Document tools'),
|
|
96
|
+
shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused
|
|
97
|
+
}, createElement("div", {
|
|
98
|
+
className: "edit-site-header-edit-mode__toolbar"
|
|
99
|
+
}, !isDistractionFree && createElement(ToolbarItem, {
|
|
100
|
+
ref: inserterButton,
|
|
101
|
+
as: Button,
|
|
102
|
+
className: "edit-site-header-edit-mode__inserter-toggle",
|
|
103
|
+
variant: "primary",
|
|
104
|
+
isPressed: isInserterOpen,
|
|
105
|
+
onMouseDown: preventDefault,
|
|
106
|
+
onClick: toggleInserter,
|
|
107
|
+
disabled: !isVisualMode,
|
|
108
|
+
icon: plus,
|
|
109
|
+
label: showIconLabels ? shortLabel : longLabel,
|
|
110
|
+
showTooltip: !showIconLabels,
|
|
111
|
+
"aria-expanded": isInserterOpen
|
|
112
|
+
}), isLargeViewport && createElement(Fragment, null, !hasFixedToolbar && createElement(ToolbarItem, {
|
|
113
|
+
as: ToolSelector,
|
|
114
|
+
showTooltip: !showIconLabels,
|
|
115
|
+
variant: showIconLabels ? 'tertiary' : undefined,
|
|
116
|
+
disabled: !isVisualMode
|
|
117
|
+
}), createElement(ToolbarItem, {
|
|
118
|
+
as: UndoButton,
|
|
119
|
+
showTooltip: !showIconLabels,
|
|
120
|
+
variant: showIconLabels ? 'tertiary' : undefined
|
|
121
|
+
}), createElement(ToolbarItem, {
|
|
122
|
+
as: RedoButton,
|
|
123
|
+
showTooltip: !showIconLabels,
|
|
124
|
+
variant: showIconLabels ? 'tertiary' : undefined
|
|
125
|
+
}), !isDistractionFree && createElement(ToolbarItem, {
|
|
126
|
+
as: Button,
|
|
127
|
+
className: "edit-site-header-edit-mode__list-view-toggle",
|
|
128
|
+
disabled: !isVisualMode || isZoomedOutView,
|
|
129
|
+
icon: listView,
|
|
130
|
+
isPressed: isListViewOpen
|
|
131
|
+
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
132
|
+
label: __('List View'),
|
|
133
|
+
onClick: toggleListView,
|
|
134
|
+
ref: setListViewToggleElement,
|
|
135
|
+
shortcut: listViewShortcut,
|
|
136
|
+
showTooltip: !showIconLabels,
|
|
137
|
+
variant: showIconLabels ? 'tertiary' : undefined,
|
|
138
|
+
"aria-expanded": isListViewOpen
|
|
139
|
+
}), isZoomedOutViewExperimentEnabled && !isDistractionFree && !hasFixedToolbar && createElement(ToolbarItem, {
|
|
140
|
+
as: Button,
|
|
141
|
+
className: "edit-site-header-edit-mode__zoom-out-view-toggle",
|
|
142
|
+
icon: chevronUpDown,
|
|
143
|
+
isPressed: isZoomedOutView
|
|
144
|
+
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
145
|
+
label: __('Zoom-out View'),
|
|
146
|
+
onClick: () => {
|
|
147
|
+
setPreviewDeviceType('Desktop');
|
|
148
|
+
__unstableSetEditorMode(isZoomedOutView ? 'edit' : 'zoom-out');
|
|
149
|
+
}
|
|
150
|
+
}))));
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useViewportMatch","ToolSelector","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","useSelect","useDispatch","_x","__","listView","plus","chevronUpDown","Button","ToolbarItem","keyboardShortcutsStore","UndoButton","RedoButton","editSiteStore","unlock","useShouldContextualToolbarShow","preventDefault","event","DocumentTools","blockEditorMode","hasFixedToolbar","isDistractionFree","showIconLabels","setListViewToggleElement","inserterButton","isInserterOpen","isListViewOpen","listViewShortcut","isVisualMode","select","__experimentalGetPreviewDeviceType","isInserterOpened","isListViewOpened","getEditorMode","getShortcutRepresentation","deviceType","__experimentalSetPreviewDeviceType","setPreviewDeviceType","setIsInserterOpened","setIsListViewOpened","__unstableSetEditorMode","isLargeViewport","toggleInserter","current","focus","toggleListView","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","longLabel","shortLabel","isZoomedOutViewExperimentEnabled","window","__experimentalEnableZoomedOutView","isZoomedOutView","createElement","className","shouldUseKeyboardFocusShortcut","ref","as","variant","isPressed","onMouseDown","onClick","disabled","icon","label","showTooltip","Fragment","undefined","shortcut"],"sources":["@wordpress/edit-site/src/components/header-edit-mode/document-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tToolSelector,\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { _x, __ } from '@wordpress/i18n';\nimport { listView, plus, chevronUpDown } from '@wordpress/icons';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport { store as editSiteStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nexport default function DocumentTools( {\n\tblockEditorMode,\n\thasFixedToolbar,\n\tisDistractionFree,\n\tshowIconLabels,\n\tsetListViewToggleElement,\n} ) {\n\tconst inserterButton = useRef();\n\tconst { isInserterOpen, isListViewOpen, listViewShortcut, isVisualMode } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\t\tisInserterOpened,\n\t\t\t\tisListViewOpened,\n\t\t\t\tgetEditorMode,\n\t\t\t} = select( editSiteStore );\n\t\t\tconst { getShortcutRepresentation } = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t\t'core/edit-site/toggle-list-view'\n\t\t\t\t),\n\t\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\t};\n\t\t}, [] );\n\n\tconst {\n\t\t__experimentalSetPreviewDeviceType: setPreviewDeviceType,\n\t\tsetIsInserterOpened,\n\t\tsetIsListViewOpened,\n\t} = useDispatch( editSiteStore );\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpen, setIsInserterOpened ] );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpen ? __( 'Add' ) : __( 'Close' );\n\n\tconst isZoomedOutViewExperimentEnabled =\n\t\twindow?.__experimentalEnableZoomedOutView && isVisualMode;\n\tconst isZoomedOutView = blockEditorMode === 'zoom-out';\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-site-header-edit-mode__document-tools\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t>\n\t\t\t<div className=\"edit-site-header-edit-mode__toolbar\">\n\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-site-header-edit-mode__inserter-toggle\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\taria-expanded={ isInserterOpen }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ UndoButton }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ RedoButton }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-header-edit-mode__list-view-toggle\"\n\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode || isZoomedOutView }\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tref={ setListViewToggleElement }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isZoomedOutViewExperimentEnabled &&\n\t\t\t\t\t\t\t! isDistractionFree &&\n\t\t\t\t\t\t\t! hasFixedToolbar && (\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-header-edit-mode__zoom-out-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ chevronUpDown }\n\t\t\t\t\t\t\t\t\tisPressed={ isZoomedOutView }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Zoom-out View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetPreviewDeviceType( 'Desktop' );\n\t\t\t\t\t\t\t\t\t\t__unstableSetEditorMode(\n\t\t\t\t\t\t\t\t\t\t\tisZoomedOutView\n\t\t\t\t\t\t\t\t\t\t\t\t? 'edit'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'zoom-out'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SACCC,YAAY,EACZC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,QAAQ,EAAEC,IAAI,EAAEC,aAA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K,EAAG/D,EAAE,CAAE,WAAY,CAAG;IAC3B4D,OAAO,EAAGnB,cAAgB;IAC1Bc,GAAG,EAAGpC,wBAA0B;IAChCgD,QAAQ,EAAG5C,gBAAkB;IAC7ByC,WAAW,EAAG,CAAE9C,cAAgB;IAChCuC,OAAO,EACNvC,cAAc,GAAG,UAAU,GAAGgD,SAC9B;IACD,iBAAgB5C;EAAgB,CAChC,CACD,EACC0B,gCAAgC,IACjC,CAAE/B,iBAAiB,IACnB,CAAED,eAAe,IAChBoC,aAAA,CAAC/C,WAAW;IACXmD,EAAE,EAAGpD,MAAQ;IACbiD,SAAS,EAAC,kDAAkD;IAC5DS,IAAI,EAAG3D,aAAe;IACtBuD,SAAS,EAAGP;IACZ;IACAY,KAAK,EAAG/D,EAAE,CAAE,eAAgB,CAAG;IAC/B4D,OAAO,EAAGA,CAAA,KAAM;MACf3B,oBAAoB,CAAE,SAAU,CAAC;MACjCG,uBAAuB,CACtBe,eAAe,GACZ,MAAM,GACN,UACJ,CAAC;IACF;EAAG,CACH,CAEF,CAEC,CACY,CAAC;AAErB"}
|
|
@@ -7,16 +7,15 @@ import classnames from 'classnames';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { useCallback, useRef } from '@wordpress/element';
|
|
11
10
|
import { useViewportMatch, useReducedMotion } from '@wordpress/compose';
|
|
12
11
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
-
import {
|
|
12
|
+
import { __experimentalPreviewOptions as PreviewOptions, privateApis as blockEditorPrivateApis, store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
13
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
|
+
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
15
15
|
import { PinnedItems } from '@wordpress/interface';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { __unstableMotion as motion,
|
|
19
|
-
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
17
|
+
import { external, next, previous } from '@wordpress/icons';
|
|
18
|
+
import { Button, __unstableMotion as motion, MenuGroup, MenuItem, Popover, VisuallyHidden } from '@wordpress/components';
|
|
20
19
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -24,48 +23,36 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
24
23
|
*/
|
|
25
24
|
import MoreMenu from './more-menu';
|
|
26
25
|
import SaveButton from '../save-button';
|
|
27
|
-
import UndoButton from './undo-redo/undo';
|
|
28
|
-
import RedoButton from './undo-redo/redo';
|
|
29
26
|
import DocumentActions from './document-actions';
|
|
27
|
+
import DocumentTools from './document-tools';
|
|
30
28
|
import { store as editSiteStore } from '../../store';
|
|
31
29
|
import { getEditorCanvasContainerTitle, useHasEditorCanvasContainer } from '../editor-canvas-container';
|
|
32
30
|
import { unlock } from '../../lock-unlock';
|
|
33
31
|
import { FOCUSABLE_ENTITIES } from '../../utils/constants';
|
|
34
32
|
const {
|
|
35
|
-
|
|
33
|
+
BlockContextualToolbar
|
|
36
34
|
} = unlock(blockEditorPrivateApis);
|
|
37
|
-
const preventDefault = event => {
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
};
|
|
40
35
|
export default function HeaderEditMode({
|
|
41
36
|
setListViewToggleElement
|
|
42
37
|
}) {
|
|
43
|
-
const inserterButton = useRef();
|
|
44
38
|
const {
|
|
45
39
|
deviceType,
|
|
46
40
|
templateType,
|
|
47
|
-
isInserterOpen,
|
|
48
|
-
isListViewOpen,
|
|
49
|
-
listViewShortcut,
|
|
50
|
-
isVisualMode,
|
|
51
41
|
isDistractionFree,
|
|
52
42
|
blockEditorMode,
|
|
43
|
+
blockSelectionStart,
|
|
53
44
|
homeUrl,
|
|
54
45
|
showIconLabels,
|
|
55
46
|
editorCanvasView,
|
|
56
|
-
hasFixedToolbar
|
|
47
|
+
hasFixedToolbar,
|
|
48
|
+
isZoomOutMode
|
|
57
49
|
} = useSelect(select => {
|
|
58
50
|
const {
|
|
59
51
|
__experimentalGetPreviewDeviceType,
|
|
60
|
-
getEditedPostType
|
|
61
|
-
isInserterOpened,
|
|
62
|
-
isListViewOpened,
|
|
63
|
-
getEditorMode
|
|
52
|
+
getEditedPostType
|
|
64
53
|
} = select(editSiteStore);
|
|
65
54
|
const {
|
|
66
|
-
|
|
67
|
-
} = select(keyboardShortcutsStore);
|
|
68
|
-
const {
|
|
55
|
+
getBlockSelectionStart,
|
|
69
56
|
__unstableGetEditorMode
|
|
70
57
|
} = select(blockEditorStore);
|
|
71
58
|
const postType = getEditedPostType();
|
|
@@ -78,56 +65,34 @@ export default function HeaderEditMode({
|
|
|
78
65
|
return {
|
|
79
66
|
deviceType: __experimentalGetPreviewDeviceType(),
|
|
80
67
|
templateType: postType,
|
|
81
|
-
isInserterOpen: isInserterOpened(),
|
|
82
|
-
isListViewOpen: isListViewOpened(),
|
|
83
|
-
listViewShortcut: getShortcutRepresentation('core/edit-site/toggle-list-view'),
|
|
84
|
-
isVisualMode: getEditorMode() === 'visual',
|
|
85
68
|
blockEditorMode: __unstableGetEditorMode(),
|
|
69
|
+
blockSelectionStart: getBlockSelectionStart(),
|
|
86
70
|
homeUrl: getUnstableBase()?.home,
|
|
87
71
|
showIconLabels: getPreference(editSiteStore.name, 'showIconLabels'),
|
|
88
72
|
editorCanvasView: unlock(select(editSiteStore)).getEditorCanvasContainerView(),
|
|
73
|
+
hasFixedToolbar: getPreference(editSiteStore.name, 'fixedToolbar'),
|
|
89
74
|
isDistractionFree: getPreference(editSiteStore.name, 'distractionFree'),
|
|
90
|
-
|
|
75
|
+
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out'
|
|
91
76
|
};
|
|
92
77
|
}, []);
|
|
78
|
+
const isLargeViewport = useViewportMatch('medium');
|
|
79
|
+
const isTopToolbar = !isZoomOutMode && hasFixedToolbar && isLargeViewport;
|
|
80
|
+
const blockToolbarRef = useRef();
|
|
93
81
|
const {
|
|
94
|
-
__experimentalSetPreviewDeviceType: setPreviewDeviceType
|
|
95
|
-
setIsInserterOpened,
|
|
96
|
-
setIsListViewOpened
|
|
82
|
+
__experimentalSetPreviewDeviceType: setPreviewDeviceType
|
|
97
83
|
} = useDispatch(editSiteStore);
|
|
98
|
-
const {
|
|
99
|
-
__unstableSetEditorMode
|
|
100
|
-
} = useDispatch(blockEditorStore);
|
|
101
84
|
const disableMotion = useReducedMotion();
|
|
102
|
-
const isLargeViewport = useViewportMatch('medium');
|
|
103
|
-
const toggleInserter = useCallback(() => {
|
|
104
|
-
if (isInserterOpen) {
|
|
105
|
-
// Focusing the inserter button should close the inserter popover.
|
|
106
|
-
// However, there are some cases it won't close when the focus is lost.
|
|
107
|
-
// See https://github.com/WordPress/gutenberg/issues/43090 for more details.
|
|
108
|
-
inserterButton.current.focus();
|
|
109
|
-
setIsInserterOpened(false);
|
|
110
|
-
} else {
|
|
111
|
-
setIsInserterOpened(true);
|
|
112
|
-
}
|
|
113
|
-
}, [isInserterOpen, setIsInserterOpened]);
|
|
114
|
-
const toggleListView = useCallback(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
|
|
115
|
-
const {
|
|
116
|
-
shouldShowContextualToolbar,
|
|
117
|
-
canFocusHiddenToolbar,
|
|
118
|
-
fixedToolbarCanBeFocused
|
|
119
|
-
} = useShouldContextualToolbarShow();
|
|
120
|
-
// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
|
|
121
|
-
// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
|
|
122
|
-
const blockToolbarCanBeFocused = shouldShowContextualToolbar || canFocusHiddenToolbar || fixedToolbarCanBeFocused;
|
|
123
85
|
const hasDefaultEditorCanvasView = !useHasEditorCanvasContainer();
|
|
124
86
|
const isFocusMode = FOCUSABLE_ENTITIES.includes(templateType);
|
|
125
|
-
|
|
126
|
-
/* translators: button label text should, if possible, be under 16 characters. */
|
|
127
|
-
const longLabel = _x('Toggle block inserter', 'Generic label for block inserter button');
|
|
128
|
-
const shortLabel = !isInserterOpen ? __('Add') : __('Close');
|
|
129
|
-
const isZoomedOutViewExperimentEnabled = window?.__experimentalEnableZoomedOutView && isVisualMode;
|
|
130
87
|
const isZoomedOutView = blockEditorMode === 'zoom-out';
|
|
88
|
+
const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = useState(true);
|
|
89
|
+
const hasBlockSelected = !!blockSelectionStart;
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
// If we have a new block selection, show the block tools
|
|
92
|
+
if (blockSelectionStart) {
|
|
93
|
+
setIsBlockToolsCollapsed(false);
|
|
94
|
+
}
|
|
95
|
+
}, [blockSelectionStart]);
|
|
131
96
|
const toolbarVariants = {
|
|
132
97
|
isDistractionFree: {
|
|
133
98
|
y: '-50px'
|
|
@@ -151,68 +116,35 @@ export default function HeaderEditMode({
|
|
|
151
116
|
className: classnames('edit-site-header-edit-mode', {
|
|
152
117
|
'show-icon-labels': showIconLabels
|
|
153
118
|
})
|
|
154
|
-
}, hasDefaultEditorCanvasView && createElement(
|
|
155
|
-
as: motion.div,
|
|
119
|
+
}, hasDefaultEditorCanvasView && createElement(motion.div, {
|
|
156
120
|
className: "edit-site-header-edit-mode__start",
|
|
157
|
-
"aria-label": __('Document tools'),
|
|
158
|
-
shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused,
|
|
159
121
|
variants: toolbarVariants,
|
|
160
122
|
transition: toolbarTransition
|
|
161
|
-
}, createElement(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
showTooltip: !showIconLabels,
|
|
179
|
-
variant: showIconLabels ? 'tertiary' : undefined,
|
|
180
|
-
disabled: !isVisualMode
|
|
181
|
-
}), createElement(ToolbarItem, {
|
|
182
|
-
as: UndoButton,
|
|
183
|
-
showTooltip: !showIconLabels,
|
|
184
|
-
variant: showIconLabels ? 'tertiary' : undefined
|
|
185
|
-
}), createElement(ToolbarItem, {
|
|
186
|
-
as: RedoButton,
|
|
187
|
-
showTooltip: !showIconLabels,
|
|
188
|
-
variant: showIconLabels ? 'tertiary' : undefined
|
|
189
|
-
}), !isDistractionFree && createElement(ToolbarItem, {
|
|
190
|
-
as: Button,
|
|
191
|
-
className: "edit-site-header-edit-mode__list-view-toggle",
|
|
192
|
-
disabled: !isVisualMode || isZoomedOutView,
|
|
193
|
-
icon: listView,
|
|
194
|
-
isPressed: isListViewOpen
|
|
195
|
-
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
196
|
-
label: __('List View'),
|
|
197
|
-
onClick: toggleListView,
|
|
198
|
-
ref: setListViewToggleElement,
|
|
199
|
-
shortcut: listViewShortcut,
|
|
200
|
-
showTooltip: !showIconLabels,
|
|
201
|
-
variant: showIconLabels ? 'tertiary' : undefined,
|
|
202
|
-
"aria-expanded": isListViewOpen
|
|
203
|
-
}), isZoomedOutViewExperimentEnabled && !isDistractionFree && !hasFixedToolbar && createElement(ToolbarItem, {
|
|
204
|
-
as: Button,
|
|
205
|
-
className: "edit-site-header-edit-mode__zoom-out-view-toggle",
|
|
206
|
-
icon: chevronUpDown,
|
|
207
|
-
isPressed: isZoomedOutView
|
|
208
|
-
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
209
|
-
label: __('Zoom-out View'),
|
|
123
|
+
}, createElement(DocumentTools, {
|
|
124
|
+
blockEditorMode: blockEditorMode,
|
|
125
|
+
isDistractionFree: isDistractionFree,
|
|
126
|
+
showIconLabels: showIconLabels,
|
|
127
|
+
setListViewToggleElement: setListViewToggleElement
|
|
128
|
+
}), isTopToolbar && createElement(Fragment, null, createElement("div", {
|
|
129
|
+
className: classnames('selected-block-tools-wrapper', {
|
|
130
|
+
'is-collapsed': isBlockToolsCollapsed
|
|
131
|
+
})
|
|
132
|
+
}, createElement(BlockContextualToolbar, {
|
|
133
|
+
isFixed: true
|
|
134
|
+
})), createElement(Popover.Slot, {
|
|
135
|
+
ref: blockToolbarRef,
|
|
136
|
+
name: "block-toolbar"
|
|
137
|
+
}), hasBlockSelected && createElement(Button, {
|
|
138
|
+
className: "edit-site-header-edit-mode__block-tools-toggle",
|
|
139
|
+
icon: isBlockToolsCollapsed ? next : previous,
|
|
210
140
|
onClick: () => {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})))
|
|
215
|
-
className:
|
|
141
|
+
setIsBlockToolsCollapsed(collapsed => !collapsed);
|
|
142
|
+
},
|
|
143
|
+
label: isBlockToolsCollapsed ? __('Show block tools') : __('Hide block tools')
|
|
144
|
+
}))), !isDistractionFree && createElement("div", {
|
|
145
|
+
className: classnames('edit-site-header-edit-mode__center', {
|
|
146
|
+
'is-collapsed': !isBlockToolsCollapsed && isLargeViewport
|
|
147
|
+
})
|
|
216
148
|
}, !hasDefaultEditorCanvasView ? getEditorCanvasContainerTitle(editorCanvasView) : createElement(DocumentActions, null)), createElement("div", {
|
|
217
149
|
className: "edit-site-header-edit-mode__end"
|
|
218
150
|
}, createElement(motion.div, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useCallback","useRef","useViewportMatch","useReducedMotion","store","coreStore","ToolSelector","__experimentalPreviewOptions","PreviewOptions","NavigableToolbar","blockEditorStore","privateApis","blockEditorPrivateApis","useSelect","useDispatch","PinnedItems","_x","__","listView","plus","external","chevronUpDown","__unstableMotion","motion","Button","ToolbarItem","MenuGroup","MenuItem","VisuallyHidden","keyboardShortcutsStore","preferencesStore","MoreMenu","SaveButton","UndoButton","RedoButton","DocumentActions","editSiteStore","getEditorCanvasContainerTitle","useHasEditorCanvasContainer","unlock","FOCUSABLE_ENTITIES","useShouldContextualToolbarShow","preventDefault","event","HeaderEditMode","setListViewToggleElement","inserterButton","deviceType","templateType","isInserterOpen","isListViewOpen","listViewShortcut","isVisualMode","isDistractionFree","blockEditorMode","homeUrl","showIconLabels","editorCanvasView","hasFixedToolbar","select","__experimentalGetPreviewDeviceType","getEditedPostType","isInserterOpened","isListViewOpened","getEditorMode","getShortcutRepresentation","__unstableGetEditorMode","postType","getUnstableBase","get","getPreference","home","name","getEditorCanvasContainerView","__experimentalSetPreviewDeviceType","setPreviewDeviceType","setIsInserterOpened","setIsListViewOpened","__unstableSetEditorMode","disableMotion","isLargeViewport","toggleInserter","current","focus","toggleListView","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","hasDefaultEditorCanvasView","isFocusMode","includes","longLabel","shortLabel","isZoomedOutViewExperimentEnabled","window","__experimentalEnableZoomedOutView","isZoomedOutView","toolbarVariants","y","isDistractionFreeHovering","view","edit","toolbarTransition","type","duration","ease","createElement","className","as","div","shouldUseKeyboardFocusShortcut","variants","transition","ref","variant","isPressed","onMouseDown","onClick","disabled","icon","label","showTooltip","Fragment","undefined","shortcut","setDeviceType","isEnabled","onClose","href","target","Slot","scope"],"sources":["@wordpress/edit-site/src/components/header-edit-mode/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch, useReducedMotion } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tToolSelector,\n\t__experimentalPreviewOptions as PreviewOptions,\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { PinnedItems } from '@wordpress/interface';\nimport { _x, __ } from '@wordpress/i18n';\nimport { listView, plus, external, chevronUpDown } from '@wordpress/icons';\nimport {\n\t__unstableMotion as motion,\n\tButton,\n\tToolbarItem,\n\tMenuGroup,\n\tMenuItem,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport MoreMenu from './more-menu';\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport DocumentActions from './document-actions';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tgetEditorCanvasContainerTitle,\n\tuseHasEditorCanvasContainer,\n} from '../editor-canvas-container';\nimport { unlock } from '../../lock-unlock';\nimport { FOCUSABLE_ENTITIES } from '../../utils/constants';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nexport default function HeaderEditMode( { setListViewToggleElement } ) {\n\tconst inserterButton = useRef();\n\tconst {\n\t\tdeviceType,\n\t\ttemplateType,\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tisVisualMode,\n\t\tisDistractionFree,\n\t\tblockEditorMode,\n\t\thomeUrl,\n\t\tshowIconLabels,\n\t\teditorCanvasView,\n\t\thasFixedToolbar,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetEditedPostType,\n\t\t\tisInserterOpened,\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t} = select( editSiteStore );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\tconst postType = getEditedPostType();\n\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\tconst { get: getPreference } = select( preferencesStore );\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\ttemplateType: postType,\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-site/toggle-list-view'\n\t\t\t),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\tshowIconLabels: getPreference(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\teditorCanvasView: unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t).getEditorCanvasContainerView(),\n\t\t\tisDistractionFree: getPreference(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t\thasFixedToolbar: getPreference(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\t__experimentalSetPreviewDeviceType: setPreviewDeviceType,\n\t\tsetIsInserterOpened,\n\t\tsetIsListViewOpened,\n\t} = useDispatch( editSiteStore );\n\tconst { __unstableSetEditorMode } = useDispatch( blockEditorStore );\n\tconst disableMotion = useReducedMotion();\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpen, setIsInserterOpened ] );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\tconst hasDefaultEditorCanvasView = ! useHasEditorCanvasContainer();\n\n\tconst isFocusMode = FOCUSABLE_ENTITIES.includes( templateType );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpen ? __( 'Add' ) : __( 'Close' );\n\n\tconst isZoomedOutViewExperimentEnabled =\n\t\twindow?.__experimentalEnableZoomedOutView && isVisualMode;\n\tconst isZoomedOutView = blockEditorMode === 'zoom-out';\n\n\tconst toolbarVariants = {\n\t\tisDistractionFree: { y: '-50px' },\n\t\tisDistractionFreeHovering: { y: 0 },\n\t\tview: { y: 0 },\n\t\tedit: { y: 0 },\n\t};\n\n\tconst toolbarTransition = {\n\t\ttype: 'tween',\n\t\tduration: disableMotion ? 0 : 0.2,\n\t\tease: 'easeOut',\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-header-edit-mode', {\n\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ hasDefaultEditorCanvasView && (\n\t\t\t\t<NavigableToolbar\n\t\t\t\t\tas={ motion.div }\n\t\t\t\t\tclassName=\"edit-site-header-edit-mode__start\"\n\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t}\n\t\t\t\t\tvariants={ toolbarVariants }\n\t\t\t\t\ttransition={ toolbarTransition }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"edit-site-header-edit-mode__toolbar\">\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-header-edit-mode__inserter-toggle\"\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? shortLabel : longLabel\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\taria-expanded={ isInserterOpen }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ ! hasFixedToolbar && (\n\t\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\tshowIconLabels\n\t\t\t\t\t\t\t\t\t\t\t\t? 'tertiary'\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tdisabled={ ! isVisualMode }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ UndoButton }\n\t\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ RedoButton }\n\t\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-header-edit-mode__list-view-toggle\"\n\t\t\t\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\t\t\t\t! isVisualMode || isZoomedOutView\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t\t\tref={ setListViewToggleElement }\n\t\t\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\tshowIconLabels\n\t\t\t\t\t\t\t\t\t\t\t\t? 'tertiary'\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ isZoomedOutViewExperimentEnabled &&\n\t\t\t\t\t\t\t\t\t! isDistractionFree &&\n\t\t\t\t\t\t\t\t\t! hasFixedToolbar && (\n\t\t\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-header-edit-mode__zoom-out-view-toggle\"\n\t\t\t\t\t\t\t\t\t\t\ticon={ chevronUpDown }\n\t\t\t\t\t\t\t\t\t\t\tisPressed={ isZoomedOutView }\n\t\t\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Zoom-out View' ) }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tsetPreviewDeviceType(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Desktop'\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t__unstableSetEditorMode(\n\t\t\t\t\t\t\t\t\t\t\t\t\tisZoomedOutView\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'edit'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 'zoom-out'\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</NavigableToolbar>\n\t\t\t) }\n\n\t\t\t{ ! isDistractionFree && (\n\t\t\t\t<div className=\"edit-site-header-edit-mode__center\">\n\t\t\t\t\t{ ! hasDefaultEditorCanvasView ? (\n\t\t\t\t\t\tgetEditorCanvasContainerTitle( editorCanvasView )\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<DocumentActions />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t<div className=\"edit-site-header-edit-mode__end\">\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"edit-site-header-edit-mode__actions\"\n\t\t\t\t\tvariants={ toolbarVariants }\n\t\t\t\t\ttransition={ toolbarTransition }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-header-edit-mode__preview-options',\n\t\t\t\t\t\t\t{ 'is-zoomed-out': isZoomedOutView }\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PreviewOptions\n\t\t\t\t\t\t\tdeviceType={ deviceType }\n\t\t\t\t\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\t\t\t\t\tlabel={ __( 'View' ) }\n\t\t\t\t\t\t\tisEnabled={\n\t\t\t\t\t\t\t\t! isFocusMode && hasDefaultEditorCanvasView\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'View site' ) }\n\t\t\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</PreviewOptions>\n\t\t\t\t\t</div>\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t) }\n\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t</motion.div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,oBAAoB;AACvE,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,YAAY,EACZC,4BAA4B,IAAIC,cAAc,EAC9CC,gBAAgB,EAChBL,KAAK,IAAIM,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,QAAQ,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,kBAAkB;AAC1E,SACCC,gBAAgB,IAAIC,MAAM,EAC1BC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,cAAc,QACR,uBAAuB;AAC9B,SAASxB,KAAK,IAAIyB,sBAAsB,QAAQ,+BAA+B;AAC/E,SAASzB,KAAK,IAAI0B,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,OAAOC,eAAe,MAAM,oBAAoB;AAChD,SAAS/B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,EAAG7G,UAAU,CACrB,6CAA6C,EAC7C;MAAE,eAAe,EAAEkG;IAAgB,CACpC;EAAG,GAEHU,aAAA,CAACnG,cAAc;IACduC,UAAU,EAAGA,UAAY;IACzB+E,aAAa,EAAGnD,oBAAsB;IACtC8C,KAAK,EAAGxG,EAAE,CAAE,MAAO,CAAG;IACtB8G,SAAS,EACR,CAAErC,WAAW,IAAID;EACjB,GAEC,CAAE;IAAEuC;EAAQ,CAAC,KACdrB,aAAA,CAACjF,SAAS,QACTiF,aAAA,CAAChF,QAAQ;IACRsG,IAAI,EAAG1E,OAAS;IAChB2E,MAAM,EAAC,QAAQ;IACfV,IAAI,EAAGpG,QAAU;IACjBkG,OAAO,EAAGU;EAAS,GAEjB/G,EAAE,CAAE,WAAY,CAAC,EACnB0F,aAAA,CAAC/E,cAAc;IAACiF,EAAE,EAAC;EAAM,GAEvB;EACA5F,EAAE,CAAE,sBAAuB,CAEb,CACP,CACA,CAEG,CACZ,CAAC,EACN0F,aAAA,CAAC3E,UAAU,MAAE,CAAC,EACZ,CAAEqB,iBAAiB,IACpBsD,aAAA,CAAC5F,WAAW,CAACoH,IAAI;IAACC,KAAK,EAAC;EAAgB,CAAE,CAC1C,EACDzB,aAAA,CAAC5E,QAAQ;IAACyB,cAAc,EAAGA;EAAgB,CAAE,CAClC,CACR,CACD,CAAC;AAER"}
|
|
1
|
+
{"version":3,"names":["classnames","useViewportMatch","useReducedMotion","store","coreStore","__experimentalPreviewOptions","PreviewOptions","privateApis","blockEditorPrivateApis","blockEditorStore","useSelect","useDispatch","useEffect","useRef","useState","PinnedItems","__","external","next","previous","Button","__unstableMotion","motion","MenuGroup","MenuItem","Popover","VisuallyHidden","preferencesStore","MoreMenu","SaveButton","DocumentActions","DocumentTools","editSiteStore","getEditorCanvasContainerTitle","useHasEditorCanvasContainer","unlock","FOCUSABLE_ENTITIES","BlockContextualToolbar","HeaderEditMode","setListViewToggleElement","deviceType","templateType","isDistractionFree","blockEditorMode","blockSelectionStart","homeUrl","showIconLabels","editorCanvasView","hasFixedToolbar","isZoomOutMode","select","__experimentalGetPreviewDeviceType","getEditedPostType","getBlockSelectionStart","__unstableGetEditorMode","postType","getUnstableBase","get","getPreference","home","name","getEditorCanvasContainerView","isLargeViewport","isTopToolbar","blockToolbarRef","__experimentalSetPreviewDeviceType","setPreviewDeviceType","disableMotion","hasDefaultEditorCanvasView","isFocusMode","includes","isZoomedOutView","isBlockToolsCollapsed","setIsBlockToolsCollapsed","hasBlockSelected","toolbarVariants","y","isDistractionFreeHovering","view","edit","toolbarTransition","type","duration","ease","createElement","className","div","variants","transition","Fragment","isFixed","Slot","ref","icon","onClick","collapsed","label","setDeviceType","isEnabled","onClose","href","target","as","scope"],"sources":["@wordpress/edit-site/src/components/header-edit-mode/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useReducedMotion } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\t__experimentalPreviewOptions as PreviewOptions,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { external, next, previous } from '@wordpress/icons';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\tMenuGroup,\n\tMenuItem,\n\tPopover,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport MoreMenu from './more-menu';\nimport SaveButton from '../save-button';\nimport DocumentActions from './document-actions';\nimport DocumentTools from './document-tools';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tgetEditorCanvasContainerTitle,\n\tuseHasEditorCanvasContainer,\n} from '../editor-canvas-container';\nimport { unlock } from '../../lock-unlock';\nimport { FOCUSABLE_ENTITIES } from '../../utils/constants';\n\nconst { BlockContextualToolbar } = unlock( blockEditorPrivateApis );\n\nexport default function HeaderEditMode( { setListViewToggleElement } ) {\n\tconst {\n\t\tdeviceType,\n\t\ttemplateType,\n\t\tisDistractionFree,\n\t\tblockEditorMode,\n\t\tblockSelectionStart,\n\t\thomeUrl,\n\t\tshowIconLabels,\n\t\teditorCanvasView,\n\t\thasFixedToolbar,\n\t\tisZoomOutMode,\n\t} = useSelect( ( select ) => {\n\t\tconst { __experimentalGetPreviewDeviceType, getEditedPostType } =\n\t\t\tselect( editSiteStore );\n\t\tconst { getBlockSelectionStart, __unstableGetEditorMode } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst postType = getEditedPostType();\n\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\tconst { get: getPreference } = select( preferencesStore );\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\ttemplateType: postType,\n\t\t\tblockEditorMode: __unstableGetEditorMode(),\n\t\t\tblockSelectionStart: getBlockSelectionStart(),\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\tshowIconLabels: getPreference(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\teditorCanvasView: unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t).getEditorCanvasContainerView(),\n\t\t\thasFixedToolbar: getPreference(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tisDistractionFree: getPreference(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t\tisZoomOutMode: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTopToolbar = ! isZoomOutMode && hasFixedToolbar && isLargeViewport;\n\tconst blockToolbarRef = useRef();\n\n\tconst { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =\n\t\tuseDispatch( editSiteStore );\n\tconst disableMotion = useReducedMotion();\n\n\tconst hasDefaultEditorCanvasView = ! useHasEditorCanvasContainer();\n\n\tconst isFocusMode = FOCUSABLE_ENTITIES.includes( templateType );\n\n\tconst isZoomedOutView = blockEditorMode === 'zoom-out';\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasBlockSelected = !! blockSelectionStart;\n\n\tuseEffect( () => {\n\t\t// If we have a new block selection, show the block tools\n\t\tif ( blockSelectionStart ) {\n\t\t\tsetIsBlockToolsCollapsed( false );\n\t\t}\n\t}, [ blockSelectionStart ] );\n\n\tconst toolbarVariants = {\n\t\tisDistractionFree: { y: '-50px' },\n\t\tisDistractionFreeHovering: { y: 0 },\n\t\tview: { y: 0 },\n\t\tedit: { y: 0 },\n\t};\n\n\tconst toolbarTransition = {\n\t\ttype: 'tween',\n\t\tduration: disableMotion ? 0 : 0.2,\n\t\tease: 'easeOut',\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-header-edit-mode', {\n\t\t\t\t'show-icon-labels': showIconLabels,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ hasDefaultEditorCanvasView && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"edit-site-header-edit-mode__start\"\n\t\t\t\t\tvariants={ toolbarVariants }\n\t\t\t\t\ttransition={ toolbarTransition }\n\t\t\t\t>\n\t\t\t\t\t<DocumentTools\n\t\t\t\t\t\tblockEditorMode={ blockEditorMode }\n\t\t\t\t\t\tisDistractionFree={ isDistractionFree }\n\t\t\t\t\t\tshowIconLabels={ showIconLabels }\n\t\t\t\t\t\tsetListViewToggleElement={ setListViewToggleElement }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isTopToolbar && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'selected-block-tools-wrapper',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-collapsed': isBlockToolsCollapsed,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<BlockContextualToolbar isFixed />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ hasBlockSelected && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-header-edit-mode__block-tools-toggle\"\n\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\tisBlockToolsCollapsed ? next : previous\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsBlockToolsCollapsed(\n\t\t\t\t\t\t\t\t\t\t\t( collapsed ) => ! collapsed\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\tisBlockToolsCollapsed\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\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</motion.div>\n\t\t\t) }\n\n\t\t\t{ ! isDistractionFree && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'edit-site-header-edit-mode__center',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-collapsed':\n\t\t\t\t\t\t\t\t! isBlockToolsCollapsed && isLargeViewport,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ ! hasDefaultEditorCanvasView ? (\n\t\t\t\t\t\tgetEditorCanvasContainerTitle( editorCanvasView )\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<DocumentActions />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t<div className=\"edit-site-header-edit-mode__end\">\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"edit-site-header-edit-mode__actions\"\n\t\t\t\t\tvariants={ toolbarVariants }\n\t\t\t\t\ttransition={ toolbarTransition }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-header-edit-mode__preview-options',\n\t\t\t\t\t\t\t{ 'is-zoomed-out': isZoomedOutView }\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PreviewOptions\n\t\t\t\t\t\t\tdeviceType={ deviceType }\n\t\t\t\t\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\t\t\t\t\tlabel={ __( 'View' ) }\n\t\t\t\t\t\t\tisEnabled={\n\t\t\t\t\t\t\t\t! isFocusMode && hasDefaultEditorCanvasView\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'View site' ) }\n\t\t\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</PreviewOptions>\n\t\t\t\t\t</div>\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-site\" />\n\t\t\t\t\t) }\n\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t</motion.div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,oBAAoB;AACvE,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,4BAA4B,IAAIC,cAAc,EAC9CC,WAAW,IAAIC,sBAAsB,EACrCL,KAAK,IAAIM,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,kBAAkB;AAC3D,SACCC,MAAM,EACNC,gBAAgB,IAAIC,MAAM,EAC1BC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,cAAc,QACR,uBAAuB;AAC9B,SAASvB,KAAK,IAAIwB,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC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AAW,CAAC4E,IAAI;IAACY,KAAK,EAAC;EAAgB,CAAE,CAC1C,EACDnB,aAAA,CAACxD,QAAQ;IAACkB,cAAc,EAAGA;EAAgB,CAAE,CAClC,CACR,CACD,CAAC;AAER"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import downloadjs from 'downloadjs';
|
|
6
|
-
|
|
7
2
|
/**
|
|
8
3
|
* WordPress dependencies
|
|
9
4
|
*/
|
|
@@ -12,6 +7,7 @@ import { MenuItem } from '@wordpress/components';
|
|
|
12
7
|
import apiFetch from '@wordpress/api-fetch';
|
|
13
8
|
import { download } from '@wordpress/icons';
|
|
14
9
|
import { useDispatch } from '@wordpress/data';
|
|
10
|
+
import { downloadBlob } from '@wordpress/blob';
|
|
15
11
|
import { store as noticesStore } from '@wordpress/notices';
|
|
16
12
|
export default function SiteExport() {
|
|
17
13
|
const {
|
|
@@ -30,7 +26,7 @@ export default function SiteExport() {
|
|
|
30
26
|
const contentDisposition = response.headers.get('content-disposition');
|
|
31
27
|
const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/);
|
|
32
28
|
const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export';
|
|
33
|
-
|
|
29
|
+
downloadBlob(fileName + '.zip', blob, 'application/zip');
|
|
34
30
|
} catch (errorResponse) {
|
|
35
31
|
let error = {};
|
|
36
32
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["__","_x","MenuItem","apiFetch","download","useDispatch","downloadBlob","store","noticesStore","SiteExport","createErrorNotice","handleExport","response","path","parse","headers","Accept","blob","contentDisposition","get","contentDispositionMatches","match","fileName","errorResponse","error","json","e","errorMessage","message","code","type","createElement","role","icon","onClick","info"],"sources":["@wordpress/edit-site/src/components/header-edit-mode/more-menu/site-export.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport apiFetch from '@wordpress/api-fetch';\nimport { download } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\nimport { downloadBlob } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function SiteExport() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tasync function handleExport() {\n\t\ttry {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tpath: '/wp-block-editor/v1/export',\n\t\t\t\tparse: false,\n\t\t\t\theaders: {\n\t\t\t\t\tAccept: 'application/zip',\n\t\t\t\t},\n\t\t\t} );\n\t\t\tconst blob = await response.blob();\n\t\t\tconst contentDisposition = response.headers.get(\n\t\t\t\t'content-disposition'\n\t\t\t);\n\t\t\tconst contentDispositionMatches =\n\t\t\t\tcontentDisposition.match( /=(.+)\\.zip/ );\n\t\t\tconst fileName = contentDispositionMatches[ 1 ]\n\t\t\t\t? contentDispositionMatches[ 1 ]\n\t\t\t\t: 'edit-site-export';\n\n\t\t\tdownloadBlob( fileName + '.zip', blob, 'application/zip' );\n\t\t} catch ( errorResponse ) {\n\t\t\tlet error = {};\n\t\t\ttry {\n\t\t\t\terror = await errorResponse.json();\n\t\t\t} catch ( e ) {}\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the site export.' );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\trole=\"menuitem\"\n\t\t\ticon={ download }\n\t\t\tonClick={ handleExport }\n\t\t\tinfo={ __(\n\t\t\t\t'Download your theme with updated templates and styles.'\n\t\t\t) }\n\t\t>\n\t\t\t{ _x( 'Export', 'site exporter menu item' ) }\n\t\t</MenuItem>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,S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,KAAK,CAACI,OAAO,GACb5B,EAAE,CAAE,mDAAoD,CAAC;MAE7DU,iBAAiB,CAAEiB,YAAY,EAAE;QAAEG,IAAI,EAAE;MAAW,CAAE,CAAC;IACxD;EACD;EAEA,OACCC,aAAA,CAAC7B,QAAQ;IACR8B,IAAI,EAAC,UAAU;IACfC,IAAI,EAAG7B,QAAU;IACjB8B,OAAO,EAAGvB,YAAc;IACxBwB,IAAI,EAAGnC,EAAE,CACR,wDACD;EAAG,GAEDC,EAAE,CAAE,QAAQ,EAAE,yBAA0B,CACjC,CAAC;AAEb"}
|
|
@@ -11,7 +11,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
11
11
|
import { __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence, __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';
|
|
12
12
|
import { useReducedMotion, useViewportMatch, useResizeObserver } from '@wordpress/compose';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
|
-
import { useState
|
|
14
|
+
import { useState } from '@wordpress/element';
|
|
15
15
|
import { NavigableRegion } from '@wordpress/interface';
|
|
16
16
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
17
17
|
import { CommandMenu, privateApis as commandsPrivateApis } from '@wordpress/commands';
|
|
@@ -62,7 +62,6 @@ export default function Layout() {
|
|
|
62
62
|
useEditModeCommands();
|
|
63
63
|
useCommonCommands();
|
|
64
64
|
useBlockCommands();
|
|
65
|
-
const hubRef = useRef();
|
|
66
65
|
const {
|
|
67
66
|
params
|
|
68
67
|
} = useLocation();
|
|
@@ -98,7 +97,7 @@ export default function Layout() {
|
|
|
98
97
|
next: nextShortcut
|
|
99
98
|
});
|
|
100
99
|
const disableMotion = useReducedMotion();
|
|
101
|
-
const showSidebar = isMobileViewport && !isListPage || !isMobileViewport && (canvasMode === 'view' || !isEditorPage);
|
|
100
|
+
const showSidebar = isMobileViewport && canvasMode === 'view' && !isListPage || !isMobileViewport && (canvasMode === 'view' || !isEditorPage);
|
|
102
101
|
const showCanvas = isMobileViewport && isEditorPage && isEditing || !isMobileViewport || !isEditorPage;
|
|
103
102
|
const isFullCanvas = isMobileViewport && isListPage || isEditorPage && isEditing;
|
|
104
103
|
const [canvasResizer, canvasSize] = useResizeObserver();
|
|
@@ -153,7 +152,8 @@ export default function Layout() {
|
|
|
153
152
|
'is-distraction-free': isDistractionFree && isEditing,
|
|
154
153
|
'is-full-canvas': isFullCanvas,
|
|
155
154
|
'is-edit-mode': isEditing,
|
|
156
|
-
'has-fixed-toolbar': hasFixedToolbar
|
|
155
|
+
'has-fixed-toolbar': hasFixedToolbar,
|
|
156
|
+
'is-block-toolbar-visible': hasBlockSelected
|
|
157
157
|
})
|
|
158
158
|
}, createElement(motion.div, {
|
|
159
159
|
className: "edit-site-layout__header-container",
|
|
@@ -186,21 +186,6 @@ export default function Layout() {
|
|
|
186
186
|
whileHover: isDistractionFree ? 'isDistractionFreeHovering' : undefined,
|
|
187
187
|
animate: headerAnimationState
|
|
188
188
|
}, createElement(SiteHub, {
|
|
189
|
-
variants: {
|
|
190
|
-
isDistractionFree: {
|
|
191
|
-
x: '-100%'
|
|
192
|
-
},
|
|
193
|
-
isDistractionFreeHovering: {
|
|
194
|
-
x: 0
|
|
195
|
-
},
|
|
196
|
-
view: {
|
|
197
|
-
x: 0
|
|
198
|
-
},
|
|
199
|
-
edit: {
|
|
200
|
-
x: 0
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
ref: hubRef,
|
|
204
189
|
isTransparent: isResizableFrameOversized,
|
|
205
190
|
className: "edit-site-layout__hub"
|
|
206
191
|
}), createElement(AnimatePresence, {
|
|
@@ -252,7 +237,7 @@ export default function Layout() {
|
|
|
252
237
|
// (https://github.com/WordPress/gutenberg/pull/51558/files#r1231763003),
|
|
253
238
|
// so we can't remove the element entirely. Using `inert` will make
|
|
254
239
|
// it inaccessible to screen readers and keyboard navigation.
|
|
255
|
-
inert: showSidebar ? undefined : '
|
|
240
|
+
inert: showSidebar ? undefined : 'true',
|
|
256
241
|
animate: {
|
|
257
242
|
opacity: showSidebar ? 1 : 0
|
|
258
243
|
},
|