JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.5
[ckeditor.git] / _source / plugins / tabletools / plugin.js
index 3a6511d..520e11d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -9,10 +9,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        function getSelectedCells( selection )\r
        {\r
-               // Walker will try to split text nodes, which will make the current selection\r
-               // invalid. So save bookmarks before doing anything.\r
-               var bookmarks = selection.createBookmarks();\r
-\r
                var ranges = selection.getRanges();\r
                var retval = [];\r
                var database = {};\r
@@ -72,9 +68,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                CKEDITOR.dom.element.clearAllMarkers( database );\r
 \r
-               // Restore selection position.\r
-               selection.selectBookmarks( bookmarks );\r
-\r
                return retval;\r
        }\r
 \r
@@ -282,15 +275,18 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                {\r
                        cloneCol.push( map[ i ][ colIndex ] );\r
                        var nextCell = insertBefore ? map[ i ][ colIndex - 1 ] : map[ i ][ colIndex + 1 ];\r
-                       nextCell && nextCol.push( nextCell );\r
+                       nextCol.push( nextCell );\r
                }\r
 \r
                for ( i = 0; i < height; i++ )\r
                {\r
                        var cell;\r
+\r
+                       if ( !cloneCol[ i ] )\r
+                               continue;\r
+\r
                        // Check whether there's a spanning column here, do not break it.\r
                        if ( cloneCol[ i ].colSpan > 1\r
-                               && nextCol.length\r
                                && nextCol[ i ] == cloneCol[ i ] )\r
                        {\r
                                cell = cloneCol[ i ];\r
@@ -490,21 +486,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                return cell.is ? -1 : null;\r
        }\r
 \r
-       function cellInCol( tableMap, colIndex, cell )\r
+       function cellInCol( tableMap, colIndex )\r
        {\r
                var oCol = [];\r
                for ( var r = 0; r < tableMap.length; r++ )\r
                {\r
                        var row = tableMap[ r ];\r
-                       if ( typeof cell == 'undefined' )\r
-                               oCol.push( row[ colIndex ] );\r
-                       else if ( cell.is && row[ colIndex ] == cell.$ )\r
-                               return r;\r
-                       else if ( r == cell )\r
-                               return new CKEDITOR.dom.element( row[ colIndex ] );\r
-               }\r
+                       oCol.push( row[ colIndex ] );\r
 \r
-               return ( typeof cell == 'undefined' )? oCol : cell.is ? -1 :  null;\r
+                       // Avoid adding duplicate cells.\r
+                       if ( row[ colIndex ].rowSpan > 1 )\r
+                               r += row[ colIndex ].rowSpan - 1;\r
+               }\r
+               return oCol;\r
        }\r
 \r
        function mergeCells( selection, mergeDirection, isDetect )\r
@@ -780,6 +774,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        CKEDITOR.plugins.tabletools =\r
        {\r
+               requires : [ 'table', 'dialog' ],\r
+\r
                init : function( editor )\r
                {\r
                        var lang = editor.lang.table;\r