   #
   deleteSel: (selection) ->
     if not selection.isValid()
-      throw new Error "Invalid selection"
+      console.log selection
+      throw new Error "Invalid selection, got", selection
 
     left = selection.left
     right = selection.right

        @deleteSel selection

      else if delta.insert?
        @insert position, delta.insert
        position += delta.insert.length

      else
        throw new Error "Unknown operation"

      if delta.attributes?
        for attr in delta.attributes
          @setAttr(selection.clone().style = attr)

  # Remove a selection from selection list
  #

# @param [Rte] rte an rte instance
relativeFromAbsolute = (position, rte)->
    index = 0
    while position > 0
      if index >= rte._rte.words.length
        position = 0
        break
      if rte._rte.words[index].word.length > position
        break
      else
        position -= rte._rte.words[index].word.length
        index += 1

    return {word: index, pos: position}

# Function that translates an index from start (absolute position) into a
