Skip to content

Commit

Permalink
fix: Switch from hostic dom to zeed dom (#2151)
Browse files Browse the repository at this point in the history
* add zeed-dom

* update zeed-dom for performance improvements
  • Loading branch information
philippkuehn authored Nov 9, 2021
1 parent 696cfcb commit 56a75db
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.133",
"hostic-dom": "^0.8.7",
"prosemirror-model": "^1.15.0"
"prosemirror-model": "^1.15.0",
"zeed-dom": "^0.9.15"
},
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions packages/html/src/generateJSON.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
11 changes: 5 additions & 6 deletions packages/html/src/getHTMLFromFragment.ts
Original file line number Diff line number Diff line change
@@ -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()
}
19 changes: 10 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3483,7 +3483,7 @@ css-unit-converter@^1.1.1:
resolved "https://registry.yarnpkg.com/css-unit-converter/-/css-unit-converter-1.1.2.tgz#4c77f5a1954e6dbff60695ecb214e3270436ab21"
integrity sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA==

css-what@^5.0.1:
css-what@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe"
integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==
Expand Down Expand Up @@ -5095,14 +5095,6 @@ hosted-git-info@^4.0.0, hosted-git-info@^4.0.1:
dependencies:
lru-cache "^6.0.0"

hostic-dom@^0.8.7:
version "0.8.7"
resolved "https://registry.yarnpkg.com/hostic-dom/-/hostic-dom-0.8.7.tgz#fafb73da1d0dbd08b0c76e5baf3ca8aba28716be"
integrity sha512-TUUD8jv1fzfbual/ljzYMcyXorjAJX4dtm9eE3YxSyVmGCQSfTyvvsXpz60IfeZDdPUB2vjTOhlI8n2l+8BdmA==
dependencies:
css-what "^5.0.1"
he "^1.2.0"

hsl-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hsl-regex/-/hsl-regex-1.0.0.tgz#d49330c789ed819e276a4c0d272dffa30b18fe6e"
Expand Down Expand Up @@ -9065,3 +9057,12 @@ yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zeed-dom@^0.9.15:
version "0.9.15"
resolved "https://registry.yarnpkg.com/zeed-dom/-/zeed-dom-0.9.15.tgz#024dd9f93cc4f04f0fca17053060975747d35687"
integrity sha512-xLFxKLjksNT5I11v6xy8b8LU8Vv+q7m3ppG76NcTQvOtTQxf+RKHJhlibld7RinIVBqCxO4o0geEnshgOYGY6Q==
dependencies:
css-what "^5.1.0"
optionalDependencies:
he "^1.2.0"

0 comments on commit 56a75db

Please sign in to comment.