Use Maps to pass "constructor args" to blocks from a transform#49456
Closed
noisysocks wants to merge 2 commits intotrunkfrom
Closed
Use Maps to pass "constructor args" to blocks from a transform#49456noisysocks wants to merge 2 commits intotrunkfrom
noisysocks wants to merge 2 commits intotrunkfrom
Conversation
|
Size Change: -430 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 1832263. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4559300679
|
Contributor
|
I'm giddy at how simple and uncompromising this is. It's slightly more eyebrow-rising with inter-block deps (legacy-widget ➡ navigation), but we retain all the control within the core library, with no leakage outside the package. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
This is an alternative approach to #49391.
Instead of adjusting the block API, we can take advantage of the fact that
transformsandeditexist within the same package (block-library) and send "constructor args" toeditvia aMapdefined at the module level.With this approach we can fix a longstanding issue we've had in Gutenberg which is that we use attributes to store "internal" state in certain blocks. For example an undo level is created when dragging-and-dropping an image or file into the editor because the blob URL is stored in the
urlattribute while the file is uploaded. I've included a fix for the File block (61ad707) to illustrate howparamshelps.We can also allow Menu widgets wrapped in a Legacy Widget block to be converted to a Navigation block. This is done by having the transform provide the Navigation block with the menu to convert via a
Map. See #47285.