Ticket #4125: 4125_7.patch
File 4125_7.patch, 4.1 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 /** 121 * Perform the remove format filters on the passed element. 122 * @param {CKEDITOR.editor} editor 123 * @param {CKEDITOR.dom.element} element 124 */ 125 filter : function ( editor, element ) 126 { 127 var filters = editor._.removeFormat.filters; 128 for ( var i = 0; i < filters.length; i++ ) 129 { 130 if ( filters[ i ]( element ) === false ) 131 return false; 132 } 133 return true; 134 } 114 135 }; 115 136 116 137 /** 138 * Add to a collection of functions to decide whether a specific 139 * element should be considered as formatting element and thus 140 * could be removed during <b>removeFormat</b> command, 141 * Note: Only available with the existence of 'removeformat' plugin. 142 * @since 3.3 143 * @param {Function} func The function to be called, which will be passed a {CKEDITOR.dom.element} element to test. 144 * @example 145 * // Don't remove empty span 146 * editor.addRemoveFormatFilter.push( function( element ) 147 * { 148 * return !( element.is( 'span' ) && CKEDITOR.tools.isEmpty( element.getAttributes() ) ); 149 * }); 150 */ 151 CKEDITOR.editor.prototype.addRemoveFormatFilter = function( func ) 152 { 153 this._.removeFormat.filters.push( func ); 154 }; 155 156 /** 117 157 * A comma separated list of elements to be removed when executing the "remove 118 158 " format" command. Note that only inline elements are allowed. 119 159 * @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 })();