Browse Source

Fixed: The split cell vertically and horizontally was wrongly used in code.

Maciej Gołaszewski 7 years ago
parent
commit
88b65d4fa3

+ 3 - 3
packages/ckeditor5-table/src/commands/settableheaderscommand.js

@@ -53,7 +53,7 @@ export default class SetTableHeadersCommand extends Command {
 				const cellsToSplit = getOverlappingCells( table, rowsToSet, currentHeadingRows );
 
 				for ( const cell of cellsToSplit ) {
-					splitVertically( cell, rowsToSet, writer );
+					splitHorizontally( cell, rowsToSet, writer );
 				}
 			}
 
@@ -95,12 +95,12 @@ function updateTableAttribute( table, attributeName, newValue, writer ) {
 	}
 }
 
-// Splits table cell vertically.
+// Splits table cell horizontally.
 //
 // @param {module:engine/model/element~Element} tableCell
 // @param {Number} headingRows
 // @param {module:engine/model/writer~Writer} writer
-function splitVertically( tableCell, headingRows, writer ) {
+function splitHorizontally( tableCell, headingRows, writer ) {
 	const tableRow = tableCell.parent;
 	const table = tableRow.parent;
 	const rowIndex = tableRow.index;

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

@@ -189,12 +189,12 @@ export default class TableUtils extends Plugin {
 	}
 
 	/**
-	 * Divides table cell horizontally into several ones.
+	 * Divides table cell vertically into several ones.
 	 *
 	 * @param {module:engine/model/element~Element} tableCell
 	 * @param {Number} numberOfCells
 	 */
-	splitCellHorizontally( tableCell, numberOfCells = 2 ) {
+	splitCellVertically( tableCell, numberOfCells = 2 ) {
 		const model = this.editor.model;
 		const table = getParentTable( tableCell );
 
@@ -249,7 +249,7 @@ export default class TableUtils extends Plugin {
 	 * @param {module:engine/model/element~Element} tableCell
 	 * @param {Number} numberOfCells
 	 */
-	splitCellVertically( tableCell, numberOfCells = 2 ) {
+	splitCellHorizontally( tableCell, numberOfCells = 2 ) {
 		const model = this.editor.model;
 
 		const table = getParentTable( tableCell );

+ 4 - 4
packages/ckeditor5-table/tests/commands/splitcellcommand.js

@@ -71,9 +71,9 @@ describe( 'SplitCellCommand', () => {
 		return editor.destroy();
 	} );
 
-	describe( 'direction=horizontally', () => {
+	describe( 'direction=vertically', () => {
 		beforeEach( () => {
-			command = new SplitCellCommand( editor, { direction: 'horizontally' } );
+			command = new SplitCellCommand( editor, { direction: 'vertically' } );
 		} );
 
 		describe( 'isEnabled', () => {
@@ -175,9 +175,9 @@ describe( 'SplitCellCommand', () => {
 		} );
 	} );
 
-	describe( 'direction=vertically', () => {
+	describe( 'direction=horizontally', () => {
 		beforeEach( () => {
-			command = new SplitCellCommand( editor, { direction: 'vertically' } );
+			command = new SplitCellCommand( editor, { direction: 'horizontally' } );
 		} );
 
 		describe( 'isEnabled', () => {

+ 17 - 17
packages/ckeditor5-table/tests/tableutils.js

@@ -410,7 +410,7 @@ describe( 'TableUtils', () => {
 		} );
 	} );
 
-	describe( 'splitCellHorizontally()', () => {
+	describe( 'splitCellVertically()', () => {
 		it( 'should split table cell to given table cells number', () => {
 			setData( model, modelTable( [
 				[ '00', '01', '02' ],
@@ -419,7 +419,7 @@ describe( 'TableUtils', () => {
 				[ { colspan: 2, contents: '30' }, '32' ]
 			] ) );
 
-			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 1 ] ), 3 );
+			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 1 ] ), 3 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', { colspan: 3, contents: '01' }, '02' ],
@@ -437,7 +437,7 @@ describe( 'TableUtils', () => {
 				[ { colspan: 2, contents: '30' }, '32' ]
 			] ) );
 
-			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 1 ] ) );
+			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 1 ] ) );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', { colspan: 2, contents: '01' }, '02' ],
@@ -455,7 +455,7 @@ describe( 'TableUtils', () => {
 				[ { colspan: 2, contents: '30' }, '32' ]
 			] ) );
 
-			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 2, 1 ] ), 2 );
+			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 2, 1 ] ), 2 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01', '02' ],
@@ -471,7 +471,7 @@ describe( 'TableUtils', () => {
 				[ { colspan: 3, contents: '10[]' } ]
 			] ) );
 
-			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 0 ] ), 2 );
+			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 0 ] ), 2 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01', '02' ],
@@ -485,7 +485,7 @@ describe( 'TableUtils', () => {
 				[ { colspan: 4, contents: '10[]' } ]
 			] ) );
 
-			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 0 ] ), 2 );
+			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 0 ] ), 2 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01', '02', '03' ],
@@ -500,7 +500,7 @@ describe( 'TableUtils', () => {
 				[ '25' ]
 			] ) );
 
-			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 0 ] ), 2 );
+			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 0 ] ), 2 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01', '02', '03', '04', '05' ],
@@ -510,7 +510,7 @@ describe( 'TableUtils', () => {
 		} );
 	} );
 
-	describe( 'splitCellVertically()', () => {
+	describe( 'splitCellHorizontally()', () => {
 		it( 'should split table cell to default table cells number', () => {
 			setData( model, modelTable( [
 				[ '00', '01', '02' ],
@@ -518,7 +518,7 @@ describe( 'TableUtils', () => {
 				[ '20', '21', '22' ]
 			] ) );
 
-			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 1 ] ) );
+			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 1 ] ) );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01', '02' ],
@@ -535,7 +535,7 @@ describe( 'TableUtils', () => {
 				[ '20', '21', '22' ]
 			] ) );
 
-			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 1 ] ), 4 );
+			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 1 ] ), 4 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01', '02' ],
@@ -554,7 +554,7 @@ describe( 'TableUtils', () => {
 				[ '20', '21' ]
 			] ) );
 
-			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 1, 0 ] ), 3 );
+			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 1, 0 ] ), 3 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ { rowspan: 4, contents: '00' }, '01', { rowspan: 5, contents: '02' } ],
@@ -574,7 +574,7 @@ describe( 'TableUtils', () => {
 
 			const tableCell = root.getNodeByPath( [ 0, 0, 1 ] );
 
-			tableUtils.splitCellVertically( tableCell, 2 );
+			tableUtils.splitCellHorizontally( tableCell, 2 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01[]' ],
@@ -592,7 +592,7 @@ describe( 'TableUtils', () => {
 
 			const tableCell = root.getNodeByPath( [ 0, 0, 1 ] );
 
-			tableUtils.splitCellVertically( tableCell, 2 );
+			tableUtils.splitCellHorizontally( tableCell, 2 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', { colspan: 2, contents: '01[]' } ],
@@ -615,7 +615,7 @@ describe( 'TableUtils', () => {
 
 			const tableCell = root.getNodeByPath( [ 0, 0, 1 ] );
 
-			tableUtils.splitCellVertically( tableCell, 3 );
+			tableUtils.splitCellHorizontally( tableCell, 3 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', { rowspan: 3, contents: '01[]' } ],
@@ -638,7 +638,7 @@ describe( 'TableUtils', () => {
 
 			const tableCell = root.getNodeByPath( [ 0, 0, 1 ] );
 
-			tableUtils.splitCellVertically( tableCell, 3 );
+			tableUtils.splitCellHorizontally( tableCell, 3 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ { rowspan: 2, contents: '00' }, '01[]' ],
@@ -656,7 +656,7 @@ describe( 'TableUtils', () => {
 
 			const tableCell = root.getNodeByPath( [ 0, 0, 1 ] );
 
-			tableUtils.splitCellVertically( tableCell, 3 );
+			tableUtils.splitCellHorizontally( tableCell, 3 );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ { rowspan: 3, contents: '00' }, { colspan: 2, contents: '01[]' } ],
@@ -673,7 +673,7 @@ describe( 'TableUtils', () => {
 				[ '20', '21', '22' ]
 			], { headingRows: 1 } ) );
 
-			tableUtils.splitCellVertically( root.getNodeByPath( [ 0, 0, 0 ] ) );
+			tableUtils.splitCellHorizontally( root.getNodeByPath( [ 0, 0, 0 ] ) );
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00[]', { rowspan: 2, contents: '01' }, { rowspan: 2, contents: '02' } ],