@wordpress/edit-post 6.19.0 → 7.0.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/block-manager/index.js +3 -10
  3. package/build/components/block-manager/index.js.map +1 -1
  4. package/build/components/header/index.js +2 -2
  5. package/build/components/header/index.js.map +1 -1
  6. package/build/components/layout/index.js +2 -1
  7. package/build/components/layout/index.js.map +1 -1
  8. package/build/components/preferences-modal/meta-boxes-section.js +1 -1
  9. package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
  10. package/build/components/sidebar/post-status/index.js +1 -1
  11. package/build/components/sidebar/post-status/index.js.map +1 -1
  12. package/build/components/sidebar/post-template/index.js +2 -4
  13. package/build/components/sidebar/post-template/index.js.map +1 -1
  14. package/build/components/sidebar/settings-sidebar/index.js +7 -7
  15. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  16. package/build/editor.native.js +8 -2
  17. package/build/editor.native.js.map +1 -1
  18. package/build/hooks/validate-multiple-use/index.js +1 -7
  19. package/build/hooks/validate-multiple-use/index.js.map +1 -1
  20. package/build/plugins/index.js +3 -1
  21. package/build/plugins/index.js.map +1 -1
  22. package/build/plugins/navigation-list-view-menu-item.js +48 -0
  23. package/build/plugins/navigation-list-view-menu-item.js.map +1 -0
  24. package/build-module/components/block-manager/index.js +3 -9
  25. package/build-module/components/block-manager/index.js.map +1 -1
  26. package/build-module/components/header/index.js +2 -2
  27. package/build-module/components/header/index.js.map +1 -1
  28. package/build-module/components/layout/index.js +2 -1
  29. package/build-module/components/layout/index.js.map +1 -1
  30. package/build-module/components/preferences-modal/meta-boxes-section.js +2 -2
  31. package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
  32. package/build-module/components/sidebar/post-status/index.js +1 -1
  33. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  34. package/build-module/components/sidebar/post-template/index.js +2 -4
  35. package/build-module/components/sidebar/post-template/index.js.map +1 -1
  36. package/build-module/components/sidebar/settings-sidebar/index.js +5 -5
  37. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  38. package/build-module/editor.native.js +7 -2
  39. package/build-module/editor.native.js.map +1 -1
  40. package/build-module/hooks/validate-multiple-use/index.js +1 -6
  41. package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
  42. package/build-module/plugins/index.js +2 -1
  43. package/build-module/plugins/index.js.map +1 -1
  44. package/build-module/plugins/navigation-list-view-menu-item.js +40 -0
  45. package/build-module/plugins/navigation-list-view-menu-item.js.map +1 -0
  46. package/build-style/classic-rtl.css +14 -0
  47. package/build-style/classic.css +14 -0
  48. package/build-style/style-rtl.css +67 -33
  49. package/build-style/style.css +67 -33
  50. package/package.json +29 -29
  51. package/src/components/block-manager/index.js +6 -10
  52. package/src/components/header/index.js +3 -3
  53. package/src/components/layout/index.js +3 -1
  54. package/src/components/preferences-modal/meta-boxes-section.js +2 -3
  55. package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +56 -4
  56. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +39 -14
  57. package/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap +51 -6
  58. package/src/components/sidebar/post-schedule/style.scss +2 -1
  59. package/src/components/sidebar/post-status/index.js +1 -1
  60. package/src/components/sidebar/post-template/index.js +8 -3
  61. package/src/components/sidebar/post-template/style.scss +2 -0
  62. package/src/components/sidebar/post-url/style.scss +3 -0
  63. package/src/components/sidebar/post-visibility/style.scss +2 -0
  64. package/src/components/sidebar/settings-header/style.scss +47 -34
  65. package/src/components/sidebar/settings-sidebar/index.js +5 -5
  66. package/src/components/visual-editor/test/index.native.js +20 -9
  67. package/src/editor.native.js +14 -11
  68. package/src/hooks/validate-multiple-use/index.js +1 -7
  69. package/src/plugins/index.js +2 -0
  70. package/src/plugins/navigation-list-view-menu-item.js +56 -0
@@ -41,6 +41,17 @@ exports[`MetaBoxesSection renders a Custom Fields option 1`] = `
41
41
  min-width: 0;
42
42
  }
43
43
 
44
+ .emotion-6 {
45
+ display: block;
46
+ max-height: 100%;
47
+ max-width: 100%;
48
+ min-height: 0;
49
+ min-width: 0;
50
+ -webkit-flex: 1;
51
+ -ms-flex: 1;
52
+ flex: 1;
53
+ }
54
+
44
55
  <fieldset
45
56
  class="interface-preferences-modal__section"
46
57
  >
@@ -83,7 +94,9 @@ exports[`MetaBoxesSection renders a Custom Fields option 1`] = `
83
94
  />
84
95
  </span>
85
96
  <label
86
- class="components-toggle-control__label"
97
+ class="components-flex-item components-flex-block components-toggle-control__label emotion-6 emotion-5"
98
+ data-wp-c16t="true"
99
+ data-wp-component="FlexBlock"
87
100
  for="inspector-toggle-control-0"
88
101
  >
89
102
  Custom fields
@@ -136,6 +149,17 @@ exports[`MetaBoxesSection renders a Custom Fields option and meta box options 1`
136
149
  min-width: 0;
137
150
  }
138
151
 
152
+ .emotion-6 {
153
+ display: block;
154
+ max-height: 100%;
155
+ max-width: 100%;
156
+ min-height: 0;
157
+ min-width: 0;
158
+ -webkit-flex: 1;
159
+ -ms-flex: 1;
160
+ flex: 1;
161
+ }
162
+
139
163
  <fieldset
140
164
  class="interface-preferences-modal__section"
141
165
  >
@@ -178,7 +202,9 @@ exports[`MetaBoxesSection renders a Custom Fields option and meta box options 1`
178
202
  />
179
203
  </span>
180
204
  <label
181
- class="components-toggle-control__label"
205
+ class="components-flex-item components-flex-block components-toggle-control__label emotion-6 emotion-5"
206
+ data-wp-c16t="true"
207
+ data-wp-component="FlexBlock"
182
208
  for="inspector-toggle-control-3"
183
209
  >
184
210
  Custom fields
@@ -218,7 +244,9 @@ exports[`MetaBoxesSection renders a Custom Fields option and meta box options 1`
218
244
  />
219
245
  </span>
220
246
  <label
221
- class="components-toggle-control__label"
247
+ class="components-flex-item components-flex-block components-toggle-control__label emotion-6 emotion-5"
248
+ data-wp-c16t="true"
249
+ data-wp-component="FlexBlock"
222
250
  for="inspector-toggle-control-4"
223
251
  >
224
252
  Meta Box 1
@@ -258,7 +286,9 @@ exports[`MetaBoxesSection renders a Custom Fields option and meta box options 1`
258
286
  />
259
287
  </span>
260
288
  <label
261
- class="components-toggle-control__label"
289
+ class="components-flex-item components-flex-block components-toggle-control__label emotion-6 emotion-5"
290
+ data-wp-c16t="true"
291
+ data-wp-component="FlexBlock"
262
292
  for="inspector-toggle-control-5"
263
293
  >
264
294
  Meta Box 2
@@ -311,6 +341,17 @@ exports[`MetaBoxesSection renders meta box options 1`] = `
311
341
  min-width: 0;
312
342
  }
313
343
 
344
+ .emotion-6 {
345
+ display: block;
346
+ max-height: 100%;
347
+ max-width: 100%;
348
+ min-height: 0;
349
+ min-width: 0;
350
+ -webkit-flex: 1;
351
+ -ms-flex: 1;
352
+ flex: 1;
353
+ }
354
+
314
355
  <fieldset
315
356
  class="interface-preferences-modal__section"
316
357
  >
@@ -354,7 +395,9 @@ exports[`MetaBoxesSection renders meta box options 1`] = `
354
395
  />
355
396
  </span>
356
397
  <label
357
- class="components-toggle-control__label"
398
+ class="components-flex-item components-flex-block components-toggle-control__label emotion-6 emotion-5"
399
+ data-wp-c16t="true"
400
+ data-wp-component="FlexBlock"
358
401
  for="inspector-toggle-control-1"
359
402
  >
360
403
  Meta Box 1
@@ -394,7 +437,9 @@ exports[`MetaBoxesSection renders meta box options 1`] = `
394
437
  />
395
438
  </span>
396
439
  <label
397
- class="components-toggle-control__label"
440
+ class="components-flex-item components-flex-block components-toggle-control__label emotion-6 emotion-5"
441
+ data-wp-c16t="true"
442
+ data-wp-component="FlexBlock"
398
443
  for="inspector-toggle-control-2"
399
444
  >
400
445
  Meta Box 2
@@ -7,13 +7,14 @@
7
7
  display: block;
8
8
  width: 45%;
9
9
  flex-shrink: 0;
10
+ // Match padding on tertiary buttons for alignment.
11
+ padding: $grid-unit-15 * 0.5 0;
10
12
  }
11
13
  }
12
14
 
13
15
  .components-button.edit-post-post-schedule__toggle {
14
16
  text-align: left;
15
17
  white-space: normal;
16
- height: auto;
17
18
 
18
19
  // This span is added by the Popover in Tooltip when no anchor is
19
20
  // provided. We set its width to 0 so that it does not cause the button text
@@ -40,8 +40,8 @@ function PostStatus( { isOpened, onTogglePanel } ) {
40
40
  <>
41
41
  <PostVisibility />
42
42
  <PostSchedule />
43
- <PostURL />
44
43
  <PostTemplate />
44
+ <PostURL />
45
45
  <PostSticky />
46
46
  <PostPendingStatus />
47
47
  <PostFormat />
@@ -85,9 +85,14 @@ function PostTemplateToggle( { isOpen, onClick } ) {
85
85
  if ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {
86
86
  return availableTemplates[ templateSlug ];
87
87
  }
88
-
89
- const template = select( editPostStore ).getEditedPostTemplate();
90
- return template?.title ?? template?.slug;
88
+ const template =
89
+ select( coreStore ).canUser( 'create', 'templates' ) &&
90
+ select( editPostStore ).getEditedPostTemplate();
91
+ return (
92
+ template?.title ||
93
+ template?.slug ||
94
+ availableTemplates?.[ templateSlug ]
95
+ );
91
96
  }, [] );
92
97
 
93
98
  return (
@@ -5,6 +5,8 @@
5
5
  span {
6
6
  display: block;
7
7
  width: 45%;
8
+ // Match padding on tertiary buttons for alignment.
9
+ padding: $grid-unit-15 * 0.5 0;
8
10
  }
9
11
  }
10
12
 
@@ -1,11 +1,14 @@
1
1
  .edit-post-post-url {
2
2
  width: 100%;
3
3
  justify-content: flex-start;
4
+ align-items: flex-start;
4
5
 
5
6
  span {
6
7
  display: block;
7
8
  width: 45%;
8
9
  flex-shrink: 0;
10
+ // Match padding on tertiary buttons for alignment.
11
+ padding: $grid-unit-15 * 0.5 0;
9
12
  }
10
13
  }
11
14
 
@@ -5,6 +5,8 @@
5
5
  span {
6
6
  display: block;
7
7
  width: 45%;
8
+ // Match padding on tertiary buttons for alignment.
9
+ padding: $grid-unit-15 * 0.5 0;
8
10
  }
9
11
  }
10
12
 
@@ -1,53 +1,66 @@
1
+ // This tab style CSS is duplicated verbatim in
2
+ // /packages/components/src/tab-panel/style.scss
1
3
  .components-button.edit-post-sidebar__panel-tab {
4
+ position: relative;
2
5
  border-radius: 0;
3
6
  height: $grid-unit-60;
4
7
  background: transparent;
5
8
  border: none;
6
9
  box-shadow: none;
7
10
  cursor: pointer;
8
- display: inline-block;
9
- padding: 3px 15px; // Use padding to offset the is-active border, this benefits Windows High Contrast mode
11
+ padding: 3px $grid-unit-20; // Use padding to offset the is-active border, this benefits Windows High Contrast mode
10
12
  margin-left: 0;
11
13
  font-weight: 500;
12
14
 
13
- // This pseudo-element "duplicates" the tab label and sets the text to bold.
14
- // This ensures that the tab doesn't change width when selected.
15
- // See: https://github.com/WordPress/gutenberg/pull/9793
15
+ &:focus:not(:disabled) {
16
+ position: relative;
17
+ box-shadow: none;
18
+ }
19
+
20
+ // Tab indicator
16
21
  &::after {
17
- content: attr(data-label);
18
- display: block;
19
- font-weight: 600;
20
- height: 0;
21
- overflow: hidden;
22
- speak: none;
23
- visibility: hidden;
22
+ content: "";
23
+ position: absolute;
24
+ right: 0;
25
+ bottom: 0;
26
+ left: 0;
27
+ pointer-events: none;
28
+
29
+ // Draw the indicator.
30
+ background: var(--wp-admin-theme-color);
31
+ height: calc(0 * var(--wp-admin-border-width-focus));
32
+ border-radius: 0;
33
+
34
+ // Animation
35
+ transition: all 0.1s linear;
36
+ @include reduce-motion("transition");
24
37
  }
25
38
 
26
- &.is-active {
27
- // The transparent shadow ensures no jumpiness when focus animates on an active tab.
28
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) transparent, inset 0 0 -$border-width-tab 0 0 var(--wp-admin-theme-color);
29
- position: relative;
30
- z-index: z-index(".edit-post-sidebar__panel-tab.is-active");
31
-
32
- // This border appears in Windows High Contrast mode instead of the box-shadow.
33
- &::before {
34
- content: "";
35
- position: absolute;
36
- top: 0;
37
- bottom: 1px;
38
- right: 0;
39
- left: 0;
40
- border-bottom: $border-width-tab solid transparent;
41
- }
39
+ // Active.
40
+ &.is-active::after {
41
+ height: calc(1 * var(--wp-admin-border-width-focus));
42
42
  }
43
43
 
44
- &:focus {
45
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
46
- position: relative;
47
- z-index: z-index(".edit-post-sidebar__panel-tab.is-active");
44
+ // Focus.
45
+ &::before {
46
+ content: "";
47
+ position: absolute;
48
+ top: $grid-unit-15;
49
+ right: $grid-unit-15;
50
+ bottom: $grid-unit-15;
51
+ left: $grid-unit-15;
52
+ pointer-events: none;
53
+
54
+ // Draw the indicator.
55
+ box-shadow: 0 0 0 0 transparent;
56
+ border-radius: $radius-block-ui;
57
+
58
+ // Animation
59
+ transition: all 0.1s linear;
60
+ @include reduce-motion("transition");
48
61
  }
49
62
 
50
- &.is-active:focus {
51
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 -#{$border-width-tab * 2} 0 0 var(--wp-admin-theme-color);
63
+ &:focus-visible::before {
64
+ box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
52
65
  }
53
66
  }
@@ -5,10 +5,12 @@ import {
5
5
  BlockInspector,
6
6
  store as blockEditorStore,
7
7
  } from '@wordpress/block-editor';
8
- import { cog } from '@wordpress/icons';
8
+ import { useSelect } from '@wordpress/data';
9
9
  import { Platform } from '@wordpress/element';
10
- import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
10
+ import { isRTL, __ } from '@wordpress/i18n';
11
+ import { drawerLeft, drawerRight } from '@wordpress/icons';
11
12
  import { store as interfaceStore } from '@wordpress/interface';
13
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
12
14
 
13
15
  /**
14
16
  * Internal dependencies
@@ -25,8 +27,6 @@ import MetaBoxes from '../../meta-boxes';
25
27
  import PluginDocumentSettingPanel from '../plugin-document-setting-panel';
26
28
  import PluginSidebarEditPost from '../plugin-sidebar';
27
29
  import TemplateSummary from '../template-summary';
28
- import { __ } from '@wordpress/i18n';
29
- import { useSelect } from '@wordpress/data';
30
30
  import { store as editPostStore } from '../../../store';
31
31
 
32
32
  const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {
@@ -78,7 +78,7 @@ const SettingsSidebar = () => {
78
78
  /* translators: button label text should, if possible, be under 16 characters. */
79
79
  title={ __( 'Settings' ) }
80
80
  toggleShortcut={ keyboardShortcut }
81
- icon={ cog }
81
+ icon={ isRTL() ? drawerLeft : drawerRight }
82
82
  isActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }
83
83
  >
84
84
  { ! isTemplateMode && sidebarName === 'edit-post/document' && (
@@ -38,7 +38,9 @@ describe( 'when title is focused', () => {
38
38
  } );
39
39
 
40
40
  // Focus first block
41
- fireEvent.press( screen.getByLabelText( /Paragraph Block. Row 1/ ) );
41
+ fireEvent.press(
42
+ screen.getAllByLabelText( /Paragraph Block. Row 1/ )[ 0 ]
43
+ );
42
44
 
43
45
  // Focus title
44
46
  fireEvent(
@@ -50,12 +52,15 @@ describe( 'when title is focused', () => {
50
52
  fireEvent.press( screen.getByLabelText( 'Add block' ) );
51
53
  fireEvent.press( screen.getByText( 'Heading' ) );
52
54
 
53
- expect( screen.getByLabelText( /Heading Block. Row 1/ ) ).toBeDefined();
54
55
  expect(
55
- screen.getByLabelText( /Paragraph Block. Row 2/ )
56
+ screen.getAllByLabelText( /Heading Block. Row 1/ )[ 0 ]
57
+ ).toBeDefined();
58
+ expect(
59
+ screen.getAllByLabelText( /Paragraph Block. Row 2/ )[ 0 ]
56
60
  ).toBeDefined();
61
+
57
62
  expect(
58
- screen.getByLabelText( /Paragraph Block. Row 3/ )
63
+ screen.getAllByLabelText( /Paragraph Block. Row 3/ )[ 0 ]
59
64
  ).toBeDefined();
60
65
  } );
61
66
  } );
@@ -67,7 +72,9 @@ describe( 'when title is no longer focused', () => {
67
72
  } );
68
73
 
69
74
  // Focus first block
70
- fireEvent.press( screen.getByLabelText( /Paragraph Block. Row 1/ ) );
75
+ fireEvent.press(
76
+ screen.getAllByLabelText( /Paragraph Block. Row 1/ )[ 0 ]
77
+ );
71
78
 
72
79
  // Focus title
73
80
  fireEvent(
@@ -76,18 +83,22 @@ describe( 'when title is no longer focused', () => {
76
83
  );
77
84
 
78
85
  // Focus last block
79
- fireEvent.press( screen.getByLabelText( /Paragraph Block. Row 2/ ) );
86
+ fireEvent.press(
87
+ screen.getAllByLabelText( /Paragraph Block. Row 2/ )[ 0 ]
88
+ );
80
89
 
81
90
  // Add new Heading block
82
91
  fireEvent.press( screen.getByLabelText( 'Add block' ) );
83
92
  fireEvent.press( screen.getByText( 'Heading' ) );
84
93
 
85
94
  expect(
86
- screen.getByLabelText( /Paragraph Block. Row 1/ )
95
+ screen.getAllByLabelText( /Paragraph Block. Row 1/ )[ 0 ]
96
+ ).toBeDefined();
97
+ expect(
98
+ screen.getAllByLabelText( /Paragraph Block. Row 2/ )[ 0 ]
87
99
  ).toBeDefined();
88
100
  expect(
89
- screen.getByLabelText( /Paragraph Block. Row 2/ )
101
+ screen.getAllByLabelText( /Heading Block. Row 3/ )[ 0 ]
90
102
  ).toBeDefined();
91
- expect( screen.getByLabelText( /Heading Block. Row 3/ ) ).toBeDefined();
92
103
  } );
93
104
  } );
@@ -4,6 +4,7 @@
4
4
  import memize from 'memize';
5
5
  import { map } from 'lodash';
6
6
  import { I18nManager } from 'react-native';
7
+ import { GestureHandlerRootView } from 'react-native-gesture-handler';
7
8
 
8
9
  /**
9
10
  * WordPress dependencies
@@ -173,17 +174,19 @@ class Editor extends Component {
173
174
  };
174
175
 
175
176
  return (
176
- <SlotFillProvider>
177
- <EditorProvider
178
- settings={ editorSettings }
179
- post={ normalizedPost }
180
- initialEdits={ initialEdits }
181
- useSubRegistry={ false }
182
- { ...props }
183
- >
184
- <Layout setTitleRef={ this.setTitleRef } />
185
- </EditorProvider>
186
- </SlotFillProvider>
177
+ <GestureHandlerRootView style={ { flex: 1 } }>
178
+ <SlotFillProvider>
179
+ <EditorProvider
180
+ settings={ editorSettings }
181
+ post={ normalizedPost }
182
+ initialEdits={ initialEdits }
183
+ useSubRegistry={ false }
184
+ { ...props }
185
+ >
186
+ <Layout setTitleRef={ this.setTitleRef } />
187
+ </EditorProvider>
188
+ </SlotFillProvider>
189
+ </GestureHandlerRootView>
187
190
  );
188
191
  }
189
192
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { find } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -44,8 +39,7 @@ const enhance = compose(
44
39
  // Otherwise, only pass `originalBlockClientId` if it refers to a different
45
40
  // block from the current one.
46
41
  const blocks = select( blockEditorStore ).getBlocks();
47
- const firstOfSameType = find(
48
- blocks,
42
+ const firstOfSameType = blocks.find(
49
43
  ( { name } ) => block.name === name
50
44
  );
51
45
  const isInvalid =
@@ -14,6 +14,7 @@ import CopyContentMenuItem from './copy-content-menu-item';
14
14
  import KeyboardShortcutsHelpMenuItem from './keyboard-shortcuts-help-menu-item';
15
15
  import ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';
16
16
  import WelcomeGuideMenuItem from './welcome-guide-menu-item';
17
+ import NavigationListViewMenuItem from './navigation-list-view-menu-item';
17
18
 
18
19
  registerPlugin( 'edit-post', {
19
20
  render() {
@@ -55,6 +56,7 @@ registerPlugin( 'edit-post', {
55
56
  </>
56
57
  ) }
57
58
  </ToolsMoreMenuGroup>
59
+ <NavigationListViewMenuItem />
58
60
  </>
59
61
  );
60
62
  },
@@ -0,0 +1,56 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ BlockEditorProvider,
6
+ __unstableBlockToolbarLastItem,
7
+ __unstableBlockNameContext,
8
+ } from '@wordpress/block-editor';
9
+ import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
10
+ import { useDispatch } from '@wordpress/data';
11
+ import { Fragment } from '@wordpress/element';
12
+ import { __ } from '@wordpress/i18n';
13
+ import { listView } from '@wordpress/icons';
14
+
15
+ const NavMenuSidebarToggle = () => {
16
+ // eslint-disable-next-line @wordpress/data-no-store-string-literals
17
+ const { openGeneralSidebar } = useDispatch( 'core/edit-post' );
18
+
19
+ return (
20
+ <ToolbarGroup>
21
+ <ToolbarButton
22
+ className="components-toolbar__control"
23
+ label={ __( 'Open navigation list view' ) }
24
+ onClick={ () => openGeneralSidebar( 'edit-post/block' ) }
25
+ icon={ listView }
26
+ />
27
+ </ToolbarGroup>
28
+ );
29
+ };
30
+
31
+ let MaybeNavMenuSidebarToggle = Fragment;
32
+
33
+ const isOffCanvasNavigationEditorEnabled =
34
+ window?.__experimentalEnableOffCanvasNavigationEditor === true;
35
+
36
+ if ( isOffCanvasNavigationEditorEnabled ) {
37
+ MaybeNavMenuSidebarToggle = NavMenuSidebarToggle;
38
+ }
39
+
40
+ const NavigationEditMenuItem = () => {
41
+ return (
42
+ <BlockEditorProvider>
43
+ <__unstableBlockToolbarLastItem>
44
+ <__unstableBlockNameContext.Consumer>
45
+ { ( blockName ) =>
46
+ blockName === 'core/navigation' && (
47
+ <MaybeNavMenuSidebarToggle />
48
+ )
49
+ }
50
+ </__unstableBlockNameContext.Consumer>
51
+ </__unstableBlockToolbarLastItem>
52
+ </BlockEditorProvider>
53
+ );
54
+ };
55
+
56
+ export default NavigationEditMenuItem;