improve commands

This commit is contained in:
Philipp Kühn
2020-11-02 14:46:18 +01:00
parent a97ffc41f4
commit 2bc02e50e0
3 changed files with 19 additions and 12 deletions

View File

@@ -22,13 +22,19 @@ const HardBreak = createNode({
addCommands() {
return {
hardBreak: (): Command => ({
tr, state, dispatch, view,
}) => {
return chainCommands(exitCode, () => {
dispatch(tr.replaceSelectionWith(this.type.create()).scrollIntoView())
return true
})(state, dispatch, view)
hardBreak: (): Command => ({ state, dispatch, view }) => {
return chainCommands(
exitCode,
(_, d) => {
if (typeof d !== 'function') {
return false
}
d(state.tr.replaceSelectionWith(this.type.create()).scrollIntoView())
return true
},
)(state, dispatch, view)
},
}
},