-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[Widgets Editor] Add a filter function to registerCoreBlock
#26259
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
Conversation
|
Size Change: +45 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
|
An alternative might be adding new functions IMO, the biggest problem the existing functions solve is the maintenance of keeping up-to-date with the available blocks from the block-library package rather than registration. Registration itself is relatively straightforward. |
|
@talldan I added a new function |
talldan
left a comment
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.
@kevin940726 Nice! A bit different to what I was thinking, but I think this is better. Offers lots of granularity for users of the package, they can use a completely custom list of blocks, filter out particular core blocks, or use all core blocks.
I was also thinking we'd go for the same API for experimental blocks which are registered a little later in the file, but there's no urgency on that as not related to this bug.
| * const coreBlocks = __experimentalGetCoreBlocks(); | ||
| * ``` | ||
| */ | ||
| export const __experimentalGetCoreBlocks = () => [ |
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'm not convinced it needs to be experimental, but it does no harm (other than later maintenance).
| ) => { | ||
| blocks.forEach( registerBlock ); | ||
|
|
||
| setDefaultBlockName( paragraph.name ); |
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 note that there'd be issues if one of these blocks was not passed in the blocks param.
That could be considered using the function incorrectly, but we could also add some guards to prevent errors.
Description
Fix #26178.
Add a
filterfunction toregisterCoreBlockand filter outcore/moreblock in widgets editor.I'm not sure this is the right approach. Another option I can think of is to add a
disallowedBlocksto<InnerBlocks>andwidget-area. Or removemoreblock from core, and register them manually one-by-one in each usage. I figured to open this PR first to gain more discussion and suggestions.How has this been tested?
Screenshots
Types of changes
Bug fix
Checklist: