 
   # Private
 
-  getText: ->
-    @text.copy()
+  getDocument: ->
+    # TODO
+    @document.copy()
 
   getInternalSelectedRange: ->
     @selectionDelegate?.getSelectedRangeOfComposition?(this)

  # Snapshots

  createSnapshot: ->
    text: @getText()
    selectedRange: @getInternalSelectedRange()

  restoreSnapshot: ({text, selectedRange}) ->
    @text.replaceText(text)
    @requestSelectedRange(selectedRange)

  # Document delegate

    if @getSelectedRange()
      @deleteBackward()
    else
      location = @getLocation()
      text = @getTextAtIndex(location.index)
      # TODO: delete across blocks
      stringBeforePosition = text.getStringAtRange([0, location.position])
      # TODO: \b is not unicode compatible
      positionBeforeLastWord = stringBeforePosition.search(/(\b\w+)\W*$/)
      @deleteFromCurrentPosition(positionBeforeLastWord - position)

  moveTextFromRange: (range) ->
    location = @getLocation()
    # TODO: move selection spanning blocks
    text = @getTextAtIndex(index)
    text.moveTextFromRangeToPosition(range, position)
    @requestPosition(position)

  getTextFromSelection: ->
    # TODO: get text(s) spanning blocks
    if locationRange = @getSelectedRange()
      if locationRange[0].index is locationRange[1].index
        text = @getTextAtIndex(locationRange[0].index)
        text.getTextAtRange([locationRange[0].position, locationRange[1].position])

  # Attachment owner protocol

