add a generateJSON utility to the HTML package

This commit is contained in:
Hans Pagel
2021-05-05 23:10:45 +02:00
parent 90380f207d
commit a9c0bf5982
10 changed files with 95 additions and 42 deletions

View File

@@ -0,0 +1,10 @@
import { Extensions, getSchema } from '@tiptap/core'
import { Node } from 'prosemirror-model'
import getHTMLFromFragment from './getHTMLFromFragment'
export default function generateHTML(doc: object, extensions: Extensions): string {
const schema = getSchema(extensions)
const contentNode = Node.fromJSON(schema, doc)
return getHTMLFromFragment(contentNode, schema)
}