src/edit/history.js
// to a document transform, returning the transform and the step ID.
to a document transform, returning the transform and the step ID.
to a document transform returning the transform and the step ID .
popEvent(doc, allowCollapsing) {
    this.abortCompression()
    let event = this.events.pop()
    if (!event) return null
    let remap = new BranchRemapping(this), collapsing = allowCollapsing
    let tr = new Transform(doc)
    let ids = []
    for (let i = event.length - 1; i >= 0; i--) {
      let invertedStep = event[i], step = invertedStep.step
      if (!collapsing || invertedStep.version != remap.version) {
        collapsing = false
        remap.moveToVersion(invertedStep.version)
        step = step.map(remap.remap)
        let result = step && tr.step(step)
        if (result) {
          ids.push(invertedStep.id)
          if (this.addMap(result.map))
            this.mirror[this.version] = invertedStep.version
        }
        if (i > 0) remap.movePastStep(result)
      } else {
        this.version--
        delete this.mirror[this.version]
        this.maps.pop()
        tr.step(step)
        ids.push(invertedStep.id)
        --remap.version
      }
    }
    if (this.empty()) this.clear(true)
    return {transform: tr, ids}
  }
popEvent ( doc , allowCollapsing ) { this . abortCompression ( ) let event = this . events . pop ( ) if ( ! event ) return null let remap = new BranchRemapping ( this ) , collapsing = allowCollapsing let tr = new Transform ( doc ) let ids = [ ] for ( let i = event . length - 1 ; i >= 0 ; i -- ) { let invertedStep = event [ i ] , step = invertedStep . step if ( ! collapsing || invertedStep . version != remap . version ) { collapsing = false remap . moveToVersion ( invertedStep . version ) step = step . map ( remap . remap ) let result = step && tr . step ( step ) if ( result ) { ids . push ( invertedStep . id ) if ( this . addMap ( result . map ) ) this . mirror [ this . version ] = invertedStep . version } if ( i > 0 ) remap . movePastStep ( result ) } else { this . version -- delete this . mirror [ this . version ] this . maps . pop ( ) tr . step ( step ) ids . push ( invertedStep . id ) -- remap . version } } if ( this . empty ( ) ) this . clear ( true ) return { transform : tr , ids } }
to a document transform, returning the transform and the step ID.
to a document transform returning the transform and the step ID .