2020-09-24 06:29:05 +08:00
|
|
|
import { Node, DOMSerializer, Schema } from 'prosemirror-model'
|
2021-11-09 23:09:39 +08:00
|
|
|
import { createHTMLDocument, VHTMLDocument } from 'zeed-dom'
|
2020-09-04 19:44:27 +08:00
|
|
|
|
2021-12-06 19:00:09 +08:00
|
|
|
export function getHTMLFromFragment(doc: Node, schema: Schema): string {
|
2021-11-09 23:09:39 +08:00
|
|
|
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(),
|
2021-11-09 23:09:39 +08:00
|
|
|
}) as unknown as VHTMLDocument
|
|
|
|
|
|
|
|
return document.render()
|
2020-09-04 19:44:27 +08:00
|
|
|
}
|