tinymce.full.js
function getTableGrid(tableDetails) {
        function key(rowIndex, colIndex) {
          return rowIndex + ',' + colIndex;
        }

        function getAt(rowIndex, colIndex) {
          return access[key(rowIndex, colIndex)];
        }

        function getAllCells() {
          var allCells = [];
          Tools.each(rows, function (row) {
            allCells = allCells.concat(row.cells);
          });
          return allCells;
        }

        function getAllRows() {
          return rows;
        }

        var access = {};
        var rows = [];

        var maxRows = 0;
        var maxCols = 0;

        Tools.each(tableDetails, function (row, rowIndex) {
          var currentRow = [];

          Tools.each(row.cells, function (cell) {

            var start = 0;

            while (access[key(rowIndex, start)] !== undefined) {
              start++;
            }

            var current = {
              element: cell.element,
              colspan: cell.colspan,
              rowspan: cell.rowspan,
              rowIndex: rowIndex,
              colIndex: start
            };

            for (var i = 0; i < cell.colspan; i++) {
              for (var j = 0; j < cell.rowspan; j++) {
                var cr = rowIndex + j;
                var cc = start + i;
                access[key(cr, cc)] = current;
                maxRows = Math.max(maxRows, cr + 1);
                maxCols = Math.max(maxCols, cc + 1);
              }
            }

            currentRow.push(current);
          });

          rows.push({
            element: row.element,
            cells: currentRow
          });
        });

        return {
          grid: {
            maxRows: maxRows,
            maxCols: maxCols
          },
          getAt: getAt,
          getAllCells: getAllCells,
          getAllRows: getAllRows
        };
      }
function getTableGrid(tableDetails) {
        function key(rowIndex, colIndex) {
          return rowIndex + ',' + colIndex;
        }

        function getAt(rowIndex, colIndex) {
          return access[key(rowIndex, colIndex)];
        }

        function getAllCells() {
          var allCells = [];
          Tools.each(rows, function (row) {
            allCells = allCells.concat(row.cells);
          });
          return allCells;
        }

        function getAllRows() {
          return rows;
        }

        var access = {};
        var rows = [];

        var maxRows = 0;
        var maxCols = 0;

        Tools.each(tableDetails, function (row, rowIndex) {
          var currentRow = [];

          Tools.each(row.cells, function (cell) {

            var start = 0;

            while (access[key(rowIndex, start)] !== undefined) {
              start++;
            }

            var current = {
              element: cell.element,
              colspan: cell.colspan,
              rowspan: cell.rowspan,
              rowIndex: rowIndex,
              colIndex: start
            };

            for (var i = 0; i < cell.colspan; i++) {
              for (var j = 0; j < cell.rowspan; j++) {
                var cr = rowIndex + j;
                var cc = start + i;
                access[key(cr, cc)] = current;
                maxRows = Math.max(maxRows, cr + 1);
                maxCols = Math.max(maxCols, cc + 1);
              }
            }

            currentRow.push(current);
          });

          rows.push({
            element: row.element,
            cells: currentRow
          });
        });

        return {
          grid: {
            maxRows: maxRows,
            maxCols: maxCols
          },
          getAt: getAt,
          getAllCells: getAllCells,
          getAllRows: getAllRows
        };
      }
function getTableGrid ( tableDetails ) { function key ( rowIndex , colIndex ) { return rowIndex + ',' + colIndex ; } function getAt ( rowIndex , colIndex ) { return access [ key ( rowIndex , colIndex ) ] ; } function getAllCells ( ) { var allCells = [ ] ; Tools . each ( rows , function ( row ) { allCells = allCells . concat ( row . cells ) ; } ) ; return allCells ; } function getAllRows ( ) { return rows ; } var access = { } ; var rows = [ ] ; var maxRows = 0 ; var maxCols = 0 ; Tools . each ( tableDetails , function ( row , rowIndex ) { var currentRow = [ ] ; Tools . each ( row . cells , function ( cell ) { var start = 0 ; while ( access [ key ( rowIndex , start ) ] !== undefined ) { start ++ ; } var current = { element : cell . element , colspan : cell . colspan , rowspan : cell . rowspan , rowIndex : rowIndex , colIndex : start } ; for ( var i = 0 ; i < cell . colspan ; i ++ ) { for ( var j = 0 ; j < cell . rowspan ; j ++ ) { var cr = rowIndex + j ; var cc = start + i ; access [ key ( cr , cc ) ] = current ; maxRows = Math . max ( maxRows , cr + 1 ) ; maxCols = Math . max ( maxCols , cc + 1 ) ; } } currentRow . push ( current ) ; } ) ; rows . push ( { element : row . element , cells : currentRow } ) ; } ) ; return { grid : { maxRows : maxRows , maxCols : maxCols } , getAt : getAt , getAllCells : getAllCells , getAllRows : getAllRows } ; }
Get a grid model of the table.
Get a grid model of the table .