Ticket #5590: 5590.patch
File 5590.patch, 3.5 KB (added by , 14 years ago) |
---|
-
_source/plugins/removeformat/plugin.js
41 41 42 42 while ( ( range = iterator.getNextRange() ) ) 43 43 { 44 if ( range.collapsed )45 continue;44 if ( ! range.collapsed ) 45 range.enlarge( CKEDITOR.ENLARGE_ELEMENT ); 46 46 47 range.enlarge( CKEDITOR.ENLARGE_ELEMENT );48 49 47 // Bookmark the range so we can re-select it after processing. 50 var bookmark = range.createBookmark(); 48 var bookmark = range.createBookmark(), 49 // The style will be applied within the bookmark boundaries. 50 startNode = bookmark.startNode, 51 endNode = bookmark.endNode, 52 currentNode; 51 53 52 // The style will be applied within the bookmark boundaries.53 var startNode = bookmark.startNode,54 endNode = bookmark.endNode;55 56 54 // We need to check the selection boundaries (bookmark spans) to break 57 55 // the code in a way that we can properly remove partially selected nodes. 58 56 // For example, removing a <b> style from … … 81 79 }; 82 80 83 81 breakParent( startNode ); 84 breakParent( endNode ); 82 if ( endNode ) 83 { 84 breakParent( endNode ); 85 85 86 // Navigate through all nodes between the bookmarks.87 varcurrentNode = startNode.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT );86 // Navigate through all nodes between the bookmarks. 87 currentNode = startNode.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT ); 88 88 89 while ( currentNode )90 {91 // If we have reached the end of the selection, stop looping.92 if ( currentNode.equals( endNode ) )93 break;89 while ( currentNode ) 90 { 91 // If we have reached the end of the selection, stop looping. 92 if ( currentNode.equals( endNode ) ) 93 break; 94 94 95 // Cache the next node to be processed. Do it now, because96 // currentNode may be removed.97 var nextNode = currentNode.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT );95 // Cache the next node to be processed. Do it now, because 96 // currentNode may be removed. 97 var nextNode = currentNode.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT ); 98 98 99 // This node must not be a fake element. 100 if ( !( currentNode.getName() == 'img' 101 && currentNode.getAttribute( '_cke_realelement' ) ) 102 && filter( editor, currentNode ) ) 103 { 104 // Remove elements nodes that match with this style rules. 105 if ( tagsRegex.test( currentNode.getName() ) ) 106 currentNode.remove( 1 ); 107 else 99 // This node must not be a fake element. 100 if ( !( currentNode.getName() == 'img' 101 && currentNode.getAttribute( '_cke_realelement' ) ) 102 && filter( editor, currentNode ) ) 108 103 { 109 currentNode.removeAttributes( removeAttributes ); 110 editor.fire( 'removeFormatCleanup', currentNode ); 104 // Remove elements nodes that match with this style rules. 105 if ( tagsRegex.test( currentNode.getName() ) ) 106 currentNode.remove( 1 ); 107 else 108 { 109 currentNode.removeAttributes( removeAttributes ); 110 editor.fire( 'removeFormatCleanup', currentNode ); 111 } 111 112 } 113 114 currentNode = nextNode; 112 115 } 113 114 currentNode = nextNode;115 116 } 116 117 117 118 range.moveToBookmark( bookmark );