Tiptap: create node from json?

Created on 8 Mar 2019  路  1Comment  路  Source: ueberdosis/tiptap

How should I create a Node from json content?

for example: for the todo list example. I want to insert a todo list of 3 todo item with prefixed content.

my current roadmap is to get the json of todo lists and then create a todolist node from it then insert that node to the editor.

but I did not find a road to create a node from the json.

Thanks!

question

Most helpful comment

You can do something like this:

const doc = this.editor.getJSON()

doc.content.push({
  type: 'custom_node',
  attrs: {}, 
  content: [{
    type: 'paragraph',
  }],
})

this.editor.setContent(doc)

>All comments

You can do something like this:

const doc = this.editor.getJSON()

doc.content.push({
  type: 'custom_node',
  attrs: {}, 
  content: [{
    type: 'paragraph',
  }],
})

this.editor.setContent(doc)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

glavdir picture glavdir  路  3Comments

santicros picture santicros  路  3Comments

nekooee picture nekooee  路  3Comments

chrisjbrown picture chrisjbrown  路  3Comments

leandromatos picture leandromatos  路  4Comments