fix: Switch from hostic dom to zeed dom (#2151)

* add zeed-dom

* update zeed-dom for performance improvements
This commit is contained in:
Philipp Kühn
2021-11-09 16:09:39 +01:00
committed by GitHub
parent 696cfcbd8b
commit 56a75db024
4 changed files with 19 additions and 20 deletions

View File

@@ -1,11 +1,10 @@
import { DOMParser } from 'prosemirror-model'
import { getSchema, Extensions } from '@tiptap/core'
// @ts-ignore
import { parseHTML } from 'hostic-dom'
import { parseHTML } from 'zeed-dom'
export default function generateJSON(html: string, extensions: Extensions): Record<string, any> {
const schema = getSchema(extensions)
const dom = parseHTML(html)
const dom = parseHTML(html) as unknown as Node
return DOMParser.fromSchema(schema)
.parse(dom)

View File

@@ -1,13 +1,12 @@
import { Node, DOMSerializer, Schema } from 'prosemirror-model'
// @ts-ignore
import { createHTMLDocument } from 'hostic-dom'
import { createHTMLDocument, VHTMLDocument } from 'zeed-dom'
export default function getHTMLFromFragment(doc: Node, schema: Schema): string {
return DOMSerializer
const document = DOMSerializer
.fromSchema(schema)
.serializeFragment(doc.content, {
document: createHTMLDocument(),
})
// @ts-ignore
.render()
}) as unknown as VHTMLDocument
return document.render()
}