add highlight commands

This commit is contained in:
Philipp Kühn
2020-11-17 21:59:04 +01:00
parent f9025775ca
commit 34a25c7ea0
6 changed files with 22 additions and 10 deletions

View File

@@ -58,18 +58,30 @@ const Highlight = Mark.create({
addCommands() {
return {
/**
* Set a highlight mark
*/
setHighlight: (attributes?: { color: string }): Command => ({ commands }) => {
return commands.addMark('highlight', attributes)
},
/**
* Toggle a highlight mark
*/
highlight: (attributes?: { color: string }): Command => ({ commands }) => {
toggleHighlight: (attributes?: { color: string }): Command => ({ commands }) => {
return commands.toggleMark('highlight', attributes)
},
/**
* Set a highlight mark
*/
unsetHighlight: (): Command => ({ commands }) => {
return commands.removeMark('highlight')
},
}
},
addKeyboardShortcuts() {
return {
'Mod-e': () => this.editor.commands.highlight(),
'Mod-e': () => this.editor.commands.toggleHighlight(),
}
},