question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add metadata to existing blocks and return it on Editor save

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
gohaberegcommented, Apr 15, 2019

Hi @majuric

Good point! We have plans to extend the API to allow pass any meta data you want

5reactions
hughfenghencommented, Mar 17, 2020

Is there any new infomation on this issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found