mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-06 10:50:10 +08:00
15 lines
465 B
TypeScript
15 lines
465 B
TypeScript
import { DOMSerializer, Schema, Fragment } from 'prosemirror-model'
|
|
|
|
export default function getHTMLFromFragment(fragment: Fragment, schema: Schema): string {
|
|
const documentFragment = DOMSerializer
|
|
.fromSchema(schema)
|
|
.serializeFragment(fragment)
|
|
|
|
const temporaryDocument = document.implementation.createHTMLDocument()
|
|
const container = temporaryDocument.createElement('div')
|
|
|
|
container.appendChild(documentFragment)
|
|
|
|
return container.innerHTML
|
|
}
|