 
     @blockList = blockList
 
-  replaceTextAtLocationRange: edit (text, range) ->
-    @removeTextAtLocationRange(range)
-    @insertTextAtLocation(text, range[0])
+  replaceTextAtLocationRange: edit (text, locationRange) ->
+    @removeTextAtLocationRange(locationRange)
+    @insertTextAtLocationRange(text, locationRange)
 
   addAttributeAtLocationRange: edit (attribute, value, locationRange) ->
     @eachBlockInLocationRange locationRange, (block, range, index) =>

    @blockList.replaceBlockList(document.blockList)
    @delegate?.didEditDocument?(this)

  getCommonAttributesAtLocationRange: (range) ->
    if range.isCollapsed()
      @getCommonAttributesAtLocation(range.start)
    else
      textAttributes = []
      blockAttributes = []

      @eachBlockAtLocationRange range, (block, textRange) ->
        textAttributes.push(block.text.getCommonAttributesAtRange(textRange))
        blockAttributes.push(block.getAttributes())



        callback(block, textRange, index)

  insertTextAtLocationRange: edit (text, locationRange) ->
    @blockList = @blockList.editObjectAtIndex locationRange.index, (block) ->
      block.copyWithText(block.text.insertTextAtPosition(text, locationRange.position))

  removeTextAtLocationRange: edit (locationRange) ->
    range = @rangeFromLocationRange(locationRange)
    blockList = @blockList.removeObjectsInRange(range)

    leftIndex = locationRange.index
    rightIndex = leftIndex + 1
    leftBlock = blockList.getObjectAtIndex(leftIndex)
    rightBlock = blockList.getObjectAtIndex(rightIndex)
