kommitters / editorjs-undo

Undo/Redo feature for Editor.js
https://www.npmjs.com/package/editorjs-undo
MIT License
169 stars 51 forks source link

Add support for operations on nested list-like properties of a block #278

Closed keliumJU closed 2 months ago

keliumJU commented 2 months ago

Context

Currently, the new approach to do undo/redo actions does not support updates on nested list-like properties of a block, i.e., given the following structure:

 {
  "id": "aZB6o-2E6S",
  "type": "table",
  "data": {
    "withHeadings": false,
    "content": [
      [
        "head 1",
        "head 2"
      ],
      [
        "element 1",
        "element 2"
      ]
    ]
  }
}

The elements in content are nested, so the result of the formater would be:

op: "remove",
path: "3/data/content/1/1" 

This means that element 1 would be removed from element 1 of content, this is not contemplated and currently the editorjs block API does not allow modifying data individually in the block properties, but in the whole block by means of the update function, therefore, it is necessary to make the following validations:

This ensures that internal modifications are visible in the DOM.

Objective