Skip to content

Commit 543ab97

Browse files
committed
Make block-comments part of editor support
1 parent 9d07a6b commit 543ab97

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

gutenberg.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
### END AUTO-GENERATED DEFINES
1818
defined( 'GUTENBERG_MINIMUM_WP_VERSION' ) or define( 'GUTENBERG_MINIMUM_WP_VERSION', '6.7' );
1919

20-
2120
gutenberg_pre_init();
2221

2322
/**

lib/experimental/block-comments.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
* @return void
77
*/
88
function gutenberg_block_comment_add_post_type_support() {
9-
add_post_type_support( 'post', 'block-comments' );
10-
add_post_type_support( 'page', 'block-comments' );
9+
$post_types = array( 'post', 'page' );
10+
foreach ( $post_types as $post_type ) {
11+
if ( post_type_supports( $post_type, 'editor' ) ) {
12+
add_post_type_support( $post_type, 'editor', array( 'block-comments' => true ) );
13+
}
14+
}
1115
}
1216
add_action( 'init', 'gutenberg_block_comment_add_post_type_support' );
1317

packages/editor/src/components/header/index.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { __unstableMotion as motion } from '@wordpress/components';
88
import { store as preferencesStore } from '@wordpress/preferences';
99
import { useState } from '@wordpress/element';
1010
import { PinnedItems } from '@wordpress/interface';
11+
import { store as coreStore } from '@wordpress/core-data';
1112

1213
/**
1314
* Internal dependencies
@@ -21,7 +22,6 @@ import MoreMenu from '../more-menu';
2122
import PostPreviewButton from '../post-preview-button';
2223
import PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';
2324
import PostSavedState from '../post-saved-state';
24-
import PostTypeSupportCheck from '../post-type-support-check';
2525
import PostViewLink from '../post-view-link';
2626
import PreviewDropdown from '../preview-dropdown';
2727
import ZoomOutToggle from '../zoom-out-toggle';
@@ -70,8 +70,10 @@ function Header( {
7070
hasFixedToolbar,
7171
hasBlockSelection,
7272
hasSectionRootClientId,
73+
supportsBlockComments,
7374
} = useSelect( ( select ) => {
7475
const { get: getPreference } = select( preferencesStore );
76+
const { getPostType } = select( coreStore );
7577
const {
7678
getEditorMode,
7779
getCurrentPostType,
@@ -81,14 +83,23 @@ function Header( {
8183
select( blockEditorStore )
8284
);
8385

86+
const currentPostType = getCurrentPostType();
87+
const _postType = getPostType( currentPostType );
88+
8489
return {
85-
postType: getCurrentPostType(),
90+
postType: currentPostType,
8691
isTextEditor: getEditorMode() === 'text',
8792
isPublishSidebarOpened: _isPublishSidebarOpened(),
8893
showIconLabels: getPreference( 'core', 'showIconLabels' ),
8994
hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
9095
hasBlockSelection: !! getBlockSelectionStart(),
9196
hasSectionRootClientId: !! getSectionRootClientId(),
97+
supportsBlockComments:
98+
_postType?.supports?.editor &&
99+
Array.isArray( _postType.supports.editor ) &&
100+
!! _postType.supports.editor.find(
101+
( item ) => item?.[ 'block-comments' ] === true
102+
),
92103
};
93104
}, [] );
94105

@@ -197,11 +208,9 @@ function Header( {
197208
/>
198209
) }
199210

200-
{ isBlockCommentExperimentEnabled ? (
201-
<PostTypeSupportCheck supportKeys="block-comments">
202-
<CollabSidebar />
203-
</PostTypeSupportCheck>
204-
) : undefined }
211+
{ isBlockCommentExperimentEnabled && supportsBlockComments && (
212+
<CollabSidebar />
213+
) }
205214

206215
{ customSaveButton }
207216
<MoreMenu />

0 commit comments

Comments
 (0)