8
0
Quellcode durchsuchen

Removed unnecessary code.

Kuba Niegowski vor 5 Jahren
Ursprung
Commit
86bdae4df4

+ 5 - 25
packages/ckeditor5-table/src/commands/mergecellscommand.js

@@ -46,19 +46,16 @@ export default class MergeCellsCommand extends Command {
 			const selectedTableCells = getSelectedTableCells( model.document.selection );
 
 			// All cells will be merged into the first one.
-			const firstTableCell = selectedTableCells[ 0 ];
+			const firstTableCell = selectedTableCells.shift();
 
 			// Update target cell dimensions.
-			const { mergeWidth, mergeHeight } = getMergeDimensions( selectedTableCells, tableUtils );
+			const { mergeWidth, mergeHeight } = getMergeDimensions( firstTableCell, selectedTableCells, tableUtils );
 			updateNumericAttribute( 'colspan', mergeWidth, firstTableCell, writer );
 			updateNumericAttribute( 'rowspan', mergeHeight, firstTableCell, writer );
 
-			for ( let i = 1; i < selectedTableCells.length; i++ ) {
-				mergeTableCells( selectedTableCells[ i ], firstTableCell, writer );
+			for ( const tableCell of selectedTableCells ) {
+				mergeTableCells( tableCell, firstTableCell, writer );
 			}
-			// for ( let i = selectedTableCells.length - 1; i > 0; i-- ) {
-			// 	mergeTableCells( selectedTableCells[ i ], selectedTableCells[ i - 1 ], writer );
-			// }
 
 			const table = findAncestor( 'table', firstTableCell );
 
@@ -88,23 +85,6 @@ function mergeTableCells( cellBeingMerged, targetCell, writer ) {
 
 	// Remove merged table cell.
 	writer.remove( cellBeingMerged );
-
-	// 	const positionAfterTargetCell = writer.createPositionAfter( targetCell );
-	// 	const positionBeforeMergedCell = writer.createPositionBefore( cellBeingMerged );
-	//
-	// 	const targetCellWasEmpty = !writer.model.hasContent( targetCell );
-	// 	const mergedCellWasEmpty = !writer.model.hasContent( cellBeingMerged );
-	// 	const positionAtEndOfTargetContent = writer.createPositionAt( targetCell, 'end' );
-	//
-	// 	if ( !positionAfterTargetCell.isEqual( positionBeforeMergedCell ) ) {
-	// 		writer.move( writer.createRangeOn( cellBeingMerged ), positionAfterTargetCell );
-	// 	}
-	//
-	// 	writer.merge( positionAfterTargetCell );
-	//
-	// 	if ( targetCellWasEmpty || mergedCellWasEmpty ) {
-	// 		writer.merge( positionAtEndOfTargetContent );
-	// 	}
 }
 
 // Checks if the passed table cell contains an empty paragraph.
@@ -115,7 +95,7 @@ function isEmpty( tableCell ) {
 	return tableCell.childCount == 1 && tableCell.getChild( 0 ).is( 'paragraph' ) && tableCell.getChild( 0 ).isEmpty;
 }
 
-function getMergeDimensions( [ firstTableCell, ...selectedTableCells ], tableUtils ) {
+function getMergeDimensions( firstTableCell, selectedTableCells, tableUtils ) {
 	let maxWidthOffset = 0;
 	let maxHeightOffset = 0;
 

+ 0 - 49
packages/ckeditor5-undo/tests/undoediting-integration.js

@@ -430,55 +430,6 @@ describe( 'UndoEditing integration', () => {
 
 			undoDisabled();
 		} );
-
-		it.skip( 'move, merge and undo', () => {
-			// Add a "div feature".
-			model.schema.register( 'div', {
-				allowWhere: '$block',
-				allowContentOf: '$root'
-			} );
-
-			editor.conversion.for( 'downcast' ).elementToElement( { model: 'div', view: 'div' } );
-			editor.conversion.for( 'upcast' ).elementToElement( { model: 'div', view: 'div' } );
-
-			input(
-				'<div><paragraph>[]00.</paragraph><paragraph>01.</paragraph><paragraph>02.</paragraph></div>' +
-				'<div><paragraph>10.</paragraph><paragraph>11.</paragraph><paragraph>12.</paragraph></div>'
-			);
-
-			const elements = [
-				root.getNodeByPath( [ 0, 1 ] ),
-				root.getNodeByPath( [ 1, 0 ] ),
-				root.getNodeByPath( [ 1, 1 ] )
-			];
-
-			model.change( writer => {
-				for ( let i = elements.length - 1; i > 0; i-- ) {
-					merge( elements[ i ], elements[ i - 1 ], writer );
-				}
-			} );
-			output(
-				'<div><paragraph>[]00.</paragraph><paragraph>01.10.11.</paragraph><paragraph>02.</paragraph></div>' +
-				'<div><paragraph>12.</paragraph></div>'
-			);
-
-			editor.execute( 'undo' );
-			output(
-				'<div><paragraph>[]00.</paragraph><paragraph>01.</paragraph><paragraph>02.</paragraph></div>' +
-				'<div><paragraph>10.</paragraph><paragraph>11.</paragraph><paragraph>12.</paragraph></div>'
-			);
-
-			function merge( element, targetElement, writer ) {
-				const positionAfterTarget = writer.createPositionAfter( targetElement );
-				const positionBeforeElement = writer.createPositionBefore( element );
-
-				if ( !positionAfterTarget.isEqual( positionBeforeElement ) ) {
-					writer.move( writer.createRangeOn( element ), positionAfterTarget );
-				}
-
-				writer.merge( positionAfterTarget );
-			}
-		} );
 	} );
 
 	// Restoring selection in those examples may be completely off.