2

I am migrating to newer version of react slate editor. But the data format of the new version is different than old one(0.47.x). Is there any function given by slate-react or slate itself for the conversion? The old data stored in the db is not compatible with new version of slate.

Old version looks like:

{
  "object": "value",
  "document": {
    "object": "document",
    "data": {},
    "nodes": [
      {
        "object": "block",
        "type": "paragraph",
        "data": {},
        "nodes": [
          {
            "object": "text",
            "text": "angaint ",
            "marks": []
          },
          {
            "object": "text",
            "text": "new",
            "marks": [
              {
                "object": "mark",
                "type": "bold",
                "data": {}
              }
            ]
          },
         
        ]
      },
      
    ]
  }
}

Newer looks like:

[
  {
    "type": "paragraph",
    "children": [
      {
        "text": "write something "
      },
      {
        "text": "things to do ",
        "bold": true
      },
      {
        "type": "link",
        "href": "google.com",
        "target": "_blank",
        "children": [
          {
            "text": "here"
          }
        ]
      },
      {
        "text": " and there"
      },
      
    ]
  }
]()
Bhuwan Adhikari
  • 879
  • 1
  • 9
  • 21

0 Answers0