JSON Data Processing Created Using Editor.js

  Kiến thức lập trình

I am creating a page that receives JSON data created using Editor.js, a document editor, in the GET method.

{
  "userId": 1,
  "petType": "DOG",
  "title": "Top Tips for Dog Care",
  "category": "TIPS",
  "blocks": [{
      "id": "mhTl6ghSkV",
      "type": "paragraph",
      "data": {
        "text": "Hey. Meet the new Editor. On this picture you can see it in action. Then, try a demo 🤓"
      }
    },
    {
      "id": "l98dyx3yjb",
      "type": "header",
      "data": {
        "text": "Key features",
        "level": 3
      }
    },
    {
      "id": "os_YI4eub4",
      "type": "list",
      "data": {
        "type": "unordered",
        "items": [
          "It is a block-style editor",
          "It returns clean data output in JSON",
          "Designed to be extendable and pluggable with a <a href="https://editorjs.io/creating-a-block-tool">simple API</a>"
        ]
      }
    },
    {
      "id": "TcUNySG15P",
      "type": "paragraph",
      "data": {
        "text": "Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor.js workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc. Each of them is an independent <sup data-tune="footnotes">1</sup> contenteditable element (or more complex structure) provided by Plugin and united by Editor's Core."
      },
      "tunes": {
        "footnotes": [
          "It works more stable then in other WYSIWYG editors. Same time it has smooth and well-known arrow navigation behavior like classic editors."
        ]
      }
    },
    {
      "id": "ksCokKAhQw",
      "type": "paragraph",
      "data": {
        "text": "Classic WYSIWYG editors produce raw HTML-markup with both content data and content appearance. On the contrary, <mark class="cdx-marker">Editor.js outputs JSON object</mark> with data of each Block."
      }
    },
    {
      "id": "XKNT99-qqS",
      "type": "attaches",
      "data": {
        "file": {
          "url": "https://drive.google.com/user/catalog/my-file.pdf",
          "size": 12902,
          "name": "file.pdf",
          "extension": "pdf"
        },
        "title": "My file"
      }
    },
    {
      "id": "hZAjSnqYMX",
      "type": "image",
      "data": {
        "file": {
          "url": "assets/codex2x.png"
        },
        "withBorder": false,
        "withBackground": false,
        "stretched": true,
        "caption": "CodeX Code Camp 2019"
      }
    }
  ]
}

However, when I actually received the data, I found that the field was too complex as above api data, and there were so many different factors such as font thickness and italic body application.
Originally, I tried to apply the style myself by separating the elements one by one with a switch case statement, but I thought it was almost impossible.

So my question is, may I know a tool or a way to help you process JSON data made with these editor.js? I couldn’t find it however I searched.

I’ve seen most of the videos involved and I’ve tried Googling, but I couldn’t find a satisfactory answer.

New contributor

김현지 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT