add code commands

This commit is contained in:
Philipp Kühn
2020-11-17 21:53:39 +01:00
parent 8195cbd91d
commit f9025775ca
5 changed files with 18 additions and 6 deletions

View File

@@ -35,18 +35,30 @@ const Code = Mark.create({
addCommands() {
return {
/**
* Set a code mark
*/
setCode: (): Command => ({ commands }) => {
return commands.addMark('code')
},
/**
* Toggle inline code
*/
code: (): Command => ({ commands }) => {
toggleCode: (): Command => ({ commands }) => {
return commands.toggleMark('code')
},
/**
* Set a code mark
*/
unsetCode: (): Command => ({ commands }) => {
return commands.addMark('code')
},
}
},
addKeyboardShortcuts() {
return {
'Mod-`': () => this.editor.commands.code(),
'Mod-`': () => this.editor.commands.toggleCode(),
}
},