 
   insertAt: (index, text, emitEvent = true) ->
     this.doSilently( =>
-      delta = this.trackDelta( =>
-        @selection.preserve( =>
+      @selection.preserve( =>
+        delta = this.trackDelta( =>
           this.keepNormalized( =>
             @doc.insertText(index, text)
           )
         )
-      )
-      this.emit(ScribeEditor.events.TEXT_CHANGE, delta) if emitEvent
+        this.emit(ScribeEditor.events.TEXT_CHANGE, delta) if emitEvent
+        return delta
+      )
     )
     
   setSelection: (range) ->


  deleteAt: (index, length, emitEvent = true) ->
    this.doSilently( =>
      delta = this.trackDelta( =>
        @selection.preserve( =>
          this.keepNormalized( =>
            @doc.deleteText(index, length)
          )
        )
      )
      this.emit(ScribeEditor.events.TEXT_CHANGE, delta) if emitEvent
    )

  doSilently: (fn) ->


  update: (emitEvent = true) ->
    this.doSilently( =>
      @selection.preserve( =>
        delta = this.trackDelta( =>
          Scribe.Document.normalizeHtml(@root)
          lines = @doc.lines.toArray()
          lineNode = @root.firstChild
