Skip to content

Commit

Permalink
Style Book: Exclude blocks that are not allowed to insert (#47461)
Browse files Browse the repository at this point in the history
* Style Book: Exclude blocks that are not allowed to insert or have parent

* Update changelog

* Ignore blocks with `ancestor prop`

* Revert some conditions

* Update description

* Fix changelog comment
  • Loading branch information
t-hamano authored Feb 3, 2023
1 parent e88baef commit a93f4f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/block-api/block-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ supports: {
- Type: `boolean`
- Default value: `true`

By default, all blocks will appear in the inserter. To hide a block so that it can only be inserted programmatically, set `inserter` to `false`.
By default, all blocks will appear in the inserter, block transforms menu, Style Book, etc. To hide a block from all parts of the user interface so that it can only be inserted programatically, set `inserter` to `false`.

```js
supports: {
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Bug Fix

- Force visual editor in browse mode ([#47329](https://github.com/WordPress/gutenberg/pull/47329)).
- Style Book: Exclude blocks that are not allowed to insert ([#47461](https://github.com/WordPress/gutenberg/pull/47461)).

## 5.2.0 (2023-01-11)

Expand Down
12 changes: 8 additions & 4 deletions packages/edit-site/src/components/style-book/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ function getExamples() {
};

const otherExamples = getBlockTypes()
.filter(
( blockType ) =>
blockType.name !== 'core/heading' && !! blockType.example
)
.filter( ( blockType ) => {
const { name, example, supports } = blockType;
return (
name !== 'core/heading' &&
!! example &&
supports.inserter !== false
);
} )
.map( ( blockType ) => ( {
name: blockType.name,
title: blockType.title,
Expand Down
2 changes: 1 addition & 1 deletion schemas/json/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
},
"inserter": {
"type": "boolean",
"description": "By default, all blocks will appear in the inserter. To hide a block so that it can only be inserted programmatically, set inserter to false.",
"description": "By default, all blocks will appear in the inserter, block transforms menu, Style Book, etc. To hide a block from all parts of the user interface so that it can only be inserted programatically, set inserter to false.",
"default": true
},
"multiple": {
Expand Down

1 comment on commit a93f4f8

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in a93f4f8.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4081272905
📝 Reported issues:

Please sign in to comment.