add highlight commands
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="editor">
|
||||
<button
|
||||
@click="editor.chain().focus().highlight().run()"
|
||||
@click="editor.chain().focus().toggleHighlight().run()"
|
||||
:class="{ 'is-active': editor.isActive('highlight') }"
|
||||
>
|
||||
highlight (any)
|
||||
|
||||
@@ -48,7 +48,7 @@ const Code = Mark.create({
|
||||
return commands.toggleMark('code')
|
||||
},
|
||||
/**
|
||||
* Set a code mark
|
||||
* Unset a code mark
|
||||
*/
|
||||
unsetCode: (): Command => ({ commands }) => {
|
||||
return commands.addMark('code')
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ const Italic = Mark.create({
|
||||
addCommands() {
|
||||
return {
|
||||
/**
|
||||
* Set a italic mark
|
||||
* Set an italic mark
|
||||
*/
|
||||
setItalic: (): Command => ({ commands }) => {
|
||||
return commands.addMark('italic')
|
||||
@@ -57,7 +57,7 @@ const Italic = Mark.create({
|
||||
return commands.toggleMark('italic')
|
||||
},
|
||||
/**
|
||||
* Set a italic mark
|
||||
* Unset an italic mark
|
||||
*/
|
||||
unsetItalic: (): Command => ({ commands }) => {
|
||||
return commands.addMark('italic')
|
||||
|
||||
@@ -57,7 +57,7 @@ const Strike = Mark.create({
|
||||
return commands.toggleMark('strike')
|
||||
},
|
||||
/**
|
||||
* Set a strike mark
|
||||
* Unset a strike mark
|
||||
*/
|
||||
unsetStrike: (): Command => ({ commands }) => {
|
||||
return commands.addMark('strike')
|
||||
|
||||
@@ -31,19 +31,19 @@ const Underline = Mark.create({
|
||||
addCommands() {
|
||||
return {
|
||||
/**
|
||||
* Set a underline mark
|
||||
* Set an underline mark
|
||||
*/
|
||||
setUnderline: (): Command => ({ commands }) => {
|
||||
return commands.addMark('underline')
|
||||
},
|
||||
/**
|
||||
* Toggle a underline mark
|
||||
* Toggle an underline mark
|
||||
*/
|
||||
toggleUnderline: (): Command => ({ commands }) => {
|
||||
return commands.toggleMark('underline')
|
||||
},
|
||||
/**
|
||||
* Set a underline mark
|
||||
* Unset an underline mark
|
||||
*/
|
||||
unsetUnderline: (): Command => ({ commands }) => {
|
||||
return commands.addMark('underline')
|
||||
|
||||
Reference in New Issue
Block a user