-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Allow developers to reuse default blocks in their blocks #2995
Comments
We're thinking of a "template" feature for CPTs which is a list of prefilled blocks. I can't seem to find the corresponding ticket but the idea is that a CPT defines a template with mandatory locked blocks. I think this would address most of the concerns here. |
Also nested blocks would allow to define a |
@youknowriad I don't think CPT is something similar to what I'm building. I definitely don't want to "pollute" users WP admin/DB with extra CPTs for cases when they use a custom block only a few times on a whole website. It will be great if you direct to the ticket. Maybe I'm wrong. @mtias thanks for this inside. The problem that we know nothing about planned features. There is no roadmap that we can see. This way we waste too much of time on development of the stuff that we will have to redo completely later (on another side we can't wait and release it long after Gutenberg merged). |
This is a really great suggestion. This will definitely make the 3rd party developer's life much much easier and will ultimately bring improved code overall to 3rd party plugins, as they will be mostly referencing already available core blocks (in many cases). Just for a practical reference, I would like to point SiteOrigin's Widget API here. Their API brings widgets (like blocks in Gutenberg) as a field type simply. So if a 3rd party developer building a site origin widget and needs a button, he/she doesn't need to code the button component but can just include the core (SiteOrigin) button. Here is the specific field type reference. I am not sure if this will be a helpful reference here, but I am just dropping in case it is. |
The changes proposed in #3745 were modeled with this in mind; while not currently implemented, it should be fairly simple to extend |
@aduth Great to hear that. This will be really helpfull\ and will make the life much easier for 3rd party developers. |
Has this been implemented yet? For example, I am trying to reuse the Gallery block functionality but just have different settings and styling with an option to also have the default galleries. |
For your use case, it seems block variations could be what you are after: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#variations-optional and https://richtabor.com/block-variations/ |
I'm coding new custom blocks. For every custom block, I have to copy paste whole files of code to get the same functionality you already have in the default blocks. It's very confusing and goes against "do not repeat yourself" principle we try to stick to.
Issue:
For example, if I need to create a new custom block "Recipe" with the next structure:
I will have to copy/paste the code from 5 already coded default blocks. What even worse: I will have to monitor official blocks for further improvements/changes in the future and update my block accordingly.
Please, allow 3-rd party developers to easily reuse already coded default blocks in their blocks.
Something like
<Freeform />
<Image />
<Button />
<Heading />
<Paragraph />
will make our lives much easier.Benefits:
It's better to do this now, not after release as many 3-rd party developers with have to create custom blocks for their plugins before Gutenberg merged into WP.
I see no reason why it can't be good for everyone.
The text was updated successfully, but these errors were encountered: