Ticket #7896: 7896.patch
File 7896.patch, 3.2 KB (added by , 13 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
288 288 this.getSelection().lock(); 289 289 } 290 290 291 // DOM modification here should not bother dirty flag.(#4385)292 function restoreDirty( editor )293 {294 if ( !editor.checkDirty() )295 setTimeout( function(){ editor.resetDirty(); }, 0 );296 }297 298 291 var isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true ), 299 292 isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true ); 300 293 … … 309 302 && CKEDITOR.tools.trim( node.getText() ).match( /^(?: |\xa0)$/ ); 310 303 } 311 304 312 function restoreSelection( selection )313 {314 if ( selection.isLocked )315 {316 selection.unlock();317 setTimeout( function() { selection.lock(); }, 0 );318 }319 }320 321 305 function isBlankParagraph( block ) 322 306 { 323 307 return block.getOuterHtml().match( emptyParagraphRegexp ); … … 366 350 } 367 351 } 368 352 353 /* 354 * Revert various editor status which should get affected by the changes brought by the executed function: (#4385,#5221) 355 * 1. dirty flag; 356 * 2. selection lock; 357 * 3. undo stack; 358 */ 359 function keepEditorStatus( editor, func ) 360 { 361 return function() 362 { 363 var wasClean = !editor.checkDirty(); 364 var sel = editor.getSelection(); 365 if ( !sel || sel.isLocked ) 366 return; 367 editor.fire( 'updateSnapshot' ); 368 369 func.apply( this, arguments ); 370 371 wasClean && editor.resetDirty(); 372 }; 373 } 374 369 375 /** 370 376 * Auto-fixing block-less content by wrapping paragraph (#3190), prevent 371 377 * non-exitable-block by padding extra br.(#3189) … … 398 404 && !pathBlock.is( 'pre' ) 399 405 && !pathBlock.getBogus() ) 400 406 { 401 editor.fire( 'updateSnapshot' );402 restoreDirty( editor );403 407 pathBlock.appendBogus(); 404 408 } 405 409 } … … 412 416 && blockLimit.getName() == 'body' 413 417 && !path.block ) 414 418 { 415 editor.fire( 'updateSnapshot' );416 restoreDirty( editor );417 CKEDITOR.env.ie && restoreSelection( selection );418 419 419 var fixedBlock = range.fixBlock( true, 420 420 editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ); 421 421 … … 464 464 var testPath = new CKEDITOR.dom.elementPath( testRange.startContainer ); 465 465 if ( !testPath.blockLimit.is( 'body') ) 466 466 { 467 editor.fire( 'updateSnapshot' );468 restoreDirty( editor );469 CKEDITOR.env.ie && restoreSelection( selection );470 471 467 var paddingBlock; 472 468 if ( enterMode != CKEDITOR.ENTER_BR ) 473 469 paddingBlock = body.append( editor.document.createElement( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ); … … 1125 1121 editor.on( 'insertElement', onInsert( doInsertElement ), null, null, 20 ); 1126 1122 editor.on( 'insertText', onInsert( doInsertText ), null, null, 20 ); 1127 1123 // Auto fixing on some document structure weakness to enhance usabilities. (#3190 and #3189) 1128 editor.on( 'selectionChange', onSelectionChangeFixBody, null, null, 1 );1124 editor.on( 'selectionChange', keepEditorStatus( editor, onSelectionChangeFixBody ), null, null, 1 ); 1129 1125 }); 1130 1126 1131 1127 var titleBackup;