tiptap/packages/html/index.ts

11 lines
368 B
TypeScript
Raw Normal View History

2020-09-10 06:11:07 +08:00
import { Extensions, getSchema } from '@tiptap/core'
2020-09-04 19:44:27 +08:00
import { Node } from 'prosemirror-model'
2020-09-10 06:11:07 +08:00
import getHtmlFromFragment from './getHtmlFromFragment'
2020-09-04 19:44:27 +08:00
2020-10-29 00:12:25 +08:00
export function generateHtml(doc: object, extensions: Extensions): string {
2020-09-04 19:44:27 +08:00
const schema = getSchema(extensions)
const contentNode = Node.fromJSON(schema, doc)
return getHtmlFromFragment(contentNode, schema)
}