Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding block description settings in preference #68435

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/block-editor/src/components/block-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';
import { __, isRTL } from '@wordpress/i18n';
import { chevronLeft, chevronRight } from '@wordpress/icons';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
Expand Down Expand Up @@ -78,7 +79,9 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
)[ 0 ],
};
}, [] );

const showBlockDescription = useSelect( ( select ) => {
return select( preferencesStore ).get( 'core', 'showBlockDescription' );
}, [] );
const { selectBlock } = useDispatch( blockEditorStore );

return (
Expand All @@ -104,7 +107,7 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
</span>
{ !! name?.length && <Badge>{ title }</Badge> }
</h2>
{ description && (
{ description && showBlockDescription && (
<Text className="block-editor-block-card__description">
{ description }
</Text>
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function initializeEditor(
showListViewByDefault: false,
enableChoosePatternModal: true,
isPublishSidebarEnabled: true,
showBlockDescription: true,
} );

if ( window.__experimentalMediaProcessing ) {
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function initializeEditor( id, settings ) {
showBlockBreadcrumbs: true,
showListViewByDefault: false,
enableChoosePatternModal: true,
showBlockDescription: true,
} );

if ( window.__experimentalMediaProcessing ) {
Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ function PreferencesModalContents( { extraSections = {} } ) {
label={ __( 'Spotlight mode' ) }
/>
{ extraSections?.appearance }
<PreferenceToggleControl
scope="core"
featureName="showBlockDescription"
help={ __(
'Show block descriptions in the editor sidebar.'
) }
label={ __( 'Show block descriptions' ) }
/>
</PreferencesModalSection>
),
},
Expand Down
Loading