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

Schemas: Allow custom blocks in theme.json styles #36411

Merged
merged 2 commits into from Nov 23, 2021

Conversation

walbo
Copy link
Member

@walbo walbo commented Nov 11, 2021

Description

This PR fixes the JSON Schema to add support for custom blocks in the styles blocks section of theme.json files. Support for custom blocks in the settings section was added in #36341

How has this been tested?

{
	"$schema": "../theme.json",
	"version": 1,
	"styles": {
		"blocks": {
			"core/archives": {
				"border": {
					"color": "#000"
				}
			},
			"example/namespace": {
				"border": {
					"color": "#000"
				}
			}
		}
	}
}

Types of changes

Update JSON Schema to allow custom blocks

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@walbo walbo added the Developer Experience Ideas about improving block and theme developer experience label Nov 11, 2021
@walbo walbo requested a review from gziolo November 16, 2021 18:07
Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

},
"core/legacy-widget": {
"$ref": "#/definitions/stylesPropertiesAndElementsComplete"
"allOf": [
Copy link
Contributor

@ajlende ajlende Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is allOf required here, or can patternProperties just be used alongside properties?

Copy link
Member Author

@walbo walbo Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That should work. I followed how it was done in settings.blocks.

I'll update the PR and change it in settings.blocks as well (for consistency).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajlende Updated.

Testet locally that:

  • autosuggest for core blocks still works
  • custom blocks are allowed
  • custom properties with invalid name shows warning

@walbo walbo requested a review from ajlende November 17, 2021 20:02
Copy link
Contributor

@ajlende ajlende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning up that other spot too! Tested locally in VSCode and IntelliJ; LGTM 👍

@ajlende ajlende merged commit 31c4e2e into trunk Nov 23, 2021
@ajlende ajlende deleted the fix/schema-theme-json-custom-blocks-in-styles branch November 23, 2021 13:08
@github-actions github-actions bot added this to the Gutenberg 12.1 milestone Nov 23, 2021
@ajlende ajlende added the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Jan 28, 2022
@Mamaduka
Copy link
Member

Backported to 5.9.1.

@Mamaduka Mamaduka removed the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Feb 16, 2022
Mamaduka pushed a commit that referenced this pull request Feb 16, 2022
* Schemas: Allow custom blocks in theme.json styles

* Remove allOf and use patternProperties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Ideas about improving block and theme developer experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants