1
- /*
1
+ /*
2
2
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
3
3
For licensing, see LICENSE.html or http://ckeditor.com/license
4
4
*/
@@ -612,7 +612,7 @@ CKEDITOR.dom.range = function( document ) {
612
612
} ,
613
613
614
614
/**
615
- * Move the range out of bookmark nodes if they're been the container.
615
+ * Move the range out of bookmark nodes if they'd been the container.
616
616
*/
617
617
optimizeBookmark : function ( ) {
618
618
var startNode = this . startContainer ,
@@ -1015,12 +1015,12 @@ CKEDITOR.dom.range = function( document ) {
1015
1015
1016
1016
var walker = new CKEDITOR . dom . walker ( walkerRange ) ,
1017
1017
blockBoundary , // The node on which the enlarging should stop.
1018
- tailBr , //
1019
- defaultGuard = CKEDITOR . dom . walker . blockBoundary (
1018
+ tailBr , // In case BR as block boundary.
1019
+ notBlockBoundary = CKEDITOR . dom . walker . blockBoundary (
1020
1020
( unit == CKEDITOR . ENLARGE_LIST_ITEM_CONTENTS ) ? { br :1 } : null ) ,
1021
1021
// Record the encountered 'blockBoundary' for later use.
1022
1022
boundaryGuard = function ( node ) {
1023
- var retval = defaultGuard ( node ) ;
1023
+ var retval = notBlockBoundary ( node ) ;
1024
1024
if ( ! retval )
1025
1025
blockBoundary = node ;
1026
1026
return retval ;
@@ -1040,8 +1040,9 @@ CKEDITOR.dom.range = function( document ) {
1040
1040
// It's the body which stop the enlarging if no block boundary found.
1041
1041
blockBoundary = blockBoundary || body ;
1042
1042
1043
- // Start the range at different position by comparing
1044
- // the document position of it with 'enlargeable' node.
1043
+ // Start the range either after the end of found block (<p>...</p>[text)
1044
+ // or at the start of block (<p>[text...), by comparing the document position
1045
+ // with 'enlargeable' node.
1045
1046
this . setStartAt ( blockBoundary , ! blockBoundary . is ( 'br' ) && ( ! enlargeable && this . checkStartOfBlock ( ) || enlargeable && blockBoundary . contains ( enlargeable ) ) ? CKEDITOR . POSITION_AFTER_START : CKEDITOR . POSITION_AFTER_END ) ;
1046
1047
1047
1048
// Enlarging the end boundary.
@@ -1060,8 +1061,8 @@ CKEDITOR.dom.range = function( document ) {
1060
1061
// It's the body which stop the enlarging if no block boundary found.
1061
1062
blockBoundary = blockBoundary || body ;
1062
1063
1063
- // Start the range at different position by comparing
1064
- // the document position of it with 'enlargeable' node.
1064
+ // Close the range either before the found block start (text]<p>...</p>) or at the block end (...text]</p>)
1065
+ // by comparing the document position with 'enlargeable' node.
1065
1066
this . setEndAt ( blockBoundary , ( ! enlargeable && this . checkEndOfBlock ( ) || enlargeable && blockBoundary . contains ( enlargeable ) ) ? CKEDITOR . POSITION_BEFORE_END : CKEDITOR . POSITION_BEFORE_START ) ;
1066
1067
// We must include the <br> at the end of range if there's
1067
1068
// one and we're expanding list item contents
@@ -1074,6 +1075,13 @@ CKEDITOR.dom.range = function( document ) {
1074
1075
* Descrease the range to make sure that boundaries
1075
1076
* always anchor beside text nodes or innermost element.
1076
1077
* @param {Number } mode ( CKEDITOR.SHRINK_ELEMENT | CKEDITOR.SHRINK_TEXT ) The shrinking mode.
1078
+ * <dl>
1079
+ * <dt>CKEDITOR.SHRINK_ELEMENT</dt>
1080
+ * <dd>Shrink the range boundaries to the edge of the innermost element.</dd>
1081
+ * <dt>CKEDITOR.SHRINK_TEXT</dt>
1082
+ * <dd>Shrink the range boudaries to anchor by the side of enclosed text node, range remains if there's no text nodes on boundaries at all.</dd>
1083
+ * </dl>
1084
+ * @param {Boolean } selectContents Whether result range anchors at the inner OR outer boundary of the node.
1077
1085
*/
1078
1086
shrink : function ( mode , selectContents ) {
1079
1087
// Unable to shrink a collapsed range.
@@ -1430,11 +1438,11 @@ CKEDITOR.dom.range = function( document ) {
1430
1438
walkerRange [ checkType == CKEDITOR . START ? 'setStartAt' : 'setEndAt' ]
1431
1439
( element , checkType == CKEDITOR . START ? CKEDITOR . POSITION_AFTER_START : CKEDITOR . POSITION_BEFORE_END ) ;
1432
1440
1433
- var walker = new CKEDITOR . dom . walker ( walkerRange ) ,
1434
- retval = false ;
1441
+ var walker = new CKEDITOR . dom . walker ( walkerRange ) ;
1435
1442
walker . evaluator = elementBoundaryEval ;
1436
1443
return walker [ checkType == CKEDITOR . START ? 'checkBackward' : 'checkForward' ] ( ) ;
1437
1444
} ,
1445
+
1438
1446
// Calls to this function may produce changes to the DOM. The range may
1439
1447
// be updated to reflect such changes.
1440
1448
checkStartOfBlock : function ( ) {
@@ -1565,7 +1573,7 @@ CKEDITOR.dom.range = function( document ) {
1565
1573
getEnclosedNode : function ( ) {
1566
1574
var walkerRange = this . clone ( ) ;
1567
1575
1568
- // Optimize and analyze the range to avoid DOM destructive nature of walker. (#
1576
+ // Optimize and analyze the range to avoid DOM destructive nature of walker. (#5780)
1569
1577
walkerRange . optimize ( ) ;
1570
1578
if ( walkerRange . startContainer . type != CKEDITOR . NODE_ELEMENT || walkerRange . endContainer . type != CKEDITOR . NODE_ELEMENT )
1571
1579
return null ;
@@ -1613,11 +1621,15 @@ CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3;
1613
1621
1614
1622
/**
1615
1623
* Check boundary types.
1616
- * @see CKEDITOR.dom.range:: checkBoundaryOfElement
1624
+ * @see CKEDITOR.dom.range.prototype. checkBoundaryOfElement
1617
1625
*/
1618
1626
CKEDITOR . START = 1 ;
1619
1627
CKEDITOR . END = 2 ;
1620
1628
CKEDITOR . STARTEND = 3 ;
1621
1629
1630
+ /**
1631
+ * Shrink range types.
1632
+ * @see CKEDITOR.dom.range.prototype.shrink
1633
+ */
1622
1634
CKEDITOR . SHRINK_ELEMENT = 1 ;
1623
1635
CKEDITOR . SHRINK_TEXT = 2 ;
0 commit comments