diff --git a/plugins/tabletools/plugin.js b/plugins/tabletools/plugin.js index 2adcd026ef7..dedcc85d445 100644 --- a/plugins/tabletools/plugin.js +++ b/plugins/tabletools/plugin.js @@ -296,7 +296,6 @@ } function deleteColumns( selection ) { - // debugger; var ranges = selection.getRanges(), cells = getSelectedCells( selection ), firstCell = cells[ 0 ], @@ -314,7 +313,7 @@ // #577 // Map might contain multiple times this same element, because of existings collspan. // We don't want to overwrite startIndex in such situation and take first one. - if ( !startColIndex && map[ i ][ j ] == firstCell.$ ) { + if ( startColIndex === undefined && map[ i ][ j ] == firstCell.$ ) { startColIndex = j; } if ( map[ i ][ j ] == lastCell.$ ) { diff --git a/tests/plugins/tabletools/columndeletion.html b/tests/plugins/tabletools/columndeletion.html new file mode 100644 index 00000000000..c4c7e0bb6b4 --- /dev/null +++ b/tests/plugins/tabletools/columndeletion.html @@ -0,0 +1,331 @@ + + + + + + + + + + + + + diff --git a/tests/plugins/tabletools/columndeletion.js b/tests/plugins/tabletools/columndeletion.js new file mode 100644 index 00000000000..0243a3422c0 --- /dev/null +++ b/tests/plugins/tabletools/columndeletion.js @@ -0,0 +1,74 @@ +/* bender-tags: editor,unit */ +/* bender-ckeditor-plugins: wysiwygarea, table, tabletools, tableselection */ + +( function() { + 'use strict'; + + bender.editor = true; + + bender.test( { + doTest: function( name, command ) { + var bot = this.editorBot; + bender.tools.testInputOut( name, function( source, expected ) { + bot.setHtmlWithSelection( source ); + bot.execCommand( command ); + + var output = bot.getData( true ); + output = output.replace( /\u00a0/g, ' ' ); + assert.areSame( bender.tools.compatHtml( expected ), output ); + } ); + }, + + // #577 + 'test remove first column': function() { + // tests requires tableselection + if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) || bender.tools.env.mobile ) { + assert.ignore(); + } + this.doTest( 'table-1', 'columnDelete' ); + }, + + 'test remove 2 last columns by single row selection': function() { + if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) || bender.tools.env.mobile ) { + assert.ignore(); + } + this.doTest( 'table-2', 'columnDelete' ); + }, + + 'test remove selection collspan': function() { + if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) || bender.tools.env.mobile ) { + assert.ignore(); + } + this.doTest( 'table-3', 'columnDelete' ); + }, + + 'test remove single column under collspan': function() { + if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) || bender.tools.env.mobile ) { + assert.ignore(); + } + this.doTest( 'table-4', 'columnDelete' ); + }, + + 'test remove middle columns half with 2 collspans': function() { + if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) || bender.tools.env.mobile ) { + assert.ignore(); + } + this.doTest( 'table-5', 'columnDelete' ); + }, + + 'test remove multirange selection under collspan': function() { + if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) || bender.tools.env.mobile ) { + assert.ignore(); + } + this.doTest( 'table-6', 'columnDelete' ); + }, + + 'test remove entire table by column delete': function() { + if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 11 ) || bender.tools.env.mobile ) { + assert.ignore(); + } + this.doTest( 'table-7', 'columnDelete' ); + } + + } ); +} )(); diff --git a/tests/plugins/tabletools/manual/columndeletionerror.html b/tests/plugins/tabletools/manual/columndeletionerror.html new file mode 100644 index 00000000000..ee6d81d291c --- /dev/null +++ b/tests/plugins/tabletools/manual/columndeletionerror.html @@ -0,0 +1,104 @@ + + + diff --git a/tests/plugins/tabletools/manual/columndeletionerror.md b/tests/plugins/tabletools/manual/columndeletionerror.md new file mode 100644 index 00000000000..817c557a7df --- /dev/null +++ b/tests/plugins/tabletools/manual/columndeletionerror.md @@ -0,0 +1,14 @@ +@bender-tags: 4.7.2, bug, 577 +@bender-ui: collapsed +@bender-ckeditor-plugins: wysiwygarea, toolbar, table, tabletools, tableselection, contextmenu, undo + +1. Open browser console. +1. Select some cells somwhere under merged header. +1. Selection should use `tableselection` plugin. +1. Right click to open cntentxt menu. +1. Select Column -> Delete Column. +1. You can use `Undo` command and try remove different columns. + +**Expected:** Columns are deleted. There is no error in the console. + +**Unexpected:** Error is thrown in a console. Columns are not removed.