 
 
   removeLink: (link) ->
+    @endNodeEdit()
     @undoRedoManager.createAndExecuteCommand 'removeLink',
       execute: => @_removeLink link
       undo: => @_addLink link

    @selectionManager.selectForTitleEditing(@nodeKeys[nodeKey])

  selectNode: (nodeKey) ->
    @selectionManager.selectForInspection(@nodeKeys[nodeKey])





  addNode: (node) ->
    @endNodeEdit()
    @undoRedoManager.createAndExecuteCommand 'addNode',
      execute: => @_addNode node
      undo: => @_removeNode node

  removeNode: (nodeKey) ->
    @endNodeEdit()
    node = @nodeKeys[nodeKey]

    # create a copy of the list of links
