Set data to entry object from preview template

I have a resizable grid inside my page preview template when I’m moving its items it’s changing coordinates, I would like to save this coordinates to markdown. How can I make it?

Here is my preview component, where I have a callback onLayoutChange and I’m trying to use inside it setIn (not sure if it’s correct) to persist my changes

Here is my page template, where grid itself and layout generator

Thanks

Hi @passingby, preview templates are designed to consume data generated by the CMS and not to pass data back to the CMS.

You can:

  1. Model the grid coordinates in your config.yml (maybe using an object widget wrapping some number widgets).
  2. Create a custom widget to set the grid coordinates.
  3. Use CMS preSave event to change the content:
    https://www.netlifycms.org/docs/beta-features/#registering-to-cms-events