Skip to content

Commit

Permalink
Add russian undo/redo shortcuts and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmachatschek committed Jul 14, 2021
1 parent dbe2a83 commit 23c6581
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
59 changes: 45 additions & 14 deletions docs/src/demos/Extensions/History/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
context('/demos/Extensions/History', () => {
before(() => {
cy.visit('/demos/Extensions/History')
})

beforeEach(() => {
cy.visit('/demos/Extensions/History')
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.setContent('<p>Mistake</p>')
})
Expand All @@ -20,34 +17,68 @@ context('/demos/Extensions/History', () => {
.should('not.contain', 'Mistake')
})

it('the keyboard shortcut should make the last change undone', () => {
it('should make the last change undone with the keyboard shortcut', () => {
cy.get('.ProseMirror')
.trigger('keydown', {modKey: true, key: 'z' })


cy.get('.ProseMirror')
.trigger('keydown', { modKey: true, key: 'z' })
.should('not.contain', 'Mistake')
})

it('should apply the last undone change again', () => {
it('should make the last change undone with the keyboard shortcut (russian)', () => {
cy.get('.ProseMirror')
.should('contain', 'Mistake')

cy.get('button:first')
.click()
cy.get('.ProseMirror')
.trigger('keydown', {modKey: true, key: 'я' })

cy.get('.ProseMirror')
.should('not.contain', 'Mistake')
})

cy.get('button:nth-child(2)')
.click()
it('should apply the last undone change again with the keyboard shortcut', () => {
cy.get('.ProseMirror')
.trigger('keydown', {modKey: true, key: 'z' })

cy.get('.ProseMirror')
.should('not.contain', 'Mistake')

cy.get('.ProseMirror')
.trigger('keydown', {modKey: true, shiftKey: true, key: 'z' })

cy.get('.ProseMirror')
.should('contain', 'Mistake')
})

it.skip('the keyboard shortcut should apply the last undone change again', () => {
it('should apply the last undone change again with the keyboard shortcut (russian)', () => {
cy.get('.ProseMirror')
.trigger('keydown', {modKey: true, key: 'я' })

cy.get('.ProseMirror')
.trigger('keydown', { modKey: true, key: 'z' })
.should('not.contain', 'Mistake')
.trigger('keydown', { modKey: true, shiftKey: true, key: 'z' })

cy.get('.ProseMirror')
.trigger('keydown', {modKey: true, shiftKey: true, key: 'я' })

cy.get('.ProseMirror')
.should('contain', 'Mistake')
})

it('should apply the last undone change again', () => {
cy.get('.ProseMirror')
.should('contain', 'Mistake')

cy.get('button:first')
.click()

cy.get('.ProseMirror')
.should('not.contain', 'Mistake')

cy.get('button:nth-child(2)')
.click()

cy.get('.ProseMirror')
.should('contain', 'Mistake')
})
})
2 changes: 2 additions & 0 deletions packages/extension-history/src/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ export const History = Extension.create<HistoryOptions>({
addKeyboardShortcuts() {
return {
'Mod-z': () => this.editor.commands.undo(),
'Mod-я': () => this.editor.commands.undo(),
'Mod-y': () => this.editor.commands.redo(),
'Shift-Mod-z': () => this.editor.commands.redo(),
'Shift-Mod-я': () => this.editor.commands.redo(),
}
},
})

0 comments on commit 23c6581

Please sign in to comment.