Index: _whatsnew.html
===================================================================
--- _whatsnew.html (revision 2371)
+++ _whatsnew.html (working copy)
@@ -50,6 +50,8 @@
character inside text wasn't encoded in Opera and Safari.
[#2467] Fixed JavaScript
error with the fit window command in source mode.
+ [#2472] Splitting a TH
+ will create a two TH, not a TH and a TD.
See previous versions history
Index: editor/_source/internals/fcktablehandler.js
===================================================================
--- editor/_source/internals/fcktablehandler.js (revision 2371)
+++ editor/_source/internals/fcktablehandler.js (working copy)
@@ -298,7 +298,7 @@
this._MarkCells( cells, '_CellSelected' ) ;
- var tableMap = this._CreateTableMap( cells[0].parentNode.parentNode ) ;
+ var tableMap = this._CreateTableMap( cells[0] ) ;
var rowIdx = cells[0].parentNode.rowIndex ;
var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, cells[0] ) ;
@@ -357,7 +357,7 @@
// Assume the selected cells are already in a rectangular geometry.
// Because the checking is already done by FCKTableCommand.
var refCell = cells[0] ;
- var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
+ var tableMap = this._CreateTableMap( refCell ) ;
var rowIdx = refCell.parentNode.rowIndex ;
var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
@@ -450,17 +450,17 @@
return ;
var refCell = cells[0] ;
- var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
+ var tableMap = this._CreateTableMap( refCell ) ;
var rowIdx = refCell.parentNode.rowIndex ;
var colIdx = FCKTableHandler._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
var cellSpan = isNaN( refCell.colSpan ) ? 1 : refCell.colSpan ;
if ( cellSpan > 1 )
{
- // Splittng a multi-column cell - original cell gets ceil(colSpan/2) columns,
+ // Splitting a multi-column cell - original cell gets ceil(colSpan/2) columns,
// new cell gets floor(colSpan/2).
var newCellSpan = Math.ceil( cellSpan / 2 ) ;
- var newCell = FCKTools.GetElementDocument( refCell ).createElement( 'td' ) ;
+ var newCell = FCK.EditorDocument.createElement( refCell.nodeName ) ;
if ( FCKBrowserInfo.IsGeckoLike )
FCKTools.AppendBogusBr( newCell ) ;
var startIdx = colIdx + newCellSpan ;
@@ -488,7 +488,7 @@
if ( tableMap[i][colIdx] == refCell )
{
newRow.push( refCell ) ;
- newRow.push( FCKTools.GetElementDocument( refCell ).createElement( 'td' ) ) ;
+ newRow.push( FCK.EditorDocument.createElement( refCell.nodeName ) ) ;
if ( FCKBrowserInfo.IsGeckoLike )
FCKTools.AppendBogusBr( newRow[newRow.length - 1] ) ;
}
@@ -514,10 +514,10 @@
return ;
var currentCell = cells[0] ;
- var tableMap = this._CreateTableMap( currentCell.parentNode.parentNode ) ;
- var cellIndex = FCKTableHandler._GetCellIndexSpan( tableMap, currentCell.parentNode.rowIndex, currentCell ) ;
+ var tableMap = this._CreateTableMap( currentCell ) ;
+ var currentRowIndex = currentCell.parentNode.rowIndex ;
+ var cellIndex = FCKTableHandler._GetCellIndexSpan( tableMap, currentRowIndex, currentCell ) ;
var currentRowSpan = currentCell.rowSpan ;
- var currentRowIndex = currentCell.parentNode.rowIndex ;
if ( isNaN( currentRowSpan ) )
currentRowSpan = 1 ;
@@ -528,18 +528,19 @@
// 2. Find the appropriate place to insert a new cell at the next row.
var newCellRowIndex = currentRowIndex + Math.ceil( currentRowSpan / 2 ) ;
+ var oRow = tableMap[newCellRowIndex] ;
var insertMarker = null ;
- for ( var i = cellIndex+1 ; i < tableMap[newCellRowIndex].length ; i++ )
+ for ( var i = cellIndex+1 ; i < oRow.length ; i++ )
{
- if ( tableMap[newCellRowIndex][i].parentNode.rowIndex == newCellRowIndex )
+ if ( oRow[i].parentNode.rowIndex == newCellRowIndex )
{
- insertMarker = tableMap[newCellRowIndex][i] ;
+ insertMarker = oRow[i] ;
break ;
}
}
// 3. Insert the new cell to the indicated place, with the appropriate rowSpan, next row.
- var newCell = FCK.EditorDocument.createElement( 'td' ) ;
+ var newCell = FCK.EditorDocument.createElement( currentCell.nodeName ) ;
newCell.rowSpan = Math.floor( currentRowSpan / 2 ) ;
if ( FCKBrowserInfo.IsGeckoLike )
FCKTools.AppendBogusBr( newCell ) ;
@@ -575,7 +576,7 @@
}
// 3. Insert a new cell to new row.
- var newCell = FCK.EditorDocument.createElement( 'td' ) ;
+ var newCell = FCK.EditorDocument.createElement( currentCell.nodeName ) ;
if ( FCKBrowserInfo.IsGeckoLike )
FCKTools.AppendBogusBr( newCell ) ;
newRow.appendChild( newCell ) ;
@@ -631,10 +632,13 @@
// The difference here is that the "spanned" cells (colSpan and rowSpan) are duplicated on the matrix
// cells that are "spanned". For example, a row with 3 cells where the second cell has colSpan=2 and rowSpan=3
// will produce a bi-dimensional matrix with the following values (representing the cells):
-// Cell1, Cell2, Cell2, Cell 3
-// Cell4, Cell2, Cell2, Cell 5
-FCKTableHandler._CreateTableMap = function( table )
+// Cell1, Cell2, Cell2, Cell2, Cell 3
+// Cell4, Cell2, Cell2, Cell2, Cell 5
+FCKTableHandler._CreateTableMap = function( refCell )
{
+ // It's really a tbody, thead or tfoot. This is only temporary.
+ var table = (refCell.nodeName == 'TABLE' ? refCell : refCell.parentNode.parentNode ) ;
+
var aRows = table.rows ;
// Row and Column counters.
@@ -819,7 +823,7 @@
return null ;
var refCell = cells[0] ;
- var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
+ var tableMap = this._CreateTableMap( refCell ) ;
var rowIdx = refCell.parentNode.rowIndex ;
var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
var nextColIdx = colIdx + ( isNaN( refCell.colSpan ) ? 1 : refCell.colSpan ) ;
@@ -847,7 +851,7 @@
return null ;
var refCell = cells[0] ;
- var tableMap = this._CreateTableMap( refCell.parentNode.parentNode ) ;
+ var tableMap = this._CreateTableMap( refCell ) ;
var rowIdx = refCell.parentNode.rowIndex ;
var colIdx = this._GetCellIndexSpan( tableMap, rowIdx, refCell ) ;
var newRowIdx = rowIdx + ( isNaN( refCell.rowSpan ) ? 1 : refCell.rowSpan ) ;