In the function linkItem
when adding the following:
toggleMark(markType, attrs)(view.state, view.dispatch)
console.log(view.state.selection.from)
view.focus()
console.log(view.state.selection.from)
and after inserting a link, the value of view.state.selection.from
jumps from the current value to zero. So after view.focus() the selection is wrong.