Ticket #6629: 6629.patch
File 6629.patch, 3.2 KB (added by , 13 years ago) |
---|
-
_source/plugins/enterkey/plugin.js
266 266 267 267 isPre = ( startBlockTag == 'pre' ); 268 268 269 // Old IEs prefer text node as line breaks. 270 var useTextBreak = isPre && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ); 271 269 272 // Gecko prefers <br> as line-break inside <pre> (#4711). 270 if ( isPre && !CKEDITOR.env.gecko)273 if ( useTextBreak ) 271 274 lineBreak = doc.createText( CKEDITOR.env.ie ? '\r' : '\n' ); 272 275 else 273 276 lineBreak = doc.createElement( 'br' ); … … 276 279 range.insertNode( lineBreak ); 277 280 278 281 // IE has different behavior regarding position. 279 if ( CKEDITOR.env.ie)282 if ( useTextBreak ) 280 283 range.setStartAt( lineBreak, CKEDITOR.POSITION_AFTER_END ); 281 284 else 282 285 { … … 286 289 doc.createText( '\ufeff' ).insertAfter( lineBreak ); 287 290 288 291 // If we are at the end of a block, we must be sure the bogus node is available in that block. 289 if ( isEndOfBlock )292 if ( isEndOfBlock && !isPre ) 290 293 lineBreak.getParent().appendBogus(); 291 294 292 295 // Now we can remove the text node contents, so the caret doesn't … … 304 307 dummy = doc.createElement( 'span' ); 305 308 // We need have some contents for Webkit to position it 306 309 // under parent node. ( #3681) 307 dummy.setHtml( ' ');310 dummy.setHtml( ' ' ); 308 311 } 309 312 else 310 313 dummy = doc.createElement( 'br' ); … … 337 340 // 1. We want to enforce the mode to be respected, instead 338 341 // of cloning the current block. (#77) 339 342 // 2. Always perform a block break when inside <pre> (#5402). 340 if ( editor.getSelection().getStartElement().hasAscendant( 'pre', true ) ) 341 { 342 setTimeout( function() { enterBlock( editor, editor.config.enterMode, null, true ); }, 0 ); 343 return true; 344 } 345 else 346 return enter( editor, editor.config.shiftEnterMode, 1 ); 343 return enter( editor, editor.config.shiftEnterMode, 1 ); 347 344 } 348 345 349 346 function enter( editor, mode, forceMode ) … … 361 358 setTimeout( function() 362 359 { 363 360 editor.fire( 'saveSnapshot' ); // Save undo step. 364 if ( mode == CKEDITOR.ENTER_BR || editor.getSelection().getStartElement().hasAscendant( 'pre', 1 ))361 if ( mode == CKEDITOR.ENTER_BR ) 365 362 enterBr( editor, mode, null, forceMode ); 366 363 else 367 364 enterBlock( editor, mode, null, forceMode ); -
_source/core/htmlparser/fragment.js
383 383 // text contents. 384 384 if ( !inPre ) 385 385 text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' ); 386 // Old IEs cannot use <br /> line-breaks in pre-formatted block. 387 else if ( !( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) ) 388 { 389 if ( !currentNode._.hasInlineStarted ) 390 text = text.replace( /^(\r\n|\n)/g, '' ); 391 text = text.replace( /\r\n|\n/g, '<br />' ); 392 } 386 393 387 394 currentNode.add( new CKEDITOR.htmlParser.text( text ) ); 388 395 };