-
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
Allow convert to blocks for other block types #4795
Comments
Not sure I understand the question? If you want your block to be a possible resulting block of the "convert to blocks" actions, you can do this by implemeting a "raw" transforms (not documented yet #4578). Example here https://github.com/WordPress/gutenberg/blob/master/blocks/library/image/index.js#L69-L87 If you want to allow your block to be transformed to other blocks (using the block switcher for instance), it's also done using the transforms property (but this time it's the type: "blocks") |
Thanks, @youknowriad! I actually want my block to be transformed to other blocks just like the Classic Text block. I played around with transforms but I couldn't figure out how to do a catch-all transform like that. Is it possible to do something like this with transforms? |
@fastlinemedia I think you probably could do it since |
Yes, I see no reason to not keep it exposed. We should add the button to the HTML block as well, which could be a good example on how to do it for other blocks. |
And yes, I should add a read me file for it :) |
That would be great. I'll dig into |
The Convert to Blocks option has now been added to the Custom HTML block by #7667. |
This needs documentation to be closed out. |
I think we might be blocked on writing documentation by the potential changes to the raw handler to separate from pasting, but maybe @iseulde could help clarify here whether this might be impacted in those changes? |
So the rawHandler API is now automatically documented as part of the blocks module https://wordpress.org/gutenberg/handbook/designers-developers/developers/packages/packages-blocks/#rawHandler I think it can be enhanced as this is pretty minimal but I think it's fine to close this issue now. |
Issue Overview
My apologies if this is already possible with transforms, I couldn't tell from the docs. I have a block that I'd like users to be able to "convert to blocks" similar to what you can do with the Classic Text block. That looks like a really powerful catch-all for converting a string of HTML into blocks.
I did notice that I can call
setUnknownTypeHandlerName( 'my-plugin/my-block' )
to make that happen but that doesn't seem like a very safe solution. Thanks!The text was updated successfully, but these errors were encountered: