Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(strikethrough): update strikethrough shortcut #4288

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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', { modKey: true, shiftKey: true, key: 'x' })
.trigger('keydown', { ctrlKey: 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', { modKey: true, shiftKey: true, key: 'x' })
.trigger('keydown', { modKey: true, shiftKey: true, key: 'x' })
.trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' })
.trigger('keydown', { ctrlKey: 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', { modKey: true, shiftKey: true, key: 'x' })
.trigger('keydown', { ctrlKey: 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', { modKey: true, shiftKey: true, key: 'x' })
.trigger('keydown', { modKey: true, shiftKey: true, key: 'x' })
.trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' })
.trigger('keydown', { ctrlKey: true, shiftKey: true, key: 's' })
.find('s')
.should('not.exist')
})
Expand Down
11 changes: 9 additions & 2 deletions packages/extension-strike/src/strike.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
isMacOS,
Mark,
markInputRule,
markPasteRule,
Expand Down Expand Up @@ -78,9 +79,15 @@ export const Strike = Mark.create<StrikeOptions>({
},

addKeyboardShortcuts() {
return {
'Mod-Shift-x': () => this.editor.commands.toggleStrike(),
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 shortcuts
},

addInputRules() {
Expand Down