Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hostic-dom to fix style attributes #1618

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"dependencies": {
"@tiptap/core": "^2.0.0-beta.86",
"hostic-dom": "^0.8.6",
"hostic-dom": "^0.8.7",
"prosemirror-model": "^1.14.2"
}
}
27 changes: 27 additions & 0 deletions tests/cypress/integration/html/generateJSON.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateJSON } from '@tiptap/html'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import TextAlign from '@tiptap/extension-text-align'

describe('generateJSON', () => {
it('generate JSON from HTML without an editor instance', () => {
Expand All @@ -26,4 +27,30 @@ describe('generateJSON', () => {
}],
}))
})

// issue: https://github.com/ueberdosis/tiptap/issues/1601
it('generate JSON with style attributes', () => {
const html = '<p style="text-align: center;">Example Text</p>'

const json = generateJSON(html, [
Document,
Paragraph,
Text,
TextAlign.configure({ types: ['paragraph'] }),
])

expect(JSON.stringify(json)).to.eq(JSON.stringify({
type: 'doc',
content: [{
type: 'paragraph',
attrs: {
textAlign: 'center',
},
content: [{
type: 'text',
text: 'Example Text',
}],
}],
}))
})
})
17 changes: 6 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4839,12 +4839,7 @@ css-what@^3.2.1:
resolved "https://registry.yarnpkg.com/css-what/-/css-what-3.4.2.tgz#ea7026fcb01777edbde52124e21f327e7ae950e4"
integrity sha512-ACUm3L0/jiZTqfzRM3Hi9Q8eZqd6IK37mMWPLz9PJxkLWllYeRf+EHUSHYEtFop2Eqytaq1FizFVh7XfBnXCDQ==

css-what@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/css-what/-/css-what-4.0.0.tgz#35e73761cab2eeb3d3661126b23d7aa0e8432233"
integrity sha512-teijzG7kwYfNVsUh2H/YN62xW3KK9YhXEgSlbxMlcyjPNvdKJqFx5lrwlJgoFP1ZHlB89iGDlo/JyshKeRhv5A==

css-what@^5.0.0:
css-what@^5.0.0, css-what@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.0.1.tgz#3efa820131f4669a8ac2408f9c32e7c7de9f4cad"
integrity sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg==
Expand Down Expand Up @@ -7690,12 +7685,12 @@ hosted-git-info@^4.0.1:
dependencies:
lru-cache "^6.0.0"

hostic-dom@^0.8.6:
version "0.8.6"
resolved "https://registry.yarnpkg.com/hostic-dom/-/hostic-dom-0.8.6.tgz#5a5e2a1270b12ff4d479acdb679ba16de3028b58"
integrity sha512-gostOugTHuFKhnO4YQpH21SBc8A4jQ1mB5sqUCYC4gXm2LLwQ85V9EFa4DPh6Z9M6sCUJ7TAs1/hqr8iraX7Rw==
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 "^4.0.0"
css-what "^5.0.1"
he "^1.2.0"

hsl-regex@^1.0.0:
Expand Down