 
   changeLink: (link, changes={}) ->
     if changes.deleted
-      @removeSelectedLink()
+      @removeSelectedLinks()
     else if link
       originalData =
         title: link.title


    # create a copy of the list of links
    links = node.links.slice()

    @undoRedoManager.createAndExecuteCommand 'removeNode',
      execute: =>
        node.transferLink?.relation = node.transferLink.defaultRelation()
        @_removeLink(link) for link in links
        @_removeNode node
      undo: =>
        node.transferLink?.relation = transferRelation
        @_addNode node
        @_addLink(link) for link in links

  _addNode: (node) ->

    @setFilename 'New Model'
    @undoRedoManager.clearHistory()

  removeSelectedNodes: ->
    selectedNodeKeys = (node.key for node in @selectedNodes())
    for nodeKey in selectedNodeKeys
      @removeNode nodeKey

  removeSelectedLinks: ->
    for selectedLink in @selectedLinks()
      @removeLink selectedLink

  deleteSelected: ->
    log.info "Deleting selected items"
    # deleting multiple links/nodes should be undoable as a single action
    @undoRedoManager.startCommandBatch()
    @removeSelectedLinks()
    @removeSelectedNodes()
    @undoRedoManager.endCommandBatch()
    @selectionManager.clearSelection()

  removeLinksForNode: (node) ->
