Ticket #6841: 6841.patch
File 6841.patch, 3.4 KB (added by , 13 years ago) |
---|
-
_source/plugins/enterkey/plugin.js
31 31 32 32 var doc = range.document; 33 33 34 // Exit the list when we're inside an empty list item block. (#5376) 35 if ( range.checkStartOfBlock() && range.checkEndOfBlock() ) 36 { 37 var path = new CKEDITOR.dom.elementPath( range.startContainer ), 38 block = path.block; 34 var atBlockStart = range.checkStartOfBlock(), 35 atBlockEnd = range.checkEndOfBlock(), 36 path = new CKEDITOR.dom.elementPath( range.startContainer ), 37 block = path.block; 39 38 39 // Exit the list when we're inside an empty list item block. (#5376) 40 if ( atBlockStart && atBlockEnd ) 41 { 40 42 if ( block && ( block.is( 'li' ) || block.getParent().is( 'li' ) ) ) 41 43 { 42 44 editor.execCommand( 'outdent' ); 43 45 return; 44 46 } 45 47 } 48 // Don't split <pre> if we're in the middle of it, act as shift enter key. 49 else if ( !atBlockEnd && block.is( 'pre' ) ) 50 return enterBr( editor, mode, range, forceMode ); 46 51 47 52 // Determine the block element to be used. 48 53 var blockTag = ( mode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ); … … 106 111 // Do not enter this block if it's a header tag, or we are in 107 112 // a Shift+Enter (#77). Create a new block element instead 108 113 // (later in the code). 109 if ( previousBlock.is( 'li' ) || !headerTagRegex.test( previousBlock.getName() ) ) 114 if ( previousBlock.is( 'li' ) || 115 ! ( headerTagRegex.test( previousBlock.getName() ) || previousBlock.is( 'pre' ) ) ) 110 116 { 111 117 // Otherwise, duplicate the previous block. 112 118 newBlock = previousBlock.clone(); … … 328 334 // On SHIFT+ENTER: 329 335 // 1. We want to enforce the mode to be respected, instead 330 336 // of cloning the current block. (#77) 331 // 2. Always perform a block break when inside <pre> (#5402). 332 if ( editor.getSelection().getStartElement().hasAscendant( 'pre', true ) ) 333 { 334 setTimeout( function() { enterBlock( editor, editor.config.enterMode, null, true ); }, 0 ); 335 return true; 336 } 337 else 338 return enter( editor, editor.config.shiftEnterMode, 1 ); 337 return enter( editor, editor.config.shiftEnterMode, 1 ); 339 338 } 340 339 341 340 function enter( editor, mode, forceMode ) … … 353 352 setTimeout( function() 354 353 { 355 354 editor.fire( 'saveSnapshot' ); // Save undo step. 356 if ( mode == CKEDITOR.ENTER_BR || editor.getSelection().getStartElement().hasAscendant( 'pre', 1 ))355 if ( mode == CKEDITOR.ENTER_BR ) 357 356 enterBr( editor, mode, null, forceMode ); 358 357 else 359 358 enterBlock( editor, mode, null, forceMode ); -
_source/core/dom/range.js
278 278 if ( node.type == CKEDITOR.NODE_TEXT ) 279 279 { 280 280 // If there's any visible text, then we're not at the start. 281 if ( CKEDITOR.tools.trim( node.getText() ).length )281 if ( node.hasAscendant( 'pre' ) || CKEDITOR.tools.trim( node.getText() ).length ) 282 282 return false; 283 283 } 284 284 else if ( node.type == CKEDITOR.NODE_ELEMENT ) 285 285 { 286 286 // If there are non-empty inline elements (e.g. <img />), then we're not