-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Style Book: Exclude blocks that are not allowed to insert #47461
Conversation
Size Change: +3.17 kB (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Flaky tests detected in aaf9cf0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4071212287
|
name !== 'core/heading' && | ||
!! example && | ||
supports.inserter !== false && | ||
! parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go this way, I guess we should also exclude those with ancestor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!
I have also considered the approach described in this comment, which is to leave the current logic in place and simply remove the example
property of the block that we do not want to be listed in the stylebook.
Do you think this PR makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have found that there are some core blocks that will not show up if I exclude blocks with parent
and ancestor
. I added only "inserter":false
as a condition to keep the current list of blocks.
a640e94
to
7475e1b
Compare
I'm undecided. Is it not possible to want a block that is hidden from the inserter but appears in the Style Book? For example maybe a block that is intended to be available only via a plugin or via a block transform? |
What I like about the current approach is that blocks with But not sure 😀 cc.ing some folks for second opinions: @talldan @andrewserong @aaronrobertshaw |
Thanks for digging into this one @t-hamano!
I like how elegant that is, too. On the other hand, for block developers, I suppose it's good if they don't need to think about the style book when making changes, so if they reach for |
OK. @talldan and @andrewserong pointed out to me privately that we have a few deprecated Core blocks (Text Columns, Comment Author Avatar) that seem to use So yep let's go ahead with this PR 👍 While you're here making changes, would you mind please adjusting the docs so that this behaviour is clarified? diff --git a/docs/reference-guides/block-api/block-supports.md b/docs/reference-guides/block-api/block-supports.md
index 68afd79323..20856785fc 100644
--- a/docs/reference-guides/block-api/block-supports.md
+++ b/docs/reference-guides/block-api/block-supports.md
@@ -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: { |
I guess if removing the It could be an idea to add a sentence to the documentation for |
As far as I can tell,
Also, the description of the schema in block.json is as follows:
I can't think of many cases of "insert programmatically", but it might be used as part of the inner block template. However, as @noisysocks mentioned in this comment, I believe it is generally used to deprecate blocks. I think it would be a good idea to update the description in |
I have updated on this. I would like to hear again your opinions on whether this PR should be merged 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
* 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
Cherry-picked this PR to the wp/6.2 branch. |
Fixes: #47440
What?
This PR excludes blocks from the Style Book that are not allowed to insert.
Why?
The current stylebook displays all blocks that do not have the
example
property. Blocks that are not allowed to be inserted should never be previewed by themselves, even if they have the example property. Therefore, I don't think it should be displayed in the Stylebook.How
I considered excluding blocks with
parent
andancestor
properties, but the following blocks would not be displayed:To keep the current list of blocks, I didn't take that action.
Testing Instructions
There is no core block with inserter set to false and example defined. Therefore, in this PR, confirm that the blocks displayed in the stylebook remain the same as shown below: