@wordpress/edit-site 5.1.0 → 5.3.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 +8 -0
- package/LICENSE.md +1 -1
- package/build/components/add-new-template/add-custom-generic-template-modal.js +8 -10
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
- package/build/components/add-new-template/add-custom-template-modal.js +0 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +5 -9
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/app/index.js +2 -7
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +0 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +25 -59
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/inserter-media-categories.js +237 -0
- package/build/components/block-editor/inserter-media-categories.js.map +1 -0
- package/build/components/block-editor/resize-handle.js +2 -1
- package/build/components/block-editor/resize-handle.js.map +1 -1
- package/build/components/canvas-spinner/index.js +20 -0
- package/build/components/canvas-spinner/index.js.map +1 -0
- package/build/components/create-template-part-modal/index.js +4 -2
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +4 -2
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +2 -12
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/warning.js +5 -28
- package/build/components/error-boundary/warning.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +10 -4
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +18 -9
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +13 -7
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +47 -4
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +65 -14
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +50 -27
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +13 -3
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +17 -11
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +21 -142
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +0 -28
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -4
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +18 -15
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +28 -13
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +4 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-border.js +16 -4
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +17 -9
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +59 -26
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +20 -8
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +24 -16
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +9 -3
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +19 -11
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +25 -9
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -4
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +15 -7
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +23 -11
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +71 -0
- package/build/components/global-styles/screen-variations.js.map +1 -0
- package/build/components/global-styles/shadow-panel.js +196 -0
- package/build/components/global-styles/shadow-panel.js.map +1 -0
- package/build/components/global-styles/typography-panel.js +37 -22
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +19 -9
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/ui.js +139 -21
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/utils.js +8 -290
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles/variations-panel.js +85 -0
- package/build/components/global-styles/variations-panel.js.map +1 -0
- package/build/components/global-styles-renderer/index.js +7 -5
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +2 -2
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/layout/index.js +86 -15
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +8 -11
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +3 -2
- package/build/components/navigation-inspector/index.js.map +1 -0
- package/build/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -15
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -0
- package/build/components/sidebar/index.js +3 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +3 -18
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -14
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +3 -2
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +23 -1
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +35 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +3 -8
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +11 -11
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/site-icon/index.js +1 -1
- package/build/components/site-icon/index.js.map +1 -1
- package/build/components/style-book/index.js +7 -4
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +54 -0
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
- package/build/components/template-details/edit-template-title.js +1 -0
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/template-part-area-selector.js +1 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +5 -9
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/experiments.js +19 -0
- package/build/experiments.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +68 -9
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/index.js +53 -60
- package/build/index.js.map +1 -1
- package/build/store/reducer.js +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +7 -27
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +77 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/template-part-create.js +71 -0
- package/build/utils/template-part-create.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js +9 -11
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +0 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +5 -9
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/app/index.js +2 -7
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +0 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +27 -57
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/inserter-media-categories.js +225 -0
- package/build-module/components/block-editor/inserter-media-categories.js.map +1 -0
- package/build-module/components/block-editor/resize-handle.js +2 -1
- package/build-module/components/block-editor/resize-handle.js.map +1 -1
- package/build-module/components/canvas-spinner/index.js +12 -0
- package/build-module/components/canvas-spinner/index.js.map +1 -0
- package/build-module/components/create-template-part-modal/index.js +5 -3
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +3 -2
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +2 -12
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/warning.js +5 -28
- package/build-module/components/error-boundary/warning.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +10 -4
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +18 -11
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +11 -7
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +46 -8
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +61 -15
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +50 -28
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +7 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +15 -11
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +23 -134
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +0 -2
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +10 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +18 -14
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +27 -15
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +3 -1
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +14 -4
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +17 -11
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +56 -27
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +21 -9
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +24 -18
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +8 -3
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +19 -13
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +23 -9
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +5 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +15 -9
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +19 -10
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +54 -0
- package/build-module/components/global-styles/screen-variations.js.map +1 -0
- package/build-module/components/global-styles/shadow-panel.js +177 -0
- package/build-module/components/global-styles/shadow-panel.js.map +1 -0
- package/build-module/components/global-styles/typography-panel.js +37 -24
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +17 -9
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/ui.js +132 -22
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/utils.js +7 -277
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles/variations-panel.js +68 -0
- package/build-module/components/global-styles/variations-panel.js.map +1 -0
- package/build-module/components/global-styles-renderer/index.js +5 -5
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +2 -2
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/index.js +86 -17
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +9 -12
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +3 -2
- package/build-module/components/navigation-inspector/index.js.map +1 -0
- package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -16
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -0
- package/build-module/components/sidebar/index.js +2 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +6 -21
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -13
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +22 -2
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +23 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +4 -9
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +12 -11
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/site-icon/index.js +1 -1
- package/build-module/components/site-icon/index.js.map +1 -1
- package/build-module/components/style-book/index.js +8 -5
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +43 -0
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
- package/build-module/components/template-details/edit-template-title.js +1 -0
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/template-part-area-selector.js +1 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +5 -9
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/experiments.js +9 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +65 -6
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/index.js +52 -60
- package/build-module/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -26
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +66 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/template-part-create.js +53 -0
- package/build-module/utils/template-part-create.js.map +1 -0
- package/build-style/style-rtl.css +448 -278
- package/build-style/style.css +448 -278
- package/package.json +32 -30
- package/src/components/add-new-template/add-custom-generic-template-modal.js +20 -28
- package/src/components/add-new-template/add-custom-template-modal.js +0 -1
- package/src/components/add-new-template/new-template-part.js +12 -11
- package/src/components/add-new-template/style.scss +0 -4
- package/src/components/app/index.js +2 -2
- package/src/components/block-editor/editor-canvas.js +0 -1
- package/src/components/block-editor/index.js +21 -77
- package/src/components/block-editor/inserter-media-categories.js +247 -0
- package/src/components/block-editor/resize-handle.js +6 -2
- package/src/components/block-editor/style.scss +55 -7
- package/src/components/canvas-spinner/index.js +12 -0
- package/src/components/canvas-spinner/style.scss +7 -0
- package/src/components/create-template-part-modal/index.js +75 -67
- package/src/components/create-template-part-modal/style.scss +0 -10
- package/src/components/editor/index.js +5 -3
- package/src/components/error-boundary/index.js +2 -10
- package/src/components/error-boundary/warning.js +6 -35
- package/src/components/global-styles/README.md +1 -75
- package/src/components/global-styles/block-preview-panel.js +16 -4
- package/src/components/global-styles/border-panel.js +22 -16
- package/src/components/global-styles/color-palette-panel.js +10 -7
- package/src/components/global-styles/context-menu.js +117 -41
- package/src/components/global-styles/custom-css.js +76 -19
- package/src/components/global-styles/dimensions-panel.js +58 -31
- package/src/components/global-styles/global-styles-provider.js +6 -2
- package/src/components/global-styles/gradients-palette-panel.js +17 -11
- package/src/components/global-styles/hooks.js +31 -155
- package/src/components/global-styles/index.js +0 -2
- package/src/components/global-styles/palette.js +9 -5
- package/src/components/global-styles/preview.js +19 -13
- package/src/components/global-styles/screen-background-color.js +42 -19
- package/src/components/global-styles/screen-block-list.js +6 -1
- package/src/components/global-styles/screen-border.js +13 -5
- package/src/components/global-styles/screen-button-color.js +21 -19
- package/src/components/global-styles/screen-colors.js +66 -22
- package/src/components/global-styles/screen-css.js +30 -14
- package/src/components/global-styles/screen-heading-color.js +32 -27
- package/src/components/global-styles/screen-layout.js +7 -4
- package/src/components/global-styles/screen-link-color.js +34 -22
- package/src/components/global-styles/screen-root.js +24 -9
- package/src/components/global-styles/screen-style-variations.js +7 -2
- package/src/components/global-styles/screen-text-color.js +15 -15
- package/src/components/global-styles/screen-typography.js +34 -12
- package/src/components/global-styles/screen-variations.js +47 -0
- package/src/components/global-styles/shadow-panel.js +174 -0
- package/src/components/global-styles/style.scss +94 -1
- package/src/components/global-styles/typography-panel.js +58 -23
- package/src/components/global-styles/typography-preview.js +28 -9
- package/src/components/global-styles/ui.js +130 -17
- package/src/components/global-styles/utils.js +7 -330
- package/src/components/global-styles/variations-panel.js +78 -0
- package/src/components/global-styles-renderer/index.js +3 -4
- package/src/components/header-edit-mode/document-actions/index.js +1 -1
- package/src/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/src/components/layout/index.js +116 -21
- package/src/components/layout/style.scss +29 -5
- package/src/components/list/actions/rename-menu-item.js +14 -23
- package/src/components/list/style.scss +0 -4
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +3 -4
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +10 -12
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/style.scss +4 -17
- package/src/components/sidebar/index.js +2 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +8 -32
- package/src/components/sidebar-edit-mode/index.js +0 -11
- package/src/components/sidebar-edit-mode/settings-header/style.scss +8 -0
- package/src/components/sidebar-navigation-item/style.scss +28 -3
- package/src/components/sidebar-navigation-screen/index.js +4 -3
- package/src/components/sidebar-navigation-screen/style.scss +2 -0
- package/src/components/sidebar-navigation-screen-main/index.js +23 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +25 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +12 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +12 -19
- package/src/components/site-hub/index.js +120 -109
- package/src/components/site-hub/style.scss +7 -1
- package/src/components/site-icon/index.js +1 -1
- package/src/components/site-icon/style.scss +2 -2
- package/src/components/style-book/index.js +10 -5
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +40 -0
- package/src/components/template-details/edit-template-title.js +1 -0
- package/src/components/template-details/template-part-area-selector.js +1 -0
- package/src/components/template-part-converter/convert-to-template-part.js +12 -10
- package/src/experiments.js +10 -0
- package/src/hooks/push-changes-to-global-styles/index.js +66 -8
- package/src/index.js +51 -59
- package/src/store/reducer.js +1 -1
- package/src/store/selectors.js +6 -26
- package/src/store/test/utils.js +181 -0
- package/src/store/utils.js +69 -0
- package/src/style.scss +4 -2
- package/src/utils/template-part-create.js +62 -0
- package/src/utils/test/template-part-create.js +63 -0
- package/build/components/global-styles/context.js +0 -22
- package/build/components/global-styles/context.js.map +0 -1
- package/build/components/global-styles/typography-utils.js +0 -92
- package/build/components/global-styles/typography-utils.js.map +0 -1
- package/build/components/global-styles/use-global-styles-output.js +0 -857
- package/build/components/global-styles/use-global-styles-output.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -42
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/build-module/components/global-styles/context.js +0 -12
- package/build-module/components/global-styles/context.js.map +0 -1
- package/build-module/components/global-styles/typography-utils.js +0 -84
- package/build-module/components/global-styles/typography-utils.js.map +0 -1
- package/build-module/components/global-styles/use-global-styles-output.js +0 -815
- package/build-module/components/global-styles/use-global-styles-output.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -28
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/src/components/global-styles/context.js +0 -15
- package/src/components/global-styles/test/typography-utils.js +0 -393
- package/src/components/global-styles/test/use-global-styles-output.js +0 -814
- package/src/components/global-styles/test/utils.js +0 -206
- package/src/components/global-styles/typography-utils.js +0 -87
- package/src/components/global-styles/use-global-styles-output.js +0 -936
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -37
|
@@ -1,335 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { getTypographyFontSizeValue } from './typography-utils';
|
|
10
|
-
|
|
11
|
-
/* Supporting data. */
|
|
12
|
-
export const ROOT_BLOCK_NAME = 'root';
|
|
13
|
-
export const ROOT_BLOCK_SELECTOR = 'body';
|
|
14
|
-
export const ROOT_BLOCK_SUPPORTS = [
|
|
15
|
-
'background',
|
|
16
|
-
'backgroundColor',
|
|
17
|
-
'color',
|
|
18
|
-
'linkColor',
|
|
19
|
-
'buttonColor',
|
|
20
|
-
'fontFamily',
|
|
21
|
-
'fontSize',
|
|
22
|
-
'fontStyle',
|
|
23
|
-
'fontWeight',
|
|
24
|
-
'lineHeight',
|
|
25
|
-
'textDecoration',
|
|
26
|
-
'textTransform',
|
|
27
|
-
'padding',
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
export const PRESET_METADATA = [
|
|
31
|
-
{
|
|
32
|
-
path: [ 'color', 'palette' ],
|
|
33
|
-
valueKey: 'color',
|
|
34
|
-
cssVarInfix: 'color',
|
|
35
|
-
classes: [
|
|
36
|
-
{ classSuffix: 'color', propertyName: 'color' },
|
|
37
|
-
{
|
|
38
|
-
classSuffix: 'background-color',
|
|
39
|
-
propertyName: 'background-color',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
classSuffix: 'border-color',
|
|
43
|
-
propertyName: 'border-color',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
path: [ 'color', 'gradients' ],
|
|
49
|
-
valueKey: 'gradient',
|
|
50
|
-
cssVarInfix: 'gradient',
|
|
51
|
-
classes: [
|
|
52
|
-
{
|
|
53
|
-
classSuffix: 'gradient-background',
|
|
54
|
-
propertyName: 'background',
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
path: [ 'color', 'duotone' ],
|
|
60
|
-
cssVarInfix: 'duotone',
|
|
61
|
-
valueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,
|
|
62
|
-
classes: [],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
path: [ 'typography', 'fontSizes' ],
|
|
66
|
-
valueFunc: ( preset, { typography: typographySettings } ) =>
|
|
67
|
-
getTypographyFontSizeValue( preset, typographySettings ),
|
|
68
|
-
valueKey: 'size',
|
|
69
|
-
cssVarInfix: 'font-size',
|
|
70
|
-
classes: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
path: [ 'typography', 'fontFamilies' ],
|
|
74
|
-
valueKey: 'fontFamily',
|
|
75
|
-
cssVarInfix: 'font-family',
|
|
76
|
-
classes: [
|
|
77
|
-
{ classSuffix: 'font-family', propertyName: 'font-family' },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
path: [ 'spacing', 'spacingSizes' ],
|
|
82
|
-
valueKey: 'size',
|
|
83
|
-
cssVarInfix: 'spacing',
|
|
84
|
-
valueFunc: ( { size } ) => size,
|
|
85
|
-
classes: [],
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
export const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
90
|
-
'color.background': 'color',
|
|
91
|
-
'color.text': 'color',
|
|
92
|
-
'elements.link.color.text': 'color',
|
|
93
|
-
'elements.button.color.text': 'color',
|
|
94
|
-
'elements.button.backgroundColor': 'background-color',
|
|
95
|
-
'elements.heading.color': 'color',
|
|
96
|
-
'elements.heading.backgroundColor': 'background-color',
|
|
97
|
-
'elements.heading.gradient': 'gradient',
|
|
98
|
-
'color.gradient': 'gradient',
|
|
99
|
-
'typography.fontSize': 'font-size',
|
|
100
|
-
'typography.fontFamily': 'font-family',
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// A static list of block attributes that store global style preset slugs.
|
|
104
|
-
export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
105
|
-
'color.background': 'backgroundColor',
|
|
106
|
-
'color.text': 'textColor',
|
|
107
|
-
'color.gradient': 'gradient',
|
|
108
|
-
'typography.fontSize': 'fontSize',
|
|
109
|
-
'typography.fontFamily': 'fontFamily',
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
function findInPresetsBy(
|
|
113
|
-
features,
|
|
114
|
-
blockName,
|
|
115
|
-
presetPath,
|
|
116
|
-
presetProperty,
|
|
117
|
-
presetValueValue
|
|
118
|
-
) {
|
|
119
|
-
// Block presets take priority above root level presets.
|
|
120
|
-
const orderedPresetsByOrigin = [
|
|
121
|
-
get( features, [ 'blocks', blockName, ...presetPath ] ),
|
|
122
|
-
get( features, presetPath ),
|
|
123
|
-
];
|
|
124
|
-
|
|
125
|
-
for ( const presetByOrigin of orderedPresetsByOrigin ) {
|
|
126
|
-
if ( presetByOrigin ) {
|
|
127
|
-
// Preset origins ordered by priority.
|
|
128
|
-
const origins = [ 'custom', 'theme', 'default' ];
|
|
129
|
-
for ( const origin of origins ) {
|
|
130
|
-
const presets = presetByOrigin[ origin ];
|
|
131
|
-
if ( presets ) {
|
|
132
|
-
const presetObject = presets.find(
|
|
133
|
-
( preset ) =>
|
|
134
|
-
preset[ presetProperty ] === presetValueValue
|
|
135
|
-
);
|
|
136
|
-
if ( presetObject ) {
|
|
137
|
-
if ( presetProperty === 'slug' ) {
|
|
138
|
-
return presetObject;
|
|
139
|
-
}
|
|
140
|
-
// If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
|
|
141
|
-
const highestPresetObjectWithSameSlug = findInPresetsBy(
|
|
142
|
-
features,
|
|
143
|
-
blockName,
|
|
144
|
-
presetPath,
|
|
145
|
-
'slug',
|
|
146
|
-
presetObject.slug
|
|
147
|
-
);
|
|
148
|
-
if (
|
|
149
|
-
highestPresetObjectWithSameSlug[
|
|
150
|
-
presetProperty
|
|
151
|
-
] === presetObject[ presetProperty ]
|
|
152
|
-
) {
|
|
153
|
-
return presetObject;
|
|
154
|
-
}
|
|
155
|
-
return undefined;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export function getPresetVariableFromValue(
|
|
164
|
-
features,
|
|
165
|
-
blockName,
|
|
166
|
-
variableStylePath,
|
|
167
|
-
presetPropertyValue
|
|
168
|
-
) {
|
|
169
|
-
if ( ! presetPropertyValue ) {
|
|
170
|
-
return presetPropertyValue;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];
|
|
174
|
-
|
|
175
|
-
const metadata = PRESET_METADATA.find(
|
|
176
|
-
( data ) => data.cssVarInfix === cssVarInfix
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
if ( ! metadata ) {
|
|
180
|
-
// The property doesn't have preset data
|
|
181
|
-
// so the value should be returned as it is.
|
|
182
|
-
return presetPropertyValue;
|
|
183
|
-
}
|
|
184
|
-
const { valueKey, path } = metadata;
|
|
185
|
-
|
|
186
|
-
const presetObject = findInPresetsBy(
|
|
187
|
-
features,
|
|
188
|
-
blockName,
|
|
189
|
-
path,
|
|
190
|
-
valueKey,
|
|
191
|
-
presetPropertyValue
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
if ( ! presetObject ) {
|
|
195
|
-
// Value wasn't found in the presets,
|
|
196
|
-
// so it must be a custom value.
|
|
197
|
-
return presetPropertyValue;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return `var:preset|${ cssVarInfix }|${ presetObject.slug }`;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function getValueFromPresetVariable(
|
|
204
|
-
features,
|
|
205
|
-
blockName,
|
|
206
|
-
variable,
|
|
207
|
-
[ presetType, slug ]
|
|
208
|
-
) {
|
|
209
|
-
const metadata = PRESET_METADATA.find(
|
|
210
|
-
( data ) => data.cssVarInfix === presetType
|
|
211
|
-
);
|
|
212
|
-
if ( ! metadata ) {
|
|
213
|
-
return variable;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const presetObject = findInPresetsBy(
|
|
217
|
-
features.settings,
|
|
218
|
-
blockName,
|
|
219
|
-
metadata.path,
|
|
220
|
-
'slug',
|
|
221
|
-
slug
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
if ( presetObject ) {
|
|
225
|
-
const { valueKey } = metadata;
|
|
226
|
-
const result = presetObject[ valueKey ];
|
|
227
|
-
return getValueFromVariable( features, blockName, result );
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return variable;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function getValueFromCustomVariable( features, blockName, variable, path ) {
|
|
234
|
-
const result =
|
|
235
|
-
get( features.settings, [ 'blocks', blockName, 'custom', ...path ] ) ??
|
|
236
|
-
get( features.settings, [ 'custom', ...path ] );
|
|
237
|
-
if ( ! result ) {
|
|
238
|
-
return variable;
|
|
239
|
-
}
|
|
240
|
-
// A variable may reference another variable so we need recursion until we find the value.
|
|
241
|
-
return getValueFromVariable( features, blockName, result );
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Attempts to fetch the value of a theme.json CSS variable.
|
|
246
|
-
*
|
|
247
|
-
* @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.
|
|
248
|
-
* @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.
|
|
249
|
-
* @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.
|
|
250
|
-
* @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.
|
|
251
|
-
*/
|
|
252
|
-
export function getValueFromVariable( features, blockName, variable ) {
|
|
253
|
-
if ( ! variable || typeof variable !== 'string' ) {
|
|
254
|
-
if ( variable?.ref && typeof variable?.ref === 'string' ) {
|
|
255
|
-
const refPath = variable.ref.split( '.' );
|
|
256
|
-
variable = get( features, refPath );
|
|
257
|
-
// Presence of another ref indicates a reference to another dynamic value.
|
|
258
|
-
// Pointing to another dynamic value is not supported.
|
|
259
|
-
if ( ! variable || !! variable?.ref ) {
|
|
260
|
-
return variable;
|
|
261
|
-
}
|
|
262
|
-
} else {
|
|
263
|
-
return variable;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
const USER_VALUE_PREFIX = 'var:';
|
|
267
|
-
const THEME_VALUE_PREFIX = 'var(--wp--';
|
|
268
|
-
const THEME_VALUE_SUFFIX = ')';
|
|
269
|
-
|
|
270
|
-
let parsedVar;
|
|
271
|
-
|
|
272
|
-
if ( variable.startsWith( USER_VALUE_PREFIX ) ) {
|
|
273
|
-
parsedVar = variable.slice( USER_VALUE_PREFIX.length ).split( '|' );
|
|
274
|
-
} else if (
|
|
275
|
-
variable.startsWith( THEME_VALUE_PREFIX ) &&
|
|
276
|
-
variable.endsWith( THEME_VALUE_SUFFIX )
|
|
277
|
-
) {
|
|
278
|
-
parsedVar = variable
|
|
279
|
-
.slice( THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length )
|
|
280
|
-
.split( '--' );
|
|
281
|
-
} else {
|
|
282
|
-
// We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`
|
|
283
|
-
return variable;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const [ type, ...path ] = parsedVar;
|
|
287
|
-
if ( type === 'preset' ) {
|
|
288
|
-
return getValueFromPresetVariable(
|
|
289
|
-
features,
|
|
290
|
-
blockName,
|
|
291
|
-
variable,
|
|
292
|
-
path
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
if ( type === 'custom' ) {
|
|
296
|
-
return getValueFromCustomVariable(
|
|
297
|
-
features,
|
|
298
|
-
blockName,
|
|
299
|
-
variable,
|
|
300
|
-
path
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
return variable;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Function that scopes a selector with another one. This works a bit like
|
|
308
|
-
* SCSS nesting except the `&` operator isn't supported.
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* ```js
|
|
312
|
-
* const scope = '.a, .b .c';
|
|
313
|
-
* const selector = '> .x, .y';
|
|
314
|
-
* const merged = scopeSelector( scope, selector );
|
|
315
|
-
* // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
|
|
316
|
-
* ```
|
|
317
2
|
*
|
|
318
|
-
* @param {string}
|
|
319
|
-
* @param {string} selector Original selector.
|
|
3
|
+
* @param {string} variation The variation name.
|
|
320
4
|
*
|
|
321
|
-
* @return {string}
|
|
5
|
+
* @return {string} The variation class name.
|
|
322
6
|
*/
|
|
323
|
-
export function
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
scopes.forEach( ( outer ) => {
|
|
329
|
-
selectors.forEach( ( inner ) => {
|
|
330
|
-
selectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );
|
|
331
|
-
} );
|
|
332
|
-
} );
|
|
333
|
-
|
|
334
|
-
return selectorsScoped.join( ', ' );
|
|
7
|
+
export function getVariationClassName( variation ) {
|
|
8
|
+
if ( ! variation ) {
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
return `is-style-${ variation }`;
|
|
335
12
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { NavigationButtonAsItem } from './navigation-button';
|
|
12
|
+
import ContextMenu from './context-menu';
|
|
13
|
+
|
|
14
|
+
function getCoreBlockStyles( blockStyles ) {
|
|
15
|
+
return blockStyles?.filter( ( style ) => style.source === 'block' );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useHasVariationsPanel( name, parentMenu = '' ) {
|
|
19
|
+
const isInsideVariationsPanel = parentMenu.includes( 'variations' );
|
|
20
|
+
const blockStyles = useSelect(
|
|
21
|
+
( select ) => {
|
|
22
|
+
const { getBlockStyles } = select( blocksStore );
|
|
23
|
+
return getBlockStyles( name );
|
|
24
|
+
},
|
|
25
|
+
[ name ]
|
|
26
|
+
);
|
|
27
|
+
const coreBlockStyles = getCoreBlockStyles( blockStyles );
|
|
28
|
+
return !! coreBlockStyles?.length && ! isInsideVariationsPanel;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function VariationsPanel( { name } ) {
|
|
32
|
+
const blockStyles = useSelect(
|
|
33
|
+
( select ) => {
|
|
34
|
+
const { getBlockStyles } = select( blocksStore );
|
|
35
|
+
return getBlockStyles( name );
|
|
36
|
+
},
|
|
37
|
+
[ name ]
|
|
38
|
+
);
|
|
39
|
+
const coreBlockStyles = getCoreBlockStyles( blockStyles );
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<ItemGroup isBordered isSeparated>
|
|
43
|
+
{ coreBlockStyles.map( ( style, index ) => {
|
|
44
|
+
if ( style?.isDefault ) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (
|
|
48
|
+
<NavigationButtonAsItem
|
|
49
|
+
key={ index }
|
|
50
|
+
path={
|
|
51
|
+
'/blocks/' +
|
|
52
|
+
encodeURIComponent( name ) +
|
|
53
|
+
'/variations/' +
|
|
54
|
+
encodeURIComponent( style.name )
|
|
55
|
+
}
|
|
56
|
+
aria-label={ style.label }
|
|
57
|
+
>
|
|
58
|
+
{ style.label }
|
|
59
|
+
</NavigationButtonAsItem>
|
|
60
|
+
);
|
|
61
|
+
} ) }
|
|
62
|
+
</ItemGroup>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function VariationPanel( { blockName, styleName } ) {
|
|
67
|
+
return (
|
|
68
|
+
<ContextMenu
|
|
69
|
+
parentMenu={
|
|
70
|
+
'/blocks/' +
|
|
71
|
+
encodeURIComponent( blockName ) +
|
|
72
|
+
'/variations/' +
|
|
73
|
+
encodeURIComponent( styleName )
|
|
74
|
+
}
|
|
75
|
+
name={ blockName }
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useEffect } from '@wordpress/element';
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
11
|
import { store as editSiteStore } from '../../store';
|
|
12
|
+
import { unlock } from '../../experiments';
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { useGlobalStylesOutput } from '../global-styles/use-global-styles-output';
|
|
14
|
+
const { useGlobalStylesOutput } = unlock( blockEditorExperiments );
|
|
16
15
|
|
|
17
16
|
function useGlobalStylesRenderer() {
|
|
18
17
|
const [ styles, settings, svgFilters ] = useGlobalStylesOutput();
|
|
@@ -88,6 +88,7 @@ export default function DocumentActions() {
|
|
|
88
88
|
// Use the title wrapper as the popover anchor so that the dropdown is
|
|
89
89
|
// centered over the whole title area rather than just one part of it.
|
|
90
90
|
anchor: popoverAnchor,
|
|
91
|
+
placement: 'bottom',
|
|
91
92
|
} ),
|
|
92
93
|
[ popoverAnchor ]
|
|
93
94
|
);
|
|
@@ -146,7 +147,6 @@ export default function DocumentActions() {
|
|
|
146
147
|
|
|
147
148
|
<Dropdown
|
|
148
149
|
popoverProps={ popoverProps }
|
|
149
|
-
position="bottom center"
|
|
150
150
|
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
151
151
|
<Button
|
|
152
152
|
className="edit-site-document-actions__get-info"
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
__unstableMotion as motion,
|
|
12
12
|
__unstableAnimatePresence as AnimatePresence,
|
|
13
13
|
__unstableUseNavigateRegions as useNavigateRegions,
|
|
14
|
+
ResizableBox,
|
|
14
15
|
} from '@wordpress/components';
|
|
15
16
|
import {
|
|
16
17
|
useReducedMotion,
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
useResizeObserver,
|
|
19
20
|
} from '@wordpress/compose';
|
|
20
21
|
import { __ } from '@wordpress/i18n';
|
|
21
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
22
|
+
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
22
23
|
import { NavigableRegion } from '@wordpress/interface';
|
|
23
24
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
24
25
|
|
|
@@ -35,13 +36,28 @@ import getIsListPage from '../../utils/get-is-list-page';
|
|
|
35
36
|
import Header from '../header-edit-mode';
|
|
36
37
|
import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url';
|
|
37
38
|
import SiteHub from '../site-hub';
|
|
39
|
+
import ResizeHandle from '../block-editor/resize-handle';
|
|
40
|
+
import useSyncCanvasModeWithURL from '../sync-state-with-url/use-sync-canvas-mode-with-url';
|
|
38
41
|
|
|
39
42
|
const ANIMATION_DURATION = 0.5;
|
|
43
|
+
const emptyResizeHandleStyles = {
|
|
44
|
+
position: undefined,
|
|
45
|
+
userSelect: undefined,
|
|
46
|
+
cursor: undefined,
|
|
47
|
+
width: undefined,
|
|
48
|
+
height: undefined,
|
|
49
|
+
top: undefined,
|
|
50
|
+
right: undefined,
|
|
51
|
+
bottom: undefined,
|
|
52
|
+
left: undefined,
|
|
53
|
+
};
|
|
40
54
|
|
|
41
|
-
export default function Layout(
|
|
55
|
+
export default function Layout() {
|
|
42
56
|
// This ensures the edited entity id and type are initialized properly.
|
|
43
57
|
useInitEditedEntityFromURL();
|
|
58
|
+
useSyncCanvasModeWithURL();
|
|
44
59
|
|
|
60
|
+
const hubRef = useRef();
|
|
45
61
|
const { params } = useLocation();
|
|
46
62
|
const isListPage = getIsListPage( params );
|
|
47
63
|
const isEditorPage = ! isListPage;
|
|
@@ -86,6 +102,14 @@ export default function Layout( { onError } ) {
|
|
|
86
102
|
// Ideally this effect could be removed if we move the "isMobileCanvasVisible" into the store.
|
|
87
103
|
const [ canvasResizer, canvasSize ] = useResizeObserver();
|
|
88
104
|
const [ fullResizer, fullSize ] = useResizeObserver();
|
|
105
|
+
const [ forcedWidth, setForcedWidth ] = useState( null );
|
|
106
|
+
const [ isResizing, setIsResizing ] = useState( false );
|
|
107
|
+
const isResizingEnabled = ! isMobileViewport && canvasMode === 'view';
|
|
108
|
+
const defaultSidebarWidth = isMobileViewport ? '100vw' : 360;
|
|
109
|
+
let canvasWidth = isResizing ? '100%' : fullSize.width;
|
|
110
|
+
if ( showFrame && ! isResizing ) {
|
|
111
|
+
canvasWidth = canvasSize.width - canvasPadding;
|
|
112
|
+
}
|
|
89
113
|
useEffect( () => {
|
|
90
114
|
if ( canvasMode === 'view' && isMobileViewport ) {
|
|
91
115
|
setIsMobileCanvasVisible( false );
|
|
@@ -96,6 +120,13 @@ export default function Layout( { onError } ) {
|
|
|
96
120
|
}
|
|
97
121
|
}, [ canvasMode, isMobileViewport ] );
|
|
98
122
|
|
|
123
|
+
// Synchronizing the URL with the store value of canvasMode happens in an effect
|
|
124
|
+
// This condition ensures the component is only rendered after the synchronization happens
|
|
125
|
+
// which prevents any animations due to potential canvasMode value change.
|
|
126
|
+
if ( canvasMode === 'init' ) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
99
130
|
return (
|
|
100
131
|
<>
|
|
101
132
|
{ fullResizer }
|
|
@@ -112,7 +143,14 @@ export default function Layout( { onError } ) {
|
|
|
112
143
|
) }
|
|
113
144
|
>
|
|
114
145
|
<SiteHub
|
|
146
|
+
ref={ hubRef }
|
|
115
147
|
className="edit-site-layout__hub"
|
|
148
|
+
style={ {
|
|
149
|
+
width:
|
|
150
|
+
isResizingEnabled && forcedWidth
|
|
151
|
+
? forcedWidth - 48
|
|
152
|
+
: undefined,
|
|
153
|
+
} }
|
|
116
154
|
isMobileCanvasVisible={ isMobileCanvasVisible }
|
|
117
155
|
setIsMobileCanvasVisible={ setIsMobileCanvasVisible }
|
|
118
156
|
/>
|
|
@@ -149,7 +187,7 @@ export default function Layout( { onError } ) {
|
|
|
149
187
|
<div className="edit-site-layout__content">
|
|
150
188
|
<AnimatePresence initial={ false }>
|
|
151
189
|
{ showSidebar && (
|
|
152
|
-
<
|
|
190
|
+
<ResizableBox
|
|
153
191
|
as={ motion.div }
|
|
154
192
|
initial={ {
|
|
155
193
|
opacity: 0,
|
|
@@ -162,22 +200,80 @@ export default function Layout( { onError } ) {
|
|
|
162
200
|
} }
|
|
163
201
|
transition={ {
|
|
164
202
|
type: 'tween',
|
|
165
|
-
duration:
|
|
166
|
-
|
|
167
|
-
|
|
203
|
+
duration:
|
|
204
|
+
disableMotion || isResizing
|
|
205
|
+
? 0
|
|
206
|
+
: ANIMATION_DURATION,
|
|
168
207
|
ease: 'easeOut',
|
|
169
208
|
} }
|
|
209
|
+
size={ {
|
|
210
|
+
height: '100%',
|
|
211
|
+
width:
|
|
212
|
+
isResizingEnabled && forcedWidth
|
|
213
|
+
? forcedWidth
|
|
214
|
+
: defaultSidebarWidth,
|
|
215
|
+
} }
|
|
170
216
|
className="edit-site-layout__sidebar"
|
|
171
|
-
|
|
217
|
+
enable={ {
|
|
218
|
+
right: isResizingEnabled,
|
|
219
|
+
} }
|
|
220
|
+
onResizeStop={ ( event, direction, elt ) => {
|
|
221
|
+
setForcedWidth( elt.clientWidth );
|
|
222
|
+
setIsResizing( false );
|
|
223
|
+
} }
|
|
224
|
+
onResizeStart={ () => {
|
|
225
|
+
setIsResizing( true );
|
|
226
|
+
} }
|
|
227
|
+
onResize={ ( event, direction, elt ) => {
|
|
228
|
+
// This is a performance optimization
|
|
229
|
+
// We set the width imperatively to avoid re-rendering
|
|
230
|
+
// the whole component while resizing.
|
|
231
|
+
hubRef.current.style.width =
|
|
232
|
+
elt.clientWidth - 48 + 'px';
|
|
233
|
+
} }
|
|
234
|
+
handleComponent={ {
|
|
235
|
+
right: (
|
|
236
|
+
<ResizeHandle
|
|
237
|
+
direction="right"
|
|
238
|
+
variation="separator"
|
|
239
|
+
resizeWidthBy={ ( delta ) => {
|
|
240
|
+
setForcedWidth(
|
|
241
|
+
( forcedWidth ??
|
|
242
|
+
defaultSidebarWidth ) +
|
|
243
|
+
delta
|
|
244
|
+
);
|
|
245
|
+
} }
|
|
246
|
+
/>
|
|
247
|
+
),
|
|
248
|
+
} }
|
|
249
|
+
handleClasses={ undefined }
|
|
250
|
+
handleStyles={ {
|
|
251
|
+
right: emptyResizeHandleStyles,
|
|
252
|
+
} }
|
|
253
|
+
minWidth={ isResizingEnabled ? 320 : undefined }
|
|
254
|
+
maxWidth={
|
|
255
|
+
isResizingEnabled && fullSize
|
|
256
|
+
? fullSize.width - 360
|
|
257
|
+
: undefined
|
|
258
|
+
}
|
|
172
259
|
>
|
|
173
|
-
<
|
|
174
|
-
|
|
260
|
+
<NavigableRegion
|
|
261
|
+
ariaLabel={ __( 'Navigation sidebar' ) }
|
|
262
|
+
>
|
|
263
|
+
<Sidebar />
|
|
264
|
+
</NavigableRegion>
|
|
265
|
+
</ResizableBox>
|
|
175
266
|
) }
|
|
176
267
|
</AnimatePresence>
|
|
177
268
|
|
|
178
269
|
{ showCanvas && (
|
|
179
270
|
<div
|
|
180
|
-
className=
|
|
271
|
+
className={ classnames(
|
|
272
|
+
'edit-site-layout__canvas-container',
|
|
273
|
+
{
|
|
274
|
+
'is-resizing': isResizing,
|
|
275
|
+
}
|
|
276
|
+
) }
|
|
181
277
|
style={ {
|
|
182
278
|
paddingTop: showFrame ? canvasPadding : 0,
|
|
183
279
|
paddingBottom: showFrame ? canvasPadding : 0,
|
|
@@ -191,9 +287,10 @@ export default function Layout( { onError } ) {
|
|
|
191
287
|
className="edit-site-layout__canvas"
|
|
192
288
|
transition={ {
|
|
193
289
|
type: 'tween',
|
|
194
|
-
duration:
|
|
195
|
-
|
|
196
|
-
|
|
290
|
+
duration:
|
|
291
|
+
disableMotion || isResizing
|
|
292
|
+
? 0
|
|
293
|
+
: ANIMATION_DURATION,
|
|
197
294
|
ease: 'easeOut',
|
|
198
295
|
} }
|
|
199
296
|
>
|
|
@@ -206,20 +303,18 @@ export default function Layout( { onError } ) {
|
|
|
206
303
|
} }
|
|
207
304
|
initial={ false }
|
|
208
305
|
animate={ {
|
|
209
|
-
width:
|
|
210
|
-
? canvasSize.width -
|
|
211
|
-
canvasPadding
|
|
212
|
-
: fullSize.width,
|
|
306
|
+
width: canvasWidth,
|
|
213
307
|
} }
|
|
214
308
|
transition={ {
|
|
215
309
|
type: 'tween',
|
|
216
|
-
duration:
|
|
217
|
-
|
|
218
|
-
|
|
310
|
+
duration:
|
|
311
|
+
disableMotion || isResizing
|
|
312
|
+
? 0
|
|
313
|
+
: ANIMATION_DURATION,
|
|
219
314
|
ease: 'easeOut',
|
|
220
315
|
} }
|
|
221
316
|
>
|
|
222
|
-
<ErrorBoundary
|
|
317
|
+
<ErrorBoundary>
|
|
223
318
|
{ isEditorPage && <Editor /> }
|
|
224
319
|
{ isListPage && <ListPage /> }
|
|
225
320
|
</ErrorBoundary>
|