move commands again

This commit is contained in:
Philipp Kühn
2020-11-04 22:38:52 +01:00
parent ca0c3188f3
commit 6f3db0970f
59 changed files with 761 additions and 1066 deletions

View File

@@ -0,0 +1,16 @@
import { wrapIn, lift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model'
import { Command } from '../Editor'
import nodeIsActive from '../utils/nodeIsActive'
import getNodeType from '../utils/getNodeType'
export default (typeOrName: string | NodeType, attrs = {}): Command => ({ state, dispatch }) => {
const type = getNodeType(typeOrName, state.schema)
const isActive = nodeIsActive(state, type, attrs)
if (isActive) {
return lift(state, dispatch)
}
return wrapIn(type, attrs)(state, dispatch)
}