-
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
Use Maps to pass "constructor args" to blocks from a transform #49456
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
|
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. |
What & why
This is an alternative approach to #49391.
Instead of adjusting the block API, we can take advantage of the fact that
transforms
andedit
exist within the same package (block-library
) and send "constructor args" toedit
via aMap
defined 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
url
attribute while the file is uploaded. I've included a fix for the File block (61ad707) to illustrate howparams
helps.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.