X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fremoveformat%2Fplugin.js;h=066fce6ce869c3eee5fc70ba72babc175d5d8e94;hp=c46f6ba6586539d73514430b92731ebccf9f8c53;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hpb=9afde8772159bd3436f1f5b7862960307710ae5a diff --git a/_source/plugins/removeformat/plugin.js b/_source/plugins/removeformat/plugin.js index c46f6ba..066fce6 100644 --- a/_source/plugins/removeformat/plugin.js +++ b/_source/plugins/removeformat/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -41,17 +41,15 @@ CKEDITOR.plugins.removeformat = while ( ( range = iterator.getNextRange() ) ) { - if ( range.collapsed ) - continue; - - range.enlarge( CKEDITOR.ENLARGE_ELEMENT ); + if ( ! range.collapsed ) + range.enlarge( CKEDITOR.ENLARGE_ELEMENT ); // Bookmark the range so we can re-select it after processing. - var bookmark = range.createBookmark(); - - // The style will be applied within the bookmark boundaries. - var startNode = bookmark.startNode, - endNode = bookmark.endNode; + var bookmark = range.createBookmark(), + // The style will be applied within the bookmark boundaries. + startNode = bookmark.startNode, + endNode = bookmark.endNode, + currentNode; // We need to check the selection boundaries (bookmark spans) to break // the code in a way that we can properly remove partially selected nodes. @@ -81,37 +79,40 @@ CKEDITOR.plugins.removeformat = }; breakParent( startNode ); - breakParent( endNode ); + if ( endNode ) + { + breakParent( endNode ); - // Navigate through all nodes between the bookmarks. - var currentNode = startNode.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT ); + // Navigate through all nodes between the bookmarks. + currentNode = startNode.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT ); - while ( currentNode ) - { - // If we have reached the end of the selection, stop looping. - if ( currentNode.equals( endNode ) ) - break; - - // Cache the next node to be processed. Do it now, because - // currentNode may be removed. - var nextNode = currentNode.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT ); - - // This node must not be a fake element. - if ( !( currentNode.getName() == 'img' - && currentNode.data( 'cke-realelement' ) ) - && filter( editor, currentNode ) ) + while ( currentNode ) { - // Remove elements nodes that match with this style rules. - if ( tagsRegex.test( currentNode.getName() ) ) - currentNode.remove( 1 ); - else + // If we have reached the end of the selection, stop looping. + if ( currentNode.equals( endNode ) ) + break; + + // Cache the next node to be processed. Do it now, because + // currentNode may be removed. + var nextNode = currentNode.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT ); + + // This node must not be a fake element. + if ( !( currentNode.getName() == 'img' + && currentNode.data( 'cke-realelement' ) ) + && filter( editor, currentNode ) ) { - currentNode.removeAttributes( removeAttributes ); - editor.fire( 'removeFormatCleanup', currentNode ); + // Remove elements nodes that match with this style rules. + if ( tagsRegex.test( currentNode.getName() ) ) + currentNode.remove( 1 ); + else + { + currentNode.removeAttributes( removeAttributes ); + editor.fire( 'removeFormatCleanup', currentNode ); + } } - } - currentNode = nextNode; + currentNode = nextNode; + } } range.moveToBookmark( bookmark ); @@ -178,7 +179,7 @@ CKEDITOR.config.removeFormatAttributes = 'class,style,lang,width,height,align,hs /** * Fired after an element was cleaned by the removeFormat plugin. - * @name CKEDITOR#removeFormatCleanup + * @name CKEDITOR.editor#removeFormatCleanup * @event * @param {Object} data.element The element that was cleaned up. */