   getLength: ->
     @blockList.getEndPosition()
 
+  getBlocks: ->
+    @blockList.toArray()
+
   eachBlock: (callback) ->
     @blockList.eachObject(callback)
 

  moveTextFromLocationRangeToPosition: edit "moveTextFromLocationRangeToPosition", (locationRange, position) ->
    range = @rangeFromLocationRange(locationRange)
    return if range[0] <= position <= range[1]
    document = @getDocumentAtLocationRange(locationRange)
    @removeTextAtLocationRange(locationRange)
    position -= document.getLength() if range[0] < position
    @insertDocumentAtLocationRange(document, @locationRangeFromPosition(position))

  addAttributeAtLocationRange: edit "addAttributeAtLocationRange", (attribute, value, locationRange) ->

    @removeTextAtLocationRange(locationRange)
    blocks = [new Trix.Block] if locationRange.offset is 0
    @blockList = @blockList.insertSplittableListAtPosition(new Trix.SplittableList(blocks), position)

  firstBlockInLocationRangeIsEntirelySelected: (locationRange) ->
    if locationRange.start.offset is 0 and locationRange.start.index < locationRange.end.index
      true
    else if locationRange.start.index is locationRange.end.index
      length = @getBlockAtIndex(locationRange.start.index).getLength()
      locationRange.start.offset is 0 and locationRange.end.offset is length
    else
      false

  expandLocationRangeToLineBreaksAndSplitBlocks: (locationRange) ->
    start = index: locationRange.start.index, offset: locationRange.start.offset
