-
Notifications
You must be signed in to change notification settings - Fork 799
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
Markdown block: Add Align and Spacing features #22429
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
This commit adds Align and Spacing features to the Markdown block.
These two featurs were added by accident.
c54ea57
to
fc39bf8
Compare
This commit updates the Jest snapshot file to reflect the added `style` prop in the `<RawHTML>` component.
This commit makes sure the `supports` elements are ordered alphabetically.
The commit changes the way the `getStyles()` handles the situation where the input parameter `attribute` is undefined.
export default ( { className, source = '' } ) => ( | ||
<RawHTML className={ className } onClick={ handleLinkClick }> | ||
const getStyles = ( attributes = {} ) => { | ||
const spacingProps = getSpacingClassesAndStyles( attributes ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that getSpacingClassesAndStyles
exists before we use it, given that it's still marked as experimental?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that getSpacingClassesAndStyles exists before we use it, given that it's still marked as experimental?
Thank you for the feedback, Jeremy! That's a good point.
I have added check in the new commit: e367e3d:
const getStyles = ( attributes = {} ) => {
const spacingProps = getSpacingClassesAndStyles?.( attributes );
return spacingProps?.style ? spacingProps.style : {};
};
In case the getSpacingClassesAndStyles()
doesn't exist, spacingProps
will be undefined and getStyles()
will return an empty object. Padding won't be applied and the app won't crash. This is what the user would see:
When they click the "Attempt Block Recovery" button, padding will be removed from the content, but everything else will work correctly.
The proposed code will now also check whether spacingProps.style
exists.
By the way, I was doing a research on the state of __experimentalGetSpacingClassesAndStyles()
before and could find the following thread: WordPress/gutenberg#35920. There are no details shared unfortunately, but the function is being used with core Button block. Also, similar getColorClassesAndStyles()
function is used with the Table and Pullquote blocks.
The commit adds check that looks if `getSpacingClassesAndStyles()` exists. If it does not exist, `getStyles()` will return an empty object.
Tested Wide & Full together with/without Padding on Geologist, Quadrat & TT1 Blocks. On themes like Dara where align is not supported, switching over to Dara would not exhibit the full page stretch effect, and opening the post in the editor, the align option will not show. When switching back to a theme that supports align, the previously used alignment value is restored. |
Great news! One last step: head over to your WordPress.com diff, D73475-code, and commit it. Thank you! |
Since this change affects custom Gutenberg block, I am adding it to the list of diffs to commit on the Jetpack release day. |
Changeset: r239310-wpcom. |
Changes proposed in this Pull Request:
The proposed change adds Align (Wide & Full Width) and Dimensions (Padding) features to the Markdown block.
Jetpack product discussion
This PR is a part of the Expanding Jetpack Block design tooling for Full Site Editing project: pdDOJh-6-p2.
Does this pull request change what data or activity we track or use?
No, it does not.
Testing instructions:
For example, themes like Storefront and Dara doesn't support block Dimensions / Padding and therefore it won't display in the block sidebar. Theme like Hever, Maywood or Geologist support both Align and Dimensions / Padding.
Example markdown text you can use in your tests: