Merge pull request #727 from ValJed/fix/passing-attributes-to-wrappers

Allow attributes for wrappers
This commit is contained in:
Philipp Kühn 2020-07-08 08:59:57 +02:00 committed by GitHub
commit 8e17738895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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