Ticket #5479: 5479_8.patch
File 5479_8.patch, 7.9 KB (added by , 10 years ago) |
---|
-
_source/plugins/elementspath/plugin.js
179 179 180 180 if ( name == 'body' ) 181 181 break; 182 else if ( name == 'html' ) 183 return; 182 184 183 185 element = element.getParent(); 184 186 } -
_source/core/dom/element.js
234 234 this.append( new CKEDITOR.dom.text( text ) ); 235 235 }, 236 236 237 appendBogus : function()238 {239 var lastChild = this.getLast() ;240 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' );249 250 CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' );251 252 this.append( bogus );253 }254 },255 256 237 /** 257 238 * Retrieve block element's filler node if existed. 258 239 */ -
_source/core/dom/walker.js
449 449 return false; 450 450 }; 451 451 452 // Append a filler node at the end of an element if not exists. 453 CKEDITOR.dom.element.prototype.appendBogus = function() 454 { 455 var lastChild = this.getLast( fillerEvaluator ) ; 456 if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) ) 457 { 458 var bogus = CKEDITOR.env.opera ? 459 this.getDocument().createText('') : 460 this.getDocument().createElement( 'br' ); 461 462 CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' ); 463 464 this.append( bogus ); 465 } 466 }; 467 468 452 469 })(); -
_source/plugins/wysiwygarea/plugin.js
304 304 return block.getOuterHtml().match( emptyParagraphRegexp ); 305 305 } 306 306 307 isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true );308 309 307 // Gecko need a key event to 'wake up' the editing 310 308 // ability when document is empty.(#3864, #5781) 311 309 function activateEditing( editor ) … … 359 357 360 358 CKEDITOR.env.gecko && activateEditing( editor ); 361 359 360 // Remove the padding body node used in IE. 361 if ( CKEDITOR.env.ie ) 362 { 363 var start = range.collapsed && range.startContainer; 364 if ( start.type == CKEDITOR.NODE_ELEMENT && start.is( 'span') && start.data( 'cke-bogus') ) 365 { 366 range.moveToPosition( start, CKEDITOR.POSITION_BEFORE_START ); 367 start.remove(); 368 range.select(); 369 return; 370 } 371 } 372 362 373 // When enterMode set to block, we'll establing new paragraph only if we're 363 374 // selecting inline contents right under body. (#3657) 364 375 if ( enterMode != CKEDITOR.ENTER_BR … … 396 407 { 397 408 element = fixedBlock.getPrevious( isNotWhitespace ); 398 409 if ( element && 399 element.type == CKEDITOR.NODE_ELEMENT && 400 !nonExitable( element ) ) 410 element.type == CKEDITOR.NODE_ELEMENT ) 401 411 { 402 range.moveToElementEditEnd( element ); 403 fixedBlock.remove(); 404 } 405 } 406 } 412 if ( !nonExitable( element ) ) 413 { 414 range.moveToElementEditEnd( element ); 415 fixedBlock.remove(); 416 } 417 else if ( element.getDirection() ) 418 fixedBlock.setAttribute( 'dir', element.getDirection() ); 419 } 420 } 421 } 407 422 408 423 range.select(); 409 424 // Notify non-IE that selection has changed. 410 425 if ( !CKEDITOR.env.ie ) 411 426 editor.selectionChange(); 412 427 } 413 414 // All browsers are incapable to moving cursor out of certain non-exitable 415 // blocks (e.g. table, list, pre) at the end of document, make this happen by 416 // place a bogus node there, which would be later removed by dataprocessor. 417 var walkerRange = new CKEDITOR.dom.range( editor.document ), 418 walker = new CKEDITOR.dom.walker( walkerRange ); 419 walkerRange.selectNodeContents( body ); 420 walker.evaluator = function( node ) 421 { 422 return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in nonExitableElementNames ); 423 }; 424 walker.guard = function( node, isMoveout ) 425 { 426 return !( ( node.type == CKEDITOR.NODE_TEXT && isNotWhitespace( node ) ) || isMoveout ); 427 }; 428 429 if ( walker.previous() ) 430 { 431 editor.fire( 'updateSnapshot' ); 432 restoreDirty( editor ); 433 CKEDITOR.env.ie && restoreSelection( selection ); 434 435 var paddingBlock; 436 if ( enterMode != CKEDITOR.ENTER_BR ) 437 paddingBlock = body.append( new CKEDITOR.dom.element( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ); 438 else 439 paddingBlock = body; 440 441 if ( !CKEDITOR.env.ie ) 442 paddingBlock.appendBogus(); 443 } 444 } 428 } 445 429 446 430 CKEDITOR.plugins.add( 'wysiwygarea', 447 431 { … … 686 670 } ); 687 671 } 688 672 673 // In certain situation when browsers are incapable to moving cursor out of certain non-exitable 674 // blocks (e.g. table, list, pre) at the end of document, make this happen by 675 // placing a padding area, when clicked put a padding node at the end of body. (#5479) 676 var htmlElement = domDocument.getDocumentElement(), 677 body = domDocument.getBody(), 678 nonWhiteSpaces = CKEDITOR.dom.walker.whitespaces( 1 ), 679 bodyPad = htmlElement.append( 'div' ); 680 bodyPad.setAttribute( 'contentEditable', false ); 681 bodyPad.addClass( 'cke_body_pad' ); 682 bodyPad.setStyles( { width : '100%', height : '1em' } ); 683 bodyPad.on( 'click', function() 684 { 685 var last = body.getLast( nonWhiteSpaces ); 686 if ( last.type == CKEDITOR.NODE_TEXT || !nonExitable( last ) ) 687 return; 688 689 if ( !CKEDITOR.env.ie ) 690 body.appendBogus(); 691 else 692 { 693 // IE need at least a node to show the cursor, use a zero height br 694 // to fly under the radar, additionally wrap the br element with an extra span , 695 // so selection change event could be easily captured when cursor move inside of it. 696 var paddingNode = CKEDITOR.dom.element.createFromHtml( '<span data-cke-bogus=1>' + 697 '<br data-cke-temp=1 style="line-height:0"/></span>', domDocument ); 698 699 body.append( paddingNode ); 700 } 701 702 var range = new CKEDITOR.dom.range( domDocument ); 703 range.moveToPosition( body, CKEDITOR.POSITION_BEFORE_END ); 704 range.select(); 705 }); 706 689 707 // IE standard compliant in editing frame doesn't focus the editor when 690 708 // clicking outside actual content, manually apply the focus. (#1659) 691 709 if ( CKEDITOR.env.ie … … 699 717 // Setting focus directly on editor doesn't work, we 700 718 // have to use here a temporary element to 'redirect' 701 719 // the focus. 702 if ( evt.data.getTarget().equals( htmlElement) )720 if ( !evt.data.getTarget().getAscendant( 'body' ) ) 703 721 { 704 722 if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 ) 705 723 blinkCursor(); … … 1163 1181 } 1164 1182 }); 1165 1183 1166 } 1167 }); 1184 var dataProcessor = editor.dataProcessor, 1185 htmlFilter = dataProcessor && dataProcessor.htmlFilter; 1186 1187 htmlFilter && htmlFilter.addRules( 1188 { 1189 elements : 1190 { 1191 // Remove body pad for full page. 1192 div : function( element ) 1193 { 1194 var attributes = element.attributes; 1195 if ( attributes[ 'class' ] == 'cke_body_pad' ) 1196 return false; 1197 } 1198 } 1199 }); 1200 } 1201 }); 1168 1202 1169 1203 // Fixing Firefox 'Back-Forward Cache' break design mode. (#4514) 1170 1204 if ( CKEDITOR.env.gecko )