@wordpress/edit-site 5.3.6 → 5.3.7
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/block-editor/editor-canvas.js +2 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/layout/index.js +6 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/index.js +2 -1
- package/build/components/list/index.js.map +1 -1
- package/build/components/routes/link.js +4 -1
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-button/index.js +2 -5
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +82 -0
- package/build/components/save-hub/index.js.map +1 -0
- package/build/components/sidebar/index.js +2 -4
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +5 -2
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -14
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +139 -11
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-template/index.js +18 -4
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +5 -2
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-details/index.js +0 -3
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +6 -6
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/utils/history.js +8 -2
- package/build/utils/history.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +2 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/layout/index.js +6 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/index.js +2 -1
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/routes/link.js +5 -2
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-button/index.js +2 -5
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +68 -0
- package/build-module/components/save-hub/index.js.map +1 -0
- package/build-module/components/sidebar/index.js +2 -4
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +5 -2
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +13 -18
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +131 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js +18 -5
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -2
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-details/index.js +0 -3
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +6 -6
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/index.js +4 -1
- package/build-module/index.js.map +1 -1
- package/build-module/utils/history.js +9 -3
- package/build-module/utils/history.js.map +1 -1
- package/build-style/style-rtl.css +80 -67
- package/build-style/style.css +80 -67
- package/package.json +7 -7
- package/src/components/block-editor/editor-canvas.js +2 -1
- package/src/components/layout/index.js +14 -0
- package/src/components/layout/style.scss +1 -3
- package/src/components/list/index.js +3 -1
- package/src/components/routes/link.js +9 -2
- package/src/components/save-button/index.js +2 -2
- package/src/components/save-hub/index.js +78 -0
- package/src/components/save-hub/style.scss +15 -0
- package/src/components/sidebar/index.js +2 -3
- package/src/components/sidebar/style.scss +4 -3
- package/src/components/sidebar-button/style.scss +2 -1
- package/src/components/sidebar-navigation-item/style.scss +0 -20
- package/src/components/sidebar-navigation-screen/index.js +6 -0
- package/src/components/sidebar-navigation-screen/style.scss +15 -0
- package/src/components/sidebar-navigation-screen-main/index.js +3 -0
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +141 -10
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +55 -4
- package/src/components/sidebar-navigation-screen-template/index.js +21 -7
- package/src/components/sidebar-navigation-screen-templates/index.js +7 -0
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +12 -7
- package/src/components/template-details/index.js +0 -3
- package/src/components/use-edited-entity-record/index.js +26 -18
- package/src/index.js +5 -1
- package/src/style.scss +1 -1
- package/src/utils/history.js +13 -9
- package/build/components/navigation-inspector/index.js +0 -190
- package/build/components/navigation-inspector/index.js.map +0 -1
- package/build/components/navigation-inspector/navigation-menu.js +0 -62
- package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/build-module/components/navigation-inspector/index.js +0 -173
- package/build-module/components/navigation-inspector/index.js.map +0 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
- package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/src/components/navigation-inspector/index.js +0 -223
- package/src/components/navigation-inspector/navigation-menu.js +0 -66
- package/src/components/navigation-inspector/style.scss +0 -46
|
@@ -18,7 +18,7 @@ import useSyncPathWithURL, {
|
|
|
18
18
|
} from '../sync-state-with-url/use-sync-path-with-url';
|
|
19
19
|
import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
|
|
20
20
|
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
|
|
21
|
-
import
|
|
21
|
+
import SaveHub from '../save-hub';
|
|
22
22
|
import SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';
|
|
23
23
|
import { useLocation } from '../routes';
|
|
24
24
|
|
|
@@ -61,9 +61,8 @@ function Sidebar() {
|
|
|
61
61
|
>
|
|
62
62
|
<SidebarScreens />
|
|
63
63
|
</NavigatorProvider>
|
|
64
|
-
|
|
65
64
|
<div className="edit-site-sidebar__footer">
|
|
66
|
-
<
|
|
65
|
+
<SaveHub />
|
|
67
66
|
</div>
|
|
68
67
|
</>
|
|
69
68
|
);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
.edit-site-sidebar__content {
|
|
2
2
|
flex-grow: 1;
|
|
3
3
|
overflow-y: auto;
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
.components-navigator-screen {
|
|
6
|
+
@include custom-scrollbars-on-hover;
|
|
7
|
+
}
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
.edit-site-sidebar__footer {
|
|
@@ -9,8 +12,6 @@
|
|
|
9
12
|
flex-shrink: 0;
|
|
10
13
|
margin: 0 $canvas-padding;
|
|
11
14
|
padding: $canvas-padding 0;
|
|
12
|
-
display: flex;
|
|
13
|
-
justify-content: flex-end;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
.edit-site-sidebar__content.edit-site-sidebar__content {
|
|
@@ -15,26 +15,6 @@
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
.edit-site-sidebar-navigation-screen__content .edit-site-navigation-inspector .components-button {
|
|
19
|
-
color: $gray-600;
|
|
20
|
-
&:hover,
|
|
21
|
-
&:focus,
|
|
22
|
-
&[aria-current] {
|
|
23
|
-
color: $white;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.edit-site-sidebar-navigation-screen__content .edit-site-navigation-inspector .offcanvas-editor-list-view-leaf {
|
|
28
|
-
&:hover,
|
|
29
|
-
&:focus,
|
|
30
|
-
&[aria-current] {
|
|
31
|
-
background: $gray-800;
|
|
32
|
-
}
|
|
33
|
-
.block-editor-list-view-block__menu {
|
|
34
|
-
margin-left: -$grid-unit-10;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
18
|
.edit-site-sidebar-navigation-screen__content .block-editor-list-view-block-select-button {
|
|
39
19
|
cursor: grab;
|
|
40
20
|
width: calc(100% - #{ $border-width-focus });
|
|
@@ -22,6 +22,7 @@ export default function SidebarNavigationScreen( {
|
|
|
22
22
|
title,
|
|
23
23
|
actions,
|
|
24
24
|
content,
|
|
25
|
+
description,
|
|
25
26
|
} ) {
|
|
26
27
|
const { dashboardLink } = useSelect( ( select ) => {
|
|
27
28
|
const { getSettings } = unlock( select( editSiteStore ) );
|
|
@@ -58,6 +59,11 @@ export default function SidebarNavigationScreen( {
|
|
|
58
59
|
</HStack>
|
|
59
60
|
|
|
60
61
|
<nav className="edit-site-sidebar-navigation-screen__content">
|
|
62
|
+
{ description && (
|
|
63
|
+
<p className="edit-site-sidebar-navigation-screen__description">
|
|
64
|
+
{ description }
|
|
65
|
+
</p>
|
|
66
|
+
) }
|
|
61
67
|
{ content }
|
|
62
68
|
</nav>
|
|
63
69
|
</VStack>
|
|
@@ -10,6 +10,21 @@
|
|
|
10
10
|
color: $gray-600;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.edit-site-sidebar-navigation-screen__page-link {
|
|
14
|
+
color: $gray-600;
|
|
15
|
+
|
|
16
|
+
&:hover,
|
|
17
|
+
&:focus {
|
|
18
|
+
color: $white;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.components-external-link__icon {
|
|
22
|
+
margin-left: $grid-unit-05;
|
|
23
|
+
}
|
|
24
|
+
margin-left: $grid-unit-20;
|
|
25
|
+
display: inline-block;
|
|
26
|
+
}
|
|
27
|
+
|
|
13
28
|
.edit-site-sidebar-navigation-screen__title-icon {
|
|
14
29
|
position: sticky;
|
|
15
30
|
top: 0;
|
|
@@ -31,6 +31,9 @@ export default function SidebarNavigationScreenMain() {
|
|
|
31
31
|
<SidebarNavigationScreen
|
|
32
32
|
isRoot
|
|
33
33
|
title={ __( 'Design' ) }
|
|
34
|
+
description={ __(
|
|
35
|
+
'Customize the appearance of your website using the block editor.'
|
|
36
|
+
) }
|
|
34
37
|
content={
|
|
35
38
|
<ItemGroup>
|
|
36
39
|
{ !! navigationMenus && navigationMenus.length > 0 && (
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useDispatch
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
|
+
import {
|
|
7
|
+
__experimentalUseNavigator as useNavigator,
|
|
8
|
+
ExternalLink,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { useEntityRecord } from '@wordpress/core-data';
|
|
8
11
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
12
|
import { pencil } from '@wordpress/icons';
|
|
10
13
|
|
|
@@ -21,26 +24,11 @@ export default function SidebarNavigationScreenNavigationItem() {
|
|
|
21
24
|
const {
|
|
22
25
|
params: { postType, postId },
|
|
23
26
|
} = useNavigator();
|
|
24
|
-
|
|
25
|
-
const { post } = useSelect(
|
|
26
|
-
( select ) => {
|
|
27
|
-
const { getEntityRecord } = select( coreStore );
|
|
28
|
-
|
|
29
|
-
// The currently selected entity to display.
|
|
30
|
-
// Typically template or template part in the site editor.
|
|
31
|
-
return {
|
|
32
|
-
post:
|
|
33
|
-
postId && postType
|
|
34
|
-
? getEntityRecord( 'postType', postType, postId )
|
|
35
|
-
: null,
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
[ postType, postId ]
|
|
39
|
-
);
|
|
27
|
+
const { record } = useEntityRecord( 'postType', postType, postId );
|
|
40
28
|
|
|
41
29
|
return (
|
|
42
30
|
<SidebarNavigationScreen
|
|
43
|
-
title={
|
|
31
|
+
title={ record ? decodeEntities( record?.title?.rendered ) : null }
|
|
44
32
|
actions={
|
|
45
33
|
<SidebarButton
|
|
46
34
|
onClick={ () => setCanvasMode( 'edit' ) }
|
|
@@ -48,8 +36,29 @@ export default function SidebarNavigationScreenNavigationItem() {
|
|
|
48
36
|
icon={ pencil }
|
|
49
37
|
/>
|
|
50
38
|
}
|
|
39
|
+
description={
|
|
40
|
+
postType === 'page'
|
|
41
|
+
? __(
|
|
42
|
+
'Pages are static and are not listed by date. Pages do not use tags or categories.'
|
|
43
|
+
)
|
|
44
|
+
: __(
|
|
45
|
+
'Posts are entries listed in reverse chronological order on the site homepage or on the posts page.'
|
|
46
|
+
)
|
|
47
|
+
}
|
|
51
48
|
content={
|
|
52
|
-
|
|
49
|
+
<>
|
|
50
|
+
{ record?.link ? (
|
|
51
|
+
<ExternalLink
|
|
52
|
+
className="edit-site-sidebar-navigation-screen__page-link"
|
|
53
|
+
href={ record.link }
|
|
54
|
+
>
|
|
55
|
+
{ record.link }
|
|
56
|
+
</ExternalLink>
|
|
57
|
+
) : null }
|
|
58
|
+
{ record
|
|
59
|
+
? decodeEntities( record?.description?.rendered )
|
|
60
|
+
: null }
|
|
61
|
+
</>
|
|
53
62
|
}
|
|
54
63
|
/>
|
|
55
64
|
);
|
|
@@ -2,20 +2,93 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
+
import {
|
|
9
|
+
BlockEditorProvider,
|
|
10
|
+
privateApis as blockEditorPrivateApis,
|
|
11
|
+
} from '@wordpress/block-editor';
|
|
12
|
+
import { createBlock } from '@wordpress/blocks';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* Internal dependencies
|
|
9
16
|
*/
|
|
10
17
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
11
|
-
import NavigationInspector from '../navigation-inspector';
|
|
12
18
|
import { useHistory } from '../routes';
|
|
19
|
+
import NavigationMenuContent from './navigation-menu-content';
|
|
20
|
+
import SidebarButton from '../sidebar-button';
|
|
21
|
+
import { NavigationMenuLoader } from './loader';
|
|
22
|
+
import { unlock } from '../../private-apis';
|
|
23
|
+
import { store as editSiteStore } from '../../store';
|
|
24
|
+
|
|
25
|
+
const noop = () => {};
|
|
26
|
+
const NAVIGATION_MENUS_QUERY = { per_page: -1, status: 'publish' };
|
|
27
|
+
|
|
28
|
+
function SidebarNavigationScreenWrapper( { children, actions } ) {
|
|
29
|
+
return (
|
|
30
|
+
<SidebarNavigationScreen
|
|
31
|
+
title={ __( 'Navigation' ) }
|
|
32
|
+
actions={ actions }
|
|
33
|
+
description={ __(
|
|
34
|
+
'Browse your site, edit pages, and manage your primary navigation menu.'
|
|
35
|
+
) }
|
|
36
|
+
content={ children }
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const prioritizedInserterBlocks = [
|
|
42
|
+
'core/navigation-link/page',
|
|
43
|
+
'core/navigation-link',
|
|
44
|
+
];
|
|
13
45
|
|
|
14
46
|
export default function SidebarNavigationScreenNavigationMenus() {
|
|
15
47
|
const history = useHistory();
|
|
48
|
+
const { navigationMenus, hasResolvedNavigationMenus, storedSettings } =
|
|
49
|
+
useSelect( ( select ) => {
|
|
50
|
+
const { getSettings } = unlock( select( editSiteStore ) );
|
|
51
|
+
const { getEntityRecords, hasFinishedResolution } =
|
|
52
|
+
select( coreStore );
|
|
53
|
+
|
|
54
|
+
const navigationMenusQuery = [
|
|
55
|
+
'postType',
|
|
56
|
+
'wp_navigation',
|
|
57
|
+
NAVIGATION_MENUS_QUERY,
|
|
58
|
+
];
|
|
59
|
+
return {
|
|
60
|
+
storedSettings: getSettings( false ),
|
|
61
|
+
navigationMenus: getEntityRecords( ...navigationMenusQuery ),
|
|
62
|
+
hasResolvedNavigationMenus: hasFinishedResolution(
|
|
63
|
+
'getEntityRecords',
|
|
64
|
+
navigationMenusQuery
|
|
65
|
+
),
|
|
66
|
+
};
|
|
67
|
+
}, [] );
|
|
68
|
+
|
|
69
|
+
// Sort navigation menus by date.
|
|
70
|
+
const orderedNavigationMenus = useMemo(
|
|
71
|
+
() =>
|
|
72
|
+
navigationMenus?.sort( ( menuA, menuB ) => {
|
|
73
|
+
const menuADate = new Date( menuA.date );
|
|
74
|
+
const menuBDate = new Date( menuB.date );
|
|
75
|
+
return menuADate.getTime() > menuBDate.getTime();
|
|
76
|
+
} ),
|
|
77
|
+
[ navigationMenus ]
|
|
78
|
+
);
|
|
79
|
+
const firstNavigationMenu = orderedNavigationMenus?.[ 0 ]?.id;
|
|
80
|
+
const blocks = useMemo( () => {
|
|
81
|
+
return [
|
|
82
|
+
createBlock( 'core/navigation', { ref: firstNavigationMenu } ),
|
|
83
|
+
];
|
|
84
|
+
}, [ firstNavigationMenu ] );
|
|
85
|
+
|
|
86
|
+
const isLoading = ! hasResolvedNavigationMenus;
|
|
87
|
+
const hasNavigationMenus = !! navigationMenus?.length;
|
|
88
|
+
|
|
16
89
|
const onSelect = useCallback(
|
|
17
90
|
( selectedBlock ) => {
|
|
18
|
-
const { attributes } = selectedBlock;
|
|
91
|
+
const { attributes, name } = selectedBlock;
|
|
19
92
|
if (
|
|
20
93
|
attributes.kind === 'post-type' &&
|
|
21
94
|
attributes.id &&
|
|
@@ -27,17 +100,75 @@ export default function SidebarNavigationScreenNavigationMenus() {
|
|
|
27
100
|
postId: attributes.id,
|
|
28
101
|
} );
|
|
29
102
|
}
|
|
103
|
+
if ( name === 'core/page-list-item' && attributes.id && history ) {
|
|
104
|
+
history.push( {
|
|
105
|
+
postType: 'page',
|
|
106
|
+
postId: attributes.id,
|
|
107
|
+
} );
|
|
108
|
+
}
|
|
30
109
|
},
|
|
31
110
|
[ history ]
|
|
32
111
|
);
|
|
112
|
+
const orderInitialBlockItems = useCallback( ( items ) => {
|
|
113
|
+
items.sort( ( { id: aName }, { id: bName } ) => {
|
|
114
|
+
// Sort block items according to `prioritizedInserterBlocks`.
|
|
115
|
+
let aIndex = prioritizedInserterBlocks.indexOf( aName );
|
|
116
|
+
let bIndex = prioritizedInserterBlocks.indexOf( bName );
|
|
117
|
+
// All other block items should come after that.
|
|
118
|
+
if ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;
|
|
119
|
+
if ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;
|
|
120
|
+
return aIndex - bIndex;
|
|
121
|
+
} );
|
|
122
|
+
return items;
|
|
123
|
+
}, [] );
|
|
124
|
+
|
|
125
|
+
if ( hasResolvedNavigationMenus && ! hasNavigationMenus ) {
|
|
126
|
+
return (
|
|
127
|
+
<SidebarNavigationScreenWrapper>
|
|
128
|
+
{ __( 'There are no Navigation Menus.' ) }
|
|
129
|
+
</SidebarNavigationScreenWrapper>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if ( ! hasResolvedNavigationMenus || isLoading ) {
|
|
134
|
+
return (
|
|
135
|
+
<SidebarNavigationScreenWrapper>
|
|
136
|
+
<NavigationMenuLoader />
|
|
137
|
+
</SidebarNavigationScreenWrapper>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
const { PrivateInserter } = unlock( blockEditorPrivateApis );
|
|
33
141
|
return (
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
142
|
+
<BlockEditorProvider
|
|
143
|
+
settings={ storedSettings }
|
|
144
|
+
value={ blocks }
|
|
145
|
+
onChange={ noop }
|
|
146
|
+
onInput={ noop }
|
|
147
|
+
>
|
|
148
|
+
<SidebarNavigationScreenWrapper
|
|
149
|
+
actions={
|
|
150
|
+
<PrivateInserter
|
|
151
|
+
rootClientId={ blocks[ 0 ].clientId }
|
|
152
|
+
position="bottom right"
|
|
153
|
+
isAppender
|
|
154
|
+
selectBlockOnInsert={ false }
|
|
155
|
+
shouldDirectInsert={ false }
|
|
156
|
+
__experimentalIsQuick
|
|
157
|
+
toggleProps={ {
|
|
158
|
+
as: SidebarButton,
|
|
159
|
+
label: __( 'Add menu item' ),
|
|
160
|
+
} }
|
|
161
|
+
orderInitialBlockItems={ orderInitialBlockItems }
|
|
162
|
+
/>
|
|
163
|
+
}
|
|
164
|
+
>
|
|
165
|
+
<div className="edit-site-sidebar-navigation-screen-navigation-menus__content">
|
|
166
|
+
<NavigationMenuContent
|
|
167
|
+
rootClientId={ blocks[ 0 ].clientId }
|
|
168
|
+
onSelect={ onSelect }
|
|
169
|
+
/>
|
|
39
170
|
</div>
|
|
40
|
-
|
|
41
|
-
|
|
171
|
+
</SidebarNavigationScreenWrapper>
|
|
172
|
+
</BlockEditorProvider>
|
|
42
173
|
);
|
|
43
174
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function NavigationMenuLoader() {
|
|
2
|
+
return (
|
|
3
|
+
<>
|
|
4
|
+
<div className="edit-site-sidebar-navigation-screen-navigation-menus__placeholder" />
|
|
5
|
+
<div className="edit-site-sidebar-navigation-screen-navigation-menus__placeholder" />
|
|
6
|
+
<div className="edit-site-sidebar-navigation-screen-navigation-menus__placeholder" />
|
|
7
|
+
</>
|
|
8
|
+
);
|
|
9
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
privateApis as blockEditorPrivateApis,
|
|
6
|
+
store as blockEditorStore,
|
|
7
|
+
BlockList,
|
|
8
|
+
BlockTools,
|
|
9
|
+
} from '@wordpress/block-editor';
|
|
10
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
+
import { createBlock } from '@wordpress/blocks';
|
|
12
|
+
import { useCallback } from '@wordpress/element';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { unlock } from '../../private-apis';
|
|
18
|
+
import { NavigationMenuLoader } from './loader';
|
|
19
|
+
|
|
20
|
+
export default function NavigationMenuContent( { rootClientId, onSelect } ) {
|
|
21
|
+
const { clientIdsTree, isLoading } = useSelect(
|
|
22
|
+
( select ) => {
|
|
23
|
+
const { __unstableGetClientIdsTree, areInnerBlocksControlled } =
|
|
24
|
+
select( blockEditorStore );
|
|
25
|
+
return {
|
|
26
|
+
clientIdsTree: __unstableGetClientIdsTree( rootClientId ),
|
|
27
|
+
|
|
28
|
+
// This is a small hack to wait for the navigation block
|
|
29
|
+
// to actually load its inner blocks.
|
|
30
|
+
isLoading: ! areInnerBlocksControlled( rootClientId ),
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
[ rootClientId ]
|
|
34
|
+
);
|
|
35
|
+
const { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =
|
|
36
|
+
useDispatch( blockEditorStore );
|
|
37
|
+
|
|
38
|
+
const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
|
|
39
|
+
|
|
40
|
+
const offCanvasOnselect = useCallback(
|
|
41
|
+
( block ) => {
|
|
42
|
+
if (
|
|
43
|
+
block.name === 'core/navigation-link' &&
|
|
44
|
+
! block.attributes.url
|
|
45
|
+
) {
|
|
46
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
47
|
+
replaceBlock(
|
|
48
|
+
block.clientId,
|
|
49
|
+
createBlock( 'core/navigation-link', block.attributes )
|
|
50
|
+
);
|
|
51
|
+
} else {
|
|
52
|
+
onSelect( block );
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
[ onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock ]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// The hidden block is needed because it makes block edit side effects trigger.
|
|
59
|
+
// For example a navigation page list load its items has an effect on edit to load its items.
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{ isLoading && <NavigationMenuLoader /> }
|
|
63
|
+
{ ! isLoading && (
|
|
64
|
+
<OffCanvasEditor
|
|
65
|
+
blocks={ clientIdsTree }
|
|
66
|
+
onSelect={ offCanvasOnselect }
|
|
67
|
+
LeafMoreMenu={ LeafMoreMenu }
|
|
68
|
+
showAppender={ false }
|
|
69
|
+
/>
|
|
70
|
+
) }
|
|
71
|
+
<div style={ { visibility: 'hidden' } }>
|
|
72
|
+
<BlockTools>
|
|
73
|
+
<BlockList />
|
|
74
|
+
</BlockTools>
|
|
75
|
+
</div>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -1,12 +1,63 @@
|
|
|
1
|
-
.edit-site-sidebar-navigation-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
.edit-site-sidebar-navigation-screen__description {
|
|
2
|
+
margin: 0 0 $grid-unit-40 $grid-unit-20;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.edit-site-sidebar-navigation-screen-navigation-menus__placeholder {
|
|
6
|
+
padding: $grid-unit-10;
|
|
7
|
+
margin: $grid-unit-10;
|
|
8
|
+
background-color: $gray-100;
|
|
9
|
+
animation: loadingpulse 1s linear infinite;
|
|
10
|
+
animation-delay: 0.5s; // avoid animating for fast network responses
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@keyframes loadingpulse {
|
|
14
|
+
0% {
|
|
15
|
+
opacity: 1;
|
|
16
|
+
}
|
|
17
|
+
50% {
|
|
18
|
+
opacity: 0.5;
|
|
5
19
|
}
|
|
20
|
+
100% {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.edit-site-sidebar-navigation-screen-navigation-menus__content {
|
|
6
26
|
.offcanvas-editor-list-view-leaf {
|
|
7
27
|
max-width: calc(100% - #{ $grid-unit-05 });
|
|
28
|
+
border-radius: $radius-block-ui;
|
|
29
|
+
&:hover,
|
|
30
|
+
&:focus,
|
|
31
|
+
&[aria-current] {
|
|
32
|
+
background: $gray-800;
|
|
33
|
+
}
|
|
34
|
+
.block-editor-list-view-block__menu {
|
|
35
|
+
margin-left: -$grid-unit-10;
|
|
36
|
+
}
|
|
8
37
|
}
|
|
38
|
+
|
|
9
39
|
.block-editor-list-view-leaf .block-editor-list-view-block__contents-cell {
|
|
10
40
|
width: 100%;
|
|
11
41
|
}
|
|
42
|
+
|
|
43
|
+
.block-editor-list-view-leaf .block-editor-list-view-block-contents {
|
|
44
|
+
white-space: normal;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.block-editor-list-view-block__title {
|
|
48
|
+
margin-top: 3px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.block-editor-list-view-block__menu-cell {
|
|
52
|
+
padding-right: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.components-button {
|
|
56
|
+
color: $gray-600;
|
|
57
|
+
&:hover,
|
|
58
|
+
&:focus,
|
|
59
|
+
&[aria-current] {
|
|
60
|
+
color: $white;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
12
63
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { useDispatch } from '@wordpress/data';
|
|
6
6
|
import { pencil } from '@wordpress/icons';
|
|
7
|
+
import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
@@ -15,13 +16,26 @@ import { store as editSiteStore } from '../../store';
|
|
|
15
16
|
import SidebarButton from '../sidebar-button';
|
|
16
17
|
|
|
17
18
|
export default function SidebarNavigationScreenTemplate() {
|
|
19
|
+
const { params } = useNavigator();
|
|
20
|
+
const { postType, postId } = params;
|
|
18
21
|
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
|
|
19
|
-
const { getDescription, getTitle, record } = useEditedEntityRecord(
|
|
22
|
+
const { getDescription, getTitle, record } = useEditedEntityRecord(
|
|
23
|
+
postType,
|
|
24
|
+
postId
|
|
25
|
+
);
|
|
20
26
|
let description = getDescription();
|
|
21
|
-
if ( ! description
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
if ( ! description ) {
|
|
28
|
+
if ( record.type === 'wp_template' && record.is_custom ) {
|
|
29
|
+
description = __(
|
|
30
|
+
'This is a custom template that can be applied manually to any Post or Page.'
|
|
31
|
+
);
|
|
32
|
+
} else if ( record.type === 'wp_template_part' ) {
|
|
33
|
+
description = sprintf(
|
|
34
|
+
// translators: %s: template part title e.g: "Header".
|
|
35
|
+
__( 'This is your %s template part.' ),
|
|
36
|
+
getTitle()
|
|
37
|
+
);
|
|
38
|
+
}
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
return (
|
|
@@ -34,7 +48,7 @@ export default function SidebarNavigationScreenTemplate() {
|
|
|
34
48
|
icon={ pencil }
|
|
35
49
|
/>
|
|
36
50
|
}
|
|
37
|
-
|
|
51
|
+
description={ description }
|
|
38
52
|
/>
|
|
39
53
|
);
|
|
40
54
|
}
|
|
@@ -29,6 +29,9 @@ const config = {
|
|
|
29
29
|
loading: __( 'Loading templates' ),
|
|
30
30
|
notFound: __( 'No templates found' ),
|
|
31
31
|
manage: __( 'Manage all templates' ),
|
|
32
|
+
description: __(
|
|
33
|
+
'Express the layout of your site with templates.'
|
|
34
|
+
),
|
|
32
35
|
},
|
|
33
36
|
},
|
|
34
37
|
wp_template_part: {
|
|
@@ -37,6 +40,9 @@ const config = {
|
|
|
37
40
|
loading: __( 'Loading template parts' ),
|
|
38
41
|
notFound: __( 'No template parts found' ),
|
|
39
42
|
manage: __( 'Manage all template parts' ),
|
|
43
|
+
description: __(
|
|
44
|
+
'Template Parts are small pieces of a layout that can be reused across multiple templates and always appear the same way. Common template parts include the site header, footer, or sidebar.'
|
|
45
|
+
),
|
|
40
46
|
},
|
|
41
47
|
},
|
|
42
48
|
};
|
|
@@ -80,6 +86,7 @@ export default function SidebarNavigationScreenTemplates() {
|
|
|
80
86
|
<SidebarNavigationScreen
|
|
81
87
|
isRoot={ isTemplatePartsMode }
|
|
82
88
|
title={ config[ postType ].labels.title }
|
|
89
|
+
description={ config[ postType ].labels.description }
|
|
83
90
|
actions={
|
|
84
91
|
canCreate && (
|
|
85
92
|
<AddNewTemplate
|
|
@@ -12,9 +12,15 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
12
12
|
const config = {
|
|
13
13
|
wp_template: {
|
|
14
14
|
title: __( 'All templates' ),
|
|
15
|
+
description: __(
|
|
16
|
+
'Create new templates, or reset any customizations made to the templates supplied by your theme.'
|
|
17
|
+
),
|
|
15
18
|
},
|
|
16
19
|
wp_template_part: {
|
|
17
20
|
title: __( 'All template parts' ),
|
|
21
|
+
description: __(
|
|
22
|
+
'Create new template parts, or reset any customisations made to the template parts supplied by your theme.'
|
|
23
|
+
),
|
|
18
24
|
},
|
|
19
25
|
};
|
|
20
26
|
|
|
@@ -22,5 +28,10 @@ export default function SidebarNavigationScreenTemplatesBrowse() {
|
|
|
22
28
|
const {
|
|
23
29
|
params: { postType },
|
|
24
30
|
} = useNavigator();
|
|
25
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
<SidebarNavigationScreen
|
|
33
|
+
title={ config[ postType ].title }
|
|
34
|
+
description={ config[ postType ].description }
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
26
37
|
}
|