-
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
Proposal: Internal block attributes #49457
Conversation
Size Change: +338 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
I wanted to re-share my comment #49391 (comment) where I expressed my sympathy towards this PR:
|
It's also an alternative approach to #34750 where @stacimc proposed extending the "attributes": {
"_blobURL": {
"type": "string",
"__experimentalRole": "internal"
}
} How do you feel about using In effect, this PR could potentially close #29693. |
What & why
This PR is an alternative approach to #49391 and experiments with adding the concept of internal attributes to the block API.
Internal attributes behave like regular attributes except that they are:
post_content
and do not appear inserialize( block )
.The motivation for this is to 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 how this can be fixed using an internal_blobURL
attribute.I've also included fixes for two other issues to illustrate that there are many uses for such an API:
__internalWidgetId
attribute in favour of an explicit_widgetId
internal attribute.__internalWidgetId
is how the widget editor tracks which widget entity should be updated when a block is modified. It's a hack that works because__internalWidgetId
does not appear in theblock.json
and so is filtered out byserialize()
. Using an internal attribute works exactly the same but is more explicit._classicMenuId
attribute. See Widget Importer: ensure it works with importing menus #47285.The downside of this is that implementation details appear for all to see in
block.json
.