Ticket #4125: 4125_6.patch
File 4125_6.patch, 3.8 KB (added by , 13 years ago) |
---|
-
_source/plugins/removeformat/plugin.js
15 15 label : editor.lang.removeFormat, 16 16 command : 'removeFormat' 17 17 }); 18 19 editor._.removeFormat = { filters: [] }; 18 20 } 19 21 }); 20 22 … … 32 34 var removeAttributes = editor._.removeAttributes || 33 35 ( editor._.removeAttributes = editor.config.removeFormatAttributes.split( ',' ) ); 34 36 37 var filter = CKEDITOR.plugins.removeformat.filter; 35 38 var ranges = editor.getSelection().getRanges(); 36 39 37 40 for ( var i = 0, range ; range = ranges[ i ] ; i++ ) … … 70 73 break; 71 74 72 75 // If this element can be removed (even partially). 73 if ( tagsRegex.test( pathElement.getName() ) )76 if ( tagsRegex.test( pathElement.getName() ) && filter( editor, pathElement ) ) 74 77 node.breakParent( pathElement ); 75 78 } 76 79 }; … … 92 95 var nextNode = currentNode.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT ); 93 96 94 97 // This node must not be a fake element. 95 if ( !( currentNode.getName() == 'img' && currentNode.getAttribute( '_cke_realelement' ) ) ) 98 if ( !( currentNode.getName() == 'img' 99 && currentNode.getAttribute( '_cke_realelement' ) ) 100 && filter( editor, currentNode ) ) 96 101 { 97 102 // Remove elements nodes that match with this style rules. 98 103 if ( tagsRegex.test( currentNode.getName() ) ) … … 110 115 editor.getSelection().selectRanges( ranges ); 111 116 } 112 117 } 113 } 118 }, 119 120 filter : function ( editor, element ) 121 { 122 var filters = editor._.removeFormat.filters; 123 for ( var i = 0; i < filters.length; i++ ) 124 { 125 if ( filters[ i ]( element ) === false ) 126 return false; 127 } 128 return true; 129 } 114 130 }; 115 131 116 132 /** 133 * Add to a collection of functions to decide whether a specific 134 * element should be considered as formatting element and thus 135 * could be removed during <b>removeFormat</b> command, 136 * Note: Only available with the existence of 'removeformat' plugin. 137 * @since 3.3 138 * @default [] 139 * @example 140 * // Don't remove empty span 141 * editor.addRemoveFormatFilter.push( function( element ) 142 * { 143 * return !( element.is( 'span' ) && CKEDITOR.tools.isEmpty( element.getAttributes() ) ); 144 * }); 145 */ 146 CKEDITOR.editor.prototype.addRemoveFormatFilter = function( func ) 147 { 148 this._.removeFormat.filters.push( func ); 149 }; 150 151 /** 117 152 * A comma separated list of elements to be removed when executing the "remove 118 153 " format" command. Note that only inline elements are allowed. 119 154 * @type String -
_source/plugins/scayt/plugin.js
636 636 637 637 afterInit : function( editor ) 638 638 { 639 // Prevent word marker line from displaying in elements path. (#3570) 640 var elementsPathFilters; 641 if ( editor._.elementsPath && ( elementsPathFilters = editor._.elementsPath.filters ) ) 642 { 643 elementsPathFilters.push( function( element ) 644 { 645 if ( element.hasAttribute( 'scaytid' ) ) 646 return false; 647 } ); 648 } 639 // Prevent word marker line from displaying in elements path and been removed when cleaning format. (#3570) (#4125) 640 var elementsPathFilters, 641 scaytFilter = function( element ) 642 { 643 if ( element.hasAttribute( 'scaytid' ) ) 644 return false; 645 }; 649 646 647 if ( editor._.elementsPath && ( elementsPathFilters = editor._.elementsPath.filters ) ) 648 elementsPathFilters.push( scaytFilter ); 649 650 editor.addRemoveFormatFilter && editor.addRemoveFormatFilter( scaytFilter ); 651 650 652 } 651 653 }); 652 654 })();