Merge pull request #10 from ueberdosis/feature/add-paragraph-command
add paragraph command and keyboard shortcut
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user