       Math.floor(new Date().getTime() / Trix.config.undoInterval)
     else
       0
+
+  isFocused: ->
+    @editorElement is @editorElement.ownerDocument?.activeElement

    @attachmentLocationRange = null

  compositionDidRequestChangingSelectionToLocationRange: (locationRange) ->
    @requestedLocationRange = locationRange
    @documentWhenLocationRangeRequested = @composition.document
    @render() unless @handlingInput

    @loadSnapshot({document, selectedRange: [0, 0]})

  loadSnapshot: (snapshot) ->
    @loadingSnapshot = true
    @undoManager = new Trix.UndoManager @composition
    @composition.loadSnapshot(snapshot)

