Ticket #5402: 5402.patch
File 5402.patch, 5.5 KB (added by , 14 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
170 170 } 171 171 } 172 172 173 function isBlankParagraph( block ) 174 { 175 return block.getOuterHtml().match( emptyParagraphRegexp ); 176 } 177 178 var isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true ); 179 173 180 /** 174 181 * Auto-fixing block-less content by wrapping paragraph (#3190), prevent 175 182 * non-exitable-block by padding extra br.(#3189) … … 204 211 first && isNbsp( first ) && first.remove(); 205 212 } 206 213 207 // If the fixed block is blank and already followed by a exitable208 // block, we should revert the fix . (#3684)209 if ( fixedBlock.getOuterHtml().match( emptyParagraphRegexp) )214 // If the fixed block is actually blank and is already followed by an exitable blank 215 // block, we should revert the fix and move into the existed one. (#3684) 216 if ( isBlankParagraph( fixedBlock ) ) 210 217 { 211 218 var previousElement = fixedBlock.getPrevious( isNotWhitespace ), 212 219 nextElement = fixedBlock.getNext( isNotWhitespace ); 213 220 214 221 if ( previousElement && previousElement.getName 215 222 && !( previousElement.getName() in nonExitableElementNames ) 223 && isBlankParagraph( previousElement ) 216 224 && range.moveToElementEditStart( previousElement ) 217 225 || nextElement && nextElement.getName 218 && !( nextElement.getName() in nonExitableElementNames ) 219 && range.moveToElementEditStart( nextElement ) ) 226 && !( nextElement.getName() in nonExitableElementNames ) 227 && isBlankParagraph( nextElement ) 228 && range.moveToElementEditStart( nextElement ) ) 220 229 { 221 230 fixedBlock.remove(); 222 231 } -
_source/plugins/enterkey/plugin.js
14 14 var specialKeys = editor.specialKeys; 15 15 specialKeys[ 13 ] = enter; 16 16 specialKeys[ CKEDITOR.SHIFT + 13 ] = shiftEnter; 17 specialKeys[ CKEDITOR.CTRL + CKEDITOR.SHIFT + 13 ] = ctrlShiftEnter; 17 18 } 18 19 }); 19 20 … … 281 282 range.collapse( true ); 282 283 283 284 range.select( isPre ); 284 } 285 }, 286 287 /** 288 * If the cursor is inside a block, exit from the current block by putting the cursor after the end of it. 289 * @param editor 290 */ 291 enterExit : function( editor ) 292 { 293 var range = getRange( editor ), 294 doc = editor.document, 295 path = new CKEDITOR.dom.elementPath( range.startContainer ), 296 block = path.block || path.blockLimit; 297 298 if ( block ) 299 { 300 var parent; 301 while( block && ( parent = block.getParent() ) 302 && !CKEDITOR.dtd[ parent.getName() ][ '#' ] ) 303 { 304 block = block.getParent(); 305 } 306 307 if ( parent ) 308 { 309 range.moveToPosition( block, CKEDITOR.POSITION_AFTER_END ); 310 311 // Insert filler node when cursor is at the end of block 312 // or by side of a block. 313 var next; 314 if ( range.checkEndOfBlock() ) 315 parent.appendBogus(); 316 else if ( ( next = block.getNext() ) && next.type == CKEDITOR.NODE_ELEMENT && next.isBlockBoundary() ) 317 { 318 var filler = CKEDITOR.env.ie ?doc.createText( '\u00a0' ) : 319 CKEDITOR.env.opera ? doc.createText( '' ) : 320 doc.createElement( 'br' ); 321 322 filler.insertAfter( block ); 323 } 324 325 range.select(); 326 } 327 } 328 } 285 329 }; 286 330 287 331 var plugin = CKEDITOR.plugins.enterkey, … … 321 365 return true; 322 366 } 323 367 368 function ctrlShiftEnter( editor ) 369 { 370 // Use setTimout so the keys get cancelled immediatelly. 371 setTimeout( function() 372 { 373 editor.fire( 'saveSnapshot' ); // Save undo step. 374 CKEDITOR.plugins.enterkey.enterExit( editor ); 375 editor.fire( 'saveSnapshot' ); // Save undo step. 376 }, 0 ); 377 } 324 378 325 379 function getRange( editor ) 326 380 { -
_source/core/dom/element.js
236 236 237 237 appendBogus : function() 238 238 { 239 var lastChild = this.getLast() ; 239 var nonBookmark = CKEDITOR.dom.walker.bookmark( false, true ), 240 nonEmptyspaces = CKEDITOR.dom.walker.whitespaces( true ), 241 evaluator = function( node ) 242 { 243 return nonEmptyspaces( node ) && nonBookmark( node ) 244 }; 240 245 241 // Ignore empty/spaces text.242 while ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT && !CKEDITOR.tools.rtrim( lastChild.getText() ) )243 lastChild = lastChild.getPrevious();244 if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) )245 {246 var bogus = CKEDITOR.env.opera ?247 this.getDocument().createText('') :248 this.getDocument().createElement( 'br' );246 this.appendBogus = function() 247 { 248 var lastChild = this.getLast( evaluator ); 249 if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) ) 250 { 251 var bogus = CKEDITOR.env.ie ? this.getDocument().createText( '\u00a0' ) : 252 CKEDITOR.env.opera ? this.getDocument().createText('') : 253 this.getDocument().createElement( 'br' ); 249 254 250 CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' );255 CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' ); 251 256 252 this.append( bogus ); 253 } 257 this.append( bogus ); 258 } 259 }; 260 261 this.appendBogus(); 254 262 }, 255 263 256 264 /**