-
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
[RNMobile] Allow wildcard block transformations for container blocks #48792
Conversation
* | ||
* @param {import('@testing-library/react-native').RenderAPI} screen The Testing Library screen. | ||
*/ | ||
export const openBlockActionsMenu = async ( screen ) => { |
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 introduced this test helper to simplify the action of opening the Block actions menu, which is needed for transforming a block.
// NOTE: Paragraph block can be transformed to Buttons block in web, | ||
// however this transform is not supported in the native version. | ||
const transformsWithInnerBlocks = [ 'List', 'Quote', 'Columns', 'Group' ]; | ||
const blockTransforms = [ | ||
'Heading', | ||
'Preformatted', | ||
'Pullquote', | ||
'Verse', | ||
...transformsWithInnerBlocks, | ||
]; |
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.
This unit test covers the blocks that a Paragraph block can be transformed to:
- Heading ✅
- List ✅
- Quote ✅
- Buttons (only in web) ❌ => Native version needs
document.createHTMLDocument
function to work. - Preformatted ✅
- Columns ✅
- Verse ✅
- Pullquote ✅
- Group ✅
Size Change: -10 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
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.
LGTM! I was able to successfully test the changes. 👍 🚀
As mentioned in the PR's description:
I'm going to reference the follow-up PRs that include the unit tests. Since we incorporated new transformations, I'd like also to take the opportunity on those PRs to perform manual tests as a double-check:
@derekblank since you reviewed this PR, I'm wondering if you could also take a look at some of the rest. Thanks 🙇 ! |
What?
Allow wildcard block transformations for container blocks in the native version of the editor.
Why?
Fix #44452.
One of the Paragraph blocks' transformations is to the Quote block. The v2 of the Quote block, which was released some time ago, allows inner blocks which makes it a container block. This change made the native version of the editor remove the Quote block transformation option based on the following code:
gutenberg/packages/blocks/src/api/factory.js
Lines 214 to 220 in d1ab8ce
How?
Disable the restriction that disallows wildcard block transformations for container blocks. It's not clear why we introduced this restriction when native block transformations were added, however, per the tests I've made seems the issues we might have by that time can no longer be reproduced.
This change will also allow new transformations for most of the blocks we support in the native version. In the following list, I outline the new transformations:
NOTE: As mentioned above, this PR will allow new transformations so I'll create another PR adding unit tests to cover the different transformations of all blocks.
UPDATE: Here are the follow-up PRs:
Testing Instructions
Testing Instructions for Keyboard
N/A
Screenshots or screencast
N/A