| 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 | | } |
| | 425 | } |
| | 670 | // In certain situation when browsers are incapable to moving cursor out of certain non-exitable |
| | 671 | // blocks (e.g. table, list, pre) at the end of document, make this happen by |
| | 672 | // placing a padding area, when clicked put cursor at the end of body. |
| | 673 | var htmlElement = domDocument.getDocumentElement(), |
| | 674 | body = domDocument.getBody(), |
| | 675 | nonWhiteSpaces = CKEDITOR.dom.walker.whitespaces( 1 ), |
| | 676 | bodyPad = htmlElement.append( 'div' ); |
| | 677 | bodyPad.setAttribute( 'contentEditable', false ); |
| | 678 | bodyPad.addClass( 'cke_body_pad' ); |
| | 679 | bodyPad.setStyles( { width : '100%', height : '1em' } ); |
| | 680 | bodyPad.on( 'click', function() |
| | 681 | { |
| | 682 | var last = body.getLast( nonWhiteSpaces ); |
| | 683 | if ( last.type == CKEDITOR.NODE_TEXT || !nonExitable( last ) ) |
| | 684 | return; |
| | 685 | |
| | 686 | if ( !CKEDITOR.env.ie ) |
| | 687 | body.appendBogus(); |
| | 688 | else |
| | 689 | { |
| | 690 | // IE need at least a node to show the cursor, make it |
| | 691 | // as <span><br /></span> to capture selection change |
| | 692 | // event. |
| | 693 | var paddingNode = CKEDITOR.dom.element.createFromHtml( '<span data-cke-bogus=1>' + |
| | 694 | '<br data-cke-temp=1 style="line-height:0"/></span>', domDocument ); |
| | 695 | |
| | 696 | body.append( paddingNode ); |
| | 697 | } |
| | 698 | |
| | 699 | var range = new CKEDITOR.dom.range( domDocument ); |
| | 700 | range.moveToPosition( body, CKEDITOR.POSITION_BEFORE_END ); |
| | 701 | range.select(); |
| | 702 | }); |
| | 703 | |
| | 704 | |