| 389 | | |
| 390 | | var currentCell = cells[0] ; |
| 391 | | var currentRowSpan = currentCell.rowSpan ; |
| 392 | | if ( isNaN( currentRowSpan ) ) |
| 393 | | currentRowSpan = 1 ; |
| 394 | | var nextRow = currentCell.parentNode.parentNode.rows[currentCell.parentNode.rowIndex + currentRowSpan] ; |
| 395 | | if ( nextRow ) |
| 396 | | { |
| 397 | | var tableMap = this._CreateTableMap( currentCell.parentNode.parentNode ) ; |
| 398 | | var cellIndex = FCKTableHandler._GetCellIndexSpan( tableMap, currentCell.parentNode.rowIndex, currentCell ) ; |
| 399 | | var equivalentCell = tableMap[currentCell.parentNode.rowIndex + currentRowSpan][cellIndex] ; |
| 400 | | |
| 401 | | if ( ! equivalentCell ) |
| 402 | | return ; |
| 403 | | |
| 404 | | var equivalentRowSpan = equivalentCell.rowSpan ; |
| 405 | | if ( isNaN( equivalentRowSpan ) ) |
| 406 | | equivalentRowSpan = 1 ; |
| 407 | | |
| 408 | | var cellContents = FCK.EditorDocument.createDocumentFragment() ; |
| 409 | | while ( equivalentCell.childNodes.length > 0 ) |
| 410 | | cellContents.appendChild( equivalentCell.removeChild( equivalentCell.firstChild ) ) ; |
| 411 | | if ( cellContents.childNodes.length > 0 ) |
| 412 | | cellContents.insertBefore( FCK.EditorDocument.createElement( 'br' ), cellContents.firstChild ) ; |
| 413 | | if ( isNaN( currentCell.rowSpan ) ) |
| 414 | | currentCell.rowSpan = 1 ; |
| 415 | | currentCell.rowSpan += equivalentRowSpan ; |
| 416 | | currentCell.appendChild( cellContents ) ; |
| 417 | | equivalentCell.parentNode.removeChild( equivalentCell ) ; |
| 418 | | } |
| | 392 | var refCell = target.refCell ; |
| | 393 | var tableMap = target.tableMap ; |
| | 394 | var nextCell = target.nextCell ; |
| | 395 | |
| | 396 | var cellContents = refCell.ownerDocument.createDocumentFragment() ; |
| | 397 | while ( nextCell.childNodes.length > 0 ) |
| | 398 | cellContents.appendChild( nextCell.removeChild( nextCell.firstChild ) ) ; |
| | 399 | if ( cellContents.firstChild ) |
| | 400 | cellContents.insertBefore( nextCell.ownerDocument.createElement( 'br' ), cellContents.firstChild ) ; |
| | 401 | refCell.appendChild( cellContents ) ; |
| | 402 | this._MarkCells( [nextCell], '_Replace' ) ; |
| | 403 | this._ReplaceCellsByMarker( tableMap, '_Replace', refCell ) ; |
| | 404 | this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ; |
| | 405 | |
| | 406 | FCKSelection.SelectNode( refCell ) ; |
| | 407 | FCKSelection.Collapse( false ) ; |
| | 758 | |
| | 759 | FCKTableHandler.GetMergeDownTarget = function() |
| | 760 | { |
| | 761 | var cells = this.GetSelectedCells() ; |
| | 762 | if ( cells.length != 1 ) |
| | 763 | return null ; |
| | 764 | |
| | 765 | var refCell = cells[0] ; |
| | 766 | var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ; |
| | 767 | var rowIdx = refCell.parentNode.rowIndex ; |
| | 768 | var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; |
| | 769 | var newRowIdx = rowIdx + ( isNaN( refCell.rowSpan ) ? 1 : refCell.rowSpan ) ; |
| | 770 | if ( ! tableMap[newRowIdx] ) |
| | 771 | return null ; |
| | 772 | |
| | 773 | var nextCell = tableMap[newRowIdx][colIdx] ; |
| | 774 | |
| | 775 | if ( ! nextCell ) |
| | 776 | return null ; |
| | 777 | |
| | 778 | // The two cells must have the same horizontal geometry, otherwise merging does not makes sense. |
| | 779 | this._MarkCells( [refCell, nextCell], '_SizeTest' ) ; |
| | 780 | var refGeometry = this._GetMarkerGeometry( tableMap, rowIdx, colIdx, '_SizeTest' ) ; |
| | 781 | var nextGeometry = this._GetMarkerGeometry( tableMap, newRowIdx, colIdx, '_SizeTest' ) ; |
| | 782 | this._UnmarkCells( [refCell, nextCell], '_SizeTest' ) ; |
| | 783 | |
| | 784 | if ( refGeometry.width != nextGeometry.width || refGeometry.x != nextGeometry.x ) |
| | 785 | return null ; |
| | 786 | |
| | 787 | return { refCell : refCell, nextCell : nextCell, tableMap : tableMap } ; |
| | 788 | } |