add italic commands
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
||||||
bold
|
bold
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
||||||
italic
|
italic
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().strike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
<button @click="editor.chain().focus().strike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
||||||
bold
|
bold
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
||||||
italic
|
italic
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().strike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
<button @click="editor.chain().focus().strike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
||||||
bold
|
bold
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
||||||
italic
|
italic
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().strike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
<button @click="editor.chain().focus().strike().run()" :class="{ 'is-active': editor.isActive('strike') }">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
||||||
Bold
|
Bold
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
||||||
Italic
|
Italic
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
||||||
bold
|
bold
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
||||||
italic
|
italic
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().heading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
|
<button @click="editor.chain().focus().heading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
|
||||||
bold
|
bold
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
||||||
italic
|
italic
|
||||||
</button>
|
</button>
|
||||||
<button @click="editor.chain().focus().heading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
|
<button @click="editor.chain().focus().heading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="editor">
|
<div v-if="editor">
|
||||||
<button @click="editor.chain().focus().italic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
<button @click="editor.chain().focus().toggleItalic().run()" :class="{ 'is-active': editor.isActive('italic') }">
|
||||||
italic
|
italic
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ editor
|
|||||||
.can()
|
.can()
|
||||||
.chain()
|
.chain()
|
||||||
.toggleBold()
|
.toggleBold()
|
||||||
.italic()
|
.toggleItalic()
|
||||||
.run()
|
.run()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -44,18 +44,30 @@ const Italic = Mark.create({
|
|||||||
|
|
||||||
addCommands() {
|
addCommands() {
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* Set a italic mark
|
||||||
|
*/
|
||||||
|
setItalic: (): Command => ({ commands }) => {
|
||||||
|
return commands.addMark('italic')
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Toggle an italic mark
|
* Toggle an italic mark
|
||||||
*/
|
*/
|
||||||
italic: (): Command => ({ commands }) => {
|
toggleItalic: (): Command => ({ commands }) => {
|
||||||
return commands.toggleMark('italic')
|
return commands.toggleMark('italic')
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Set a italic mark
|
||||||
|
*/
|
||||||
|
unsetItalic: (): Command => ({ commands }) => {
|
||||||
|
return commands.addMark('italic')
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addKeyboardShortcuts() {
|
addKeyboardShortcuts() {
|
||||||
return {
|
return {
|
||||||
'Mod-i': () => this.editor.commands.italic(),
|
'Mod-i': () => this.editor.commands.toggleItalic(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user