Przeglądaj źródła

Merge pull request #289 from ckeditor/i/5882

Fix: Inserting table column at the first col-row spanned cell should work properly. Closes ckeditor/ckeditor5#5882.
Maciej 5 lat temu
rodzic
commit
cceca4932b

+ 1 - 1
packages/ckeditor5-table/src/tableutils.js

@@ -228,7 +228,7 @@ export default class TableUtils extends Plugin {
 				const rowspan = parseInt( cell.getAttribute( 'rowspan' ) || 1 );
 				const colspan = parseInt( cell.getAttribute( 'colspan' ) || 1 );
 
-				if ( cell.index !== insertAt && colspan > 1 ) {
+				if ( cellIndex !== insertAt && colspan > 1 ) {
 					// If column is different than `insertAt`, it is a cell that spans over an inserted column (cell "a" & "i").
 					// For such cells expand them by a number of columns inserted.
 					writer.setAttribute( 'colspan', colspan + columnsToInsert, cell );

+ 18 - 0
packages/ckeditor5-table/tests/tableutils.js

@@ -272,6 +272,24 @@ describe( 'TableUtils', () => {
 			] ) );
 		} );
 
+		it( 'should properly insert column at beginning of row-col-spanned cell', () => {
+			setData( model, modelTable( [
+				[ '11', '12', '13' ],
+				[ '21', { colspan: 2, rowspan: 2, contents: '22[]' } ],
+				[ '31' ],
+				[ '41', '42', '43' ]
+			] ) );
+
+			tableUtils.insertColumns( root.getNodeByPath( [ 0 ] ), { at: 1, columns: 1 } );
+
+			assertEqualMarkup( getData( model ), modelTable( [
+				[ '11', '', '12', '13' ],
+				[ '21', '', { colspan: 2, rowspan: 2, contents: '22[]' } ],
+				[ '31', '' ],
+				[ '41', '', '42', '43' ]
+			] ) );
+		} );
+
 		it( 'should update table heading columns attribute when inserting column in headings section', () => {
 			setData( model, modelTable( [
 				[ '11[]', '12' ],