 #= require tandem/selection
 #= require tandem/renderer
 
+stripNewlineAttributes = (delta) ->
+  deltas = []
+  _.each(delta.deltas, (delta) ->
+    if delta.text?
+      texts = delta.text.split("\n")
+      _.each(texts, (text, index) ->
+        deltas.push(new JetInsert(text, _.clone(delta.attributes)))
+        deltas.push(new JetInsert("\n")) if index < texts.length - 1
+      )
+    else
+      deltas.push(delta)
+  )
+  delta = new JetDelta(delta.startLength, delta.endLength, deltas)
+  delta.compact()
+  return delta
+
 class TandemEditor extends EventEmitter2
   @editors: []
 

    index = 0       # Stores where the last retain end was, so if we see another one, we know to delete
    offset = 0      # Tracks how many characters inserted to correctly offset new text
    oldDelta = @doc.toDelta()

    cursors = {}
    _.each(delta.deltas, (delta) =>
      if JetDelta.isInsert(delta)

      decompose = JetSync.decompose(oldDelta, newDelta)
      compose = JetSync.compose(oldDelta, decompose)
      console.assert(_.isEqual(compose, newDelta), oldDelta, newDelta, decompose, compose)
      delta = stripNewlineAttributes(decompose)
    else
      fn()
    @ignoreDomChanges = oldIgnoreDomChange
