       attachment.delegate = this
       @delegate?.compositionDidAddAttachment?(attachment)
 
-  groupAdjacentAttachments: ->
-    position = @getPosition()
+  groupAdjacentAttachmentsAtPosition: (position) ->
     range = @document.getRangeOfPreviewableAttachmentsAtPosition(position)
     length = range[1] - range[0]
     if length > 1

      @insertAttachment(attachment)

  insertFiles: (files) ->
    headText = new Trix.Text
    tailText = new Trix.Text


    [position] = @getSelectedRange()
    @setDocument(@document.moveTextFromRangeToPosition(range, position))
    @setSelection(position)
    @groupAdjacentAttachmentsAtPosition(position)

  removeAttachment: (attachment) ->
    if range = @document.getRangeOfAttachment(attachment)
