 
   replaceHTML: (html) ->
     document = Trix.Document.fromHTML(html).copyUsingObjectsFromDocument(@document)
-    unless document.isEqualTo(@document)
-      @preserveSelection =>
-        @document.replaceDocument(document)
+    @preserveSelection =>
+      @setDocument(document)
 
   insertFile: (file) ->
     if @delegate?.compositionShouldAcceptFile(file)


class Trix.Composition extends Trix.BasicObject
  constructor: (@document = new Trix.Document) ->
    @document.delegate = this
    @currentAttributes = {}

  # Snapshots


        text = Trix.Text.textForStringWithAttributes(value, href: value)
        @insertText(text)
    else
      @setDocument(@document.addAttributeAtRange(attributeName, value, selectedRange))

  setBlockAttribute: (attributeName, value) ->
    return unless selectedRange = @getSelectedRange()
    @setDocument(@document.applyBlockAttributeAtRange(attributeName, value, selectedRange))
    @setSelectedRange(selectedRange)

  removeCurrentAttribute: (attributeName) ->
