-
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
Block API: Allow blocks to register their compatibility with black/whitelists #1654
Comments
Closing this as you can whitelist blocks for a CPT now. |
Why was this closed? The proposal was for blocks to register their support for various other parts of the Gutenberg interface. . .custom post types is a tiny part of that. Gutenberg doesn't even support Page Templates yet, but when it does, this would be a perfect use case for that. But as @jasmussen mentioned, the conditions are pretty endless. I could easily see some blocks being related to post_status even. In editorial workflows, I could easily see some blocks, such as a hypothetical "editorial comment blocks" being allowed to be added between/next to other blocks if the status is draft, but on publish the block could no longer be added. Also a newsroom example, I could see conditions re: user roles/capabilities. Like a writer could add/manipulate text blocks, and a photographer/photo-editor could add/manipulate image/gallery blocks. The conditions go on and on. Being able to declare what blocks support what conditions seems like an important API to think more about. . .not sure what it needs to look like, but closing this issue seems pre-mature to me 🤔 |
@jasonbahl Does the presence of an |
@brandonpayton even that filter doesn't fully define what block types are allowed or not. . .it does remove them from the inserter, but it doesn't affect the Probably need to open another issue pointing that out. . .that blocks should only be able to be transformed into other "allowed" blocks. |
This one is a bit exotic, and please feel free to add to this ticket, or edit it, to expand upon the details.
Our API right now allows a plugin to filter out certain blocks. This is useful if, for example, an institution would like to hide the "YouTube Embed" block. A blacklist usecase, sort of.
Or perhaps another plugin can register itself as requiring the user to use only basic text blocks, so no blocks are used that break the layout of a specific setup. This would be more of a whitelist.
Now imagine WordPress gets updated with a new block. In the blacklist usecase, this block would suddenly show up out of the blue, because the blacklist hasn't been updated, perhaps inappropriately so. In the case of the whitelist, this new block wouldn't show up at all, which might be a great loss since it would be a cool thing to have.
Can we let blocks register properties that can help guide such filters? For example, could we let a block register itself as
G
, orPG
(like Gravatars), or evenxhtml-compatible
, orno-js-compatible
, or any number of other properties that might make sense to inform filters of?The text was updated successfully, but these errors were encountered: