tiptap/packages/html/src/getHTMLFromFragment.ts

13 lines
422 B
TypeScript
Raw Normal View History

import { DOMSerializer, Node, Schema } from 'prosemirror-model'
import { createHTMLDocument, VHTMLDocument } from 'zeed-dom'
2020-09-04 19:44:27 +08:00
export 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 Document),
}) as unknown as VHTMLDocument
return document.render()
2020-09-04 19:44:27 +08:00
}