-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Document isMultiBlock param for block transforms #25952
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
Conversation
|
Size Change: +758 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
ntsekouras
left a comment
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.
Thanks @nosolosw - that's definitely helpful.
I recently worked on tranforms and missed the fact that documentation was lacking, by looking the source code.
| - **blocks** _(array)_: a list of known block types. It also accepts the wildcard value (`"*"`), meaning that the transform is available to _all_ block types (eg: all blocks can transform into `core/group`). | ||
| - **transform** _(function)_: a callback that receives the attributes and inner blocks of the block being processed. It should return a block object or an array of block objects. | ||
| - **isMatch** _(function, optional)_: a callback that receives the block attributes and should return a boolean. Returning `false` from this function will prevent the transform from being available and displayed as an option to the user. | ||
| - **isMultiblock** _(boolean, optional)_: whether the transformation can be applied when multiple blocks are selected. If this is true, the `transform` function will receive as paramaters an with the values of each selected block. False by default. |
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.
You missed the word array in will receive as paramaters an with... and maybe replace values with attributes?
Also the API returns a second argument that is an array with the InnerBlocks of each selected block.
gutenberg/packages/blocks/src/api/factory.js
Line 463 in c120818
| transformationResults = transformation.transform( |
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.
Good catch! Pushed a new wording. Is now clearer? Will welcome suggestions. Today, my brain has proven to have issues to enter documentation mode.
ntsekouras
left a comment
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.
Thanks! 👍 - I think the 's is need and it's fine!
docs/designers-developers/developers/block-api/block-transforms.md
Outdated
Show resolved
Hide resolved
…s.md Co-authored-by: Nik Tsekouras <[email protected]>
Documents the
isMultiBlockparam of block transformations.