@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.
Files changed (132) hide show
  1. package/build/components/block-editor/editor-canvas.js +2 -1
  2. package/build/components/block-editor/editor-canvas.js.map +1 -1
  3. package/build/components/layout/index.js +6 -0
  4. package/build/components/layout/index.js.map +1 -1
  5. package/build/components/list/index.js +2 -1
  6. package/build/components/list/index.js.map +1 -1
  7. package/build/components/routes/link.js +4 -1
  8. package/build/components/routes/link.js.map +1 -1
  9. package/build/components/save-button/index.js +2 -5
  10. package/build/components/save-button/index.js.map +1 -1
  11. package/build/components/save-hub/index.js +82 -0
  12. package/build/components/save-hub/index.js.map +1 -0
  13. package/build/components/sidebar/index.js +2 -4
  14. package/build/components/sidebar/index.js.map +1 -1
  15. package/build/components/sidebar-navigation-screen/index.js +5 -2
  16. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  17. package/build/components/sidebar-navigation-screen-main/index.js +1 -0
  18. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  19. package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -14
  20. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  21. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +139 -11
  22. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  23. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  24. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  25. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  26. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  27. package/build/components/sidebar-navigation-screen-template/index.js +18 -4
  28. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  29. package/build/components/sidebar-navigation-screen-templates/index.js +5 -2
  30. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  31. package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  32. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  33. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  34. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  35. package/build/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  36. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  37. package/build/components/template-details/index.js +0 -3
  38. package/build/components/template-details/index.js.map +1 -1
  39. package/build/components/use-edited-entity-record/index.js +6 -6
  40. package/build/components/use-edited-entity-record/index.js.map +1 -1
  41. package/build/index.js +3 -0
  42. package/build/index.js.map +1 -1
  43. package/build/utils/history.js +8 -2
  44. package/build/utils/history.js.map +1 -1
  45. package/build-module/components/block-editor/editor-canvas.js +2 -1
  46. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  47. package/build-module/components/layout/index.js +6 -0
  48. package/build-module/components/layout/index.js.map +1 -1
  49. package/build-module/components/list/index.js +2 -1
  50. package/build-module/components/list/index.js.map +1 -1
  51. package/build-module/components/routes/link.js +5 -2
  52. package/build-module/components/routes/link.js.map +1 -1
  53. package/build-module/components/save-button/index.js +2 -5
  54. package/build-module/components/save-button/index.js.map +1 -1
  55. package/build-module/components/save-hub/index.js +68 -0
  56. package/build-module/components/save-hub/index.js.map +1 -0
  57. package/build-module/components/sidebar/index.js +2 -4
  58. package/build-module/components/sidebar/index.js.map +1 -1
  59. package/build-module/components/sidebar-navigation-screen/index.js +5 -2
  60. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  61. package/build-module/components/sidebar-navigation-screen-main/index.js +1 -0
  62. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  63. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +13 -18
  64. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  65. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +131 -11
  66. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  67. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  68. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  69. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  70. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  71. package/build-module/components/sidebar-navigation-screen-template/index.js +18 -5
  72. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  73. package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -2
  74. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  75. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  76. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  77. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  78. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  79. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  80. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  81. package/build-module/components/template-details/index.js +0 -3
  82. package/build-module/components/template-details/index.js.map +1 -1
  83. package/build-module/components/use-edited-entity-record/index.js +6 -6
  84. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  85. package/build-module/index.js +4 -1
  86. package/build-module/index.js.map +1 -1
  87. package/build-module/utils/history.js +9 -3
  88. package/build-module/utils/history.js.map +1 -1
  89. package/build-style/style-rtl.css +80 -67
  90. package/build-style/style.css +80 -67
  91. package/package.json +7 -7
  92. package/src/components/block-editor/editor-canvas.js +2 -1
  93. package/src/components/layout/index.js +14 -0
  94. package/src/components/layout/style.scss +1 -3
  95. package/src/components/list/index.js +3 -1
  96. package/src/components/routes/link.js +9 -2
  97. package/src/components/save-button/index.js +2 -2
  98. package/src/components/save-hub/index.js +78 -0
  99. package/src/components/save-hub/style.scss +15 -0
  100. package/src/components/sidebar/index.js +2 -3
  101. package/src/components/sidebar/style.scss +4 -3
  102. package/src/components/sidebar-button/style.scss +2 -1
  103. package/src/components/sidebar-navigation-item/style.scss +0 -20
  104. package/src/components/sidebar-navigation-screen/index.js +6 -0
  105. package/src/components/sidebar-navigation-screen/style.scss +15 -0
  106. package/src/components/sidebar-navigation-screen-main/index.js +3 -0
  107. package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
  108. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +141 -10
  109. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  110. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  111. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +55 -4
  112. package/src/components/sidebar-navigation-screen-template/index.js +21 -7
  113. package/src/components/sidebar-navigation-screen-templates/index.js +7 -0
  114. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
  115. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  116. package/src/components/sync-state-with-url/use-sync-path-with-url.js +12 -7
  117. package/src/components/template-details/index.js +0 -3
  118. package/src/components/use-edited-entity-record/index.js +26 -18
  119. package/src/index.js +5 -1
  120. package/src/style.scss +1 -1
  121. package/src/utils/history.js +13 -9
  122. package/build/components/navigation-inspector/index.js +0 -190
  123. package/build/components/navigation-inspector/index.js.map +0 -1
  124. package/build/components/navigation-inspector/navigation-menu.js +0 -62
  125. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  126. package/build-module/components/navigation-inspector/index.js +0 -173
  127. package/build-module/components/navigation-inspector/index.js.map +0 -1
  128. package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
  129. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  130. package/src/components/navigation-inspector/index.js +0 -223
  131. package/src/components/navigation-inspector/navigation-menu.js +0 -66
  132. package/src/components/navigation-inspector/style.scss +0 -46
@@ -20,22 +20,52 @@ export default function useSyncCanvasModeWithURL() {
20
20
  );
21
21
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
22
22
  const currentCanvasMode = useRef( canvasMode );
23
- const { canvas: canvasInUrl = 'view' } = params;
23
+ const { canvas: canvasInUrl } = params;
24
24
  const currentCanvasInUrl = useRef( canvasInUrl );
25
+ const currentUrlParams = useRef( params );
26
+ useEffect( () => {
27
+ currentUrlParams.current = params;
28
+ }, [ params ] );
29
+
25
30
  useEffect( () => {
26
31
  currentCanvasMode.current = canvasMode;
27
- if ( currentCanvasMode !== currentCanvasInUrl ) {
32
+ if ( canvasMode === 'init' ) {
33
+ return;
34
+ }
35
+
36
+ if (
37
+ canvasMode === 'edit' &&
38
+ currentCanvasInUrl.current !== canvasMode
39
+ ) {
40
+ history.push( {
41
+ ...currentUrlParams.current,
42
+ canvas: 'edit',
43
+ } );
44
+ }
45
+
46
+ if (
47
+ canvasMode === 'view' &&
48
+ currentCanvasInUrl.current !== undefined
49
+ ) {
28
50
  history.push( {
29
- ...params,
30
- canvas: canvasMode,
51
+ ...currentUrlParams.current,
52
+ canvas: undefined,
31
53
  } );
32
54
  }
33
- }, [ canvasMode ] );
55
+ }, [ canvasMode, history ] );
34
56
 
35
57
  useEffect( () => {
36
58
  currentCanvasInUrl.current = canvasInUrl;
37
- if ( canvasInUrl !== currentCanvasMode.current ) {
38
- setCanvasMode( canvasInUrl );
59
+ if (
60
+ canvasInUrl === undefined &&
61
+ currentCanvasMode.current !== 'view'
62
+ ) {
63
+ setCanvasMode( 'view' );
64
+ } else if (
65
+ canvasInUrl === 'edit' &&
66
+ currentCanvasMode.current !== 'edit'
67
+ ) {
68
+ setCanvasMode( 'edit' );
39
69
  }
40
- }, [ canvasInUrl ] );
70
+ }, [ canvasInUrl, setCanvasMode ] );
41
71
  }
@@ -41,8 +41,16 @@ export default function useSyncPathWithURL() {
41
41
  } = useNavigator();
42
42
  const currentUrlParams = useRef( urlParams );
43
43
  const currentPath = useRef( navigatorLocation.path );
44
+ const isMounting = useRef( true );
44
45
 
