delete(type = 'row', _range) {
    this.changeData(() => {
      const {
        rows, merges, selector, cols,
      } = this;
      let { range } = selector;
      if (_range) {
        range = new CellRange(_range.sri, _range.sci, _range.eri, _range.eci);
      }
      const {
        sri, sci, eri, eci,
      } = range;
      const [rsize, csize] = range.size();
      let si = sri;
      let size = rsize;
      if (type === 'row') {
        rows.delete(sri, eri);
      } else if (type === 'column') {
        rows.deleteColumn(sci, eci);
        si = range.sci;
        size = csize;
        cols.len -= 1;
      }
      // console.log('type:', type, ', si:', si, ', size:', size);
      merges.shift(type, si, -size, (ri, ci, rn, cn, cellRange) => {
        // console.log('ri:', ri, ', ci:', ci, ', rn:', rn, ', cn:', cn, 'cellRange:', cellRange);
        const cell = rows.getCellOrNew(ri, ci);
        if (cell.merge) {
          cell.merge[0] += rn;
          cell.merge[1] += cn;
        } else {
          cell.merge = [cellRange.eri - cellRange.sri, cellRange.eci - cellRange.sci];
        }
        if (cell.merge[0] === 0 && cell.merge[1] === 0) {
          delete cell.merge;
          return true;
        }
        return false;
      });
    });
  }
// _range custom range when invoke by api
_range custom range when invoke by api
_range custom range when invoke by api
delete(type = 'row', _range) {
    this.changeData(() => {
      const {
        rows, merges, selector, cols,
      } = this;
      let { range } = selector;
      if (_range) {
        range = new CellRange(_range.sri, _range.sci, _range.eri, _range.eci);
      }
      const {
        sri, sci, eri, eci,
      } = range;
      const [rsize, csize] = range.size();
      let si = sri;
      let size = rsize;
      if (type === 'row') {
        rows.delete(sri, eri);
      } else if (type === 'column') {
        rows.deleteColumn(sci, eci);
        si = range.sci;
        size = csize;
        cols.len -= 1;
      }
      merges.shift(type, si, -size, (ri, ci, rn, cn, cellRange) => {
        const cell = rows.getCellOrNew(ri, ci);
        if (cell.merge) {
          cell.merge[0] += rn;
          cell.merge[1] += cn;
        } else {
          cell.merge = [cellRange.eri - cellRange.sri, cellRange.eci - cellRange.sci];
        }
        if (cell.merge[0] === 0 && cell.merge[1] === 0) {
          delete cell.merge;
          return true;
        }
        return false;
      });
    });
  }
delete ( type = 'row' , _range ) { this . changeData ( ( ) => { const { rows , merges , selector , cols , } = this ; let { range } = selector ; if ( _range ) { range = new CellRange ( _range . sri , _range . sci , _range . eri , _range . eci ) ; } const { sri , sci , eri , eci , } = range ; const [ rsize , csize ] = range . size ( ) ; let si = sri ; let size = rsize ; if ( type === 'row' ) { rows . delete ( sri , eri ) ; } else if ( type === 'column' ) { rows . deleteColumn ( sci , eci ) ; si = range . sci ; size = csize ; cols . len -= 1 ; } merges . shift ( type , si , - size , ( ri , ci , rn , cn , cellRange ) => { const cell = rows . getCellOrNew ( ri , ci ) ; if ( cell . merge ) { cell . merge [ 0 ] += rn ; cell . merge [ 1 ] += cn ; } else { cell . merge = [ cellRange . eri - cellRange . sri , cellRange . eci - cellRange . sci ] ; } if ( cell . merge [ 0 ] === 0 && cell . merge [ 1 ] === 0 ) { delete cell . merge ; return true ; } return false ; } ) ; } ) ; }
_range custom range when invoke by api
_range custom range when invoke by api
// console.log('type:', type, ', si:', si, ', size:', size); // console.log('ri:', ri, ', ci:', ci, ', rn:', rn, ', cn:', cn, 'cellRange:', cellRange);