Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.03 KB

README.md

File metadata and controls

61 lines (51 loc) · 1.03 KB

Editor.js (Go)

Server-side implementation sample for the Editor.js. It contains data validation and converts output from Editor.js to HTML.

Installation

go get github.com/si3nloong/go-editorjs

Basic usage

import (
    editorjs "github.com/si3nloong/go-editorjs"
)

func main() {
    b := []byte(`
    {
        "time": 1589098011153,
        "blocks": [
            {
            "type": "header",
            "data": {
                "text": "Editor.js",
                "level": 2
            }
            }
        ],
        "version": "2.17.0"
    }
    `)

    ejs := editorjs.NewEditorJS()
    buf := new(bytes.Buffer)
    if err := ejs.ParseTo(b, buf); err != nil {
        panic(err)
    }

    log.Println("HTML result =>", buf.String())
}

Example of Editor.js output

{
  "time": 1589098011153,
  "blocks": [
    {
      "type": "header",
      "data": {
        "text": "Editor.js",
        "level": 2
      }
    }
  ],
  "version": "2.17.0"
}