 
 DEFAULT_API_OPTIONS = { silent: false, source: 'api' }
 
-
-_checkUpdate = ->
-  if @innerHTML != @root.innerHTML
-    delta = this.update()
-    @innerHTML = @root.innerHTML
-    return delta
-  else
-    return false
-
-_doAt = (fn, options) ->
-  delta = false
-  this.doSilently( =>
-    delta = _trackDelta.call(this, =>
-      fn.call(this)
-    , options)
-  )
-  return delta
 
 _deleteAt = (index, length) ->
   return if length <= 0

          newLine = @doc.appendLine(lineNode)
          lineNode = lineNode.nextSibling
      )
      @innerHTML = @root.innerHTML    # trackDelta will emit events that may cause clients to call get functions
    , { silent: false, source: 'user' })


module.exports = ScribeEditor

  )

_trackDelta = (fn, options) ->
  oldIndex = @savedRange?.start.index
  fn()
  newDelta = @doc.toDelta()
  try
    newIndex = @selection.getRange()?.start.index     # this.getSelection() triggers infinite loop
    if oldIndex? and newIndex? and oldIndex <= @delta.endLength and newIndex <= newDelta.endLength
      [oldLeftDelta, oldRightDelta] = @delta.split(oldIndex)
      [newLeftDelta, newRightDelta] = newDelta.split(newIndex)
      decomposeLeft = newLeftDelta.decompose(oldLeftDelta)
      decomposeRight = newRightDelta.decompose(oldRightDelta)
      decomposeA = decomposeLeft.merge(decomposeRight)
  catch ignored
  decomposeB = newDelta.decompose(@delta)
  if decomposeA and decomposeB
    decompose = if decomposeA.ops.length < decomposeB.ops.length then decomposeA else decomposeB
  else
    decompose = decomposeA or decomposeB
  return decompose

_update = ->
  delta = _trackDelta.call(this, =>
    this.doSilently( =>
      @selection.preserve( =>
        ScribeNormalizer.breakBlocks(@root)
        lines = @doc.lines.toArray()
