Skip to content
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

[Question] Can core blocks be extended? #5785

Closed
jahvi opened this issue Mar 25, 2018 · 5 comments
Closed

[Question] Can core blocks be extended? #5785

jahvi opened this issue Mar 25, 2018 · 5 comments
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Question Questions about the design or development of the editor.

Comments

@jahvi
Copy link
Contributor

jahvi commented Mar 25, 2018

Is it possible to 'extend' the functionality of core blocks? If not, are there any plans to allow plugins to do so?

My use case is that I'm trying to integrate my Category Filter plugin to work with Gutenberg however I'm not sure how to do so without directly messing with the TaxonomyPanel component.

@karmatosed karmatosed added the [Type] Question Questions about the design or development of the editor. label Mar 27, 2018
@gziolo
Copy link
Member

gziolo commented Mar 30, 2018

There are a couple of ways how core blocks can be extended or modified. You can see more in here: https://github.com/WordPress/gutenberg/blob/master/docs/extensibility/extending-blocks.md.

We provide a few hooks which make it possible to change core blocks. We are still working on making it more robust so it is still considered experimental. However, we encourage every plugin developer to give it a try.

It seems like in the case you mentioned blocks.registerBlockType would be the filter to look at. It allows to override edit implementation of the core block. It might be a lot of work to reimplement the edit experience with your own logic. Can you share more details what exactly should change in the logic of the existing blocks with your plugin? Is it about UI or data or both?

@gziolo gziolo added [Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Block API API that allows to express the block paradigm. [Feature] Blocks Overall functionality of blocks and removed [Feature] Block API API that allows to express the block paradigm. labels Mar 30, 2018
@jahvi
Copy link
Contributor Author

jahvi commented Mar 30, 2018 via email

@jahvi
Copy link
Contributor Author

jahvi commented Mar 30, 2018

I think I've hit my first roadblock, I tried using the blocks.registerBlockType filter to get a list of block names that I can extend like this:

function getBlockSettings( settings, blockName ) {
    console.log(blockName);
    return settings;
}

wp.hooks.addFilter(
    'blocks.registerBlockType',
    'post-taxonomy-filter/test-function',
    getBlockSettings
);

However the list that comes back are block names (which makes sense) however I need to extend one of the core components in the sidebar (<TaxonomyPanel> I believe) which is not technically a block.

screen shot 2018-03-30 at 9 38 10 pm

Can I still extend it somehow?

@jasmussen
Copy link
Contributor

To answer the original question, Riad has a bunch of information here as well: https://riad.blog/2017/10/16/one-thousand-and-one-way-to-extend-gutenberg-today/

Closing this ticket as part of some repository management. Support questions are most welcome in the WordPress core slack, channel #core-editor, or in the plugin support forum.

@gziolo
Copy link
Member

gziolo commented Apr 9, 2018

Related issue: #6023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Question Questions about the design or development of the editor.
Projects
None yet
Development

No branches or pull requests

4 participants