         tailText = tailText.appendText(attachmentText)
 
     @insertText(headText.appendText(tailText))
-    @groupAdjacentAttachments()
+    @groupAdjacentAttachmentsAtPosition(position)
 
   insertAttachment: (attachment) ->
+    position = @getPosition()
     text = Trix.Text.textForAttachmentWithAttributes(attachment, @currentAttributes)
     @insertText(text)
-    @groupAdjacentAttachments()
+    @groupAdjacentAttachmentsAtPosition(position)
 
   deleteInDirection: (direction) ->
     locationRange = @getLocationRange()

      @insertAttachment(attachment)

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


      attachment.delegate = this
      @delegate?.compositionDidAddAttachment?(attachment)

  groupAdjacentAttachmentsAtPosition: (position) ->
    range = @document.getRangeOfPreviewableAttachmentsAtPosition(position)
    length = range[1] - range[0]
    if length > 1