45
46
  useEffect( () => {
47
+ // The navigatorParams are only initially filled properly when the
48
+ // navigator screens mount. so we ignore the first synchronisation.
49
+ if ( isMounting.current ) {
50
+ isMounting.current = false;
51
+ return;
52
+ }
53
+
46
54
  function updateUrlParams( newUrlParams ) {
47
55
  if (
48
56
  Object.entries( newUrlParams ).every( ( [ key, value ] ) => {
@@ -65,17 +73,14 @@ export default function useSyncPathWithURL() {
65
73
  postId: navigatorParams?.postId,
66
74
  path: undefined,
67
75
  } );
68
- } else if ( navigatorParams?.postType && ! navigatorParams?.postId ) {
69
- updateUrlParams( {
70
- postType: navigatorParams?.postType,
71
- path: navigatorLocation.path,
72
- postId: undefined,
73
- } );
74
76
  } else {
75
77
  updateUrlParams( {
76
78
  postType: undefined,
77
79
  postId: undefined,
78
- path: navigatorLocation.path,
80
+ path:
81
+ navigatorLocation.path === '/'
82
+ ? undefined
83
+ : navigatorLocation.path,
79
84
  } );
80
85
  }
81
86
  }, [ navigatorLocation?.path, navigatorParams, history ] );
@@ -32,9 +32,6 @@ export default function TemplateDetails( { template, onClose } ) {
32
32
 
33
33
  // TODO: We should update this to filter by template part's areas as well.
34
34
  const browseAllLinkProps = useLink( {
35
- canvas: 'view',
36
- postType: template.type,
37
- postId: undefined,
38
35
  path: '/' + template.type + '/all',
39
36
  } );
40
37
 
@@ -11,25 +11,33 @@ import { decodeEntities } from '@wordpress/html-entities';
11
11
  */
12
12
  import { store as editSiteStore } from '../../store';
13
13
 
14
- export default function useEditedEntityRecord() {
15
- const { record, title, description, isLoaded } = useSelect( ( select ) => {
16
- const { getEditedPostType, getEditedPostId } = select( editSiteStore );
17
- const { getEditedEntityRecord } = select( coreStore );
18
- const { __experimentalGetTemplateInfo: getTemplateInfo } =
19
- select( editorStore );
20
- const postType = getEditedPostType();
21
- const postId = getEditedPostId();
22
- const _record = getEditedEntityRecord( 'postType', postType, postId );
23
- const _isLoaded = !! postId;
24
- const templateInfo = getTemplateInfo( _record );
14
+ export default function useEditedEntityRecord( postType, postId ) {
15
+ const { record, title, description, isLoaded } = useSelect(
16
+ ( select ) => {
17
+ const { getEditedPostType, getEditedPostId } =
18
+ select( editSiteStore );
19
+ const { getEditedEntityRecord } = select( coreStore );
20
+ const { __experimentalGetTemplateInfo: getTemplateInfo } =
21
+ select( editorStore );
22
+ const usedPostType = postType ?? getEditedPostType();
23
+ const usedPostId = postId ?? getEditedPostId();
24
+ const _record = getEditedEntityRecord(
25
+ 'postType',
26
+ usedPostType,
27
+ usedPostId
28
+ );
29
+ const _isLoaded = !! usedPostId;
30
+ const templateInfo = getTemplateInfo( _record );
25
31
 
26
- return {
27
- record: _record,
28
- title: templateInfo.title,
29
- description: templateInfo.description,
30
- isLoaded: _isLoaded,
31
- };
32
- }, [] );
32
+ return {
33
+ record: _record,
34
+ title: templateInfo.title,
35
+ description: templateInfo.description,
36
+ isLoaded: _isLoaded,
37
+ };
38
+ },
39
+ [ postType, postId ]
40
+ );
33
41
 
34
42
  return {
35
43
  isLoaded,
package/src/index.js CHANGED
@@ -17,7 +17,10 @@ import {
17
17
  import { store as editorStore } from '@wordpress/editor';
18
18
  import { store as interfaceStore } from '@wordpress/interface';
19
19
  import { store as preferencesStore } from '@wordpress/preferences';
20
- import { registerLegacyWidgetBlock } from '@wordpress/widgets';
20
+ import {
21
+ registerLegacyWidgetBlock,
22
+ registerWidgetGroupBlock,
23
+ } from '@wordpress/widgets';
21
24
 
22
25
  /**
23
26
  * Internal dependencies
@@ -47,6 +50,7 @@ export function initializeEditor( id, settings ) {
47
50
  registerCoreBlocks( coreBlocks );
48
51
  dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );
49
52
  registerLegacyWidgetBlock( { inserter: false } );
53
+ registerWidgetGroupBlock( { inserter: false } );
50
54
  if ( process.env.IS_GUTENBERG_PLUGIN ) {
51
55
  __experimentalRegisterExperimentalCoreBlocks( {
52
56
  enableFSEBlocks: true,
package/src/style.scss CHANGED
@@ -8,7 +8,6 @@
8
8
  @import "./components/header-edit-mode/style.scss";
9
9
  @import "./components/header-edit-mode/document-actions/style.scss";
10
10
  @import "./components/list/style.scss";
11
- @import "./components/navigation-inspector/style.scss";
12
11
  @import "./components/sidebar-edit-mode/style.scss";
13
12
  @import "./components/sidebar-edit-mode/settings-header/style.scss";
14
13
  @import "./components/sidebar-edit-mode/template-card/style.scss";
@@ -19,6 +18,7 @@
19
18
  @import "./components/welcome-guide/style.scss";
20
19
  @import "./components/keyboard-shortcut-help-modal/style.scss";
21
20
  @import "./components/layout/style.scss";
21
+ @import "./components/save-hub/style.scss";
22
22
  @import "./components/save-panel/style.scss";
23
23
  @import "./components/sidebar/style.scss";
24
24
  @import "./components/sidebar-button/style.scss";
@@ -6,7 +6,7 @@ import { createBrowserHistory } from 'history';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { addQueryArgs } from '@wordpress/url';
9
+ import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
10
10
 
11
11
  const history = createBrowserHistory();
12
12
 
@@ -14,19 +14,23 @@ const originalHistoryPush = history.push;
14
14
  const originalHistoryReplace = history.replace;
15
15
 
16
16
  function push( params, state ) {
17
- return originalHistoryPush.call(
18
- history,
19
- addQueryArgs( window.location.href, params ),
20
- state
17
+ const currentArgs = getQueryArgs( window.location.href );
18
+ const currentUrlWithoutArgs = removeQueryArgs(
19
+ window.location.href,
20
+ ...Object.keys( currentArgs )
21
21
  );
22
+ const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
23
+ return originalHistoryPush.call( history, newUrl, state );
22
24
  }
23
25
 
24
26
  function replace( params, state ) {
25
- return originalHistoryReplace.call(
26
- history,
27
- addQueryArgs( window.location.href, params ),
28
- state
27
+ const currentArgs = getQueryArgs( window.location.href );
28
+ const currentUrlWithoutArgs = removeQueryArgs(
29
+ window.location.href,
30
+ ...Object.keys( currentArgs )
29
31
  );
32
+ const newUrl = addQueryArgs( currentUrlWithoutArgs, params );
33
+ return originalHistoryReplace.call( history, newUrl, state );
30
34
  }
31
35
 
32
36
  history.push = push;
@@ -1,190 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = NavigationInspector;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _data = require("@wordpress/data");
13
-
14
- var _components = require("@wordpress/components");
15
-
16
- var _coreData = require("@wordpress/core-data");
17
-
18
- var _blockEditor = require("@wordpress/block-editor");
19
-
20
- var _a11y = require("@wordpress/a11y");
21
-
22
- var _compose = require("@wordpress/compose");
23
-
24
- var _i18n = require("@wordpress/i18n");
25
-
26
- var _navigationMenu = _interopRequireDefault(require("./navigation-menu"));
27
-
28
- /**
29
- * WordPress dependencies
30
- */
31
-
32
- /**
33
- * Internal dependencies
34
- */
35
- const NAVIGATION_MENUS_QUERY = [{
36
- per_page: -1,
37
- status: 'publish'
38
- }];
39
-
40
- function NavigationInspector(_ref) {
41
- var _navigationMenus$;
42
-
43
- let {
44
- onSelect
45
- } = _ref;
46
- const {
47
- selectedNavigationBlockId,
48
- clientIdToRef,
49
- navigationMenus,
50
- isResolvingNavigationMenus,
51
- hasResolvedNavigationMenus,
52
- firstNavigationBlockId
53
- } = (0, _data.useSelect)(select => {
54
- const {
55
- __experimentalGetActiveBlockIdByBlockNames,
56
- __experimentalGetGlobalBlocksByName,
57
- getBlock
58
- } = select(_blockEditor.store);
59
- const {
60
- getEntityRecords,
61
- hasFinishedResolution,
62
- isResolving
63
- } = select(_coreData.store);
64
- const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY[0]]; // Get the active Navigation block (if present).
65
-
66
- const selectedNavId = __experimentalGetActiveBlockIdByBlockNames('core/navigation'); // Get all Navigation blocks currently within the editor canvas.
67
-
68
-
69
- const navBlockIds = __experimentalGetGlobalBlocksByName('core/navigation');
70
-
71
- const idToRef = {};
72
- navBlockIds.forEach(id => {
73
- var _getBlock, _getBlock$attributes;
74
-
75
- idToRef[id] = (_getBlock = getBlock(id)) === null || _getBlock === void 0 ? void 0 : (_getBlock$attributes = _getBlock.attributes) === null || _getBlock$attributes === void 0 ? void 0 : _getBlock$attributes.ref;
76
- });
77
- return {
78
- selectedNavigationBlockId: selectedNavId,
79
- firstNavigationBlockId: navBlockIds === null || navBlockIds === void 0 ? void 0 : navBlockIds[0],
80
- clientIdToRef: idToRef,
81
- navigationMenus: getEntityRecords(...navigationMenusQuery),
82
- isResolvingNavigationMenus: isResolving('getEntityRecords', navigationMenusQuery),
83
- hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
84
- };
85
- }, []);
86
- const navMenuListId = (0, _compose.useInstanceId)(_navigationMenu.default, 'edit-site-navigation-inspector-menu');
87
- const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
88
- const firstNavigationMenuRef = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id; // Default Navigation Menu is either:
89
- // - the Navigation Menu referenced by the first Nav block within the template.
90
- // - the first of the available Navigation Menus (`wp_navigation`) posts.
91
-
92
- const defaultNavigationMenuId = firstNavRefInTemplate || firstNavigationMenuRef; // The Navigation Menu manually selected by the user within the Nav inspector.
93
-
94
- const [currentMenuId, setCurrentMenuId] = (0, _element.useState)(firstNavRefInTemplate); // If a Nav block is selected within the canvas then set the
95
- // Navigation Menu referenced by it's `ref` attribute to be
96
- // active within the Navigation sidebar.
97
-
98
- (0, _element.useEffect)(() => {
99
- if (selectedNavigationBlockId) {
100
- setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
101
- }
102
- }, [selectedNavigationBlockId]);
103
- let options = [];
104
-
105
- if (navigationMenus) {
106
- options = navigationMenus.map(_ref2 => {
107
- let {
108
- id,
109
- title
110
- } = _ref2;
111
- return {
112
- value: id,
113
- label: title.rendered
114
- };
115
- });
116
- }
117
-
118
- const [innerBlocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('postType', 'wp_navigation', {
119
- id: currentMenuId || defaultNavigationMenuId
120
- });
121
- const {
122
- isLoadingInnerBlocks,
123
- hasLoadedInnerBlocks
124
- } = (0, _data.useSelect)(select => {
125
- const {
126
- isResolving,
127
- hasFinishedResolution
128
- } = select(_coreData.store);
129
- return {
130
- isLoadingInnerBlocks: isResolving('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId]),
131
- hasLoadedInnerBlocks: hasFinishedResolution('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId])
132
- };
133
- }, [currentMenuId, defaultNavigationMenuId]);
134
- const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
135
- const hasMoreThanOneNavigationMenu = (navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.length) > 1;
136
- const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
137
- // Guard by only allowing their usage if there are published Nav Menus.
138
-
139
- const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
140
- const hasInnerBlocks = !!(publishedInnerBlocks !== null && publishedInnerBlocks !== void 0 && publishedInnerBlocks.length);
141
- (0, _element.useEffect)(() => {
142
- if (isResolvingNavigationMenus) {
143
- (0, _a11y.speak)('Loading Navigation sidebar menus.');
144
- }
145
-
146
- if (hasResolvedNavigationMenus) {
147
- (0, _a11y.speak)('Navigation sidebar menus have loaded.');
148
- }
149
- }, [isResolvingNavigationMenus, hasResolvedNavigationMenus]);
150
- (0, _element.useEffect)(() => {
151
- if (isLoadingInnerBlocks) {
152
- (0, _a11y.speak)('Loading Navigation sidebar selected menu items.');
153
- }
154
-
155
- if (hasLoadedInnerBlocks) {
156
- (0, _a11y.speak)('Navigation sidebar selected menu items have loaded.');
157
- }
158
- }, [isLoadingInnerBlocks, hasLoadedInnerBlocks]);
159
- return (0, _element.createElement)("div", {
160
- className: "edit-site-navigation-inspector"
161
- }, hasResolvedNavigationMenus && !hasNavigationMenus && (0, _element.createElement)("p", {
162
- className: "edit-site-navigation-inspector__empty-msg"
163
- }, (0, _i18n.__)('There are no Navigation Menus.')), !hasResolvedNavigationMenus && (0, _element.createElement)("div", {
164
- className: "edit-site-navigation-inspector__placeholder"
165
- }), hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (0, _element.createElement)(_components.SelectControl, {
166
- __nextHasNoMarginBottom: true,
167
- className: "edit-site-navigation-inspector__select-menu",
168
- "aria-controls": // aria-controls should only apply when referenced element is in DOM
169
- hasLoadedInnerBlocks ? navMenuListId : undefined,
170
- value: currentMenuId || defaultNavigationMenuId,
171
- options: options,
172
- onChange: newMenuId => setCurrentMenuId(Number(newMenuId))
173
- }), isLoading && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
174
- className: "edit-site-navigation-inspector__placeholder is-child"
175
- }), (0, _element.createElement)("div", {
176
- className: "edit-site-navigation-inspector__placeholder is-child"
177
- }), (0, _element.createElement)("div", {
178
- className: "edit-site-navigation-inspector__placeholder is-child"
179
- })), hasInnerBlocks && !isLoading && (0, _element.createElement)(_blockEditor.BlockEditorProvider, {
180
- value: publishedInnerBlocks,
181
- onChange: onChange,
182
- onInput: onInput
183
- }, (0, _element.createElement)(_navigationMenu.default, {
184
- innerBlocks: publishedInnerBlocks,
185
- onSelect: onSelect
186
- })), !hasInnerBlocks && !isLoading && (0, _element.createElement)("p", {
187
- className: "edit-site-navigation-inspector__empty-msg"
188
- }, (0, _i18n.__)('Navigation Menu is empty.')));
189
- }
190
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/index.js"],"names":["NAVIGATION_MENUS_QUERY","per_page","status","NavigationInspector","onSelect","selectedNavigationBlockId","clientIdToRef","navigationMenus","isResolvingNavigationMenus","hasResolvedNavigationMenus","firstNavigationBlockId","select","__experimentalGetActiveBlockIdByBlockNames","__experimentalGetGlobalBlocksByName","getBlock","blockEditorStore","getEntityRecords","hasFinishedResolution","isResolving","coreStore","navigationMenusQuery","selectedNavId","navBlockIds","idToRef","forEach","id","attributes","ref","navMenuListId","NavigationMenu","firstNavRefInTemplate","firstNavigationMenuRef","defaultNavigationMenuId","currentMenuId","setCurrentMenuId","options","map","title","value","label","rendered","innerBlocks","onInput","onChange","isLoadingInnerBlocks","hasLoadedInnerBlocks","isLoading","hasMoreThanOneNavigationMenu","length","hasNavigationMenus","publishedInnerBlocks","hasInnerBlocks","undefined","newMenuId","Number"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG,CAAE;AAAEC,EAAAA,QAAQ,EAAE,CAAC,CAAb;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAAF,CAA/B;;AAEe,SAASC,mBAAT,OAA6C;AAAA;;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC3D,QAAM;AACLC,IAAAA,yBADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,0BALK;AAMLC,IAAAA;AANK,MAOF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,0CADK;AAELC,MAAAA,mCAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,kBAAF,CAJV;AAMA,UAAM;AAAEC,MAAAA,gBAAF;AAAoBC,MAAAA,qBAApB;AAA2CC,MAAAA;AAA3C,QACLP,MAAM,CAAEQ,eAAF,CADP;AAGA,UAAMC,oBAAoB,GAAG,CAC5B,UAD4B,EAE5B,eAF4B,EAG5BpB,sBAAsB,CAAE,CAAF,CAHM,CAA7B,CAV4B,CAgB5B;;AACA,UAAMqB,aAAa,GAClBT,0CAA0C,CAAE,iBAAF,CAD3C,CAjB4B,CAoB5B;;;AACA,UAA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A,SAAS,EAAC;AAAf,IAFD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,IAHD,CA1BF,EAgCGK,cAAc,IAAI,CAAEL,SAApB,IACD,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGI,oBADT;AAEC,IAAA,QAAQ,EAAGP,QAFZ;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKC,4BAAC,uBAAD;AACC,IAAA,WAAW,EAAGQ,oBADf;AAEC,IAAA,QAAQ,EAAG9C;AAFZ,IALD,CAjCF,EA6CG,CAAE+C,cAAF,IAAoB,CAAEL,SAAtB,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACG,cAAI,2BAAJ,CADH,CA9CF,CADD;AAqDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { SelectControl } from '@wordpress/components';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tstore as blockEditorStore,\n\tBlockEditorProvider,\n} from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenu from './navigation-menu';\n\nconst NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];\n\nexport default function NavigationInspector( { onSelect } ) {\n\tconst {\n\t\tselectedNavigationBlockId,\n\t\tclientIdToRef,\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tfirstNavigationBlockId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetActiveBlockIdByBlockNames,\n\t\t\t__experimentalGetGlobalBlocksByName,\n\t\t\tgetBlock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getEntityRecords, hasFinishedResolution, isResolving } =\n\t\t\tselect( coreStore );\n\n\t\tconst navigationMenusQuery = [\n\t\t\t'postType',\n\t\t\t'wp_navigation',\n\t\t\tNAVIGATION_MENUS_QUERY[ 0 ],\n\t\t];\n\n\t\t// Get the active Navigation block (if present).\n\t\tconst selectedNavId =\n\t\t\t__experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );\n\n\t\t// Get all Navigation blocks currently within the editor canvas.\n\t\tconst navBlockIds =\n\t\t\t__experimentalGetGlobalBlocksByName( 'core/navigation' );\n\t\tconst idToRef = {};\n\t\tnavBlockIds.forEach( ( id ) => {\n\t\t\tidToRef[ id ] = getBlock( id )?.attributes?.ref;\n\t\t} );\n\t\treturn {\n\t\t\tselectedNavigationBlockId: selectedNavId,\n\t\t\tfirstNavigationBlockId: navBlockIds?.[ 0 ],\n\t\t\tclientIdToRef: idToRef,\n\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\tisResolvingNavigationMenus: isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst navMenuListId = useInstanceId(\n\t\tNavigationMenu,\n\t\t'edit-site-navigation-inspector-menu'\n\t);\n\n\tconst firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];\n\tconst firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;\n\n\t// Default Navigation Menu is either:\n\t// - the Navigation Menu referenced by the first Nav block within the template.\n\t// - the first of the available Navigation Menus (`wp_navigation`) posts.\n\tconst defaultNavigationMenuId =\n\t\tfirstNavRefInTemplate || firstNavigationMenuRef;\n\n\t// The Navigation Menu manually selected by the user within the Nav inspector.\n\tconst [ currentMenuId, setCurrentMenuId ] = useState(\n\t\tfirstNavRefInTemplate\n\t);\n\n\t// If a Nav block is selected within the canvas then set the\n\t// Navigation Menu referenced by it's `ref` attribute to be\n\t// active within the Navigation sidebar.\n\tuseEffect( () => {\n\t\tif ( selectedNavigationBlockId ) {\n\t\t\tsetCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );\n\t\t}\n\t}, [ selectedNavigationBlockId ] );\n\n\tlet options = [];\n\tif ( navigationMenus ) {\n\t\toptions = navigationMenus.map( ( { id, title } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: title.rendered,\n\t\t} ) );\n\t}\n\n\tconst [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t{ id: currentMenuId || defaultNavigationMenuId }\n\t);\n\n\tconst { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isResolving, hasFinishedResolution } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisLoadingInnerBlocks: isResolving( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_navigation',\n\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t] ),\n\t\t\t\thasLoadedInnerBlocks: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t[\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_navigation',\n\t\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ currentMenuId, defaultNavigationMenuId ]\n\t);\n\n\tconst isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );\n\n\tconst hasMoreThanOneNavigationMenu = navigationMenus?.length > 1;\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\t// Entity block editor will return entities that are not currently published.\n\t// Guard by only allowing their usage if there are published Nav Menus.\n\tconst publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];\n\n\tconst hasInnerBlocks = !! publishedInnerBlocks?.length;\n\n\tuseEffect( () => {\n\t\tif ( isResolvingNavigationMenus ) {\n\t\t\tspeak( 'Loading Navigation sidebar menus.' );\n\t\t}\n\n\t\tif ( hasResolvedNavigationMenus ) {\n\t\t\tspeak( 'Navigation sidebar menus have loaded.' );\n\t\t}\n\t}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );\n\n\tuseEffect( () => {\n\t\tif ( isLoadingInnerBlocks ) {\n\t\t\tspeak( 'Loading Navigation sidebar selected menu items.' );\n\t\t}\n\n\t\tif ( hasLoadedInnerBlocks ) {\n\t\t\tspeak( 'Navigation sidebar selected menu items have loaded.' );\n\t\t}\n\t}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-inspector\">\n\t\t\t{ hasResolvedNavigationMenus && ! hasNavigationMenus && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t{ ! hasResolvedNavigationMenus && (\n\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder\" />\n\t\t\t) }\n\t\t\t{ hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tclassName=\"edit-site-navigation-inspector__select-menu\"\n\t\t\t\t\taria-controls={\n\t\t\t\t\t\t// aria-controls should only apply when referenced element is in DOM\n\t\t\t\t\t\thasLoadedInnerBlocks ? navMenuListId : undefined\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ currentMenuId || defaultNavigationMenuId }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( newMenuId ) =>\n\t\t\t\t\t\tsetCurrentMenuId( Number( newMenuId ) )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isLoading && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ hasInnerBlocks && ! isLoading && (\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ publishedInnerBlocks }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t>\n\t\t\t\t\t<NavigationMenu\n\t\t\t\t\t\tinnerBlocks={ publishedInnerBlocks }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</BlockEditorProvider>\n\t\t\t) }\n\n\t\t\t{ ! hasInnerBlocks && ! isLoading && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = NavigationMenu;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _blockEditor = require("@wordpress/block-editor");
11
-
12
- var _data = require("@wordpress/data");
13
-
14
- var _privateApis = require("../../private-apis");
15
-
16
- /**
17
- * WordPress dependencies
18
- */
19
-
20
- /**
21
- * Internal dependencies
22
- */
23
- const ALLOWED_BLOCKS = {
24
- 'core/navigation': ['core/navigation-link', 'core/search', 'core/social-links', 'core/page-list', 'core/spacer', 'core/home-link', 'core/site-title', 'core/site-logo', 'core/navigation-submenu'],
25
- 'core/social-links': ['core/social-link'],
26
- 'core/navigation-submenu': ['core/navigation-link', 'core/navigation-submenu'],
27
- 'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
28
- };
29
-
30
- function NavigationMenu(_ref) {
31
- let {
32
- innerBlocks,
33
- onSelect
34
- } = _ref;
35
- const {
36
- updateBlockListSettings
37
- } = (0, _data.useDispatch)(_blockEditor.store);
38
- const {
39
- OffCanvasEditor,
40
- LeafMoreMenu
41
- } = (0, _privateApis.unlock)(_blockEditor.privateApis); //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
42
- //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
43
-
44
- (0, _element.useEffect)(() => {
45
- updateBlockListSettings('', {
46
- allowedBlocks: ALLOWED_BLOCKS['core/navigation']
47
- });
48
- innerBlocks.forEach(block => {
49
- if (ALLOWED_BLOCKS[block.name]) {
50
- updateBlockListSettings(block.clientId, {
51
- allowedBlocks: ALLOWED_BLOCKS[block.name]
52
- });
53
- }
54
- });
55
- }, [updateBlockListSettings, innerBlocks]);
56
- return (0, _element.createElement)(OffCanvasEditor, {
57
- blocks: innerBlocks,
58
- onSelect: onSelect,
59
- LeafMoreMenu: LeafMoreMenu
60
- });
61
- }
62
- //# sourceMappingURL=navigation-menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/navigation-menu.js"],"names":["ALLOWED_BLOCKS","NavigationMenu","innerBlocks","onSelect","updateBlockListSettings","blockEditorStore","OffCanvasEditor","LeafMoreMenu","blockEditorPrivateApis","allowedBlocks","forEach","block","name","clientId"],"mappings":";;;;;;;AAOA;;AAJA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGA,MAAMA,cAAc,GAAG;AACtB,qBAAmB,CAClB,sBADkB,EAElB,aAFkB,EAGlB,mBAHkB,EAIlB,gBAJkB,EAKlB,aALkB,EAMlB,gBANkB,EAOlB,iBAPkB,EAQlB,gBARkB,EASlB,yBATkB,CADG;AAYtB,uBAAqB,CAAE,kBAAF,CAZC;AAatB,6BAA2B,CAC1B,sBAD0B,EAE1B,yBAF0B,CAbL;AAiBtB,0BAAwB,CACvB,sBADuB,EAEvB,yBAFuB;AAjBF,CAAvB;;AAuBe,SAASC,cAAT,OAAqD;AAAA,MAA5B;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,GAA4B;AACnE,QAAM;AAAEC,IAAAA;AAAF,MAA8B,uBAAaC,kBAAb,CAApC;AAEA,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAoC,yBAAQC,wBAAR,CAA1C,CAHmE,CAKnE;AACA;;AACA,0BAAW,MAAM;AAChBJ,IAAAA,uBAAuB,CAAE,EAAF,EAAM;AAC5BK,MAAAA,aAAa,EAAET,cAAc,CAAE,iBAAF;AADD,KAAN,CAAvB;AAGAE,IAAAA,WAAW,CAACQ,OAAZ,CAAuBC,KAAF,IAAa;AACjC,UAAKX,cAAc,CAAEW,KAAK,CAACC,IAAR,CAAnB,EAAoC;AACnCR,QAAAA,uBAAuB,CAAEO,KAAK,CAACE,QAAR,EAAkB;AACxCJ,UAAAA,aAAa,EAAET,cAAc,CAAEW,KAAK,CAACC,IAAR;AADW,SAAlB,CAAvB;AAGA;AACD,KAND;AAOA,GAXD,EAWG,CAAER,uBAAF,EAA2BF,WAA3B,CAXH;AAaA,SACC,4BAAC,eAAD;AACC,IAAA,MAAM,EAAGA,WADV;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,YAAY,EAAGI;AAHhB,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst ALLOWED_BLOCKS = {\n\t'core/navigation': [\n\t\t'core/navigation-link',\n\t\t'core/search',\n\t\t'core/social-links',\n\t\t'core/page-list',\n\t\t'core/spacer',\n\t\t'core/home-link',\n\t\t'core/site-title',\n\t\t'core/site-logo',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/social-links': [ 'core/social-link' ],\n\t'core/navigation-submenu': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/navigation-link': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n};\n\nexport default function NavigationMenu( { innerBlocks, onSelect } ) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\n\tconst { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\t//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList\n\t//Think through a better way of doing this, possible with adding allowed blocks to block library metadata\n\tuseEffect( () => {\n\t\tupdateBlockListSettings( '', {\n\t\t\tallowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],\n\t\t} );\n\t\tinnerBlocks.forEach( ( block ) => {\n\t\t\tif ( ALLOWED_BLOCKS[ block.name ] ) {\n\t\t\t\tupdateBlockListSettings( block.clientId, {\n\t\t\t\t\tallowedBlocks: ALLOWED_BLOCKS[ block.name ],\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [ updateBlockListSettings, innerBlocks ] );\n\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ innerBlocks }\n\t\t\tonSelect={ onSelect }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t/>\n\t);\n}\n"]}