Skip to content

Block API: add blockGap support when skipping spacing serialization #70327

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

DarkMatter-999
Copy link

What?

Closes #63163

This PR adds support for blockGap when using supports.spacing.__experimentalSkipSerialisation in the block.json.

Why?

Currently there exists support for margin and padding but blockGap is not supported. This PR adds support for that.

How?

This PR adds gap.ts at packages/style-engine/src/styles/spacing/gap.ts.
The implementation is similar to the implementation for the padding and margin.

Testing Instructions

Create/edit a block.

  1. In block.json, set supports.spacing.__experimentalSkipSerialisation to true.
"supports": {
	"spacing": {
		"__experimentalSkipSerialization": true,
		"padding": true,
                 "margin": true,
		"blockGap": true
	}
}
  1. In Edit import { __experimentalGetSpacingClassesAndStyles as useSpacingProps } from '@wordpress/block-editor';.
  2. In Edit const spacingProps = useSpacingProps( attributes );
import {
	__experimentalGetSpacingClassesAndStyles as useSpacingProps,
} from '@wordpress/block-editor';

export default function ( { attributes } ) {
	const spacingProps = useSpacingProps( attributes );
	console.log( spacingProps );
}

Screenshots or screencast

Before:

Screen.Recording.2025-06-05.at.11.11.42.AM.mov

After:

Screen.Recording.2025-06-05.at.11.12.41.AM.mov

Copy link

github-actions bot commented Jun 5, 2025

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @DarkMatter-999! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 5, 2025
@DarkMatter-999 DarkMatter-999 marked this pull request as ready for review June 5, 2025 06:33
Copy link

github-actions bot commented Jun 5, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: DarkMatter-999 <[email protected]>
Co-authored-by: inc2734 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] Block API API that allows to express the block paradigm. labels Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot get blockGap when skipping supports.spacing serialisation.
2 participants