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' ;
7
+ import { __ , sprintf } from '@wordpress/i18n' ;
6
8
import { useViewportMatch } from '@wordpress/compose' ;
9
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts' ;
7
10
8
11
/**
9
12
* Internal dependencies
10
13
*/
14
+ import useRegisterShortcuts from './use-register-shortcuts' ;
11
15
import Header from './header' ;
12
16
import NavigationSidebar from '../navigation-sidebar' ;
13
17
import Table from './table' ;
14
18
15
19
export default function List ( { templateType } ) {
20
+ useRegisterShortcuts ( ) ;
16
21
const isDesktopViewport = useViewportMatch ( 'medium' ) ;
17
22
23
+ const { previousShortcut, nextShortcut } = useSelect ( ( select ) => {
24
+ return {
25
+ previousShortcut : select (
26
+ keyboardShortcutsStore
27
+ ) . getAllShortcutKeyCombinations ( 'core/edit-site/previous-region' ) ,
28
+ nextShortcut : select (
29
+ keyboardShortcutsStore
30
+ ) . getAllShortcutKeyCombinations ( 'core/edit-site/next-region' ) ,
31
+ } ;
32
+ } , [ ] ) ;
33
+
34
+ const postType = useSelect (
35
+ ( select ) => select ( coreStore ) . getPostType ( templateType ) ,
36
+ [ templateType ]
37
+ ) ;
38
+
39
+ // `postType` could load in asynchronously. Only provide the detailed region labels if
40
+ // the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
41
+ const itemsListLabel = postType ?. labels ?. items_list ;
42
+ const detailedRegionLabels = postType
43
+ ? {
44
+ header : sprintf (
45
+ // translators: %s - the name of the page, 'Header' as in the header area of that page.
46
+ __ ( '%s - Header' ) ,
47
+ itemsListLabel
48
+ ) ,
49
+ body : sprintf (
50
+ // translators: %s - the name of the page, 'Content' as in the content area of that page.
51
+ __ ( '%s - Content' ) ,
52
+ itemsListLabel
53
+ ) ,
54
+ }
55
+ : undefined ;
56
+
18
57
return (
19
58
< InterfaceSkeleton
20
59
className = "edit-site-list"
21
60
labels = { {
22
61
drawer : __ ( 'Navigation Sidebar' ) ,
62
+ ...detailedRegionLabels ,
23
63
} }
24
64
header = { < Header templateType = { templateType } /> }
25
65
drawer = {
@@ -33,6 +73,10 @@ export default function List( { templateType } ) {
33
73
< Table templateType = { templateType } />
34
74
</ main >
35
75
}
76
+ shortcuts = { {
77
+ previous : previousShortcut ,
78
+ next : nextShortcut ,
79
+ } }
36
80
/>
37
81
) ;
38
82
}
0 commit comments