-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gutenlypso: Register server-defined blocks attributes #29984
Conversation
We'll want to work with WordPress core to make sure we can access these in a cleaner way. @Copons do you mind filing an enhancement issue in https://github.com/WordPress/gutenberg/issues ? cc @gziolo @aduth @youknowriad I'm thinking maybe a custom wpcom endpoint for now to fix the issue, or embedding a similar global on the app skeleton for this section. |
No need to create an issue, we have a huge issue which is one of the goals of Gutenberg phase 2 (WordPress/gutenberg#13113). In fact, there are 2 issues opened:
Please leave your comments there if you have some ideas. Let me also re-share a part of my comment I left in the last issue:
There might be other ways to solve this. What I'm sharing is what I actually coded as an excercise to see what could work. |
Alternative approach with a custom WPCOM endpoint at #30045 + D22987-code |
Replaced by #30045 |
Changes proposed in this Pull Request
Dynamic blocks are registered server-side, and their attribute are loaded through the
unstable__bootstrapServerSideBlockDefinitions
function, called server-side as well.Gutenlypso doesn't have access to the same JS globals so it doesn't have any information about the dynamic blocks' schema and attributes.
This PR is a bit of a clumsy workaround, and proposes to manually register the attributes of server-defined blocks during the Gutenlypso initialization.
For now, I've only worked on the Latest Comments block because it's a major offender (all its attributes default to
true
, so fallbacking all of them tofalse
is very visibly incorrect), and because I'd like to discuss this change before working on more blocks.Please compare this PR with how the block defines its attributes in PHP.
Is my solution a viable, or even desirable?
Testing instructions
/block-editor
.Fixes #27963