Ticket #1865: 1865_4a.patch

File 1865_4a.patch, 4.3 KB (added by Koen Willems, 15 years ago)
  • fcktablehandler.js

     
    382382
    383383        this._ReplaceCellsByMarker( tableMap, '_SelectedCells', refCell ) ;
    384384        this._UnmarkCells( cells, '_SelectedCells' ) ;
    385         this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;
     385        this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ;
    386386        refCell.appendChild( cellContents ) ;
    387387
    388388        if ( FCKBrowserInfo.IsGeckoLike && ( ! refCell.firstChild ) )
     
    408408        refCell.appendChild( cellContents ) ;
    409409        this._MarkCells( [nextCell], '_Replace' ) ;
    410410        this._ReplaceCellsByMarker( tableMap, '_Replace', refCell ) ;
    411         this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;
     411        this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ;
    412412
    413413        this._MoveCaretToCell( refCell, false ) ;
    414414}
     
    430430        refCell.appendChild( cellContents ) ;
    431431        this._MarkCells( [nextCell], '_Replace' ) ;
    432432        this._ReplaceCellsByMarker( tableMap, '_Replace', refCell ) ;
    433         this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;
     433        this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ;
    434434
    435435        this._MoveCaretToCell( refCell, false ) ;
    436436}
     
    496496                tableMap = newTableMap ;
    497497        }
    498498
    499         this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;
     499        this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ;
    500500}
    501501
    502502FCKTableHandler.VerticalSplitCell = function()
     
    540540                        newCell.colSpan = currentColSpan ;
    541541                if ( FCKBrowserInfo.IsGeckoLike )
    542542                        FCKTools.AppendBogusBr( newCell ) ;
    543                 currentCell.parentNode.parentNode.rows[newCellRowIndex].insertBefore( newCell, insertMarker ) ;
     543                currentCell.parentNode.parentNode.parentNode.rows[newCellRowIndex].insertBefore( newCell, insertMarker ) ;
    544544        }
    545545        else
    546546        {
    547547                // 1. Insert a new row.
    548                 var newCellRowIndex = currentRowIndex + 1 ;
     548                var newSectionRowIdx = currentCell.parentNode.sectionRowIndex + 1 ;
    549549                var newRow = FCK.EditorDocument.createElement( 'tr' ) ;
    550                 var tBody = currentCell.parentNode.parentNode ;
    551                 if ( tBody.rows.length > newCellRowIndex )
    552                         tBody.insertBefore( newRow, tBody.rows[newCellRowIndex] ) ;
     550                var tSection = currentCell.parentNode.parentNode ;
     551                if ( tSection.rows.length > newSectionRowIdx )
     552                        tSection.insertBefore( newRow, tSection.rows[newSectionRowIdx] ) ;
    553553                else
    554                         tBody.appendChild( newRow ) ;
     554                        tSection.appendChild( newRow ) ;
    555555
    556556                // 2. +1 to rowSpan for all cells crossing currentCell's row.
    557557                for ( var i = 0 ; i < tableMap[currentRowIndex].length ; )
     
    615615// The difference here is that the "spanned" cells (colSpan and rowSpan) are duplicated on the matrix
    616616// cells that are "spanned". For example, a row with 3 cells where the second cell has colSpan=2 and rowSpan=3
    617617// will produce a bi-dimensional matrix with the following values (representing the cells):
    618 //              Cell1, Cell2, Cell2, Cell2, Cell 3
    619 //              Cell4, Cell2, Cell2, Cell2, Cell 5
     618//              Cell1, Cell2, Cell2, Cell3
     619//              Cell4, Cell2, Cell2, Cell5
     620//              Cell6, Cell2, Cell2, Cell7
    620621FCKTableHandler._CreateTableMap = function( refCell )
    621622{
    622         // It's really a tbody, thead or tfoot. This is only temporary.
    623         var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode ) ;
     623        var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode.parentNode ) ;
    624624
    625625        var aRows = table.rows ;
    626626
     
    673673        // for storing the calculated rowSpan in IE.
    674674        var rowSpanAttr = FCKBrowserInfo.IsIE ? "_fckrowspan" : "rowSpan" ;
    675675
    676         // Clear the table of all rows first.
    677         while ( table.rows.length > 0 )
    678         {
    679                 var row = table.rows[0] ;
    680                 row.parentNode.removeChild( row ) ;
    681         }
    682 
    683676        // Disconnect all the cells in tableMap from their parents, set all colSpan and rowSpan attributes to 1.
    684677        for ( var i = 0 ; i < tableMap.length ; i++ )
    685678        {
     
    764757                        if ( cell.rowSpan == 1 )
    765758                                cell.removeAttribute( 'rowspan' ) ;
    766759                }
    767                 table.appendChild( rowObj ) ;
     760                if ( FCKBrowserInfo.IsIE )
     761                {
     762                        table.rows[i].replaceNode( rowObj ) ;
     763                }
     764                else
     765                {
     766                        table.rows[i].innerHTML = '' ;
     767                        FCKDomTools.MoveChildren( rowObj, table.rows[i] ) ;
     768                }
    768769        }
    769770}
    770771
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy