 
   # applyAttribute: (TandemRange range, Object attribute) ->
   # applyAttribute: (Number startIndex, Number length, attribute) ->
-  applyAttribute: (range, attribute) ->
-    #if !_.isNumber(startIndex)
-    #  selection = this.getSelection()
-    #  startIndex = selection.getStartIndex()
-    #  length = selection.getEndIndex() - startIndex
-
+  applyAttribute: (startIndex, length, attribute) ->
+    @ignoreDomChanges = true
+    range = if _.isNumber(startIndex) then new Tandem.Range(this, startIndex, startIndex + length) else startIndex
     this.preserveSelection(range, 0, =>
       range.splitEnds()
       _.each(range.groupNodesByLine(), (elems) =>

    # 6. Restore selection

  deleteAt: (startIndex, length) ->  
    this.preserveSelection(range, 0 - length, ->

    )  
    # 1. Save selection
    # 2. Find nodes in range
    # 3. For first and last node, delete text

    return iframe

  insertAt: (startIndex, text, attributes = {}) ->
    @ignoreDomChanges = true
    range = if _.isNumber(startIndex) then new Tandem.Range(this, startIndex, startIndex) else startIndex
    this.preserveSelection(range, text.length, ->

    )
    @ignoreDomChanges = false
    # 1. Save selection
    # 2. Split text into lines
    # 3. Find node where it starts
