From 23c6581c05e826265329b984a13f4b25a6c86b2a Mon Sep 17 00:00:00 2001 From: Markus Machatschek Date: Wed, 14 Jul 2021 17:29:28 +0200 Subject: [PATCH 1/2] Add russian undo/redo shortcuts and fix tests --- .../demos/Extensions/History/index.spec.js | 59 ++++++++++++++----- packages/extension-history/src/history.ts | 2 + 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/docs/src/demos/Extensions/History/index.spec.js b/docs/src/demos/Extensions/History/index.spec.js index e1ee5b9af2..cd4f43d6b1 100644 --- a/docs/src/demos/Extensions/History/index.spec.js +++ b/docs/src/demos/Extensions/History/index.spec.js @@ -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('

Mistake

') }) @@ -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') }) }) diff --git a/packages/extension-history/src/history.ts b/packages/extension-history/src/history.ts index dfaa962246..6739607ed8 100644 --- a/packages/extension-history/src/history.ts +++ b/packages/extension-history/src/history.ts @@ -49,8 +49,10 @@ export const History = Extension.create({ 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(), } }, }) From 780e0951921d7874219ca17eee436d9be6501044 Mon Sep 17 00:00:00 2001 From: Markus Machatschek Date: Wed, 14 Jul 2021 17:41:54 +0200 Subject: [PATCH 2/2] Readd skipped tests Fix lint issue --- .../Examples/MarkdownShortcuts/Vue/index.spec.js | 6 +++--- docs/src/demos/Extensions/History/index.spec.js | 13 ++++++------- docs/src/demos/Nodes/HardBreak/index.spec.js | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/docs/src/demos/Examples/MarkdownShortcuts/Vue/index.spec.js b/docs/src/demos/Examples/MarkdownShortcuts/Vue/index.spec.js index 7c68301171..aaf19b7f71 100644 --- a/docs/src/demos/Examples/MarkdownShortcuts/Vue/index.spec.js +++ b/docs/src/demos/Examples/MarkdownShortcuts/Vue/index.spec.js @@ -58,7 +58,7 @@ context('/demos/Examples/MarkdownShortcuts/Vue', () => { .should('contain', '$foobar') }) - it.skip('should create a code block without language', () => { + it('should create a code block without language', () => { cy.get('.ProseMirror') .type('``` {enter}const foo = bar{enter}```') .find('pre') @@ -86,14 +86,14 @@ context('/demos/Examples/MarkdownShortcuts/Vue', () => { .should('contain', 'foobar') }) - it.skip('should create a ordered list', () => { + it('should create a ordered list', () => { cy.get('.ProseMirror') .type('1. foobar') .find('ol') .should('contain', 'foobar') }) - it.skip('should create a blockquote', () => { + it('should create a blockquote', () => { cy.get('.ProseMirror') .type('> foobar') .find('blockquote') diff --git a/docs/src/demos/Extensions/History/index.spec.js b/docs/src/demos/Extensions/History/index.spec.js index cd4f43d6b1..6f8e940b0b 100644 --- a/docs/src/demos/Extensions/History/index.spec.js +++ b/docs/src/demos/Extensions/History/index.spec.js @@ -19,8 +19,7 @@ context('/demos/Extensions/History', () => { it('should make the last change undone with the keyboard shortcut', () => { cy.get('.ProseMirror') - .trigger('keydown', {modKey: true, key: 'z' }) - + .trigger('keydown', { modKey: true, key: 'z' }) cy.get('.ProseMirror') .should('not.contain', 'Mistake') @@ -31,7 +30,7 @@ context('/demos/Extensions/History', () => { .should('contain', 'Mistake') cy.get('.ProseMirror') - .trigger('keydown', {modKey: true, key: 'я' }) + .trigger('keydown', { modKey: true, key: 'я' }) cy.get('.ProseMirror') .should('not.contain', 'Mistake') @@ -39,13 +38,13 @@ context('/demos/Extensions/History', () => { it('should apply the last undone change again with the keyboard shortcut', () => { cy.get('.ProseMirror') - .trigger('keydown', {modKey: true, key: 'z' }) + .trigger('keydown', { modKey: true, key: 'z' }) cy.get('.ProseMirror') .should('not.contain', 'Mistake') cy.get('.ProseMirror') - .trigger('keydown', {modKey: true, shiftKey: true, key: 'z' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 'z' }) cy.get('.ProseMirror') .should('contain', 'Mistake') @@ -53,13 +52,13 @@ context('/demos/Extensions/History', () => { it('should apply the last undone change again with the keyboard shortcut (russian)', () => { cy.get('.ProseMirror') - .trigger('keydown', {modKey: true, key: 'я' }) + .trigger('keydown', { modKey: true, key: 'я' }) cy.get('.ProseMirror') .should('not.contain', 'Mistake') cy.get('.ProseMirror') - .trigger('keydown', {modKey: true, shiftKey: true, key: 'я' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 'я' }) cy.get('.ProseMirror') .should('contain', 'Mistake') diff --git a/docs/src/demos/Nodes/HardBreak/index.spec.js b/docs/src/demos/Nodes/HardBreak/index.spec.js index 0f22ad0707..8c0097d18d 100644 --- a/docs/src/demos/Nodes/HardBreak/index.spec.js +++ b/docs/src/demos/Nodes/HardBreak/index.spec.js @@ -34,7 +34,7 @@ context('/demos/Nodes/HardBreak', () => { .should('exist') }) - it.skip('the default keyboard shortcut should add a line break', () => { + it('the default keyboard shortcut should add a line break', () => { cy.get('.ProseMirror br') .should('not.exist')