Problem/Motivation

Everytime the relevant entity type for a Gutenberg enabled entity is save, it automatically adds in new changes in the config for every new block instance it finds, which can be annoying if you have loads of derivative fields e.g. block content blocks.

Steps to reproduce

Enable Gutenberg on your Node entity type, save then export the configuration.

Then introduce a new block type instance, e.g. an exposed filter block or a new content block.

Then once you resave the Node entity type, it'll automatically add those new block instances into the config like this in your config diff:

+  'block_content:f5c762e6-962a-42cf-841b-611e5ee40204': 0
+  'block_content:ced96c38-d1a0-4d34-ba1f-946de1291938': 0
+  'block_content:b5bfb9e5-8a8f-4db3-a343-7e3d8522feb6': 0
+  'block_content:59437793-d207-4182-bf96-52fa8c04755a': 0

Proposed resolution

Remove irrelevant config on save, as well as a post update hook to clean up the existing config.

We should ideally store these inside the individual Node entity's third_party_settings, that way it can be modelled consistently in the config schema, just like it was previously done in #3163200: Make Gutenberg entity-type-agnostic, but that's work to be in a future major release since it's a big change to the current data structure.

Remaining tasks

Provide update hook and MR.

User interface changes

N/A

API changes

N/A

Data model changes

Inactive blocks will no longer be exported in the config.

Issue fork gutenberg-3415218

Command icon 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

codebymikey created an issue. See original summary.

codebymikey’s picture

Title: Clean up gutenberg.settings config » Normalize the gutenberg.settings config
Status: Active » Needs review

Pushed an update normalizing the config, providing an update hook to apply it, as well as removing the redundant gutenberg.mediaedit config.

The current and new configuration schema can be reviewed using the https://www.drupal.org/project/config_inspector

marcofernandes made their first commit to this issue’s fork.

marcofernandes’s picture

Hmm.. something went wrong when merging dev. It updated from 2.x. I'll try to revert and do things properly.

marcofernandes’s picture

Status: Needs review » Needs work

This change affects the way the editor loads the configuration to register the blocks. Ex: /js/overrides/register-core-blocks.jsx

marcofernandes changed the visibility of the branch 3415218-clean-up-gutenberg.settings to hidden.

marcofernandes changed the visibility of the branch 3415218-clean-up-gutenberg.settings to active.

marcofernandes changed the visibility of the branch revert-93c85c9e to hidden.

marcofernandes changed the visibility of the branch 3.0.x to hidden.

marcofernandes’s picture

Status: Needs work » Fixed

Because of these changes on the config structure, UpdateAddMediaTest::testMediaUpdate() had to be disabled for now. Follow-up on https://www.drupal.org/project/gutenberg/issues/3418917

  • marcofernandes committed 1ee7c38d on 3.0.x
    Issue #3415218: Fix allowed blocks values on edit form + fix embed...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

codebymikey’s picture

Version: 3.0.x-dev » 8.x-2.x-dev
Status: Closed (fixed) » Needs review

Reopened to address some config normalization issues related to the #3340209: Limit available image styles for image related blocks feature which was added, but doesn't currently have a valid schema.

codebymikey changed the visibility of the branch 8.x-2.x to hidden.

codebymikey changed the visibility of the branch 3415218-clean-up-gutenberg.settings-2.x to hidden.

codebymikey changed the visibility of the branch 3415218-clean-up-gutenberg.settings-2.8 to hidden.

codebymikey changed the visibility of the branch 3415218-clean-up-gutenberg.settings to hidden.

codebymikey’s picture

Title: Normalize the gutenberg.settings config » Normalize the gutenberg.settings config and support image sizes filtering
Related issues: +#3229848: Allow API to restrict which image styles are available to users, +#3341296: Followup: SVG's should not use image styles

In the spirit of making the image size support more complete, I've added a commit to the merge request which incorporates changes from #3229848: Allow API to restrict which image styles are available to users and #3341296: Followup: SVG's should not use image styles

  • codebymikey committed 6986578f on 3.0.x
    Issue #3415218 by codebymikey: Normalize the gutenberg.settings config
    

  • codebymikey committed 419e6083 on 8.x-2.x
    Issue #3415218 by codebymikey: Normalize the gutenberg.settings config
    
codebymikey’s picture

Version: 8.x-2.x-dev » 3.0.x-dev
Status: Needs review » Fixed

Merged both the 2.0.x and 3.0.x MRs.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • codebymikey committed 6986578f on 4.0.x
    Issue #3415218 by codebymikey: Normalize the gutenberg.settings config
    

  • codebymikey committed 6986578f on feature/wp-scripts-packages-build
    Issue #3415218 by codebymikey: Normalize the gutenberg.settings config
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.