Add metadata to existing blocks and return it on Editor save
See original GitHub issueIs there a way to add metadata to a block and have it returned on editor save?
For instance adding a self generated uuid to a particular so I can link the data from a particular block to some other aspect of my application.
{
"type": "paragraph",
"data": {
"text": "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration."
}
uuid: "a24f-fs4f-fsdf4-fsefsdf"
}
When I call save()
the uuid
part is stripped and it’s not returned.
Having this would be awesome to be able to link individual block and add some outside logic to it. Other metadata could be used as well. Allowing metadata
key in data would solve the issue as well
{
"type": "paragraph",
"data": {
"text": "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text. Source code of the page contains the example of connection and configuration."
},
metadata: {
uuid: "a24f-fs4f-fsdf4-fsefsdf",
foo: "bar"
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Edit and Save | Block Editor Handbook
Like the edit function, when rendering static blocks, it's important to add the block props returned by useBlockProps.save() to the wrapper element of...
Read more >Saving Metadata from the Gutenberg Editor Sidebar to the ...
In the console type the following and press return wp.data.select('core/editor').getEditedPostAttribute('meta'). This will return something like ...
Read more >Gutenberg Block fail to save block metadata - Stack Overflow
Another common issue is the post type (or custom post type) doesn't support meta values - this can be confirmed via calling:
Read more >Managing WordPress Metadata in Gutenberg Using a Sidebar ...
This function will return an array of objects where each object represents a block in your current post. So depending on how many...
Read more >Writing a Custom WordPress Block - Joni Halabi
This function accepts a single props parameter, which is an object that is automatically passed to the block edit function by Gutenberg. This ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @majuric
Good point! We have plans to extend the API to allow pass any meta data you want
Is there any new infomation on this issue?