change keyboard shortcut for code blocks, should fix tests

This commit is contained in:
Hans Pagel
2020-10-12 20:28:04 +02:00
parent a237db377b
commit 3e3f4444e4
3 changed files with 6 additions and 5 deletions

View File

@@ -53,20 +53,20 @@ context('/api/extensions/code-block', () => {
it('the keyboard shortcut should make the selected line a code block', () => {
cy.get('.ProseMirror')
.trigger('keydown', { shiftKey: true, ctrlKey: true, key: '\\' })
.trigger('keydown', { shiftKey: true, modKey: true, key: 'c' })
.find('pre')
.should('contain', 'Example Text')
})
it('the keyboard shortcut should toggle the code block', () => {
cy.get('.ProseMirror')
.trigger('keydown', { shiftKey: true, ctrlKey: true, key: '\\' })
.trigger('keydown', { shiftKey: true, modKey: true, key: 'c' })
.find('pre')
.should('contain', 'Example Text')
cy.get('.ProseMirror')
.type('{selectall}')
.trigger('keydown', { shiftKey: true, ctrlKey: true, key: '\\' })
.trigger('keydown', { shiftKey: true, modKey: true, key: 'c' })
cy.get('.ProseMirror pre')
.should('not.exist')

View File

@@ -28,7 +28,8 @@ yarn add @tiptap/extension-code-block
| codeBlock | — | Wrap content in a code block. |
## Keyboard shortcuts
* `Shift` `Control` `\`
* Windows/Linux: `Control` `Shift` `C`
* macOS: `Cmd` `Shift` `C`
## Source code
[packages/extension-code-block/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-code-block/)

View File

@@ -60,7 +60,7 @@ export default new Node<CodeBlockOptions>()
},
}))
.keys(({ editor }) => ({
'Shift-Control-\\': () => editor.codeBlock(),
'Mod-Shift-c': () => editor.codeBlock(),
}))
.inputRules(({ type }) => [
textblockTypeInputRule(backtickInputRegex, type, ({ groups }: any) => groups),