Index: /CKEditor/branches/versions/3.4.x/CHANGES.html
===================================================================
--- /CKEditor/branches/versions/3.4.x/CHANGES.html (revision 6003)
+++ /CKEditor/branches/versions/3.4.x/CHANGES.html (revision 6004)
@@ -91,4 +91,5 @@
#6508 : BiDi: Margin mirroring logic doesn't honor CSS direction.
#6043 : BIDI: When we apply RTL direction to a right aligned Paragraph, Paragraph is not moved to left & Alignment of Paragraph is not changed.
+ #6485 : BIDI: When direction is applied on partial selected list, the style is been incorrectly applied on the entired list.
#6087 : Cursor of input fields in dialog isn't visible in RLT .
#5595 : Extra leading spaces added in preformatted block.
Index: /CKEditor/branches/versions/3.4.x/_source/core/dom/rangelist.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/core/dom/rangelist.js (revision 6003)
+++ /CKEditor/branches/versions/3.4.x/_source/core/dom/rangelist.js (revision 6004)
@@ -1,3 +1,3 @@
-/*
+/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -40,5 +40,8 @@
{
var rangeList = this,
- bookmarks = [],
+ bookmark = CKEDITOR.dom.walker.bookmark(),
+ emptySpaces = CKEDITOR.dom.walker.whitespaces(),
+ guard = function( node ) { return ! ( node.is && node.is( 'tr' ) ); },
+ bookmarks = [],
current;
@@ -50,6 +53,7 @@
/**
* Retrieves the next range in the list.
+ * @param {Boolean} mergeConsequent Whether join two adjacent ranges into single, e.g. consequent table cells.
*/
- getNextRange : function()
+ getNextRange : function( mergeConsequent )
{
current = current == undefined ? 0 : current + 1;
@@ -66,9 +70,56 @@
{
// Make sure bookmark correctness by reverse processing.
- for ( var i = rangeList.length - 1; i > 0; i-- )
+ for ( var i = rangeList.length - 1; i >= 0; i-- )
bookmarks.unshift( rangeList[ i ].createBookmark( true ) );
}
- else
- range.moveToBookmark( bookmarks.shift() );
+
+ if ( mergeConsequent )
+ {
+ // Figure out how many ranges should be merged.
+ var mergeCount = 0;
+ while ( rangeList[ current + mergeCount + 1 ] )
+ {
+ var doc = range.document,
+ found = 0,
+ left = doc.getById( bookmarks[ mergeCount ].endNode ),
+ right = doc.getById( bookmarks[ mergeCount + 1 ].startNode ),
+ next;
+
+ // Check subsequent range.
+ while ( 1 )
+ {
+ next = left.getNextSourceNode( false );
+ if ( !right.equals( next ) )
+ {
+ // This could be yet another bookmark or
+ // walking across block boundaries.
+ if ( bookmark( next ) || ( next.type == CKEDITOR.NODE_ELEMENT && next.isBlockBoundary() ) )
+ {
+ left = next;
+ continue;
+ }
+ }
+ else
+ found = 1;
+
+ break;
+ }
+
+ if ( !found )
+ break;
+
+ mergeCount++;
+ }
+ }
+
+ range.moveToBookmark( bookmarks.shift() );
+
+ // Merge ranges finally after moving to bookmarks.
+ while( mergeCount-- )
+ {
+ var next = rangeList[ ++current ];
+ next.moveToBookmark( bookmarks.shift() );
+ range.setEnd( next.endContainer, next.endOffset );
+ }
}
Index: /CKEditor/branches/versions/3.4.x/_source/core/dom/walker.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/core/dom/walker.js (revision 6003)
+++ /CKEditor/branches/versions/3.4.x/_source/core/dom/walker.js (revision 6004)
@@ -1,3 +1,3 @@
-/*
+/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -386,5 +386,5 @@
// Is bookmark node?
isBookmark = contentOnly ? isBookmark : isBookmark || isBookmarkNode( node );
- return isReject ^ isBookmark;
+ return !! ( isReject ^ isBookmark );
};
};
@@ -400,5 +400,5 @@
var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT )
&& !CKEDITOR.tools.trim( node.getText() );
- return isReject ^ isWhitespace;
+ return !! ( isReject ^ isWhitespace );
};
};
@@ -419,5 +419,5 @@
// all sorts of empty paragraph, e.g.
.
var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight;
- return isReject ^ isInvisible;
+ return !! ( isReject ^ isInvisible );
};
};
Index: /CKEditor/branches/versions/3.4.x/_source/plugins/bidi/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/plugins/bidi/plugin.js (revision 6003)
+++ /CKEditor/branches/versions/3.4.x/_source/plugins/bidi/plugin.js (revision 6004)
@@ -1,3 +1,3 @@
-/*
+/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -6,9 +6,9 @@
(function()
{
- var guardElements = { table:1, ul:1, ol:1, blockquote:1, div:1 },
+ var guardElements = { table:1, tbody: 1, tr:1, ul:1, ol:1, blockquote:1, div:1 },
directSelectionGuardElements = {},
// All guard elements which can have a direction applied on them.
allGuardElements = {};
- CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { tr:1, p:1, div:1, li:1 } );
+ CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { p:1, div:1, li:1 } );
CKEDITOR.tools.extend( allGuardElements, directSelectionGuardElements, { td:1 } );
@@ -131,16 +131,7 @@
}
- function getFullySelected( selection, elements )
- {
- var ancestor = selection.getCommonAncestor();
- if ( ancestor.type != CKEDITOR.NODE_ELEMENT )
- return;
-
- var ranges = selection.getRanges();
-
- // Join multiple ranges.
- var range = new CKEDITOR.dom.range( selection.document );
- range.setStart( ranges[ 0 ].startContainer, ranges[ 0 ].startOffset );
- range.setEnd( ranges[ ranges.length - 1 ].endContainer, ranges[ ranges.length - 1 ].endOffset );
+ function getFullySelected( range, elements )
+ {
+ var ancestor = range.getCommonAncestor( false, true );
range.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS );
@@ -149,9 +140,11 @@
&& range.checkBoundaryOfElement( ancestor, CKEDITOR.END ) )
{
- while ( ancestor.type == CKEDITOR.NODE_ELEMENT
- && !( ancestor.getName() in elements )
- && ancestor.getParent().getChildCount() == 1
+ var parent;
+ while ( ancestor && ancestor.type == CKEDITOR.NODE_ELEMENT
+ && ( parent = ancestor.getParent() )
+ && parent.getChildCount() == 1
+ && ( !( ancestor.getName() in elements ) || ( parent.getName() in elements ) )
)
- ancestor = ancestor.getParent();
+ ancestor = parent;
return ancestor.type == CKEDITOR.NODE_ELEMENT
@@ -172,36 +165,45 @@
{
var database = {};
- // Apply do directly selected elements from guardElements.
- var selectedElement = ranges[ 0 ].getEnclosedNode();
-
- // If this is not our element of interest, apply to fully selected elements from guardElements.
- if ( !selectedElement || selectedElement
- && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
- )
- selectedElement = getFullySelected( selection, guardElements );
-
- if ( selectedElement && !selectedElement.isReadOnly() )
- switchDir( selectedElement, dir, editor, database );
-
+
// Creates bookmarks for selection, as we may split some blocks.
var bookmarks = selection.createBookmarks();
- var iterator,
- block;
-
- for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
+ var rangeIterator = ranges.createIterator(),
+ range,
+ i = 0;
+
+ while ( ( range = rangeIterator.getNextRange( 1 ) ) )
{
- // Array of elements processed as guardElements.
- var processedElements = [];
+ // Apply do directly selected elements from guardElements.
+ var selectedElement = range.getEnclosedNode();
+
+ // If this is not our element of interest, apply to fully selected elements from guardElements.
+ if ( !selectedElement || selectedElement
+ && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
+ )
+ selectedElement = getFullySelected( range, guardElements );
+
+ if ( selectedElement && !selectedElement.isReadOnly() )
+ switchDir( selectedElement, dir, editor, database );
+
+ var iterator,
+ block;
+
// Walker searching for guardElements.
- var walker = new CKEDITOR.dom.walker( ranges[ i ] );
+ var walker = new CKEDITOR.dom.walker( range );
+
+ var start = bookmarks[ i ].startNode,
+ end = bookmarks[ i++ ].endNode;
+
walker.evaluator = function( node )
{
- return node.type == CKEDITOR.NODE_ELEMENT
- && node.getName() in guardElements
- && !( node.getName() == ( enterMode == CKEDITOR.ENTER_P ) ? 'p' : 'div'
- && node.getParent().type == CKEDITOR.NODE_ELEMENT
- && node.getParent().getName() == 'blockquote'
- );
+ return !! ( node.type == CKEDITOR.NODE_ELEMENT
+ && node.getName() in guardElements
+ && !( node.getName() == ( enterMode == CKEDITOR.ENTER_P ) ? 'p' : 'div'
+ && node.getParent().type == CKEDITOR.NODE_ELEMENT
+ && node.getParent().getName() == 'blockquote' )
+ // Element must be fully included in the range as well. (#6485).
+ && node.getPosition( start ) & CKEDITOR.POSITION_FOLLOWING
+ && ( ( node.getPosition( end ) & CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_CONTAINS ) == CKEDITOR.POSITION_PRECEDING ) );
};
@@ -209,16 +211,16 @@
switchDir( block, dir, editor, database );
- iterator = ranges[ i ].createIterator();
+ iterator = range.createIterator();
iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
!block.isReadOnly() && switchDir( block, dir, editor, database );
-
- CKEDITOR.dom.element.clearAllMarkers( database );
-
- editor.forceNextSelectionCheck();
- // Restore selection position.
- selection.selectBookmarks( bookmarks );
}
+
+ CKEDITOR.dom.element.clearAllMarkers( database );
+
+ editor.forceNextSelectionCheck();
+ // Restore selection position.
+ selection.selectBookmarks( bookmarks );
editor.focus();
Index: /CKEditor/branches/versions/3.4.x/_source/plugins/domiterator/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.4.x/_source/plugins/domiterator/plugin.js (revision 6003)
+++ /CKEditor/branches/versions/3.4.x/_source/plugins/domiterator/plugin.js (revision 6004)
@@ -1,3 +1,3 @@
-/*
+/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -66,5 +66,5 @@
var walker = new CKEDITOR.dom.walker( range ),
- ignoreBookmarkTextEvaluator = CKEDITOR.dom.walker.bookmark( true, true );
+ ignoreBookmarkTextEvaluator = CKEDITOR.dom.walker.bookmark( false, true );
// Avoid anchor inside bookmark inner text.
walker.evaluator = ignoreBookmarkTextEvaluator;