2022-06-08 20:10:25 +08:00
|
|
|
import { DOMSerializer, Node, 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, {
|
2022-06-20 17:45:37 +08:00
|
|
|
document: (createHTMLDocument() as unknown as Document),
|
2021-11-09 23:09:39 +08:00
|
|
|
}) as unknown as VHTMLDocument
|
|
|
|
|
|
|
|
return document.render()
|
2020-09-04 19:44:27 +08:00
|
|
|
}
|