     text = Trix.Text.textForStringWithAttributes(string, attributes)
     @appendText(@text.appendText(text))
 
-  appendAttachmentForAttributes: (attributes) ->
-    if managedAttachment = @findManagedAttachmentByAttributes(attributes)
-      attachment = managedAttachment.attachment
+  appendAttachmentForAttributes: (attributes, textAttributes) ->
+    attachment = if @attachments and attributes.id
+      @attachments.get(attributes.id)
     else
-      attachment = new Trix.Attachment
+      delete attributes.id
+      new Trix.Attachment attributes
 
-    text = Trix.Text.textForAttachmentWithAttributes(attachment, attributes)
+    text = Trix.Text.textForAttachmentWithAttributes(attachment, textAttributes)
     @appendText(@text.appendText(text))
 
   appendText: (@text) ->
     index = @blocks.length - 1
     block = @blocks[index]
     @blocks[index] = block.copyWithText(@text)
-
-  findManagedAttachmentByAttributes: (attributes) ->
-    return unless @attachments
-    {identifier, url} = attributes
-    if identifier?
-      @attachments.findWhere({identifier})
-    else if url?
-      @attachments.findWhere({url})
 
   getDocument: ->
     new Trix.Document @blocks

    style = window.getComputedStyle(element)

    for attribute, config of Trix.attributes
      if config.parser
        if value = config.parser({element, style})
          attributes[attribute] = value
      else if config.tagName
        if element.tagName?.toLowerCase() is config.tagName
          attributes[attribute] = true
    attributes

  getMetadata = (element) ->

        @processElementNode(node)

  appendBlockForNode: (node) ->
    unless @currentBlockElement?.contains(node)
      if node.nodeType is Node.ELEMENT_NODE
        if window.getComputedStyle(node).display is "block"
          switch node.tagName.toLowerCase()
            when "blockquote"
              @appendBlockForAttributes(quote: true)
              @currentBlockElement = node
            when "pre"
              @appendBlockForAttributes(code: true)
              @currentBlockElement = node
            when "div"
              @appendBlockForAttributes()
              @currentBlockElement = node

    unless @blocks.length
      @appendBlockForAttributes({})
