fix more commands

This commit is contained in:
Philipp Kühn
2020-09-22 09:08:08 +02:00
parent 655d721914
commit dcac67c61a
25 changed files with 167 additions and 182 deletions

View File

@@ -1,14 +1,16 @@
import { Node } from '@tiptap/core'
import { Command, Node } from '@tiptap/core'
import { textblockTypeInputRule } from 'prosemirror-inputrules'
export type CodeBlockCommand = () => Command
declare module '@tiptap/core/src/Editor' {
interface Editor {
codeBlock(): Editor,
codeBlock: CodeBlockCommand,
}
}
export default new Node()
.name('codeBlock')
.name('code_block')
.schema(() => ({
content: 'text*',
marks: '',
@@ -21,12 +23,11 @@ export default new Node()
],
toDOM: () => ['pre', ['code', 0]],
}))
// .commands(({ editor, name }) => ({
// [name]: next => attrs => {
// editor.toggleNode(name, 'paragraph', attrs)
// next()
// },
// }))
.commands(({ name }) => ({
codeBlock: attrs => ({ commands }) => {
return commands.toggleNode(name, 'paragraph', attrs)
},
}))
.keys(({ editor }) => ({
'Shift-Ctrl-\\': () => editor.codeBlock()
}))