Ticket #5479: 5479_9.patch
File 5479_9.patch, 9.3 KB (added by , 13 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. … … 414 429 editor.selectionChange(); 415 430 } 416 431 } 417 418 // All browsers are incapable to moving cursor out of certain non-exitable 419 // blocks (e.g. table, list, pre) at the end of document, make this happen by 420 // place a bogus node there, which would be later removed by dataprocessor. 421 var walkerRange = new CKEDITOR.dom.range( editor.document ), 422 walker = new CKEDITOR.dom.walker( walkerRange ); 423 walkerRange.selectNodeContents( body ); 424 walker.evaluator = function( node ) 425 { 426 return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in nonExitableElementNames ); 427 }; 428 walker.guard = function( node, isMoveout ) 429 { 430 return !( ( node.type == CKEDITOR.NODE_TEXT && isNotWhitespace( node ) ) || isMoveout ); 431 }; 432 433 if ( walker.previous() ) 434 { 435 editor.fire( 'updateSnapshot' ); 436 restoreDirty( editor ); 437 CKEDITOR.env.ie && restoreSelection( selection ); 438 439 var paddingBlock; 440 if ( enterMode != CKEDITOR.ENTER_BR ) 441 paddingBlock = body.append( new CKEDITOR.dom.element( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ); 442 else 443 paddingBlock = body; 444 445 if ( !CKEDITOR.env.ie ) 446 paddingBlock.appendBogus(); 447 } 448 } 432 } 449 433 450 434 CKEDITOR.plugins.add( 'wysiwygarea', 451 435 { … … 690 674 } ); 691 675 } 692 676 677 // In certain situation when browsers are incapable to moving cursor out of certain non-exitable 678 // blocks (e.g. table, list, pre) at the end of document, make this happen by 679 // placing a padding area, when clicked put a padding node at the end of body. (#5479) 680 var htmlElement = domDocument.getDocumentElement(), 681 body = domDocument.getBody(), 682 nonWhiteSpaces = CKEDITOR.dom.walker.whitespaces( 1 ), 683 bodyPad = htmlElement.append( 'div' ); 684 bodyPad.setAttribute( 'contentEditable', false ); 685 bodyPad.addClass( 'cke_body_pad' ); 686 bodyPad.setStyles( { width : '100%', height : '1em' } ); 687 bodyPad.on( 'click', function() 688 { 689 var last = body.getLast( nonWhiteSpaces ); 690 if ( !last || last.type != CKEDITOR.NODE_ELEMENT || !nonExitable( last ) ) 691 return; 692 693 if ( !CKEDITOR.env.ie ) 694 body.appendBogus(); 695 else 696 { 697 // IE need at least a node to show the cursor, use a zero height br 698 // to fly under the radar, additionally wrap the br element with an extra span , 699 // so selection change event could be easily captured when cursor move inside of it. 700 var paddingNode = CKEDITOR.dom.element.createFromHtml( '<span data-cke-bogus=1>' + 701 '<br data-cke-temp=1 style="line-height:0"/></span>', domDocument ); 702 703 body.append( paddingNode ); 704 } 705 706 var range = new CKEDITOR.dom.range( domDocument ); 707 range.moveToPosition( body, CKEDITOR.POSITION_BEFORE_END ); 708 range.select(); 709 }); 710 693 711 // IE standard compliant in editing frame doesn't focus the editor when 694 712 // clicking outside actual content, manually apply the focus. (#1659) 695 713 if ( CKEDITOR.env.ie … … 703 721 // Setting focus directly on editor doesn't work, we 704 722 // have to use here a temporary element to 'redirect' 705 723 // the focus. 706 if ( evt.data.getTarget().equals( htmlElement) )724 if ( !evt.data.getTarget().getAscendant( 'body' ) ) 707 725 { 708 726 if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 ) 709 727 blinkCursor(); … … 1167 1185 } 1168 1186 }); 1169 1187 1170 } 1171 }); 1188 var dataProcessor = editor.dataProcessor, 1189 htmlFilter = dataProcessor && dataProcessor.htmlFilter; 1190 1191 htmlFilter && htmlFilter.addRules( 1192 { 1193 elements : 1194 { 1195 // Remove body pad for full page. 1196 div : function( element ) 1197 { 1198 var attributes = element.attributes; 1199 if ( attributes[ 'class' ] == 'cke_body_pad' ) 1200 return false; 1201 } 1202 } 1203 }); 1204 } 1205 }); 1172 1206 1173 1207 // Fixing Firefox 'Back-Forward Cache' break design mode. (#4514) 1174 1208 if ( CKEDITOR.env.gecko ) -
_source/plugins/selection/plugin.js
599 599 return { container : parent, offset : getNodeIndex( child ) }; 600 600 } 601 601 602 // All childs are text nodes. 603 if ( index == -1 ) 602 // All childs are text nodes, 603 // or to the right hand of test range are all text nodes. (#6992) 604 if ( index == -1 || index == siblings.length - 1 && position < 0 ) 604 605 { 605 606 // Adapt test range to embrace the entire parent contents. 606 607 testRange.moveToElementText( parent ); … … 613 614 614 615 siblings = parent.childNodes; 615 616 616 // Actual range anchor right beside test range at the innerboundary of text node.617 // Actual range anchor right beside test range at the boundary of text node. 617 618 if ( !distance ) 618 619 { 619 620 child = siblings[ siblings.length - 1 ]; 620 return { container : child, offset : child.nodeValue.length }; 621 622 if ( child.nodeType == CKEDITOR.NODE_ELEMENT ) 623 return { container : parent, offset : siblings.length }; 624 else 625 return { container : child, offset : child.nodeValue.length }; 621 626 } 622 627 623 628 // Start the measuring until distance overflows, meanwhile count the text nodes.