@wordpress/edit-site 3.0.10 → 3.0.14
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 +34 -18
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +41 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +3 -1
- package/build/components/block-editor/index.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/global-styles/gradients-palette-panel.js +71 -0
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +5 -5
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +3 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +23 -3
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +3 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +3 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +54 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +74 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +28 -8
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +12 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +2 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.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/actions/index.js +104 -0
- package/build/components/list/actions/index.js.map +1 -0
- package/build/components/list/actions/rename-menu-item.js +112 -0
- package/build/components/list/actions/rename-menu-item.js.map +1 -0
- package/build/components/list/added-by.js +180 -0
- package/build/components/list/added-by.js.map +1 -0
- package/build/components/list/index.js +54 -7
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +58 -68
- 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 +24 -9
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +35 -17
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +14 -5
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +33 -0
- package/build/components/template-details/edit-template-title.js.map +1 -0
- package/build/components/template-details/index.js +8 -4
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/store/actions.js +47 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +25 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +30 -17
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +40 -24
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -1
- package/build-module/components/block-editor/index.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/global-styles/gradients-palette-panel.js +60 -0
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +5 -5
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +12 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +3 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +22 -3
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +3 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +3 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +41 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +70 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +28 -8
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +11 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.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/actions/index.js +85 -0
- package/build-module/components/list/actions/index.js.map +1 -0
- package/build-module/components/list/actions/rename-menu-item.js +101 -0
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
- package/build-module/components/list/added-by.js +166 -0
- package/build-module/components/list/added-by.js.map +1 -0
- package/build-module/components/list/index.js +49 -8
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +60 -70
- 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 +22 -10
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +33 -18
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +14 -6
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +23 -0
- package/build-module/components/template-details/edit-template-title.js.map +1 -0
- package/build-module/components/template-details/index.js +7 -4
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/index.js +8 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +48 -19
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +21 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +146 -21
- package/build-style/style.css +146 -21
- package/package.json +10 -8
- package/src/components/add-new-template/new-template-part.js +32 -18
- package/src/components/add-new-template/new-template.js +39 -20
- package/src/components/block-editor/index.js +2 -0
- 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/global-styles/gradients-palette-panel.js +99 -0
- package/src/components/global-styles/hooks.js +4 -4
- package/src/components/global-styles/palette.js +30 -10
- package/src/components/global-styles/screen-background-color.js +2 -0
- package/src/components/global-styles/screen-color-palette.js +30 -3
- package/src/components/global-styles/screen-link-color.js +2 -0
- package/src/components/global-styles/screen-text-color.js +2 -0
- package/src/components/global-styles/screen-typography-element.js +39 -0
- package/src/components/global-styles/screen-typography.js +84 -3
- package/src/components/global-styles/style.scss +45 -6
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/test/utils.js +1 -1
- package/src/components/global-styles/typography-panel.js +37 -7
- package/src/components/global-styles/ui.js +9 -0
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +32 -0
- package/src/components/list/actions/index.js +95 -0
- package/src/components/list/actions/rename-menu-item.js +134 -0
- package/src/components/list/added-by.js +179 -0
- package/src/components/list/index.js +63 -5
- package/src/components/list/style.scss +106 -11
- package/src/components/list/table.js +65 -76
- package/src/components/list/use-register-shortcuts.js +45 -0
- package/src/components/navigation-sidebar/index.js +21 -12
- package/src/components/navigation-sidebar/navigation-panel/index.js +32 -15
- package/src/components/navigation-sidebar/navigation-toggle/index.js +29 -17
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
- package/src/components/sidebar/style.scss +2 -1
- package/src/components/template-details/edit-template-title.js +28 -0
- package/src/components/template-details/index.js +15 -10
- package/src/components/template-details/template-areas.js +1 -1
- package/src/index.js +10 -2
- package/src/store/actions.js +82 -34
- package/src/store/selectors.js +22 -4
- package/src/store/test/actions.js +0 -24
- package/src/store/test/selectors.js +24 -0
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useSelect
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as coreStore } from '@wordpress/core-data';
|
|
6
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
7
7
|
import {
|
|
8
8
|
VisuallyHidden,
|
|
9
|
-
FlexItem,
|
|
10
|
-
__experimentalHStack as HStack,
|
|
11
9
|
__experimentalHeading as Heading,
|
|
12
|
-
DropdownMenu,
|
|
13
|
-
MenuGroup,
|
|
14
|
-
MenuItem,
|
|
15
10
|
} from '@wordpress/components';
|
|
16
|
-
import { moreVertical } from '@wordpress/icons';
|
|
17
11
|
import { addQueryArgs } from '@wordpress/url';
|
|
18
12
|
|
|
19
13
|
/**
|
|
20
14
|
* Internal dependencies
|
|
21
15
|
*/
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
function Actions( { template, onClose } ) {
|
|
26
|
-
const { removeTemplate } = useDispatch( editSiteStore );
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<MenuGroup>
|
|
30
|
-
<MenuItem
|
|
31
|
-
onClick={ () => {
|
|
32
|
-
removeTemplate( template );
|
|
33
|
-
onClose();
|
|
34
|
-
} }
|
|
35
|
-
>
|
|
36
|
-
{ __( 'Remove template' ) }
|
|
37
|
-
</MenuItem>
|
|
38
|
-
</MenuGroup>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
16
|
+
import Actions from './actions';
|
|
17
|
+
import AddedBy from './added-by';
|
|
41
18
|
|
|
42
19
|
export default function Table( { templateType } ) {
|
|
43
20
|
const { templates, isLoading, postType } = useSelect(
|
|
@@ -49,10 +26,13 @@ export default function Table( { templateType } ) {
|
|
|
49
26
|
} = select( coreStore );
|
|
50
27
|
|
|
51
28
|
return {
|
|
52
|
-
templates: getEntityRecords( 'postType', templateType
|
|
29
|
+
templates: getEntityRecords( 'postType', templateType, {
|
|
30
|
+
per_page: -1,
|
|
31
|
+
} ),
|
|
53
32
|
isLoading: ! hasFinishedResolution( 'getEntityRecords', [
|
|
54
33
|
'postType',
|
|
55
34
|
templateType,
|
|
35
|
+
{ per_page: -1 },
|
|
56
36
|
] ),
|
|
57
37
|
postType: getPostType( templateType ),
|
|
58
38
|
};
|
|
@@ -77,57 +57,66 @@ export default function Table( { templateType } ) {
|
|
|
77
57
|
}
|
|
78
58
|
|
|
79
59
|
return (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
60
|
+
// These explicit aria roles are needed for Safari.
|
|
61
|
+
// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
|
|
62
|
+
<table className="edit-site-list-table" role="table">
|
|
63
|
+
<thead>
|
|
64
|
+
<tr className="edit-site-list-table-head" role="row">
|
|
65
|
+
<th
|
|
66
|
+
className="edit-site-list-table-column"
|
|
67
|
+
role="columnheader"
|
|
68
|
+
>
|
|
69
|
+
{ __( 'Template' ) }
|
|
70
|
+
</th>
|
|
71
|
+
<th
|
|
72
|
+
className="edit-site-list-table-column"
|
|
73
|
+
role="columnheader"
|
|
74
|
+
>
|
|
75
|
+
{ __( 'Added by' ) }
|
|
76
|
+
</th>
|
|
77
|
+
<th
|
|
78
|
+
className="edit-site-list-table-column"
|
|
79
|
+
role="columnheader"
|
|
80
|
+
>
|
|
81
|
+
<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>
|
|
82
|
+
</th>
|
|
83
|
+
</tr>
|
|
84
|
+
</thead>
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
<tbody>
|
|
87
|
+
{ templates.map( ( template ) => (
|
|
88
|
+
<tr
|
|
89
|
+
key={ template.id }
|
|
90
|
+
className="edit-site-list-table-row"
|
|
91
|
+
role="row"
|
|
92
|
+
>
|
|
93
|
+
<td className="edit-site-list-table-column" role="cell">
|
|
94
|
+
<Heading level={ 4 }>
|
|
95
|
+
<a
|
|
96
|
+
href={ addQueryArgs( window.location.href, {
|
|
97
|
+
postId: template.id,
|
|
98
|
+
postType: template.type,
|
|
99
|
+
} ) }
|
|
100
|
+
>
|
|
101
|
+
{ template.title?.rendered ||
|
|
102
|
+
template.slug }
|
|
103
|
+
</a>
|
|
104
|
+
</Heading>
|
|
106
105
|
{ template.description }
|
|
107
|
-
</
|
|
106
|
+
</td>
|
|
108
107
|
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
onClose={ onClose }
|
|
123
|
-
/>
|
|
124
|
-
) }
|
|
125
|
-
</DropdownMenu>
|
|
126
|
-
) }
|
|
127
|
-
</FlexItem>
|
|
128
|
-
</HStack>
|
|
129
|
-
</li>
|
|
130
|
-
) ) }
|
|
131
|
-
</ul>
|
|
108
|
+
<td className="edit-site-list-table-column" role="cell">
|
|
109
|
+
<AddedBy
|
|
110
|
+
templateType={ templateType }
|
|
111
|
+
template={ template }
|
|
112
|
+
/>
|
|
113
|
+
</td>
|
|
114
|
+
<td className="edit-site-list-table-column" role="cell">
|
|
115
|
+
<Actions template={ template } />
|
|
116
|
+
</td>
|
|
117
|
+
</tr>
|
|
118
|
+
) ) }
|
|
119
|
+
</tbody>
|
|
120
|
+
</table>
|
|
132
121
|
);
|
|
133
122
|
}
|
|
@@ -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,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useEffect } from '@wordpress/element';
|
|
5
5
|
import { createSlotFill } from '@wordpress/components';
|
|
6
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Internal dependencies
|
|
9
11
|
*/
|
|
12
|
+
import { store as editSiteStore } from '../../store';
|
|
10
13
|
import NavigationPanel from './navigation-panel';
|
|
11
14
|
import NavigationToggle from './navigation-toggle';
|
|
12
15
|
|
|
@@ -16,22 +19,28 @@ export const {
|
|
|
16
19
|
} = createSlotFill( 'EditSiteNavigationPanelPreview' );
|
|
17
20
|
|
|
18
21
|
export default function NavigationSidebar( {
|
|
19
|
-
|
|
22
|
+
isDefaultOpen = false,
|
|
20
23
|
activeTemplateType,
|
|
21
24
|
} ) {
|
|
22
|
-
const
|
|
25
|
+
const isDesktopViewport = useViewportMatch( 'medium' );
|
|
26
|
+
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
27
|
+
|
|
28
|
+
useEffect( () => {
|
|
29
|
+
// When transitioning to desktop open the navigation if `isDefaultOpen` is true.
|
|
30
|
+
if ( isDefaultOpen && isDesktopViewport ) {
|
|
31
|
+
setIsNavigationPanelOpened( true );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// When transitioning to mobile/tablet, close the navigation.
|
|
35
|
+
if ( ! isDesktopViewport ) {
|
|
36
|
+
setIsNavigationPanelOpened( false );
|
|
37
|
+
}
|
|
38
|
+
}, [ isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened ] );
|
|
23
39
|
|
|
24
40
|
return (
|
|
25
41
|
<>
|
|
26
|
-
<NavigationToggle
|
|
27
|
-
|
|
28
|
-
setIsOpen={ setIsNavigationOpen }
|
|
29
|
-
/>
|
|
30
|
-
<NavigationPanel
|
|
31
|
-
isOpen={ isNavigationOpen }
|
|
32
|
-
setIsOpen={ setIsNavigationOpen }
|
|
33
|
-
activeTemplateType={ activeTemplateType }
|
|
34
|
-
/>
|
|
42
|
+
<NavigationToggle />
|
|
43
|
+
<NavigationPanel activeItem={ activeTemplateType } />
|
|
35
44
|
<NavigationPanelPreviewSlot />
|
|
36
45
|
</>
|
|
37
46
|
);
|
|
@@ -14,41 +14,53 @@ import {
|
|
|
14
14
|
__experimentalNavigationMenu as NavigationMenu,
|
|
15
15
|
} from '@wordpress/components';
|
|
16
16
|
import { store as coreDataStore } from '@wordpress/core-data';
|
|
17
|
-
import { useSelect } from '@wordpress/data';
|
|
17
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
18
|
import { useEffect, useRef } from '@wordpress/element';
|
|
19
19
|
import { __ } from '@wordpress/i18n';
|
|
20
20
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
21
21
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
22
22
|
import { addQueryArgs } from '@wordpress/url';
|
|
23
|
+
import {
|
|
24
|
+
home as siteIcon,
|
|
25
|
+
layout as templateIcon,
|
|
26
|
+
symbolFilled as templatePartIcon,
|
|
27
|
+
} from '@wordpress/icons';
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
30
|
* Internal dependencies
|
|
26
31
|
*/
|
|
27
32
|
import MainDashboardButton from '../../main-dashboard-button';
|
|
33
|
+
import { store as editSiteStore } from '../../../store';
|
|
34
|
+
|
|
35
|
+
const SITE_EDITOR_KEY = 'site-editor';
|
|
28
36
|
|
|
29
|
-
const NavigationPanel = ( {
|
|
30
|
-
const siteTitle = useSelect( ( select ) => {
|
|
37
|
+
const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
38
|
+
const { isNavigationOpen, siteTitle } = useSelect( ( select ) => {
|
|
31
39
|
const { getEntityRecord } = select( coreDataStore );
|
|
32
40
|
|
|
33
41
|
const siteData =
|
|
34
42
|
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
|
|
35
43
|
|
|
36
|
-
return
|
|
44
|
+
return {
|
|
45
|
+
siteTitle: siteData.name,
|
|
46
|
+
isNavigationOpen: select( editSiteStore ).isNavigationOpened(),
|
|
47
|
+
};
|
|
37
48
|
}, [] );
|
|
49
|
+
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
38
50
|
|
|
39
51
|
// Ensures focus is moved to the panel area when it is activated
|
|
40
52
|
// from a separate component (such as document actions in the header).
|
|
41
53
|
const panelRef = useRef();
|
|
42
54
|
useEffect( () => {
|
|
43
|
-
if (
|
|
55
|
+
if ( isNavigationOpen ) {
|
|
44
56
|
panelRef.current.focus();
|
|
45
57
|
}
|
|
46
|
-
}, [
|
|
58
|
+
}, [ activeItem, isNavigationOpen ] );
|
|
47
59
|
|
|
48
60
|
const closeOnEscape = ( event ) => {
|
|
49
61
|
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
50
62
|
event.preventDefault();
|
|
51
|
-
|
|
63
|
+
setIsNavigationPanelOpened( false );
|
|
52
64
|
}
|
|
53
65
|
};
|
|
54
66
|
|
|
@@ -56,7 +68,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
56
68
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
57
69
|
<div
|
|
58
70
|
className={ classnames( `edit-site-navigation-panel`, {
|
|
59
|
-
'is-open':
|
|
71
|
+
'is-open': isNavigationOpen,
|
|
60
72
|
} ) }
|
|
61
73
|
ref={ panelRef }
|
|
62
74
|
tabIndex="-1"
|
|
@@ -69,7 +81,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
69
81
|
</div>
|
|
70
82
|
</div>
|
|
71
83
|
<div className="edit-site-navigation-panel__scroll-container">
|
|
72
|
-
<Navigation activeItem={
|
|
84
|
+
<Navigation activeItem={ activeItem }>
|
|
73
85
|
<MainDashboardButton.Slot>
|
|
74
86
|
<NavigationBackButton
|
|
75
87
|
backButtonLabel={ __( 'Dashboard' ) }
|
|
@@ -81,24 +93,29 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
81
93
|
<NavigationMenu>
|
|
82
94
|
<NavigationGroup title={ __( 'Editor' ) }>
|
|
83
95
|
<NavigationItem
|
|
96
|
+
icon={ siteIcon }
|
|
84
97
|
title={ __( 'Site' ) }
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
item={ SITE_EDITOR_KEY }
|
|
99
|
+
href={ addQueryArgs( window.location.href, {
|
|
100
|
+
postId: undefined,
|
|
101
|
+
postType: undefined,
|
|
87
102
|
} ) }
|
|
88
103
|
/>
|
|
89
104
|
<NavigationItem
|
|
105
|
+
icon={ templateIcon }
|
|
90
106
|
title={ __( 'Templates' ) }
|
|
91
107
|
item="wp_template"
|
|
92
|
-
href={ addQueryArgs(
|
|
93
|
-
|
|
108
|
+
href={ addQueryArgs( window.location.href, {
|
|
109
|
+
postId: undefined,
|
|
94
110
|
postType: 'wp_template',
|
|
95
111
|
} ) }
|
|
96
112
|
/>
|
|
97
113
|
<NavigationItem
|
|
114
|
+
icon={ templatePartIcon }
|
|
98
115
|
title={ __( 'Template Parts' ) }
|
|
99
116
|
item="wp_template_part"
|
|
100
|
-
href={ addQueryArgs(
|
|
101
|
-
|
|
117
|
+
href={ addQueryArgs( window.location.href, {
|
|
118
|
+
postId: undefined,
|
|
102
119
|
postType: 'wp_template_part',
|
|
103
120
|
} ) }
|
|
104
121
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
5
|
import {
|
|
6
6
|
Button,
|
|
7
7
|
Icon,
|
|
@@ -12,25 +12,36 @@ import { wordpress } from '@wordpress/icons';
|
|
|
12
12
|
import { store as coreDataStore } from '@wordpress/core-data';
|
|
13
13
|
import { useReducedMotion } from '@wordpress/compose';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { store as editSiteStore } from '../../../store';
|
|
19
|
+
|
|
20
|
+
function NavigationToggle( { icon } ) {
|
|
21
|
+
const { isNavigationOpen, isRequestingSiteIcon, siteIconUrl } = useSelect(
|
|
22
|
+
( select ) => {
|
|
23
|
+
const { getEntityRecord, isResolving } = select( coreDataStore );
|
|
24
|
+
const siteData =
|
|
25
|
+
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return {
|
|
28
|
+
isNavigationOpen: select( editSiteStore ).isNavigationOpened(),
|
|
29
|
+
isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [
|
|
30
|
+
'root',
|
|
31
|
+
'__unstableBase',
|
|
32
|
+
undefined,
|
|
33
|
+
] ),
|
|
34
|
+
siteIconUrl: siteData.site_icon_url,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
39
|
+
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
30
40
|
|
|
31
41
|
const disableMotion = useReducedMotion();
|
|
32
42
|
|
|
33
|
-
const toggleNavigationPanel = () =>
|
|
43
|
+
const toggleNavigationPanel = () =>
|
|
44
|
+
setIsNavigationPanelOpened( ! isNavigationOpen );
|
|
34
45
|
|
|
35
46
|
let buttonIcon = <Icon size="36px" icon={ wordpress } />;
|
|
36
47
|
|
|
@@ -60,7 +71,8 @@ function NavigationToggle( { icon, isOpen, setIsOpen } ) {
|
|
|
60
71
|
return (
|
|
61
72
|
<motion.div
|
|
62
73
|
className={
|
|
63
|
-
'edit-site-navigation-toggle' +
|
|
74
|
+
'edit-site-navigation-toggle' +
|
|
75
|
+
( isNavigationOpen ? ' is-open' : '' )
|
|
64
76
|
}
|
|
65
77
|
whileHover="expand"
|
|
66
78
|
>
|
|
@@ -34,6 +34,7 @@ describe( 'NavigationToggle', () => {
|
|
|
34
34
|
site_icon_url: 'https://fakeUrl.com',
|
|
35
35
|
} ),
|
|
36
36
|
isResolving: () => false,
|
|
37
|
+
isNavigationOpened: () => false,
|
|
37
38
|
} ) );
|
|
38
39
|
} );
|
|
39
40
|
|
|
@@ -53,6 +54,7 @@ describe( 'NavigationToggle', () => {
|
|
|
53
54
|
site_icon_url: '',
|
|
54
55
|
} ),
|
|
55
56
|
isResolving: () => false,
|
|
57
|
+
isNavigationOpened: () => false,
|
|
56
58
|
} ) );
|
|
57
59
|
} );
|
|
58
60
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { TextControl } from '@wordpress/components';
|
|
6
|
+
import { useEntityProp } from '@wordpress/core-data';
|
|
7
|
+
|
|
8
|
+
export default function EditTemplateTitle( { template } ) {
|
|
9
|
+
const [ title, setTitle ] = useEntityProp(
|
|
10
|
+
'postType',
|
|
11
|
+
template.type,
|
|
12
|
+
'title',
|
|
13
|
+
template.id
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<TextControl
|
|
18
|
+
label={ __( 'Title' ) }
|
|
19
|
+
value={ title }
|
|
20
|
+
help={ __(
|
|
21
|
+
'Give the template a title that indicates its purpose, e.g. "Full Width".'
|
|
22
|
+
) }
|
|
23
|
+
onChange={ ( newTitle ) => {
|
|
24
|
+
setTitle( newTitle || template.slug );
|
|
25
|
+
} }
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from '../navigation-sidebar/navigation-panel/constants';
|
|
25
25
|
import { store as editSiteStore } from '../../store';
|
|
26
26
|
import TemplateAreas from './template-areas';
|
|
27
|
+
import EditTemplateTitle from './edit-template-title';
|
|
27
28
|
|
|
28
29
|
export default function TemplateDetails( { template, onClose } ) {
|
|
29
30
|
const { title, description } = useSelect(
|
|
@@ -55,13 +56,17 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
55
56
|
return (
|
|
56
57
|
<div className="edit-site-template-details">
|
|
57
58
|
<div className="edit-site-template-details__group">
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
{ template.is_custom ? (
|
|
60
|
+
<EditTemplateTitle template={ template } />
|
|
61
|
+
) : (
|
|
62
|
+
<Heading
|
|
63
|
+
level={ 4 }
|
|
64
|
+
weight={ 600 }
|
|
65
|
+
className="edit-site-template-details__title"
|
|
66
|
+
>
|
|
67
|
+
{ title }
|
|
68
|
+
</Heading>
|
|
69
|
+
) }
|
|
65
70
|
|
|
66
71
|
{ description && (
|
|
67
72
|
<Text
|
|
@@ -80,7 +85,7 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
80
85
|
<MenuGroup className="edit-site-template-details__group edit-site-template-details__revert">
|
|
81
86
|
<MenuItem
|
|
82
87
|
className="edit-site-template-details__revert-button"
|
|
83
|
-
info={ __( 'Restore template to
|
|
88
|
+
info={ __( 'Restore template to default state' ) }
|
|
84
89
|
onClick={ revert }
|
|
85
90
|
>
|
|
86
91
|
{ __( 'Clear customizations' ) }
|
|
@@ -90,9 +95,9 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
90
95
|
|
|
91
96
|
<Button
|
|
92
97
|
className="edit-site-template-details__show-all-button"
|
|
93
|
-
href={ addQueryArgs(
|
|
94
|
-
page: 'gutenberg-edit-site',
|
|
98
|
+
href={ addQueryArgs( window.location.href, {
|
|
95
99
|
// TODO: We should update this to filter by template part's areas as well.
|
|
100
|
+
postId: undefined,
|
|
96
101
|
postType: template.type,
|
|
97
102
|
} ) }
|
|
98
103
|
>
|
|
@@ -48,7 +48,7 @@ function TemplatePartItemMore( {
|
|
|
48
48
|
{ isTemplateRevertable( templatePart ) && (
|
|
49
49
|
<MenuGroup>
|
|
50
50
|
<MenuItem
|
|
51
|
-
info={ __( 'Restore template to
|
|
51
|
+
info={ __( 'Restore template to default state' ) }
|
|
52
52
|
onClick={ clearCustomizations }
|
|
53
53
|
>
|
|
54
54
|
{ __( 'Clear customizations' ) }
|
package/src/index.js
CHANGED
|
@@ -6,20 +6,21 @@ import {
|
|
|
6
6
|
registerCoreBlocks,
|
|
7
7
|
__experimentalRegisterExperimentalCoreBlocks,
|
|
8
8
|
} from '@wordpress/block-library';
|
|
9
|
-
import { dispatch } from '@wordpress/data';
|
|
9
|
+
import { dispatch, select } from '@wordpress/data';
|
|
10
10
|
import { render, unmountComponentAtNode } from '@wordpress/element';
|
|
11
11
|
import {
|
|
12
12
|
__experimentalFetchLinkSuggestions as fetchLinkSuggestions,
|
|
13
13
|
__experimentalFetchUrlData as fetchUrlData,
|
|
14
14
|
} from '@wordpress/core-data';
|
|
15
15
|
import { store as editorStore } from '@wordpress/editor';
|
|
16
|
+
import { store as viewportStore } from '@wordpress/viewport';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Internal dependencies
|
|
19
20
|
*/
|
|
20
21
|
import './plugins';
|
|
21
22
|
import './hooks';
|
|
22
|
-
import './store';
|
|
23
|
+
import { store as editSiteStore } from './store';
|
|
23
24
|
import Editor from './components/editor';
|
|
24
25
|
import List from './components/list';
|
|
25
26
|
|
|
@@ -84,6 +85,13 @@ export function initializeList( id, templateType, settings ) {
|
|
|
84
85
|
defaultTemplatePartAreas: settings.defaultTemplatePartAreas,
|
|
85
86
|
} );
|
|
86
87
|
|
|
88
|
+
// Default the navigation panel to be opened when we're in a bigger screen.
|
|
89
|
+
// We update the store synchronously before rendering so that we won't
|
|
90
|
+
// trigger an unnecessary re-render with useEffect.
|
|
91
|
+
dispatch( editSiteStore ).setIsNavigationPanelOpened(
|
|
92
|
+
select( viewportStore ).isViewportMatch( 'medium' )
|
|
93
|
+
);
|
|
94
|
+
|
|
87
95
|
render( <List templateType={ templateType } />, target );
|
|
88
96
|
}
|
|
89
97
|
|