Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit cb77e38

Browse files
authored
Merge pull request #91 from ckeditor/t/86
Fix: Merging down rowspanned cell from the head with a cell in body is now disabled. Closes #86.
2 parents a3ea18d + 76d72ae commit cb77e38

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/commands/mergecellcommand.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,14 @@ function getVerticalCell( tableCell, direction ) {
199199
return;
200200
}
201201

202+
const rowspan = parseInt( tableCell.getAttribute( 'rowspan' ) || 1 );
202203
const headingRows = table.getAttribute( 'headingRows' ) || 0;
203204

205+
const isMergeWithBodyCell = direction == 'down' && ( rowIndex + rowspan ) === headingRows;
206+
const isMergeWithHeadCell = direction == 'up' && rowIndex === headingRows;
207+
204208
// Don't search for mergeable cell if direction points out of the current table section.
205-
if ( headingRows && ( ( direction == 'down' && rowIndex === headingRows - 1 ) || ( direction == 'up' && rowIndex === headingRows ) ) ) {
209+
if ( headingRows && ( isMergeWithBodyCell || isMergeWithHeadCell ) ) {
206210
return;
207211
}
208212

tests/commands/mergecellcommand.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,16 @@ describe( 'MergeCellCommand', () => {
413413
expect( command.value ).to.be.undefined;
414414
} );
415415

416+
it( 'should be undefined if mergable cell is in other table section', () => {
417+
setData( model, modelTable( [
418+
[ { rowspan: 2, contents: '00[]' }, '02' ],
419+
[ '12' ],
420+
[ '21', '22' ]
421+
], { headingRows: 2 } ) );
422+
423+
expect( command.value ).to.be.undefined;
424+
} );
425+
416426
it( 'should be undefined if not in a cell', () => {
417427
setData( model, '<p>11[]</p>' );
418428

0 commit comments

Comments
 (0)