@wordpress/editor 13.28.5 → 13.30.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 (144) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/block-removal-warnings/index.js +70 -0
  3. package/build/components/block-removal-warnings/index.js.map +1 -0
  4. package/build/components/commands/index.js +209 -0
  5. package/build/components/commands/index.js.map +1 -0
  6. package/build/components/commands/index.native.js +9 -0
  7. package/build/components/commands/index.native.js.map +1 -0
  8. package/build/components/document-bar/index.js +78 -67
  9. package/build/components/document-bar/index.js.map +1 -1
  10. package/build/components/document-outline/check.js +8 -7
  11. package/build/components/document-outline/check.js.map +1 -1
  12. package/build/components/document-outline/index.js +26 -27
  13. package/build/components/document-outline/index.js.map +1 -1
  14. package/build/components/document-tools/index.js +5 -3
  15. package/build/components/document-tools/index.js.map +1 -1
  16. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  17. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  18. package/build/components/global-keyboard-shortcuts/index.js +20 -2
  19. package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
  20. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
  21. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  22. package/build/components/list-view-sidebar/index.js +1 -1
  23. package/build/components/list-view-sidebar/index.js.map +1 -1
  24. package/build/components/mode-switcher/index.js +86 -0
  25. package/build/components/mode-switcher/index.js.map +1 -0
  26. package/build/components/post-locked-modal/index.js.map +1 -1
  27. package/build/components/post-preview-button/index.js +2 -1
  28. package/build/components/post-preview-button/index.js.map +1 -1
  29. package/build/components/post-publish-button/index.js +2 -1
  30. package/build/components/post-publish-button/index.js.map +1 -1
  31. package/build/components/post-publish-panel/index.js.map +1 -1
  32. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  33. package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  34. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  35. package/build/components/post-title/index.js +0 -5
  36. package/build/components/post-title/index.js.map +1 -1
  37. package/build/components/post-title/index.native.js.map +1 -1
  38. package/build/components/post-title/post-title-raw.js.map +1 -1
  39. package/build/components/post-view-link/index.js +2 -1
  40. package/build/components/post-view-link/index.js.map +1 -1
  41. package/build/components/provider/index.js +8 -1
  42. package/build/components/provider/index.js.map +1 -1
  43. package/build/components/provider/index.native.js +4 -9
  44. package/build/components/provider/index.native.js.map +1 -1
  45. package/build/components/provider/use-block-editor-settings.js +1 -1
  46. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  47. package/build/components/provider/use-hide-blocks-from-inserter.js +53 -0
  48. package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
  49. package/build/private-apis.js +2 -0
  50. package/build/private-apis.js.map +1 -1
  51. package/build/store/actions.js +69 -2
  52. package/build/store/actions.js.map +1 -1
  53. package/build/store/selectors.js +13 -1
  54. package/build/store/selectors.js.map +1 -1
  55. package/build-module/components/block-removal-warnings/index.js +64 -0
  56. package/build-module/components/block-removal-warnings/index.js.map +1 -0
  57. package/build-module/components/commands/index.js +202 -0
  58. package/build-module/components/commands/index.js.map +1 -0
  59. package/build-module/components/commands/index.native.js +3 -0
  60. package/build-module/components/commands/index.native.js.map +1 -0
  61. package/build-module/components/document-bar/index.js +81 -70
  62. package/build-module/components/document-bar/index.js.map +1 -1
  63. package/build-module/components/document-outline/check.js +9 -8
  64. package/build-module/components/document-outline/check.js.map +1 -1
  65. package/build-module/components/document-outline/index.js +26 -26
  66. package/build-module/components/document-outline/index.js.map +1 -1
  67. package/build-module/components/document-tools/index.js +5 -3
  68. package/build-module/components/document-tools/index.js.map +1 -1
  69. package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
  70. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  71. package/build-module/components/global-keyboard-shortcuts/index.js +20 -2
  72. package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
  73. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
  74. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  75. package/build-module/components/list-view-sidebar/index.js +1 -1
  76. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  77. package/build-module/components/mode-switcher/index.js +80 -0
  78. package/build-module/components/mode-switcher/index.js.map +1 -0
  79. package/build-module/components/post-locked-modal/index.js.map +1 -1
  80. package/build-module/components/post-preview-button/index.js +2 -1
  81. package/build-module/components/post-preview-button/index.js.map +1 -1
  82. package/build-module/components/post-publish-button/index.js +2 -1
  83. package/build-module/components/post-publish-button/index.js.map +1 -1
  84. package/build-module/components/post-publish-panel/index.js.map +1 -1
  85. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  86. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  87. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  88. package/build-module/components/post-title/index.js +0 -5
  89. package/build-module/components/post-title/index.js.map +1 -1
  90. package/build-module/components/post-title/index.native.js.map +1 -1
  91. package/build-module/components/post-title/post-title-raw.js.map +1 -1
  92. package/build-module/components/post-view-link/index.js +2 -1
  93. package/build-module/components/post-view-link/index.js.map +1 -1
  94. package/build-module/components/provider/index.js +8 -1
  95. package/build-module/components/provider/index.js.map +1 -1
  96. package/build-module/components/provider/index.native.js +4 -10
  97. package/build-module/components/provider/index.native.js.map +1 -1
  98. package/build-module/components/provider/use-block-editor-settings.js +1 -1
  99. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  100. package/build-module/components/provider/use-hide-blocks-from-inserter.js +47 -0
  101. package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
  102. package/build-module/private-apis.js +2 -0
  103. package/build-module/private-apis.js.map +1 -1
  104. package/build-module/store/actions.js +66 -0
  105. package/build-module/store/actions.js.map +1 -1
  106. package/build-module/store/selectors.js +12 -0
  107. package/build-module/store/selectors.js.map +1 -1
  108. package/build-style/style-rtl.css +4 -47
  109. package/build-style/style.css +4 -47
  110. package/package.json +32 -32
  111. package/src/components/block-removal-warnings/index.js +92 -0
  112. package/src/components/commands/index.js +210 -0
  113. package/src/components/commands/index.native.js +2 -0
  114. package/src/components/document-bar/index.js +115 -94
  115. package/src/components/document-bar/style.scss +4 -37
  116. package/src/components/document-outline/check.js +8 -10
  117. package/src/components/document-outline/index.js +18 -23
  118. package/src/components/document-outline/test/index.js +26 -7
  119. package/src/components/document-tools/index.js +3 -3
  120. package/src/components/editor-help/intro-to-blocks.native.js +1 -1
  121. package/src/components/entities-saved-states/entity-type-list.js +1 -1
  122. package/src/components/global-keyboard-shortcuts/index.js +35 -4
  123. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +20 -0
  124. package/src/components/list-view-sidebar/index.js +1 -1
  125. package/src/components/mode-switcher/index.js +90 -0
  126. package/src/components/post-locked-modal/index.js +1 -1
  127. package/src/components/post-preview-button/index.js +1 -0
  128. package/src/components/post-publish-button/index.js +1 -0
  129. package/src/components/post-publish-panel/index.js +1 -1
  130. package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
  131. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +3 -3
  132. package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  133. package/src/components/post-title/index.js +0 -3
  134. package/src/components/post-title/index.native.js +2 -2
  135. package/src/components/post-title/post-title-raw.js +1 -1
  136. package/src/components/post-view-link/index.js +1 -0
  137. package/src/components/provider/index.js +9 -0
  138. package/src/components/provider/index.native.js +7 -6
  139. package/src/components/provider/use-block-editor-settings.js +0 -3
  140. package/src/components/provider/use-hide-blocks-from-inserter.js +81 -0
  141. package/src/private-apis.js +2 -0
  142. package/src/store/actions.js +95 -0
  143. package/src/store/selectors.js +12 -0
  144. package/src/store/test/actions.js +82 -0
@@ -40,6 +40,10 @@
40
40
  flex-grow: 1;
41
41
  overflow: hidden;
42
42
  color: $gray-800;
43
+ gap: $grid-unit-05;
44
+ display: flex;
45
+ justify-content: center;
46
+ align-items: center;
43
47
 
44
48
  // Offset the layout based on the width of the ⌘K label. This ensures the title is centrally aligned.
45
49
  @include break-small() {
@@ -66,16 +70,6 @@
66
70
  max-width: 50%;
67
71
  color: currentColor;
68
72
  }
69
-
70
- .editor-document-bar.is-animated.has-back-button & {
71
- animation: editor-document-bar__slide-in-left 0.3s;
72
- @include reduce-motion("animation");
73
- }
74
-
75
- .editor-document-bar.is-animated & {
76
- animation: editor-document-bar__slide-in-right 0.3s;
77
- @include reduce-motion("animation");
78
- }
79
73
  }
80
74
 
81
75
  .editor-document-bar__shortcut {
@@ -100,31 +94,4 @@
100
94
  color: var(--wp-block-synced-color);
101
95
  background-color: transparent;
102
96
  }
103
-
104
- .editor-document-bar.is-animated & {
105
- animation: editor-document-bar__slide-in-left 0.3s;
106
- @include reduce-motion("animation");
107
- }
108
- }
109
-
110
- @keyframes editor-document-bar__slide-in-right {
111
- from {
112
- transform: translateX(-15%);
113
- opacity: 0;
114
- }
115
- to {
116
- transform: translateX(0);
117
- opacity: 1;
118
- }
119
- }
120
-
121
- @keyframes editor-document-bar__slide-in-left {
122
- from {
123
- transform: translateX(15%);
124
- opacity: 0;
125
- }
126
- to {
127
- transform: translateX(0);
128
- opacity: 1;
129
- }
130
97
  }
