mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 19:59:02 +08:00
add italic parseDOM tests
This commit is contained in:
parent
78cc76c1a6
commit
d09c664909
@ -10,6 +10,27 @@ context('/api/extensions/italic', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('i tags should be transformed to em tags', () => {
|
||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||
editor.setContent('<p><i>Example Text</i></p>')
|
||||
expect(editor.html()).to.eq('<p><em>Example Text</em></p>')
|
||||
})
|
||||
})
|
||||
|
||||
it('i tags with normal font style should be omitted', () => {
|
||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||
editor.setContent('<p><i style="font-style: normal">Example Text</i></p>')
|
||||
expect(editor.html()).to.eq('<p>Example Text</p>')
|
||||
})
|
||||
})
|
||||
|
||||
it('generic tags with italic style should be transformed to strong tags', () => {
|
||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||
editor.setContent('<p><span style="font-style: italic">Example Text</span></p>')
|
||||
expect(editor.html()).to.eq('<p><em>Example Text</em></p>')
|
||||
})
|
||||
})
|
||||
|
||||
it('the button should make the selected text italic', () => {
|
||||
cy.get('.demo__preview button:first')
|
||||
.click()
|
||||
|
@ -19,9 +19,16 @@ export default new Mark()
|
||||
.name('italic')
|
||||
.schema(() => ({
|
||||
parseDOM: [
|
||||
{ tag: 'i' },
|
||||
{ tag: 'em' },
|
||||
{ style: 'font-style=italic' },
|
||||
{
|
||||
tag: 'em',
|
||||
},
|
||||
{
|
||||
tag: 'i',
|
||||
getAttrs: node => (node as HTMLElement).style.fontStyle !== 'normal' && null,
|
||||
},
|
||||
{
|
||||
style: 'font-style=italic',
|
||||
},
|
||||
],
|
||||
toDOM: () => ['em', 0],
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user