Ticket #6629: 6629_3.patch
File 6629_3.patch, 3.3 KB (added by , 13 years ago) |
---|
-
_source/plugins/wysiwygarea/plugin.js
10 10 11 11 (function() 12 12 { 13 // List of elements in which has no way to move editing focus outside.14 var nonExitableElementNames = { table:1,pre:1 };15 16 13 // Matching an empty paragraph at the end of document. 17 var emptyParagraphRegexp = /(^|<body\b[^>]*>)\s*<(p|div|address|h\d|center )[^>]*>\s*(?:<br[^>]*>| |\u00A0| )?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi;14 var emptyParagraphRegexp = /(^|<body\b[^>]*>)\s*<(p|div|address|h\d|center|pre)[^>]*>\s*(?:<br[^>]*>| |\u00A0| )?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi; 18 15 19 16 var notWhitespaceEval = CKEDITOR.dom.walker.whitespaces( true ); 20 17 21 // Elements that could have empty new line around, including table, pre-formatted block,hr, page-break. (#6554)22 function nonE xitable( element )18 // Elements that could blink the cursor anchoring beside it, like hr, page-break. (#6554) 19 function nonEditable( element ) 23 20 { 24 return ( element.getName() in nonExitableElementNames ) 25 || element.isBlockBoundary() && CKEDITOR.dtd.$empty[ element.getName() ]; 21 return element.isBlockBoundary() && CKEDITOR.dtd.$empty[ element.getName() ]; 26 22 } 27 23 28 24 … … 409 405 var element = fixedBlock.getNext( isNotWhitespace ); 410 406 if ( element && 411 407 element.type == CKEDITOR.NODE_ELEMENT && 412 !nonE xitable( element ) )408 !nonEditable( element ) ) 413 409 { 414 410 range.moveToElementEditStart( element ); 415 411 fixedBlock.remove(); … … 419 415 element = fixedBlock.getPrevious( isNotWhitespace ); 420 416 if ( element && 421 417 element.type == CKEDITOR.NODE_ELEMENT && 422 !nonE xitable( element ) )418 !nonEditable( element ) ) 423 419 { 424 420 range.moveToElementEditEnd( element ); 425 421 fixedBlock.remove(); … … 432 428 evt.cancel(); 433 429 } 434 430 435 // All browsers are incapable to moving cursor out of certain non-exitable436 // blocks (e.g. table, list, pre) at the end of document, make this happen by437 // place a bogus node there, which would be later removed by dataprocessor.438 var walkerRange = new CKEDITOR.dom.range( editor.document ),439 walker = new CKEDITOR.dom.walker( walkerRange);440 walkerRange.selectNodeContents( body);441 walker.evaluator = function( node)431 // Browsers are incapable of moving cursor out of certain block elements (e.g. table, div, pre) 432 // at the end of document, makes it unable to continue adding content, we have to make this 433 // easier by opening an new empty paragraph. 434 var testRange = new CKEDITOR.dom.range( editor.document ); 435 testRange.moveToElementEditEnd( editor.document.getBody() ); 436 var testPath = new CKEDITOR.dom.elementPath( testRange.startContainer ); 437 if ( !testPath.blockLimit.is( 'body') ) 442 438 { 443 return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in nonExitableElementNames );444 };445 walker.guard = function( node, isMoveout )446 {447 return !( ( node.type == CKEDITOR.NODE_TEXT && isNotWhitespace( node ) ) || isMoveout );448 };449 450 if ( walker.previous() )451 {452 439 editor.fire( 'updateSnapshot' ); 453 440 restoreDirty( editor ); 454 441 CKEDITOR.env.ie && restoreSelection( selection );