Let's discuss Core block extensibility #63877
Replies: 8 comments 4 replies
-
I would add that, in this example of a block that needs to support SVG icons, it might be necessary to inject some "support" markup into the block itself, such as an SVG with symbols, which is currently not possible. In this regard, you can refer to the ticket #56207 |
Beta Was this translation helpful? Give feedback.
-
Some nice enhancements around HTML/CSS of blocks:
|
Beta Was this translation helpful? Give feedback.
-
I’ve spent quite a bit of time attempting to properly extend the featured image core block. My conclusion is that, as @ndiego mentioned above. I’ve been able to add attributes, a new InspectorPanel to edit these settings and finally tapped into render_block to modify the output. The issue I face now, and have given up, is editing the block output in the block editor cleanly. You can tap into BlockListBlock but there is no clean way I could see where I can detect what the current output is and then modify it. Obviously, it could be that I don’t know what to do, but I couldn’t find documentation answering this. So here’s what I think we need.
Not sure if this can be done, but it will make extending blocks a lot easier. Right now, my approach will be to park the block editor rendering on the fly and tell the user to look at the front end. The other alternative is to duplicate the entire block and then add in the features I want, which I think beats the spirit of extending blocks. |
Beta Was this translation helpful? Give feedback.
-
There should be an easy way to extend core blocks with primarily PHP, and some way to publish the core blocks templates to modify or extend them in PHP. |
Beta Was this translation helpful? Give feedback.
-
I wonder if my experiement outlined here in which I replace the edit component of the core block using blocks.registerBlockType may be relevant (although in the specific case, @bacoords came up with a much simpler solution). This doesn't change the validation problem, though. I wonder if there is even a logical way to get around the validation problem as long as there is no separation of attributes and markup? |
Beta Was this translation helpful? Give feedback.
-
@ndiego You mention in your tutorial, that when we look at block extensions, we'll see a pattern (and, yep, I've seen it). Do you know if there's a create-block template for block extension? |
Beta Was this translation helpful? Give feedback.
-
Would be great if members of the @WordPress/outreach team also chime in and bring their lists. |
Beta Was this translation helpful? Give feedback.
-
I'm a bit late to the party, but here is some feedback I've gathered from my colleagues, on top of what has already been mentioned:
|
Beta Was this translation helpful? Give feedback.
-
This is an open conversation about improving Core block extensibility that stemmed from the latest Developer Hours session and discussion around #63626. The more Core blocks can be made extensible, the less need there will be to create custom blocks with similar functionality.
Example
Here's one example to get the discussion started. Let's say that I want to extend the Button block by adding an option for users to choose an SVG icon that will appear to the left or right of the button text. We have solutions for much of this project:
blocks.registerBlockType
editor.BlockEdit
render_block_core/button
The one thing that you cannot do easily is modify the markup in the Editor to reflect the user's icon choice. Any changes to the markup can lead to block validation errors. The best solution I could come up with is outlined in this experimental plugin.
@bacoords has created a separate discussion specifically about this issue: #63876
Share your feedback
So, let's discuss current blockers to Core block extensibility and things you would like to see implemented/changed. Based on the feedback here and proposed solutions, issues will be created.
Beta Was this translation helpful? Give feedback.
All reactions