@@ -1,21 +1,19 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { withSelect } from '@wordpress/data';
4
+ import { useSelect } from '@wordpress/data';
5
5
  import { store as blockEditorStore } from '@wordpress/block-editor';
6
6
 
7
- function DocumentOutlineCheck( { blocks, children } ) {
8
- const headings = blocks.filter(
9
- ( block ) => block.name === 'core/heading'
10
- );
7
+ export default function DocumentOutlineCheck( { children } ) {
8
+ const hasHeadings = useSelect( ( select ) => {
9
+ const { getGlobalBlockCount } = select( blockEditorStore );
11
10
 
12
- if ( headings.length < 1 ) {
11
+ return getGlobalBlockCount( 'core/heading' ) > 0;
12
+ } );
13
+
14
+ if ( hasHeadings ) {
13
15
  return null;
14
16
  }
15
17
 
16
18
  return children;
17
19
  }
18
-
19
- export default withSelect( ( select ) => ( {
20
- blocks: select( blockEditorStore ).getBlocks(),
21
- } ) )( DocumentOutlineCheck );
@@ -2,8 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { compose } from '@wordpress/compose';
6
- import { withSelect, useDispatch } from '@wordpress/data';
5
+ import { useDispatch, useSelect } from '@wordpress/data';
7
6
  import { create, getTextContent } from '@wordpress/rich-text';
8
7
  import { store as blockEditorStore } from '@wordpress/block-editor';
9
8
  import { store as coreStore } from '@wordpress/core-data';
@@ -98,15 +97,26 @@ const computeOutlineHeadings = ( blocks = [] ) => {
98
97
  const isEmptyHeading = ( heading ) =>
99
98
  ! heading.attributes.content || heading.attributes.content.length === 0;
100
99
 
101
- export const DocumentOutline = ( {
102
- blocks = [],
103
- title,
100
+ export default function DocumentOutline( {
104
101
  onSelect,
105
102
  isTitleSupported,
106
103
  hasOutlineItemsDisabled,
107
- } ) => {
108
- const headings = computeOutlineHeadings( blocks );
104
+ } ) {
109
105
  const { selectBlock } = useDispatch( blockEditorStore );
106
+ const { blocks, title } = useSelect( ( select ) => {
107
+ const { getBlocks } = select( blockEditorStore );
108
+ const { getEditedPostAttribute } = select( editorStore );
109
+ const { getPostType } = select( coreStore );
110
+ const postType = getPostType( getEditedPostAttribute( 'type' ) );
111
+
112
+ return {
113
+ title: getEditedPostAttribute( 'title' ),
114
+ blocks: getBlocks(),
115
+ isTitleSupported: postType?.supports?.title ?? false,
116
+ };
117
+ } );
118
+
119
+ const headings = computeOutlineHeadings( blocks );
110
120
  if ( headings.length < 1 ) {
111
121
  return (
112
122
  <div className="editor-document-outline has-no-headings">
@@ -194,19 +204,4 @@ export const DocumentOutline = ( {
194
204
  </ul>
195
205
  </div>
196
206
  );
197
- };
198
-
199
- export default compose(
200
- withSelect( ( select ) => {
201
- const { getBlocks } = select( blockEditorStore );
202
- const { getEditedPostAttribute } = select( editorStore );
203
- const { getPostType } = select( coreStore );
204
- const postType = getPostType( getEditedPostAttribute( 'type' ) );
205
-
206
- return {
207
- title: getEditedPostAttribute( 'title' ),
208
- blocks: getBlocks(),
209
- isTitleSupported: postType?.supports?.title ?? false,
210
- };
211
- } )
212
- )( DocumentOutline );
207
+ }
@@ -11,15 +11,27 @@ import {
11
11
  registerBlockType,
12
12
  unregisterBlockType,
13
13
  } from '@wordpress/blocks';
14
+ import { useSelect } from '@wordpress/data';
14
15
 
15
16
  /**
16
17
  * Internal dependencies
17
18
  */
18
- import { DocumentOutline } from '../';
19
+ import DocumentOutline from '../';
19
20
 
20
21
  jest.mock( '@wordpress/block-editor', () => ( {
21
22
  BlockTitle: () => 'Block Title',
22
23
  } ) );
24
+ jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
25
+
26
+ function setupMockSelect( blocks ) {
27
+ useSelect.mockImplementation( ( mapSelect ) => {
28
+ return mapSelect( () => ( {
29
+ getBlocks: () => blocks,
30
+ getEditedPostAttribute: () => null,
31
+ getPostType: () => null,
32
+ } ) );
33
+ } );
34
+ }
23
35
 
24
36
  describe( 'DocumentOutline', () => {
25
37
  let paragraph, headingH1, headingH2, headingH3, nestedHeading;
@@ -77,6 +89,7 @@ describe( 'DocumentOutline', () => {
77
89
 
78
90
  describe( 'no header blocks present', () => {
79
91
  it( 'should not render when no blocks provided', () => {
92
+ setupMockSelect( [] );
80
93
  render( <DocumentOutline /> );
81
94
 
82
95
  expect( screen.queryByRole( 'list' ) ).not.toBeInTheDocument();
@@ -87,7 +100,8 @@ describe( 'DocumentOutline', () => {
87
100
  // Set client IDs to a predictable value.
88
101
  return { ...block, clientId: `clientId_${ index }` };
89
102
  } );
90
- render( <DocumentOutline blocks={ blocks } /> );
103
+ setupMockSelect( blocks );
104
+ render( <DocumentOutline /> );
91
105
 
92
106
  expect( screen.queryByRole( 'list' ) ).not.toBeInTheDocument();
93
107
  } );
@@ -99,14 +113,16 @@ describe( 'DocumentOutline', () => {
99
113
  // Set client IDs to a predictable value.
100
114
  return { ...block, clientId: `clientId_${ index }` };
101
115
  } );
102
- render( <DocumentOutline blocks={ blocks } /> );
116
+ setupMockSelect( blocks );
117
+ render( <DocumentOutline /> );
103
118
 
104
119
  expect( screen.getByRole( 'list' ) ).toMatchSnapshot();
105
120
  } );
106
121
 
107
122
  it( 'should render an item when only one heading provided', () => {
108
123
  const blocks = [ headingH2 ];
109
- render( <DocumentOutline blocks={ blocks } /> );
124
+ setupMockSelect( blocks );
125
+ render( <DocumentOutline /> );
110
126
 
111
127
  const tableOfContentItem = within(
112
128
  screen.getByRole( 'list' )
@@ -123,7 +139,8 @@ describe( 'DocumentOutline', () => {
123
139
  headingH3,
124
140
  paragraph,
125
141
  ];
126
- render( <DocumentOutline blocks={ blocks } /> );
142
+ setupMockSelect( blocks );
143
+ render( <DocumentOutline /> );
127
144
 
128
145
  expect(
129
146
  within( screen.getByRole( 'list' ) ).getAllByRole( 'listitem' )
@@ -137,7 +154,8 @@ describe( 'DocumentOutline', () => {
137
154
  return { ...block, clientId: `clientId_${ index }` };
138
155
  }
139
156
  );
140
- render( <DocumentOutline blocks={ blocks } /> );
157
+ setupMockSelect( blocks );
158
+ render( <DocumentOutline /> );
141
159
 
142
160
  expect( screen.getByRole( 'list' ) ).toMatchSnapshot();
143
161
  } );
@@ -146,7 +164,8 @@ describe( 'DocumentOutline', () => {
146
164
  describe( 'nested headings', () => {
147
165
  it( 'should render even if the heading is nested', () => {
148
166
  const blocks = [ headingH2, nestedHeading ];
149
- render( <DocumentOutline blocks={ blocks } /> );
167
+ setupMockSelect( blocks );
168
+ render( <DocumentOutline /> );
150
169
 
151
170
  // Unnested heading and nested heading should appear as items.
152
171
  const tableOfContentItems = within(
@@ -29,7 +29,7 @@ import { store as editorStore } from '../../store';
29
29
  import EditorHistoryRedo from '../editor-history/redo';
30
30
  import EditorHistoryUndo from '../editor-history/undo';
31
31
 
32
- const { useCanBlockToolbarBeFocused } = unlock( blockEditorPrivateApis );
32
+ const { useShowBlockTools } = unlock( blockEditorPrivateApis );
33
33
 
34
34
  const preventDefault = ( event ) => {
35
35
  event.preventDefault();
@@ -76,7 +76,7 @@ function DocumentTools( {
76
76
 
77
77
  const isLargeViewport = useViewportMatch( 'medium' );
78
78
  const isWideViewport = useViewportMatch( 'wide' );
79
- const blockToolbarCanBeFocused = useCanBlockToolbarBeFocused();
79
+ const { showFixedToolbar } = useShowBlockTools();
80
80
 
81
81
  /* translators: accessibility text for the editor toolbar */
82
82
  const toolbarAriaLabel = __( 'Document tools' );
@@ -117,7 +117,7 @@ function DocumentTools( {
117
117
  className
118
118
  ) }
119
119
  aria-label={ toolbarAriaLabel }
120
- shouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }
120
+ shouldUseKeyboardFocusShortcut={ ! showFixedToolbar }
121
121
  variant="unstyled"
122
122
  >
123
123
  <div className="editor-document-tools__left">
@@ -51,7 +51,7 @@ const IntroToBlocks = () => {
51
51
  ) }
52
52
  />
53
53
  <HelpDetailImage
54
- accessible={ true }
54
+ accessible
55
55
  accessibilityLabel={ __(
56
56
  'Text formatting controls are located within the toolbar positioned above the keyboard while editing a text block'
57
57
  ) }
@@ -94,7 +94,7 @@ export default function EntityTypeList( {
94
94
  }
95
95
 
96
96
  return (
97
- <PanelBody title={ entityLabel } initialOpen={ true }>
97
+ <PanelBody title={ entityLabel } initialOpen>
98
98
  <EntityDescription record={ firstRecord } count={ count } />
99
99
  { list.map( ( record ) => {
100
100
  return (
@@ -10,10 +10,41 @@ import { useDispatch, useSelect } from '@wordpress/data';
10
10
  import { store as editorStore } from '../../store';
11
11
 
12
12
  export default function EditorKeyboardShortcuts() {
13
- const { redo, undo, savePost, setIsListViewOpened } =
14
- useDispatch( editorStore );
15
- const { isEditedPostDirty, isPostSavingLocked, isListViewOpened } =
16
- useSelect( editorStore );
13
+ const isModeToggleDisabled = useSelect( ( select ) => {
14
+ const { richEditingEnabled, codeEditingEnabled } =
15
+ select( editorStore ).getEditorSettings();
16
+ return ! richEditingEnabled || ! codeEditingEnabled;
17
+ }, [] );
18
+ const {
19
+ redo,
20
+ undo,
21
+ savePost,
22
+ setIsListViewOpened,
23
+ switchEditorMode,
24
+ toggleDistractionFree,
25
+ } = useDispatch( editorStore );
26
+ const {
27
+ isEditedPostDirty,
28
+ isPostSavingLocked,
29
+ isListViewOpened,
30
+ getEditorMode,
31
+ } = useSelect( editorStore );
32
+
33
+ useShortcut(
34
+ 'core/editor/toggle-mode',
35
+ () => {
36
+ switchEditorMode(
37
+ getEditorMode() === 'visual' ? 'text' : 'visual'
38
+ );
39
+ },
40
+ {
41
+ isDisabled: isModeToggleDisabled,
42
+ }
43
+ );
44
+
45
+ useShortcut( 'core/editor/toggle-distraction-free', () => {
46
+ toggleDistractionFree();
47
+ } );
17
48
 
18
49
  useShortcut( 'core/editor/undo', ( event ) => {
19
50
  undo();
@@ -12,6 +12,16 @@ function EditorKeyboardShortcutsRegister() {
12
12
  // Registering the shortcuts.
13
13
  const { registerShortcut } = useDispatch( keyboardShortcutsStore );
14
14
  useEffect( () => {
15
+ registerShortcut( {
16
+ name: 'core/editor/toggle-mode',
17
+ category: 'global',
18
+ description: __( 'Switch between visual editor and code editor.' ),
19
+ keyCombination: {
20
+ modifier: 'secondary',
21
+ character: 'm',
22
+ },
23
+ } );
24
+
15
25
  registerShortcut( {
16
26
  name: 'core/editor/save',
17
27
  category: 'global',
@@ -63,6 +73,16 @@ function EditorKeyboardShortcutsRegister() {
63
73
  character: 'o',
64
74
  },
65
75
  } );
76
+
77
+ registerShortcut( {
78
+ name: 'core/editor/toggle-distraction-free',
79
+ category: 'global',
80
+ description: __( 'Toggle distraction free mode.' ),
81
+ keyCombination: {
82
+ modifier: 'primaryShift',
83
+ character: '\\',
84
+ },
85
+ } );
66
86
  }, [ registerShortcut ] );
67
87
 
68
88
  return <BlockEditorKeyboardShortcuts.Register />;
@@ -127,7 +127,7 @@ export default function ListViewSidebar() {
127
127
  // render where no tab is selected. This ensures that the
128
128
  // tabpanel height is correct so the relevant scroll container
129
129
  // can be rendered internally.
130
- initialTabId="list-view"
130
+ defaultTabId="list-view"
131
131
  >
132
132
  <div className="edit-post-editor__document-overview-panel__header">
133
133
  <Button
@@ -0,0 +1,90 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
6
+ import { useSelect, useDispatch } from '@wordpress/data';
7
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { store as editorStore } from '../../store';
13
+
14
+ /**
15
+ * Set of available mode options.
16
+ *
17
+ * @type {Array}
18
+ */
19
+ const MODES = [
20
+ {
21
+ value: 'visual',
22
+ label: __( 'Visual editor' ),
23
+ },
24
+ {
25
+ value: 'text',
26
+ label: __( 'Code editor' ),
27
+ },
28
+ ];
29
+
30
+ function ModeSwitcher() {
31
+ const { shortcut, isRichEditingEnabled, isCodeEditingEnabled, mode } =
32
+ useSelect(
33
+ ( select ) => ( {
34
+ shortcut: select(
35
+ keyboardShortcutsStore
36
+ ).getShortcutRepresentation( 'core/editor/toggle-mode' ),
37
+ isRichEditingEnabled:
38
+ select( editorStore ).getEditorSettings()
39
+ .richEditingEnabled,
40
+ isCodeEditingEnabled:
41
+ select( editorStore ).getEditorSettings()
42
+ .codeEditingEnabled,
43
+ mode: select( editorStore ).getEditorMode(),
44
+ } ),
45
+ []
46
+ );
47
+ const { switchEditorMode } = useDispatch( editorStore );
48
+
49
+ let selectedMode = mode;
50
+ if ( ! isRichEditingEnabled && mode === 'visual' ) {
51
+ selectedMode = 'text';
52
+ }
53
+ if ( ! isCodeEditingEnabled && mode === 'text' ) {
54
+ selectedMode = 'visual';
55
+ }
56
+
57
+ const choices = MODES.map( ( choice ) => {
58
+ if ( ! isCodeEditingEnabled && choice.value === 'text' ) {
59
+ choice = {
60
+ ...choice,
61
+ disabled: true,
62
+ };
63
+ }
64
+ if ( ! isRichEditingEnabled && choice.value === 'visual' ) {
65
+ choice = {
66
+ ...choice,
67
+ disabled: true,
68
+ info: __(
69
+ 'You can enable the visual editor in your profile settings.'
70
+ ),
71
+ };
72
+ }
73
+ if ( choice.value !== selectedMode && ! choice.disabled ) {
74
+ return { ...choice, shortcut };
75
+ }
76
+ return choice;
77
+ } );
78
+
79
+ return (
80
+ <MenuGroup label={ __( 'Editor' ) }>
81
+ <MenuItemsChoice
82
+ choices={ choices }
83
+ value={ selectedMode }
84
+ onSelect={ switchEditorMode }
85
+ />
86
+ </MenuGroup>
87
+ );
88
+ }
89
+
90
+ export default ModeSwitcher;
@@ -168,7 +168,7 @@ export default function PostLockedModal() {
168
168
  ? __( 'Someone else has taken over this post' )
169
169
  : __( 'This post is already being edited' )
170
170
  }
171
- focusOnMount={ true }
171
+ focusOnMount
172
172
  shouldCloseOnClickOutside={ false }
173
173
  shouldCloseOnEsc={ false }
174
174
  isDismissible={ false }
@@ -171,6 +171,7 @@ export default function PostPreviewButton( {
171
171
  disabled={ ! isSaveable }
172
172
  onClick={ openPreviewWindow }
173
173
  role={ role }
174
+ size="compact"
174
175
  >
175
176
  { textContent || (
176
177
  <>
@@ -203,6 +203,7 @@ export class PostPublishButton extends Component {
203
203
  'has-changes-dot': hasNonPostEntityChanges,
204
204
  }
205
205
  ) }
206
+ size="compact"
206
207
  >
207
208
  { componentChildren }
208
209
  </Button>
@@ -110,7 +110,7 @@ export class PostPublishPanel extends Component {
110
110
  </PostPublishPanelPrepublish>
111
111
  ) }
112
112
  { isPostPublish && (
113
- <PostPublishPanelPostpublish focusOnMount={ true }>
113
+ <PostPublishPanelPostpublish focusOnMount>
114
114
  { PostPublishExtension && <PostPublishExtension /> }
115
115
  </PostPublishPanelPostpublish>
116
116
  ) }
@@ -131,7 +131,7 @@ export default function PostFormatPanel() {
131
131
  }
132
132
 
133
133
  return (
134
- <PanelBody initialOpen={ true } title={ panelBodyTitle }>
134
+ <PanelBody initialOpen title={ panelBodyTitle }>
135
135
  <p>
136
136
  { __(
137
137
  'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'
@@ -353,7 +353,7 @@ exports[`PostPublishPanel should render the pre-publish panel if post status is
353
353
  >
354
354
  <button
355
355
  aria-disabled="true"
356
- class="components-button editor-post-publish-button editor-post-publish-button__button is-primary"
356
+ class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
357
357
  type="button"
358
358
  >
359
359
  Submit for Review
@@ -476,7 +476,7 @@ exports[`PostPublishPanel should render the pre-publish panel if the post is not
476
476
  >
477
477
  <button
478
478
  aria-disabled="true"
479
- class="components-button editor-post-publish-button editor-post-publish-button__button is-primary"
479
+ class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
480
480
  type="button"
481
481
  >
482
482
  Submit for Review
@@ -643,7 +643,7 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
643
643
  >
644
644
  <button
645
645
  aria-disabled="true"
646
- class="components-button editor-post-publish-button editor-post-publish-button__button is-primary"
646
+ class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
647
647
  type="button"
648
648
  >
649
649
  Submit for Review
@@ -439,6 +439,7 @@ export function HierarchicalTermSelector( { slug } ) {
439
439
  <form onSubmit={ onAddTerm }>
440
440
  <Flex direction="column" gap="4">
441
441
  <TextControl
442
+ __next40pxDefaultSize
442
443
  __nextHasNoMarginBottom
443
444
  className="editor-post-taxonomies__hierarchical-terms-input"
444
445
  label={ newTermLabel }
@@ -448,6 +449,7 @@ export function HierarchicalTermSelector( { slug } ) {
448
449
  />
449
450
  { !! availableTerms.length && (
450
451
  <TreeSelect
452
+ __next40pxDefaultSize
451
453
  __nextHasNoMarginBottom
452
454
  label={ parentSelectLabel }
453
455
  noOptionLabel={ noParentOption }
@@ -458,6 +460,7 @@ export function HierarchicalTermSelector( { slug } ) {
458
460
  ) }
459
461
  <FlexItem>
460
462
  <Button
463
+ __next40pxDefaultSize
461
464
  variant="secondary"
462
465
  type="submit"
463
466
  className="editor-post-taxonomies__hierarchical-terms-submit"
@@ -25,7 +25,6 @@ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
25
25
  /**
26
26
  * Internal dependencies
27
27
  */
28
- import { store as editorStore } from '../../store';
29
28
  import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';
30
29
  import usePostTitleFocus from './use-post-title-focus';
31
30
  import usePostTitle from './use-post-title';
@@ -33,13 +32,11 @@ import PostTypeSupportCheck from '../post-type-support-check';
33
32
 
34
33
  function PostTitle( _, forwardedRef ) {
35
34
  const { placeholder, hasFixedToolbar } = useSelect( ( select ) => {
36
- const { getEditedPostAttribute } = select( editorStore );
37
35
  const { getSettings } = select( blockEditorStore );
38
36
  const { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } =
39
37
  getSettings();
40
38
 
41
39
  return {
42
- title: getEditedPostAttribute( 'title' ),
43
40
  placeholder: titlePlaceholder,
44
41
  hasFixedToolbar: _hasFixedToolbar,
45
42
  };
@@ -175,7 +175,7 @@ class PostTitle extends Component {
175
175
  fontSize={ 24 }
176
176
  lineHeight={ 1 }
177
177
  fontWeight={ 'bold' }
178
- deleteEnter={ true }
178
+ deleteEnter
179
179
  onChange={ ( value ) => {
180
180
  this.props.onUpdate( value );
181
181
  } }
@@ -184,7 +184,7 @@ class PostTitle extends Component {
184
184
  value={ title }
185
185
  onSelectionChange={ () => {} }
186
186
  onEnter={ this.props.onEnterPress }
187
- disableEditingMenu={ true }
187
+ disableEditingMenu
188
188
  __unstableIsSelected={ this.props.isSelected }
189
189
  __unstableOnCreateUndoLevel={ () => {} }
190
190
  />
@@ -70,7 +70,7 @@ function PostTitleRaw( _, forwardedRef ) {
70
70
  label={ placeholder }
71
71
  className={ className }
72
72
  placeholder={ decodedPlaceholder }
73
- hideLabelFromVision={ true }
73
+ hideLabelFromVision
74
74
  autoComplete="off"
75
75
  dir="auto"
76
76
  rows={ 1 }
@@ -42,6 +42,7 @@ export default function PostViewLink() {
42
42
  href={ permalink }
43
43
  target="_blank"
44
44
  showTooltip={ ! showIconLabels }
45
+ size="compact"
45
46
  />
46
47
  );
47
48
  }
@@ -23,6 +23,9 @@ import useBlockEditorSettings from './use-block-editor-settings';
23
23
  import { unlock } from '../../lock-unlock';
24
24
  import DisableNonPageContentBlocks from './disable-non-page-content-blocks';
25
25
  import NavigationBlockEditingMode from './navigation-block-editing-mode';
26
+ import { useHideBlocksFromInserter } from './use-hide-blocks-from-inserter';
27
+ import useCommands from '../commands';
28
+ import BlockRemovalWarnings from '../block-removal-warnings';
26
29
 
27
30
  const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );
28
31
  const { PatternsMenuItems } = unlock( editPatternsPrivateApis );
@@ -229,6 +232,11 @@ export const ExperimentalEditorProvider = withRegistryProvider(
229
232
  setRenderingMode( settings.defaultRenderingMode ?? 'post-only' );
230
233
  }, [ settings.defaultRenderingMode, setRenderingMode ] );
231
234
 
235
+ useHideBlocksFromInserter( post.type );
236
+
237
+ // Register the editor commands.
238
+ useCommands();
239
+
232
240
  if ( ! isReady ) {
233
241
  return null;
234
242
  }
@@ -257,6 +265,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
257
265
  { type === 'wp_navigation' && (
258
266
  <NavigationBlockEditingMode />
259
267
  ) }
268
+ <BlockRemovalWarnings />
260
269
  </BlockEditorProviderComponent>
261
270
  </BlockContextProvider>
262
271
  </EntityProvider>