|
@@ -59,7 +59,7 @@ import TableWalker from './../tablewalker';
|
|
|
* <td>XYZ<td>
|
|
* <td>XYZ<td>
|
|
|
* </tr>
|
|
* </tr>
|
|
|
* </tbody>
|
|
* </tbody>
|
|
|
- * <table>
|
|
|
|
|
|
|
+ * </table>
|
|
|
*
|
|
*
|
|
|
* In above example the table will be rendered as a table with two rows - one in the header and second one in the body.
|
|
* In above example the table will be rendered as a table with two rows - one in the header and second one in the body.
|
|
|
* The table cell with FOO contents will not expand to the body section so its `rowspan` attribute will be changed to `1` (and as
|
|
* The table cell with FOO contents will not expand to the body section so its `rowspan` attribute will be changed to `1` (and as
|
|
@@ -92,7 +92,7 @@ import TableWalker from './../tablewalker';
|
|
|
* <td>XYZ<td>
|
|
* <td>XYZ<td>
|
|
|
* </tr>
|
|
* </tr>
|
|
|
* </tbody>
|
|
* </tbody>
|
|
|
- * <table>
|
|
|
|
|
|
|
+ * </table>
|
|
|
*
|
|
*
|
|
|
* **Note** The table post-fixer only ensures proper structure without deeper analysis of the nature of a change. As such it might lead
|
|
* **Note** The table post-fixer only ensures proper structure without deeper analysis of the nature of a change. As such it might lead
|
|
|
* to a structure which was not intended by user changes. In particular it will also fix undo steps (in conjunction with collaboration)
|
|
* to a structure which was not intended by user changes. In particular it will also fix undo steps (in conjunction with collaboration)
|
|
@@ -208,17 +208,22 @@ function findCellsToTrim( table ) {
|
|
|
for ( const { row, rowspan, cell } of new TableWalker( table ) ) {
|
|
for ( const { row, rowspan, cell } of new TableWalker( table ) ) {
|
|
|
const maxRows = table.childCount;
|
|
const maxRows = table.childCount;
|
|
|
|
|
|
|
|
|
|
+ // Skip cells that do not expand over its row.
|
|
|
|
|
+ if ( rowspan < 2 ) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if ( headingRows > row ) {
|
|
if ( headingRows > row ) {
|
|
|
if ( row + rowspan > headingRows ) {
|
|
if ( row + rowspan > headingRows ) {
|
|
|
const newRowspan = headingRows - row;
|
|
const newRowspan = headingRows - row;
|
|
|
|
|
|
|
|
- cellsToTrim.push( { cell, rowspan: newRowspan } );
|
|
|
|
|
|
|
+ cellsToTrim.push( { cell, rowspan: newRowspan, old: rowspan } );
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- if ( row + rowspan + headingRows > maxRows ) {
|
|
|
|
|
|
|
+ if ( row + rowspan + headingRows > maxRows + 1 ) {
|
|
|
const newRowspan = maxRows - row - headingRows + 1;
|
|
const newRowspan = maxRows - row - headingRows + 1;
|
|
|
|
|
|
|
|
- cellsToTrim.push( { cell, rowspan: newRowspan } );
|
|
|
|
|
|
|
+ cellsToTrim.push( { cell, rowspan: newRowspan, old: rowspan } );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|