client/firepad/firepad.js
// Apply an operation to an ACE instance.
Apply an operation to an ACE instance.
Apply an operation to an ACE instance .
applyOperationToACE(operation) {
      var from, index, j, len, op, range, ref, to;
      index = 0;
      ref = operation.ops;
      for (j = 0, len = ref.length; j < len; j++) {
        op = ref[j];
        if (op.isRetain()) {
          index += op.chars;
        } else if (op.isInsert()) {
          this.aceDoc.insert(this.posFromIndex(index), op.text);
          index += op.text.length;
        } else if (op.isDelete()) {
          from = this.posFromIndex(index);
          to = this.posFromIndex(index + op.chars);
          range = this.aceRange.fromPoints(from, to);
          this.aceDoc.remove(range);
        }
      }
      return this.grabDocumentState();
    }
applyOperationToACE ( operation ) { var from , index , j , len , op , range , ref , to ; index = 0 ; ref = operation . ops ; for ( j = 0 , len = ref . length ; j < len ; j ++ ) { op = ref [ j ] ; if ( op . isRetain ( ) ) { index += op . chars ; } else if ( op . isInsert ( ) ) { this . aceDoc . insert ( this . posFromIndex ( index ) , op . text ) ; index += op . text . length ; } else if ( op . isDelete ( ) ) { from = this . posFromIndex ( index ) ; to = this . posFromIndex ( index + op . chars ) ; range = this . aceRange . fromPoints ( from , to ) ; this . aceDoc . remove ( range ) ; } } return this . grabDocumentState ( ) ; }
Apply an operation to an ACE instance.
Apply an operation to an ACE instance .