@wordpress/edit-site 5.3.2 → 5.4.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 +3 -0
- package/build/components/add-new-template/new-template-part.js +8 -5
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +9 -25
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +4 -3
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +3 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +28 -24
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +6 -6
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +7 -4
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/color-utils.js +1 -1
- package/build/components/global-styles/color-utils.js.map +1 -1
- package/build/components/global-styles/context-menu.js +16 -3
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +3 -3
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +10 -9
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +2 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +10 -5
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/header.js +4 -2
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/hooks.js +16 -53
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/navigation-button.js +1 -1
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +5 -3
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +2 -2
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +5 -4
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +14 -3
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +9 -7
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +10 -8
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +5 -5
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +10 -8
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +5 -4
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -2
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +5 -4
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -3
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +4 -5
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/subtitle.js +3 -2
- package/build/components/global-styles/subtitle.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +24 -301
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +2 -2
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/ui.js +3 -10
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +2 -2
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +6 -3
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/layout/index.js +10 -23
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +1 -1
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/list/table.js +1 -0
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-inspector/index.js +0 -29
- package/build/components/navigation-inspector/index.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +6 -4
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/save-panel/index.js +4 -3
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +18 -23
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/index.js +9 -2
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/last-revision.js +84 -0
- package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
- package/build/components/sidebar-navigation-screen/index.js +28 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +72 -0
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +70 -0
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +32 -82
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +43 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
- package/build/components/site-hub/index.js +14 -49
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/start-template-options/index.js +175 -0
- package/build/components/start-template-options/index.js.map +1 -0
- package/build/components/style-book/index.js +10 -3
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +55 -20
- 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 +3 -3
- 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-sidebar-path-with-url.js → use-sync-path-with-url.js} +12 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
- package/build/components/use-edited-entity-record/index.js +6 -2
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +7 -6
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/{experiments.js → private-apis.js} +3 -3
- package/build/private-apis.js.map +1 -0
- package/build/store/index.js +3 -3
- package/build/store/index.js.map +1 -1
- package/build/utils/get-is-list-page.js +5 -6
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +7 -4
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +8 -22
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- 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/block-editor/index.js +3 -3
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +27 -25
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +8 -8
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +8 -5
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/color-utils.js +2 -2
- package/build-module/components/global-styles/color-utils.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +13 -2
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +4 -4
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +12 -11
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +3 -3
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +11 -6
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +5 -3
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +15 -52
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/navigation-button.js +2 -2
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +6 -4
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +3 -3
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +7 -6
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +12 -3
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +11 -9
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +12 -10
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +5 -5
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +12 -10
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +7 -6
- package/build-module/components/global-styles/screen-link-color.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/screen-style-variations.js +3 -3
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +7 -6
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +6 -4
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +6 -7
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/subtitle.js +3 -2
- package/build-module/components/global-styles/subtitle.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +29 -302
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +3 -3
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/ui.js +4 -11
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +3 -3
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +6 -3
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/layout/index.js +10 -23
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +1 -1
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/list/table.js +1 -0
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-inspector/index.js +0 -27
- package/build-module/components/navigation-inspector/index.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +7 -5
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/save-panel/index.js +3 -2
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +15 -21
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/index.js +9 -4
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/last-revision.js +70 -0
- package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen/index.js +27 -9
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +55 -0
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +53 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +34 -81
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
- package/build-module/components/site-hub/index.js +14 -46
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +156 -0
- package/build-module/components/start-template-options/index.js.map +1 -0
- package/build-module/components/style-book/index.js +11 -4
- 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 +55 -21
- 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 +1 -1
- 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-sidebar-path-with-url.js → use-sync-path-with-url.js} +11 -11
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
- package/build-module/components/use-edited-entity-record/index.js +6 -2
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +9 -8
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/{experiments.js → private-apis.js} +2 -2
- package/build-module/private-apis.js.map +1 -0
- package/build-module/store/index.js +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +5 -6
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-style/style-rtl.css +91 -41
- package/build-style/style.css +91 -41
- package/package.json +31 -31
- package/src/components/add-new-template/new-template-part.js +7 -4
- package/src/components/add-new-template/new-template.js +9 -22
- package/src/components/app/index.js +0 -1
- package/src/components/block-editor/editor-canvas.js +2 -1
- package/src/components/block-editor/index.js +3 -3
- package/src/components/editor/index.js +31 -28
- package/src/components/global-styles/border-panel.js +8 -8
- package/src/components/global-styles/color-palette-panel.js +6 -3
- package/src/components/global-styles/color-utils.js +2 -3
- package/src/components/global-styles/context-menu.js +17 -2
- package/src/components/global-styles/custom-css.js +4 -4
- package/src/components/global-styles/dimensions-panel.js +15 -11
- package/src/components/global-styles/global-styles-provider.js +3 -3
- package/src/components/global-styles/gradients-palette-panel.js +7 -4
- package/src/components/global-styles/header.js +9 -3
- package/src/components/global-styles/hooks.js +20 -93
- package/src/components/global-styles/navigation-button.js +4 -2
- package/src/components/global-styles/palette.js +4 -4
- package/src/components/global-styles/preview.js +3 -3
- package/src/components/global-styles/screen-background-color.js +6 -5
- package/src/components/global-styles/screen-block-list.js +19 -3
- package/src/components/global-styles/screen-button-color.js +11 -9
- package/src/components/global-styles/screen-colors.js +10 -10
- package/src/components/global-styles/screen-css.js +14 -7
- package/src/components/global-styles/screen-heading-color.js +12 -10
- package/src/components/global-styles/screen-link-color.js +6 -5
- package/src/components/global-styles/screen-root.js +3 -3
- package/src/components/global-styles/screen-style-variations.js +3 -3
- package/src/components/global-styles/screen-text-color.js +6 -5
- package/src/components/global-styles/screen-typography.js +4 -4
- package/src/components/global-styles/shadow-panel.js +9 -6
- package/src/components/global-styles/style.scss +7 -1
- package/src/components/global-styles/subtitle.js +5 -2
- package/src/components/global-styles/typography-panel.js +31 -395
- package/src/components/global-styles/typography-preview.js +3 -3
- package/src/components/global-styles/ui.js +3 -8
- package/src/components/global-styles-renderer/index.js +3 -3
- package/src/components/header-edit-mode/index.js +6 -3
- package/src/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/src/components/layout/index.js +35 -48
- package/src/components/layout/style.scss +11 -23
- package/src/components/list/actions/rename-menu-item.js +1 -1
- package/src/components/list/table.js +4 -0
- package/src/components/navigation-inspector/index.js +0 -32
- package/src/components/navigation-inspector/navigation-menu.js +10 -4
- package/src/components/save-panel/index.js +4 -1
- package/src/components/sidebar/index.js +14 -19
- package/src/components/sidebar-edit-mode/index.js +1 -1
- package/src/components/sidebar-edit-mode/template-card/index.js +24 -14
- package/src/components/sidebar-edit-mode/template-card/last-revision.js +75 -0
- package/src/components/sidebar-edit-mode/template-card/style.scss +4 -0
- package/src/components/sidebar-navigation-screen/index.js +27 -11
- package/src/components/sidebar-navigation-screen/style.scss +4 -6
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +52 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +1 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +0 -4
- package/src/components/sidebar-navigation-screen-template/index.js +52 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +49 -83
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
- package/src/components/site-hub/index.js +67 -122
- package/src/components/site-hub/style.scss +1 -11
- package/src/components/start-template-options/index.js +171 -0
- package/src/components/start-template-options/style.scss +76 -0
- package/src/components/style-book/index.js +11 -7
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +48 -14
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/src/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +10 -10
- package/src/components/use-edited-entity-record/index.js +6 -2
- package/src/hooks/push-changes-to-global-styles/index.js +29 -24
- package/src/{experiments.js → private-apis.js} +1 -1
- package/src/store/index.js +1 -1
- package/src/style.scss +1 -0
- package/src/utils/get-is-list-page.js +5 -5
- package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
- package/build/experiments.js.map +0 -1
- package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
- package/build-module/experiments.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
|
+
import { Button } from '@wordpress/components';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
14
|
+
import useEditedEntityRecord from '../use-edited-entity-record';
|
|
15
|
+
import { unlock } from '../../private-apis';
|
|
16
|
+
import { store as editSiteStore } from '../../store';
|
|
17
|
+
const config = {
|
|
18
|
+
wp_template: {
|
|
19
|
+
path: '/templates/single'
|
|
20
|
+
},
|
|
21
|
+
wp_template_part: {
|
|
22
|
+
path: '/template-parts/single'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export default function SidebarNavigationScreenTemplate(_ref) {
|
|
26
|
+
let {
|
|
27
|
+
postType = 'wp_template'
|
|
28
|
+
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
setCanvasMode
|
|
31
|
+
} = unlock(useDispatch(editSiteStore));
|
|
32
|
+
const {
|
|
33
|
+
getDescription,
|
|
34
|
+
getTitle,
|
|
35
|
+
record
|
|
36
|
+
} = useEditedEntityRecord();
|
|
37
|
+
let description = getDescription();
|
|
38
|
+
|
|
39
|
+
if (!description && record.is_custom) {
|
|
40
|
+
description = __('This is a custom template that can be applied manually to any Post or Page.');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return createElement(SidebarNavigationScreen, {
|
|
44
|
+
path: config[postType].path,
|
|
45
|
+
title: getTitle(),
|
|
46
|
+
actions: createElement(Button, {
|
|
47
|
+
variant: "primary",
|
|
48
|
+
onClick: () => setCanvasMode('edit')
|
|
49
|
+
}, __('Edit')),
|
|
50
|
+
content: description ? createElement("p", null, description) : undefined
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"names":["__","useDispatch","Button","SidebarNavigationScreen","useEditedEntityRecord","unlock","store","editSiteStore","config","wp_template","path","wp_template_part","SidebarNavigationScreenTemplate","postType","setCanvasMode","getDescription","getTitle","record","description","is_custom","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,qBAAP,MAAkC,6BAAlC;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,IAAI,EAAE;AADM,GADC;AAIdC,EAAAA,gBAAgB,EAAE;AACjBD,IAAAA,IAAI,EAAE;AADW;AAJJ,CAAf;AASA,eAAe,SAASE,+BAAT,OAEX;AAAA,MAFqD;AACxDC,IAAAA,QAAQ,GAAG;AAD6C,GAErD;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAoBT,MAAM,CAAEJ,WAAW,CAAEM,aAAF,CAAb,CAAhC;AACA,QAAM;AAAEQ,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA;AAA5B,MAAuCb,qBAAqB,EAAlE;AACA,MAAIc,WAAW,GAAGH,cAAc,EAAhC;;AACA,MAAK,CAAEG,WAAF,IAAiBD,MAAM,CAACE,SAA7B,EAAyC;AACxCD,IAAAA,WAAW,GAAGlB,EAAE,CACf,6EADe,CAAhB;AAGA;;AAED,SACC,cAAC,uBAAD;AACC,IAAA,IAAI,EAAGQ,MAAM,CAAEK,QAAF,CAAN,CAAmBH,IAD3B;AAEC,IAAA,KAAK,EAAGM,QAAQ,EAFjB;AAGC,IAAA,OAAO,EACN,cAAC,MAAD;AACC,MAAA,OAAO,EAAC,SADT;AAEC,MAAA,OAAO,EAAG,MAAMF,aAAa,CAAE,MAAF;AAF9B,OAIGd,EAAE,CAAE,MAAF,CAJL,CAJF;AAWC,IAAA,OAAO,EAAGkB,WAAW,GAAG,yBAAKA,WAAL,CAAH,GAA4BE;AAXlD,IADD;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates/single',\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts/single',\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplate( {\n\tpostType = 'wp_template',\n} ) {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord();\n\tlet description = getDescription();\n\tif ( ! description && record.is_custom ) {\n\t\tdescription = __(\n\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\ttitle={ getTitle() }\n\t\t\tactions={\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t\tcontent={ description ? <p>{ description }</p> : undefined }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -4,9 +4,8 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
7
|
+
import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item } from '@wordpress/components';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
10
9
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
11
10
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
@@ -17,28 +16,7 @@ import { useViewportMatch } from '@wordpress/compose';
|
|
|
17
16
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
18
17
|
import { useLink } from '../routes/link';
|
|
19
18
|
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
20
|
-
import { useLocation } from '../routes';
|
|
21
|
-
import { store as editSiteStore } from '../../store';
|
|
22
19
|
import AddNewTemplate from '../add-new-template';
|
|
23
|
-
|
|
24
|
-
function omit(object, keys) {
|
|
25
|
-
return Object.fromEntries(Object.entries(object).filter(_ref => {
|
|
26
|
-
let [key] = _ref;
|
|
27
|
-
return !keys.includes(key);
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const Item = _ref2 => {
|
|
32
|
-
let {
|
|
33
|
-
item
|
|
34
|
-
} = _ref2;
|
|
35
|
-
const linkInfo = useLink(item.params);
|
|
36
|
-
const props = item.params ? { ...omit(item, 'params'),
|
|
37
|
-
...linkInfo
|
|
38
|
-
} : item;
|
|
39
|
-
return createElement(SidebarNavigationItem, props);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
20
|
const config = {
|
|
43
21
|
wp_template: {
|
|
44
22
|
path: '/templates',
|
|
@@ -59,65 +37,39 @@ const config = {
|
|
|
59
37
|
}
|
|
60
38
|
}
|
|
61
39
|
};
|
|
62
|
-
|
|
40
|
+
|
|
41
|
+
const TemplateItem = _ref => {
|
|
63
42
|
let {
|
|
64
|
-
postType
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
postType,
|
|
44
|
+
postId,
|
|
45
|
+
...props
|
|
46
|
+
} = _ref;
|
|
47
|
+
const linkInfo = useLink({
|
|
48
|
+
postType,
|
|
49
|
+
postId,
|
|
50
|
+
path: config[postType].path + '/single'
|
|
51
|
+
});
|
|
52
|
+
return createElement(SidebarNavigationItem, _extends({}, linkInfo, props));
|
|
53
|
+
};
|
|
72
54
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} =
|
|
77
|
-
|
|
78
|
-
getEditedPostType,
|
|
79
|
-
getEditedPostId
|
|
80
|
-
} = select(editSiteStore);
|
|
81
|
-
return {
|
|
82
|
-
editedPostId: getEditedPostId(),
|
|
83
|
-
editedPostType: getEditedPostType()
|
|
84
|
-
};
|
|
85
|
-
}, []);
|
|
55
|
+
export default function SidebarNavigationScreenTemplates(_ref2) {
|
|
56
|
+
let {
|
|
57
|
+
postType = 'wp_template'
|
|
58
|
+
} = _ref2;
|
|
59
|
+
const isMobileViewport = useViewportMatch('medium', '<');
|
|
86
60
|
const {
|
|
87
61
|
records: templates,
|
|
88
62
|
isResolving: isLoading
|
|
89
63
|
} = useEntityRecords('postType', postType, {
|
|
90
64
|
per_page: -1
|
|
91
65
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}];
|
|
98
|
-
} else if (!templates && !isLoading) {
|
|
99
|
-
items = [{
|
|
100
|
-
children: config[postType].labels.notFound
|
|
101
|
-
}];
|
|
102
|
-
} else {
|
|
103
|
-
items = templates === null || templates === void 0 ? void 0 : templates.map(template => {
|
|
104
|
-
var _template$title;
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
params: {
|
|
108
|
-
postType,
|
|
109
|
-
postId: template.id
|
|
110
|
-
},
|
|
111
|
-
children: decodeEntities(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug),
|
|
112
|
-
'aria-current': params.postType === postType && params.postId === template.id || // This is a special case for the home page.
|
|
113
|
-
editedPostId === template.id && editedPostType === postType && !!params.postId ? 'page' : undefined
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
66
|
+
const browseAllLink = useLink({
|
|
67
|
+
postType,
|
|
68
|
+
postId: undefined,
|
|
69
|
+
path: config[postType].path + '/all'
|
|
70
|
+
});
|
|
118
71
|
return createElement(SidebarNavigationScreen, {
|
|
119
72
|
path: config[postType].path,
|
|
120
|
-
parentTitle: __('Design'),
|
|
121
73
|
title: config[postType].labels.title,
|
|
122
74
|
actions: !isMobileViewport && createElement(AddNewTemplate, {
|
|
123
75
|
templateType: postType,
|
|
@@ -125,16 +77,17 @@ export default function SidebarNavigationScreenTemplates(_ref3) {
|
|
|
125
77
|
className: 'edit-site-sidebar-navigation-screen-templates__add-button'
|
|
126
78
|
}
|
|
127
79
|
}),
|
|
128
|
-
content: createElement(Fragment, null, createElement(ItemGroup, null,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
80
|
+
content: createElement(Fragment, null, isLoading && config[postType].labels.loading, !isLoading && createElement(ItemGroup, null, !(templates !== null && templates !== void 0 && templates.length) && createElement(Item, null, config[postType].labels.notFound), (templates !== null && templates !== void 0 ? templates : []).map(template => {
|
|
81
|
+
var _template$title;
|
|
82
|
+
|
|
83
|
+
return createElement(TemplateItem, {
|
|
84
|
+
postType: postType,
|
|
85
|
+
postId: template.id,
|
|
86
|
+
key: template.id
|
|
87
|
+
}, decodeEntities(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug));
|
|
88
|
+
}), !isMobileViewport && createElement(SidebarNavigationItem, _extends({
|
|
132
89
|
className: "edit-site-sidebar-navigation-screen-templates__see-all"
|
|
133
|
-
},
|
|
134
|
-
postType,
|
|
135
|
-
postId: undefined
|
|
136
|
-
}), {
|
|
137
|
-
"aria-current": params.postType === postType && !params.postId ? 'page' : undefined,
|
|
90
|
+
}, browseAllLink, {
|
|
138
91
|
children: config[postType].labels.manage
|
|
139
92
|
}))))
|
|
140
93
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["__experimentalItemGroup","ItemGroup","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__","useEntityRecords","decodeEntities","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","AddNewTemplate","config","wp_template","path","labels","title","loading","notFound","manage","wp_template_part","TemplateItem","postType","postId","props","linkInfo","SidebarNavigationScreenTemplates","isMobileViewport","records","templates","isResolving","isLoading","per_page","browseAllLink","undefined","className","length","map","template","id","rendered","slug"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,kBAAkB,IAAIC,IAFvB,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AAEA,MAAMC,MAAM,GAAG;AACdC,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,CAACG,IAFK,CALjB,CAD0B;AAAA,KAAzB,CANH,EAkBG,CAAEd,gBAAF,IACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAC;AADX,OAEMM,aAFN;AAGC,MAAA,QAAQ,EACPrB,MAAM,CAAEU,QAAF,CAAN,CAAmBP,MAAnB,CAA0BI;AAJ5B,OAnBF,CAHF;AAfF,IADD;AAoDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport AddNewTemplate from '../add-new-template';\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates',\n\t\tlabels: {\n\t\t\ttitle: __( 'Templates' ),\n\t\t\tloading: __( 'Loading templates' ),\n\t\t\tnotFound: __( 'No templates found' ),\n\t\t\tmanage: __( 'Manage all templates' ),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts',\n\t\tlabels: {\n\t\t\ttitle: __( 'Template parts' ),\n\t\t\tloading: __( 'Loading template parts' ),\n\t\t\tnotFound: __( 'No template parts found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t},\n\t},\n};\n\nconst TemplateItem = ( { postType, postId, ...props } ) => {\n\tconst linkInfo = useLink( {\n\t\tpostType,\n\t\tpostId,\n\t\tpath: config[ postType ].path + '/single',\n\t} );\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenTemplates( {\n\tpostType = 'wp_template',\n} ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\n\tconst browseAllLink = useLink( {\n\t\tpostType,\n\t\tpostId: undefined,\n\t\tpath: config[ postType ].path + '/all',\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\ttitle={ config[ postType ].labels.title }\n\t\t\tactions={\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t'edit-site-sidebar-navigation-screen-templates__add-button',\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ isLoading && config[ postType ].labels.loading }\n\t\t\t\t\t{ ! isLoading && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t{ ! templates?.length && (\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t{ config[ postType ].labels.notFound }\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( templates ?? [] ).map( ( template ) => (\n\t\t\t\t\t\t\t\t<TemplateItem\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</TemplateItem>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t\t\t{ ...browseAllLink }\n\t\t\t\t\t\t\t\t\tchildren={\n\t\t\t\t\t\t\t\t\t\tconfig[ postType ].labels.manage\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</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
12
|
+
const config = {
|
|
13
|
+
wp_template: {
|
|
14
|
+
path: '/templates/all',
|
|
15
|
+
title: __('All templates')
|
|
16
|
+
},
|
|
17
|
+
wp_template_part: {
|
|
18
|
+
path: '/template-parts/all',
|
|
19
|
+
title: __('All template parts')
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export default function SidebarNavigationScreenTemplatesBrowse(_ref) {
|
|
23
|
+
let {
|
|
24
|
+
postType = 'wp_template'
|
|
25
|
+
} = _ref;
|
|
26
|
+
return createElement(SidebarNavigationScreen, {
|
|
27
|
+
path: config[postType].path,
|
|
28
|
+
title: config[postType].title
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js"],"names":["__","SidebarNavigationScreen","config","wp_template","path","title","wp_template_part","SidebarNavigationScreenTemplatesBrowse","postType"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,IAAI,EAAE,gBADM;AAEZC,IAAAA,KAAK,EAAEL,EAAE,CAAE,eAAF;AAFG,GADC;AAKdM,EAAAA,gBAAgB,EAAE;AACjBF,IAAAA,IAAI,EAAE,qBADW;AAEjBC,IAAAA,KAAK,EAAEL,EAAE,CAAE,oBAAF;AAFQ;AALJ,CAAf;AAWA,eAAe,SAASO,sCAAT,OAEX;AAAA,MAF4D;AAC/DC,IAAAA,QAAQ,GAAG;AADoD,GAE5D;AACH,SACC,cAAC,uBAAD;AACC,IAAA,IAAI,EAAGN,MAAM,CAAEM,QAAF,CAAN,CAAmBJ,IAD3B;AAEC,IAAA,KAAK,EAAGF,MAAM,CAAEM,QAAF,CAAN,CAAmBH;AAF5B,IADD;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates/all',\n\t\ttitle: __( 'All templates' ),\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts/all',\n\t\ttitle: __( 'All template parts' ),\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplatesBrowse( {\n\tpostType = 'wp_template',\n} ) {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\ttitle={ config[ postType ].title }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -10,8 +10,8 @@ import classnames from 'classnames';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
-
import { Button, __unstableMotion as motion, __experimentalHStack as HStack
|
|
14
|
-
import { useReducedMotion
|
|
13
|
+
import { Button, __unstableMotion as motion, __experimentalHStack as HStack } from '@wordpress/components';
|
|
14
|
+
import { useReducedMotion } from '@wordpress/compose';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
17
17
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -21,50 +21,32 @@ import { forwardRef } from '@wordpress/element';
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import { store as editSiteStore } from '../../store';
|
|
24
|
-
import { useLocation } from '../routes';
|
|
25
|
-
import getIsListPage from '../../utils/get-is-list-page';
|
|
26
24
|
import SiteIcon from '../site-icon';
|
|
27
|
-
import
|
|
28
|
-
import { unlock } from '../../experiments';
|
|
25
|
+
import { unlock } from '../../private-apis';
|
|
29
26
|
const HUB_ANIMATION_DURATION = 0.3;
|
|
30
|
-
const SiteHub = forwardRef((
|
|
31
|
-
let {
|
|
32
|
-
isMobileCanvasVisible,
|
|
33
|
-
setIsMobileCanvasVisible,
|
|
34
|
-
...props
|
|
35
|
-
} = _ref;
|
|
36
|
-
const {
|
|
37
|
-
params
|
|
38
|
-
} = useLocation();
|
|
39
|
-
const isListPage = getIsListPage(params);
|
|
40
|
-
const isEditorPage = !isListPage;
|
|
27
|
+
const SiteHub = forwardRef((props, ref) => {
|
|
41
28
|
const {
|
|
42
29
|
canvasMode,
|
|
43
|
-
dashboardLink
|
|
44
|
-
entityConfig
|
|
30
|
+
dashboardLink
|
|
45
31
|
} = useSelect(select => {
|
|
46
32
|
select(editSiteStore).getEditedPostType();
|
|
47
33
|
const {
|
|
48
34
|
getCanvasMode,
|
|
49
|
-
getSettings
|
|
50
|
-
getEditedPostType
|
|
35
|
+
getSettings
|
|
51
36
|
} = unlock(select(editSiteStore));
|
|
52
37
|
return {
|
|
53
38
|
canvasMode: getCanvasMode(),
|
|
54
|
-
dashboardLink: getSettings().__experimentalDashboardLink
|
|
55
|
-
entityConfig: select(coreStore).getEntityConfig('postType', getEditedPostType())
|
|
39
|
+
dashboardLink: getSettings().__experimentalDashboardLink
|
|
56
40
|
};
|
|
57
41
|
}, []);
|
|
58
42
|
const disableMotion = useReducedMotion();
|
|
59
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
60
43
|
const {
|
|
61
44
|
setCanvasMode
|
|
62
45
|
} = unlock(useDispatch(editSiteStore));
|
|
63
46
|
const {
|
|
64
47
|
clearSelectedBlock
|
|
65
48
|
} = useDispatch(blockEditorStore);
|
|
66
|
-
const
|
|
67
|
-
const isBackToDashboardButton = !isMobileViewport && canvasMode === 'view' || isMobileViewport && !isMobileCanvasVisible;
|
|
49
|
+
const isBackToDashboardButton = canvasMode === 'view';
|
|
68
50
|
const showLabels = canvasMode !== 'edit';
|
|
69
51
|
const siteIconButtonProps = isBackToDashboardButton ? {
|
|
70
52
|
href: dashboardLink || 'index.php',
|
|
@@ -73,13 +55,14 @@ const SiteHub = forwardRef((_ref, ref) => {
|
|
|
73
55
|
label: __('Open Navigation Sidebar'),
|
|
74
56
|
onClick: () => {
|
|
75
57
|
clearSelectedBlock();
|
|
76
|
-
setIsMobileCanvasVisible(false);
|
|
77
58
|
setCanvasMode('view');
|
|
78
59
|
}
|
|
79
60
|
};
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
61
|
+
const siteTitle = useSelect(select => {
|
|
62
|
+
var _select$getEntityReco;
|
|
63
|
+
|
|
64
|
+
return (_select$getEntityReco = select(coreStore).getEntityRecord('root', 'site')) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.title;
|
|
65
|
+
}, []);
|
|
83
66
|
return createElement(motion.div, _extends({
|
|
84
67
|
ref: ref
|
|
85
68
|
}, props, {
|
|
@@ -106,22 +89,7 @@ const SiteHub = forwardRef((_ref, ref) => {
|
|
|
106
89
|
className: "edit-site-layout__view-mode-toggle"
|
|
107
90
|
}), createElement(SiteIcon, {
|
|
108
91
|
className: "edit-site-layout__view-mode-toggle-icon"
|
|
109
|
-
}))), showLabels && createElement(
|
|
110
|
-
spacing: 0
|
|
111
|
-
}, createElement("div", {
|
|
112
|
-
className: "edit-site-site-hub__title"
|
|
113
|
-
}, getTitle()), createElement("div", {
|
|
114
|
-
className: "edit-site-site-hub__post-type"
|
|
115
|
-
}, entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.label))), showEditButton && createElement(Button, {
|
|
116
|
-
className: "edit-site-site-hub__edit-button",
|
|
117
|
-
onClick: () => {
|
|
118
|
-
setCanvasMode('edit');
|
|
119
|
-
},
|
|
120
|
-
variant: "primary"
|
|
121
|
-
}, __('Edit')), isMobileViewport && !isMobileCanvasVisible && createElement(Button, {
|
|
122
|
-
onClick: () => setIsMobileCanvasVisible(true),
|
|
123
|
-
variant: "primary"
|
|
124
|
-
}, __('View Editor')));
|
|
92
|
+
}))), showLabels && createElement("div", null, siteTitle)));
|
|
125
93
|
});
|
|
126
94
|
export default SiteHub;
|
|
127
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["classnames","useSelect","useDispatch","Button","__unstableMotion","motion","__experimentalHStack","HStack","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["classnames","useSelect","useDispatch","Button","__unstableMotion","motion","__experimentalHStack","HStack","useReducedMotion","__","store","blockEditorStore","coreStore","forwardRef","editSiteStore","SiteIcon","unlock","HUB_ANIMATION_DURATION","SiteHub","props","ref","canvasMode","dashboardLink","select","getEditedPostType","getCanvasMode","getSettings","__experimentalDashboardLink","disableMotion","setCanvasMode","clearSelectedBlock","isBackToDashboardButton","showLabels","siteIconButtonProps","href","label","onClick","siteTitle","getEntityRecord","title","className","type","duration","ease"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAv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C,QAAD;AAAU,IAAA,SAAS,EAAC;AAApB,IAJD,CATD,CALD,EAsBGD,UAAU,IAAI,2BAAOK,SAAP,CAtBjB,CAXD,CADD;AAsCA,CAxEyB,CAA1B;AA0EA,eAAenB,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../private-apis';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nconst SiteHub = forwardRef( ( props, ref ) => {\n\tconst { canvasMode, dashboardLink } = useSelect( ( select ) => {\n\t\tselect( editSiteStore ).getEditedPostType();\n\t\tconst { getCanvasMode, getSettings } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\t\treturn {\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t};\n\t}, [] );\n\tconst disableMotion = useReducedMotion();\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst isBackToDashboardButton = canvasMode === 'view';\n\tconst showLabels = canvasMode !== 'edit';\n\tconst siteIconButtonProps = isBackToDashboardButton\n\t\t? {\n\t\t\t\thref: dashboardLink || 'index.php',\n\t\t\t\t'aria-label': __( 'Go back to the dashboard' ),\n\t\t }\n\t\t: {\n\t\t\t\tlabel: __( 'Open Navigation Sidebar' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetCanvasMode( 'view' );\n\t\t\t\t},\n\t\t };\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )?.title,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames( 'edit-site-site-hub', props.className ) }\n\t\t\tlayout\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-site-hub__text-content\"\n\t\t\t\tspacing=\"0\"\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"edit-site-site-hub__view-mode-toggle-container\"\n\t\t\t\t\tlayout\n\t\t\t\t\ttransition={ {\n\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t</Button>\n\t\t\t\t</motion.div>\n\n\t\t\t\t{ showLabels && <div>{ siteTitle }</div> }\n\t\t\t</HStack>\n\t\t</motion.div>\n\t);\n} );\n\nexport default SiteHub;\n"]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Modal } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
9
|
+
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { useAsyncList } from '@wordpress/compose';
|
|
12
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
|
+
import { parse } from '@wordpress/blocks';
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { store as editSiteStore } from '../../store';
|
|
19
|
+
import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
|
|
20
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
21
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
22
|
+
|
|
23
|
+
function useFallbackTemplateContent(slug) {
|
|
24
|
+
let isCustom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
25
|
+
const [templateContent, setTemplateContent] = useState('');
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
apiFetch({
|
|
28
|
+
path: addQueryArgs('/wp/v2/templates/lookup', {
|
|
29
|
+
slug,
|
|
30
|
+
is_custom: isCustom,
|
|
31
|
+
ignore_empty: true
|
|
32
|
+
})
|
|
33
|
+
}).then(_ref => {
|
|
34
|
+
let {
|
|
35
|
+
content
|
|
36
|
+
} = _ref;
|
|
37
|
+
return setTemplateContent(content.raw);
|
|
38
|
+
});
|
|
39
|
+
}, [slug]);
|
|
40
|
+
return templateContent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const START_BLANK_TITLE = __('Start blank');
|
|
44
|
+
|
|
45
|
+
function PatternSelection(_ref2) {
|
|
46
|
+
let {
|
|
47
|
+
fallbackContent,
|
|
48
|
+
onChoosePattern,
|
|
49
|
+
postType
|
|
50
|
+
} = _ref2;
|
|
51
|
+
const [,, onChange] = useEntityBlockEditor('postType', postType);
|
|
52
|
+
const blockPatterns = useMemo(() => [{
|
|
53
|
+
name: 'fallback',
|
|
54
|
+
blocks: parse(fallbackContent),
|
|
55
|
+
title: __('Fallback content')
|
|
56
|
+
}, {
|
|
57
|
+
name: 'start-blank',
|
|
58
|
+
blocks: parse('<!-- wp:paragraph --><p></p><!-- /wp:paragraph -->'),
|
|
59
|
+
title: START_BLANK_TITLE
|
|
60
|
+
}], [fallbackContent]);
|
|
61
|
+
const shownBlockPatterns = useAsyncList(blockPatterns);
|
|
62
|
+
return createElement("div", {
|
|
63
|
+
className: "edit-site-start-template-options__pattern-container",
|
|
64
|
+
style: {
|
|
65
|
+
'--wp-edit-site-start-template-options-start-blank': `"${START_BLANK_TITLE}"`
|
|
66
|
+
}
|
|
67
|
+
}, createElement(BlockPatternsList, {
|
|
68
|
+
blockPatterns: blockPatterns,
|
|
69
|
+
shownPatterns: shownBlockPatterns,
|
|
70
|
+
onClickPattern: (pattern, blocks) => {
|
|
71
|
+
onChange('start-blank' === pattern.name ? [] : blocks, {
|
|
72
|
+
selection: undefined
|
|
73
|
+
});
|
|
74
|
+
onChoosePattern();
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function StartModal(_ref3) {
|
|
80
|
+
let {
|
|
81
|
+
slug,
|
|
82
|
+
isCustom,
|
|
83
|
+
onClose,
|
|
84
|
+
postType
|
|
85
|
+
} = _ref3;
|
|
86
|
+
const fallbackContent = useFallbackTemplateContent(slug, isCustom);
|
|
87
|
+
|
|
88
|
+
if (!fallbackContent) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return createElement(Modal, {
|
|
93
|
+
className: "edit-site-start-template-options__modal",
|
|
94
|
+
title: __('Choose a pattern'),
|
|
95
|
+
closeLabel: __('Cancel'),
|
|
96
|
+
focusOnMount: "firstElement",
|
|
97
|
+
onRequestClose: onClose
|
|
98
|
+
}, createElement("div", {
|
|
99
|
+
className: "edit-site-start-template-options__modal-content"
|
|
100
|
+
}, createElement(PatternSelection, {
|
|
101
|
+
fallbackContent: fallbackContent,
|
|
102
|
+
slug: slug,
|
|
103
|
+
isCustom: isCustom,
|
|
104
|
+
postType: postType,
|
|
105
|
+
onChoosePattern: () => {
|
|
106
|
+
onClose();
|
|
107
|
+
}
|
|
108
|
+
})));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const START_TEMPLATE_MODAL_STATES = {
|
|
112
|
+
INITIAL: 'INITIAL',
|
|
113
|
+
CLOSED: 'CLOSED'
|
|
114
|
+
};
|
|
115
|
+
export default function StartTemplateOptions() {
|
|
116
|
+
const [modalState, setModalState] = useState(START_TEMPLATE_MODAL_STATES.INITIAL);
|
|
117
|
+
const {
|
|
118
|
+
shouldOpenModel,
|
|
119
|
+
slug,
|
|
120
|
+
isCustom,
|
|
121
|
+
postType
|
|
122
|
+
} = useSelect(select => {
|
|
123
|
+
const {
|
|
124
|
+
getEditedPostType,
|
|
125
|
+
getEditedPostId
|
|
126
|
+
} = select(editSiteStore);
|
|
127
|
+
|
|
128
|
+
const _postType = getEditedPostType();
|
|
129
|
+
|
|
130
|
+
const postId = getEditedPostId();
|
|
131
|
+
const {
|
|
132
|
+
__experimentalGetDirtyEntityRecords,
|
|
133
|
+
getEditedEntityRecord
|
|
134
|
+
} = select(coreStore);
|
|
135
|
+
const templateRecord = getEditedEntityRecord('postType', _postType, postId);
|
|
136
|
+
const hasDirtyEntityRecords = __experimentalGetDirtyEntityRecords().length > 0;
|
|
137
|
+
return {
|
|
138
|
+
shouldOpenModel: !hasDirtyEntityRecords && '' === templateRecord.content && 'wp_template' === _postType && !select(preferencesStore).get('core/edit-site', 'welcomeGuide'),
|
|
139
|
+
slug: templateRecord.slug,
|
|
140
|
+
isCustom: templateRecord.is_custom,
|
|
141
|
+
postType: _postType
|
|
142
|
+
};
|
|
143
|
+
}, []);
|
|
144
|
+
|
|
145
|
+
if (modalState === START_TEMPLATE_MODAL_STATES.INITIAL && !shouldOpenModel || modalState === START_TEMPLATE_MODAL_STATES.CLOSED) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return createElement(StartModal, {
|
|
150
|
+
slug: slug,
|
|
151
|
+
isCustom: isCustom,
|
|
152
|
+
postType: postType,
|
|
153
|
+
onClose: () => setModalState(START_TEMPLATE_MODAL_STATES.CLOSED)
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=index.js.map
|