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 | | } |
| 413 | } |
| 658 | // In certain situation when browsers are incapable to moving cursor out of certain non-exitable |
| 659 | // blocks (e.g. table, list, pre) at the end of document, make this happen by |
| 660 | // placing a padding area, when clicked put cursor at the end of body. |
| 661 | var htmlElement = domDocument.getDocumentElement(), |
| 662 | body = domDocument.getBody(), |
| 663 | nonWhiteSpaces = CKEDITOR.dom.walker.whitespaces( 1 ), |
| 664 | bodyPad = htmlElement.append( 'div' ); |
| 665 | bodyPad.setAttribute( 'contentEditable', false ); |
| 666 | bodyPad.addClass( 'cke_body_pad' ); |
| 667 | bodyPad.setStyles( { width : '100%', height : '1em' } ); |
| 668 | bodyPad.on( 'click', function() |
| 669 | { |
| 670 | var last = body.getLast( nonWhiteSpaces ); |
| 671 | if ( last.type == CKEDITOR.NODE_TEXT || !nonExitable( last ) ) |
| 672 | return; |
| 673 | |
| 674 | var range = new CKEDITOR.dom.range( domDocument ); |
| 675 | range.moveToPosition( body, CKEDITOR.POSITION_BEFORE_END ); |
| 676 | range.select(); |
| 677 | }); |
| 678 | |
| 679 | |