src/js/extensions/table/tableRangeHandler.js
function getTableSelectionRange(tableData, $selectedCells, $startContainer) {
  const cellIndexData = tableDataHandler.createCellIndexData(tableData);
  const tableRange = {};

  if ($selectedCells.length) {
    const startRange = tableDataHandler.findCellIndex(cellIndexData, $selectedCells.first());
    const endRange = util.extend({}, startRange);

    $selectedCells.each((index, cell) => {
      const cellIndex = tableDataHandler.findCellIndex(cellIndexData, $(cell));
      const cellData = tableData[cellIndex.rowIndex][cellIndex.colIndex];
      const lastRowMergedIndex = cellIndex.rowIndex + cellData.rowspan - 1;
      const lastColMergedIndex = cellIndex.colIndex + cellData.colspan - 1;

      endRange.rowIndex = Math.max(endRange.rowIndex, lastRowMergedIndex);
      endRange.colIndex = Math.max(endRange.colIndex, lastColMergedIndex);
    });

    tableRange.start = startRange;
    tableRange.end = endRange;
  } else {
    const cellIndex = tableDataHandler.findCellIndex(cellIndexData, $startContainer);

    tableRange.start = cellIndex;
    tableRange.end = util.extend({}, cellIndex);
  }

  return tableRange;
}
function getTableSelectionRange(tableData, $selectedCells, $startContainer) {
  const cellIndexData = tableDataHandler.createCellIndexData(tableData);
  const tableRange = {};

  if ($selectedCells.length) {
    const startRange = tableDataHandler.findCellIndex(cellIndexData, $selectedCells.first());
    const endRange = util.extend({}, startRange);

    $selectedCells.each((index, cell) => {
      const cellIndex = tableDataHandler.findCellIndex(cellIndexData, $(cell));
      const cellData = tableData[cellIndex.rowIndex][cellIndex.colIndex];
      const lastRowMergedIndex = cellIndex.rowIndex + cellData.rowspan - 1;
      const lastColMergedIndex = cellIndex.colIndex + cellData.colspan - 1;

      endRange.rowIndex = Math.max(endRange.rowIndex, lastRowMergedIndex);
      endRange.colIndex = Math.max(endRange.colIndex, lastColMergedIndex);
    });

    tableRange.start = startRange;
    tableRange.end = endRange;
  } else {
    const cellIndex = tableDataHandler.findCellIndex(cellIndexData, $startContainer);

    tableRange.start = cellIndex;
    tableRange.end = util.extend({}, cellIndex);
  }

  return tableRange;
}
function getTableSelectionRange ( tableData , $selectedCells , $startContainer ) { const cellIndexData = tableDataHandler . createCellIndexData ( tableData ) ; const tableRange = { } ; if ( $selectedCells . length ) { const startRange = tableDataHandler . findCellIndex ( cellIndexData , $selectedCells . first ( ) ) ; const endRange = util . extend ( { } , startRange ) ; $selectedCells . each ( ( index , cell ) => { const cellIndex = tableDataHandler . findCellIndex ( cellIndexData , $ ( cell ) ) ; const cellData = tableData [ cellIndex . rowIndex ] [ cellIndex . colIndex ] ; const lastRowMergedIndex = cellIndex . rowIndex + cellData . rowspan - 1 ; const lastColMergedIndex = cellIndex . colIndex + cellData . colspan - 1 ; endRange . rowIndex = Math . max ( endRange . rowIndex , lastRowMergedIndex ) ; endRange . colIndex = Math . max ( endRange . colIndex , lastColMergedIndex ) ; } ) ; tableRange . start = startRange ; tableRange . end = endRange ; } else { const cellIndex = tableDataHandler . findCellIndex ( cellIndexData , $startContainer ) ; tableRange . start = cellIndex ; tableRange . end = util . extend ( { } , cellIndex ) ; } return tableRange ; }
Get table selection range.
@param {Array.<Array.<object>>} tableData - table data
@param {jQuery} $selectedCells - selected cells jQuery elements
@param {jQuery} $startContainer - start container jQuery element of text range
@returns {{
start: {rowIndex: number, colIndex: number},
end: {rowIndex: number, colIndex: number}
}}
@ignore
Get table selection range .