title: ProseMirror - Set caret position to end of selected node
body: <p>After running command({ href: url }), I would like to deselect current selection and set caret position to end of selected node. NOTE: I am using TipTap</p>
  <pre class="lang-js prettyprint-override"><code>setLinkUrl(command, url) {
  command({ href: url })
  this.hideLinkMenu()
  
  // Set cursor position after highlighted link
  var tag = document.getElementById(&quot;editor&quot;)
  
  var setpos = document.createRange()
  
  var set = window.getSelection()
  
  const state = this.editor.state
  
  let sel = state.selection
  // TODO: Check if sel range &gt; 0
  let resolvedPos = state.doc.resolve(sel.from)
  let node = resolvedPos.node(resolvedPos.depth)
  
  // This is where I want to set the caret position to the end of the currently selected node
  // Currently, I'm using hardcoded indices as proof of concept while the editor contains three paragraph nodes
  setpos.setStart(document.getElementById(&quot;editor&quot;).childNodes[0].childNodes[1], 1)
  setpos.setEnd(document.getElementById(&quot;editor&quot;).childNodes[0].childNodes[1], 1)
  
  setpos.collapse(true)
  
  set.removeAllRanges()
  
  set.addRange(setpos)
  
  tag.focus()
  </code></pre>