X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fwalker.js;h=a4ed957dc2aaa4385b0a01a4121dd07524f4a4f5;hb=fb481ba0a7d298e3e7b9034fcb9f2afdc6e8e796;hp=3d1942596e51d4ce96278d36bdd155fdf396fe30;hpb=2f22c0c38f17e75be5541089076885442aaa2377;p=ckeditor.git diff --git a/_source/core/dom/walker.js b/_source/core/dom/walker.js index 3d19425..a4ed957 100644 --- a/_source/core/dom/walker.js +++ b/_source/core/dom/walker.js @@ -413,8 +413,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { return function( node ) { - var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT ) - && !CKEDITOR.tools.trim( node.getText() ); + var isWhitespace; + if ( node && node.type == CKEDITOR.NODE_TEXT ) + { + // whitespace, as well as the text cursor filler node we used in Webkit. (#9384) + isWhitespace = !CKEDITOR.tools.trim( node.getText() ) || + CKEDITOR.env.webkit && node.getText() == '\u200b'; + } + return !! ( isReject ^ isWhitespace ); }; }; @@ -428,13 +434,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var whitespace = CKEDITOR.dom.walker.whitespaces(); return function( node ) { - // Nodes that take no spaces in wysiwyg: - // 1. White-spaces but not including NBSP; - // 2. Empty inline elements, e.g. we're checking here - // 'offsetHeight' instead of 'offsetWidth' for properly excluding - // all sorts of empty paragraph, e.g.
. - var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight; - return !! ( isReject ^ isInvisible ); + var invisible; + + if ( whitespace( node ) ) + invisible = 1; + else + { + // Visibility should be checked on element. + if ( node.type == CKEDITOR.NODE_TEXT ) + node = node.getParent(); + + // Nodes that take no spaces in wysiwyg: + // 1. White-spaces but not including NBSP; + // 2. Empty inline elements, e.g. we're checking here + // 'offsetHeight' instead of 'offsetWidth' for properly excluding + // all sorts of empty paragraph, e.g.
. + invisible = !node.$.offsetHeight; + } + + return !! ( isReject ^ invisible ); }; }; @@ -446,7 +464,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }; }; - CKEDITOR.dom.walker.bogus = function( type, isReject ) + CKEDITOR.dom.walker.bogus = function( isReject ) { function nonEmpty( node ) { @@ -455,11 +473,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return function( node ) { - var parent = node.getParent(), - isBogus = !CKEDITOR.env.ie ? node.is && node.is( 'br' ) : + var isBogus = !CKEDITOR.env.ie ? node.is && node.is( 'br' ) : node.getText && tailNbspRegex.test( node.getText() ); - isBogus = isBogus && parent.isBlockBoundary() && !!parent.getLast( nonEmpty ); + if ( isBogus ) + { + var parent = node.getParent(), next = node.getNext( nonEmpty ); + isBogus = parent.isBlockBoundary() && + ( !next || + next.type == CKEDITOR.NODE_ELEMENT && + next.isBlockBoundary() ); + } return !! ( isReject ^ isBogus ); };