 
   # Location range and selection
 
+  getRange: ->
+    locationRange = @getLocationRange()
+    @document.rangeFromLocationRange(locationRange)
+
+  setRange: (range) ->
+    locationRange = @document.locationRangeFromRange(range)
+    @setLocationRange(locationRange)
+
   getPosition: ->
-    locationRange = @getLocationRange()
-    @document.rangeFromLocationRange(locationRange)[0]
+    @getRange()[0]
 
   setPosition: (position) ->
     locationRange = @document.locationRangeFromPosition(position)

  setBlockAttribute: (attributeName, value) ->
    return unless locationRange = @getLocationRange()
    @notifyDelegateOfIntentionToSetLocationRange()
    [startPosition, endPosition] = @document.rangeFromLocationRange(locationRange)

    @document.applyBlockAttributeAtLocationRange(attributeName, value, locationRange)

    {start} = @document.locationRangeFromPosition(startPosition)
    {end} = @document.locationRangeFromPosition(endPosition)
    @setLocationRange(start, end)

  removeCurrentAttribute: (attributeName) ->
    if Trix.blockAttributes[attributeName]

    @setPosition(@getPosition() + distance)

  expandLocationRangeInDirection: (direction) ->
    range = @getRange()
    if direction is "backward" then range[0]-- else range[1]++
    @setRange(range)

  expandSelectionInDirection: (direction) ->
    if @shouldExpandInDirectionUsingLocationRange(direction)
