         position += 1
 
     newDocument = new Trix.Document [block.removeLastAttribute().copyWithoutText()]
-    if "header" in block.attributes
+    if @hasCurrentAttribute("header")
       document = document.removeTextAtRange([position - 1, position])
       @setDocument(document.insertDocumentAtRange(newDocument, [position - 1, position]))
     else

          @removeLastBlockAttribute()
        else if block.text.getStringAtRange([endLocation.offset - 1, endLocation.offset]) is "\n"
          @breakFormattedBlock()
        else if "header" in block.attributes and block.text.getStringAtRange([endLocation.offset, endLocation.offset + 1]) is "\n"
          @breakFormattedBlock()
        else
          @insertString("\n")

  canAddBlockAttribute: (attributeName) ->
    return true unless @getBlock()?.hasAttributes()
    if attributeName in ["quote", "code", "bullet", "number"]
      if @hasCurrentAttribute("header") and attributeName not in @getBlock()?.getAttributes()
        return false
      return true
    return true
