change keyboard shortcut for code blocks, should fix tests
This commit is contained in:
@@ -53,20 +53,20 @@ context('/api/extensions/code-block', () => {
|
|||||||
|
|
||||||
it('the keyboard shortcut should make the selected line a code block', () => {
|
it('the keyboard shortcut should make the selected line a code block', () => {
|
||||||
cy.get('.ProseMirror')
|
cy.get('.ProseMirror')
|
||||||
.trigger('keydown', { shiftKey: true, ctrlKey: true, key: '\\' })
|
.trigger('keydown', { shiftKey: true, modKey: true, key: 'c' })
|
||||||
.find('pre')
|
.find('pre')
|
||||||
.should('contain', 'Example Text')
|
.should('contain', 'Example Text')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('the keyboard shortcut should toggle the code block', () => {
|
it('the keyboard shortcut should toggle the code block', () => {
|
||||||
cy.get('.ProseMirror')
|
cy.get('.ProseMirror')
|
||||||
.trigger('keydown', { shiftKey: true, ctrlKey: true, key: '\\' })
|
.trigger('keydown', { shiftKey: true, modKey: true, key: 'c' })
|
||||||
.find('pre')
|
.find('pre')
|
||||||
.should('contain', 'Example Text')
|
.should('contain', 'Example Text')
|
||||||
|
|
||||||
cy.get('.ProseMirror')
|
cy.get('.ProseMirror')
|
||||||
.type('{selectall}')
|
.type('{selectall}')
|
||||||
.trigger('keydown', { shiftKey: true, ctrlKey: true, key: '\\' })
|
.trigger('keydown', { shiftKey: true, modKey: true, key: 'c' })
|
||||||
|
|
||||||
cy.get('.ProseMirror pre')
|
cy.get('.ProseMirror pre')
|
||||||
.should('not.exist')
|
.should('not.exist')
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ yarn add @tiptap/extension-code-block
|
|||||||
| codeBlock | — | Wrap content in a code block. |
|
| codeBlock | — | Wrap content in a code block. |
|
||||||
|
|
||||||
## Keyboard shortcuts
|
## Keyboard shortcuts
|
||||||
* `Shift` `Control` `\`
|
* Windows/Linux: `Control` `Shift` `C`
|
||||||
|
* macOS: `Cmd` `Shift` `C`
|
||||||
|
|
||||||
## Source code
|
## Source code
|
||||||
[packages/extension-code-block/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-code-block/)
|
[packages/extension-code-block/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-code-block/)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export default new Node<CodeBlockOptions>()
|
|||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
.keys(({ editor }) => ({
|
.keys(({ editor }) => ({
|
||||||
'Shift-Control-\\': () => editor.codeBlock(),
|
'Mod-Shift-c': () => editor.codeBlock(),
|
||||||
}))
|
}))
|
||||||
.inputRules(({ type }) => [
|
.inputRules(({ type }) => [
|
||||||
textblockTypeInputRule(backtickInputRegex, type, ({ groups }: any) => groups),
|
textblockTypeInputRule(backtickInputRegex, type, ({ groups }: any) => groups),
|
||||||
|
|||||||
Reference in New Issue
Block a user