@wordpress/edit-site 5.5.0 → 5.6.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/CHANGELOG.md +2 -0
- package/build/components/add-new-template/new-template.js +16 -10
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +4 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +2 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +2 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +20 -159
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +2 -3
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/hooks.js +11 -26
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +2 -3
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-border.js +13 -5
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -1
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -1
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/layout/index.js +7 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +128 -136
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/index.js +2 -1
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +6 -5
- package/build/components/list/table.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 +13 -13
- 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 +87 -10
- 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 +59 -10
- 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/site-hub/index.js +3 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +134 -19
- package/build/components/style-book/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/template-part-converter/convert-to-regular.js +8 -12
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +2 -2
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/components/template-part-converter/index.js +19 -14
- package/build/components/template-part-converter/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/add-new-template/new-template.js +18 -11
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +3 -2
- package/build-module/components/app/index.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/editor/index.js +2 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +21 -157
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +2 -2
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +11 -26
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +2 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +11 -2
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +2 -1
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -1
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/layout/index.js +7 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +126 -137
- package/build-module/components/list/added-by.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/list/table.js +6 -5
- package/build-module/components/list/table.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 +13 -13
- 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 +81 -10
- 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 +60 -13
- 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/site-hub/index.js +3 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +135 -22
- package/build-module/components/style-book/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/template-part-converter/convert-to-regular.js +9 -13
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +20 -15
- package/build-module/components/template-part-converter/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 +168 -111
- package/build-style/style.css +168 -111
- package/package.json +31 -31
- package/src/components/add-new-template/new-template.js +57 -32
- package/src/components/add-new-template/style.scss +12 -1
- package/src/components/app/index.js +9 -6
- package/src/components/block-editor/editor-canvas.js +2 -1
- package/src/components/editor/index.js +61 -65
- package/src/components/global-styles/border-panel.js +24 -199
- package/src/components/global-styles/context-menu.js +2 -2
- package/src/components/global-styles/hooks.js +12 -36
- package/src/components/global-styles/screen-block-list.js +2 -2
- package/src/components/global-styles/screen-border.js +9 -2
- package/src/components/global-styles/screen-root.js +1 -1
- package/src/components/global-styles/screen-style-variations.js +5 -1
- package/src/components/global-styles/style.scss +10 -0
- package/src/components/layout/index.js +15 -0
- package/src/components/layout/style.scss +1 -3
- package/src/components/list/added-by.js +144 -140
- package/src/components/list/index.js +3 -1
- package/src/components/list/table.js +7 -4
- 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 +1 -23
- 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 +21 -8
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +92 -9
- 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 +108 -1
- package/src/components/sidebar-navigation-screen-template/index.js +82 -11
- package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
- 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/site-hub/index.js +5 -1
- package/src/components/site-hub/style.scss +5 -1
- package/src/components/style-book/index.js +209 -54
- package/src/components/style-book/style.scss +1 -45
- 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/template-part-converter/convert-to-regular.js +10 -17
- package/src/components/template-part-converter/convert-to-template-part.js +9 -16
- package/src/components/template-part-converter/index.js +28 -12
- package/src/components/use-edited-entity-record/index.js +26 -18
- package/src/index.js +5 -1
- package/src/store/test/actions.js +0 -2
- package/src/style.scss +2 -1
- package/src/utils/history.js +13 -9
- package/build/components/navigation-inspector/index.js +0 -161
- package/build/components/navigation-inspector/index.js.map +0 -1
- package/build/components/navigation-inspector/navigation-menu.js +0 -79
- package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/build-module/components/navigation-inspector/index.js +0 -146
- package/build-module/components/navigation-inspector/index.js.map +0 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +0 -69
- package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
- package/src/components/navigation-inspector/index.js +0 -191
- package/src/components/navigation-inspector/navigation-menu.js +0 -84
- package/src/components/navigation-inspector/style.scss +0 -46
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
6
|
-
import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
|
|
7
|
-
import {
|
|
8
|
-
store as blockEditorStore,
|
|
9
|
-
BlockEditorProvider,
|
|
10
|
-
} from '@wordpress/block-editor';
|
|
11
|
-
import { speak } from '@wordpress/a11y';
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import NavigationMenu from './navigation-menu';
|
|
18
|
-
|
|
19
|
-
const NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];
|
|
20
|
-
|
|
21
|
-
export default function NavigationInspector( { onSelect } ) {
|
|
22
|
-
const {
|
|
23
|
-
selectedNavigationBlockId,
|
|
24
|
-
clientIdToRef,
|
|
25
|
-
navigationMenus,
|
|
26
|
-
isResolvingNavigationMenus,
|
|
27
|
-
hasResolvedNavigationMenus,
|
|
28
|
-
firstNavigationBlockId,
|
|
29
|
-
} = useSelect( ( select ) => {
|
|
30
|
-
const {
|
|
31
|
-
__experimentalGetActiveBlockIdByBlockNames,
|
|
32
|
-
__experimentalGetGlobalBlocksByName,
|
|
33
|
-
getBlock,
|
|
34
|
-
} = select( blockEditorStore );
|
|
35
|
-
|
|
36
|
-
const { getEntityRecords, hasFinishedResolution, isResolving } =
|
|
37
|
-
select( coreStore );
|
|
38
|
-
|
|
39
|
-
const navigationMenusQuery = [
|
|
40
|
-
'postType',
|
|
41
|
-
'wp_navigation',
|
|
42
|
-
NAVIGATION_MENUS_QUERY[ 0 ],
|
|
43
|
-
];
|
|
44
|
-
|
|
45
|
-
// Get the active Navigation block (if present).
|
|
46
|
-
const selectedNavId =
|
|
47
|
-
__experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );
|
|
48
|
-
|
|
49
|
-
// Get all Navigation blocks currently within the editor canvas.
|
|
50
|
-
const navBlockIds =
|
|
51
|
-
__experimentalGetGlobalBlocksByName( 'core/navigation' );
|
|
52
|
-
const idToRef = {};
|
|
53
|
-
navBlockIds.forEach( ( id ) => {
|
|
54
|
-
idToRef[ id ] = getBlock( id )?.attributes?.ref;
|
|
55
|
-
} );
|
|
56
|
-
return {
|
|
57
|
-
selectedNavigationBlockId: selectedNavId,
|
|
58
|
-
firstNavigationBlockId: navBlockIds?.[ 0 ],
|
|
59
|
-
clientIdToRef: idToRef,
|
|
60
|
-
navigationMenus: getEntityRecords( ...navigationMenusQuery ),
|
|
61
|
-
isResolvingNavigationMenus: isResolving(
|
|
62
|
-
'getEntityRecords',
|
|
63
|
-
navigationMenusQuery
|
|
64
|
-
),
|
|
65
|
-
hasResolvedNavigationMenus: hasFinishedResolution(
|
|
66
|
-
'getEntityRecords',
|
|
67
|
-
navigationMenusQuery
|
|
68
|
-
),
|
|
69
|
-
};
|
|
70
|
-
}, [] );
|
|
71
|
-
|
|
72
|
-
const firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];
|
|
73
|
-
const firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;
|
|
74
|
-
|
|
75
|
-
// Default Navigation Menu is either:
|
|
76
|
-
// - the Navigation Menu referenced by the first Nav block within the template.
|
|
77
|
-
// - the first of the available Navigation Menus (`wp_navigation`) posts.
|
|
78
|
-
const defaultNavigationMenuId =
|
|
79
|
-
firstNavRefInTemplate || firstNavigationMenuRef;
|
|
80
|
-
|
|
81
|
-
// The Navigation Menu manually selected by the user within the Nav inspector.
|
|
82
|
-
const [ currentMenuId, setCurrentMenuId ] = useState(
|
|
83
|
-
firstNavRefInTemplate
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// If a Nav block is selected within the canvas then set the
|
|
87
|
-
// Navigation Menu referenced by it's `ref` attribute to be
|
|
88
|
-
// active within the Navigation sidebar.
|
|
89
|
-
useEffect( () => {
|
|
90
|
-
if ( selectedNavigationBlockId ) {
|
|
91
|
-
setCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );
|
|
92
|
-
}
|
|
93
|
-
}, [ selectedNavigationBlockId ] );
|
|
94
|
-
|
|
95
|
-
const [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(
|
|
96
|
-
'postType',
|
|
97
|
-
'wp_navigation',
|
|
98
|
-
{ id: currentMenuId || defaultNavigationMenuId }
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(
|
|
102
|
-
( select ) => {
|
|
103
|
-
const { isResolving, hasFinishedResolution } = select( coreStore );
|
|
104
|
-
return {
|
|
105
|
-
isLoadingInnerBlocks: isResolving( 'getEntityRecord', [
|
|
106
|
-
'postType',
|
|
107
|
-
'wp_navigation',
|
|
108
|
-
currentMenuId || defaultNavigationMenuId,
|
|
109
|
-
] ),
|
|
110
|
-
hasLoadedInnerBlocks: hasFinishedResolution(
|
|
111
|
-
'getEntityRecord',
|
|
112
|
-
[
|
|
113
|
-
'postType',
|
|
114
|
-
'wp_navigation',
|
|
115
|
-
currentMenuId || defaultNavigationMenuId,
|
|
116
|
-
]
|
|
117
|
-
),
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
[ currentMenuId, defaultNavigationMenuId ]
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );
|
|
124
|
-
|
|
125
|
-
const hasNavigationMenus = !! navigationMenus?.length;
|
|
126
|
-
|
|
127
|
-
// Entity block editor will return entities that are not currently published.
|
|
128
|
-
// Guard by only allowing their usage if there are published Nav Menus.
|
|
129
|
-
const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
|
|
130
|
-
|
|
131
|
-
const hasInnerBlocks = !! publishedInnerBlocks?.length;
|
|
132
|
-
|
|
133
|
-
useEffect( () => {
|
|
134
|
-
if ( isResolvingNavigationMenus ) {
|
|
135
|
-
speak( 'Loading Navigation sidebar menus.' );
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if ( hasResolvedNavigationMenus ) {
|
|
139
|
-
speak( 'Navigation sidebar menus have loaded.' );
|
|
140
|
-
}
|
|
141
|
-
}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );
|
|
142
|
-
|
|
143
|
-
useEffect( () => {
|
|
144
|
-
if ( isLoadingInnerBlocks ) {
|
|
145
|
-
speak( 'Loading Navigation sidebar selected menu items.' );
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if ( hasLoadedInnerBlocks ) {
|
|
149
|
-
speak( 'Navigation sidebar selected menu items have loaded.' );
|
|
150
|
-
}
|
|
151
|
-
}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<div className="edit-site-navigation-inspector">
|
|
155
|
-
{ hasResolvedNavigationMenus && ! hasNavigationMenus && (
|
|
156
|
-
<p className="edit-site-navigation-inspector__empty-msg">
|
|
157
|
-
{ __( 'There are no Navigation Menus.' ) }
|
|
158
|
-
</p>
|
|
159
|
-
) }
|
|
160
|
-
|
|
161
|
-
{ ! hasResolvedNavigationMenus && (
|
|
162
|
-
<div className="edit-site-navigation-inspector__placeholder" />
|
|
163
|
-
) }
|
|
164
|
-
{ isLoading && (
|
|
165
|
-
<>
|
|
166
|
-
<div className="edit-site-navigation-inspector__placeholder is-child" />
|
|
167
|
-
<div className="edit-site-navigation-inspector__placeholder is-child" />
|
|
168
|
-
<div className="edit-site-navigation-inspector__placeholder is-child" />
|
|
169
|
-
</>
|
|
170
|
-
) }
|
|
171
|
-
{ hasInnerBlocks && ! isLoading && (
|
|
172
|
-
<BlockEditorProvider
|
|
173
|
-
value={ publishedInnerBlocks }
|
|
174
|
-
onChange={ onChange }
|
|
175
|
-
onInput={ onInput }
|
|
176
|
-
>
|
|
177
|
-
<NavigationMenu
|
|
178
|
-
innerBlocks={ publishedInnerBlocks }
|
|
179
|
-
onSelect={ onSelect }
|
|
180
|
-
/>
|
|
181
|
-
</BlockEditorProvider>
|
|
182
|
-
) }
|
|
183
|
-
|
|
184
|
-
{ ! hasInnerBlocks && ! isLoading && (
|
|
185
|
-
<p className="edit-site-navigation-inspector__empty-msg">
|
|
186
|
-
{ __( 'Navigation Menu is empty.' ) }
|
|
187
|
-
</p>
|
|
188
|
-
) }
|
|
189
|
-
</div>
|
|
190
|
-
);
|
|
191
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
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 { useEffect } from '@wordpress/element';
|
|
11
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { unlock } from '../../private-apis';
|
|
17
|
-
|
|
18
|
-
const ALLOWED_BLOCKS = {
|
|
19
|
-
'core/navigation': [
|
|
20
|
-
'core/navigation-link',
|
|
21
|
-
'core/search',
|
|
22
|
-
'core/social-links',
|
|
23
|
-
'core/page-list',
|
|
24
|
-
'core/spacer',
|
|
25
|
-
'core/home-link',
|
|
26
|
-
'core/site-title',
|
|
27
|
-
'core/site-logo',
|
|
28
|
-
'core/navigation-submenu',
|
|
29
|
-
],
|
|
30
|
-
'core/social-links': [ 'core/social-link' ],
|
|
31
|
-
'core/navigation-submenu': [
|
|
32
|
-
'core/navigation-link',
|
|
33
|
-
'core/navigation-submenu',
|
|
34
|
-
],
|
|
35
|
-
'core/navigation-link': [
|
|
36
|
-
'core/navigation-link',
|
|
37
|
-
'core/navigation-submenu',
|
|
38
|
-
],
|
|
39
|
-
'core/page-list': [ 'core/page-list-item' ],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default function NavigationMenu( { innerBlocks, onSelect } ) {
|
|
43
|
-
const { clientIdsTree } = useSelect( ( select ) => {
|
|
44
|
-
const { __unstableGetClientIdsTree } = select( blockEditorStore );
|
|
45
|
-
return {
|
|
46
|
-
clientIdsTree: __unstableGetClientIdsTree(),
|
|
47
|
-
};
|
|
48
|
-
} );
|
|
49
|
-
const { updateBlockListSettings } = useDispatch( blockEditorStore );
|
|
50
|
-
|
|
51
|
-
const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
|
|
52
|
-
|
|
53
|
-
//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
|
|
54
|
-
//Think through a better way of doing this, possible with adding allowed blocks to block library metadata
|
|
55
|
-
useEffect( () => {
|
|
56
|
-
updateBlockListSettings( '', {
|
|
57
|
-
allowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],
|
|
58
|
-
} );
|
|
59
|
-
innerBlocks.forEach( ( block ) => {
|
|
60
|
-
if ( ALLOWED_BLOCKS[ block.name ] ) {
|
|
61
|
-
updateBlockListSettings( block.clientId, {
|
|
62
|
-
allowedBlocks: ALLOWED_BLOCKS[ block.name ],
|
|
63
|
-
} );
|
|
64
|
-
}
|
|
65
|
-
} );
|
|
66
|
-
}, [ updateBlockListSettings, innerBlocks ] );
|
|
67
|
-
|
|
68
|
-
// The hidden block is needed because it makes block edit side effects trigger.
|
|
69
|
-
// For example a navigation page list load its items has an effect on edit to load its items.
|
|
70
|
-
return (
|
|
71
|
-
<>
|
|
72
|
-
<OffCanvasEditor
|
|
73
|
-
blocks={ clientIdsTree }
|
|
74
|
-
onSelect={ onSelect }
|
|
75
|
-
LeafMoreMenu={ LeafMoreMenu }
|
|
76
|
-
/>
|
|
77
|
-
<div style={ { display: 'none' } }>
|
|
78
|
-
<BlockTools>
|
|
79
|
-
<BlockList />
|
|
80
|
-
</BlockTools>
|
|
81
|
-
</div>
|
|
82
|
-
</>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
@keyframes loadingpulse {
|
|
2
|
-
0% {
|
|
3
|
-
opacity: 1;
|
|
4
|
-
}
|
|
5
|
-
50% {
|
|
6
|
-
opacity: 0.5;
|
|
7
|
-
}
|
|
8
|
-
100% {
|
|
9
|
-
opacity: 1;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.edit-site-navigation-inspector {
|
|
14
|
-
.block-editor-list-view-leaf .block-editor-list-view-block-contents {
|
|
15
|
-
white-space: normal;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.block-editor-list-view-block__title {
|
|
19
|
-
margin-top: 3px;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.block-editor-list-view-block__menu-cell {
|
|
23
|
-
padding-right: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.edit-site-navigation-inspector__select-menu {
|
|
27
|
-
margin-bottom: $grid-unit-10;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.edit-site-navigation-inspector__placeholder {
|
|
32
|
-
padding: $grid-unit-10;
|
|
33
|
-
margin: $grid-unit-10;
|
|
34
|
-
background-color: $gray-100;
|
|
35
|
-
animation: loadingpulse 1s linear infinite;
|
|
36
|
-
animation-delay: 0.5s; // avoid animating for fast network responses
|
|
37
|
-
|
|
38
|
-
&.is-child {
|
|
39
|
-
margin-left: $grid-unit-30;
|
|
40
|
-
width: 50%;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.edit-site-navigation-inspector__empty-msg {
|
|
45
|
-
padding: 0 $grid-unit-10;
|
|
46
|
-
}
|