editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Add metadata to existing blocks and return it on Editor save

Open majuric opened this issue 7 years ago • 5 comments

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"
         }
      }

majuric avatar Apr 15 '19 15:04 majuric

Hi @majuric

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

gohabereg avatar Apr 15 '19 16:04 gohabereg

To add a use-case to this request: if I am saving the data in a different format, and assembling it before passing through to Editor.js then it would be useful to have my own meta associated with each block, so that if a block is updated, I can then pass that individual change back to my database.

This could be useful for real-time collaboration, etc.

jamiemchale avatar Aug 21 '19 22:08 jamiemchale

Is there any new infomation on this issue?

hughfenghen avatar Mar 17 '20 01:03 hughfenghen

Any update on this? Whatever data I pass should remain on the object after save()

evanjmg avatar Mar 03 '21 12:03 evanjmg

We really need that ability

ksydex avatar Jun 02 '21 13:06 ksydex