@wordpress/edit-site 4.19.0 → 5.1.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 +17 -0
- package/build/components/add-new-template/add-custom-template-modal.js +1 -0
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/index.js +8 -5
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +21 -6
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +12 -8
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +15 -30
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +64 -0
- package/build/components/block-editor/editor-canvas.js.map +1 -0
- package/build/components/block-editor/index.js +62 -59
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +10 -44
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/editor/index.js +76 -135
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +57 -0
- package/build/components/global-styles/block-preview-panel.js.map +1 -0
- package/build/components/global-styles/border-panel.js +0 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +6 -2
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +62 -0
- package/build/components/global-styles/custom-css.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +2 -6
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +18 -4
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +1 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +0 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +2 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-block.js +5 -1
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-border.js +47 -0
- package/build/components/global-styles/screen-border.js.map +1 -0
- package/build/components/global-styles/screen-button-color.js +0 -2
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +5 -1
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +42 -0
- package/build/components/global-styles/screen-css.js.map +1 -0
- package/build/components/global-styles/screen-heading-color.js +1 -3
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +4 -5
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +0 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +20 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +3 -3
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +0 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +17 -5
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/ui.js +50 -4
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +5 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +14 -4
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -8
- package/build/components/global-styles-renderer/index.js.map +1 -0
- package/build/components/header-edit-mode/document-actions/index.js +21 -45
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +19 -12
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +11 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +200 -0
- package/build/components/layout/index.js.map +1 -0
- package/build/components/list/header.js +5 -1
- package/build/components/list/header.js.map +1 -1
- package/build/components/list/index.js +4 -22
- package/build/components/list/index.js.map +1 -1
- package/build/components/navigate-to-link/index.js +1 -3
- package/build/components/navigate-to-link/index.js.map +1 -1
- package/build/components/routes/index.js +1 -1
- package/build/components/routes/index.js.map +1 -1
- package/build/components/sidebar/index.js +46 -0
- package/build/components/sidebar/index.js.map +1 -0
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +24 -4
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +4 -2
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-item/index.js +53 -0
- package/build/components/sidebar-navigation-item/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen/index.js +49 -0
- package/build/components/sidebar-navigation-screen/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js +46 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +169 -0
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -0
- package/build/components/site-hub/index.js +149 -0
- package/build/components/site-hub/index.js.map +1 -0
- package/build/components/site-icon/index.js +70 -0
- package/build/components/site-icon/index.js.map +1 -0
- package/build/components/style-book/index.js +173 -0
- package/build/components/style-book/index.js.map +1 -0
- package/build/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +5 -4
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
- package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +53 -0
- package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
- package/build/components/use-edited-entity-record/index.js +60 -0
- package/build/components/use-edited-entity-record/index.js.map +1 -0
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +144 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build/index.js +7 -45
- package/build/index.js.map +1 -1
- package/build/store/actions.js +93 -43
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +35 -107
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +69 -78
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/index.js +7 -5
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +18 -6
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +13 -9
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +15 -28
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +51 -0
- package/build-module/components/block-editor/editor-canvas.js.map +1 -0
- package/build-module/components/block-editor/index.js +62 -60
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +11 -40
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/editor/index.js +75 -129
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +46 -0
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -0
- package/build-module/components/global-styles/border-panel.js +0 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +7 -3
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +52 -0
- package/build-module/components/global-styles/custom-css.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +3 -7
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +18 -4
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +1 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +0 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +2 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +4 -1
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +30 -0
- package/build-module/components/global-styles/screen-border.js.map +1 -0
- package/build-module/components/global-styles/screen-button-color.js +0 -2
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +4 -1
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +28 -0
- package/build-module/components/global-styles/screen-css.js.map +1 -0
- package/build-module/components/global-styles/screen-heading-color.js +1 -3
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +3 -4
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +0 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +21 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +0 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +17 -5
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/ui.js +48 -5
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +5 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +13 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -7
- package/build-module/components/global-styles-renderer/index.js.map +1 -0
- package/build-module/components/header-edit-mode/document-actions/index.js +22 -43
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +16 -11
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +10 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +173 -0
- package/build-module/components/layout/index.js.map +1 -0
- package/build-module/components/list/header.js +5 -1
- package/build-module/components/list/header.js.map +1 -1
- package/build-module/components/list/index.js +4 -19
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/navigate-to-link/index.js +1 -3
- package/build-module/components/navigate-to-link/index.js.map +1 -1
- package/build-module/components/routes/index.js +1 -1
- package/build-module/components/routes/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +33 -0
- package/build-module/components/sidebar/index.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +27 -7
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +6 -4
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +11 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-item/index.js +40 -0
- package/build-module/components/sidebar-navigation-item/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen/index.js +39 -0
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js +32 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +147 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -0
- package/build-module/components/site-hub/index.js +126 -0
- package/build-module/components/site-hub/index.js.map +1 -0
- package/build-module/components/site-icon/index.js +55 -0
- package/build-module/components/site-icon/index.js.map +1 -0
- package/build-module/components/style-book/index.js +156 -0
- package/build-module/components/style-book/index.js.map +1 -0
- package/build-module/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +4 -3
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
- package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +43 -0
- package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
- package/build-module/components/use-edited-entity-record/index.js +48 -0
- package/build-module/components/use-edited-entity-record/index.js.map +1 -0
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +132 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -0
- package/build-module/index.js +9 -36
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +87 -42
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +35 -102
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +60 -72
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +549 -352
- package/build-style/style.css +549 -352
- package/package.json +33 -31
- package/src/components/add-new-template/add-custom-template-modal.js +1 -0
- package/src/components/add-new-template/index.js +6 -3
- package/src/components/add-new-template/new-template-part.js +15 -3
- package/src/components/add-new-template/new-template.js +14 -7
- package/src/components/add-new-template/style.scss +0 -4
- package/src/components/app/index.js +14 -43
- package/src/components/block-editor/editor-canvas.js +69 -0
- package/src/components/block-editor/index.js +100 -87
- package/src/components/block-editor/resizable-editor.js +9 -64
- package/src/components/block-editor/style.scss +25 -1
- package/src/components/code-editor/style.scss +1 -1
- package/src/components/editor/index.js +157 -238
- package/src/components/editor/style.scss +0 -22
- package/src/components/global-styles/block-preview-panel.js +44 -0
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/context-menu.js +11 -2
- package/src/components/global-styles/custom-css.js +74 -0
- package/src/components/global-styles/dimensions-panel.js +2 -5
- package/src/components/global-styles/global-styles-provider.js +50 -22
- package/src/components/global-styles/hooks.js +8 -3
- package/src/components/global-styles/palette.js +1 -1
- package/src/components/global-styles/screen-background-color.js +0 -1
- package/src/components/global-styles/screen-block-list.js +2 -1
- package/src/components/global-styles/screen-block.js +6 -1
- package/src/components/global-styles/screen-border.js +25 -0
- package/src/components/global-styles/screen-button-color.js +0 -2
- package/src/components/global-styles/screen-colors.js +5 -1
- package/src/components/global-styles/screen-css.js +33 -0
- package/src/components/global-styles/screen-heading-color.js +1 -3
- package/src/components/global-styles/screen-layout.js +2 -3
- package/src/components/global-styles/screen-link-color.js +0 -1
- package/src/components/global-styles/screen-root.js +37 -1
- package/src/components/global-styles/screen-style-variations.js +5 -2
- package/src/components/global-styles/screen-text-color.js +0 -1
- package/src/components/global-styles/screen-typography.js +3 -0
- package/src/components/global-styles/style.scss +31 -2
- package/src/components/global-styles/test/typography-utils.js +72 -23
- package/src/components/global-styles/typography-utils.js +24 -4
- package/src/components/global-styles/ui.js +47 -4
- package/src/components/global-styles/use-global-styles-output.js +5 -0
- package/src/components/global-styles/utils.js +18 -6
- package/src/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +3 -9
- package/src/components/header-edit-mode/document-actions/index.js +31 -45
- package/src/components/header-edit-mode/document-actions/style.scss +8 -1
- package/src/components/header-edit-mode/index.js +96 -78
- package/src/components/header-edit-mode/style.scss +6 -33
- package/src/components/keyboard-shortcuts/index.js +13 -0
- package/src/components/layout/index.js +235 -0
- package/src/components/layout/style.scss +183 -0
- package/src/components/list/header.js +5 -1
- package/src/components/list/index.js +12 -31
- package/src/components/list/style.scss +3 -4
- package/src/components/navigate-to-link/index.js +2 -8
- package/src/components/routes/index.js +1 -1
- package/src/components/sidebar/index.js +37 -0
- package/src/components/sidebar/style.scss +8 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +42 -7
- package/src/components/sidebar-edit-mode/index.js +4 -4
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js +10 -0
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +21 -3
- package/src/components/sidebar-edit-mode/settings-header/style.scss +47 -34
- package/src/components/sidebar-edit-mode/style.scss +0 -13
- package/src/components/sidebar-navigation-item/index.js +51 -0
- package/src/components/sidebar-navigation-item/style.scss +17 -0
- package/src/components/sidebar-navigation-screen/index.js +55 -0
- package/src/components/sidebar-navigation-screen/style.scss +39 -0
- package/src/components/sidebar-navigation-screen-main/index.js +44 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +163 -0
- package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
- package/src/components/site-hub/index.js +150 -0
- package/src/components/site-hub/style.scss +31 -0
- package/src/components/site-icon/index.js +56 -0
- package/src/components/site-icon/style.scss +10 -0
- package/src/components/style-book/index.js +193 -0
- package/src/components/style-book/style.scss +78 -0
- package/src/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +3 -3
- package/src/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +36 -0
- package/src/components/template-details/style.scss +4 -0
- package/src/components/use-edited-entity-record/index.js +37 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/push-changes-to-global-styles/index.js +162 -0
- package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
- package/src/index.js +5 -53
- package/src/store/actions.js +93 -48
- package/src/store/reducer.js +29 -91
- package/src/store/selectors.js +61 -101
- package/src/store/test/actions.js +3 -15
- package/src/store/test/reducer.js +8 -192
- package/src/store/test/selectors.js +3 -42
- package/src/style.scss +21 -3
- package/build/components/editor/global-styles-renderer.js.map +0 -1
- package/build/components/navigation-sidebar/index.js +0 -62
- package/build/components/navigation-sidebar/index.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/constants.js +0 -77
- package/build/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +0 -152
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
- package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +0 -124
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
- package/build/components/url-query-controller/index.js.map +0 -1
- package/build-module/components/editor/global-styles-renderer.js.map +0 -1
- package/build-module/components/navigation-sidebar/index.js +0 -45
- package/build-module/components/navigation-sidebar/index.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -49
- package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +0 -131
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -66
- package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +0 -108
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
- package/build-module/components/url-query-controller/index.js.map +0 -1
- package/src/components/navigation-sidebar/index.js +0 -46
- package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -94
- package/src/components/navigation-sidebar/navigation-panel/index.js +0 -142
- package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -152
- package/src/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
- package/src/components/navigation-sidebar/navigation-toggle/index.js +0 -114
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +0 -71
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +0 -65
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WordPress dependencies
|
|
6
|
+
*/
|
|
7
|
+
import { __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack } from '@wordpress/components';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { useEntityRecords } from '@wordpress/core-data';
|
|
11
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
18
|
+
import { useLink } from '../routes/link';
|
|
19
|
+
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
20
|
+
import { useLocation } from '../routes';
|
|
21
|
+
import { store as editSiteStore } from '../../store';
|
|
22
|
+
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
|
+
const config = {
|
|
43
|
+
wp_template: {
|
|
44
|
+
path: '/templates',
|
|
45
|
+
labels: {
|
|
46
|
+
title: __('Templates'),
|
|
47
|
+
loading: __('Loading templates'),
|
|
48
|
+
notFound: __('No templates found'),
|
|
49
|
+
manage: __('Manage all templates')
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
wp_template_part: {
|
|
53
|
+
path: '/template-parts',
|
|
54
|
+
labels: {
|
|
55
|
+
title: __('Template parts'),
|
|
56
|
+
loading: __('Loading template parts'),
|
|
57
|
+
notFound: __('No template parts found'),
|
|
58
|
+
manage: __('Manage all template parts')
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export default function SidebarNavigationScreenTemplates(_ref3) {
|
|
63
|
+
let {
|
|
64
|
+
postType = 'wp_template'
|
|
65
|
+
} = _ref3;
|
|
66
|
+
const {
|
|
67
|
+
params
|
|
68
|
+
} = useLocation();
|
|
69
|
+
const isMobileViewport = useViewportMatch('medium', '<'); // Ideally the URL params would be enough.
|
|
70
|
+
// Loading the editor should ideally redirect to the home page
|
|
71
|
+
// instead of fetching the edited entity here.
|
|
72
|
+
|
|
73
|
+
const {
|
|
74
|
+
editedPostId,
|
|
75
|
+
editedPostType
|
|
76
|
+
} = useSelect(select => {
|
|
77
|
+
const {
|
|
78
|
+
getEditedPostType,
|
|
79
|
+
getEditedPostId
|
|
80
|
+
} = select(editSiteStore);
|
|
81
|
+
return {
|
|
82
|
+
editedPostId: getEditedPostId(),
|
|
83
|
+
editedPostType: getEditedPostType()
|
|
84
|
+
};
|
|
85
|
+
}, []);
|
|
86
|
+
const {
|
|
87
|
+
records: templates,
|
|
88
|
+
isResolving: isLoading
|
|
89
|
+
} = useEntityRecords('postType', postType, {
|
|
90
|
+
per_page: -1
|
|
91
|
+
});
|
|
92
|
+
let items = [];
|
|
93
|
+
|
|
94
|
+
if (isLoading) {
|
|
95
|
+
items = [{
|
|
96
|
+
children: config[postType].labels.loading
|
|
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
|
+
|
|
118
|
+
return createElement(SidebarNavigationScreen, {
|
|
119
|
+
path: config[postType].path,
|
|
120
|
+
parentTitle: __('Design'),
|
|
121
|
+
title: createElement(HStack, {
|
|
122
|
+
justify: "space-between"
|
|
123
|
+
}, createElement("div", {
|
|
124
|
+
style: {
|
|
125
|
+
flexShrink: 0
|
|
126
|
+
}
|
|
127
|
+
}, config[postType].labels.title), !isMobileViewport && createElement(AddNewTemplate, {
|
|
128
|
+
templateType: postType,
|
|
129
|
+
toggleProps: {
|
|
130
|
+
className: 'edit-site-sidebar-navigation-screen-templates__add-button'
|
|
131
|
+
}
|
|
132
|
+
})),
|
|
133
|
+
content: createElement(Fragment, null, createElement(ItemGroup, null, items.map((item, index) => createElement(Item, {
|
|
134
|
+
item: item,
|
|
135
|
+
key: index
|
|
136
|
+
})), createElement(SidebarNavigationItem, _extends({
|
|
137
|
+
className: "edit-site-sidebar-navigation-screen-templates__see-all"
|
|
138
|
+
}, useLink({
|
|
139
|
+
postType,
|
|
140
|
+
postId: undefined
|
|
141
|
+
}), {
|
|
142
|
+
"aria-current": params.postType === postType && !params.postId ? 'page' : undefined,
|
|
143
|
+
children: config[postType].labels.manage
|
|
144
|
+
}))))
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__","useSelect","useEntityRecords","decodeEntities","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","useLocation","store","editSiteStore","AddNewTemplate","omit","object","keys","Object","fromEntries","entries","filter","key","includes","Item","item","linkInfo","params","props","config","wp_template","path","labels","title","loading","notFound","manage","wp_template_part","SidebarNavigationScreenTemplates","postType","isMobileViewport","editedPostId","editedPostType","select","getEditedPostType","getEditedPostId","records","templates","isResolving","isLoading","per_page","items","children","map","template","postId","id","rendered","slug","undefined","flexShrink","className","index"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,oBAAoB,IAAIC,MAFzB,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,iBAA1B;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,SAASC,WAAT,QAA4B,WAA5B;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;;AAEA,SAASC,IAAT,CAAeC,MAAf,EAAuBC,IAAvB,EAA8B;AAC7B,SAAOC,MAAM,CAACC,WAAP,CACND,MAAM,CAACE,OAAP,C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AAM,EAAEI;AAFK,KAAF,CAFb;AAMC,sBACChC,MAAM,CAACY,QAAP,KAAoBA,QAApB,IAAgC,CAAEZ,MAAM,CAAC4B,MAAzC,GACG,MADH,GAEGI,SATL;AAWC,MAAA,QAAQ,EAAG9B,MAAM,CAAEU,QAAF,CAAN,CAAmBP,MAAnB,CAA0BI;AAXtC,OALD,CADD;AApBF,IADD;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\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 { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport AddNewTemplate from '../add-new-template';\n\nfunction omit( object, keys ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )\n\t);\n}\n\nconst Item = ( { item } ) => {\n\tconst linkInfo = useLink( item.params );\n\tconst props = item.params\n\t\t? { ...omit( item, 'params' ), ...linkInfo }\n\t\t: item;\n\treturn <SidebarNavigationItem { ...props } />;\n};\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\nexport default function SidebarNavigationScreenTemplates( {\n\tpostType = 'wp_template',\n} ) {\n\tconst { params } = useLocation();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\t// Ideally the URL params would be enough.\n\t// Loading the editor should ideally redirect to the home page\n\t// instead of fetching the edited entity here.\n\tconst { editedPostId, editedPostType } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\treturn {\n\t\t\teditedPostId: getEditedPostId(),\n\t\t\teditedPostType: getEditedPostType(),\n\t\t};\n\t}, [] );\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\tlet items = [];\n\tif ( isLoading ) {\n\t\titems = [\n\t\t\t{\n\t\t\t\tchildren: config[ postType ].labels.loading,\n\t\t\t},\n\t\t];\n\t} else if ( ! templates && ! isLoading ) {\n\t\titems = [\n\t\t\t{\n\t\t\t\tchildren: config[ postType ].labels.notFound,\n\t\t\t},\n\t\t];\n\t} else {\n\t\titems = templates?.map( ( template ) => ( {\n\t\t\tparams: {\n\t\t\t\tpostType,\n\t\t\t\tpostId: template.id,\n\t\t\t},\n\t\t\tchildren: decodeEntities(\n\t\t\t\ttemplate.title?.rendered || template.slug\n\t\t\t),\n\t\t\t'aria-current':\n\t\t\t\t( params.postType === postType &&\n\t\t\t\t\tparams.postId === template.id ) ||\n\t\t\t\t// This is a special case for the home page.\n\t\t\t\t( editedPostId === template.id &&\n\t\t\t\t\teditedPostType === postType &&\n\t\t\t\t\t!! params.postId )\n\t\t\t\t\t? 'page'\n\t\t\t\t\t: undefined,\n\t\t} ) );\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\tparentTitle={ __( 'Design' ) }\n\t\t\ttitle={\n\t\t\t\t<HStack justify=\"space-between\">\n\t\t\t\t\t<div style={ { flexShrink: 0 } }>\n\t\t\t\t\t\t{ config[ postType ].labels.title }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t'edit-site-sidebar-navigation-screen-templates__add-button',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t{ items.map( ( item, index ) => (\n\t\t\t\t\t\t\t<Item item={ item } key={ index } />\n\t\t\t\t\t\t) ) }\n\n\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t{ ...useLink( {\n\t\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\t\tpostId: undefined,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\tparams.postType === postType && ! params.postId\n\t\t\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchildren={ config[ postType ].labels.manage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ItemGroup>\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
+
import { Button, __unstableMotion as motion, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
14
|
+
import { useReducedMotion, useViewportMatch } from '@wordpress/compose';
|
|
15
|
+
import { __ } from '@wordpress/i18n';
|
|
16
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
17
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { store as editSiteStore } from '../../store';
|
|
23
|
+
import { useLocation } from '../routes';
|
|
24
|
+
import getIsListPage from '../../utils/get-is-list-page';
|
|
25
|
+
import SiteIcon from '../site-icon';
|
|
26
|
+
import useEditedEntityRecord from '../use-edited-entity-record';
|
|
27
|
+
const HUB_ANIMATION_DURATION = 0.3;
|
|
28
|
+
|
|
29
|
+
function SiteHub(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
className,
|
|
32
|
+
isMobileCanvasVisible,
|
|
33
|
+
setIsMobileCanvasVisible
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
params
|
|
37
|
+
} = useLocation();
|
|
38
|
+
const isListPage = getIsListPage(params);
|
|
39
|
+
const isEditorPage = !isListPage;
|
|
40
|
+
const {
|
|
41
|
+
canvasMode,
|
|
42
|
+
dashboardLink,
|
|
43
|
+
entityConfig
|
|
44
|
+
} = useSelect(select => {
|
|
45
|
+
select(editSiteStore).getEditedPostType();
|
|
46
|
+
const {
|
|
47
|
+
__unstableGetCanvasMode,
|
|
48
|
+
getSettings,
|
|
49
|
+
getEditedPostType
|
|
50
|
+
} = select(editSiteStore);
|
|
51
|
+
return {
|
|
52
|
+
canvasMode: __unstableGetCanvasMode(),
|
|
53
|
+
dashboardLink: getSettings().__experimentalDashboardLink,
|
|
54
|
+
entityConfig: select(coreStore).getEntityConfig('postType', getEditedPostType())
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
const disableMotion = useReducedMotion();
|
|
58
|
+
const isMobileViewport = useViewportMatch('medium', '<');
|
|
59
|
+
const {
|
|
60
|
+
__unstableSetCanvasMode
|
|
61
|
+
} = useDispatch(editSiteStore);
|
|
62
|
+
const {
|
|
63
|
+
clearSelectedBlock
|
|
64
|
+
} = useDispatch(blockEditorStore);
|
|
65
|
+
const showEditButton = isEditorPage && canvasMode === 'view' && !isMobileViewport || isMobileViewport && canvasMode === 'view' && isMobileCanvasVisible;
|
|
66
|
+
const isBackToDashboardButton = !isMobileViewport && canvasMode === 'view' || isMobileViewport && !isMobileCanvasVisible;
|
|
67
|
+
const showLabels = canvasMode !== 'edit';
|
|
68
|
+
const siteIconButtonProps = isBackToDashboardButton ? {
|
|
69
|
+
href: dashboardLink || 'index.php',
|
|
70
|
+
'aria-label': __('Go back to the dashboard')
|
|
71
|
+
} : {
|
|
72
|
+
label: __('Open Navigation Sidebar'),
|
|
73
|
+
onClick: () => {
|
|
74
|
+
clearSelectedBlock();
|
|
75
|
+
setIsMobileCanvasVisible(false);
|
|
76
|
+
|
|
77
|
+
__unstableSetCanvasMode('view');
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const {
|
|
81
|
+
getTitle
|
|
82
|
+
} = useEditedEntityRecord();
|
|
83
|
+
return createElement(motion.div, {
|
|
84
|
+
className: classnames('edit-site-site-hub', className),
|
|
85
|
+
layout: true,
|
|
86
|
+
transition: {
|
|
87
|
+
type: 'tween',
|
|
88
|
+
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
89
|
+
ease: 'easeOut'
|
|
90
|
+
}
|
|
91
|
+
}, createElement(HStack, {
|
|
92
|
+
justify: "flex-start",
|
|
93
|
+
className: "edit-site-site-hub__text-content"
|
|
94
|
+
}, createElement(motion.div, {
|
|
95
|
+
className: "edit-site-site-hub__view-mode-toggle-container",
|
|
96
|
+
layout: true,
|
|
97
|
+
transition: {
|
|
98
|
+
type: 'tween',
|
|
99
|
+
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
100
|
+
ease: 'easeOut'
|
|
101
|
+
}
|
|
102
|
+
}, createElement(Button, _extends({}, siteIconButtonProps, {
|
|
103
|
+
className: "edit-site-layout__view-mode-toggle"
|
|
104
|
+
}), createElement(SiteIcon, {
|
|
105
|
+
className: "edit-site-layout__view-mode-toggle-icon"
|
|
106
|
+
}))), showLabels && createElement(VStack, {
|
|
107
|
+
spacing: 0
|
|
108
|
+
}, createElement("div", {
|
|
109
|
+
className: "edit-site-site-hub__title"
|
|
110
|
+
}, getTitle()), createElement("div", {
|
|
111
|
+
className: "edit-site-site-hub__post-type"
|
|
112
|
+
}, entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.label))), showEditButton && createElement(Button, {
|
|
113
|
+
className: "edit-site-site-hub__edit-button",
|
|
114
|
+
label: __('Open the editor'),
|
|
115
|
+
onClick: () => {
|
|
116
|
+
__unstableSetCanvasMode('edit');
|
|
117
|
+
},
|
|
118
|
+
variant: "primary"
|
|
119
|
+
}, __('Edit')), isMobileViewport && !isMobileCanvasVisible && createElement(Button, {
|
|
120
|
+
onClick: () => setIsMobileCanvasVisible(true),
|
|
121
|
+
variant: "primary"
|
|
122
|
+
}, __('View Editor')));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default SiteHub;
|
|
126
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["classnames","useSelect","useDispatch","Button","__unstableMotion","motion","__experimentalHStack","HStack","__experimentalVStack","VStack","useReducedMotion","useViewportMatch","__","store","blockEditorStore","coreStore","editSiteStore","useLocation","getIsListPage","SiteIcon","useEditedEntityRecord","HUB_ANIMATION_DURATION","SiteHub","className","isMobileCanvasVisible","setIsMobileCanvasVisible","params","isListPage","isEditorPage","canvasMode","dashboardLink","entityConfig","select","getEditedPostType","__unstableGetCanvasMode","getSettings","__experimentalDashboardLink","getEntityConfig","disableMotion","isMobileViewport","__unstableSetCanvasMode","clearSelectedBlock","showEditButton","isBackToDashboardButton","showLabels","siteIconButtonProps","href","label","onClick","getTitle","type","duration","ease"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,MADD,EAECC,gBAAgB,IAAIC,MAFrB,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,oBAAoB,IAAIC,MAJzB,QAKO,uBALP;AAMA,SAASC,gBAAT,EAA2BC,gBAA3B,QAAmD,oBAAnD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,aAAvC;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,OAAOC,aAAP,MAA0B,8BAA1B;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,OAAOC,qBAAP,MAAkC,6BAAlC;AAEA,MAAMC,sBAAsB,GAAG,GAA/B;;AAEA,SAASC,OAAT,OAII;AAAA,MAJc;AACjBC,IAAAA,SADiB;AAEjBC,IAAAA,qBAFiB;AAGjBC,IAAAA;AAHiB,GAId;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAaT,WAAW,EAA9B;AACA,QAAMU,UAAU,GAAGT,aAAa,CAAEQ,MAAF,CAAhC;AACA,QAAME,YAAY,GAAG,CAAED,UAAvB;AACA,QAAM;AAAEE,IAAAA,UAAF;AAAcC,IAAAA,aAAd;AAA6BC,IAAAA;AAA7B,MAA8C9B,SAAS,CAC1D+B,MAAF,IAAc;AACbA,IAAAA,MAAM,CAAEhB,aAAF,CAAN,CAAwBiB,iBAAxB;AACA,UAAM;AAAEC,M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AAO,EAAC;AANT,KAQG5B,EAAE,CAAE,MAAF,CARL,CA3CF,EAuDG2B,gBAAgB,IAAI,CAAEf,qBAAtB,IACD,cAAC,MAAD;AACC,IAAA,OAAO,EAAG,MAAMC,wBAAwB,CAAE,IAAF,CADzC;AAEC,IAAA,OAAO,EAAC;AAFT,KAIGb,EAAE,CAAE,aAAF,CAJL,CAxDF,CADD;AAkEA;;AAED,eAAeU,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\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useReducedMotion, useViewportMatch } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { useLocation } from '../routes';\nimport getIsListPage from '../../utils/get-is-list-page';\nimport SiteIcon from '../site-icon';\nimport useEditedEntityRecord from '../use-edited-entity-record';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nfunction SiteHub( {\n\tclassName,\n\tisMobileCanvasVisible,\n\tsetIsMobileCanvasVisible,\n} ) {\n\tconst { params } = useLocation();\n\tconst isListPage = getIsListPage( params );\n\tconst isEditorPage = ! isListPage;\n\tconst { canvasMode, dashboardLink, entityConfig } = useSelect(\n\t\t( select ) => {\n\t\t\tselect( editSiteStore ).getEditedPostType();\n\t\t\tconst { __unstableGetCanvasMode, getSettings, getEditedPostType } =\n\t\t\t\tselect( editSiteStore );\n\t\t\treturn {\n\t\t\t\tcanvasMode: __unstableGetCanvasMode(),\n\t\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t\t\tentityConfig: select( coreStore ).getEntityConfig(\n\t\t\t\t\t'postType',\n\t\t\t\t\tgetEditedPostType()\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst disableMotion = useReducedMotion();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { __unstableSetCanvasMode } = useDispatch( editSiteStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst showEditButton =\n\t\t( isEditorPage && canvasMode === 'view' && ! isMobileViewport ) ||\n\t\t( isMobileViewport && canvasMode === 'view' && isMobileCanvasVisible );\n\tconst isBackToDashboardButton =\n\t\t( ! isMobileViewport && canvasMode === 'view' ) ||\n\t\t( isMobileViewport && ! isMobileCanvasVisible );\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\tsetIsMobileCanvasVisible( false );\n\t\t\t\t\t__unstableSetCanvasMode( 'view' );\n\t\t\t\t},\n\t\t };\n\tconst { getTitle } = useEditedEntityRecord();\n\n\treturn (\n\t\t<motion.div\n\t\t\tclassName={ classnames( 'edit-site-site-hub', 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>\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 && (\n\t\t\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t{ getTitle() }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__post-type\">\n\t\t\t\t\t\t\t{ entityConfig?.label }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</VStack>\n\t\t\t\t) }\n\t\t\t</HStack>\n\n\t\t\t{ showEditButton && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-site-hub__edit-button\"\n\t\t\t\t\tlabel={ __( 'Open the editor' ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t__unstableSetCanvasMode( 'edit' );\n\t\t\t\t\t} }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\n\t\t\t{ isMobileViewport && ! isMobileCanvasVisible && (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => setIsMobileCanvasVisible( true ) }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'View Editor' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</motion.div>\n\t);\n}\n\nexport default SiteHub;\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
12
|
+
import { Icon } from '@wordpress/components';
|
|
13
|
+
import { __ } from '@wordpress/i18n';
|
|
14
|
+
import { wordpress } from '@wordpress/icons';
|
|
15
|
+
import { store as coreDataStore } from '@wordpress/core-data';
|
|
16
|
+
|
|
17
|
+
function SiteIcon(_ref) {
|
|
18
|
+
let {
|
|
19
|
+
className
|
|
20
|
+
} = _ref;
|
|
21
|
+
const {
|
|
22
|
+
isRequestingSite,
|
|
23
|
+
siteIconUrl
|
|
24
|
+
} = useSelect(select => {
|
|
25
|
+
const {
|
|
26
|
+
getEntityRecord,
|
|
27
|
+
isResolving
|
|
28
|
+
} = select(coreDataStore);
|
|
29
|
+
const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
|
|
30
|
+
return {
|
|
31
|
+
isRequestingSite: isResolving('core', 'getEntityRecord', ['root', '__unstableBase', undefined]),
|
|
32
|
+
siteIconUrl: siteData.site_icon_url
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
if (isRequestingSite && !siteIconUrl) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const icon = siteIconUrl ? createElement("img", {
|
|
41
|
+
className: "edit-site-site-icon__image",
|
|
42
|
+
alt: __('Site Icon'),
|
|
43
|
+
src: siteIconUrl
|
|
44
|
+
}) : createElement(Icon, {
|
|
45
|
+
className: "edit-site-site-icon__icon",
|
|
46
|
+
size: "36px",
|
|
47
|
+
icon: wordpress
|
|
48
|
+
});
|
|
49
|
+
return createElement("div", {
|
|
50
|
+
className: classnames(className, 'edit-site-site-icon')
|
|
51
|
+
}, icon);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default SiteIcon;
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/site-icon/index.js"],"names":["classnames","useSelect","Icon","__","wordpress","store","coreDataStore","SiteIcon","className","isRequestingSite","siteIconUrl","select","getEntityRecord","isResolving","siteData","undefined","site_icon_url","icon"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;;AAEA,SAASC,QAAT,OAAmC;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAClC,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAoCT,SAAS,CAAIU,MAAF,IAAc;AAClE,UAAM;AAAEC,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,QAAmCF,MAAM,CAAEL,aAAF,CAA/C;AACA,UAAMQ,QAAQ,GACbF,eAAe,CAAE,MAAF,EAAU,gBAAV,EAA4BG,SAA5B,CAAf,IAA0D,EAD3D;AAGA,WAAO;AACNN,MAAAA,gBAAgB,EAAEI,WAAW,CAAE,MAAF,EAAU,iBAAV,EAA6B,CACzD,MADyD,EAEzD,gBAFyD,EAGzDE,SAHyD,CAA7B,CADvB;AAMNL,MAAAA,WAAW,EAAEI,QAAQ,CAACE;AANhB,KAAP;AAQA,GAbkD,EAahD,EAbgD,CAAnD;;AAeA,MAAKP,gBAAgB,IAAI,CAAEC,WAA3B,EAAyC;AACxC,WAAO,IAAP;AACA;;AAED,QAAMO,IAAI,GAAGP,WAAW,GACvB;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,GAAG,EAAGP,EAAE,CAAE,WAAF,CAFT;AAGC,IAAA,GAAG,EAAGO;AAHP,IADuB,GAOvB,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,2BADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,IAAA,IAAI,EAAGN;AAHR,IAPD;AAcA,SACC;AAAK,IAAA,SAAS,EAAGJ,UAAU,CAAEQ,SAAF,EAAa,qBAAb;AAA3B,KACGS,IADH,CADD;AAKA;;AAED,eAAeV,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { Icon } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { wordpress } from '@wordpress/icons';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\nfunction SiteIcon( { className } ) {\n\tconst { isRequestingSite, siteIconUrl } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, isResolving } = select( coreDataStore );\n\t\tconst siteData =\n\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\treturn {\n\t\t\tisRequestingSite: isResolving( 'core', 'getEntityRecord', [\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase',\n\t\t\t\tundefined,\n\t\t\t] ),\n\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t};\n\t}, [] );\n\n\tif ( isRequestingSite && ! siteIconUrl ) {\n\t\treturn null;\n\t}\n\n\tconst icon = siteIconUrl ? (\n\t\t<img\n\t\t\tclassName=\"edit-site-site-icon__image\"\n\t\t\talt={ __( 'Site Icon' ) }\n\t\t\tsrc={ siteIconUrl }\n\t\t/>\n\t) : (\n\t\t<Icon\n\t\t\tclassName=\"edit-site-site-icon__icon\"\n\t\t\tsize=\"36px\"\n\t\t\ticon={ wordpress }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<div className={ classnames( className, 'edit-site-site-icon' ) }>\n\t\t\t{ icon }\n\t\t</div>\n\t);\n}\n\nexport default SiteIcon;\n"]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Button, TabPanel, createSlotFill, __experimentalUseSlotFills as useSlotFills } from '@wordpress/components';
|
|
12
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
13
|
+
import { getCategories, getBlockTypes, getBlockFromExample, createBlock } from '@wordpress/blocks';
|
|
14
|
+
import { BlockPreview } from '@wordpress/block-editor';
|
|
15
|
+
import { closeSmall } from '@wordpress/icons';
|
|
16
|
+
import { useResizeObserver } from '@wordpress/compose';
|
|
17
|
+
import { useMemo, memo } from '@wordpress/element';
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { useStyle } from '../global-styles';
|
|
23
|
+
const SLOT_FILL_NAME = 'EditSiteStyleBook';
|
|
24
|
+
const {
|
|
25
|
+
Slot: StyleBookSlot,
|
|
26
|
+
Fill: StyleBookFill
|
|
27
|
+
} = createSlotFill(SLOT_FILL_NAME);
|
|
28
|
+
|
|
29
|
+
function getExamples() {
|
|
30
|
+
// Use our own example for the Heading block so that we can show multiple
|
|
31
|
+
// heading levels.
|
|
32
|
+
const headingsExample = {
|
|
33
|
+
name: 'core/heading',
|
|
34
|
+
title: __('Headings'),
|
|
35
|
+
category: 'text',
|
|
36
|
+
blocks: [createBlock('core/heading', {
|
|
37
|
+
content: __('Code Is Poetry'),
|
|
38
|
+
level: 1
|
|
39
|
+
}), createBlock('core/heading', {
|
|
40
|
+
content: __('Code Is Poetry'),
|
|
41
|
+
level: 2
|
|
42
|
+
}), createBlock('core/heading', {
|
|
43
|
+
content: __('Code Is Poetry'),
|
|
44
|
+
level: 3
|
|
45
|
+
}), createBlock('core/heading', {
|
|
46
|
+
content: __('Code Is Poetry'),
|
|
47
|
+
level: 4
|
|
48
|
+
}), createBlock('core/heading', {
|
|
49
|
+
content: __('Code Is Poetry'),
|
|
50
|
+
level: 5
|
|
51
|
+
})]
|
|
52
|
+
};
|
|
53
|
+
const otherExamples = getBlockTypes().filter(blockType => blockType.name !== 'core/heading' && !!blockType.example).map(blockType => ({
|
|
54
|
+
name: blockType.name,
|
|
55
|
+
title: blockType.title,
|
|
56
|
+
category: blockType.category,
|
|
57
|
+
blocks: getBlockFromExample(blockType.name, blockType.example)
|
|
58
|
+
}));
|
|
59
|
+
return [headingsExample, ...otherExamples];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function StyleBook(_ref) {
|
|
63
|
+
let {
|
|
64
|
+
isSelected,
|
|
65
|
+
onSelect,
|
|
66
|
+
onClose
|
|
67
|
+
} = _ref;
|
|
68
|
+
const [resizeObserver, sizes] = useResizeObserver();
|
|
69
|
+
const [textColor] = useStyle('color.text');
|
|
70
|
+
const [backgroundColor] = useStyle('color.background');
|
|
71
|
+
const examples = useMemo(getExamples, []);
|
|
72
|
+
const tabs = useMemo(() => getCategories().filter(category => examples.some(example => example.category === category.slug)).map(category => ({
|
|
73
|
+
name: category.slug,
|
|
74
|
+
title: category.title,
|
|
75
|
+
icon: category.icon
|
|
76
|
+
})), [examples]);
|
|
77
|
+
return createElement(StyleBookFill, null, createElement("section", {
|
|
78
|
+
className: classnames('edit-site-style-book', {
|
|
79
|
+
'is-wide': sizes.width > 600
|
|
80
|
+
}),
|
|
81
|
+
style: {
|
|
82
|
+
color: textColor,
|
|
83
|
+
background: backgroundColor
|
|
84
|
+
},
|
|
85
|
+
"aria-label": __('Style Book')
|
|
86
|
+
}, resizeObserver, createElement(Button, {
|
|
87
|
+
className: "edit-site-style-book__close-button",
|
|
88
|
+
icon: closeSmall,
|
|
89
|
+
label: __('Close Style Book'),
|
|
90
|
+
onClick: onClose
|
|
91
|
+
}), createElement(TabPanel, {
|
|
92
|
+
className: "edit-site-style-book__tab-panel",
|
|
93
|
+
tabs: tabs
|
|
94
|
+
}, tab => createElement(Examples, {
|
|
95
|
+
examples: examples,
|
|
96
|
+
category: tab.name,
|
|
97
|
+
isSelected: isSelected,
|
|
98
|
+
onSelect: onSelect
|
|
99
|
+
}))));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const Examples = memo(_ref2 => {
|
|
103
|
+
let {
|
|
104
|
+
examples,
|
|
105
|
+
category,
|
|
106
|
+
isSelected,
|
|
107
|
+
onSelect
|
|
108
|
+
} = _ref2;
|
|
109
|
+
return createElement("div", {
|
|
110
|
+
className: "edit-site-style-book__examples"
|
|
111
|
+
}, examples.filter(example => example.category === category).map(example => createElement(Example, {
|
|
112
|
+
key: example.name,
|
|
113
|
+
title: example.title,
|
|
114
|
+
blocks: example.blocks,
|
|
115
|
+
isSelected: isSelected(example.name),
|
|
116
|
+
onClick: () => {
|
|
117
|
+
onSelect(example.name);
|
|
118
|
+
}
|
|
119
|
+
})));
|
|
120
|
+
});
|
|
121
|
+
const Example = memo(_ref3 => {
|
|
122
|
+
let {
|
|
123
|
+
title,
|
|
124
|
+
blocks,
|
|
125
|
+
isSelected,
|
|
126
|
+
onClick
|
|
127
|
+
} = _ref3;
|
|
128
|
+
return createElement("button", {
|
|
129
|
+
className: classnames('edit-site-style-book__example', {
|
|
130
|
+
'is-selected': isSelected
|
|
131
|
+
}),
|
|
132
|
+
"aria-label": sprintf( // translators: %s: Title of a block, e.g. Heading.
|
|
133
|
+
__('Open %s styles in Styles panel'), title),
|
|
134
|
+
onClick: onClick
|
|
135
|
+
}, createElement("span", {
|
|
136
|
+
className: "edit-site-style-book__example-title"
|
|
137
|
+
}, title), createElement("div", {
|
|
138
|
+
className: "edit-site-style-book__example-preview"
|
|
139
|
+
}, createElement(BlockPreview, {
|
|
140
|
+
blocks: blocks,
|
|
141
|
+
viewportWidth: 0,
|
|
142
|
+
__experimentalStyles: [{
|
|
143
|
+
css: '.wp-block:first-child { margin-top: 0; }' + '.wp-block:last-child { margin-bottom: 0; }'
|
|
144
|
+
}]
|
|
145
|
+
})));
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
function useHasStyleBook() {
|
|
149
|
+
const fills = useSlotFills(SLOT_FILL_NAME);
|
|
150
|
+
return !!(fills !== null && fills !== void 0 && fills.length);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
StyleBook.Slot = StyleBookSlot;
|
|
154
|
+
export default StyleBook;
|
|
155
|
+
export { useHasStyleBook };
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["classnames","Button","TabPanel","createSlotFill","__experimentalUseSlotFills","useSlotFills","__","sprintf","getCategories","getBlockTypes","getBlockFromExample","createBlock","BlockPreview","closeSmall","useResizeObserver","useMemo","memo","useStyle","SLOT_FILL_NAME","Slot","StyleBookSlot","Fill","StyleBookFill","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","map","StyleBook","isSelected","onSelect","onClose","resizeObserver","sizes","textColor","backgroundColor","examples","tabs","some","slug","icon","width","color","background","tab","Examples","Example","onClick","css","useHasStyleBook","fills","length"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,QAFD,EAGCC,cAHD,EAICC,0BAA0B,IAAIC,YAJ/B,QAKO,uBALP;AAMA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,aADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,WAJD,QAKO,mBALP;AAMA,SAASC,YAAT,QAA6B,yBAA7B;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AACA,SAASC,OAAT,EAAkBC,IAAlB,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,kBAAzB;AAEA,MAAMC,cAAc,GAAG,mBAAvB;AACA,MAAM;AAAEC,EAAAA,IAAI,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;AAAA,MAAE;AAAEU,IAAAA,KAAF;AAASE,IAAAA,MAAT;AAAiBS,IAAAA,UAAjB;AAA6BkB,IAAAA;AAA7B,GAAF;AAAA,SACrB;AACC,IAAA,SAAS,EAAGvD,UAAU,CAAE,+BAAF,EAAmC;AACxD,qBAAeqC;AADyC,KAAnC,CADvB;AAIC,kBAAa9B,OAAO,EACnB;AACAD,IAAAA,EAAE,CAAE,gCAAF,CAFiB,EAGnBoB,KAHmB,CAJrB;AASC,IAAA,OAAO,EAAG6B;AATX,KAWC;AAAM,IAAA,SAAS,EAAC;AAAhB,KAAwD7B,KAAxD,CAXD,EAYC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,YAAD;AACC,IAAA,MAAM,EAAGE,MADV;AAEC,IAAA,aAAa,EAAG,CAFjB;AAGC,IAAA,oBAAoB,EAAG,CACtB;AACC4B,MAAAA,GAAG,EACF,6CACA;AAHF,KADsB;AAHxB,IADD,CAZD,CADqB;AAAA,CAAF,CAApB;;AA6BA,SAASC,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAGrD,YAAY,CAAEa,cAAF,CAA1B;AACA,SAAO,CAAC,EAAEwC,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,MAAT,CAAR;AACA;;AAEDvB,SAAS,CAACjB,IAAV,GAAiBC,aAAjB;AACA,eAAegB,SAAf;AACA,SAASqB,eAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTabPanel,\n\tcreateSlotFill,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetCategories,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport { BlockPreview } from '@wordpress/block-editor';\nimport { closeSmall } from '@wordpress/icons';\nimport { useResizeObserver } from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useStyle } from '../global-styles';\n\nconst SLOT_FILL_NAME = 'EditSiteStyleBook';\nconst { Slot: StyleBookSlot, Fill: StyleBookFill } =\n\tcreateSlotFill( SLOT_FILL_NAME );\n\nfunction getExamples() {\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 1,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 2,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 3,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 4,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 5,\n\t\t\t} ),\n\t\t],\n\t};\n\n\tconst otherExamples = getBlockTypes()\n\t\t.filter(\n\t\t\t( blockType ) =>\n\t\t\t\tblockType.name !== 'core/heading' && !! blockType.example\n\t\t)\n\t\t.map( ( blockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\tblocks: getBlockFromExample( blockType.name, blockType.example ),\n\t\t} ) );\n\n\treturn [ headingsExample, ...otherExamples ];\n}\n\nfunction StyleBook( { isSelected, onSelect, onClose } ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ textColor ] = useStyle( 'color.text' );\n\tconst [ backgroundColor ] = useStyle( 'color.background' );\n\tconst examples = useMemo( getExamples, [] );\n\tconst tabs = useMemo(\n\t\t() =>\n\t\t\tgetCategories()\n\t\t\t\t.filter( ( category ) =>\n\t\t\t\t\texamples.some(\n\t\t\t\t\t\t( example ) => example.category === category.slug\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( category ) => ( {\n\t\t\t\t\tname: category.slug,\n\t\t\t\t\ttitle: category.title,\n\t\t\t\t\ticon: category.icon,\n\t\t\t\t} ) ),\n\t\t[ examples ]\n\t);\n\treturn (\n\t\t<StyleBookFill>\n\t\t\t<section\n\t\t\t\tclassName={ classnames( 'edit-site-style-book', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcolor: textColor,\n\t\t\t\t\tbackground: backgroundColor,\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Style Book' ) }\n\t\t\t>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-style-book__close-button\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close Style Book' ) }\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t/>\n\t\t\t\t<TabPanel\n\t\t\t\t\tclassName=\"edit-site-style-book__tab-panel\"\n\t\t\t\t\ttabs={ tabs }\n\t\t\t\t>\n\t\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TabPanel>\n\t\t\t</section>\n\t\t</StyleBookFill>\n\t);\n}\n\nconst Examples = memo( ( { examples, category, isSelected, onSelect } ) => (\n\t<div className=\"edit-site-style-book__examples\">\n\t\t{ examples\n\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t.map( ( example ) => (\n\t\t\t\t<Example\n\t\t\t\t\tkey={ example.name }\n\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSelect( example.name );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t</div>\n) );\n\nconst Example = memo( ( { title, blocks, isSelected, onClick } ) => (\n\t<button\n\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t'is-selected': isSelected,\n\t\t} ) }\n\t\taria-label={ sprintf(\n\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\ttitle\n\t\t) }\n\t\tonClick={ onClick }\n\t>\n\t\t<span className=\"edit-site-style-book__example-title\">{ title }</span>\n\t\t<div className=\"edit-site-style-book__example-preview\">\n\t\t\t<BlockPreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tviewportWidth={ 0 }\n\t\t\t\t__experimentalStyles={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tcss:\n\t\t\t\t\t\t\t'.wp-block:first-child { margin-top: 0; }' +\n\t\t\t\t\t\t\t'.wp-block:last-child { margin-bottom: 0; }',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t/>\n\t\t</div>\n\t</button>\n) );\n\nfunction useHasStyleBook() {\n\tconst fills = useSlotFills( SLOT_FILL_NAME );\n\treturn !! fills?.length;\n}\n\nStyleBook.Slot = StyleBookSlot;\nexport default StyleBook;\nexport { useHasStyleBook };\n"]}
|
|
@@ -9,7 +9,7 @@ import { useDispatch } from '@wordpress/data';
|
|
|
9
9
|
|
|
10
10
|
import { useLocation } from '../routes';
|
|
11
11
|
import { store as editSiteStore } from '../../store';
|
|
12
|
-
export default function
|
|
12
|
+
export default function useInitEditedEntityFromURL() {
|
|
13
13
|
const {
|
|
14
14
|
setTemplate,
|
|
15
15
|
setTemplatePart,
|
|
@@ -23,6 +23,8 @@ export default function URLQueryController() {
|
|
|
23
23
|
} = useLocation(); // Set correct entity on page navigation.
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
26
|
+
// This URL scheme mean we can't open a template part with the context of a given post.
|
|
27
|
+
// Potentially posts and pages could be moved to a "context" query string instead.
|
|
26
28
|
if ('page' === postType || 'post' === postType) {
|
|
27
29
|
setPage({
|
|
28
30
|
context: {
|
|
@@ -36,6 +38,5 @@ export default function URLQueryController() {
|
|
|
36
38
|
setTemplatePart(postId);
|
|
37
39
|
}
|
|
38
40
|
}, [postId, postType]);
|
|
39
|
-
return null;
|
|
40
41
|
}
|
|
41
|
-
//# sourceMappingURL=
|
|
42
|
+
//# sourceMappingURL=use-init-edited-entity-from-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useEffect","useDispatch","useLocation","store","editSiteStore","useInitEditedEntityFromURL","setTemplate","setTemplatePart","setPage","params","postId","postType","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA;AAAhC,MACLP,WAAW,CAAEG,aAAF,CADZ;AAEA,QAAM;AACLK,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEFT,WAAW,EAFf,CAHoD,CAOpD;;AACAF,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA;AACA,QAAK,WAAWW,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDH,MAAAA,OAAO,CAAE;AAAEI,QAAAA,OAAO,EAAE;AAAED,UAAAA,QAAF;AAAYD,UAAAA;AAAZ;AAAX,OAAF,CAAP,CADiD,CACH;AAC9C,KAFD,MAEO,IAAK,kBAAkBC,QAAvB,EAAkC;AACxCL,MAAAA,WAAW,CAAEI,MAAF,CAAX;AACA,KAFM,MAEA,IAAK,uBAAuBC,QAA5B,EAAuC;AAC7CJ,MAAAA,eAAe,CAAEG,MAAF,CAAf;AACA;AACD,GAVQ,EAUN,CAAEA,MAAF,EAAUC,QAAV,CAVM,CAAT;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { setTemplate, setTemplatePart, setPage } =\n\t\tuseDispatch( editSiteStore );\n\tconst {\n\t\tparams: { postId, postType },\n\t} = useLocation();\n\n\t// Set correct entity on page navigation.\n\tuseEffect( () => {\n\t\t// This URL scheme mean we can't open a template part with the context of a given post.\n\t\t// Potentially posts and pages could be moved to a \"context\" query string instead.\n\t\tif ( 'page' === postType || 'post' === postType ) {\n\t\t\tsetPage( { context: { postType, postId } } ); // Resolves correct template based on ID.\n\t\t} else if ( 'wp_template' === postType ) {\n\t\t\tsetTemplate( postId );\n\t\t} else if ( 'wp_template_part' === postType ) {\n\t\t\tsetTemplatePart( postId );\n\t\t}\n\t}, [ postId, postType ] );\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
|
|
5
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useLocation, useHistory } from '../routes';
|
|
11
|
+
export default function useSyncSidebarPathWithURL() {
|
|
12
|
+
const history = useHistory();
|
|
13
|
+
const {
|
|
14
|
+
params
|
|
15
|
+
} = useLocation();
|
|
16
|
+
const {
|
|
17
|
+
sidebar = '/'
|
|
18
|
+
} = params;
|
|
19
|
+
const {
|
|
20
|
+
location,
|
|
21
|
+
goTo
|
|
22
|
+
} = useNavigator();
|
|
23
|
+
const currentSidebar = useRef(sidebar);
|
|
24
|
+
const currentNavigatorLocation = useRef(location.path);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
currentSidebar.current = sidebar;
|
|
27
|
+
|
|
28
|
+
if (sidebar !== currentNavigatorLocation.current) {
|
|
29
|
+
goTo(sidebar);
|
|
30
|
+
}
|
|
31
|
+
}, [sidebar]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
currentNavigatorLocation.current = location.path;
|
|
34
|
+
|
|
35
|
+
if (location.path !== currentSidebar.current) {
|
|
36
|
+
history.push({ ...params,
|
|
37
|
+
sidebar: location.path
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, [location.path, history]);
|
|
41
|
+
return sidebar;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=use-sync-sidebar-path-with-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-sidebar-path-with-url.js"],"names":["__experimentalUseNavigator","useNavigator","useEffect","useRef","useLocation","useHistory","useSyncSidebarPathWithURL","history","params","sidebar","location","goTo","currentSidebar","currentNavigatorLocation","path","current","push"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,0BAA0B,IAAIC,YAAvC,QAA2D,uBAA3D;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,UAAtB,QAAwC,WAAxC;AAEA,eAAe,SAASC,yBAAT,GAAqC;AACnD,QAAMC,OAAO,GAAGF,UAAU,EAA1B;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAaJ,WAAW,EAA9B;AACA,QAAM;AAAEK,IAAAA,OAAO,GAAG;AAAZ,MAAoBD,MAA1B;AACA,QAAM;AAAEE,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAqBV,YAAY,EAAvC;AACA,QAAMW,cAAc,GAAGT,MAAM,CAAEM,OAAF,CAA7B;AACA,QAAMI,wBAAwB,GAAGV,MAAM,CAAEO,QAAQ,CAACI,IAAX,CAAvC;AACAZ,EAAAA,SAAS,CAAE,MAAM;AAChBU,IAAAA,cAAc,CAACG,OAAf,GAAyBN,OAAzB;;AACA,QAAKA,OAAO,KAAKI,wBAAwB,CAACE,OAA1C,EAAoD;AACnDJ,MAAAA,IAAI,CAAEF,OAAF,CAAJ;AACA;AACD,GALQ,EAKN,CAAEA,OAAF,CALM,CAAT;AAMAP,EAAAA,SAAS,CAAE,MAAM;AAChBW,IAAAA,wBAAwB,CAACE,OAAzB,GAAmCL,QAAQ,CAACI,IAA5C;;AACA,QAAKJ,QAAQ,CAACI,IAAT,KAAkBF,cAAc,CAACG,OAAtC,EAAgD;AAC/CR,MAAAA,OAAO,CAACS,IAAR,CAAc,EACb,GAAGR,MADU;AAEbC,QAAAA,OAAO,EAAEC,QAAQ,CAACI;AAFL,OAAd;AAIA;AACD,GARQ,EAQN,CAAEJ,QAAQ,CAACI,IAAX,EAAiBP,OAAjB,CARM,CAAT;AAUA,SAAOE,OAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useLocation, useHistory } from '../routes';\n\nexport default function useSyncSidebarPathWithURL() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst { sidebar = '/' } = params;\n\tconst { location, goTo } = useNavigator();\n\tconst currentSidebar = useRef( sidebar );\n\tconst currentNavigatorLocation = useRef( location.path );\n\tuseEffect( () => {\n\t\tcurrentSidebar.current = sidebar;\n\t\tif ( sidebar !== currentNavigatorLocation.current ) {\n\t\t\tgoTo( sidebar );\n\t\t}\n\t}, [ sidebar ] );\n\tuseEffect( () => {\n\t\tcurrentNavigatorLocation.current = location.path;\n\t\tif ( location.path !== currentSidebar.current ) {\n\t\t\thistory.push( {\n\t\t\t\t...params,\n\t\t\t\tsidebar: location.path,\n\t\t\t} );\n\t\t}\n\t}, [ location.path, history ] );\n\n\treturn sidebar;\n}\n"]}
|