From 1ff58aea21c0bd5fb8b2d58c55db902d251de830 Mon Sep 17 00:00:00 2001 From: Nick Perez Date: Tue, 14 May 2024 14:42:57 +0200 Subject: [PATCH] test: get tests running on macOS again by leveraging built-in platform detection (#5144) --- demos/src/Marks/Strike/React/index.spec.js | 6 +++--- demos/src/Marks/Strike/Vue/index.spec.js | 6 +++--- packages/extension-strike/src/strike.ts | 11 ++--------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/demos/src/Marks/Strike/React/index.spec.js b/demos/src/Marks/Strike/React/index.spec.js index 44c8169a2..ad96ce177 100644 --- a/demos/src/Marks/Strike/React/index.spec.js +++ b/demos/src/Marks/Strike/React/index.spec.js @@ -58,15 +58,15 @@ context('/src/Marks/Strike/React/', () => { it('should strike the selected text when the keyboard shortcut is pressed', () => { cy.get('.tiptap') - .trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 's' }) .find('s') .should('contain', 'Example Text') }) it('should toggle the selected text striked when the keyboard shortcut is pressed', () => { cy.get('.tiptap') - .trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' }) - .trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 's' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 's' }) .find('s') .should('not.exist') }) diff --git a/demos/src/Marks/Strike/Vue/index.spec.js b/demos/src/Marks/Strike/Vue/index.spec.js index 522c5a6f6..09b36dd69 100644 --- a/demos/src/Marks/Strike/Vue/index.spec.js +++ b/demos/src/Marks/Strike/Vue/index.spec.js @@ -64,15 +64,15 @@ context('/src/Marks/Strike/Vue/', () => { it('should strike the selected text when the keyboard shortcut is pressed', () => { cy.get('.tiptap') - .trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 's' }) .find('s') .should('contain', 'Example Text') }) it('should toggle the selected text striked when the keyboard shortcut is pressed', () => { cy.get('.tiptap') - .trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' }) - .trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 's' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 's' }) .find('s') .should('not.exist') }) diff --git a/packages/extension-strike/src/strike.ts b/packages/extension-strike/src/strike.ts index 7d11ecdf3..e5cd0e5ea 100644 --- a/packages/extension-strike/src/strike.ts +++ b/packages/extension-strike/src/strike.ts @@ -1,5 +1,4 @@ import { - isMacOS, Mark, markInputRule, markPasteRule, @@ -98,15 +97,9 @@ export const Strike = Mark.create({ }, addKeyboardShortcuts() { - const shortcuts: Record boolean> = {} - - if (isMacOS()) { - shortcuts['Mod-Shift-s'] = () => this.editor.commands.toggleStrike() - } else { - shortcuts['Ctrl-Shift-s'] = () => this.editor.commands.toggleStrike() + return { + 'Mod-Shift-s': () => this.editor.commands.toggleStrike(), } - - return shortcuts }, addInputRules() {