浏览代码

Fix: Merging down rowspanned cell from the head with a cell in body is now disabled.

Maciej Gołaszewski 7 年之前
父节点
当前提交
a4d01e6bfa

+ 5 - 1
packages/ckeditor5-table/src/commands/mergecellcommand.js

@@ -199,10 +199,14 @@ function getVerticalCell( tableCell, direction ) {
 		return;
 	}
 
+	const rowspan = parseInt( tableCell.getAttribute( 'rowspan' ) || 1 );
 	const headingRows = table.getAttribute( 'headingRows' ) || 0;
 
+	const isMergeWithBodyCell = direction == 'down' && ( rowIndex + rowspan ) === headingRows;
+	const isMergeWithHeadCell = direction == 'up' && rowIndex === headingRows;
+
 	// Don't search for mergeable cell if direction points out of the current table section.
-	if ( headingRows && ( ( direction == 'down' && rowIndex === headingRows - 1 ) || ( direction == 'up' && rowIndex === headingRows ) ) ) {
+	if ( headingRows && ( isMergeWithBodyCell || isMergeWithHeadCell ) ) {
 		return;
 	}
 

+ 10 - 0
packages/ckeditor5-table/tests/commands/mergecellcommand.js

@@ -413,6 +413,16 @@ describe( 'MergeCellCommand', () => {
 				expect( command.value ).to.be.undefined;
 			} );
 
+			it( 'should be undefined if mergable cell is in other table section', () => {
+				setData( model, modelTable( [
+					[ { rowspan: 2, contents: '00[]' }, '02' ],
+					[ '12' ],
+					[ '21', '22' ]
+				], { headingRows: 2 } ) );
+
+				expect( command.value ).to.be.undefined;
+			} );
+
 			it( 'should be undefined if not in a cell', () => {
 				setData( model, '<p>11[]</p>' );