Merge pull request #10 from ueberdosis/feature/add-paragraph-command

add paragraph command and keyboard shortcut
This commit is contained in:
Philipp Kühn
2020-09-24 20:45:12 +02:00
committed by GitHub
4 changed files with 27 additions and 5 deletions

View File

@@ -1,6 +1,14 @@
import { Node } from '@tiptap/core'
import { Command, Node } from '@tiptap/core'
// import ParagraphComponent from './paragraph.vue'
export type ParagraphCommand = () => Command
declare module '@tiptap/core/src/Editor' {
interface Commands {
paragraph: ParagraphCommand,
}
}
export default new Node()
.name('paragraph')
.schema(() => ({
@@ -10,4 +18,12 @@ export default new Node()
toDOM: () => ['p', 0],
// toVue: ParagraphComponent,
}))
.commands(({ name }) => ({
[name]: () => ({ commands }) => {
return commands.toggleNode(name, 'paragraph')
},
}))
.keys(({ editor }) => ({
'Mod-Alt-0': () => editor.paragraph(),
}))
.create()