Problem/Motivation
Currently if you have two modules or themes defining blocks in the mymodule.gutenberg.yml file using the same category reference, the later processed module will overwrite the blocks of the first one. Essentially you will not be able to make custom blocks of the first module with the same category available at all.
It would be good if multiple modules/themes could add blocks for example to the "Layout" category.
Currently it behaves the following.
mymodule_a.gutenberg.yml
custom-blocks:
categories:
- reference: layout # The category where the block will be added.
name: Layout
blocks:
- id: custom-card-block/custom-card-block
name: Custom Card Block
mymodule_b.gutenberg.yml
custom-blocks:
categories:
- reference: layout # The category where the block will be added.
name: Layout
blocks:
- id: custom-example-block/custom-example-block
name: Custom Example Block
Then the custom blocks from mymodule_a will not be selectable in the node type form and therefore cannot be used in Gutenberg.
Steps to reproduce
Proposed resolution
If a category reference was already defined then the blocks of mymodule_b should merge into the existing category, so that all blocks can be configured and enabled/disabled.
It of course would not solve, if a the second module defines a different name for the category, but I think that's a minor problem compared to the real-life problem described above.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork gutenberg-3468393
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
szeidler commentedI created a pull request that is now merging the blocks together, if a category of mymodule_b is processed and the same category reference from mymodule_b already exists.
Furthermore – since I have been touching the code anyhow – I renamed the foreach $theme_definition to $definition to be precise, because it's actually the merged together definitions from themes and modules.
Comment #5
marcofernandes commented