Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html (revision 4566)
+++ /CKEditor/trunk/CHANGES.html (revision 4567)
@@ -85,4 +85,5 @@
#4527 : Fixed checkbox generate invalid 'checked' attribute.
#1659 : Fixed unable to click below content to start editing in IE with 'config.docType' setting to standard compliant.
+ #3933 : Fixed extra <br> left at the end of document when the last element is a table.
Index: /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js (revision 4566)
+++ /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js (revision 4567)
@@ -140,4 +140,18 @@
}
+ var isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true ),
+ isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true );
+
+ function isNotEmpty( node )
+ {
+ return isNotWhitespace( node ) && isNotBookmark( node );
+ };
+
+ function isNbsp( node )
+ {
+ return node.type == CKEDITOR.NODE_TEXT
+ && CKEDITOR.tools.trim( node.getText() ).match( /^(?: |\xa0)$/ );
+ }
+
/**
* Auto-fixing block-less content by wrapping paragraph (#3190), prevent
@@ -166,14 +180,9 @@
editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );
- // For IE, we'll be removing any bogus br ( introduce by fixing body )
- // right now to prevent it introducing visual line break.
+ // For IE, we should remove any filler node which was introduced before.
if ( CKEDITOR.env.ie )
{
- var brNodeList = fixedBlock.getElementsByTag( 'br' ), brNode;
- for ( var i = 0 ; i < brNodeList.count() ; i++ )
- {
- if( ( brNode = brNodeList.getItem( i ) ) && brNode.hasAttribute( '_cke_bogus' ) )
- brNode.remove();
- }
+ var first = fixedBlock.getFirst( isNotEmpty );
+ isNbsp( first ) && first.remove();
}
@@ -185,7 +194,6 @@
count = children.count(),
firstChild,
- whitespaceGuard = CKEDITOR.dom.walker.whitespaces( true ),
- previousElement = fixedBlock.getPrevious( whitespaceGuard ),
- nextElement = fixedBlock.getNext( whitespaceGuard ),
+ previousElement = fixedBlock.getPrevious( isNotWhitespace ),
+ nextElement = fixedBlock.getNext( isNotWhitespace ),
enterBlock;
if ( previousElement && previousElement.getName
@@ -207,14 +215,15 @@
}
- // Inserting the padding-br before body if it's preceded by an
- // unexitable block.
+ // All browsers are incapable to moving cursor out of certain non-exitable
+ // blocks (e.g. table, list, pre) at the end of document, make this happen by
+ // place a bogus node there, which would be later removed by dataprocessor.
var lastNode = body.getLast( CKEDITOR.dom.walker.whitespaces( true ) );
if ( lastNode && lastNode.getName && ( lastNode.getName() in nonExitableElementNames ) )
{
restoreDirty( editor );
- var paddingBlock = editor.document.createElement(
- ( CKEDITOR.env.ie && enterMode != CKEDITOR.ENTER_BR ) ?
- '
' : 'br' );
- body.append( paddingBlock );
+ if( !CKEDITOR.env.ie )
+ body.appendBogus();
+ else
+ body.append( editor.document.createText( '\xa0' ) );
}
}