Ticket #1865: 1865_4.patch
File 1865_4.patch, 5.2 KB (added by , 14 years ago) |
---|
-
fcktablehandler.js
382 382 383 383 this._ReplaceCellsByMarker( tableMap, '_SelectedCells', refCell ) ; 384 384 this._UnmarkCells( cells, '_SelectedCells' ) ; 385 this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;385 this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ; 386 386 refCell.appendChild( cellContents ) ; 387 387 388 388 if ( FCKBrowserInfo.IsGeckoLike && ( ! refCell.firstChild ) ) … … 408 408 refCell.appendChild( cellContents ) ; 409 409 this._MarkCells( [nextCell], '_Replace' ) ; 410 410 this._ReplaceCellsByMarker( tableMap, '_Replace', refCell ) ; 411 this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;411 this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ; 412 412 413 413 this._MoveCaretToCell( refCell, false ) ; 414 414 } … … 430 430 refCell.appendChild( cellContents ) ; 431 431 this._MarkCells( [nextCell], '_Replace' ) ; 432 432 this._ReplaceCellsByMarker( tableMap, '_Replace', refCell ) ; 433 this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;433 this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ; 434 434 435 435 this._MoveCaretToCell( refCell, false ) ; 436 436 } … … 496 496 tableMap = newTableMap ; 497 497 } 498 498 499 this._InstallTableMap( tableMap, refCell.parentNode.parentNode ) ;499 this._InstallTableMap( tableMap, refCell.parentNode.parentNode.parentNode ) ; 500 500 } 501 501 502 502 FCKTableHandler.VerticalSplitCell = function() … … 540 540 newCell.colSpan = currentColSpan ; 541 541 if ( FCKBrowserInfo.IsGeckoLike ) 542 542 FCKTools.AppendBogusBr( newCell ) ; 543 currentCell.parentNode.parentNode. rows[newCellRowIndex].insertBefore( newCell, insertMarker ) ;543 currentCell.parentNode.parentNode.parentNode.rows[newCellRowIndex].insertBefore( newCell, insertMarker ) ; 544 544 } 545 545 else 546 546 { 547 547 // 1. Insert a new row. 548 548 var newCellRowIndex = currentRowIndex + 1 ; 549 549 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 oTable = FCKTools.GetElementAscensor( currentCell, 'TABLE' ) ; 551 552 if( oTable.tHead ) 553 { 554 var theadRows = oTable.tHead.rows.length ; 555 556 if ( currentCell.parentNode.parentNode.tagName == 'TBODY' && currentCell.parentNode.parentNode.rows.length <= newCellRowIndex - theadRows ) 557 currentCell.parentNode.parentNode.appendChild(newRow) ; 558 else if ( currentCell.parentNode.parentNode.tagName == 'THEAD' && currentCell.parentNode.parentNode.rows.length <= newCellRowIndex ) 559 currentCell.parentNode.parentNode.appendChild(newRow) ; 560 else if( currentCell.parentNode.parentNode.tagName == 'TBODY' ) 561 currentCell.parentNode.parentNode.insertBefore( newRow, currentCell.parentNode.parentNode.rows[newCellRowIndex - theadRows] ) ; 562 else 563 currentCell.parentNode.parentNode.insertBefore( newRow, currentCell.parentNode.parentNode.rows[newCellRowIndex] ) ; 564 } 553 565 else 554 tBody.appendChild( newRow ) ; 566 { 567 if( currentCell.parentNode.parentNode.rows.length <= newCellRowIndex) 568 currentCell.parentNode.parentNode.appendChild(newRow) ; 569 else 570 currentCell.parentNode.parentNode.insertBefore( newRow, currentCell.parentNode.parentNode.rows[newCellRowIndex] ) ; 571 } 555 572 556 573 // 2. +1 to rowSpan for all cells crossing currentCell's row. 557 574 for ( var i = 0 ; i < tableMap[currentRowIndex].length ; ) … … 615 632 // The difference here is that the "spanned" cells (colSpan and rowSpan) are duplicated on the matrix 616 633 // cells that are "spanned". For example, a row with 3 cells where the second cell has colSpan=2 and rowSpan=3 617 634 // 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 635 // Cell1, Cell2, Cell2, Cell3 636 // Cell4, Cell2, Cell2, Cell5 637 // Cell6, Cell2, Cell2, Cell7 620 638 FCKTableHandler._CreateTableMap = function( refCell ) 621 639 { 622 // It's really a tbody, thead or tfoot. This is only temporary. 623 var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode ) ; 640 var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode.parentNode ) ; 624 641 625 642 var aRows = table.rows ; 626 643 … … 673 690 // for storing the calculated rowSpan in IE. 674 691 var rowSpanAttr = FCKBrowserInfo.IsIE ? "_fckrowspan" : "rowSpan" ; 675 692 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 683 693 // Disconnect all the cells in tableMap from their parents, set all colSpan and rowSpan attributes to 1. 684 694 for ( var i = 0 ; i < tableMap.length ; i++ ) 685 695 { … … 764 774 if ( cell.rowSpan == 1 ) 765 775 cell.removeAttribute( 'rowspan' ) ; 766 776 } 767 table.appendChild( rowObj ) ; 777 if ( FCKBrowserInfo.IsIE ) 778 { 779 table.rows[i].replaceNode( rowObj ) ; 780 } 781 else 782 { 783 table.rows[i].innerHTML = '' ; 784 FCKDomTools.MoveChildren( rowObj, table.rows[i] ) ; 785 } 768 786 } 769 787 } 770 788