-
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
Update docs to reflect new preferred convert
method on transform objects
#15972
Comments
apply
method on transform objects convert
method on transform objects
@youknowriad @aduth Did we decide to stick with this naming? Either way is this docs task required for the release (which I think is coming up soon right?). |
I don't personally take strong issue with it. I know @nerrad had proposed an alternative I think I'll be fine to see it go through as-is. We could flag it as "experimental" if we wanted some more time to consider it. But just as well, there is still an option to deprecate before the next WordPress stable release if a viable alternative presents itself.
No, I don't think it's required. |
After talking a bit more with @nerrad , I think we may want to just mark this as experimental for now. There were a few other approaches we discussed, and in general I don't think we seem all that comfortable to commit to the current API as proposed. Since it's not documented anyways, we can plan to stabilize the API in tandem with introducing the documentation. A few of the additional considerations:
Personally, I also sought to look up additional options for words, closer to the intention with the "apply" as describe the act of applying a transform. None of which really strike me more than what's already been considered.
I've also considered completely different options for defining the transform, again not striking me as particularly viable or an improvement.
As an immediate action item, I will follow-up with a pull request to mark this function as experimental (Edit: See #16047). |
Thanks for summarizing this @aduth! |
@aduth When might be remove |
@youknowriad @aduth Sorry to chase, but just wondering if it's ok to make this a first-class citizen now? I noticed this effort to audit experimental APIs so perhaps this will be taken care of without me needing to keep 👁 👁 on it? |
@getdave Sorry that I'd missed your October ping, as it happened to fall within a window of my extended leave from the project. Coincidentally, I'd been thinking about this since it had been brought up in Slack as something to stabilize. Much of this prior discussion had slipped my memory, and I don't personally take any issue with stabilizing the function as it exists today. I can plan to take care of it, unless you had already been thinking about it? |
Looking at the documentation: There are two things which stand out to me:
One idea which I don't know had been considered previously: What if we continue to support There's still a problem in that one form receives the full block objects ( What we could do, though, if we want the behavior to align, is to proceed with the renaming and soft-deprecation of Something like:
The reason I think this matters is that, anecdotally, I suspect that the majority of usage will only care to apply a consistent transformation on singular blocks. The multi-block transforms (like for the Group block) seem to be more of the edge-case, so it doesn't really make sense to me to optimize for this. |
Looking again at the implementation, there's already an (undocumented) expectation that multi-block transformations should provide a Thus, I don't think we need to have separate functions, we can just name the function |
Related to this, and probably more pressing for consideration: There are special kinds of transformation "types" which are handled outside the standard block transform API. These also use the See also:
This late observation and additional maintenance overhead can serve as good justification that this ought to be refactored to a consolidated approach, which might be worth doing as part of this effort. |
I managed to work my way through most of a branch to deprecate |
The pull request at #19401 will stabilize this API. The open questions are still pending on how we address some of the inconsistencies noted in my previous comment. |
Cross-commenting for visibility #19401 (comment) |
A new
convert
method will shortly become the preferred way to define the way in which one (or more blocks) can be transformed into one (or more) other blocks using the Block Transforms mechanic.Currently developers define a
transform
method on the transform object definition in which they defined how to transform the block.The issue is that this function is provided with only 2 arguments
attributes
innerBlocks
However, there are many cases where having access to the entire Block object is required (eg: for example see the Grouping mechanic).
After a lengthy discussion in Slack and having reviewed several options, it was decided to create a new
convert
method which would accept the full block object.When the transform is applied this
convert
method is always run in preference over anytransform
method. However, if noconvert
method is defined then thetransform
method will be attempted. As a result it is fully backwards compatible.We now need to fully document this change. This involves:
See also #14908
The text was updated successfully, but these errors were encountered: