tiptap/packages/html/src/getHTMLFromFragment.ts

13 lines
405 B
TypeScript
Raw Normal View History

2020-09-24 06:29:05 +08:00
import { Node, DOMSerializer, Schema } from 'prosemirror-model'
import { createHTMLDocument, VHTMLDocument } from 'zeed-dom'
2020-09-04 19:44:27 +08:00
2020-10-29 00:20:38 +08:00
export default function getHTMLFromFragment(doc: Node, schema: Schema): string {
const document = DOMSerializer
2020-09-04 19:44:27 +08:00
.fromSchema(schema)
2020-10-29 00:12:25 +08:00
.serializeFragment(doc.content, {
document: createHTMLDocument(),
}) as unknown as VHTMLDocument
return document.render()
2020-09-04 19:44:27 +08:00
}