 #= require trix/utilities/dom
 #= require trix/utilities/helpers
 
+{DOM} = Trix
 {memoize} = Trix.Helpers
 
 class Trix.SelectionManager

    [container, offset]

  findNodeForLocationRange: (range) ->
    walker = Trix.DOM.createTreeWalker(@element, null, nodeFilterForLocationRange)
    node = walker.currentNode

    while walker.nextNode()

        position = container.trixPosition
      else
        node = container.childNodes[offset - 1]
        walker = DOM.createTreeWalker(node)
        walker.lastChild()
        index = walker.currentNode.trixIndex
        position = walker.currentNode.trixPosition + walker.currentNode.trixLength
