Files
tiptap/packages/tiptap-commands/src/commands/toggleWrap.js
2018-11-08 22:03:10 +01:00

15 lines
331 B
JavaScript

import { wrapIn, lift } from 'prosemirror-commands'
import { nodeIsActive } from 'tiptap-utils'
export default function (type) {
return (state, dispatch, view) => {
const isActive = nodeIsActive(state, type)
if (isActive) {
return lift(state, dispatch)
}
return wrapIn(type)(state, dispatch, view)
}
}