-
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
Blocks: Provide a general solution to customize the list of allowed blocks for inner blocks with block attributes #15682
Comments
@jorgefilipecosta - I guess this is not possible as of today given that the list of allowed blocks is hardcoded in the gutenberg/packages/block-library/src/media-text/edit.js Lines 235 to 239 in 1a20e15
|
Yes, unfortunately, we don't have a way to filter allowedBlocks in InnerBlock scenarios. Maybe we could add a generic filter that allows changing InnerBlocks properties? cc: @gziolo For the specific case in question, a possible workaround is to define the newly created block as a child block of the media & text block, child blocks are allowed even if the allowedBlocks setting does not include them. cc: @edirpedro |
I wonder if we could be even more flexible and add some filter to There might be some cases where a block can be inserted depending on the current editor state. For instance, in Automattic/wp-calypso#41850 we're interested in making a custom button block insertable as a inner block of |
I am noting that there is an open PR #49128 that proposes adding |
A general solution to this problem would be great. The media and text block is a very common use case for this in my projects - we often only want the client to insert "text blocks" (paragraph, heading, button, list) and not embeds or "layout" blocks. Providing this option on a per-instance basis to blocks is great. Some core blocks already allow this, but not all. So combining these efforts would be great. |
Ideally, the information about the allowed inner blocks would be stored in attributes in some type of the |
I agree with you. I think a lot of "settings" attributes which are not content-/design-related but more settings for the editor-ui of this specific block instance could be bundled into this. I think there were some discussions about this in some issues/PRs regarding container-block system. I can only find those atm: #41547 #39281 #40318 Also related: #48112 |
I agree with @gziolo. Eventually, we want to move all attributes that serve as per-block settings in the editor into We can consider a more general solution once the @mmtr, I believe you're describing a different issue tracked in #14515. |
For what it's worth: I would still like to add this property to the media & text block, since some other core blocks (cover, group) already provide that option. When a general api for meta/internal attributes is implemented they have to be migrated anyway. Just like #49128 for the group block. I can create a PR if that's an option for you? |
Sounds good, @gaambo. Feel free to ping me in the PR for testing/review. |
#31387 - Navigation block is another use case discussed. |
It can be considered done with #58262. It got backported to WordPress Core with https://core.trac.wordpress.org/changeset/57521, and it will be released in WordPress 6.5. Kudos to @jsnajdr for championing the efforts. |
Part of #41236.
For example the Media and Text block can accept only
[ 'core/button', 'core/paragraph', 'core/heading', 'core/list' ]
and due the fact the heading block doesn't offer an option for color, I created my own block to use inside the Media and Text block, but it's not possible and I couldn't add my block to the allowed list.I expected to filter the allowedBlocks list like that.
The text was updated successfully, but these errors were encountered: