Skip to content
Merged
1 change: 0 additions & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
### END AUTO-GENERATED DEFINES
defined( 'GUTENBERG_MINIMUM_WP_VERSION' ) or define( 'GUTENBERG_MINIMUM_WP_VERSION', '6.7' );


gutenberg_pre_init();

/**
Expand Down
16 changes: 16 additions & 0 deletions lib/experimental/block-comments.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
<?php

/**
* Adds support for block comments to the built-in post types.
*
* @return void
*/
function gutenberg_block_comment_add_post_type_support() {
$post_types = array( 'post', 'page' );
foreach ( $post_types as $post_type ) {
if ( post_type_supports( $post_type, 'editor' ) ) {
add_post_type_support( $post_type, 'editor', array( 'block-comments' => true ) );
}
}
}
add_action( 'init', 'gutenberg_block_comment_add_post_type_support' );

/**
* Updates the comment type in the REST API.
*
Expand Down
5 changes: 0 additions & 5 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,6 @@ export default function CollabSidebar() {
? resultComments.find( ( thread ) => thread.id === blockCommentId )
: null;

// If postId is not a valid number, do not render the comment sidebar.
if ( ! ( !! postId && typeof postId === 'number' ) ) {
return null;
}

return (
<>
<AddCommentComponent
Expand Down
18 changes: 15 additions & 3 deletions packages/editor/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { __unstableMotion as motion } from '@wordpress/components';
import { store as preferencesStore } from '@wordpress/preferences';
import { useState } from '@wordpress/element';
import { PinnedItems } from '@wordpress/interface';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand Down Expand Up @@ -69,8 +70,10 @@ function Header( {
hasFixedToolbar,
hasBlockSelection,
hasSectionRootClientId,
supportsBlockComments,
} = useSelect( ( select ) => {
const { get: getPreference } = select( preferencesStore );
const { getPostType } = select( coreStore );
const {
getEditorMode,
getCurrentPostType,
Expand All @@ -80,14 +83,23 @@ function Header( {
select( blockEditorStore )
);

const currentPostType = getCurrentPostType();
const _postType = getPostType( currentPostType );

return {
postType: getCurrentPostType(),
postType: currentPostType,
isTextEditor: getEditorMode() === 'text',
isPublishSidebarOpened: _isPublishSidebarOpened(),
showIconLabels: getPreference( 'core', 'showIconLabels' ),
hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
hasBlockSelection: !! getBlockSelectionStart(),
hasSectionRootClientId: !! getSectionRootClientId(),
supportsBlockComments:
_postType?.supports?.editor &&
Array.isArray( _postType.supports.editor ) &&
!! _postType.supports.editor.find(
( item ) => item?.[ 'block-comments' ] === true
),
};
}, [] );

Expand Down Expand Up @@ -196,9 +208,9 @@ function Header( {
/>
) }

{ isBlockCommentExperimentEnabled ? (
{ isBlockCommentExperimentEnabled && supportsBlockComments && (
<CollabSidebar />
) : undefined }
) }

{ customSaveButton }
<MoreMenu />
Expand Down
Loading