@wordpress/edit-site 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/add-new-template/add-custom-template-modal.js +12 -3
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +8 -7
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +19 -16
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +4 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +2 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +5 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +20 -159
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +13 -11
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +41 -487
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/duotone-panel.js +78 -0
- package/build/components/global-styles/duotone-panel.js.map +1 -0
- package/build/components/global-styles/filter-utils.js +17 -0
- package/build/components/global-styles/filter-utils.js.map +1 -0
- package/build/components/global-styles/hooks.js +11 -26
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview.js +9 -5
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +6 -11
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-border.js +14 -6
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +46 -0
- package/build/components/global-styles/screen-filters.js.map +1 -0
- package/build/components/global-styles/screen-layout.js +13 -5
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -1
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -1
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +1 -1
- package/build/components/global-styles/screen-variations.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +6 -4
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +2 -5
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +7 -1
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build/components/keyboard-shortcuts/global.js +48 -0
- package/build/components/keyboard-shortcuts/global.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +67 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +153 -0
- package/build/components/keyboard-shortcuts/register.js.map +1 -0
- package/build/components/layout/index.js +12 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +127 -136
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/index.js +2 -1
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +9 -7
- package/build/components/list/table.js.map +1 -1
- package/build/components/routes/link.js +4 -1
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-hub/index.js +82 -0
- package/build/components/save-hub/index.js.map +1 -0
- package/build/components/save-panel/index.js +11 -1
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +27 -17
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +30 -0
- package/build/components/sidebar-button/index.js.map +1 -0
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +14 -11
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +16 -16
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +22 -26
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +97 -14
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-template/index.js +66 -27
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +30 -17
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +14 -10
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +3 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +151 -21
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-details/index.js +5 -10
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-regular.js +8 -12
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +2 -2
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/template-part-converter/index.js +19 -14
- package/build/components/template-part-converter/index.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -6
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/index.js +13 -22
- package/build/index.js.map +1 -1
- package/build/store/actions.js +2 -2
- package/build/store/actions.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build/utils/history.js +8 -2
- package/build/utils/history.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +8 -7
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +21 -17
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +3 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +2 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +5 -6
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +21 -157
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +14 -11
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +43 -480
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/duotone-panel.js +67 -0
- package/build-module/components/global-styles/duotone-panel.js.map +1 -0
- package/build-module/components/global-styles/filter-utils.js +9 -0
- package/build-module/components/global-styles/filter-utils.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +11 -26
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview.js +10 -6
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +6 -8
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +12 -3
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +33 -0
- package/build-module/components/global-styles/screen-filters.js.map +1 -0
- package/build-module/components/global-styles/screen-layout.js +11 -2
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +2 -1
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -1
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +1 -1
- package/build-module/components/global-styles/screen-variations.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +6 -4
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +2 -5
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +6 -1
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/global.js +37 -0
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +65 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +141 -0
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
- package/build-module/components/layout/index.js +10 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +126 -138
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/list/index.js +2 -1
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +9 -7
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/routes/link.js +5 -2
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-hub/index.js +68 -0
- package/build-module/components/save-hub/index.js.map +1 -0
- package/build-module/components/save-panel/index.js +8 -1
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +24 -19
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +18 -0
- package/build-module/components/sidebar-button/index.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +12 -12
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +16 -16
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +24 -30
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +91 -14
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js +67 -30
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +28 -18
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +13 -10
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +152 -25
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +65 -18
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-details/index.js +5 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +20 -15
- package/build-module/components/template-part-converter/index.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +6 -6
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/index.js +16 -23
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-module/utils/history.js +9 -3
- package/build-module/utils/history.js.map +1 -1
- package/build-style/style-rtl.css +203 -143
- package/build-style/style.css +203 -143
- package/package.json +31 -31
- package/src/components/add-new-template/add-custom-template-modal.js +14 -10
- package/src/components/add-new-template/new-template-part.js +7 -9
- package/src/components/add-new-template/new-template.js +60 -38
- package/src/components/add-new-template/style.scss +12 -6
- package/src/components/app/index.js +9 -6
- package/src/components/block-editor/editor-canvas.js +2 -1
- package/src/components/block-editor/style.scss +1 -1
- package/src/components/editor/index.js +62 -65
- package/src/components/editor/style.scss +0 -6
- package/src/components/global-styles/border-panel.js +24 -199
- package/src/components/global-styles/context-menu.js +18 -12
- package/src/components/global-styles/dimensions-panel.js +43 -577
- package/src/components/global-styles/duotone-panel.js +82 -0
- package/src/components/global-styles/filter-utils.js +9 -0
- package/src/components/global-styles/hooks.js +12 -36
- package/src/components/global-styles/preview.js +155 -140
- package/src/components/global-styles/screen-block-list.js +6 -11
- package/src/components/global-styles/screen-border.js +10 -3
- package/src/components/global-styles/screen-filters.js +27 -0
- package/src/components/global-styles/screen-layout.js +9 -2
- package/src/components/global-styles/screen-root.js +1 -1
- package/src/components/global-styles/screen-style-variations.js +5 -1
- package/src/components/global-styles/screen-variations.js +0 -1
- package/src/components/global-styles/shadow-panel.js +4 -3
- package/src/components/global-styles/style.scss +10 -0
- package/src/components/global-styles/typography-panel.js +5 -7
- package/src/components/global-styles/ui.js +6 -1
- package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
- package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
- package/src/components/keyboard-shortcuts/global.js +35 -0
- package/src/components/keyboard-shortcuts/index.js +70 -0
- package/src/components/keyboard-shortcuts/register.js +157 -0
- package/src/components/layout/index.js +19 -0
- package/src/components/layout/style.scss +9 -4
- package/src/components/list/added-by.js +152 -155
- package/src/components/list/index.js +3 -1
- package/src/components/list/style.scss +5 -13
- package/src/components/list/table.js +11 -9
- package/src/components/routes/link.js +9 -2
- package/src/components/save-hub/index.js +78 -0
- package/src/components/save-hub/style.scss +15 -0
- package/src/components/save-panel/index.js +8 -1
- package/src/components/sidebar/index.js +33 -16
- package/src/components/sidebar/style.scss +4 -3
- package/src/components/sidebar-button/index.js +21 -0
- package/src/components/sidebar-button/style.scss +24 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
- package/src/components/sidebar-edit-mode/style.scss +16 -0
- package/src/components/sidebar-navigation-item/style.scss +1 -23
- package/src/components/sidebar-navigation-screen/index.js +37 -38
- package/src/components/sidebar-navigation-screen/style.scss +16 -9
- package/src/components/sidebar-navigation-screen-main/index.js +24 -11
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +39 -26
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +99 -12
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
- package/src/components/sidebar-navigation-screen-template/index.js +89 -30
- package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +29 -14
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -6
- package/src/components/site-hub/index.js +5 -1
- package/src/components/site-hub/style.scss +5 -1
- package/src/components/style-book/index.js +234 -55
- package/src/components/style-book/style.scss +1 -45
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +28 -23
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +77 -17
- package/src/components/template-details/index.js +4 -8
- package/src/components/template-part-converter/convert-to-regular.js +10 -17
- package/src/components/template-part-converter/convert-to-template-part.js +9 -16
- package/src/components/template-part-converter/index.js +28 -12
- package/src/components/use-edited-entity-record/index.js +26 -18
- package/src/index.js +11 -22
- package/src/store/actions.js +2 -2
- package/src/store/test/actions.js +0 -2
- package/src/style.scss +3 -1
- package/src/utils/get-is-list-page.js +1 -1
- package/src/utils/history.js +13 -9
- package/build/components/navigation-inspector/index.js +0 -161
- package/build/components/navigation-inspector/index.js.map +0 -1
- package/build/components/navigation-inspector/navigation-menu.js +0 -62
- package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/build-module/components/navigation-inspector/index.js +0 -146
- package/build-module/components/navigation-inspector/index.js.map +0 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
- package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/src/components/navigation-inspector/index.js +0 -191
- package/src/components/navigation-inspector/navigation-menu.js +0 -66
- package/src/components/navigation-inspector/style.scss +0 -46
|
@@ -18,7 +18,6 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
18
18
|
*/
|
|
19
19
|
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
20
20
|
import { store as editSiteStore } from '../../store';
|
|
21
|
-
import TemplateAreas from './template-areas';
|
|
22
21
|
import EditTemplateTitle from './edit-template-title';
|
|
23
22
|
import { useLink } from '../routes/link';
|
|
24
23
|
import TemplatePartAreaSelector from './template-part-area-selector';
|
|
@@ -31,10 +30,9 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
31
30
|
);
|
|
32
31
|
const { revertTemplate } = useDispatch( editSiteStore );
|
|
33
32
|
|
|
33
|
+
// TODO: We should update this to filter by template part's areas as well.
|
|
34
34
|
const browseAllLinkProps = useLink( {
|
|
35
|
-
|
|
36
|
-
postType: template.type,
|
|
37
|
-
postId: undefined,
|
|
35
|
+
path: '/' + template.type + '/all',
|
|
38
36
|
} );
|
|
39
37
|
|
|
40
38
|
const isTemplatePart = template.type === 'wp_template_part';
|
|
@@ -87,8 +85,6 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
87
85
|
</div>
|
|
88
86
|
) }
|
|
89
87
|
|
|
90
|
-
<TemplateAreas closeTemplateDetailsDropdown={ onClose } />
|
|
91
|
-
|
|
92
88
|
{ isTemplateRevertable( template ) && (
|
|
93
89
|
<MenuGroup className="edit-site-template-details__group edit-site-template-details__revert">
|
|
94
90
|
<MenuItem
|
|
@@ -108,8 +104,8 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
108
104
|
{ ...browseAllLinkProps }
|
|
109
105
|
>
|
|
110
106
|
{ template?.type === 'wp_template'
|
|
111
|
-
? __( '
|
|
112
|
-
: __( '
|
|
107
|
+
? __( 'Manage all templates' )
|
|
108
|
+
: __( 'Manage all template parts' ) }
|
|
113
109
|
</Button>
|
|
114
110
|
</div>
|
|
115
111
|
);
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import {
|
|
6
|
-
BlockSettingsMenuControls,
|
|
7
|
-
store as blockEditorStore,
|
|
8
|
-
} from '@wordpress/block-editor';
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
6
|
import { MenuItem } from '@wordpress/components';
|
|
10
7
|
import { __ } from '@wordpress/i18n';
|
|
11
8
|
|
|
12
|
-
export default function ConvertToRegularBlocks( { clientId } ) {
|
|
9
|
+
export default function ConvertToRegularBlocks( { clientId, onClose } ) {
|
|
13
10
|
const { getBlocks } = useSelect( blockEditorStore );
|
|
14
11
|
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
15
12
|
|
|
@@ -23,17 +20,13 @@ export default function ConvertToRegularBlocks( { clientId } ) {
|
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
return (
|
|
26
|
-
<
|
|
27
|
-
{ (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{ __( 'Detach blocks from template part' ) }
|
|
35
|
-
</MenuItem>
|
|
36
|
-
) }
|
|
37
|
-
</BlockSettingsMenuControls>
|
|
23
|
+
<MenuItem
|
|
24
|
+
onClick={ () => {
|
|
25
|
+
replaceBlocks( clientId, getBlocks( clientId ) );
|
|
26
|
+
onClose();
|
|
27
|
+
} }
|
|
28
|
+
>
|
|
29
|
+
{ __( 'Detach blocks from template part' ) }
|
|
30
|
+
</MenuItem>
|
|
38
31
|
);
|
|
39
32
|
}
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
-
import {
|
|
6
|
-
BlockSettingsMenuControls,
|
|
7
|
-
store as blockEditorStore,
|
|
8
|
-
} from '@wordpress/block-editor';
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
6
|
import { MenuItem } from '@wordpress/components';
|
|
10
7
|
import { createBlock, serialize } from '@wordpress/blocks';
|
|
11
8
|
import { __ } from '@wordpress/i18n';
|
|
@@ -78,18 +75,14 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
|
|
|
78
75
|
|
|
79
76
|
return (
|
|
80
77
|
<>
|
|
81
|
-
<
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{ __( 'Create Template part' ) }
|
|
90
|
-
</MenuItem>
|
|
91
|
-
) }
|
|
92
|
-
</BlockSettingsMenuControls>
|
|
78
|
+
<MenuItem
|
|
79
|
+
icon={ symbolFilled }
|
|
80
|
+
onClick={ () => {
|
|
81
|
+
setIsModalOpen( true );
|
|
82
|
+
} }
|
|
83
|
+
>
|
|
84
|
+
{ __( 'Create Template part' ) }
|
|
85
|
+
</MenuItem>
|
|
93
86
|
{ isModalOpen && (
|
|
94
87
|
<CreateTemplatePartModal
|
|
95
88
|
closeModal={ () => {
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
BlockSettingsMenuControls,
|
|
7
|
+
store as blockEditorStore,
|
|
8
|
+
} from '@wordpress/block-editor';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Internal dependencies
|
|
@@ -11,20 +14,33 @@ import ConvertToRegularBlocks from './convert-to-regular';
|
|
|
11
14
|
import ConvertToTemplatePart from './convert-to-template-part';
|
|
12
15
|
|
|
13
16
|
export default function TemplatePartConverter() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
return (
|
|
18
|
+
<BlockSettingsMenuControls>
|
|
19
|
+
{ ( { selectedClientIds, onClose } ) => (
|
|
20
|
+
<TemplatePartConverterMenuItem
|
|
21
|
+
clientIds={ selectedClientIds }
|
|
22
|
+
onClose={ onClose }
|
|
23
|
+
/>
|
|
24
|
+
) }
|
|
25
|
+
</BlockSettingsMenuControls>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function TemplatePartConverterMenuItem( { clientIds, onClose } ) {
|
|
30
|
+
const blocks = useSelect(
|
|
31
|
+
( select ) =>
|
|
32
|
+
select( blockEditorStore ).getBlocksByClientId( clientIds ),
|
|
33
|
+
[ clientIds ]
|
|
34
|
+
);
|
|
23
35
|
|
|
24
36
|
// Allow converting a single template part to standard blocks.
|
|
25
37
|
if ( blocks.length === 1 && blocks[ 0 ]?.name === 'core/template-part' ) {
|
|
26
|
-
return
|
|
38
|
+
return (
|
|
39
|
+
<ConvertToRegularBlocks
|
|
40
|
+
clientId={ clientIds[ 0 ] }
|
|
41
|
+
onClose={ onClose }
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
27
44
|
}
|
|
28
|
-
|
|
29
45
|
return <ConvertToTemplatePart clientIds={ clientIds } blocks={ blocks } />;
|
|
30
46
|
}
|
|
@@ -11,25 +11,33 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
11
11
|
*/
|
|
12
12
|
import { store as editSiteStore } from '../../store';
|
|
13
13
|
|
|
14
|
-
export default function useEditedEntityRecord() {
|
|
15
|
-
const { record, title, description, isLoaded } = useSelect(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
select(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
export default function useEditedEntityRecord( postType, postId ) {
|
|
15
|
+
const { record, title, description, isLoaded } = useSelect(
|
|
16
|
+
( select ) => {
|
|
17
|
+
const { getEditedPostType, getEditedPostId } =
|
|
18
|
+
select( editSiteStore );
|
|
19
|
+
const { getEditedEntityRecord } = select( coreStore );
|
|
20
|
+
const { __experimentalGetTemplateInfo: getTemplateInfo } =
|
|
21
|
+
select( editorStore );
|
|
22
|
+
const usedPostType = postType ?? getEditedPostType();
|
|
23
|
+
const usedPostId = postId ?? getEditedPostId();
|
|
24
|
+
const _record = getEditedEntityRecord(
|
|
25
|
+
'postType',
|
|
26
|
+
usedPostType,
|
|
27
|
+
usedPostId
|
|
28
|
+
);
|
|
29
|
+
const _isLoaded = !! usedPostId;
|
|
30
|
+
const templateInfo = getTemplateInfo( _record );
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
return {
|
|
33
|
+
record: _record,
|
|
34
|
+
title: templateInfo.title,
|
|
35
|
+
description: templateInfo.description,
|
|
36
|
+
isLoaded: _isLoaded,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
[ postType, postId ]
|
|
40
|
+
);
|
|
33
41
|
|
|
34
42
|
return {
|
|
35
43
|
isLoaded,
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import {
|
|
6
6
|
registerCoreBlocks,
|
|
7
|
+
__experimentalGetCoreBlocks,
|
|
7
8
|
__experimentalRegisterExperimentalCoreBlocks,
|
|
8
9
|
} from '@wordpress/block-library';
|
|
9
10
|
import { dispatch } from '@wordpress/data';
|
|
@@ -16,8 +17,10 @@ import {
|
|
|
16
17
|
import { store as editorStore } from '@wordpress/editor';
|
|
17
18
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
18
19
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
19
|
-
import {
|
|
20
|
-
|
|
20
|
+
import {
|
|
21
|
+
registerLegacyWidgetBlock,
|
|
22
|
+
registerWidgetGroupBlock,
|
|
23
|
+
} from '@wordpress/widgets';
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Internal dependencies
|
|
@@ -41,32 +44,18 @@ export function initializeEditor( id, settings ) {
|
|
|
41
44
|
settings.__experimentalFetchRichUrlData = fetchUrlData;
|
|
42
45
|
|
|
43
46
|
dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
|
|
44
|
-
|
|
47
|
+
const coreBlocks = __experimentalGetCoreBlocks().filter(
|
|
48
|
+
( { name } ) => name !== 'core/freeform'
|
|
49
|
+
);
|
|
50
|
+
registerCoreBlocks( coreBlocks );
|
|
51
|
+
dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );
|
|
45
52
|
registerLegacyWidgetBlock( { inserter: false } );
|
|
53
|
+
registerWidgetGroupBlock( { inserter: false } );
|
|
46
54
|
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
47
55
|
__experimentalRegisterExperimentalCoreBlocks( {
|
|
48
56
|
enableFSEBlocks: true,
|
|
49
57
|
} );
|
|
50
58
|
}
|
|
51
|
-
/*
|
|
52
|
-
* Prevent adding the Clasic block in the site editor.
|
|
53
|
-
* Only add the filter when the site editor is initialized, not imported.
|
|
54
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
55
|
-
* so that common filters in the block library are not overwritten.
|
|
56
|
-
*
|
|
57
|
-
* This usage here is inspired by previous usage of the filter in the post editor:
|
|
58
|
-
* https://github.com/WordPress/gutenberg/pull/37157
|
|
59
|
-
*/
|
|
60
|
-
addFilter(
|
|
61
|
-
'blockEditor.__unstableCanInsertBlockType',
|
|
62
|
-
'removeClassicBlockFromInserter',
|
|
63
|
-
( canInsert, blockType ) => {
|
|
64
|
-
if ( blockType.name === 'core/freeform' ) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return canInsert;
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
59
|
|
|
71
60
|
// We dispatch actions and update the store synchronously before rendering
|
|
72
61
|
// so that we won't trigger unnecessary re-renders with useEffect.
|
package/src/store/actions.js
CHANGED
|
@@ -526,7 +526,7 @@ export const switchEditorMode =
|
|
|
526
526
|
|
|
527
527
|
if ( mode === 'visual' ) {
|
|
528
528
|
speak( __( 'Visual editor selected' ), 'assertive' );
|
|
529
|
-
} else if ( mode === '
|
|
530
|
-
speak( __( '
|
|
529
|
+
} else if ( mode === 'text' ) {
|
|
530
|
+
speak( __( 'Code editor selected' ), 'assertive' );
|
|
531
531
|
}
|
|
532
532
|
};
|
package/src/style.scss
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
@import "./components/header-edit-mode/style.scss";
|
|
9
9
|
@import "./components/header-edit-mode/document-actions/style.scss";
|
|
10
10
|
@import "./components/list/style.scss";
|
|
11
|
-
@import "./components/navigation-inspector/style.scss";
|
|
12
11
|
@import "./components/sidebar-edit-mode/style.scss";
|
|
13
12
|
@import "./components/sidebar-edit-mode/settings-header/style.scss";
|
|
14
13
|
@import "./components/sidebar-edit-mode/template-card/style.scss";
|
|
@@ -20,10 +19,13 @@
|
|
|
20
19
|
@import "./components/start-template-options/style.scss";
|
|
21
20
|
@import "./components/keyboard-shortcut-help-modal/style.scss";
|
|
22
21
|
@import "./components/layout/style.scss";
|
|
22
|
+
@import "./components/save-hub/style.scss";
|
|
23
23
|
@import "./components/save-panel/style.scss";
|
|
24
24
|
@import "./components/sidebar/style.scss";
|
|
25
|
+
@import "./components/sidebar-button/style.scss";
|
|
25
26
|
@import "./components/sidebar-navigation-item/style.scss";
|
|
26
27
|
@import "./components/sidebar-navigation-screen/style.scss";
|
|
28
|
+
@import "./components/sidebar-navigation-screen-template/style.scss";
|
|
27
29
|
@import "./components/sidebar-navigation-screen-templates/style.scss";
|
|
28
30
|
@import "./components/site-hub/style.scss";
|
|
29
31
|
@import "./components/sidebar-navigation-screen-navigation-menus/style.scss";
|
package/src/utils/history.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createBrowserHistory } from 'history';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
9
|
+
import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
10
10
|
|
|
11
11
|
const history = createBrowserHistory();
|
|
12
12
|
|
|
@@ -14,19 +14,23 @@ const originalHistoryPush = history.push;
|
|
|
14
14
|
const originalHistoryReplace = history.replace;
|
|
15
15
|
|
|
16
16
|
function push( params, state ) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const currentArgs = getQueryArgs( window.location.href );
|
|
18
|
+
const currentUrlWithoutArgs = removeQueryArgs(
|
|
19
|
+
window.location.href,
|
|
20
|
+
...Object.keys( currentArgs )
|
|
21
21
|
);
|
|
22
|
+
const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
|
|
23
|
+
return originalHistoryPush.call( history, newUrl, state );
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
function replace( params, state ) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const currentArgs = getQueryArgs( window.location.href );
|
|
28
|
+
const currentUrlWithoutArgs = removeQueryArgs(
|
|
29
|
+
window.location.href,
|
|
30
|
+
...Object.keys( currentArgs )
|
|
29
31
|
);
|
|
32
|
+
const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
|
|
33
|
+
return originalHistoryReplace.call( history, newUrl, state );
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
history.push = push;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = NavigationInspector;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _data = require("@wordpress/data");
|
|
13
|
-
|
|
14
|
-
var _coreData = require("@wordpress/core-data");
|
|
15
|
-
|
|
16
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
17
|
-
|
|
18
|
-
var _a11y = require("@wordpress/a11y");
|
|
19
|
-
|
|
20
|
-
var _i18n = require("@wordpress/i18n");
|
|
21
|
-
|
|
22
|
-
var _navigationMenu = _interopRequireDefault(require("./navigation-menu"));
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
const NAVIGATION_MENUS_QUERY = [{
|
|
32
|
-
per_page: -1,
|
|
33
|
-
status: 'publish'
|
|
34
|
-
}];
|
|
35
|
-
|
|
36
|
-
function NavigationInspector(_ref) {
|
|
37
|
-
var _navigationMenus$;
|
|
38
|
-
|
|
39
|
-
let {
|
|
40
|
-
onSelect
|
|
41
|
-
} = _ref;
|
|
42
|
-
const {
|
|
43
|
-
selectedNavigationBlockId,
|
|
44
|
-
clientIdToRef,
|
|
45
|
-
navigationMenus,
|
|
46
|
-
isResolvingNavigationMenus,
|
|
47
|
-
hasResolvedNavigationMenus,
|
|
48
|
-
firstNavigationBlockId
|
|
49
|
-
} = (0, _data.useSelect)(select => {
|
|
50
|
-
const {
|
|
51
|
-
__experimentalGetActiveBlockIdByBlockNames,
|
|
52
|
-
__experimentalGetGlobalBlocksByName,
|
|
53
|
-
getBlock
|
|
54
|
-
} = select(_blockEditor.store);
|
|
55
|
-
const {
|
|
56
|
-
getEntityRecords,
|
|
57
|
-
hasFinishedResolution,
|
|
58
|
-
isResolving
|
|
59
|
-
} = select(_coreData.store);
|
|
60
|
-
const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY[0]]; // Get the active Navigation block (if present).
|
|
61
|
-
|
|
62
|
-
const selectedNavId = __experimentalGetActiveBlockIdByBlockNames('core/navigation'); // Get all Navigation blocks currently within the editor canvas.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const navBlockIds = __experimentalGetGlobalBlocksByName('core/navigation');
|
|
66
|
-
|
|
67
|
-
const idToRef = {};
|
|
68
|
-
navBlockIds.forEach(id => {
|
|
69
|
-
var _getBlock, _getBlock$attributes;
|
|
70
|
-
|
|
71
|
-
idToRef[id] = (_getBlock = getBlock(id)) === null || _getBlock === void 0 ? void 0 : (_getBlock$attributes = _getBlock.attributes) === null || _getBlock$attributes === void 0 ? void 0 : _getBlock$attributes.ref;
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
selectedNavigationBlockId: selectedNavId,
|
|
75
|
-
firstNavigationBlockId: navBlockIds === null || navBlockIds === void 0 ? void 0 : navBlockIds[0],
|
|
76
|
-
clientIdToRef: idToRef,
|
|
77
|
-
navigationMenus: getEntityRecords(...navigationMenusQuery),
|
|
78
|
-
isResolvingNavigationMenus: isResolving('getEntityRecords', navigationMenusQuery),
|
|
79
|
-
hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
|
|
80
|
-
};
|
|
81
|
-
}, []);
|
|
82
|
-
const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
|
|
83
|
-
const firstNavigationMenuRef = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id; // Default Navigation Menu is either:
|
|
84
|
-
// - the Navigation Menu referenced by the first Nav block within the template.
|
|
85
|
-
// - the first of the available Navigation Menus (`wp_navigation`) posts.
|
|
86
|
-
|
|
87
|
-
const defaultNavigationMenuId = firstNavRefInTemplate || firstNavigationMenuRef; // The Navigation Menu manually selected by the user within the Nav inspector.
|
|
88
|
-
|
|
89
|
-
const [currentMenuId, setCurrentMenuId] = (0, _element.useState)(firstNavRefInTemplate); // If a Nav block is selected within the canvas then set the
|
|
90
|
-
// Navigation Menu referenced by it's `ref` attribute to be
|
|
91
|
-
// active within the Navigation sidebar.
|
|
92
|
-
|
|
93
|
-
(0, _element.useEffect)(() => {
|
|
94
|
-
if (selectedNavigationBlockId) {
|
|
95
|
-
setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
|
|
96
|
-
}
|
|
97
|
-
}, [selectedNavigationBlockId]);
|
|
98
|
-
const [innerBlocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('postType', 'wp_navigation', {
|
|
99
|
-
id: currentMenuId || defaultNavigationMenuId
|
|
100
|
-
});
|
|
101
|
-
const {
|
|
102
|
-
isLoadingInnerBlocks,
|
|
103
|
-
hasLoadedInnerBlocks
|
|
104
|
-
} = (0, _data.useSelect)(select => {
|
|
105
|
-
const {
|
|
106
|
-
isResolving,
|
|
107
|
-
hasFinishedResolution
|
|
108
|
-
} = select(_coreData.store);
|
|
109
|
-
return {
|
|
110
|
-
isLoadingInnerBlocks: isResolving('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId]),
|
|
111
|
-
hasLoadedInnerBlocks: hasFinishedResolution('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId])
|
|
112
|
-
};
|
|
113
|
-
}, [currentMenuId, defaultNavigationMenuId]);
|
|
114
|
-
const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
|
|
115
|
-
const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
|
|
116
|
-
// Guard by only allowing their usage if there are published Nav Menus.
|
|
117
|
-
|
|
118
|
-
const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
|
|
119
|
-
const hasInnerBlocks = !!(publishedInnerBlocks !== null && publishedInnerBlocks !== void 0 && publishedInnerBlocks.length);
|
|
120
|
-
(0, _element.useEffect)(() => {
|
|
121
|
-
if (isResolvingNavigationMenus) {
|
|
122
|
-
(0, _a11y.speak)('Loading Navigation sidebar menus.');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (hasResolvedNavigationMenus) {
|
|
126
|
-
(0, _a11y.speak)('Navigation sidebar menus have loaded.');
|
|
127
|
-
}
|
|
128
|
-
}, [isResolvingNavigationMenus, hasResolvedNavigationMenus]);
|
|
129
|
-
(0, _element.useEffect)(() => {
|
|
130
|
-
if (isLoadingInnerBlocks) {
|
|
131
|
-
(0, _a11y.speak)('Loading Navigation sidebar selected menu items.');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (hasLoadedInnerBlocks) {
|
|
135
|
-
(0, _a11y.speak)('Navigation sidebar selected menu items have loaded.');
|
|
136
|
-
}
|
|
137
|
-
}, [isLoadingInnerBlocks, hasLoadedInnerBlocks]);
|
|
138
|
-
return (0, _element.createElement)("div", {
|
|
139
|
-
className: "edit-site-navigation-inspector"
|
|
140
|
-
}, hasResolvedNavigationMenus && !hasNavigationMenus && (0, _element.createElement)("p", {
|
|
141
|
-
className: "edit-site-navigation-inspector__empty-msg"
|
|
142
|
-
}, (0, _i18n.__)('There are no Navigation Menus.')), !hasResolvedNavigationMenus && (0, _element.createElement)("div", {
|
|
143
|
-
className: "edit-site-navigation-inspector__placeholder"
|
|
144
|
-
}), isLoading && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
|
|
145
|
-
className: "edit-site-navigation-inspector__placeholder is-child"
|
|
146
|
-
}), (0, _element.createElement)("div", {
|
|
147
|
-
className: "edit-site-navigation-inspector__placeholder is-child"
|
|
148
|
-
}), (0, _element.createElement)("div", {
|
|
149
|
-
className: "edit-site-navigation-inspector__placeholder is-child"
|
|
150
|
-
})), hasInnerBlocks && !isLoading && (0, _element.createElement)(_blockEditor.BlockEditorProvider, {
|
|
151
|
-
value: publishedInnerBlocks,
|
|
152
|
-
onChange: onChange,
|
|
153
|
-
onInput: onInput
|
|
154
|
-
}, (0, _element.createElement)(_navigationMenu.default, {
|
|
155
|
-
innerBlocks: publishedInnerBlocks,
|
|
156
|
-
onSelect: onSelect
|
|
157
|
-
})), !hasInnerBlocks && !isLoading && (0, _element.createElement)("p", {
|
|
158
|
-
className: "edit-site-navigation-inspector__empty-msg"
|
|
159
|
-
}, (0, _i18n.__)('Navigation Menu is empty.')));
|
|
160
|
-
}
|
|
161
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/index.js"],"names":["NAVIGATION_MENUS_QUERY","per_page","status","NavigationInspector","onSelect","selectedNavigationBlockId","clientIdToRef","navigationMenus","isResolvingNavigationMenus","hasResolvedNavigationMenus","firstNavigationBlockId","select","__experimentalGetActiveBlockIdByBlockNames","__experimentalGetGlobalBlocksByName","getBlock","blockEditorStore","getEntityRecords","hasFinishedResolution","isResolving","coreStore","navigationMenusQuery","selectedNavId","navBlockIds","idToRef","forEach","id","attributes","ref","firstNavRefInTemplate","firstNavigationMenuRef","defaultNavigationMenuId","currentMenuId","setCurrentMenuId","innerBlocks","onInput","onChange","isLoadingInnerBlocks","hasLoadedInnerBlocks","isLoading","hasNavigationMenus","length","publishedInnerBlocks","hasInnerBlocks"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAIA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAWA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG,CAAE;AAAEC,EAAAA,QAAQ,EAAE,CAAC,CAAb;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAAF,CAA/B;;AAEe,SAASC,mBAAT,OAA6C;AAAA;;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC3D,QAAM;AACLC,IAAAA,yBADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,0BALK;AAMLC,IAAAA;AANK,MAOF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,0CADK;AAELC,MAAAA,mCAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,k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import { useState, useEffect } from '@wordpress/element';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tstore as blockEditorStore,\n\tBlockEditorProvider,\n} from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenu from './navigation-menu';\n\nconst NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];\n\nexport default function NavigationInspector( { onSelect } ) {\n\tconst {\n\t\tselectedNavigationBlockId,\n\t\tclientIdToRef,\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tfirstNavigationBlockId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetActiveBlockIdByBlockNames,\n\t\t\t__experimentalGetGlobalBlocksByName,\n\t\t\tgetBlock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getEntityRecords, hasFinishedResolution, isResolving } =\n\t\t\tselect( coreStore );\n\n\t\tconst navigationMenusQuery = [\n\t\t\t'postType',\n\t\t\t'wp_navigation',\n\t\t\tNAVIGATION_MENUS_QUERY[ 0 ],\n\t\t];\n\n\t\t// Get the active Navigation block (if present).\n\t\tconst selectedNavId =\n\t\t\t__experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );\n\n\t\t// Get all Navigation blocks currently within the editor canvas.\n\t\tconst navBlockIds =\n\t\t\t__experimentalGetGlobalBlocksByName( 'core/navigation' );\n\t\tconst idToRef = {};\n\t\tnavBlockIds.forEach( ( id ) => {\n\t\t\tidToRef[ id ] = getBlock( id )?.attributes?.ref;\n\t\t} );\n\t\treturn {\n\t\t\tselectedNavigationBlockId: selectedNavId,\n\t\t\tfirstNavigationBlockId: navBlockIds?.[ 0 ],\n\t\t\tclientIdToRef: idToRef,\n\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\tisResolvingNavigationMenus: isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];\n\tconst firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;\n\n\t// Default Navigation Menu is either:\n\t// - the Navigation Menu referenced by the first Nav block within the template.\n\t// - the first of the available Navigation Menus (`wp_navigation`) posts.\n\tconst defaultNavigationMenuId =\n\t\tfirstNavRefInTemplate || firstNavigationMenuRef;\n\n\t// The Navigation Menu manually selected by the user within the Nav inspector.\n\tconst [ currentMenuId, setCurrentMenuId ] = useState(\n\t\tfirstNavRefInTemplate\n\t);\n\n\t// If a Nav block is selected within the canvas then set the\n\t// Navigation Menu referenced by it's `ref` attribute to be\n\t// active within the Navigation sidebar.\n\tuseEffect( () => {\n\t\tif ( selectedNavigationBlockId ) {\n\t\t\tsetCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );\n\t\t}\n\t}, [ selectedNavigationBlockId ] );\n\n\tconst [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t{ id: currentMenuId || defaultNavigationMenuId }\n\t);\n\n\tconst { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isResolving, hasFinishedResolution } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisLoadingInnerBlocks: isResolving( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_navigation',\n\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t] ),\n\t\t\t\thasLoadedInnerBlocks: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t[\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_navigation',\n\t\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ currentMenuId, defaultNavigationMenuId ]\n\t);\n\n\tconst isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\t// Entity block editor will return entities that are not currently published.\n\t// Guard by only allowing their usage if there are published Nav Menus.\n\tconst publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];\n\n\tconst hasInnerBlocks = !! publishedInnerBlocks?.length;\n\n\tuseEffect( () => {\n\t\tif ( isResolvingNavigationMenus ) {\n\t\t\tspeak( 'Loading Navigation sidebar menus.' );\n\t\t}\n\n\t\tif ( hasResolvedNavigationMenus ) {\n\t\t\tspeak( 'Navigation sidebar menus have loaded.' );\n\t\t}\n\t}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );\n\n\tuseEffect( () => {\n\t\tif ( isLoadingInnerBlocks ) {\n\t\t\tspeak( 'Loading Navigation sidebar selected menu items.' );\n\t\t}\n\n\t\tif ( hasLoadedInnerBlocks ) {\n\t\t\tspeak( 'Navigation sidebar selected menu items have loaded.' );\n\t\t}\n\t}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-inspector\">\n\t\t\t{ hasResolvedNavigationMenus && ! hasNavigationMenus && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t{ ! hasResolvedNavigationMenus && (\n\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder\" />\n\t\t\t) }\n\t\t\t{ isLoading && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ hasInnerBlocks && ! isLoading && (\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ publishedInnerBlocks }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t>\n\t\t\t\t\t<NavigationMenu\n\t\t\t\t\t\tinnerBlocks={ publishedInnerBlocks }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</BlockEditorProvider>\n\t\t\t) }\n\n\t\t\t{ ! hasInnerBlocks && ! isLoading && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = NavigationMenu;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
|
|
12
|
-
var _data = require("@wordpress/data");
|
|
13
|
-
|
|
14
|
-
var _privateApis = require("../../private-apis");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
const ALLOWED_BLOCKS = {
|
|
24
|
-
'core/navigation': ['core/navigation-link', 'core/search', 'core/social-links', 'core/page-list', 'core/spacer', 'core/home-link', 'core/site-title', 'core/site-logo', 'core/navigation-submenu'],
|
|
25
|
-
'core/social-links': ['core/social-link'],
|
|
26
|
-
'core/navigation-submenu': ['core/navigation-link', 'core/navigation-submenu'],
|
|
27
|
-
'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function NavigationMenu(_ref) {
|
|
31
|
-
let {
|
|
32
|
-
innerBlocks,
|
|
33
|
-
onSelect
|
|
34
|
-
} = _ref;
|
|
35
|
-
const {
|
|
36
|
-
updateBlockListSettings
|
|
37
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
38
|
-
const {
|
|
39
|
-
OffCanvasEditor,
|
|
40
|
-
LeafMoreMenu
|
|
41
|
-
} = (0, _privateApis.unlock)(_blockEditor.privateApis); //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
|
|
42
|
-
//Think through a better way of doing this, possible with adding allowed blocks to block library metadata
|
|
43
|
-
|
|
44
|
-
(0, _element.useEffect)(() => {
|
|
45
|
-
updateBlockListSettings('', {
|
|
46
|
-
allowedBlocks: ALLOWED_BLOCKS['core/navigation']
|
|
47
|
-
});
|
|
48
|
-
innerBlocks.forEach(block => {
|
|
49
|
-
if (ALLOWED_BLOCKS[block.name]) {
|
|
50
|
-
updateBlockListSettings(block.clientId, {
|
|
51
|
-
allowedBlocks: ALLOWED_BLOCKS[block.name]
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}, [updateBlockListSettings, innerBlocks]);
|
|
56
|
-
return (0, _element.createElement)(OffCanvasEditor, {
|
|
57
|
-
blocks: innerBlocks,
|
|
58
|
-
onSelect: onSelect,
|
|
59
|
-
LeafMoreMenu: LeafMoreMenu
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=navigation-menu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/navigation-menu.js"],"names":["ALLOWED_BLOCKS","NavigationMenu","innerBlocks","onSelect","updateBlockListSettings","blockEditorStore","OffCanvasEditor","LeafMoreMenu","blockEditorPrivateApis","allowedB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,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst ALLOWED_BLOCKS = {\n\t'core/navigation': [\n\t\t'core/navigation-link',\n\t\t'core/search',\n\t\t'core/social-links',\n\t\t'core/page-list',\n\t\t'core/spacer',\n\t\t'core/home-link',\n\t\t'core/site-title',\n\t\t'core/site-logo',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/social-links': [ 'core/social-link' ],\n\t'core/navigation-submenu': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/navigation-link': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n};\n\nexport default function NavigationMenu( { innerBlocks, onSelect } ) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\n\tconst { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\t//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList\n\t//Think through a better way of doing this, possible with adding allowed blocks to block library metadata\n\tuseEffect( () => {\n\t\tupdateBlockListSettings( '', {\n\t\t\tallowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],\n\t\t} );\n\t\tinnerBlocks.forEach( ( block ) => {\n\t\t\tif ( ALLOWED_BLOCKS[ block.name ] ) {\n\t\t\t\tupdateBlockListSettings( block.clientId, {\n\t\t\t\t\tallowedBlocks: ALLOWED_BLOCKS[ block.name ],\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [ updateBlockListSettings, innerBlocks ] );\n\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ innerBlocks }\n\t\t\tonSelect={ onSelect }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t/>\n\t);\n}\n"]}
|