Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
ckeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vanilla ckeditor-3.6.4
[ckeditor.git]
/
_source
/
plugins
/
tabletools
/
plugin.js
diff --git
a/_source/plugins/tabletools/plugin.js
b/_source/plugins/tabletools/plugin.js
index
cacc8cf
..
3c4fd01
100644
(file)
--- a/
_source/plugins/tabletools/plugin.js
+++ b/
_source/plugins/tabletools/plugin.js
@@
-1,5
+1,5
@@
/*
\r
/*
\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
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
\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
var ranges = selection.getRanges();
\r
var retval = [];
\r
var database = {};
\r
@@
-60,8
+56,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
// 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
{
\r
CKEDITOR.dom.element.setMarker( database, parent, 'selected_cell', true );
\r
retval.push( parent );
\r
@@
-72,9
+68,6
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
\r
CKEDITOR.dom.element.clearAllMarkers( database );
\r
\r
\r
CKEDITOR.dom.element.clearAllMarkers( database );
\r
\r
- // Restore selection position.
\r
- selection.selectBookmarks( bookmarks );
\r
-
\r
return retval;
\r
}
\r
\r
return retval;
\r
}
\r
\r
@@
-135,7
+128,7
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
width = map[0].length;
\r
\r
var newRow = doc.createElement( 'tr' );
\r
width = map[0].length;
\r
\r
var newRow = doc.createElement( 'tr' );
\r
- for ( var i = 0; i < width; i++ )
\r
+ for ( var i = 0; cloneRow[ i ] && i < width; i++ )
\r
{
\r
var cell;
\r
// Check whether there's a spanning row here, do not break it.
\r
{
\r
var cell;
\r
// Check whether there's a spanning row here, do not break it.
\r
@@
-215,7
+208,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
// 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
\r
for ( i = rowsToDelete.length ; i >= 0 ; i-- )
\r
deleteRows( rowsToDelete[ i ] );
\r
@@
-341,16
+334,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
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
\r
- j += cell.$.rowSpan - 1;
\r
+ j += cell.$.rowSpan - 1;
\r
\r
\r
- if ( !row.$.cells.length )
\r
- rowsToDelete.push( row );
\r
+ if ( !row.$.cells.length )
\r
+ rowsToDelete.push( row );
\r
+ }
\r
}
\r
}
\r
\r
}
\r
}
\r
\r
@@
-487,21
+483,19
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
return cell.is ? -1 : null;
\r
}
\r
\r
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
{
\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
\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
}
\r
\r
function mergeCells( selection, mergeDirection, isDetect )
\r
@@
-777,6
+771,8
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
\r
CKEDITOR.plugins.tabletools =
\r
{
\r
\r
CKEDITOR.plugins.tabletools =
\r
{
\r
+ requires : [ 'table', 'dialog', 'contextmenu' ],
\r
+
\r
init : function( editor )
\r
{
\r
var lang = editor.lang.table;
\r
init : function( editor )
\r
{
\r
var lang = editor.lang.table;
\r
@@
-795,18
+791,15
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
if ( !table )
\r
return;
\r
\r
if ( !table )
\r
return;
\r
\r
- // Maintain the selection point at where the table was deleted.
\r
- selection.selectElement( table );
\r
- var range = selection.getRanges()[0];
\r
- range.collapse();
\r
- selection.selectRanges( [ range ] );
\r
-
\r
// If the table's parent has only one child remove it as well (unless it's the body or a table cell) (#5416, #6289)
\r
var parent = table.getParent();
\r
if ( parent.getChildCount() == 1 && !parent.is( 'body', 'td', 'th' ) )
\r
// If the table's parent has only one child remove it as well (unless it's the body or a table cell) (#5416, #6289)
\r
var parent = table.getParent();
\r
if ( parent.getChildCount() == 1 && !parent.is( 'body', 'td', 'th' ) )
\r
- parent.remove();
\r
- else
\r
- table.remove();
\r
+ table = parent;
\r
+
\r
+ var range = new CKEDITOR.dom.range( editor.document );
\r
+ range.moveToPosition( table, CKEDITOR.POSITION_BEFORE_START );
\r
+ table.remove();
\r
+ range.select();
\r
}
\r
} );
\r
\r
}
\r
} );
\r
\r