const jsonContent = editor.getJSON()
內文JSON
可以將不同節點的內文,以段落格式分類,並且儲存資料的類型,用陣列去記住彼此之間的順序
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "I'm running Tiptap with Vue.js. 🎉"
}
]
},
{
"type": "heading",
"attrs": {
"level": 1
},
"content": [
{
"type": "text",
"text": "h1"
}
]
},
{
"type": "bulletList",
"content": [
{
"type": "listItem",
"attrs": {
"color": null
},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "list"
}
]
}
]
}
]
},
{
"type": "paragraph"
}
]
}
editor.commands.setContent(jsonContent)
一樣使用內建的功能就能渲染出HTML
所以不需要擔心轉換的問題,tiptap都幫你處理好了
不知不覺就過一半了,每天都在趕稿今天也在修畫面...