I have this code
afterInit: function (editor) { var dataProcessor = editor.dataProcessor, dataFilter = dataProcessor && dataProcessor.dataFilter, htmlFilter = dataProcessor && dataProcessor.htmlFilter; // Replace <!-- INLINE* --> with actual image. // Editor status: 1 if ( dataFilter ) { dataFilter.addRules({ comment: function( comment ) { that = Drupal.behaviors.inline_plugins; return comment.replace(new RegExp('INLINE:([0-9]*);w=([0-9]*);h=([0-9]*)', 'gi'), function($0, $1, $ 2, $3) { return '-->' + that._getPlaceholder($1, $2, $3) + '<!--'; }); } }); } // Replace actual image with <!-- INLINE* --> placeholder. // Editor status: 0 if ( htmlFilter ) { htmlFilter.addRules({ elements: { comment: function(element) { console.log("element"); if (element == '{cke_protected}{C}%3C!%2D%2D%20%2D%2D%3E') { return false; } }, img: function(img) { // Replace inline images with physical image. var pattern = /(<img) (.*) alt="(INLINE:\d+;w=\d+;h=\d+)" (.*)/; if (img.match(/.* class="wysiwyg-inline-image" .*/)) { var altered_str = img.replace(pattern, "<!-- $3 -->"); return altered_str; } } } }); } }
In htmlFilter.addRules only one rule is working. How can I make that the comment and image will both work?