Skip to content
Merged
Changes from 1 commit
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
15 changes: 6 additions & 9 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2154,24 +2154,21 @@ const buildBlockTypeItem =
'inserter'
);
const blockVariations = getBlockVariations( blockType.name, 'block' );
// Combine inserter and block variations. Block-scope variations without
// inserter scope are searchable via slash commands but hidden from browse.
const inserterVariationNames = new Set(
inserterVariations.map( ( variation ) => variation.name )
);
const allVariations = [
...inserterVariations,
// Built-in heading level variations have block scope but allow
// insertion via slash inserter.
Comment on lines +2159 to +2160
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to link to the associated issue(s) here: #74233, or make it clearer why we're making this exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea! Updated in 3949e8f

...blockVariations
.filter(
( variation ) =>
! inserterVariationNames.has( variation.name )
blockType.name === 'core/heading' &&
[ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ].includes(
variation.name
)
)
.map( ( variation ) => ( {
...variation,
isSearchOnly: true,
// Block-scope `isDefault` is for the placeholder picker,
// not for the inserter, so don't carry it over.
isDefault: false,
} ) ),
];
return {
Expand Down
Loading