applyDelta(delta) {
    let rm = null
    let ins = null
    let pos = 1  // skip \n #00000+swarm

    for(let i = 0; i < delta.length; i++) {
      let op = delta[i]
      if(op.insert) {
        invariant(pos > 0, 'Cannot insert at position 0.')
        if(!ins) ins = {}
        ins[this.data.getChar(pos - 1).id] = {
          value: op.insert,
          attributes: op.attributes
        }
        // we don't increment pos here because the insert hasn't actually happened yet
      }
      if(op.delete) {
        invariant(pos > 0, 'Cannot delete position 0.')
        if(!rm) rm = {}
        let rmcount = op.delete
        for (let j = 0; j < rmcount; j++) {
          rm[this.data.getChar(pos).id] = true
          pos += 1
        }
      }
      if(op.retain) {
        pos += op.retain
      }
    }

    if(rm) this.remove(rm)
    if(ins) this.insert(ins)
  }
A delta is based on the operational transform rich text type. See https://github.com/ottypes/rich-text.
@param delta