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') }">
|
||||
strike
|
||||
</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
|
||||
</button>
|
||||
<button @click="editor.chain().focus().removeMarks().run()">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||
strike
|
||||
</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
|
||||
</button>
|
||||
<button @click="editor.chain().focus().removeMarks().run()">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<button @click="editor.chain().focus().toggleStrike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||
strike
|
||||
</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
|
||||
</button>
|
||||
<button @click="editor.chain().focus().removeMarks().run()">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<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
|
||||
</button>
|
||||
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user