mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-14 18:49:02 +08:00
add attrs param to toggleWrap function for nodeIsActive and WrapIn
This commit is contained in:
parent
92eb2c61cc
commit
ba5a3c29fa
@ -1,14 +1,14 @@
|
|||||||
import { wrapIn, lift } from 'prosemirror-commands'
|
import { wrapIn, lift } from 'prosemirror-commands'
|
||||||
import { nodeIsActive } from 'tiptap-utils'
|
import { nodeIsActive } from 'tiptap-utils'
|
||||||
|
|
||||||
export default function (type) {
|
export default function (type, attrs = {}) {
|
||||||
return (state, dispatch, view) => {
|
return (state, dispatch, view) => {
|
||||||
const isActive = nodeIsActive(state, type)
|
const isActive = nodeIsActive(state, type, attrs)
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
return lift(state, dispatch)
|
return lift(state, dispatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
return wrapIn(type)(state, dispatch, view)
|
return wrapIn(type, attrs)(state, dispatch, view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user