@wordpress/edit-site 3.0.15 → 3.0.16
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/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/gradients-palette-panel.js +10 -10
- package/build/components/global-styles/gradients-palette-panel.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/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/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/global-styles-sidebar.js +10 -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 +61 -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/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/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/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/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/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/global-styles-sidebar.js +8 -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 +45 -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 +1 -6
- package/build-style/style.css +1 -6
- package/package.json +9 -8
- 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/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/gradients-palette-panel.js +12 -12
- 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/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/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/global-styles-sidebar.js +8 -0
- 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 +48 -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
|
@@ -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
|
+
}
|
|
@@ -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
|
|
@@ -39,6 +42,11 @@ export default function GlobalStylesSidebar() {
|
|
|
39
42
|
title: __( 'Reset to defaults' ),
|
|
40
43
|
onClick: onReset,
|
|
41
44
|
},
|
|
45
|
+
{
|
|
46
|
+
title: __( 'Welcome Guide' ),
|
|
47
|
+
onClick: () =>
|
|
48
|
+
toggleFeature( 'welcomeGuideStyles' ),
|
|
49
|
+
},
|
|
42
50
|
] }
|
|
43
51
|
/>
|
|
44
52
|
</FlexItem>
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useDispatch } from '@wordpress/data';
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
5
|
import { Guide } from '@wordpress/components';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { createInterpolateElement } from '@wordpress/element';
|
|
@@ -15,6 +15,15 @@ import { store as editSiteStore } from '../../store';
|
|
|
15
15
|
export default function WelcomeGuideEditor() {
|
|
16
16
|
const { toggleFeature } = useDispatch( editSiteStore );
|
|
17
17
|
|
|
18
|
+
const isActive = useSelect(
|
|
19
|
+
( select ) => select( editSiteStore ).isFeatureActive( 'welcomeGuide' ),
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if ( ! isActive ) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
18
27
|
return (
|
|
19
28
|
<Guide
|
|
20
29
|
className="edit-site-welcome-guide"
|
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Internal dependencies
|
|
9
3
|
*/
|
|
10
4
|
import WelcomeGuideEditor from './editor';
|
|
11
5
|
import WelcomeGuideStyles from './styles';
|
|
12
|
-
import { store as editSiteStore } from '../../store';
|
|
13
6
|
|
|
14
7
|
export default function WelcomeGuide() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
isActive: select( editSiteStore ).isFeatureActive( feature ),
|
|
24
|
-
isStylesOpen: isStylesSidebar,
|
|
25
|
-
};
|
|
26
|
-
}, [] );
|
|
27
|
-
|
|
28
|
-
if ( ! isActive ) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return isStylesOpen ? <WelcomeGuideStyles /> : <WelcomeGuideEditor />;
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<WelcomeGuideEditor />
|
|
11
|
+
<WelcomeGuideStyles />
|
|
12
|
+
</>
|
|
13
|
+
);
|
|
33
14
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useDispatch } from '@wordpress/data';
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
5
|
import { ExternalLink, Guide } from '@wordpress/components';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
@@ -14,6 +15,23 @@ import { store as editSiteStore } from '../../store';
|
|
|
14
15
|
export default function WelcomeGuideStyles() {
|
|
15
16
|
const { toggleFeature } = useDispatch( editSiteStore );
|
|
16
17
|
|
|
18
|
+
const { isActive, isStylesOpen } = useSelect( ( select ) => {
|
|
19
|
+
const sidebar = select( interfaceStore ).getActiveComplementaryArea(
|
|
20
|
+
editSiteStore.name
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
isActive: select( editSiteStore ).isFeatureActive(
|
|
25
|
+
'welcomeGuideStyles'
|
|
26
|
+
),
|
|
27
|
+
isStylesOpen: sidebar === 'edit-site/global-styles',
|
|
28
|
+
};
|
|
29
|
+
}, [] );
|
|
30
|
+
|
|
31
|
+
if ( ! isActive || ! isStylesOpen ) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
17
35
|
return (
|
|
18
36
|
<Guide
|
|
19
37
|
className="edit-site-welcome-guide"
|
|
@@ -99,7 +117,7 @@ export default function WelcomeGuideStyles() {
|
|
|
99
117
|
) }
|
|
100
118
|
<ExternalLink
|
|
101
119
|
href={ __(
|
|
102
|
-
'https://wordpress.org/support/article/
|
|
120
|
+
'https://wordpress.org/support/article/styles-overview/'
|
|
103
121
|
) }
|
|
104
122
|
>
|
|
105
123
|
{ __(
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from '@wordpress/core-data';
|
|
15
15
|
import { store as editorStore } from '@wordpress/editor';
|
|
16
16
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
17
|
+
import { getQueryArgs } from '@wordpress/url';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
@@ -21,8 +22,8 @@ import { store as viewportStore } from '@wordpress/viewport';
|
|
|
21
22
|
import './plugins';
|
|
22
23
|
import './hooks';
|
|
23
24
|
import { store as editSiteStore } from './store';
|
|
24
|
-
import
|
|
25
|
-
import
|
|
25
|
+
import EditSiteApp from './components/app';
|
|
26
|
+
import getIsListPage from './utils/get-is-list-page';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Reinitializes the editor after the user chooses to reboot the editor after
|
|
@@ -33,12 +34,37 @@ import List from './components/list';
|
|
|
33
34
|
* @param {?Object} settings Editor settings object.
|
|
34
35
|
*/
|
|
35
36
|
export function reinitializeEditor( target, settings ) {
|
|
37
|
+
// This will be a no-op if the target doesn't have any React nodes.
|
|
36
38
|
unmountComponentAtNode( target );
|
|
37
39
|
const reboot = reinitializeEditor.bind( null, target, settings );
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
|
|
41
|
+
// We dispatch actions and update the store synchronously before rendering
|
|
42
|
+
// so that we won't trigger unnecessary re-renders with useEffect.
|
|
43
|
+
{
|
|
44
|
+
dispatch( editSiteStore ).updateSettings( settings );
|
|
45
|
+
// Keep the defaultTemplateTypes in the core/editor settings too,
|
|
46
|
+
// so that they can be selected with core/editor selectors in any editor.
|
|
47
|
+
// This is needed because edit-site doesn't initialize with EditorProvider,
|
|
48
|
+
// which internally uses updateEditorSettings as well.
|
|
49
|
+
dispatch( editorStore ).updateEditorSettings( {
|
|
50
|
+
defaultTemplateTypes: settings.defaultTemplateTypes,
|
|
51
|
+
defaultTemplatePartAreas: settings.defaultTemplatePartAreas,
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
const isLandingOnListPage = getIsListPage(
|
|
55
|
+
getQueryArgs( window.location.href )
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if ( isLandingOnListPage ) {
|
|
59
|
+
// Default the navigation panel to be opened when we're in a bigger
|
|
60
|
+
// screen and land in the list screen.
|
|
61
|
+
dispatch( editSiteStore ).setIsNavigationPanelOpened(
|
|
62
|
+
select( viewportStore ).isViewportMatch( 'medium' )
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
render( <EditSiteApp reboot={ reboot } />, target );
|
|
42
68
|
}
|
|
43
69
|
|
|
44
70
|
/**
|
|
@@ -54,7 +80,6 @@ export function initializeEditor( id, settings ) {
|
|
|
54
80
|
settings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];
|
|
55
81
|
|
|
56
82
|
const target = document.getElementById( id );
|
|
57
|
-
const reboot = reinitializeEditor.bind( null, target, settings );
|
|
58
83
|
|
|
59
84
|
dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();
|
|
60
85
|
registerCoreBlocks();
|
|
@@ -64,35 +89,7 @@ export function initializeEditor( id, settings ) {
|
|
|
64
89
|
} );
|
|
65
90
|
}
|
|
66
91
|
|
|
67
|
-
|
|
68
|
-
<Editor initialSettings={ settings } onError={ reboot } />,
|
|
69
|
-
target
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Initializes the site editor templates list screen.
|
|
75
|
-
*
|
|
76
|
-
* @param {string} id ID of the root element to render the screen in.
|
|
77
|
-
* @param {string} templateType The type of the list. "wp_template" or "wp_template_part".
|
|
78
|
-
* @param {Object} settings Editor settings.
|
|
79
|
-
*/
|
|
80
|
-
export function initializeList( id, templateType, settings ) {
|
|
81
|
-
const target = document.getElementById( id );
|
|
82
|
-
|
|
83
|
-
dispatch( editorStore ).updateEditorSettings( {
|
|
84
|
-
defaultTemplateTypes: settings.defaultTemplateTypes,
|
|
85
|
-
defaultTemplatePartAreas: settings.defaultTemplatePartAreas,
|
|
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
|
-
|
|
95
|
-
render( <List templateType={ templateType } />, target );
|
|
92
|
+
reinitializeEditor( target, settings );
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
export { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';
|