mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-23 00:27:49 +08:00
14 lines
438 B
TypeScript
14 lines
438 B
TypeScript
import { Node, DOMSerializer, Schema } from 'prosemirror-model'
|
|
|
|
export default function getHTMLFromFragment(doc: Node, schema: Schema): string {
|
|
const fragment = DOMSerializer
|
|
.fromSchema(schema)
|
|
.serializeFragment(doc.content)
|
|
|
|
const temporaryDocument = document.implementation.createHTMLDocument()
|
|
const container = temporaryDocument.createElement('div')
|
|
container.appendChild(fragment)
|
|
|
|
return container.innerHTML
|
|
}
|