 
     @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) =>

        block.copyWithText(text.resizeAttachmentToDimensions(attachment, dimensions))

  rangeFromLocationRange: (locationRange) ->
    leftPosition = @blockList.findPositionAtIndexAndOffset(locationRange[0].index, locationRange[0].position)
    rightPosition = @blockList.findPositionAtIndexAndOffset(locationRange[1].index, locationRange[1].position)
    [leftPosition, rightPosition]

  toJSON: ->

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

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

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

