Skip to content

Commit

Permalink
test: get tests running on macOS again by leveraging built-in platfor…
Browse files Browse the repository at this point in the history
…m detection (#5144)
  • Loading branch information
nperez0111 committed May 14, 2024
1 parent cdc147a commit 1ff58ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
6 changes: 3 additions & 3 deletions demos/src/Marks/Strike/React/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down
6 changes: 3 additions & 3 deletions demos/src/Marks/Strike/Vue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down
11 changes: 2 additions & 9 deletions packages/extension-strike/src/strike.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
isMacOS,
Mark,
markInputRule,
markPasteRule,
Expand Down Expand Up @@ -98,15 +97,9 @@ export const Strike = Mark.create<StrikeOptions>({
},

addKeyboardShortcuts() {
const shortcuts: Record<string, () => 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() {
Expand Down

0 comments on commit 1ff58ae

Please sign in to comment.