add code commands
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||||
strike
|
strike
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().code().run()" :class="{ 'is-active': editor.isActive('code') }">
|
<button @click="editor.chain().focus().toggleCode().run()" :class="{ 'is-active': editor.isActive('code') }">
|
||||||
code
|
code
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().removeMarks().run()">
|
<button @click="editor.chain().focus().removeMarks().run()">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||||
strike
|
strike
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().code().run()" :class="{ 'is-active': editor.isActive('code') }">
|
<button @click="editor.chain().focus().toggleCode().run()" :class="{ 'is-active': editor.isActive('code') }">
|
||||||
code
|
code
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().removeMarks().run()">
|
<button @click="editor.chain().focus().removeMarks().run()">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||||
strike
|
strike
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().code().run()" :class="{ 'is-active': editor.isActive('code') }">
|
<button @click="editor.chain().focus().toggleCode().run()" :class="{ 'is-active': editor.isActive('code') }">
|
||||||
code
|
code
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().removeMarks().run()">
|
<button @click="editor.chain().focus().removeMarks().run()">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="editor">
|
<div v-if="editor">
|
||||||
<button @click="editor.chain().focus().code().run()" :class="{ 'is-active': editor.isActive('code') }">
|
<button @click="editor.chain().focus().toggleCode().run()" :class="{ 'is-active': editor.isActive('code') }">
|
||||||
code
|
code
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -35,18 +35,30 @@ const Code = Mark.create({
|
|||||||
|
|
||||||
addCommands() {
|
addCommands() {
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* Set a code mark
|
||||||
|
*/
|
||||||
|
setCode: (): Command => ({ commands }) => {
|
||||||
|
return commands.addMark('code')
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Toggle inline code
|
* Toggle inline code
|
||||||
*/
|
*/
|
||||||
code: (): Command => ({ commands }) => {
|
toggleCode: (): Command => ({ commands }) => {
|
||||||
return commands.toggleMark('code')
|
return commands.toggleMark('code')
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Set a code mark
|
||||||
|
*/
|
||||||
|
unsetCode: (): Command => ({ commands }) => {
|
||||||
|
return commands.addMark('code')
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addKeyboardShortcuts() {
|
addKeyboardShortcuts() {
|
||||||
return {
|
return {
|
||||||
'Mod-`': () => this.editor.commands.code(),
|
'Mod-`': () => this.editor.commands.toggleCode(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user