JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.1
[ckeditor.git] / _source / plugins / tabletools / plugin.js
index b92fb05..7b52599 100644 (file)
@@ -60,8 +60,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        // So we have to take care to include a td we've entered only when we've\r
                                        // walked into its children.\r
 \r
-                                       var parent = node.getParent();\r
-                                       if ( parent && cellNodeRegex.test( parent.getName() ) && !parent.getCustomData( 'selected_cell' ) )\r
+                                       var parent = node.getAscendant( 'td' ) || node.getAscendant( 'th' );\r
+                                       if ( parent && !parent.getCustomData( 'selected_cell' ) )\r
                                        {\r
                                                CKEDITOR.dom.element.setMarker( database, parent, 'selected_cell', true );\r
                                                retval.push( parent );\r
@@ -215,7 +215,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        // 1. Into next sibling row if any;\r
                        // 2. Into previous sibling row if any;\r
                        // 3. Into table's parent element if it's the very last row.\r
-                       var cursorPosition =  new CKEDITOR.dom.element( rows[ startRowIndex ] || rows[ startRowIndex - 1 ] || table.$.parentNode );\r
+                       var cursorPosition =  new CKEDITOR.dom.element( rows[ endRowIndex + 1 ] || ( startRowIndex > 0 ? rows[  startRowIndex - 1 ] : null ) || table.$.parentNode );\r
 \r
                        for ( i = rowsToDelete.length ; i >= 0 ; i-- )\r
                                deleteRows( rowsToDelete[ i ] );\r
@@ -341,16 +341,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        row = new CKEDITOR.dom.element( table.$.rows[ j ] ),\r
                                        cell = new CKEDITOR.dom.element( mapRow[ i ] );\r
 \r
-                               if ( cell.$.colSpan == 1 )\r
-                                       cell.remove();\r
-                               // Reduce the col spans.\r
-                               else\r
-                                       cell.$.colSpan -= 1;\r
+                               if ( cell.$ )\r
+                               {\r
+                                       if ( cell.$.colSpan == 1 )\r
+                                               cell.remove();\r
+                                       // Reduce the col spans.\r
+                                       else\r
+                                               cell.$.colSpan -= 1;\r
 \r
-                               j += cell.$.rowSpan - 1;\r
+                                       j += cell.$.rowSpan - 1;\r
 \r
-                               if ( !row.$.cells.length )\r
-                                       rowsToDelete.push( row );\r
+                                       if ( !row.$.cells.length )\r
+                                               rowsToDelete.push( row );\r
+                               }\r
                        }\r
                }\r
 \r