@wordpress/edit-site 5.12.11 → 5.12.13
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/build/components/block-editor/constants.js +1 -1
- package/build/components/block-editor/constants.js.map +1 -1
- package/build/components/editor/index.js +2 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +8 -2
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +31 -25
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +1 -1
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/layout/index.js +6 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/grid.js +2 -1
- package/build/components/page-patterns/grid.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +17 -3
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +20 -3
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-template-parts/index.js +1 -2
- package/build/components/page-template-parts/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +11 -19
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +15 -13
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +8 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +2 -0
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +0 -9
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +1 -10
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +30 -0
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/store/private-actions.js +2 -1
- package/build/store/private-actions.js.map +1 -1
- package/build-module/components/block-editor/constants.js +1 -1
- package/build-module/components/block-editor/constants.js.map +1 -1
- package/build-module/components/editor/index.js +2 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +9 -3
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +27 -21
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +3 -3
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +7 -5
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/layout/index.js +6 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/grid.js +3 -2
- package/build-module/components/page-patterns/grid.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +17 -3
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +19 -3
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-template-parts/index.js +1 -2
- package/build-module/components/page-template-parts/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +12 -20
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +13 -13
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +7 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -0
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +0 -5
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +0 -7
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +1 -8
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +29 -0
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/store/private-actions.js +2 -1
- package/build-module/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +25 -25
- package/build-style/style.css +25 -25
- package/package.json +20 -20
- package/src/components/block-editor/constants.js +5 -1
- package/src/components/editor/index.js +2 -3
- package/src/components/global-styles/screen-revisions/index.js +76 -58
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +14 -1
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +63 -48
- package/src/components/header-edit-mode/document-actions/index.js +4 -3
- package/src/components/header-edit-mode/document-actions/style.scss +25 -25
- package/src/components/keyboard-shortcuts/edit-mode.js +4 -5
- package/src/components/layout/index.js +6 -0
- package/src/components/page-patterns/grid.js +8 -3
- package/src/components/page-patterns/patterns-list.js +15 -2
- package/src/components/page-patterns/style.scss +3 -0
- package/src/components/page-patterns/use-patterns.js +19 -3
- package/src/components/page-template-parts/index.js +0 -1
- package/src/components/resizable-frame/index.js +10 -25
- package/src/components/sidebar-navigation-screen/index.js +13 -15
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +27 -15
- package/src/components/sidebar-navigation-screen-pages/index.js +9 -4
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +5 -13
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -8
- package/src/components/sidebar-navigation-screen-templates/index.js +1 -9
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -0
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -4
- package/src/hooks/commands/use-edit-mode-commands.js +34 -3
- package/src/store/private-actions.js +5 -1
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useState, useRef
|
|
9
|
+
import { useState, useRef } from '@wordpress/element';
|
|
10
10
|
import {
|
|
11
11
|
ResizableBox,
|
|
12
12
|
Tooltip,
|
|
@@ -82,6 +82,8 @@ function ResizableFrame( {
|
|
|
82
82
|
setIsOversized,
|
|
83
83
|
isReady,
|
|
84
84
|
children,
|
|
85
|
+
/** The default (unresized) width/height of the frame, based on the space availalbe in the viewport. */
|
|
86
|
+
defaultSize,
|
|
85
87
|
innerContentStyle,
|
|
86
88
|
} ) {
|
|
87
89
|
const [ frameSize, setFrameSize ] = useState( INITIAL_FRAME_SIZE );
|
|
@@ -95,22 +97,13 @@ function ResizableFrame( {
|
|
|
95
97
|
[]
|
|
96
98
|
);
|
|
97
99
|
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
|
|
98
|
-
const initialAspectRatioRef = useRef( null );
|
|
99
|
-
// The width of the resizable frame on initial render.
|
|
100
|
-
const initialComputedWidthRef = useRef( null );
|
|
101
100
|
const FRAME_TRANSITION = { type: 'tween', duration: isResizing ? 0 : 0.5 };
|
|
102
101
|
const frameRef = useRef( null );
|
|
103
102
|
const resizableHandleHelpId = useInstanceId(
|
|
104
103
|
ResizableFrame,
|
|
105
104
|
'edit-site-resizable-frame-handle-help'
|
|
106
105
|
);
|
|
107
|
-
|
|
108
|
-
// Remember frame dimensions on initial render.
|
|
109
|
-
useEffect( () => {
|
|
110
|
-
const { offsetWidth, offsetHeight } = frameRef.current.resizable;
|
|
111
|
-
initialComputedWidthRef.current = offsetWidth;
|
|
112
|
-
initialAspectRatioRef.current = offsetWidth / offsetHeight;
|
|
113
|
-
}, [] );
|
|
106
|
+
const defaultAspectRatio = defaultSize.width / defaultSize.height;
|
|
114
107
|
|
|
115
108
|
const handleResizeStart = ( _event, _direction, ref ) => {
|
|
116
109
|
// Remember the starting width so we don't have to get `ref.offsetWidth` on
|
|
@@ -126,7 +119,7 @@ function ResizableFrame( {
|
|
|
126
119
|
const maxDoubledDelta =
|
|
127
120
|
delta.width < 0 // is shrinking
|
|
128
121
|
? deltaAbs
|
|
129
|
-
: (
|
|
122
|
+
: ( defaultSize.width - startingWidth ) / 2;
|
|
130
123
|
const deltaToDouble = Math.min( deltaAbs, maxDoubledDelta );
|
|
131
124
|
const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs;
|
|
132
125
|
const singleSegment = 1 - doubleSegment;
|
|
@@ -135,17 +128,14 @@ function ResizableFrame( {
|
|
|
135
128
|
|
|
136
129
|
const updatedWidth = startingWidth + delta.width;
|
|
137
130
|
|
|
138
|
-
setIsOversized( updatedWidth >
|
|
131
|
+
setIsOversized( updatedWidth > defaultSize.width );
|
|
139
132
|
|
|
140
133
|
// Width will be controlled by the library (via `resizeRatio`),
|
|
141
134
|
// so we only need to update the height.
|
|
142
135
|
setFrameSize( {
|
|
143
136
|
height: isOversized
|
|
144
137
|
? '100%'
|
|
145
|
-
: calculateNewHeight(
|
|
146
|
-
updatedWidth,
|
|
147
|
-
initialAspectRatioRef.current
|
|
148
|
-
),
|
|
138
|
+
: calculateNewHeight( updatedWidth, defaultAspectRatio ),
|
|
149
139
|
} );
|
|
150
140
|
};
|
|
151
141
|
|
|
@@ -186,15 +176,12 @@ function ResizableFrame( {
|
|
|
186
176
|
FRAME_MIN_WIDTH,
|
|
187
177
|
frameRef.current.resizable.offsetWidth + delta
|
|
188
178
|
),
|
|
189
|
-
|
|
179
|
+
defaultSize.width
|
|
190
180
|
);
|
|
191
181
|
|
|
192
182
|
setFrameSize( {
|
|
193
183
|
width: newWidth,
|
|
194
|
-
height: calculateNewHeight(
|
|
195
|
-
newWidth,
|
|
196
|
-
initialAspectRatioRef.current
|
|
197
|
-
),
|
|
184
|
+
height: calculateNewHeight( newWidth, defaultAspectRatio ),
|
|
198
185
|
} );
|
|
199
186
|
};
|
|
200
187
|
|
|
@@ -291,9 +278,7 @@ function ResizableFrame( {
|
|
|
291
278
|
undefined
|
|
292
279
|
}
|
|
293
280
|
aria-valuemin={ FRAME_MIN_WIDTH }
|
|
294
|
-
aria-valuemax={
|
|
295
|
-
initialComputedWidthRef.current
|
|
296
|
-
}
|
|
281
|
+
aria-valuemax={ defaultSize.width }
|
|
297
282
|
onKeyDown={ handleResizableHandleKeyDown }
|
|
298
283
|
initial="hidden"
|
|
299
284
|
exit="hidden"
|
|
@@ -11,6 +11,7 @@ import { isRTL, __, sprintf } from '@wordpress/i18n';
|
|
|
11
11
|
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
12
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
13
|
import { useSelect } from '@wordpress/data';
|
|
14
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
@@ -23,6 +24,8 @@ import {
|
|
|
23
24
|
currentlyPreviewingTheme,
|
|
24
25
|
} from '../../utils/is-previewing-theme';
|
|
25
26
|
|
|
27
|
+
const { useLocation } = unlock( routerPrivateApis );
|
|
28
|
+
|
|
26
29
|
export default function SidebarNavigationScreen( {
|
|
27
30
|
isRoot,
|
|
28
31
|
title,
|
|
@@ -31,7 +34,7 @@ export default function SidebarNavigationScreen( {
|
|
|
31
34
|
content,
|
|
32
35
|
footer,
|
|
33
36
|
description,
|
|
34
|
-
backPath,
|
|
37
|
+
backPath: backPathProp,
|
|
35
38
|
} ) {
|
|
36
39
|
const { dashboardLink } = useSelect( ( select ) => {
|
|
37
40
|
const { getSettings } = unlock( select( editSiteStore ) );
|
|
@@ -40,6 +43,7 @@ export default function SidebarNavigationScreen( {
|
|
|
40
43
|
};
|
|
41
44
|
}, [] );
|
|
42
45
|
const { getTheme } = useSelect( coreStore );
|
|
46
|
+
const location = useLocation();
|
|
43
47
|
const navigator = useNavigator();
|
|
44
48
|
const theme = getTheme( currentlyPreviewingTheme() );
|
|
45
49
|
const icon = isRTL() ? chevronRight : chevronLeft;
|
|
@@ -56,13 +60,17 @@ export default function SidebarNavigationScreen( {
|
|
|
56
60
|
alignment="flex-start"
|
|
57
61
|
className="edit-site-sidebar-navigation-screen__title-icon"
|
|
58
62
|
>
|
|
59
|
-
{ ! isRoot &&
|
|
63
|
+
{ ! isRoot && (
|
|
60
64
|
<SidebarButton
|
|
61
65
|
onClick={ () => {
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
const backPath =
|
|
67
|
+
backPathProp ?? location.state?.backPath;
|
|
68
|
+
if ( backPath ) {
|
|
69
|
+
navigator.goTo( backPath, {
|
|
70
|
+
isBack: true,
|
|
71
|
+
} );
|
|
64
72
|
} else {
|
|
65
|
-
navigator.
|
|
73
|
+
navigator.goToParent();
|
|
66
74
|
}
|
|
67
75
|
} }
|
|
68
76
|
icon={ icon }
|
|
@@ -70,16 +78,6 @@ export default function SidebarNavigationScreen( {
|
|
|
70
78
|
showTooltip={ false }
|
|
71
79
|
/>
|
|
72
80
|
) }
|
|
73
|
-
{ ! isRoot && backPath && (
|
|
74
|
-
<SidebarButton
|
|
75
|
-
onClick={ () =>
|
|
76
|
-
navigator.goTo( backPath, { isBack: true } )
|
|
77
|
-
}
|
|
78
|
-
icon={ icon }
|
|
79
|
-
label={ __( 'Back' ) }
|
|
80
|
-
showTooltip={ false }
|
|
81
|
-
/>
|
|
82
|
-
) }
|
|
83
81
|
{ isRoot && (
|
|
84
82
|
<SidebarButton
|
|
85
83
|
icon={ icon }
|
|
@@ -23,10 +23,12 @@ import {
|
|
|
23
23
|
currentlyPreviewingTheme,
|
|
24
24
|
} from '../../utils/is-previewing-theme';
|
|
25
25
|
import { unlock } from '../../lock-unlock';
|
|
26
|
+
import { getPathFromURL } from '../sync-state-with-url/use-sync-path-with-url';
|
|
26
27
|
|
|
27
|
-
const { useHistory } = unlock( routerPrivateApis );
|
|
28
|
+
const { useLocation, useHistory } = unlock( routerPrivateApis );
|
|
28
29
|
|
|
29
30
|
export default function LeafMoreMenu( props ) {
|
|
31
|
+
const location = useLocation();
|
|
30
32
|
const history = useHistory();
|
|
31
33
|
const { block } = props;
|
|
32
34
|
const { clientId } = block;
|
|
@@ -63,22 +65,32 @@ export default function LeafMoreMenu( props ) {
|
|
|
63
65
|
attributes.type &&
|
|
64
66
|
history
|
|
65
67
|
) {
|
|
66
|
-
history.push(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
history.push(
|
|
69
|
+
{
|
|
70
|
+
postType: attributes.type,
|
|
71
|
+
postId: attributes.id,
|
|
72
|
+
...( isPreviewingTheme() && {
|
|
73
|
+
wp_theme_preview: currentlyPreviewingTheme(),
|
|
74
|
+
} ),
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
backPath: getPathFromURL( location.params ),
|
|
78
|
+
}
|
|
79
|
+
);
|
|
73
80
|
}
|
|
74
81
|
if ( name === 'core/page-list-item' && attributes.id && history ) {
|
|
75
|
-
history.push(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
history.push(
|
|
83
|
+
{
|
|
84
|
+
postType: 'page',
|
|
85
|
+
postId: attributes.id,
|
|
86
|
+
...( isPreviewingTheme() && {
|
|
87
|
+
wp_theme_preview: currentlyPreviewingTheme(),
|
|
88
|
+
} ),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
backPath: getPathFromURL( location.params ),
|
|
92
|
+
}
|
|
93
|
+
);
|
|
82
94
|
}
|
|
83
95
|
},
|
|
84
96
|
[ history ]
|
|
@@ -28,10 +28,15 @@ import { unlock } from '../../lock-unlock';
|
|
|
28
28
|
const { useHistory } = unlock( routerPrivateApis );
|
|
29
29
|
|
|
30
30
|
const PageItem = ( { postType = 'page', postId, ...props } ) => {
|
|
31
|
-
const linkInfo = useLink(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const linkInfo = useLink(
|
|
32
|
+
{
|
|
33
|
+
postType,
|
|
34
|
+
postId,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
backPath: '/page',
|
|
38
|
+
}
|
|
39
|
+
);
|
|
35
40
|
return <SidebarNavigationItem { ...linkInfo } { ...props } />;
|
|
36
41
|
};
|
|
37
42
|
|
|
@@ -12,19 +12,11 @@ export default function CategoryItem( {
|
|
|
12
12
|
label,
|
|
13
13
|
type,
|
|
14
14
|
} ) {
|
|
15
|
-
const linkInfo = useLink(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
// Keep a record of where we came from in state so we can
|
|
23
|
-
// use the browser's back button to go back to Patterns.
|
|
24
|
-
// See the implementation of the back button in patterns-list.
|
|
25
|
-
backPath: '/patterns',
|
|
26
|
-
}
|
|
27
|
-
);
|
|
15
|
+
const linkInfo = useLink( {
|
|
16
|
+
path: '/patterns',
|
|
17
|
+
categoryType: type,
|
|
18
|
+
categoryId: id,
|
|
19
|
+
} );
|
|
28
20
|
|
|
29
21
|
if ( ! count ) {
|
|
30
22
|
return;
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
__experimentalHeading as Heading,
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
import { useViewportMatch } from '@wordpress/compose';
|
|
13
|
-
import { useSelect } from '@wordpress/data';
|
|
14
13
|
import { getTemplatePartIcon } from '@wordpress/editor';
|
|
15
14
|
import { __ } from '@wordpress/i18n';
|
|
16
15
|
import { getQueryArgs } from '@wordpress/url';
|
|
@@ -24,7 +23,6 @@ import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
|
24
23
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
25
24
|
import CategoryItem from './category-item';
|
|
26
25
|
import { DEFAULT_CATEGORY, DEFAULT_TYPE } from '../page-patterns/utils';
|
|
27
|
-
import { store as editSiteStore } from '../../store';
|
|
28
26
|
import { useLink } from '../routes/link';
|
|
29
27
|
import usePatternCategories from './use-pattern-categories';
|
|
30
28
|
import useMyPatterns from './use-my-patterns';
|
|
@@ -106,11 +104,6 @@ export default function SidebarNavigationScreenPatterns() {
|
|
|
106
104
|
const { patternCategories, hasPatterns } = usePatternCategories();
|
|
107
105
|
const { myPatterns } = useMyPatterns();
|
|
108
106
|
|
|
109
|
-
const isTemplatePartsMode = useSelect( ( select ) => {
|
|
110
|
-
const settings = select( editSiteStore ).getSettings();
|
|
111
|
-
return !! settings.supportsTemplatePartsMode;
|
|
112
|
-
}, [] );
|
|
113
|
-
|
|
114
107
|
const templatePartsLink = useLink( { path: '/wp_template_part/all' } );
|
|
115
108
|
const footer = ! isMobileViewport ? (
|
|
116
109
|
<ItemGroup>
|
|
@@ -129,7 +122,6 @@ export default function SidebarNavigationScreenPatterns() {
|
|
|
129
122
|
|
|
130
123
|
return (
|
|
131
124
|
<SidebarNavigationScreen
|
|
132
|
-
isRoot={ isTemplatePartsMode }
|
|
133
125
|
title={ __( 'Patterns' ) }
|
|
134
126
|
description={ __(
|
|
135
127
|
'Manage what patterns are available when editing the site.'
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
} from '@wordpress/components';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
10
|
-
import { useSelect } from '@wordpress/data';
|
|
11
10
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
13
12
|
|
|
@@ -18,7 +17,6 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
18
17
|
import { useLink } from '../routes/link';
|
|
19
18
|
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
20
19
|
import AddNewTemplate from '../add-new-template';
|
|
21
|
-
import { store as editSiteStore } from '../../store';
|
|
22
20
|
import SidebarButton from '../sidebar-button';
|
|
23
21
|
|
|
24
22
|
const TemplateItem = ( { postType, postId, ...props } ) => {
|
|
@@ -31,11 +29,6 @@ const TemplateItem = ( { postType, postId, ...props } ) => {
|
|
|
31
29
|
|
|
32
30
|
export default function SidebarNavigationScreenTemplates() {
|
|
33
31
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
34
|
-
const isTemplatePartsMode = useSelect( ( select ) => {
|
|
35
|
-
const settings = select( editSiteStore ).getSettings();
|
|
36
|
-
|
|
37
|
-
return !! settings.supportsTemplatePartsMode;
|
|
38
|
-
}, [] );
|
|
39
32
|
|
|
40
33
|
const { records: templates, isResolving: isLoading } = useEntityRecords(
|
|
41
34
|
'postType',
|
|
@@ -51,10 +44,9 @@ export default function SidebarNavigationScreenTemplates() {
|
|
|
51
44
|
);
|
|
52
45
|
|
|
53
46
|
const browseAllLink = useLink( { path: '/wp_template/all' } );
|
|
54
|
-
const canCreate = ! isMobileViewport
|
|
47
|
+
const canCreate = ! isMobileViewport;
|
|
55
48
|
return (
|
|
56
49
|
<SidebarNavigationScreen
|
|
57
|
-
isRoot={ isTemplatePartsMode }
|
|
58
50
|
title={ __( 'Templates' ) }
|
|
59
51
|
description={ __(
|
|
60
52
|
'Express the layout of your site with templates'
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
5
6
|
import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
11
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
12
|
+
import { store as editSiteStore } from '../../store';
|
|
11
13
|
|
|
12
14
|
const config = {
|
|
13
15
|
wp_template: {
|
|
@@ -29,8 +31,16 @@ export default function SidebarNavigationScreenTemplatesBrowse() {
|
|
|
29
31
|
const {
|
|
30
32
|
params: { postType },
|
|
31
33
|
} = useNavigator();
|
|
34
|
+
|
|
35
|
+
const isTemplatePartsMode = useSelect( ( select ) => {
|
|
36
|
+
const settings = select( editSiteStore ).getSettings();
|
|
37
|
+
|
|
38
|
+
return !! settings.supportsTemplatePartsMode;
|
|
39
|
+
}, [] );
|
|
40
|
+
|
|
32
41
|
return (
|
|
33
42
|
<SidebarNavigationScreen
|
|
43
|
+
isRoot={ isTemplatePartsMode }
|
|
34
44
|
title={ config[ postType ].title }
|
|
35
45
|
description={ config[ postType ].description }
|
|
36
46
|
backPath={ config[ postType ].backPath }
|
|
@@ -58,10 +58,7 @@ export default function useSyncCanvasModeWithURL() {
|
|
|
58
58
|
|
|
59
59
|
useEffect( () => {
|
|
60
60
|
currentCanvasInUrl.current = canvasInUrl;
|
|
61
|
-
if (
|
|
62
|
-
canvasInUrl === undefined &&
|
|
63
|
-
currentCanvasMode.current !== 'view'
|
|
64
|
-
) {
|
|
61
|
+
if ( canvasInUrl !== 'edit' && currentCanvasMode.current !== 'view' ) {
|
|
65
62
|
setCanvasMode( 'view' );
|
|
66
63
|
} else if (
|
|
67
64
|
canvasInUrl === 'edit' &&
|
|
@@ -19,6 +19,7 @@ import { useCommandLoader } from '@wordpress/commands';
|
|
|
19
19
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
20
20
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
21
21
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
22
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Internal dependencies
|
|
@@ -137,8 +138,13 @@ function useManipulateDocumentCommands() {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
function useEditUICommands() {
|
|
140
|
-
const {
|
|
141
|
-
|
|
141
|
+
const {
|
|
142
|
+
openGeneralSidebar,
|
|
143
|
+
closeGeneralSidebar,
|
|
144
|
+
setIsInserterOpened,
|
|
145
|
+
setIsListViewOpened,
|
|
146
|
+
switchEditorMode,
|
|
147
|
+
} = useDispatch( editSiteStore );
|
|
142
148
|
const { canvasMode, editorMode, activeSidebar } = useSelect(
|
|
143
149
|
( select ) => ( {
|
|
144
150
|
canvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),
|
|
@@ -150,7 +156,9 @@ function useEditUICommands() {
|
|
|
150
156
|
[]
|
|
151
157
|
);
|
|
152
158
|
const { openModal } = useDispatch( interfaceStore );
|
|
153
|
-
const {
|
|
159
|
+
const { get: getPreference } = useSelect( preferencesStore );
|
|
160
|
+
const { set: setPreference, toggle } = useDispatch( preferencesStore );
|
|
161
|
+
const { createInfoNotice } = useDispatch( noticesStore );
|
|
154
162
|
|
|
155
163
|
if ( canvasMode !== 'edit' ) {
|
|
156
164
|
return { isLoading: false, commands: [] };
|
|
@@ -196,6 +204,29 @@ function useEditUICommands() {
|
|
|
196
204
|
},
|
|
197
205
|
} );
|
|
198
206
|
|
|
207
|
+
commands.push( {
|
|
208
|
+
name: 'core/toggle-distraction-free',
|
|
209
|
+
label: __( 'Toggle distraction free' ),
|
|
210
|
+
icon: cog,
|
|
211
|
+
callback: ( { close } ) => {
|
|
212
|
+
setPreference( 'core/edit-site', 'fixedToolbar', false );
|
|
213
|
+
setIsInserterOpened( false );
|
|
214
|
+
setIsListViewOpened( false );
|
|
215
|
+
closeGeneralSidebar();
|
|
216
|
+
toggle( 'core/edit-site', 'distractionFree' );
|
|
217
|
+
createInfoNotice(
|
|
218
|
+
getPreference( 'core/edit-site', 'distractionFree' )
|
|
219
|
+
? __( 'Distraction free mode turned on.' )
|
|
220
|
+
: __( 'Distraction free mode turned off.' ),
|
|
221
|
+
{
|
|
222
|
+
id: 'core/edit-site/distraction-free-mode/notice',
|
|
223
|
+
type: 'snackbar',
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
close();
|
|
227
|
+
},
|
|
228
|
+
} );
|
|
229
|
+
|
|
199
230
|
commands.push( {
|
|
200
231
|
name: 'core/toggle-top-toolbar',
|
|
201
232
|
label: __( 'Toggle top toolbar' ),
|
|
@@ -18,11 +18,15 @@ export const setCanvasMode =
|
|
|
18
18
|
mode,
|
|
19
19
|
} );
|
|
20
20
|
// Check if the block list view should be open by default.
|
|
21
|
+
// If `distractionFree` mode is enabled, the block list view should not be open.
|
|
21
22
|
if (
|
|
22
23
|
mode === 'edit' &&
|
|
23
24
|
registry
|
|
24
25
|
.select( preferencesStore )
|
|
25
|
-
.get( 'core/edit-site', 'showListViewByDefault' )
|
|
26
|
+
.get( 'core/edit-site', 'showListViewByDefault' ) &&
|
|
27
|
+
! registry
|
|
28
|
+
.select( preferencesStore )
|
|
29
|
+
.get( 'core/edit-site', 'distractionFree' )
|
|
26
30
|
) {
|
|
27
31
|
dispatch.setIsListViewOpened( true );
|
|
28
32
|
}
|