@wordpress/edit-site 5.0.0 → 5.2.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 +14 -1
- package/LICENSE.md +1 -1
- package/build/components/add-new-template/new-template-part.js +21 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/utils.js +9 -1
- package/build/components/add-new-template/utils.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 +17 -52
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resize-handle.js +2 -1
- package/build/components/block-editor/resize-handle.js.map +1 -1
- package/build/components/editor/index.js +5 -17
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +27 -6
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -5
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +9 -1
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +1 -0
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +16 -11
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +3 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +6 -6
- 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-block.js +2 -6
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-border.js +12 -2
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +3 -4
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +53 -25
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +9 -10
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +12 -2
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +8 -8
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +7 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +4 -4
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +11 -1
- 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/typography-panel.js +9 -8
- package/build/components/global-styles/typography-panel.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 +85 -18
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +119 -33
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +60 -3
- 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/header-edit-mode/document-actions/index.js +10 -41
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/layout/index.js +129 -87
- package/build/components/layout/index.js.map +1 -1
- package/build/components/sidebar/index.js +5 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +3 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.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-screen-main/index.js +1 -31
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +3 -22
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +149 -0
- package/build/components/site-hub/index.js.map +1 -0
- 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/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 +5 -0
- package/build/index.js.map +1 -1
- package/build/store/reducer.js +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +20 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +5 -0
- package/build-module/components/add-new-template/utils.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 +19 -50
- package/build-module/components/block-editor/index.js.map +1 -1
- 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/editor/index.js +2 -13
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +26 -6
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -5
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +7 -1
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +1 -0
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +16 -11
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +3 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +6 -6
- 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-block.js +2 -5
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +10 -2
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +3 -4
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +51 -25
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +9 -10
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +10 -2
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +8 -8
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +8 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +4 -4
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +9 -1
- 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/typography-panel.js +9 -8
- package/build-module/components/global-styles/typography-panel.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 +84 -19
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +121 -35
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +56 -3
- 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/header-edit-mode/document-actions/index.js +10 -38
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/layout/index.js +129 -88
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +4 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +3 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.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-screen-main/index.js +2 -27
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -23
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +127 -0
- package/build-module/components/site-hub/index.js.map +1 -0
- 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/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 +4 -0
- 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-style/style-rtl.css +190 -125
- package/build-style/style.css +190 -125
- package/package.json +30 -29
- package/src/components/add-new-template/new-template-part.js +23 -1
- package/src/components/add-new-template/utils.js +14 -0
- package/src/components/block-editor/editor-canvas.js +0 -1
- package/src/components/block-editor/index.js +14 -59
- package/src/components/block-editor/resize-handle.js +6 -2
- package/src/components/block-editor/style.scss +43 -7
- package/src/components/editor/index.js +2 -17
- package/src/components/global-styles/block-preview-panel.js +37 -10
- package/src/components/global-styles/border-panel.js +8 -5
- package/src/components/global-styles/context-menu.js +6 -0
- package/src/components/global-styles/custom-css.js +1 -0
- package/src/components/global-styles/dimensions-panel.js +32 -15
- package/src/components/global-styles/global-styles-provider.js +11 -5
- package/src/components/global-styles/screen-background-color.js +12 -6
- package/src/components/global-styles/screen-block-list.js +6 -1
- package/src/components/global-styles/screen-block.js +1 -4
- package/src/components/global-styles/screen-border.js +8 -3
- package/src/components/global-styles/screen-button-color.js +2 -4
- package/src/components/global-styles/screen-colors.js +84 -20
- package/src/components/global-styles/screen-heading-color.js +8 -10
- package/src/components/global-styles/screen-layout.js +11 -3
- package/src/components/global-styles/screen-link-color.js +19 -8
- package/src/components/global-styles/screen-root.js +34 -27
- package/src/components/global-styles/screen-text-color.js +7 -4
- package/src/components/global-styles/screen-typography.js +13 -3
- package/src/components/global-styles/screen-variations.js +47 -0
- package/src/components/global-styles/style.scss +9 -0
- package/src/components/global-styles/test/typography-utils.js +72 -23
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-panel.js +31 -8
- package/src/components/global-styles/typography-utils.js +24 -4
- package/src/components/global-styles/ui.js +101 -13
- package/src/components/global-styles/use-global-styles-output.js +137 -14
- package/src/components/global-styles/utils.js +56 -3
- package/src/components/global-styles/variations-panel.js +78 -0
- package/src/components/header-edit-mode/document-actions/index.js +18 -37
- package/src/components/header-edit-mode/style.scss +1 -0
- package/src/components/layout/index.js +217 -172
- package/src/components/layout/style.scss +98 -66
- package/src/components/list/style.scss +1 -8
- package/src/components/sidebar/index.js +4 -1
- package/src/components/sidebar-edit-mode/index.js +1 -1
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
- 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 +4 -0
- package/src/components/sidebar-navigation-screen/style.scss +2 -4
- package/src/components/sidebar-navigation-screen-main/index.js +1 -29
- package/src/components/sidebar-navigation-screen-templates/index.js +9 -27
- package/src/components/site-hub/index.js +161 -0
- package/src/components/site-hub/style.scss +31 -0
- 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/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 +2 -0
- package/src/store/reducer.js +1 -1
- package/src/style.scss +2 -0
- package/build/components/site-title/index.js +0 -55
- package/build/components/site-title/index.js.map +0 -1
- package/build-module/components/site-title/index.js +0 -43
- package/build-module/components/site-title/index.js.map +0 -1
- package/src/components/site-title/index.js +0 -39
|
@@ -6,12 +6,12 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useSelect
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
10
|
import {
|
|
11
|
-
Button,
|
|
12
|
-
__experimentalHStack as HStack,
|
|
13
11
|
__unstableMotion as motion,
|
|
14
12
|
__unstableAnimatePresence as AnimatePresence,
|
|
13
|
+
__unstableUseNavigateRegions as useNavigateRegions,
|
|
14
|
+
ResizableBox,
|
|
15
15
|
} from '@wordpress/components';
|
|
16
16
|
import {
|
|
17
17
|
useReducedMotion,
|
|
@@ -19,14 +19,14 @@ import {
|
|
|
19
19
|
useResizeObserver,
|
|
20
20
|
} from '@wordpress/compose';
|
|
21
21
|
import { __ } from '@wordpress/i18n';
|
|
22
|
-
import {
|
|
23
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
22
|
+
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
24
23
|
import { NavigableRegion } from '@wordpress/interface';
|
|
24
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Internal dependencies
|
|
28
28
|
*/
|
|
29
|
-
import
|
|
29
|
+
import Sidebar from '../sidebar';
|
|
30
30
|
import Editor from '../editor';
|
|
31
31
|
import ListPage from '../list';
|
|
32
32
|
import ErrorBoundary from '../error-boundary';
|
|
@@ -34,30 +34,55 @@ import { store as editSiteStore } from '../../store';
|
|
|
34
34
|
import { useLocation } from '../routes';
|
|
35
35
|
import getIsListPage from '../../utils/get-is-list-page';
|
|
36
36
|
import Header from '../header-edit-mode';
|
|
37
|
-
import SiteIcon from '../site-icon';
|
|
38
|
-
import SiteTitle from '../site-title';
|
|
39
37
|
import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url';
|
|
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';
|
|
40
41
|
|
|
41
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
|
+
};
|
|
42
54
|
|
|
43
55
|
export default function Layout( { onError } ) {
|
|
44
56
|
// This ensures the edited entity id and type are initialized properly.
|
|
45
57
|
useInitEditedEntityFromURL();
|
|
58
|
+
useSyncCanvasModeWithURL();
|
|
46
59
|
|
|
60
|
+
const hubRef = useRef();
|
|
47
61
|
const { params } = useLocation();
|
|
48
62
|
const isListPage = getIsListPage( params );
|
|
49
63
|
const isEditorPage = ! isListPage;
|
|
50
|
-
const { canvasMode,
|
|
51
|
-
( select ) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
const { canvasMode, previousShortcut, nextShortcut } = useSelect(
|
|
65
|
+
( select ) => {
|
|
66
|
+
const { getAllShortcutKeyCombinations } = select(
|
|
67
|
+
keyboardShortcutsStore
|
|
68
|
+
);
|
|
69
|
+
const { __unstableGetCanvasMode } = select( editSiteStore );
|
|
70
|
+
return {
|
|
71
|
+
canvasMode: __unstableGetCanvasMode(),
|
|
72
|
+
previousShortcut: getAllShortcutKeyCombinations(
|
|
73
|
+
'core/edit-site/previous-region'
|
|
74
|
+
),
|
|
75
|
+
nextShortcut: getAllShortcutKeyCombinations(
|
|
76
|
+
'core/edit-site/next-region'
|
|
77
|
+
),
|
|
78
|
+
};
|
|
79
|
+
},
|
|
57
80
|
[]
|
|
58
81
|
);
|
|
59
|
-
const
|
|
60
|
-
|
|
82
|
+
const navigateRegionsProps = useNavigateRegions( {
|
|
83
|
+
previous: previousShortcut,
|
|
84
|
+
next: nextShortcut,
|
|
85
|
+
} );
|
|
61
86
|
const disableMotion = useReducedMotion();
|
|
62
87
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
63
88
|
const [ isMobileCanvasVisible, setIsMobileCanvasVisible ] =
|
|
@@ -70,17 +95,21 @@ export default function Layout( { onError } ) {
|
|
|
70
95
|
( isMobileViewport && isMobileCanvasVisible ) || ! isMobileViewport;
|
|
71
96
|
const showFrame =
|
|
72
97
|
! isEditorPage || ( canvasMode === 'view' && ! isMobileViewport );
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
isMobileViewport
|
|
76
|
-
canvasMode === 'view' &&
|
|
98
|
+
|
|
99
|
+
const isFullCanvas =
|
|
100
|
+
( isEditorPage && canvasMode === 'edit' && ! isMobileViewport ) ||
|
|
77
101
|
isMobileCanvasVisible;
|
|
78
|
-
const isBackToDashboardButton =
|
|
79
|
-
( ! isMobileViewport && canvasMode === 'view' ) ||
|
|
80
|
-
( isMobileViewport && ! isMobileCanvasVisible );
|
|
81
102
|
// Ideally this effect could be removed if we move the "isMobileCanvasVisible" into the store.
|
|
82
103
|
const [ canvasResizer, canvasSize ] = useResizeObserver();
|
|
83
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
|
+
}
|
|
84
113
|
useEffect( () => {
|
|
85
114
|
if ( canvasMode === 'view' && isMobileViewport ) {
|
|
86
115
|
setIsMobileCanvasVisible( false );
|
|
@@ -90,94 +119,58 @@ export default function Layout( { onError } ) {
|
|
|
90
119
|
setIsMobileCanvasVisible( true );
|
|
91
120
|
}
|
|
92
121
|
}, [ canvasMode, isMobileViewport ] );
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
onClick: () => {
|
|
101
|
-
clearSelectedBlock();
|
|
102
|
-
setIsMobileCanvasVisible( false );
|
|
103
|
-
__unstableSetCanvasMode( 'view' );
|
|
104
|
-
},
|
|
105
|
-
};
|
|
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
|
+
}
|
|
106
129
|
|
|
107
130
|
return (
|
|
108
131
|
<>
|
|
109
132
|
{ fullResizer }
|
|
110
133
|
<div
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
134
|
+
{ ...navigateRegionsProps }
|
|
135
|
+
ref={ navigateRegionsProps.ref }
|
|
136
|
+
className={ classnames(
|
|
137
|
+
'edit-site-layout',
|
|
138
|
+
navigateRegionsProps.className,
|
|
139
|
+
{
|
|
140
|
+
'is-full-canvas': isFullCanvas,
|
|
141
|
+
'is-edit-mode': canvasMode === 'edit',
|
|
142
|
+
}
|
|
143
|
+
) }
|
|
118
144
|
>
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
exit={ { opacity: 0 } }
|
|
132
|
-
animate={ { opacity: 1 } }
|
|
133
|
-
style={ {
|
|
134
|
-
position: 'absolute',
|
|
135
|
-
left: 60,
|
|
136
|
-
} }
|
|
137
|
-
>
|
|
138
|
-
<HStack>
|
|
139
|
-
{ isBackToDashboardButton && (
|
|
140
|
-
<SiteTitle />
|
|
141
|
-
) }
|
|
142
|
-
|
|
143
|
-
{ showEditButton && (
|
|
144
|
-
<Button
|
|
145
|
-
className="edit-site-layout__edit-button"
|
|
146
|
-
label={ __(
|
|
147
|
-
'Open the editor'
|
|
148
|
-
) }
|
|
149
|
-
onClick={ () => {
|
|
150
|
-
__unstableSetCanvasMode(
|
|
151
|
-
'edit'
|
|
152
|
-
);
|
|
153
|
-
} }
|
|
154
|
-
>
|
|
155
|
-
{ __( 'Edit' ) }
|
|
156
|
-
</Button>
|
|
157
|
-
) }
|
|
158
|
-
</HStack>
|
|
159
|
-
</motion.div>
|
|
160
|
-
) }
|
|
161
|
-
</AnimatePresence>
|
|
145
|
+
<SiteHub
|
|
146
|
+
ref={ hubRef }
|
|
147
|
+
className="edit-site-layout__hub"
|
|
148
|
+
style={ {
|
|
149
|
+
width:
|
|
150
|
+
isResizingEnabled && forcedWidth
|
|
151
|
+
? forcedWidth - 48
|
|
152
|
+
: undefined,
|
|
153
|
+
} }
|
|
154
|
+
isMobileCanvasVisible={ isMobileCanvasVisible }
|
|
155
|
+
setIsMobileCanvasVisible={ setIsMobileCanvasVisible }
|
|
156
|
+
/>
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
setIsMobileCanvasVisible( true )
|
|
167
|
-
}
|
|
168
|
-
style={ { position: 'fixed', right: 0 } }
|
|
169
|
-
>
|
|
170
|
-
{ __( 'View Editor' ) }
|
|
171
|
-
</Button>
|
|
172
|
-
) }
|
|
173
|
-
</div>
|
|
174
|
-
<AnimatePresence>
|
|
175
|
-
{ isEditorPage && canvasMode === 'edit' && (
|
|
158
|
+
<AnimatePresence initial={ false }>
|
|
159
|
+
{ isEditorPage &&
|
|
160
|
+
( canvasMode === 'edit' || isMobileCanvasVisible ) && (
|
|
176
161
|
<NavigableRegion
|
|
162
|
+
className="edit-site-layout__header"
|
|
163
|
+
ariaLabel={ __( 'Editor top bar' ) }
|
|
177
164
|
as={ motion.div }
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
165
|
+
animate={ {
|
|
166
|
+
y: 0,
|
|
167
|
+
} }
|
|
168
|
+
initial={ {
|
|
169
|
+
y: '-100%',
|
|
170
|
+
} }
|
|
171
|
+
exit={ {
|
|
172
|
+
y: '-100%',
|
|
173
|
+
} }
|
|
181
174
|
transition={ {
|
|
182
175
|
type: 'tween',
|
|
183
176
|
duration: disableMotion
|
|
@@ -185,93 +178,145 @@ export default function Layout( { onError } ) {
|
|
|
185
178
|
: ANIMATION_DURATION,
|
|
186
179
|
ease: 'easeOut',
|
|
187
180
|
} }
|
|
188
|
-
className="edit-site-layout__editor-header"
|
|
189
|
-
ariaLabel={ __( 'Editor top bar' ) }
|
|
190
181
|
>
|
|
191
|
-
<Header />
|
|
182
|
+
{ canvasMode === 'edit' && <Header /> }
|
|
192
183
|
</NavigableRegion>
|
|
193
184
|
) }
|
|
194
|
-
</AnimatePresence>
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
<AnimatePresence initial={ false }>
|
|
198
|
-
{ showSidebar && (
|
|
199
|
-
<motion.div
|
|
200
|
-
initial={ {
|
|
201
|
-
opacity: 0,
|
|
202
|
-
} }
|
|
203
|
-
animate={ {
|
|
204
|
-
opacity: 1,
|
|
205
|
-
} }
|
|
206
|
-
exit={ {
|
|
207
|
-
opacity: 0,
|
|
208
|
-
} }
|
|
209
|
-
transition={ {
|
|
210
|
-
type: 'tween',
|
|
211
|
-
duration: disableMotion
|
|
212
|
-
? 0
|
|
213
|
-
: ANIMATION_DURATION,
|
|
214
|
-
ease: 'easeOut',
|
|
215
|
-
} }
|
|
216
|
-
className="edit-site-layout__sidebar"
|
|
217
|
-
>
|
|
218
|
-
<Sidebar />
|
|
219
|
-
</motion.div>
|
|
220
|
-
) }
|
|
221
185
|
</AnimatePresence>
|
|
222
186
|
|
|
223
|
-
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
187
|
+
<div className="edit-site-layout__content">
|
|
188
|
+
<AnimatePresence initial={ false }>
|
|
189
|
+
{ showSidebar && (
|
|
190
|
+
<ResizableBox
|
|
191
|
+
as={ motion.div }
|
|
192
|
+
initial={ {
|
|
193
|
+
opacity: 0,
|
|
194
|
+
} }
|
|
195
|
+
animate={ {
|
|
196
|
+
opacity: 1,
|
|
197
|
+
} }
|
|
198
|
+
exit={ {
|
|
199
|
+
opacity: 0,
|
|
200
|
+
} }
|
|
237
201
|
transition={ {
|
|
238
202
|
type: 'tween',
|
|
239
|
-
duration:
|
|
240
|
-
|
|
241
|
-
|
|
203
|
+
duration:
|
|
204
|
+
disableMotion || isResizing
|
|
205
|
+
? 0
|
|
206
|
+
: ANIMATION_DURATION,
|
|
242
207
|
ease: 'easeOut',
|
|
243
208
|
} }
|
|
209
|
+
size={ {
|
|
210
|
+
height: '100%',
|
|
211
|
+
width:
|
|
212
|
+
isResizingEnabled && forcedWidth
|
|
213
|
+
? forcedWidth
|
|
214
|
+
: defaultSidebarWidth,
|
|
215
|
+
} }
|
|
216
|
+
className="edit-site-layout__sidebar"
|
|
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
|
+
/>
|
|
240
|
+
),
|
|
241
|
+
} }
|
|
242
|
+
handleClasses={ undefined }
|
|
243
|
+
handleStyles={ {
|
|
244
|
+
right: emptyResizeHandleStyles,
|
|
245
|
+
} }
|
|
246
|
+
minWidth={ isResizingEnabled ? 320 : undefined }
|
|
247
|
+
maxWidth={
|
|
248
|
+
isResizingEnabled && fullSize
|
|
249
|
+
? fullSize.width - 360
|
|
250
|
+
: undefined
|
|
251
|
+
}
|
|
244
252
|
>
|
|
253
|
+
<NavigableRegion
|
|
254
|
+
ariaLabel={ __( 'Navigation sidebar' ) }
|
|
255
|
+
>
|
|
256
|
+
<Sidebar />
|
|
257
|
+
</NavigableRegion>
|
|
258
|
+
</ResizableBox>
|
|
259
|
+
) }
|
|
260
|
+
</AnimatePresence>
|
|
261
|
+
|
|
262
|
+
{ showCanvas && (
|
|
263
|
+
<div
|
|
264
|
+
className={ classnames(
|
|
265
|
+
'edit-site-layout__canvas-container',
|
|
266
|
+
{
|
|
267
|
+
'is-resizing': isResizing,
|
|
268
|
+
}
|
|
269
|
+
) }
|
|
270
|
+
style={ {
|
|
271
|
+
paddingTop: showFrame ? canvasPadding : 0,
|
|
272
|
+
paddingBottom: showFrame ? canvasPadding : 0,
|
|
273
|
+
} }
|
|
274
|
+
>
|
|
275
|
+
{ canvasResizer }
|
|
276
|
+
{ !! canvasSize.width && (
|
|
245
277
|
<motion.div
|
|
246
|
-
style={ {
|
|
247
|
-
position: 'absolute',
|
|
248
|
-
top: 0,
|
|
249
|
-
left: 0,
|
|
250
|
-
bottom: 0,
|
|
251
|
-
} }
|
|
252
278
|
initial={ false }
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
? canvasSize.width - canvasPadding
|
|
256
|
-
: fullSize.width,
|
|
257
|
-
} }
|
|
279
|
+
layout="position"
|
|
280
|
+
className="edit-site-layout__canvas"
|
|
258
281
|
transition={ {
|
|
259
282
|
type: 'tween',
|
|
260
|
-
duration:
|
|
261
|
-
|
|
262
|
-
|
|
283
|
+
duration:
|
|
284
|
+
disableMotion || isResizing
|
|
285
|
+
? 0
|
|
286
|
+
: ANIMATION_DURATION,
|
|
263
287
|
ease: 'easeOut',
|
|
264
288
|
} }
|
|
265
289
|
>
|
|
266
|
-
<
|
|
267
|
-
{
|
|
268
|
-
|
|
269
|
-
|
|
290
|
+
<motion.div
|
|
291
|
+
style={ {
|
|
292
|
+
position: 'absolute',
|
|
293
|
+
top: 0,
|
|
294
|
+
left: 0,
|
|
295
|
+
bottom: 0,
|
|
296
|
+
} }
|
|
297
|
+
initial={ false }
|
|
298
|
+
animate={ {
|
|
299
|
+
width: canvasWidth,
|
|
300
|
+
} }
|
|
301
|
+
transition={ {
|
|
302
|
+
type: 'tween',
|
|
303
|
+
duration:
|
|
304
|
+
disableMotion || isResizing
|
|
305
|
+
? 0
|
|
306
|
+
: ANIMATION_DURATION,
|
|
307
|
+
ease: 'easeOut',
|
|
308
|
+
} }
|
|
309
|
+
>
|
|
310
|
+
<ErrorBoundary onError={ onError }>
|
|
311
|
+
{ isEditorPage && <Editor /> }
|
|
312
|
+
{ isListPage && <ListPage /> }
|
|
313
|
+
</ErrorBoundary>
|
|
314
|
+
</motion.div>
|
|
270
315
|
</motion.div>
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
316
|
+
) }
|
|
317
|
+
</div>
|
|
318
|
+
) }
|
|
319
|
+
</div>
|
|
275
320
|
</div>
|
|
276
321
|
</>
|
|
277
322
|
);
|