Toggle the node applied

Hii, Pretty new to prosemirror and have been trying out different stuff with it. Currently, playing with applying nodes using wrapIn. Is there a toggleMark alternative for this to go back to it’s initial state?

The lift command may be what you’re looking for? Though that just unwraps something, and doesn’t re-wrap it automatically if it isn’t wrapped.

Thanks a bunch @marijn, it worked perfectly somehow :laughing: ! I did something like this and hopefully doesn’t give rise to any bugs.

 //Find out the attributes added to the selection
const node = state.selection
const hasAttribute = (node.$from.path.some(item => item.type==schema.nodes.textAlign)
//Remove the attribute if it is present and reapply the new one
hasAttribute && lift(state,dispatch)
wrapIn(schema.nodes.textAlign, { align})(view.state, dispatch);  

Lemme know if something seems off :grinning_face_with_smiling_eyes: