Skip to content

Commit

Permalink
fix(core): handle macOS text expansion properly in InputRules (#5261)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfgamaral authored Aug 22, 2024
1 parent f805333 commit 88e310b
Show file tree
Hide file tree
Showing 50 changed files with 384 additions and 368 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ context('/src/Commands/InsertContentApplyingRules/React/', () => {
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.clearContent()
})
cy.resetEditor()
})

it('should apply list InputRule', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,47 @@ context('/src/Examples/InteractivityComponentContent/React/', () => {
})

it('should have a working tiptap instance', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
cy.get('.tiptap').then(([{ editor }]) => {
// eslint-disable-next-line
expect(editor).to.not.be.null
})
})

it('should render a custom node', () => {
cy.get('.ProseMirror .react-component')
cy.get('.tiptap .react-component')
.should('have.length', 1)
})

it('should allow text editing inside component', () => {
cy.get('.ProseMirror .react-component .content div')
cy.get('.tiptap .react-component .content div')
.invoke('attr', 'contentEditable', true)
.invoke('text', '')
.type('Hello World!')
.should('have.text', 'Hello World!')
})

it('should allow text editing inside component with markdown text', () => {
cy.get('.ProseMirror .react-component .content div')
cy.get('.tiptap .react-component .content div')
.invoke('attr', 'contentEditable', true)
.invoke('text', '')
.type('Hello World! This is **bold**.')
.click()
cy.get('.tiptap .react-component .content div')
.realType('Hello World! This is **bold**.')
cy.get('.tiptap .react-component .content div')
.should('have.text', 'Hello World! This is bold.')

cy.get('.ProseMirror .react-component .content strong')
cy.get('.tiptap .react-component .content strong')
.should('exist')
})

it('should remove node via selectall', () => {
cy.get('.ProseMirror .react-component')
cy.get('.tiptap .react-component')
.should('have.length', 1)

cy.get('.ProseMirror')
cy.get('.tiptap')
.type('{selectall}{backspace}')

cy.get('.ProseMirror .react-component')
cy.get('.tiptap .react-component')
.should('have.length', 0)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ context('/src/Examples/InteractivityComponentContent/Vue/', () => {
cy.get('.tiptap .vue-component .content')
.invoke('attr', 'contentEditable', true)
.invoke('text', '')
.type('Hello World! This is **bold**.')
.click()
cy.get('.tiptap .vue-component .content')
.realType('Hello World! This is **bold**.')
cy.get('.tiptap .vue-component .content')
.should('have.text', 'Hello World! This is bold.')

cy.get('.tiptap .vue-component .content strong')
Expand Down
43 changes: 27 additions & 16 deletions demos/src/Examples/MarkdownShortcuts/React/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,109 @@ context('/src/Examples/MarkdownShortcuts/React/', () => {
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.clearContent()
})
cy.resetEditor()
})

it('should make a h1', () => {
cy.get('.tiptap')
.type('# Headline')
.realType('# Headline')
cy.get('.tiptap')
.find('h1')
.should('contain', 'Headline')
})

it('should make a h2', () => {
cy.get('.tiptap')
.type('## Headline')
.realType('## Headline')
cy.get('.tiptap')
.find('h2')
.should('contain', 'Headline')
})

it('should make a h3', () => {
cy.get('.tiptap')
.type('### Headline')
.realType('### Headline')
cy.get('.tiptap')
.find('h3')
.should('contain', 'Headline')
})

it('should make a h4', () => {
cy.get('.tiptap')
.type('#### Headline')
.realType('#### Headline')
cy.get('.tiptap')
.find('h4')
.should('contain', 'Headline')
})

it('should make a h5', () => {
cy.get('.tiptap')
.type('##### Headline')
.realType('##### Headline')
cy.get('.tiptap')
.find('h5')
.should('contain', 'Headline')
})

it('should make a h6', () => {
cy.get('.tiptap')
.type('###### Headline')
.realType('###### Headline')
cy.get('.tiptap')
.find('h6')
.should('contain', 'Headline')
})

it('should create inline code', () => {
cy.get('.tiptap')
.type('`$foobar`')
.realType('`$foobar`')
cy.get('.tiptap')
.find('code')
.should('contain', '$foobar')
})

it('should create a code block without language', () => {
cy.get('.tiptap')
.type('``` {enter}const foo = bar{enter}```')
.realType('``` {enter}const foo = bar{enter}```')
cy.get('.tiptap')
.find('pre')
.should('contain', 'const foo = bar')
})

it('should create a bullet list from asteriks', () => {
cy.get('.tiptap')
.type('* foobar')
.realType('* foobar')
cy.get('.tiptap')
.find('ul')
.should('contain', 'foobar')
})

it('should create a bullet list from dashes', () => {
cy.get('.tiptap')
.type('- foobar')
.realType('- foobar')
cy.get('.tiptap')
.find('ul')
.should('contain', 'foobar')
})

it('should create a bullet list from pluses', () => {
cy.get('.tiptap')
.type('+ foobar')
.realType('+ foobar')
cy.get('.tiptap')
.find('ul')
.should('contain', 'foobar')
})

it('should create a ordered list', () => {
cy.get('.tiptap')
.type('1. foobar')
.realType('1. foobar')
cy.get('.tiptap')
.find('ol')
.should('contain', 'foobar')
})

it('should create a blockquote', () => {
cy.get('.tiptap')
.type('> foobar')
.realType('> foobar')
cy.get('.tiptap')
.find('blockquote')
.should('contain', 'foobar')
})
Expand Down
43 changes: 27 additions & 16 deletions demos/src/Examples/MarkdownShortcuts/Vue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,109 @@ context('/src/Examples/MarkdownShortcuts/Vue/', () => {
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.clearContent()
})
cy.resetEditor()
})

it('should make a h1', () => {
cy.get('.tiptap')
.type('# Headline')
.realType('# Headline')
cy.get('.tiptap')
.find('h1')
.should('contain', 'Headline')
})

it('should make a h2', () => {
cy.get('.tiptap')
.type('## Headline')
.realType('## Headline')
cy.get('.tiptap')
.find('h2')
.should('contain', 'Headline')
})

it('should make a h3', () => {
cy.get('.tiptap')
.type('### Headline')
.realType('### Headline')
cy.get('.tiptap')
.find('h3')
.should('contain', 'Headline')
})

it('should make a h4', () => {
cy.get('.tiptap')
.type('#### Headline')
.realType('#### Headline')
cy.get('.tiptap')
.find('h4')
.should('contain', 'Headline')
})

it('should make a h5', () => {
cy.get('.tiptap')
.type('##### Headline')
.realType('##### Headline')
cy.get('.tiptap')
.find('h5')
.should('contain', 'Headline')
})

it('should make a h6', () => {
cy.get('.tiptap')
.type('###### Headline')
.realType('###### Headline')
cy.get('.tiptap')
.find('h6')
.should('contain', 'Headline')
})

it('should create inline code', () => {
cy.get('.tiptap')
.type('`$foobar`')
.realType('`$foobar`')
cy.get('.tiptap')
.find('code')
.should('contain', '$foobar')
})

it('should create a code block without language', () => {
cy.get('.tiptap')
.type('``` {enter}const foo = bar{enter}```')
.realType('``` {enter}const foo = bar{enter}```')
cy.get('.tiptap')
.find('pre')
.should('contain', 'const foo = bar')
})

it('should create a bullet list from asteriks', () => {
cy.get('.tiptap')
.type('* foobar')
.realType('* foobar')
cy.get('.tiptap')
.find('ul')
.should('contain', 'foobar')
})

it('should create a bullet list from dashes', () => {
cy.get('.tiptap')
.type('- foobar')
.realType('- foobar')
cy.get('.tiptap')
.find('ul')
.should('contain', 'foobar')
})

it('should create a bullet list from pluses', () => {
cy.get('.tiptap')
.type('+ foobar')
.realType('+ foobar')
cy.get('.tiptap')
.find('ul')
.should('contain', 'foobar')
})

it('should create a ordered list', () => {
cy.get('.tiptap')
.type('1. foobar')
.realType('1. foobar')
cy.get('.tiptap')
.find('ol')
.should('contain', 'foobar')
})

it('should create a blockquote', () => {
cy.get('.tiptap')
.type('> foobar')
.realType('> foobar')
cy.get('.tiptap')
.find('blockquote')
.should('contain', 'foobar')
})
Expand Down
4 changes: 1 addition & 3 deletions demos/src/Examples/Minimal/React/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ context('/src/Examples/Minimal/React/', () => {
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.clearContent()
})
cy.resetEditor()
})

it('text should be wrapped in a paragraph by default', () => {
Expand Down
4 changes: 1 addition & 3 deletions demos/src/Examples/Minimal/Vue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ context('/src/Examples/Minimal/Vue/', () => {
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.clearContent()
})
cy.resetEditor()
})

it('text should be wrapped in a paragraph by default', () => {
Expand Down
7 changes: 3 additions & 4 deletions demos/src/Examples/Savvy/React/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ context('/src/Examples/Savvy/React/', () => {
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.clearContent()
})
cy.resetEditor()
})

const tests = [
Expand All @@ -24,7 +22,8 @@ context('/src/Examples/Savvy/React/', () => {

tests.forEach(test => {
it(`should parse ${test[0]} correctly`, () => {
cy.get('.tiptap').type(`${test[0]} `).should('contain', test[1])
cy.get('.tiptap').realType(`${test[0]} `)
cy.get('.tiptap').should('contain', test[1])
})
})

Expand Down
7 changes: 3 additions & 4 deletions demos/src/Examples/Savvy/Vue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ context('/src/Examples/Savvy/Vue/', () => {
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.clearContent()
})
cy.resetEditor()
})

const tests = [
Expand All @@ -25,7 +23,8 @@ context('/src/Examples/Savvy/Vue/', () => {
tests.forEach(test => {
it(`should parse ${test[0]} correctly`, () => {
cy.get('.tiptap')
.type(`${test[0]} `)
.realType(`${test[0]} `)
cy.get('.tiptap')
.should('contain', test[1])
})
})
Expand Down
Loading

0 comments on commit 88e310b

Please sign in to comment.