Changeset 207
- Timestamp:
- 2007-03-14 12:55:12 (3 years ago)
- Location:
- FCKeditor/trunk
- Files:
-
- 3 modified
-
editor/_source/classes/fckdomrange.js (modified) (2 diffs)
-
editor/_source/classes/fckenterkey.js (modified) (12 diffs)
-
_whatsnew.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/classes/fckdomrange.js
r132 r207 118 118 }, 119 119 120 // Moves to the first editing point inside a element. For example, in a 121 // element tree like "<p><b><i></i></b> Text</p>", the start editing point 122 // is "<p><b><i>^</i></b> Text</p>" (inside <i>). 123 MoveToElementEditStart : function( targetElement ) 124 { 125 var child ; 126 127 while ( ( child = targetElement.firstChild ) && child.nodeType == 1 && FCKListsLib.EmptyElements[ child.nodeName.toLowerCase() ] == null ) 128 targetElement = child ; 129 130 this.MoveToElementStart( targetElement ) ; 131 }, 132 120 133 InsertNode : function( node ) 121 134 { … … 167 180 oTestRange.SetEnd( oTestRange.EndBlock || oTestRange.EndBlockLimit, 2 ) ; 168 181 169 var bIsEndOfBlock = oTestRange.CheckIsEmpty( true ) ; 170 182 var bIsEndOfBlock = oTestRange.CheckIsCollapsed() ; 183 184 if ( !bIsEndOfBlock ) 185 { 186 // Inserts the contents of the range in a div tag. 187 var eToolDiv = this.Window.document.createElement( 'div' ) ; 188 oTestRange._Range.cloneContents().AppendTo( eToolDiv ) ; 189 FCKDomTools.TrimNode( eToolDiv, true ) ; 190 191 // Find out if we are in an empty tree of inline elements, like <b><i><span></span></i></b> 192 bIsEndOfBlock = true ; 193 var eLastChild = eToolDiv ; 194 while ( ( eLastChild = eLastChild.lastChild ) ) 195 { 196 // Check the following: 197 // 1. Is there more than one node in the parents children? 198 // 2. Is the node not an element node? 199 // 3. Is it not a inline element. 200 if ( eLastChild.previousSibling || eLastChild.nodeType != 1 || FCKListsLib.InlineChildReqElements[ eLastChild.nodeName.toLowerCase() ] == null ) 201 { 202 // So we are not in the end of the range. 203 bIsEndOfBlock = false ; 204 break ; 205 } 206 } 207 } 208 171 209 oTestRange.Release() ; 172 210 -
FCKeditor/trunk/editor/_source/classes/fckenterkey.js
r184 r207 57 57 var oEnterKey = this._EnterKey ; 58 58 59 /* @Packager.RemoveLine 59 60 try 60 61 { 62 @Packager.RemoveLine */ 61 63 switch ( keystrokeValue ) 62 64 { … … 76 78 return oEnterKey.DoDelete() ; 77 79 } 80 /* @Packager.RemoveLine 78 81 } 79 82 catch (e) … … 82 85 // ahead with the browser default behavior. 83 86 } 87 @Packager.RemoveLine */ 84 88 85 89 return false ; … … 277 281 // Get the current selection. 278 282 var oRange = range || new FCKDomRange( this.Window ) ; 279 283 280 284 // If we don't have a range, move it to the selection. 281 285 if ( !range ) … … 330 334 331 335 // Move the selection to the new block. 332 oRange.MoveToElement Start( eStartBlock ) ;336 oRange.MoveToElementEditStart( eStartBlock ) ; 333 337 } 334 338 else … … 343 347 { 344 348 var eOutdented = FCKListHandler.OutdentListItem( eStartBlock ) ; 345 oRange.MoveToElement Start( eOutdented ) ;349 oRange.MoveToElementEditStart( eOutdented ) ; 346 350 } 347 351 else … … 352 356 // Otherwise, duplicate the current block. 353 357 else 358 { 354 359 eNewBlock = eStartBlock.cloneNode(false) ; 360 this._RecreateEndingTree( eStartBlock, eNewBlock ) ; 361 } 355 362 356 363 if ( FCKBrowserInfo.IsGeckoLike ) … … 384 391 { 385 392 // In Gecko, the last child node must be a bogus <br>. 386 var eLastChild = FCKDomTools.GetLastChild( eNewBlock ) ; 387 388 if ( !eLastChild || eLastChild.nodeName.toLowerCase() != 'br' || eLastChild.getAttribute( 'type', 2 ) != '_moz' ) 389 eNewBlock.appendChild( FCKTools.CreateBogusBR( this.Window.document ) ) ; 393 this._AppendBogusBr( eStartBlock ) ; 394 this._AppendBogusBr( eNewBlock ) ; 390 395 } 391 396 } … … 396 401 397 402 // Move the selection to the new block. 398 oRange.MoveToElement Start( eNewBlock ) ;403 oRange.MoveToElementEditStart( eNewBlock ) ; 399 404 400 405 if ( FCKBrowserInfo.IsGecko ) … … 406 411 { 407 412 // Move the selection to the end block. 408 oRange.MoveToElement Start( eEndBlock ) ;413 oRange.MoveToElementEditStart( eEndBlock ) ; 409 414 } 410 415 … … 471 476 // If we are at the end of a block, we must be sure the bogus node is available in that block. 472 477 if ( bIsEndOfBlock && FCKBrowserInfo.IsGecko ) 473 { 474 var eLastBr = FCKDomTools.GetLastChild( eBr.parentNode, 'BR' ) ; 475 476 if ( eLastBr && eLastBr.getAttribute( 'type', 2 ) != '_moz' ) 477 eBr.parentNode.appendChild( FCKTools.CreateBogusBR( this.Window.document ) ) ; 478 } 478 this._AppendBogusBr( eBr.parentNode ) ; 479 479 480 480 if ( FCKBrowserInfo.IsIE ) … … 522 522 range.MoveToBookmark( oBookmark ) ; 523 523 } 524 525 // Appends a bogus <br> at the end of the element, if not yet available. 526 FCKEnterKey.prototype._AppendBogusBr = function( element ) 527 { 528 var eLastChild = element.getElementsByTagName('br') ; 529 530 if ( eLastChild ) 531 eLastChild = eLastChild[ eLastChild.legth - 1 ] ; 532 533 if ( !eLastChild || eLastChild.getAttribute( 'type', 2 ) != '_moz' ) 534 element.appendChild( FCKTools.CreateBogusBR( this.Window.document ) ) ; 535 } 536 537 // Recreate the elements tree at the end of the source block, at the beginning 538 // of the target block. Eg.: 539 // If source = <p><u>Some</u> sample <b><i>text</i></b></p> then target = <p><b><i></i></b></p> 540 // If source = <p><u>Some</u> sample text</p> then target = <p></p> 541 FCKEnterKey.prototype._RecreateEndingTree = function( source, target ) 542 { 543 while ( ( source = source.lastChild ) && source.nodeType == 1 && FCKListsLib.InlineChildReqElements[ source.nodeName.toLowerCase() ] != null ) 544 target = target.insertBefore( source.cloneNode( false ), target.firstChild ) ; 545 } -
FCKeditor/trunk/_whatsnew.html
r202 r207 106 106 <li>Hidden fields will now show up as an icon in IE, instead of a normal text field. 107 107 They are also selectable and draggable, in all browsers.</li> 108 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/213">#213</a>] Styles 109 are now preserved when hitting enter at the end of a paragraph.</li> 108 110 </ul> 109 111 <h3>