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,8 +1,10 @@
import { Node, nodeInputRule } from '@tiptap/core'
import { Command, Node, nodeInputRule } from '@tiptap/core'
export type HorizontalRuleCommand = () => Command
declare module '@tiptap/core/src/Editor' {
interface Editor {
horizontalRule(): Editor,
horizontalRule: HorizontalRuleCommand,
}
}
@@ -13,15 +15,13 @@ export default new Node()
parseDOM: [{ tag: 'hr' }],
toDOM: () => ['hr'],
}))
// .commands(({ editor, type }) => ({
// horizontalRule: next => () => {
// const { state, view } = editor
// const { dispatch } = view
.commands(({ type }) => ({
horizontalRule: () => ({ tr }) => {
tr.replaceSelectionWith(type.create())
// dispatch(state.tr.replaceSelectionWith(type.create()))
// next()
// },
// }))
return true
},
}))
.inputRules(({ type }) => [
nodeInputRule(/^(?:---|___\s|\*\*\*\s)$/, type),
])