refactoring

This commit is contained in:
Philipp Kühn
2021-05-05 18:51:42 +02:00
parent 71740687f4
commit 55d430ef8f
2 changed files with 4 additions and 12 deletions

View File

@@ -1,5 +1,4 @@
import { Command, Node, mergeAttributes } from '@tiptap/core'
import { exitCode } from 'prosemirror-commands'
export interface HardBreakOptions {
HTMLAttributes: Record<string, any>,
@@ -41,16 +40,10 @@ export const HardBreak = Node.create<HardBreakOptions>({
addCommands() {
return {
setHardBreak: () => ({ commands, state, dispatch }) => {
setHardBreak: () => ({ commands }) => {
return commands.first([
() => exitCode(state, dispatch),
() => {
if (dispatch) {
state.tr.replaceSelectionWith(this.type.create()).scrollIntoView()
}
return true
},
() => commands.exitCode(),
() => commands.insertContent({ type: this.name }),
])
},
}