-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add 'innerBlocks' support for transforms #11979
Add 'innerBlocks' support for transforms #11979
Conversation
I consider this PR more or less done from a code standpoint, as it is really minor. However, I have not yet written (possible) e2e tests, as I have no idea how to do that. But I've updated the 'inner-blocks-templates' test plugin to add an appropriate block to test my two changes. |
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.
Nice changes @Luehrsen, thank you for your contribution 👍
Things tested well and the code looks good.
Given that we already have samples created here to be used in the tests, would it be possible to add a sample to https://github.com/WordPress/gutenberg/blob/master/docs/block-api.md#transforms-optional and document this enhancement to the API?
@jorgefilipecosta Done. While reviewing that doc-page: Aren't the ES5 examples wrong in terms of curly-braces and 'content' in reality being '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.
API-wise, this looks like a reasonable change which aligns with the general pattern of a "name, attributes, innerBlocks" triple when the name is already known.
Could you make the following changes?
- Additional unit tests for
switchToBlockType
in thetest/factory.js
file to cover new functionality - A note in
packages/blocks/CHANGELOG.md
describing the new feature, bumping to a new minor "Unreleased" version (reference)
@aduth I have updated the changelog as requested, but I am a total noob in terms of TDD, so any help with the unit test would be MUCH appreciated. |
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.
I rebased and force-pushed to resolve conflicts and add missing unit tests.
Writing the test for the multi-blocks, it became apparent that it's super goofy to pass as arguments two arrays of the attributes
and innerBlocks
of the blocks being transformed, rather than just the array of blocks themselves. Alas, it seems what we're forced into doing to keep backward-compatibility.
Co-Authored-By: Hendrik Luehrsen <[email protected]>
Co-Authored-By: Hendrik Luehrsen <[email protected]>
Co-Authored-By: Hendrik Luehrsen <[email protected]>
Description
This PR aims to provide support for 'innerBlocks' in transform rules. The proposed syntax is like this.
How has this been tested?
This PR has been manually tested. E2E tests are possible and the needed plugin code exists, the test itself has not been written.
Types of changes
Checklist:
closes #13052