@wordpress/edit-site 3.0.14 → 3.0.18-next.33ec3857e2.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/build/components/add-new-template/new-template-part.js +29 -18
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +30 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +51 -0
- package/build/components/app/index.js.map +1 -0
- package/build/components/block-editor/back-button.js +8 -20
- package/build/components/block-editor/back-button.js.map +1 -1
- package/build/components/block-editor/index.js +2 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +1 -0
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +0 -2
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/edit-template-part-menu-button/index.js +20 -8
- package/build/components/edit-template-part-menu-button/index.js.map +1 -1
- package/build/components/editor/index.js +11 -30
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +81 -22
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +10 -10
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +9 -10
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +1 -1
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +6 -10
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +8 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +6 -10
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/ui.js +27 -14
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/header/document-actions/index.js +3 -6
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/list/actions/index.js +1 -0
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/list/index.js +17 -15
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +4 -4
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-sidebar/index.js +12 -13
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +26 -24
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +3 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/routes/index.js +60 -0
- package/build/components/routes/index.js.map +1 -0
- package/build/components/routes/link.js +65 -0
- package/build/components/routes/link.js.map +1 -0
- package/build/components/routes/use-title.js +57 -0
- package/build/components/routes/use-title.js.map +1 -0
- package/build/components/sidebar/default-sidebar.js +4 -2
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/global-styles-sidebar.js +11 -0
- package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar/template-card/template-areas.js +7 -4
- package/build/components/sidebar/template-card/template-areas.js.map +1 -1
- package/build/components/template-details/index.js +12 -10
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +27 -10
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +7 -12
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/url-query-controller/index.js +41 -50
- package/build/components/url-query-controller/index.js.map +1 -1
- package/build/components/welcome-guide/editor.js +6 -0
- package/build/components/welcome-guide/editor.js.map +1 -1
- package/build/components/welcome-guide/index.js +1 -28
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +18 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/index.js +29 -35
- package/build/index.js.map +1 -1
- package/build/plugins/index.js +3 -23
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/site-export.js +67 -0
- package/build/plugins/site-export.js.map +1 -0
- package/build/plugins/welcome-guide-menu-item.js +1 -7
- package/build/plugins/welcome-guide-menu-item.js.map +1 -1
- package/build/store/actions.js +0 -27
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +1 -14
- package/build/store/constants.js.map +1 -1
- package/build/store/reducer.js +7 -16
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -31
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-is-list-page.js +23 -0
- package/build/utils/get-is-list-page.js.map +1 -0
- package/build/utils/history.js +35 -0
- package/build/utils/history.js.map +1 -0
- package/build-module/components/add-new-template/new-template-part.js +27 -16
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +28 -18
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +35 -0
- package/build-module/components/app/index.js.map +1 -0
- package/build-module/components/block-editor/back-button.js +8 -19
- package/build-module/components/block-editor/back-button.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/block-editor/resizable-editor.js +1 -0
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +0 -2
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/edit-template-part-menu-button/index.js +17 -9
- package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
- package/build-module/components/editor/index.js +13 -33
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +82 -23
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +10 -10
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +9 -11
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +1 -1
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +7 -11
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +9 -4
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +7 -11
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/ui.js +26 -14
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +3 -6
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +1 -0
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/list/index.js +15 -15
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +4 -4
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-sidebar/index.js +13 -13
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +24 -24
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +3 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/routes/index.js +47 -0
- package/build-module/components/routes/index.js.map +1 -0
- package/build-module/components/routes/link.js +51 -0
- package/build-module/components/routes/link.js.map +1 -0
- package/build-module/components/routes/use-title.js +44 -0
- package/build-module/components/routes/use-title.js.map +1 -0
- package/build-module/components/sidebar/default-sidebar.js +4 -2
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/global-styles-sidebar.js +9 -0
- package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-areas.js +8 -4
- package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
- package/build-module/components/template-details/index.js +10 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +24 -9
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +7 -12
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/url-query-controller/index.js +40 -49
- package/build-module/components/url-query-controller/index.js.map +1 -1
- package/build-module/components/welcome-guide/editor.js +7 -1
- package/build-module/components/welcome-guide/editor.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -26
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +18 -2
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/index.js +28 -33
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/index.js +2 -18
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/site-export.js +51 -0
- package/build-module/plugins/site-export.js.map +1 -0
- package/build-module/plugins/welcome-guide-menu-item.js +2 -7
- package/build-module/plugins/welcome-guide-menu-item.js.map +1 -1
- package/build-module/store/actions.js +0 -23
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +0 -11
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/reducer.js +7 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -27
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +16 -0
- package/build-module/utils/get-is-list-page.js.map +1 -0
- package/build-module/utils/history.js +25 -0
- package/build-module/utils/history.js.map +1 -0
- package/build-style/style-rtl.css +36 -61
- package/build-style/style.css +36 -61
- package/package.json +29 -28
- package/src/components/add-new-template/new-template-part.js +29 -11
- package/src/components/add-new-template/new-template.js +26 -12
- package/src/components/app/index.js +47 -0
- package/src/components/block-editor/back-button.js +6 -14
- package/src/components/block-editor/index.js +1 -0
- package/src/components/block-editor/resizable-editor.js +1 -0
- package/src/components/block-editor/style.scss +10 -18
- package/src/components/create-template-part-modal/index.js +0 -2
- package/src/components/edit-template-part-menu-button/index.js +16 -5
- package/src/components/editor/index.js +105 -131
- package/src/components/global-styles/border-panel.js +106 -42
- package/src/components/global-styles/gradients-palette-panel.js +12 -12
- package/src/components/global-styles/screen-background-color.js +7 -10
- package/src/components/global-styles/screen-colors.js +1 -1
- package/src/components/global-styles/screen-link-color.js +6 -14
- package/src/components/global-styles/screen-root.js +17 -7
- package/src/components/global-styles/screen-text-color.js +6 -14
- package/src/components/global-styles/style.scss +6 -17
- package/src/components/global-styles/test/use-global-styles-output.js +7 -1
- package/src/components/global-styles/ui.js +50 -25
- package/src/components/global-styles/use-global-styles-output.js +0 -1
- package/src/components/header/document-actions/index.js +3 -9
- package/src/components/header/document-actions/style.scss +1 -9
- package/src/components/header/style.scss +2 -1
- package/src/components/list/actions/index.js +1 -0
- package/src/components/list/index.js +11 -12
- package/src/components/list/style.scss +6 -11
- package/src/components/list/table.js +5 -5
- package/src/components/navigation-sidebar/index.js +18 -17
- package/src/components/navigation-sidebar/navigation-panel/index.js +16 -22
- package/src/components/navigation-sidebar/navigation-toggle/index.js +2 -0
- package/src/components/routes/index.js +53 -0
- package/src/components/routes/link.js +44 -0
- package/src/components/routes/use-title.js +56 -0
- package/src/components/sidebar/default-sidebar.js +2 -0
- package/src/components/sidebar/global-styles-sidebar.js +9 -0
- package/src/components/sidebar/style.scss +21 -14
- package/src/components/sidebar/template-card/template-areas.js +16 -4
- package/src/components/template-details/index.js +8 -6
- package/src/components/template-details/template-areas.js +31 -8
- package/src/components/template-part-converter/convert-to-template-part.js +4 -2
- package/src/components/url-query-controller/index.js +34 -45
- package/src/components/welcome-guide/editor.js +10 -1
- package/src/components/welcome-guide/index.js +6 -25
- package/src/components/welcome-guide/styles.js +20 -2
- package/src/index.js +33 -36
- package/src/plugins/index.js +2 -32
- package/src/plugins/site-export.js +52 -0
- package/src/plugins/welcome-guide-menu-item.js +2 -16
- package/src/store/actions.js +0 -23
- package/src/store/constants.js +0 -12
- package/src/store/reducer.js +12 -26
- package/src/store/selectors.js +1 -27
- package/src/store/test/reducer.js +22 -39
- package/src/store/test/selectors.js +3 -34
- package/src/utils/get-is-list-page.js +11 -0
- package/src/utils/history.js +35 -0
|
@@ -15,11 +15,9 @@ import {
|
|
|
15
15
|
} from '@wordpress/components';
|
|
16
16
|
import { store as coreDataStore } from '@wordpress/core-data';
|
|
17
17
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
19
18
|
import { __ } from '@wordpress/i18n';
|
|
20
19
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
21
20
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
22
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
23
21
|
import {
|
|
24
22
|
home as siteIcon,
|
|
25
23
|
layout as templateIcon,
|
|
@@ -29,11 +27,18 @@ import {
|
|
|
29
27
|
/**
|
|
30
28
|
* Internal dependencies
|
|
31
29
|
*/
|
|
30
|
+
import { useLink } from '../../routes/link';
|
|
32
31
|
import MainDashboardButton from '../../main-dashboard-button';
|
|
33
32
|
import { store as editSiteStore } from '../../../store';
|
|
34
33
|
|
|
35
34
|
const SITE_EDITOR_KEY = 'site-editor';
|
|
36
35
|
|
|
36
|
+
function NavLink( { params, replace, ...props } ) {
|
|
37
|
+
const linkProps = useLink( params, replace );
|
|
38
|
+
|
|
39
|
+
return <NavigationItem { ...linkProps } { ...props } />;
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
38
43
|
const { isNavigationOpen, siteTitle } = useSelect( ( select ) => {
|
|
39
44
|
const { getEntityRecord } = select( coreDataStore );
|
|
@@ -48,15 +53,6 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
|
48
53
|
}, [] );
|
|
49
54
|
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
50
55
|
|
|
51
|
-
// Ensures focus is moved to the panel area when it is activated
|
|
52
|
-
// from a separate component (such as document actions in the header).
|
|
53
|
-
const panelRef = useRef();
|
|
54
|
-
useEffect( () => {
|
|
55
|
-
if ( isNavigationOpen ) {
|
|
56
|
-
panelRef.current.focus();
|
|
57
|
-
}
|
|
58
|
-
}, [ activeItem, isNavigationOpen ] );
|
|
59
|
-
|
|
60
56
|
const closeOnEscape = ( event ) => {
|
|
61
57
|
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
62
58
|
event.preventDefault();
|
|
@@ -70,8 +66,6 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
|
70
66
|
className={ classnames( `edit-site-navigation-panel`, {
|
|
71
67
|
'is-open': isNavigationOpen,
|
|
72
68
|
} ) }
|
|
73
|
-
ref={ panelRef }
|
|
74
|
-
tabIndex="-1"
|
|
75
69
|
onKeyDown={ closeOnEscape }
|
|
76
70
|
>
|
|
77
71
|
<div className="edit-site-navigation-panel__inner">
|
|
@@ -92,32 +86,32 @@ const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
|
92
86
|
|
|
93
87
|
<NavigationMenu>
|
|
94
88
|
<NavigationGroup title={ __( 'Editor' ) }>
|
|
95
|
-
<
|
|
89
|
+
<NavLink
|
|
96
90
|
icon={ siteIcon }
|
|
97
91
|
title={ __( 'Site' ) }
|
|
98
92
|
item={ SITE_EDITOR_KEY }
|
|
99
|
-
|
|
93
|
+
params={ {
|
|
100
94
|
postId: undefined,
|
|
101
95
|
postType: undefined,
|
|
102
|
-
}
|
|
96
|
+
} }
|
|
103
97
|
/>
|
|
104
|
-
<
|
|
98
|
+
<NavLink
|
|
105
99
|
icon={ templateIcon }
|
|
106
100
|
title={ __( 'Templates' ) }
|
|
107
101
|
item="wp_template"
|
|
108
|
-
|
|
102
|
+
params={ {
|
|
109
103
|
postId: undefined,
|
|
110
104
|
postType: 'wp_template',
|
|
111
|
-
}
|
|
105
|
+
} }
|
|
112
106
|
/>
|
|
113
|
-
<
|
|
107
|
+
<NavLink
|
|
114
108
|
icon={ templatePartIcon }
|
|
115
109
|
title={ __( 'Template Parts' ) }
|
|
116
110
|
item="wp_template_part"
|
|
117
|
-
|
|
111
|
+
params={ {
|
|
118
112
|
postId: undefined,
|
|
119
113
|
postType: 'wp_template_part',
|
|
120
|
-
}
|
|
114
|
+
} }
|
|
121
115
|
/>
|
|
122
116
|
</NavigationGroup>
|
|
123
117
|
</NavigationMenu>
|
|
@@ -79,6 +79,8 @@ function NavigationToggle( { icon } ) {
|
|
|
79
79
|
<Button
|
|
80
80
|
className="edit-site-navigation-toggle__button has-icon"
|
|
81
81
|
label={ __( 'Toggle navigation' ) }
|
|
82
|
+
// isPressed will add unwanted styles.
|
|
83
|
+
aria-pressed={ isNavigationOpen }
|
|
82
84
|
onClick={ toggleNavigationPanel }
|
|
83
85
|
showTooltip
|
|
84
86
|
>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useState,
|
|
7
|
+
useEffect,
|
|
8
|
+
useContext,
|
|
9
|
+
} from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import history from '../../utils/history';
|
|
15
|
+
|
|
16
|
+
const RoutesContext = createContext();
|
|
17
|
+
const HistoryContext = createContext();
|
|
18
|
+
|
|
19
|
+
export function useLocation() {
|
|
20
|
+
return useContext( RoutesContext );
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function useHistory() {
|
|
24
|
+
return useContext( HistoryContext );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getLocationWithParams( location ) {
|
|
28
|
+
const searchParams = new URLSearchParams( location.search );
|
|
29
|
+
return {
|
|
30
|
+
...location,
|
|
31
|
+
params: Object.fromEntries( searchParams.entries() ),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function Routes( { children } ) {
|
|
36
|
+
const [ location, setLocation ] = useState( () =>
|
|
37
|
+
getLocationWithParams( history.location )
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
useEffect( () => {
|
|
41
|
+
return history.listen( ( { location: updatedLocation } ) => {
|
|
42
|
+
setLocation( getLocationWithParams( updatedLocation ) );
|
|
43
|
+
} );
|
|
44
|
+
}, [] );
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<HistoryContext.Provider value={ history }>
|
|
48
|
+
<RoutesContext.Provider value={ location }>
|
|
49
|
+
{ children( location ) }
|
|
50
|
+
</RoutesContext.Provider>
|
|
51
|
+
</HistoryContext.Provider>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useHistory } from './index';
|
|
10
|
+
|
|
11
|
+
export function useLink( params = {}, state, shouldReplace = false ) {
|
|
12
|
+
const history = useHistory();
|
|
13
|
+
|
|
14
|
+
function onClick( event ) {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
|
|
17
|
+
if ( shouldReplace ) {
|
|
18
|
+
history.replace( params, state );
|
|
19
|
+
} else {
|
|
20
|
+
history.push( params, state );
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
href: addQueryArgs( window.location.href, params ),
|
|
26
|
+
onClick,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function Link( {
|
|
31
|
+
params = {},
|
|
32
|
+
state,
|
|
33
|
+
replace: shouldReplace = false,
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
} ) {
|
|
37
|
+
const { href, onClick } = useLink( params, state, shouldReplace );
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<a href={ href } onClick={ onClick } { ...props }>
|
|
41
|
+
{ children }
|
|
42
|
+
</a>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { speak } from '@wordpress/a11y';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { useLocation } from './index';
|
|
14
|
+
|
|
15
|
+
export default function useTitle( title ) {
|
|
16
|
+
const location = useLocation();
|
|
17
|
+
const siteTitle = useSelect(
|
|
18
|
+
( select ) =>
|
|
19
|
+
select( coreStore ).getEntityRecord( 'root', 'site' )?.title,
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
22
|
+
const isInitialLocationRef = useRef( true );
|
|
23
|
+
|
|
24
|
+
useEffect( () => {
|
|
25
|
+
isInitialLocationRef.current = false;
|
|
26
|
+
}, [ location ] );
|
|
27
|
+
|
|
28
|
+
useEffect( () => {
|
|
29
|
+
// Don't update or announce the title for initial page load.
|
|
30
|
+
if ( isInitialLocationRef.current ) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if ( title && siteTitle ) {
|
|
35
|
+
// @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68
|
|
36
|
+
const formattedTitle = sprintf(
|
|
37
|
+
/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
|
|
38
|
+
__( '%1$s ‹ %2$s — WordPress' ),
|
|
39
|
+
title,
|
|
40
|
+
siteTitle
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
document.title = formattedTitle;
|
|
44
|
+
|
|
45
|
+
// Announce title on route change for screen readers.
|
|
46
|
+
speak(
|
|
47
|
+
sprintf(
|
|
48
|
+
/* translators: The page title that is currently displaying. */
|
|
49
|
+
__( 'Now displaying: %s' ),
|
|
50
|
+
document.title
|
|
51
|
+
),
|
|
52
|
+
'assertive'
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}, [ title, siteTitle, location ] );
|
|
56
|
+
}
|
|
@@ -15,6 +15,7 @@ export default function DefaultSidebar( {
|
|
|
15
15
|
closeLabel,
|
|
16
16
|
header,
|
|
17
17
|
headerClassName,
|
|
18
|
+
panelClassName,
|
|
18
19
|
} ) {
|
|
19
20
|
return (
|
|
20
21
|
<>
|
|
@@ -27,6 +28,7 @@ export default function DefaultSidebar( {
|
|
|
27
28
|
closeLabel={ closeLabel }
|
|
28
29
|
header={ header }
|
|
29
30
|
headerClassName={ headerClassName }
|
|
31
|
+
panelClassName={ panelClassName }
|
|
30
32
|
>
|
|
31
33
|
{ children }
|
|
32
34
|
</ComplementaryArea>
|
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
import { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { styles, moreVertical } from '@wordpress/icons';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
10
11
|
*/
|
|
11
12
|
import DefaultSidebar from './default-sidebar';
|
|
12
13
|
import { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';
|
|
14
|
+
import { store as editSiteStore } from '../../store';
|
|
13
15
|
|
|
14
16
|
export default function GlobalStylesSidebar() {
|
|
15
17
|
const [ canReset, onReset ] = useGlobalStylesReset();
|
|
18
|
+
const { toggleFeature } = useDispatch( editSiteStore );
|
|
16
19
|
|
|
17
20
|
return (
|
|
18
21
|
<DefaultSidebar
|
|
@@ -21,6 +24,7 @@ export default function GlobalStylesSidebar() {
|
|
|
21
24
|
title={ __( 'Styles' ) }
|
|
22
25
|
icon={ styles }
|
|
23
26
|
closeLabel={ __( 'Close global styles sidebar' ) }
|
|
27
|
+
panelClassName="edit-site-global-styles-sidebar__panel"
|
|
24
28
|
header={
|
|
25
29
|
<Flex>
|
|
26
30
|
<FlexBlock>
|
|
@@ -39,6 +43,11 @@ export default function GlobalStylesSidebar() {
|
|
|
39
43
|
title: __( 'Reset to defaults' ),
|
|
40
44
|
onClick: onReset,
|
|
41
45
|
},
|
|
46
|
+
{
|
|
47
|
+
title: __( 'Welcome Guide' ),
|
|
48
|
+
onClick: () =>
|
|
49
|
+
toggleFeature( 'welcomeGuideStyles' ),
|
|
50
|
+
},
|
|
42
51
|
] }
|
|
43
52
|
/>
|
|
44
53
|
</FlexItem>
|
|
@@ -17,6 +17,23 @@
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
.edit-site-global-styles-sidebar {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
height: 100%;
|
|
24
|
+
|
|
25
|
+
&__panel,
|
|
26
|
+
&__navigator-provider {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
flex: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&__navigator-screen {
|
|
33
|
+
flex: 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
.edit-site-global-styles-sidebar .interface-complementary-area-header .components-button.has-icon {
|
|
21
38
|
margin-left: 0;
|
|
22
39
|
}
|
|
@@ -25,20 +42,6 @@
|
|
|
25
42
|
margin-left: auto;
|
|
26
43
|
}
|
|
27
44
|
|
|
28
|
-
.edit-site-global-styles-sidebar__border-controls-row {
|
|
29
|
-
display: flex;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
margin-bottom: $grid-unit-15;
|
|
32
|
-
|
|
33
|
-
> * {
|
|
34
|
-
width: calc(50% - #{ $grid-unit-10 });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.components-border-style-control__buttons {
|
|
38
|
-
margin-bottom: 0;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
45
|
.edit-site-global-styles-sidebar .components-navigation__menu-title-heading {
|
|
43
46
|
font-size: $default-font-size * 1.2;
|
|
44
47
|
font-weight: 500;
|
|
@@ -53,6 +56,10 @@
|
|
|
53
56
|
border: 0;
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
.edit-site-global-styles-sidebar .components-tools-panel-item.single-column {
|
|
60
|
+
grid-column: span 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
.edit-site-global-styles-sidebar__blocks-group {
|
|
57
64
|
padding-top: $grid-unit-30;
|
|
58
65
|
border-top: $border-width solid $gray-200;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Button,
|
|
7
7
|
__experimentalHeading as Heading,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
|
-
import {
|
|
9
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
10
10
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
|
|
@@ -14,19 +14,31 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import { store as editSiteStore } from '../../../store';
|
|
17
|
-
import { TEMPLATE_PART_AREA_TO_NAME } from '../../../store/constants';
|
|
18
17
|
|
|
19
18
|
function TemplateAreaItem( { area, clientId } ) {
|
|
20
19
|
const { selectBlock, toggleBlockHighlight } = useDispatch(
|
|
21
20
|
blockEditorStore
|
|
22
21
|
);
|
|
22
|
+
const templatePartArea = useSelect(
|
|
23
|
+
( select ) => {
|
|
24
|
+
const defaultAreas = select(
|
|
25
|
+
editorStore
|
|
26
|
+
).__experimentalGetDefaultTemplatePartAreas();
|
|
27
|
+
|
|
28
|
+
return defaultAreas.find(
|
|
29
|
+
( defaultArea ) => defaultArea.area === area
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
[ area ]
|
|
33
|
+
);
|
|
34
|
+
|
|
23
35
|
const highlightBlock = () => toggleBlockHighlight( clientId, true );
|
|
24
36
|
const cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );
|
|
25
37
|
|
|
26
38
|
return (
|
|
27
39
|
<Button
|
|
28
40
|
className="edit-site-template-card__template-areas-item"
|
|
29
|
-
icon={
|
|
41
|
+
icon={ templatePartArea?.icon }
|
|
30
42
|
onMouseOver={ highlightBlock }
|
|
31
43
|
onMouseLeave={ cancelHighlightBlock }
|
|
32
44
|
onFocus={ highlightBlock }
|
|
@@ -35,7 +47,7 @@ function TemplateAreaItem( { area, clientId } ) {
|
|
|
35
47
|
selectBlock( clientId );
|
|
36
48
|
} }
|
|
37
49
|
>
|
|
38
|
-
{
|
|
50
|
+
{ templatePartArea?.label }
|
|
39
51
|
</Button>
|
|
40
52
|
);
|
|
41
53
|
}
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from '@wordpress/components';
|
|
13
13
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
14
14
|
import { store as editorStore } from '@wordpress/editor';
|
|
15
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Internal dependencies
|
|
@@ -25,6 +24,7 @@ import {
|
|
|
25
24
|
import { store as editSiteStore } from '../../store';
|
|
26
25
|
import TemplateAreas from './template-areas';
|
|
27
26
|
import EditTemplateTitle from './edit-template-title';
|
|
27
|
+
import { useLink } from '../routes/link';
|
|
28
28
|
|
|
29
29
|
export default function TemplateDetails( { template, onClose } ) {
|
|
30
30
|
const { title, description } = useSelect(
|
|
@@ -44,6 +44,12 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
44
44
|
);
|
|
45
45
|
}, [ template ] );
|
|
46
46
|
|
|
47
|
+
const browseAllLinkProps = useLink( {
|
|
48
|
+
// TODO: We should update this to filter by template part's areas as well.
|
|
49
|
+
postType: template.type,
|
|
50
|
+
postId: undefined,
|
|
51
|
+
} );
|
|
52
|
+
|
|
47
53
|
if ( ! template ) {
|
|
48
54
|
return null;
|
|
49
55
|
}
|
|
@@ -95,11 +101,7 @@ export default function TemplateDetails( { template, onClose } ) {
|
|
|
95
101
|
|
|
96
102
|
<Button
|
|
97
103
|
className="edit-site-template-details__show-all-button"
|
|
98
|
-
|
|
99
|
-
// TODO: We should update this to filter by template part's areas as well.
|
|
100
|
-
postId: undefined,
|
|
101
|
-
postType: template.type,
|
|
102
|
-
} ) }
|
|
104
|
+
{ ...browseAllLinkProps }
|
|
103
105
|
>
|
|
104
106
|
{ sprintf(
|
|
105
107
|
/* translators: the template part's area name ("Headers", "Sidebars") or "templates". */
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
5
5
|
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
-
import {
|
|
7
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
8
8
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
9
|
import { moreVertical } from '@wordpress/icons';
|
|
10
10
|
|
|
@@ -12,18 +12,29 @@ import { moreVertical } from '@wordpress/icons';
|
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import { store as editSiteStore } from '../../store';
|
|
15
|
-
import { TEMPLATE_PART_AREA_TO_NAME } from '../../store/constants';
|
|
16
15
|
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
16
|
+
import { useLocation } from '../routes';
|
|
17
|
+
import { useLink } from '../routes/link';
|
|
17
18
|
|
|
18
19
|
function TemplatePartItemMore( {
|
|
19
20
|
onClose,
|
|
20
21
|
templatePart,
|
|
21
22
|
closeTemplateDetailsDropdown,
|
|
22
23
|
} ) {
|
|
23
|
-
const {
|
|
24
|
+
const { revertTemplate } = useDispatch( editSiteStore );
|
|
25
|
+
const { params } = useLocation();
|
|
26
|
+
const editLinkProps = useLink(
|
|
27
|
+
{
|
|
28
|
+
postId: templatePart.id,
|
|
29
|
+
postType: templatePart.type,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
fromTemplateId: params.postId,
|
|
33
|
+
}
|
|
34
|
+
);
|
|
24
35
|
|
|
25
|
-
function editTemplatePart() {
|
|
26
|
-
|
|
36
|
+
function editTemplatePart( event ) {
|
|
37
|
+
editLinkProps.onClick( event );
|
|
27
38
|
onClose();
|
|
28
39
|
closeTemplateDetailsDropdown();
|
|
29
40
|
}
|
|
@@ -37,7 +48,7 @@ function TemplatePartItemMore( {
|
|
|
37
48
|
return (
|
|
38
49
|
<>
|
|
39
50
|
<MenuGroup>
|
|
40
|
-
<MenuItem onClick={ editTemplatePart }>
|
|
51
|
+
<MenuItem { ...editLinkProps } onClick={ editTemplatePart }>
|
|
41
52
|
{ sprintf(
|
|
42
53
|
/* translators: %s: template part title */
|
|
43
54
|
__( 'Edit %s' ),
|
|
@@ -67,6 +78,18 @@ function TemplatePartItem( {
|
|
|
67
78
|
const { selectBlock, toggleBlockHighlight } = useDispatch(
|
|
68
79
|
blockEditorStore
|
|
69
80
|
);
|
|
81
|
+
const templatePartArea = useSelect(
|
|
82
|
+
( select ) => {
|
|
83
|
+
const defaultAreas = select(
|
|
84
|
+
editorStore
|
|
85
|
+
).__experimentalGetDefaultTemplatePartAreas();
|
|
86
|
+
|
|
87
|
+
return defaultAreas.find(
|
|
88
|
+
( defaultArea ) => defaultArea.area === templatePart.area
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
[ templatePart.area ]
|
|
92
|
+
);
|
|
70
93
|
const highlightBlock = () => toggleBlockHighlight( clientId, true );
|
|
71
94
|
const cancelHighlightBlock = () => toggleBlockHighlight( clientId, false );
|
|
72
95
|
|
|
@@ -77,7 +100,7 @@ function TemplatePartItem( {
|
|
|
77
100
|
>
|
|
78
101
|
<MenuItem
|
|
79
102
|
role="button"
|
|
80
|
-
icon={
|
|
103
|
+
icon={ templatePartArea?.icon }
|
|
81
104
|
iconPosition="left"
|
|
82
105
|
onClick={ () => {
|
|
83
106
|
selectBlock( clientId );
|
|
@@ -87,7 +110,7 @@ function TemplatePartItem( {
|
|
|
87
110
|
onFocus={ highlightBlock }
|
|
88
111
|
onBlur={ cancelHighlightBlock }
|
|
89
112
|
>
|
|
90
|
-
{
|
|
113
|
+
{ templatePartArea?.label }
|
|
91
114
|
</MenuItem>
|
|
92
115
|
|
|
93
116
|
<DropdownMenu
|
|
@@ -50,16 +50,18 @@ export default function ConvertToTemplatePart( { clientIds, blocks } ) {
|
|
|
50
50
|
createSuccessNotice( __( 'Template part created.' ), {
|
|
51
51
|
type: 'snackbar',
|
|
52
52
|
} );
|
|
53
|
+
|
|
54
|
+
// The modal and this component will be unmounted because of `replaceBlocks` above,
|
|
55
|
+
// so no need to call `closeModal` or `onClose`.
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
return (
|
|
56
59
|
<>
|
|
57
60
|
<BlockSettingsMenuControls>
|
|
58
|
-
{ (
|
|
61
|
+
{ () => (
|
|
59
62
|
<MenuItem
|
|
60
63
|
onClick={ () => {
|
|
61
64
|
setIsModalOpen( true );
|
|
62
|
-
onClose();
|
|
63
65
|
} }
|
|
64
66
|
>
|
|
65
67
|
{ __( 'Make template part' ) }
|
|
@@ -3,29 +3,29 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useEffect } from '@wordpress/element';
|
|
5
5
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import { getQueryArg, addQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
10
9
|
*/
|
|
10
|
+
import { useLocation, useHistory } from '../routes';
|
|
11
11
|
import { store as editSiteStore } from '../../store';
|
|
12
12
|
|
|
13
13
|
export default function URLQueryController() {
|
|
14
14
|
const { setTemplate, setTemplatePart, showHomepage, setPage } = useDispatch(
|
|
15
15
|
editSiteStore
|
|
16
16
|
);
|
|
17
|
+
const history = useHistory();
|
|
18
|
+
const {
|
|
19
|
+
params: { postId, postType },
|
|
20
|
+
} = useLocation();
|
|
21
|
+
const { getPage, getEditedPostId, getEditedPostType } = useSelect(
|
|
22
|
+
editSiteStore
|
|
23
|
+
);
|
|
17
24
|
|
|
18
|
-
// Set correct entity on
|
|
25
|
+
// Set correct entity on page navigation.
|
|
19
26
|
useEffect( () => {
|
|
20
|
-
|
|
21
|
-
const postId = getQueryArg( url, 'postId' );
|
|
22
|
-
|
|
23
|
-
if ( ! postId ) {
|
|
24
|
-
showHomepage();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
+
let isMounted = true;
|
|
27
28
|
|
|
28
|
-
const postType = getQueryArg( url, 'postType' );
|
|
29
29
|
if ( 'page' === postType || 'post' === postType ) {
|
|
30
30
|
setPage( { context: { postType, postId } } ); // Resolves correct template based on ID.
|
|
31
31
|
} else if ( 'wp_template' === postType ) {
|
|
@@ -33,44 +33,33 @@ export default function URLQueryController() {
|
|
|
33
33
|
} else if ( 'wp_template_part' === postType ) {
|
|
34
34
|
setTemplatePart( postId );
|
|
35
35
|
} else {
|
|
36
|
-
showHomepage()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Update page URL when context changes.
|
|
41
|
-
const pageContext = useCurrentPageContext();
|
|
42
|
-
useEffect( () => {
|
|
43
|
-
const newUrl = pageContext
|
|
44
|
-
? addQueryArgs( window.location.href, pageContext )
|
|
45
|
-
: removeQueryArgs( window.location.href, 'postType', 'postId' );
|
|
36
|
+
showHomepage().then( () => {
|
|
37
|
+
if ( ! isMounted ) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
const page = getPage();
|
|
42
|
+
const editedPostId = getEditedPostId();
|
|
43
|
+
const editedPostType = getEditedPostType();
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// This doesn't seem right to me,
|
|
63
|
-
// we shouldn't be using the "page" and the "template" in the same way.
|
|
64
|
-
// This need to be investigated.
|
|
65
|
-
if ( page?.context?.postId && page?.context?.postType ) {
|
|
66
|
-
_postId = page.context.postId;
|
|
67
|
-
_postType = page.context.postType;
|
|
45
|
+
if ( page?.context?.postId && page?.context?.postType ) {
|
|
46
|
+
history.replace( {
|
|
47
|
+
postId: page.context.postId,
|
|
48
|
+
postType: page.context.postType,
|
|
49
|
+
} );
|
|
50
|
+
} else if ( editedPostId && editedPostType ) {
|
|
51
|
+
history.replace( {
|
|
52
|
+
postId: editedPostId,
|
|
53
|
+
postType: editedPostType,
|
|
54
|
+
} );
|
|
55
|
+
}
|
|
56
|
+
} );
|
|
68
57
|
}
|
|
69
58
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
59
|
+
return () => {
|
|
60
|
+
isMounted = false;
|
|
61
|
+
};
|
|
62
|
+
}, [ postId, postType ] );
|
|
73
63
|
|
|
74
|
-
|
|
75
|
-
}, [] );
|
|
64
|
+
return null;
|
|
76
65
|
}
|