@wordpress/editor 13.29.0 → 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 (115) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/index.js +2 -2
  3. package/build/bindings/index.js.map +1 -1
  4. package/build/bindings/post-meta.js +2 -1
  5. package/build/bindings/post-meta.js.map +1 -1
  6. package/build/components/block-removal-warnings/index.js +70 -0
  7. package/build/components/block-removal-warnings/index.js.map +1 -0
  8. package/build/components/commands/index.js +22 -14
  9. package/build/components/commands/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/list-view-sidebar/index.js +1 -1
  19. package/build/components/list-view-sidebar/index.js.map +1 -1
  20. package/build/components/post-locked-modal/index.js.map +1 -1
  21. package/build/components/post-preview-button/index.js +2 -1
  22. package/build/components/post-preview-button/index.js.map +1 -1
  23. package/build/components/post-publish-button/index.js +2 -1
  24. package/build/components/post-publish-button/index.js.map +1 -1
  25. package/build/components/post-publish-panel/index.js.map +1 -1
  26. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  27. package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  28. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  29. package/build/components/post-title/index.native.js.map +1 -1
  30. package/build/components/post-title/post-title-raw.js.map +1 -1
  31. package/build/components/post-view-link/index.js +2 -1
  32. package/build/components/post-view-link/index.js.map +1 -1
  33. package/build/components/provider/disable-non-page-content-blocks.js +23 -30
  34. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  35. package/build/components/provider/index.js +2 -1
  36. package/build/components/provider/index.js.map +1 -1
  37. package/build/hooks/index.js +1 -1
  38. package/build/hooks/index.js.map +1 -1
  39. package/build/hooks/{pattern-partial-syncing.js → pattern-overrides.js} +13 -9
  40. package/build/hooks/pattern-overrides.js.map +1 -0
  41. package/build-module/bindings/index.js +2 -2
  42. package/build-module/bindings/index.js.map +1 -1
  43. package/build-module/bindings/post-meta.js +2 -1
  44. package/build-module/bindings/post-meta.js.map +1 -1
  45. package/build-module/components/block-removal-warnings/index.js +64 -0
  46. package/build-module/components/block-removal-warnings/index.js.map +1 -0
  47. package/build-module/components/commands/index.js +22 -14
  48. package/build-module/components/commands/index.js.map +1 -1
  49. package/build-module/components/document-outline/check.js +9 -8
  50. package/build-module/components/document-outline/check.js.map +1 -1
  51. package/build-module/components/document-outline/index.js +26 -26
  52. package/build-module/components/document-outline/index.js.map +1 -1
  53. package/build-module/components/document-tools/index.js +5 -3
  54. package/build-module/components/document-tools/index.js.map +1 -1
  55. package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
  56. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  57. package/build-module/components/list-view-sidebar/index.js +1 -1
  58. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  59. package/build-module/components/post-locked-modal/index.js.map +1 -1
  60. package/build-module/components/post-preview-button/index.js +2 -1
  61. package/build-module/components/post-preview-button/index.js.map +1 -1
  62. package/build-module/components/post-publish-button/index.js +2 -1
  63. package/build-module/components/post-publish-button/index.js.map +1 -1
  64. package/build-module/components/post-publish-panel/index.js.map +1 -1
  65. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  66. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  67. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  68. package/build-module/components/post-title/index.native.js.map +1 -1
  69. package/build-module/components/post-title/post-title-raw.js.map +1 -1
  70. package/build-module/components/post-view-link/index.js +2 -1
  71. package/build-module/components/post-view-link/index.js.map +1 -1
  72. package/build-module/components/provider/disable-non-page-content-blocks.js +24 -31
  73. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  74. package/build-module/components/provider/index.js +2 -1
  75. package/build-module/components/provider/index.js.map +1 -1
  76. package/build-module/hooks/index.js +1 -1
  77. package/build-module/hooks/index.js.map +1 -1
  78. package/build-module/hooks/{pattern-partial-syncing.js → pattern-overrides.js} +13 -9
  79. package/build-module/hooks/pattern-overrides.js.map +1 -0
  80. package/build-style/style-rtl.css +1 -0
  81. package/build-style/style.css +1 -0
  82. package/package.json +32 -32
  83. package/src/bindings/index.js +2 -2
  84. package/src/bindings/post-meta.js +4 -1
  85. package/src/components/block-removal-warnings/index.js +92 -0
  86. package/src/components/commands/index.js +21 -13
  87. package/src/components/document-outline/check.js +8 -10
  88. package/src/components/document-outline/index.js +18 -23
  89. package/src/components/document-outline/test/index.js +26 -7
  90. package/src/components/document-tools/index.js +3 -3
  91. package/src/components/editor-help/intro-to-blocks.native.js +1 -1
  92. package/src/components/entities-saved-states/entity-type-list.js +1 -1
  93. package/src/components/list-view-sidebar/index.js +1 -1
  94. package/src/components/post-locked-modal/index.js +1 -1
  95. package/src/components/post-preview-button/index.js +1 -0
  96. package/src/components/post-publish-button/index.js +1 -0
  97. package/src/components/post-publish-panel/index.js +1 -1
  98. package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
  99. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +3 -3
  100. package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -0
  101. package/src/components/post-title/index.native.js +2 -2
  102. package/src/components/post-title/post-title-raw.js +1 -1
  103. package/src/components/post-view-link/index.js +1 -0
  104. package/src/components/provider/disable-non-page-content-blocks.js +34 -36
  105. package/src/components/provider/index.js +2 -0
  106. package/src/components/provider/test/disable-non-page-content-blocks.js +90 -0
  107. package/src/hooks/index.js +1 -1
  108. package/src/hooks/{pattern-partial-syncing.js → pattern-overrides.js} +16 -10
  109. package/build/components/provider/constants.js +0 -8
  110. package/build/components/provider/constants.js.map +0 -1
  111. package/build/hooks/pattern-partial-syncing.js.map +0 -1
  112. package/build-module/components/provider/constants.js +0 -2
  113. package/build-module/components/provider/constants.js.map +0 -1
  114. package/build-module/hooks/pattern-partial-syncing.js.map +0 -1
  115. package/src/components/provider/constants.js +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "13.29.0",
3
+ "version": "13.30.0",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,36 +31,36 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.52.0",
35
- "@wordpress/api-fetch": "^6.49.0",
36
- "@wordpress/blob": "^3.52.0",
37
- "@wordpress/block-editor": "^12.20.0",
38
- "@wordpress/blocks": "^12.29.0",
39
- "@wordpress/commands": "^0.23.0",
40
- "@wordpress/components": "^27.0.0",
41
- "@wordpress/compose": "^6.29.0",
42
- "@wordpress/core-data": "^6.29.0",
43
- "@wordpress/data": "^9.22.0",
44
- "@wordpress/date": "^4.52.0",
45
- "@wordpress/deprecated": "^3.52.0",
46
- "@wordpress/dom": "^3.52.0",
47
- "@wordpress/element": "^5.29.0",
48
- "@wordpress/hooks": "^3.52.0",
49
- "@wordpress/html-entities": "^3.52.0",
50
- "@wordpress/i18n": "^4.52.0",
51
- "@wordpress/icons": "^9.43.0",
52
- "@wordpress/keyboard-shortcuts": "^4.29.0",
53
- "@wordpress/keycodes": "^3.52.0",
54
- "@wordpress/media-utils": "^4.43.0",
55
- "@wordpress/notices": "^4.20.0",
56
- "@wordpress/patterns": "^1.13.0",
57
- "@wordpress/preferences": "^3.29.0",
58
- "@wordpress/private-apis": "^0.34.0",
59
- "@wordpress/reusable-blocks": "^4.29.0",
60
- "@wordpress/rich-text": "^6.29.0",
61
- "@wordpress/server-side-render": "^4.29.0",
62
- "@wordpress/url": "^3.53.0",
63
- "@wordpress/wordcount": "^3.52.0",
34
+ "@wordpress/a11y": "^3.53.0",
35
+ "@wordpress/api-fetch": "^6.50.0",
36
+ "@wordpress/blob": "^3.53.0",
37
+ "@wordpress/block-editor": "^12.21.0",
38
+ "@wordpress/blocks": "^12.30.0",
39
+ "@wordpress/commands": "^0.24.0",
40
+ "@wordpress/components": "^27.1.0",
41
+ "@wordpress/compose": "^6.30.0",
42
+ "@wordpress/core-data": "^6.30.0",
43
+ "@wordpress/data": "^9.23.0",
44
+ "@wordpress/date": "^4.53.0",
45
+ "@wordpress/deprecated": "^3.53.0",
46
+ "@wordpress/dom": "^3.53.0",
47
+ "@wordpress/element": "^5.30.0",
48
+ "@wordpress/hooks": "^3.53.0",
49
+ "@wordpress/html-entities": "^3.53.0",
50
+ "@wordpress/i18n": "^4.53.0",
51
+ "@wordpress/icons": "^9.44.0",
52
+ "@wordpress/keyboard-shortcuts": "^4.30.0",
53
+ "@wordpress/keycodes": "^3.53.0",
54
+ "@wordpress/media-utils": "^4.44.0",
55
+ "@wordpress/notices": "^4.21.0",
56
+ "@wordpress/patterns": "^1.14.0",
57
+ "@wordpress/preferences": "^3.30.0",
58
+ "@wordpress/private-apis": "^0.35.0",
59
+ "@wordpress/reusable-blocks": "^4.30.0",
60
+ "@wordpress/rich-text": "^6.30.0",
61
+ "@wordpress/server-side-render": "^4.30.0",
62
+ "@wordpress/url": "^3.54.0",
63
+ "@wordpress/wordcount": "^3.53.0",
64
64
  "classnames": "^2.3.1",
