Opened 12 years ago

Last modified 8 years ago

#9020 confirmed Bug

"vertical split a cell" works error when the row contains "colpan>1" cells

Reported by: tengshengbo Owned by:
Priority: Normal Milestone:
Component: Core : Tables Version: 3.1
Keywords: HasPatch Support Cc:

Description (last modified by Jakub Ś)

Follow this simple steps:

  1. create a table with 3 rows, 3 columns.
  2. merge the first two cells in the first row.
  3. veritical split the last cell(the cell after the merged cell) in the first row.

The table structure becomes messy after the third step.
The bug is in "tabletools/plugin.js", cellInRow function. Developer should avoid adding duplicate cells, similar with "cellInCol".

Change History (4)

comment:1 Changed 12 years ago by tengshengbo

My fix for this:

	function cellInRow( tableMap, rowIndex, cell )
	{
		var oRow = tableMap[ rowIndex ];
		if ( typeof cell == 'undefined' ){
			var oRowtemp = [];
			for ( var c = 0; c < oRow.length; c++ )
			{
				oRowtemp.push( oRow[ c ] );
				if ( oRow[ c ].colSpan > 1 )
					c += oRow[ c ].colSpan - 1;
			}
			return oRowtemp;
		}
			

		for ( var c = 0 ; oRow && c < oRow.length ; c++ )
		{
			if ( cell.is && oRow[c] == cell.$ )
				return c;
			else if ( c == cell )
				return new CKEDITOR.dom.element( oRow[ c ] );
		}
		return cell.is ? -1 : null;
	}
Last edited 12 years ago by Jakub Ś (previous) (diff)

comment:2 Changed 12 years ago by Jakub Ś

Description: modified (diff)
Keywords: table removed

comment:3 Changed 12 years ago by Jakub Ś

Keywords: HasPatch added
Status: newconfirmed
Version: 3.6.33.1

Issue reproducible in all browsers from CKEditor 3.1.

The same broken table structure is produced it TC presented in #8177. Perhaps these two bugs use the same invalid code and they can be fixed with one patch.

Last edited 12 years ago by Jakub Ś (previous) (diff)

comment:4 Changed 8 years ago by Jakub Ś

Keywords: Support added

This ticket has also been reported on our support channel.

---

There are two possible sources of this problem. When you start with this table:

<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
	<tbody>
		<tr>
			<td>11</td>
			<td>12</td>
			<td>13</td>
		</tr>
		<tr>
			<td>21</td>
			<td>22</td>
			<td>23</td>
		</tr>
		<tr>
			<td>31</td>
			<td>32</td>
			<td>33</td>
		</tr>
	</tbody>
</table>

and Merge cell 11 Right, you will get rowspan="1" assigned to cell 1112. This assignment is really not necessary and is the first source of the problem.

<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
	<tbody>
		<tr>
			<td colspan="2" rowspan="1">1112</td>
			<td>13</td>
		</tr>
		<tr>
			<td>21</td>
			<td>22</td>
			<td>23</td>
		</tr>
		<tr>
			<td>31</td>
			<td>32</td>
			<td>33</td>
		</tr>
	</tbody>
</table>

When you split vertically cell 13, new row is created and 2 is blindly added to rowspan value of cell 1112. This is another possible source of the problem.

<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
	<tbody>
		<tr>
			<td colspan="2" rowspan="3">1112</td>
			<td>13</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>21</td>
			<td>22</td>
			<td>23</td>
		</tr>
		<tr>
			<td>31</td>
			<td>32</td>
			<td>33</td>
		</tr>
	</tbody>
</table>

Either there should be no rowspan assignment when merging cells or rowspan value should be analysed when cell is split.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy