Ticket #2472: 2472.patch

File 2472.patch, 6.4 KB (added by Alfonso Martínez de Lizarrondo, 11 years ago)

Proposed patch

  • _whatsnew.html

     
    5050                        character inside text wasn't encoded in Opera and Safari.</li>
    5151                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2467">#2467</a>] Fixed JavaScript
    5252                        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>
    5355        </ul>
    5456        <p>
    5557                <a href="_whatsnew_history.html">See previous versions history</a></p>
  • editor/_source/internals/fcktablehandler.js

     
    298298
    299299        this._MarkCells( cells, '_CellSelected' ) ;
    300300
    301         var tableMap = this._CreateTableMap( cells[0].parentNode.parentNode ) ;
     301        var tableMap = this._CreateTableMap( cells[0] ) ;
    302302        var rowIdx = cells[0].parentNode.rowIndex ;
    303303        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, cells[0] ) ;
    304304
     
    357357        // Assume the selected cells are already in a rectangular geometry.
    358358        // Because the checking is already done by FCKTableCommand.
    359359        var refCell = cells[0] ;
    360         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
     360        var tableMap = this._CreateTableMap( refCell ) ;
    361361        var rowIdx = refCell.parentNode.rowIndex ;
    362362        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
    363363
     
    450450                return ;
    451451
    452452        var refCell = cells[0] ;
    453         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
     453        var tableMap = this._CreateTableMap( refCell ) ;
    454454        var rowIdx = refCell.parentNode.rowIndex ;
    455455        var colIdx = FCKTableHandler._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
    456456        var cellSpan = isNaN( refCell.colSpan ) ? 1 : refCell.colSpan ;
    457457
    458458        if ( cellSpan > 1 )
    459459        {
    460                 // Splittng a multi-column cell - original cell gets ceil(colSpan/2) columns,
     460                // Splitting a multi-column cell - original cell gets ceil(colSpan/2) columns,
    461461                // new cell gets floor(colSpan/2).
    462462                var newCellSpan = Math.ceil( cellSpan / 2 ) ;
    463                 var newCell = FCKTools.GetElementDocument( refCell ).createElement( 'td' ) ;
     463                var newCell = FCK.EditorDocument.createElement( refCell.nodeName ) ;
    464464                if ( FCKBrowserInfo.IsGeckoLike )
    465465                        FCKTools.AppendBogusBr( newCell ) ;
    466466                var startIdx = colIdx + newCellSpan ;
     
    488488                        if ( tableMap[i][colIdx] == refCell )
    489489                        {
    490490                                newRow.push( refCell ) ;
    491                                 newRow.push( FCKTools.GetElementDocument( refCell ).createElement( 'td' ) ) ;
     491                                newRow.push( FCK.EditorDocument.createElement( refCell.nodeName ) ) ;
    492492                                if ( FCKBrowserInfo.IsGeckoLike )
    493493                                        FCKTools.AppendBogusBr( newRow[newRow.length - 1] ) ;
    494494                        }
     
    514514                return ;
    515515
    516516        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 ) ;
    519520        var currentRowSpan = currentCell.rowSpan ;
    520         var currentRowIndex = currentCell.parentNode.rowIndex ;
    521521        if ( isNaN( currentRowSpan ) )
    522522                currentRowSpan = 1 ;
    523523
     
    528528
    529529                // 2. Find the appropriate place to insert a new cell at the next row.
    530530                var newCellRowIndex = currentRowIndex + Math.ceil( currentRowSpan / 2 ) ;
     531                var oRow = tableMap[newCellRowIndex] ;
    531532                var insertMarker = null ;
    532                 for ( var i = cellIndex+1 ; i < tableMap[newCellRowIndex].length ; i++ )
     533                for ( var i = cellIndex+1 ; i < oRow.length ; i++ )
    533534                {
    534                         if ( tableMap[newCellRowIndex][i].parentNode.rowIndex == newCellRowIndex )
     535                        if ( oRow[i].parentNode.rowIndex == newCellRowIndex )
    535536                        {
    536                                 insertMarker = tableMap[newCellRowIndex][i] ;
     537                                insertMarker = oRow[i] ;
    537538                                break ;
    538539                        }
    539540                }
    540541
    541542                // 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 ) ;
    543544                newCell.rowSpan = Math.floor( currentRowSpan / 2 ) ;
    544545                if ( FCKBrowserInfo.IsGeckoLike )
    545546                        FCKTools.AppendBogusBr( newCell ) ;
     
    575576                }
    576577
    577578                // 3. Insert a new cell to new row.
    578                 var newCell = FCK.EditorDocument.createElement( 'td' ) ;
     579                var newCell = FCK.EditorDocument.createElement( currentCell.nodeName ) ;
    579580                if ( FCKBrowserInfo.IsGeckoLike )
    580581                        FCKTools.AppendBogusBr( newCell ) ;
    581582                newRow.appendChild( newCell ) ;
     
    631632// The difference here is that the "spanned" cells (colSpan and rowSpan) are duplicated on the matrix
    632633// cells that are "spanned". For example, a row with 3 cells where the second cell has colSpan=2 and rowSpan=3
    633634// will produce a bi-dimensional matrix with the following values (representing the cells):
    634 //              Cell1, Cell2, Cell2, Cell 3
    635 //              Cell4, Cell2, Cell2, Cell 5
    636 FCKTableHandler._CreateTableMap = function( table )
     635//              Cell1, Cell2, Cell2, Cell2, Cell 3
     636//              Cell4, Cell2, Cell2, Cell2, Cell 5
     637FCKTableHandler._CreateTableMap = function( refCell )
    637638{
     639        // It's really a tbody, thead or tfoot. This is only temporary.
     640        var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode ) ;
     641
    638642        var aRows = table.rows ;
    639643
    640644        // Row and Column counters.
     
    819823                return null ;
    820824
    821825        var refCell = cells[0] ;
    822         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
     826        var tableMap = this._CreateTableMap( refCell ) ;
    823827        var rowIdx = refCell.parentNode.rowIndex ;
    824828        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
    825829        var nextColIdx = colIdx + ( isNaN( refCell.colSpan ) ? 1 : refCell.colSpan ) ;
     
    847851                return null ;
    848852
    849853        var refCell = cells[0] ;
    850         var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
     854        var tableMap = this._CreateTableMap( refCell ) ;
    851855        var rowIdx = refCell.parentNode.rowIndex ;
    852856        var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
    853857        var newRowIdx = rowIdx + ( isNaN( refCell.rowSpan ) ? 1 : refCell.rowSpan ) ;
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy