Ticket #2472: 2472.patch
File 2472.patch, 6.4 KB (added by , 16 years ago) |
---|
-
_whatsnew.html
50 50 character inside text wasn't encoded in Opera and Safari.</li> 51 51 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2467">#2467</a>] Fixed JavaScript 52 52 error with the fit window command in source mode.</li> 53 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2472">#2472</a>] Splitting a TH 54 will create a two TH, not a TH and a TD.</li> 53 55 </ul> 54 56 <p> 55 57 <a href="_whatsnew_history.html">See previous versions history</a></p> -
editor/_source/internals/fcktablehandler.js
298 298 299 299 this._MarkCells( cells, '_CellSelected' ) ; 300 300 301 var tableMap = this._CreateTableMap( cells[0] .parentNode.parentNode) ;301 var tableMap = this._CreateTableMap( cells[0] ) ; 302 302 var rowIdx = cells[0].parentNode.rowIndex ; 303 303 var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, cells[0] ) ; 304 304 … … 357 357 // Assume the selected cells are already in a rectangular geometry. 358 358 // Because the checking is already done by FCKTableCommand. 359 359 var refCell = cells[0] ; 360 var tableMap = this._CreateTableMap( refCell .parentNode.parentNode) ;360 var tableMap = this._CreateTableMap( refCell ) ; 361 361 var rowIdx = refCell.parentNode.rowIndex ; 362 362 var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 363 363 … … 450 450 return ; 451 451 452 452 var refCell = cells[0] ; 453 var tableMap = this._CreateTableMap( refCell .parentNode.parentNode) ;453 var tableMap = this._CreateTableMap( refCell ) ; 454 454 var rowIdx = refCell.parentNode.rowIndex ; 455 455 var colIdx = FCKTableHandler._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 456 456 var cellSpan = isNaN( refCell.colSpan ) ? 1 : refCell.colSpan ; 457 457 458 458 if ( cellSpan > 1 ) 459 459 { 460 // Splitt ng a multi-column cell - original cell gets ceil(colSpan/2) columns,460 // Splitting a multi-column cell - original cell gets ceil(colSpan/2) columns, 461 461 // new cell gets floor(colSpan/2). 462 462 var newCellSpan = Math.ceil( cellSpan / 2 ) ; 463 var newCell = FCK Tools.GetElementDocument( refCell ).createElement( 'td') ;463 var newCell = FCK.EditorDocument.createElement( refCell.nodeName ) ; 464 464 if ( FCKBrowserInfo.IsGeckoLike ) 465 465 FCKTools.AppendBogusBr( newCell ) ; 466 466 var startIdx = colIdx + newCellSpan ; … … 488 488 if ( tableMap[i][colIdx] == refCell ) 489 489 { 490 490 newRow.push( refCell ) ; 491 newRow.push( FCK Tools.GetElementDocument( refCell ).createElement( 'td') ) ;491 newRow.push( FCK.EditorDocument.createElement( refCell.nodeName ) ) ; 492 492 if ( FCKBrowserInfo.IsGeckoLike ) 493 493 FCKTools.AppendBogusBr( newRow[newRow.length - 1] ) ; 494 494 } … … 514 514 return ; 515 515 516 516 var currentCell = cells[0] ; 517 var tableMap = this._CreateTableMap( currentCell.parentNode.parentNode ) ; 518 var cellIndex = FCKTableHandler._GetCellIndexSpan( tableMap, currentCell.parentNode.rowIndex, currentCell ) ; 517 var tableMap = this._CreateTableMap( currentCell ) ; 518 var currentRowIndex = currentCell.parentNode.rowIndex ; 519 var cellIndex = FCKTableHandler._GetCellIndexSpan( tableMap, currentRowIndex, currentCell ) ; 519 520 var currentRowSpan = currentCell.rowSpan ; 520 var currentRowIndex = currentCell.parentNode.rowIndex ;521 521 if ( isNaN( currentRowSpan ) ) 522 522 currentRowSpan = 1 ; 523 523 … … 528 528 529 529 // 2. Find the appropriate place to insert a new cell at the next row. 530 530 var newCellRowIndex = currentRowIndex + Math.ceil( currentRowSpan / 2 ) ; 531 var oRow = tableMap[newCellRowIndex] ; 531 532 var insertMarker = null ; 532 for ( var i = cellIndex+1 ; i < tableMap[newCellRowIndex].length ; i++ )533 for ( var i = cellIndex+1 ; i < oRow.length ; i++ ) 533 534 { 534 if ( tableMap[newCellRowIndex][i].parentNode.rowIndex == newCellRowIndex )535 if ( oRow[i].parentNode.rowIndex == newCellRowIndex ) 535 536 { 536 insertMarker = tableMap[newCellRowIndex][i] ;537 insertMarker = oRow[i] ; 537 538 break ; 538 539 } 539 540 } 540 541 541 542 // 3. Insert the new cell to the indicated place, with the appropriate rowSpan, next row. 542 var newCell = FCK.EditorDocument.createElement( 'td') ;543 var newCell = FCK.EditorDocument.createElement( currentCell.nodeName ) ; 543 544 newCell.rowSpan = Math.floor( currentRowSpan / 2 ) ; 544 545 if ( FCKBrowserInfo.IsGeckoLike ) 545 546 FCKTools.AppendBogusBr( newCell ) ; … … 575 576 } 576 577 577 578 // 3. Insert a new cell to new row. 578 var newCell = FCK.EditorDocument.createElement( 'td') ;579 var newCell = FCK.EditorDocument.createElement( currentCell.nodeName ) ; 579 580 if ( FCKBrowserInfo.IsGeckoLike ) 580 581 FCKTools.AppendBogusBr( newCell ) ; 581 582 newRow.appendChild( newCell ) ; … … 631 632 // The difference here is that the "spanned" cells (colSpan and rowSpan) are duplicated on the matrix 632 633 // cells that are "spanned". For example, a row with 3 cells where the second cell has colSpan=2 and rowSpan=3 633 634 // will produce a bi-dimensional matrix with the following values (representing the cells): 634 // Cell1, Cell2, Cell2, Cell 3635 // Cell4, Cell2, Cell2, Cell 5636 FCKTableHandler._CreateTableMap = function( table)635 // Cell1, Cell2, Cell2, Cell2, Cell 3 636 // Cell4, Cell2, Cell2, Cell2, Cell 5 637 FCKTableHandler._CreateTableMap = function( refCell ) 637 638 { 639 // It's really a tbody, thead or tfoot. This is only temporary. 640 var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode ) ; 641 638 642 var aRows = table.rows ; 639 643 640 644 // Row and Column counters. … … 819 823 return null ; 820 824 821 825 var refCell = cells[0] ; 822 var tableMap = this._CreateTableMap( refCell .parentNode.parentNode) ;826 var tableMap = this._CreateTableMap( refCell ) ; 823 827 var rowIdx = refCell.parentNode.rowIndex ; 824 828 var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 825 829 var nextColIdx = colIdx + ( isNaN( refCell.colSpan ) ? 1 : refCell.colSpan ) ; … … 847 851 return null ; 848 852 849 853 var refCell = cells[0] ; 850 var tableMap = this._CreateTableMap( refCell .parentNode.parentNode) ;854 var tableMap = this._CreateTableMap( refCell ) ; 851 855 var rowIdx = refCell.parentNode.rowIndex ; 852 856 var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ; 853 857 var newRowIdx = rowIdx + ( isNaN( refCell.rowSpan ) ? 1 : refCell.rowSpan ) ;