@wordpress/edit-site 3.0.10 → 3.0.11
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/add-new-template/new-template-part.js +1 -2
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +1 -2
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/editor/index.js +12 -6
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +29 -6
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +5 -43
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +26 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/index.js +38 -6
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +1 -2
- package/build/components/list/table.js.map +1 -1
- package/build/components/list/use-register-shortcuts.js +52 -0
- package/build/components/list/use-register-shortcuts.js.map +1 -0
- package/build/components/navigation-sidebar/index.js +16 -2
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +7 -6
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/template-details/index.js +2 -2
- package/build/components/template-details/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +1 -2
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +1 -2
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/editor/index.js +13 -7
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +29 -7
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +6 -39
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +26 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/index.js +36 -7
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +1 -2
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/list/use-register-shortcuts.js +41 -0
- package/build-module/components/list/use-register-shortcuts.js.map +1 -0
- package/build-module/components/navigation-sidebar/index.js +16 -3
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +7 -6
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/template-details/index.js +2 -2
- package/build-module/components/template-details/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/add-new-template/new-template-part.js +1 -2
- package/src/components/add-new-template/new-template.js +1 -2
- package/src/components/editor/index.js +17 -6
- package/src/components/global-styles/color-palette-panel.js +64 -7
- package/src/components/global-styles/global-styles-provider.js +3 -33
- package/src/components/keyboard-shortcuts/index.js +32 -0
- package/src/components/list/index.js +46 -4
- package/src/components/list/table.js +1 -2
- package/src/components/list/use-register-shortcuts.js +45 -0
- package/src/components/navigation-sidebar/index.js +19 -3
- package/src/components/navigation-sidebar/navigation-panel/index.js +7 -6
- package/src/components/template-details/index.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,21 +29,21 @@
|
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
30
|
"@wordpress/a11y": "^3.2.4",
|
|
31
31
|
"@wordpress/api-fetch": "^5.2.6",
|
|
32
|
-
"@wordpress/block-editor": "^8.0.
|
|
33
|
-
"@wordpress/block-library": "^6.0.
|
|
32
|
+
"@wordpress/block-editor": "^8.0.5",
|
|
33
|
+
"@wordpress/block-library": "^6.0.9",
|
|
34
34
|
"@wordpress/blocks": "^11.1.4",
|
|
35
|
-
"@wordpress/components": "^19.0.
|
|
35
|
+
"@wordpress/components": "^19.0.5",
|
|
36
36
|
"@wordpress/compose": "^5.0.6",
|
|
37
37
|
"@wordpress/core-data": "^4.0.7",
|
|
38
38
|
"@wordpress/data": "^6.1.4",
|
|
39
39
|
"@wordpress/data-controls": "^2.2.7",
|
|
40
|
-
"@wordpress/editor": "^12.0.
|
|
40
|
+
"@wordpress/editor": "^12.0.8",
|
|
41
41
|
"@wordpress/element": "^4.0.4",
|
|
42
42
|
"@wordpress/hooks": "^3.2.2",
|
|
43
43
|
"@wordpress/html-entities": "^3.2.3",
|
|
44
44
|
"@wordpress/i18n": "^4.2.4",
|
|
45
45
|
"@wordpress/icons": "^6.1.1",
|
|
46
|
-
"@wordpress/interface": "^4.1.
|
|
46
|
+
"@wordpress/interface": "^4.1.7",
|
|
47
47
|
"@wordpress/keyboard-shortcuts": "^3.0.6",
|
|
48
48
|
"@wordpress/keycodes": "^3.2.4",
|
|
49
49
|
"@wordpress/media-utils": "^3.0.5",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "518e7a279a0f596612232c55c83a351460f8816d"
|
|
65
65
|
}
|
|
@@ -36,8 +36,7 @@ export default function NewTemplatePart( { postType } ) {
|
|
|
36
36
|
} );
|
|
37
37
|
|
|
38
38
|
// Navigate to the created template part editor.
|
|
39
|
-
window.location.
|
|
40
|
-
page: 'gutenberg-edit-site',
|
|
39
|
+
window.location.href = addQueryArgs( window.location.href, {
|
|
41
40
|
postId: templatePart.id,
|
|
42
41
|
postType: 'wp_template_part',
|
|
43
42
|
} );
|
|
@@ -58,8 +58,7 @@ export default function NewTemplate( { postType } ) {
|
|
|
58
58
|
} );
|
|
59
59
|
|
|
60
60
|
// Navigate to the created template editor.
|
|
61
|
-
window.location.
|
|
62
|
-
page: 'gutenberg-edit-site',
|
|
61
|
+
window.location.href = addQueryArgs( window.location.href, {
|
|
63
62
|
postId: template.id,
|
|
64
63
|
postType: 'wp_template',
|
|
65
64
|
} );
|
|
@@ -26,7 +26,10 @@ import {
|
|
|
26
26
|
} from '@wordpress/editor';
|
|
27
27
|
import { __ } from '@wordpress/i18n';
|
|
28
28
|
import { PluginArea } from '@wordpress/plugins';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
ShortcutProvider,
|
|
31
|
+
store as keyboardShortcutsStore,
|
|
32
|
+
} from '@wordpress/keyboard-shortcuts';
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
* Internal dependencies
|
|
@@ -62,6 +65,8 @@ function Editor( { initialSettings, onError } ) {
|
|
|
62
65
|
template,
|
|
63
66
|
templateResolved,
|
|
64
67
|
isNavigationOpen,
|
|
68
|
+
previousShortcut,
|
|
69
|
+
nextShortcut,
|
|
65
70
|
} = useSelect( ( select ) => {
|
|
66
71
|
const {
|
|
67
72
|
isInserterOpened,
|
|
@@ -98,6 +103,12 @@ function Editor( { initialSettings, onError } ) {
|
|
|
98
103
|
: false,
|
|
99
104
|
entityId: postId,
|
|
100
105
|
isNavigationOpen: isNavigationOpened(),
|
|
106
|
+
previousShortcut: select(
|
|
107
|
+
keyboardShortcutsStore
|
|
108
|
+
).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),
|
|
109
|
+
nextShortcut: select(
|
|
110
|
+
keyboardShortcutsStore
|
|
111
|
+
).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),
|
|
101
112
|
};
|
|
102
113
|
}, [] );
|
|
103
114
|
const { updateEditorSettings } = useDispatch( editorStore );
|
|
@@ -208,11 +219,7 @@ function Editor( { initialSettings, onError } ) {
|
|
|
208
219
|
<ComplementaryArea.Slot scope="core/edit-site" />
|
|
209
220
|
)
|
|
210
221
|
}
|
|
211
|
-
drawer={
|
|
212
|
-
<NavigationSidebar
|
|
213
|
-
defaultIsOpen={ false }
|
|
214
|
-
/>
|
|
215
|
-
}
|
|
222
|
+
drawer={ <NavigationSidebar /> }
|
|
216
223
|
header={
|
|
217
224
|
<Header
|
|
218
225
|
openEntitiesSavedStates={
|
|
@@ -282,6 +289,10 @@ function Editor( { initialSettings, onError } ) {
|
|
|
282
289
|
</>
|
|
283
290
|
}
|
|
284
291
|
footer={ <BlockBreadcrumb /> }
|
|
292
|
+
shortcuts={ {
|
|
293
|
+
previous: previousShortcut,
|
|
294
|
+
next: nextShortcut,
|
|
295
|
+
} }
|
|
285
296
|
/>
|
|
286
297
|
<WelcomeGuide />
|
|
287
298
|
<Popover.Slot />
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
__experimentalColorEdit as ColorEdit,
|
|
6
|
+
__experimentalVStack as VStack,
|
|
7
|
+
} from '@wordpress/components';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Internal dependencies
|
|
@@ -9,14 +13,67 @@ import { __experimentalColorEdit as ColorEdit } from '@wordpress/components';
|
|
|
9
13
|
import { useSetting } from './hooks';
|
|
10
14
|
|
|
11
15
|
export default function ColorPalettePanel( { name } ) {
|
|
12
|
-
const [
|
|
13
|
-
'color.palette',
|
|
16
|
+
const [ themeColors, setThemeColors ] = useSetting(
|
|
17
|
+
'color.palette.theme',
|
|
18
|
+
name
|
|
19
|
+
);
|
|
20
|
+
const [ baseThemeColors ] = useSetting(
|
|
21
|
+
'color.palette.theme',
|
|
22
|
+
name,
|
|
23
|
+
'base'
|
|
24
|
+
);
|
|
25
|
+
const [ defaultColors, setDefaultColors ] = useSetting(
|
|
26
|
+
'color.palette.default',
|
|
27
|
+
name
|
|
28
|
+
);
|
|
29
|
+
const [ baseDefaultColors ] = useSetting(
|
|
30
|
+
'color.palette.default',
|
|
14
31
|
name,
|
|
15
|
-
'
|
|
32
|
+
'base'
|
|
33
|
+
);
|
|
34
|
+
const [ customColors, setCustomColors ] = useSetting(
|
|
35
|
+
'color.palette.user',
|
|
36
|
+
name
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const [ defaultPaletteEnabled ] = useSetting(
|
|
40
|
+
'color.defaultPalette',
|
|
41
|
+
name
|
|
16
42
|
);
|
|
17
43
|
return (
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
44
|
+
<VStack
|
|
45
|
+
className="edit-site-global-styles-color-palette-panel"
|
|
46
|
+
spacing={ 10 }
|
|
47
|
+
>
|
|
48
|
+
{ !! themeColors && !! themeColors.length && (
|
|
49
|
+
<ColorEdit
|
|
50
|
+
canReset={ themeColors !== baseThemeColors }
|
|
51
|
+
canOnlyChangeValues
|
|
52
|
+
colors={ themeColors }
|
|
53
|
+
onChange={ setThemeColors }
|
|
54
|
+
paletteLabel={ __( 'Theme' ) }
|
|
55
|
+
/>
|
|
56
|
+
) }
|
|
57
|
+
{ !! defaultColors &&
|
|
58
|
+
!! defaultColors.length &&
|
|
59
|
+
!! defaultPaletteEnabled && (
|
|
60
|
+
<ColorEdit
|
|
61
|
+
canReset={ defaultColors !== baseDefaultColors }
|
|
62
|
+
canOnlyChangeValues
|
|
63
|
+
colors={ defaultColors }
|
|
64
|
+
onChange={ setDefaultColors }
|
|
65
|
+
paletteLabel={ __( 'Default' ) }
|
|
66
|
+
/>
|
|
67
|
+
) }
|
|
68
|
+
<ColorEdit
|
|
69
|
+
colors={ customColors }
|
|
70
|
+
onChange={ setCustomColors }
|
|
71
|
+
paletteLabel={ __( 'Custom' ) }
|
|
72
|
+
emptyMessage={ __(
|
|
73
|
+
'Custom colors are empty! Add some colors to create your own color palette.'
|
|
74
|
+
) }
|
|
75
|
+
slugPrefix="custom-"
|
|
76
|
+
/>
|
|
77
|
+
</VStack>
|
|
21
78
|
);
|
|
22
79
|
}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
get,
|
|
6
|
-
cloneDeep,
|
|
7
|
-
set,
|
|
8
5
|
mergeWith,
|
|
9
6
|
pickBy,
|
|
10
7
|
isEmpty,
|
|
@@ -23,7 +20,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
23
20
|
/**
|
|
24
21
|
* Internal dependencies
|
|
25
22
|
*/
|
|
26
|
-
import { PRESET_METADATA } from './utils';
|
|
27
23
|
import { GlobalStylesContext } from './context';
|
|
28
24
|
|
|
29
25
|
function mergeTreesCustomizer( _, srcValue ) {
|
|
@@ -39,29 +35,6 @@ function mergeBaseAndUserConfigs( base, user ) {
|
|
|
39
35
|
return mergeWith( {}, base, user, mergeTreesCustomizer );
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
function addUserOriginToSettings( settingsToAdd ) {
|
|
43
|
-
const newSettings = cloneDeep( settingsToAdd );
|
|
44
|
-
PRESET_METADATA.forEach( ( { path } ) => {
|
|
45
|
-
const presetData = get( newSettings, path );
|
|
46
|
-
if ( presetData ) {
|
|
47
|
-
set( newSettings, path, {
|
|
48
|
-
user: presetData,
|
|
49
|
-
} );
|
|
50
|
-
}
|
|
51
|
-
} );
|
|
52
|
-
return newSettings;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function removeUserOriginFromSettings( settingsToRemove ) {
|
|
56
|
-
const newSettings = cloneDeep( settingsToRemove );
|
|
57
|
-
PRESET_METADATA.forEach( ( { path } ) => {
|
|
58
|
-
const presetData = get( newSettings, path );
|
|
59
|
-
if ( presetData ) {
|
|
60
|
-
set( newSettings, path, ( presetData ?? {} ).user );
|
|
61
|
-
}
|
|
62
|
-
} );
|
|
63
|
-
return newSettings;
|
|
64
|
-
}
|
|
65
38
|
const cleanEmptyObject = ( object ) => {
|
|
66
39
|
if ( ! isObject( object ) || Array.isArray( object ) ) {
|
|
67
40
|
return object;
|
|
@@ -97,7 +70,7 @@ function useGlobalStylesUserConfig() {
|
|
|
97
70
|
|
|
98
71
|
const config = useMemo( () => {
|
|
99
72
|
return {
|
|
100
|
-
settings:
|
|
73
|
+
settings: settings ?? {},
|
|
101
74
|
styles: styles ?? {},
|
|
102
75
|
};
|
|
103
76
|
}, [ settings, styles ] );
|
|
@@ -111,15 +84,12 @@ function useGlobalStylesUserConfig() {
|
|
|
111
84
|
);
|
|
112
85
|
const currentConfig = {
|
|
113
86
|
styles: record?.styles ?? {},
|
|
114
|
-
settings:
|
|
87
|
+
settings: record?.settings ?? {},
|
|
115
88
|
};
|
|
116
89
|
const updatedConfig = callback( currentConfig );
|
|
117
90
|
editEntityRecord( 'root', 'globalStyles', globalStylesId, {
|
|
118
91
|
styles: cleanEmptyObject( updatedConfig.styles ) || {},
|
|
119
|
-
settings:
|
|
120
|
-
cleanEmptyObject(
|
|
121
|
-
removeUserOriginFromSettings( updatedConfig.settings )
|
|
122
|
-
) || {},
|
|
92
|
+
settings: cleanEmptyObject( updatedConfig.settings ) || {},
|
|
123
93
|
} );
|
|
124
94
|
},
|
|
125
95
|
[ globalStylesId ]
|
|
@@ -136,6 +136,38 @@ function KeyboardShortcutsRegister() {
|
|
|
136
136
|
character: ',',
|
|
137
137
|
},
|
|
138
138
|
} );
|
|
139
|
+
|
|
140
|
+
registerShortcut( {
|
|
141
|
+
name: 'core/edit-site/next-region',
|
|
142
|
+
category: 'global',
|
|
143
|
+
description: __( 'Navigate to the next part of the editor.' ),
|
|
144
|
+
keyCombination: {
|
|
145
|
+
modifier: 'ctrl',
|
|
146
|
+
character: '`',
|
|
147
|
+
},
|
|
148
|
+
aliases: [
|
|
149
|
+
{
|
|
150
|
+
modifier: 'access',
|
|
151
|
+
character: 'n',
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
registerShortcut( {
|
|
157
|
+
name: 'core/edit-site/previous-region',
|
|
158
|
+
category: 'global',
|
|
159
|
+
description: __( 'Navigate to the previous part of the editor.' ),
|
|
160
|
+
keyCombination: {
|
|
161
|
+
modifier: 'ctrlShift',
|
|
162
|
+
character: '`',
|
|
163
|
+
},
|
|
164
|
+
aliases: [
|
|
165
|
+
{
|
|
166
|
+
modifier: 'access',
|
|
167
|
+
character: 'p',
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
} );
|
|
139
171
|
}, [ registerShortcut ] );
|
|
140
172
|
|
|
141
173
|
return null;
|
|
@@ -1,31 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
4
6
|
import { InterfaceSkeleton } from '@wordpress/interface';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Internal dependencies
|
|
10
12
|
*/
|
|
13
|
+
import useRegisterShortcuts from './use-register-shortcuts';
|
|
11
14
|
import Header from './header';
|
|
12
15
|
import NavigationSidebar from '../navigation-sidebar';
|
|
13
16
|
import Table from './table';
|
|
14
17
|
|
|
15
18
|
export default function List( { templateType } ) {
|
|
16
|
-
|
|
19
|
+
useRegisterShortcuts();
|
|
20
|
+
|
|
21
|
+
const { previousShortcut, nextShortcut } = useSelect( ( select ) => {
|
|
22
|
+
return {
|
|
23
|
+
previousShortcut: select(
|
|
24
|
+
keyboardShortcutsStore
|
|
25
|
+
).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),
|
|
26
|
+
nextShortcut: select(
|
|
27
|
+
keyboardShortcutsStore
|
|
28
|
+
).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),
|
|
29
|
+
};
|
|
30
|
+
}, [] );
|
|
31
|
+
|
|
32
|
+
const postType = useSelect(
|
|
33
|
+
( select ) => select( coreStore ).getPostType( templateType ),
|
|
34
|
+
[ templateType ]
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// `postType` could load in asynchronously. Only provide the detailed region labels if
|
|
38
|
+
// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
|
|
39
|
+
const itemsListLabel = postType?.labels?.items_list;
|
|
40
|
+
const detailedRegionLabels = postType
|
|
41
|
+
? {
|
|
42
|
+
header: sprintf(
|
|
43
|
+
// translators: %s - the name of the page, 'Header' as in the header area of that page.
|
|
44
|
+
__( '%s - Header' ),
|
|
45
|
+
itemsListLabel
|
|
46
|
+
),
|
|
47
|
+
body: sprintf(
|
|
48
|
+
// translators: %s - the name of the page, 'Content' as in the content area of that page.
|
|
49
|
+
__( '%s - Content' ),
|
|
50
|
+
itemsListLabel
|
|
51
|
+
),
|
|
52
|
+
}
|
|
53
|
+
: undefined;
|
|
17
54
|
|
|
18
55
|
return (
|
|
19
56
|
<InterfaceSkeleton
|
|
20
57
|
className="edit-site-list"
|
|
21
58
|
labels={ {
|
|
22
59
|
drawer: __( 'Navigation Sidebar' ),
|
|
60
|
+
...detailedRegionLabels,
|
|
23
61
|
} }
|
|
24
62
|
header={ <Header templateType={ templateType } /> }
|
|
25
63
|
drawer={
|
|
26
64
|
<NavigationSidebar
|
|
27
|
-
defaultIsOpen={ isDesktopViewport }
|
|
28
65
|
activeTemplateType={ templateType }
|
|
66
|
+
isDefaultOpen
|
|
29
67
|
/>
|
|
30
68
|
}
|
|
31
69
|
content={
|
|
@@ -33,6 +71,10 @@ export default function List( { templateType } ) {
|
|
|
33
71
|
<Table templateType={ templateType } />
|
|
34
72
|
</main>
|
|
35
73
|
}
|
|
74
|
+
shortcuts={ {
|
|
75
|
+
previous: previousShortcut,
|
|
76
|
+
next: nextShortcut,
|
|
77
|
+
} }
|
|
36
78
|
/>
|
|
37
79
|
);
|
|
38
80
|
}
|
|
@@ -95,8 +95,7 @@ export default function Table( { templateType } ) {
|
|
|
95
95
|
<HStack className="edit-site-list-table-row">
|
|
96
96
|
<FlexItem className="edit-site-list-table-column">
|
|
97
97
|
<a
|
|
98
|
-
href={ addQueryArgs(
|
|
99
|
-
page: 'gutenberg-edit-site',
|
|
98
|
+
href={ addQueryArgs( window.location.href, {
|
|
100
99
|
postId: template.id,
|
|
101
100
|
postType: template.type,
|
|
102
101
|
} ) }
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
|
+
import { useEffect } from '@wordpress/element';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
9
|
+
|
|
10
|
+
export default function useRegisterShortcuts() {
|
|
11
|
+
const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
|
12
|
+
useEffect( () => {
|
|
13
|
+
registerShortcut( {
|
|
14
|
+
name: 'core/edit-site/next-region',
|
|
15
|
+
category: 'global',
|
|
16
|
+
description: __( 'Navigate to the next part of the editor.' ),
|
|
17
|
+
keyCombination: {
|
|
18
|
+
modifier: 'ctrl',
|
|
19
|
+
character: '`',
|
|
20
|
+
},
|
|
21
|
+
aliases: [
|
|
22
|
+
{
|
|
23
|
+
modifier: 'access',
|
|
24
|
+
character: 'n',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
registerShortcut( {
|
|
30
|
+
name: 'core/edit-site/previous-region',
|
|
31
|
+
category: 'global',
|
|
32
|
+
description: __( 'Navigate to the previous part of the editor.' ),
|
|
33
|
+
keyCombination: {
|
|
34
|
+
modifier: 'ctrlShift',
|
|
35
|
+
character: '`',
|
|
36
|
+
},
|
|
37
|
+
aliases: [
|
|
38
|
+
{
|
|
39
|
+
modifier: 'access',
|
|
40
|
+
character: 'p',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
} );
|
|
44
|
+
}, [] );
|
|
45
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useState } from '@wordpress/element';
|
|
4
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
5
5
|
import { createSlotFill } from '@wordpress/components';
|
|
6
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -16,10 +17,25 @@ export const {
|
|
|
16
17
|
} = createSlotFill( 'EditSiteNavigationPanelPreview' );
|
|
17
18
|
|
|
18
19
|
export default function NavigationSidebar( {
|
|
19
|
-
|
|
20
|
+
isDefaultOpen = false,
|
|
20
21
|
activeTemplateType,
|
|
21
22
|
} ) {
|
|
22
|
-
const
|
|
23
|
+
const isDesktopViewport = useViewportMatch( 'medium' );
|
|
24
|
+
const [ isNavigationOpen, setIsNavigationOpen ] = useState(
|
|
25
|
+
isDefaultOpen && isDesktopViewport
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
useEffect( () => {
|
|
29
|
+
// When transitioning to desktop open the navigation if `isDefaultOpen` is true.
|
|
30
|
+
if ( isDefaultOpen && isDesktopViewport ) {
|
|
31
|
+
setIsNavigationOpen( true );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// When transitioning to mobile/tablet, close the navigation.
|
|
35
|
+
if ( ! isDesktopViewport ) {
|
|
36
|
+
setIsNavigationOpen( false );
|
|
37
|
+
}
|
|
38
|
+
}, [ isDefaultOpen, isDesktopViewport ] );
|
|
23
39
|
|
|
24
40
|
return (
|
|
25
41
|
<>
|
|
@@ -82,23 +82,24 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
82
82
|
<NavigationGroup title={ __( 'Editor' ) }>
|
|
83
83
|
<NavigationItem
|
|
84
84
|
title={ __( 'Site' ) }
|
|
85
|
-
href={ addQueryArgs(
|
|
86
|
-
|
|
85
|
+
href={ addQueryArgs( window.location.href, {
|
|
86
|
+
postId: undefined,
|
|
87
|
+
postType: undefined,
|
|
87
88
|
} ) }
|
|
88
89
|
/>
|
|
89
90
|
<NavigationItem
|
|
90
91
|
title={ __( 'Templates' ) }
|
|
91
92
|
item="wp_template"
|
|
92
|
-
href={ addQueryArgs(
|
|
93
|
-
|
|
93
|
+
href={ addQueryArgs( window.location.href, {
|
|
94
|
+
postId: undefined,
|
|
94
95
|
postType: 'wp_template',
|
|
95
96
|
} ) }
|
|
96
97
|
/>
|
|
97
98
|
<NavigationItem
|
|
98
99
|
title={ __( 'Template Parts' ) }
|
|
99
100
|
item="wp_template_part"
|
|
100
|
-
href={ addQueryArgs(
|
|
101
|
-
|
|
101
|
+
href={ addQueryArgs( window.location.href, {
|
|
102
|
+
postId: undefined,
|
|
102
103
|
postType: 'wp_template_part',
|
|
103
104
|
} ) }
|
|
104
105
|
/>
|
|
@@ -90,9 +90,9 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
90
90
|
|
|
91
91
|
<Button
|
|
92
92
|
className="edit-site-template-details__show-all-button"
|
|
93
|
-
href={ addQueryArgs(
|
|
94
|
-
page: 'gutenberg-edit-site',
|
|
93
|
+
href={ addQueryArgs( window.location.href, {
|
|
95
94
|
// TODO: We should update this to filter by template part's areas as well.
|
|
95
|
+
postId: undefined,
|
|
96
96
|
postType: template.type,
|
|
97
97
|
} ) }
|
|
98
98
|
>
|