mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 14:13:21 +08:00
add underline commands
This commit is contained in:
parent
3ea2711aef
commit
8195cbd91d
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="editor">
|
<div v-if="editor">
|
||||||
<button @click="editor.chain().focus().underline().run()" :class="{ 'is-active': editor.isActive('underline') }">
|
<button @click="editor.chain().focus().toggleUnderline().run()" :class="{ 'is-active': editor.isActive('underline') }">
|
||||||
underline
|
underline
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@ -30,15 +30,30 @@ const Underline = Mark.create({
|
|||||||
|
|
||||||
addCommands() {
|
addCommands() {
|
||||||
return {
|
return {
|
||||||
underline: (): Command => ({ commands }) => {
|
/**
|
||||||
|
* Set a underline mark
|
||||||
|
*/
|
||||||
|
setUnderline: (): Command => ({ commands }) => {
|
||||||
|
return commands.addMark('underline')
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Toggle a underline mark
|
||||||
|
*/
|
||||||
|
toggleUnderline: (): Command => ({ commands }) => {
|
||||||
return commands.toggleMark('underline')
|
return commands.toggleMark('underline')
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Set a underline mark
|
||||||
|
*/
|
||||||
|
unsetUnderline: (): Command => ({ commands }) => {
|
||||||
|
return commands.addMark('underline')
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addKeyboardShortcuts() {
|
addKeyboardShortcuts() {
|
||||||
return {
|
return {
|
||||||
'Mod-u': () => this.editor.commands.underline(),
|
'Mod-u': () => this.editor.commands.toggleUnderline(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user