JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5
[ckeditor.git] / _source / plugins / removeformat / plugin.js
index 84d7947..c46f6ba 100644 (file)
@@ -35,9 +35,11 @@ CKEDITOR.plugins.removeformat =
                                        ( editor._.removeAttributes = editor.config.removeFormatAttributes.split( ',' ) );\r
 \r
                                var filter = CKEDITOR.plugins.removeformat.filter;\r
-                               var ranges = editor.getSelection().getRanges();\r
+                               var ranges = editor.getSelection().getRanges( 1 ),\r
+                                       iterator = ranges.createIterator(),\r
+                                       range;\r
 \r
-                               for ( var i = 0, range ; range = ranges[ i ] ; i++ )\r
+                               while ( ( range = iterator.getNextRange() ) )\r
                                {\r
                                        if ( range.collapsed )\r
                                                continue;\r
@@ -48,8 +50,8 @@ CKEDITOR.plugins.removeformat =
                                        var bookmark = range.createBookmark();\r
 \r
                                        // The style will be applied within the bookmark boundaries.\r
-                                       var startNode   = bookmark.startNode;\r
-                                       var endNode             = bookmark.endNode;\r
+                                       var startNode   = bookmark.startNode,\r
+                                               endNode         = bookmark.endNode;\r
 \r
                                        // We need to check the selection boundaries (bookmark spans) to break\r
                                        // the code in a way that we can properly remove partially selected nodes.\r
@@ -64,8 +66,8 @@ CKEDITOR.plugins.removeformat =
                                        var breakParent = function( node )\r
                                        {\r
                                                // Let's start checking the start boundary.\r
-                                               var path = new CKEDITOR.dom.elementPath( node );\r
-                                               var pathElements = path.elements;\r
+                                               var path = new CKEDITOR.dom.elementPath( node ),\r
+                                                       pathElements = path.elements;\r
 \r
                                                for ( var i = 1, pathElement ; pathElement = pathElements[ i ] ; i++ )\r
                                                {\r
@@ -96,14 +98,17 @@ CKEDITOR.plugins.removeformat =
 \r
                                                // This node must not be a fake element.\r
                                                if ( !( currentNode.getName() == 'img'\r
-                                                       && currentNode.getAttribute( '_cke_realelement' ) )\r
+                                                       && currentNode.data( 'cke-realelement' ) )\r
                                                        && filter( editor, currentNode ) )\r
                                                {\r
                                                        // Remove elements nodes that match with this style rules.\r
                                                        if ( tagsRegex.test( currentNode.getName() ) )\r
-                                                               currentNode.remove( true );\r
+                                                               currentNode.remove( 1 );\r
                                                        else\r
+                                                       {\r
                                                                currentNode.removeAttributes( removeAttributes );\r
+                                                               editor.fire( 'removeFormatCleanup', currentNode );\r
+                                                       }\r
                                                }\r
 \r
                                                currentNode = nextNode;\r
@@ -170,3 +175,10 @@ CKEDITOR.config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,
  * @example\r
  */\r
 CKEDITOR.config.removeFormatAttributes = 'class,style,lang,width,height,align,hspace,valign';\r
+\r
+/**\r
+ * Fired after an element was cleaned by the removeFormat plugin.\r
+ * @name CKEDITOR#removeFormatCleanup\r
+ * @event\r
+ * @param {Object} data.element The element that was cleaned up.\r
+ */\r