Update hostic-dom to fix style attributes

This commit is contained in:
sibiraj-s
2021-07-20 16:23:19 +05:30
committed by Hans Pagel
parent 8ed6ac4219
commit 656a80fc3f
3 changed files with 34 additions and 12 deletions

View File

@@ -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', () => {
@@ -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',
}],
}],
}))
})
})