65
65
  "date-fns": "^2.28.0",
66
66
  "memize": "^2.1.0",
@@ -75,5 +75,5 @@
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  },
78
- "gitHead": "c139588f4c668b38bafbc5431f2f4e3903dbe683"
78
+ "gitHead": "ac3c3e465a083081a86a4da6ee6fb817b41e5130"
79
79
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store as blockEditorStore } from '@wordpress/block-editor';
4
+ import { store as blocksStore } from '@wordpress/blocks';
5
5
  import { dispatch } from '@wordpress/data';
6
6
  /**
7
7
  * Internal dependencies
@@ -10,6 +10,6 @@ import { unlock } from '../lock-unlock';
10
10
  import patternOverrides from './pattern-overrides';
11
11
  import postMeta from './post-meta';
12
12
 
13
- const { registerBlockBindingsSource } = unlock( dispatch( blockEditorStore ) );
13
+ const { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );
14
14
  registerBlockBindingsSource( patternOverrides );
15
15
  registerBlockBindingsSource( postMeta );
@@ -19,6 +19,7 @@ export default {
19
19
  const postType = context.postType
20
20
  ? context.postType
21
21
  : getCurrentPostType();
22
+
22
23
  const [ meta, setMeta ] = useEntityProp(
23
24
  'postType',
24
25
  context.postType,
@@ -33,9 +34,11 @@ export default {
33
34
  const updateMetaValue = ( newValue ) => {
34
35
  setMeta( { ...meta, [ metaKey ]: newValue } );
35
36
  };
37
+
36
38
  return {
37
39
  placeholder: metaKey,
38
- useValue: [ metaValue, updateMetaValue ],
40
+ value: metaValue,
41
+ updateValue: updateMetaValue,
39
42
  };
40
43
  },
41
44
  };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ import { _n } from '@wordpress/i18n';
6
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
7
+ import { useSelect } from '@wordpress/data';
8
+ import { useMemo } from '@wordpress/element';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { unlock } from '../../lock-unlock';
14
+ import { store as editorStore } from '../../store';
15
+
16
+ const { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );
17
+
18
+ // Prevent accidental removal of certain blocks, asking the user for confirmation first.
19
+ const TEMPLATE_BLOCKS = [
20
+ 'core/post-content',
21
+ 'core/post-template',
22
+ 'core/query',
23
+ ];
24
+ const BLOCK_REMOVAL_RULES = [
25
+ {
26
+ // Template blocks.
27
+ // The warning is only shown when a user manipulates templates or template parts.
28
+ postTypes: [ 'wp_template', 'wp_template_part' ],
29
+ callback( removedBlocks ) {
30
+ const removedTemplateBlocks = removedBlocks.filter( ( { name } ) =>
31
+ TEMPLATE_BLOCKS.includes( name )
32
+ );
33
+ if ( removedTemplateBlocks.length ) {
34
+ return _n(
35
+ 'Deleting this block will stop your post or page content from displaying on this template. It is not recommended.',
36
+ 'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.',
37
+ removedBlocks.length
38
+ );
39
+ }
40
+ },
41
+ },
42
+ {
43
+ // Pattern overrides.
44
+ // The warning is only shown when the user edits a pattern.
45
+ postTypes: [ 'wp_block' ],
46
+ callback( removedBlocks ) {
47
+ const removedBlocksWithOverrides = removedBlocks.filter(
48
+ ( { attributes } ) =>
49
+ attributes?.metadata?.bindings &&
50
+ Object.values( attributes.metadata.bindings ).some(
51
+ ( binding ) =>
52
+ binding.source === 'core/pattern-overrides'
53
+ )
54
+ );
55
+ if ( removedBlocksWithOverrides.length ) {
56
+ return _n(
57
+ 'The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?',
58
+ 'Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?',
59
+ removedBlocks.length
60
+ );
61
+ }
62
+ },
63
+ },
64
+ ];
65
+
66
+ export default function BlockRemovalWarnings() {
67
+ const currentPostType = useSelect(
68
+ ( select ) => select( editorStore ).getCurrentPostType(),
69
+ []
70
+ );
71
+
72
+ const removalRulesForPostType = useMemo(
73
+ () =>
74
+ BLOCK_REMOVAL_RULES.filter( ( rule ) =>
75
+ rule.postTypes.includes( currentPostType )
76
+ ),
77
+ [ currentPostType ]
78
+ );
79
+
80
+ // `BlockRemovalWarnings` is rendered in the editor provider, a shared component
81
+ // across react native and web. However, `BlockRemovalWarningModal` is web only.
82
+ // Check it exists before trying to render it.
83
+ if ( ! BlockRemovalWarningModal ) {
84
+ return null;
85
+ }
86
+
87
+ if ( ! removalRulesForPostType ) {
88
+ return null;
89
+ }
90
+
91
+ return <BlockRemovalWarningModal rules={ removalRulesForPostType } />;
92
+ }
@@ -25,9 +25,12 @@ function useEditorCommandLoader() {
25
25
  isFocusMode,
26
26
  isPreviewMode,
27
27
  isViewable,
28
+ isCodeEditingEnabled,
29
+ isRichEditingEnabled,
28
30
  } = useSelect( ( select ) => {
29
31
  const { get } = select( preferencesStore );
30
- const { isListViewOpened, getCurrentPostType } = select( editorStore );
32
+ const { isListViewOpened, getCurrentPostType, getEditorSettings } =
33
+ select( editorStore );
31
34
  const { getSettings } = select( blockEditorStore );
32
35
  const { getPostType } = select( coreStore );
33
36
 
@@ -40,6 +43,8 @@ function useEditorCommandLoader() {
40
43
  isTopToolbar: get( 'core', 'fixedToolbar' ),
41
44
  isPreviewMode: getSettings().__unstableIsPreviewMode,
42
45
  isViewable: getPostType( getCurrentPostType() )?.viewable ?? false,
46
+ isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
47
+ isRichEditingEnabled: getEditorSettings().richEditingEnabled,
43
48
  };
44
49
  }, [] );
45
50
  const { toggle } = useDispatch( preferencesStore );
@@ -51,6 +56,7 @@ function useEditorCommandLoader() {
51
56
  toggleDistractionFree,
52
57
  } = useDispatch( editorStore );
53
58
  const { getCurrentPostId } = useSelect( editorStore );
59
+ const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
54
60
 
55
61
  if ( isPreviewMode ) {
56
62
  return { commands: [], isLoading: false };
@@ -141,18 +147,20 @@ function useEditorCommandLoader() {
141
147
  },
142
148
  } );
143
149
 
144
- commands.push( {
145
- name: 'core/toggle-code-editor',
146
- label:
147
- editorMode === 'visual'
148
- ? __( 'Open code editor' )
149
- : __( 'Exit code editor' ),
150
- icon: code,
151
- callback: ( { close } ) => {
152
- switchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );
153
- close();
154
- },
155
- } );
150
+ if ( allowSwitchEditorMode ) {
151
+ commands.push( {
152
+ name: 'core/toggle-code-editor',
153
+ label:
154
+ editorMode === 'visual'
155
+ ? __( 'Open code editor' )
156
+ : __( 'Exit code editor' ),
157
+ icon: code,
158
+ callback: ( { close } ) => {
159
+ switchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );
160
+ close();
161
+ },
162
+ } );
163
+ }
156
164
 
157
165
  commands.push( {
158
166
  name: 'core/toggle-breadcrumbs',
@@ -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 (
@@ -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
@@ -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"
@@ -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
  }