drupal - ckeditor removes <br /> from code, cannot remove second space -


thanks taking interest. here situation:

i'm receiving code client contains <br /> (two spaces) in content has passed ckreditor, when displayed ckreditor changes <br /> element supplied code &nbsp.

as code supplied third party , cannot changed (without creating unexpected other steps other developers won't expecting, i'd rather avoid str_replace based solutions) cannot remove space <br /> turning <br /> detailed in this answer.

here abbreviated example of receive:

<h2 dlpe-id="74">el plan perfecto0000 para una promoción única</h2>                     <br  />                     <br  />                     <br  /> <div class="swiper-container" dlpe-id="78">... 

and output ckeditor:

<h2 dlpe-id="74">el plan perfecto0000 para una promoci&oacute;n &uacute;nica</h2> <br  /> <br  /> &nbsp; <div class="swiper-container" dlpe-id="78">... 

note &nbsp. i've seen in this post config settings may key solving issue. post config @ end of question.

any ensure <br/> doesn't turned &nbsp tweaking config file or other means gladly appreciated.

/**  * @license copyright (c) 2003-2016, cksource - frederico knabben. rights reserved.  * licensing, see license.md or http://ckeditor.com/license  */  ckeditor.editorconfig = function( config ) {     // define changes default configuration here.     // complete reference see:     // http://docs.ckeditor.com/#!/api/ckeditor.config      // toolbar groups arrangement, optimized 2 toolbar rows.     config.toolbargroups = [         { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },         { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },         { name: 'links' },         { name: 'insert' },         { name: 'forms' },         { name: 'tools' },         { name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },         { name: 'others' },         '/',         { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },         { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },         { name: 'styles' },         { name: 'colors' },         { name: 'about' }     ];      // remove buttons provided standard plugins,     // not needed in standard(s) toolbar.     config.removebuttons = 'underline,subscript,superscript';      // set common block elements.     config.format_tags = 'p;h1;h2;h3;pre';      // simplify dialog windows.     config.removedialogtabs = 'image:advanced;link:advanced';      config.autoparagraph = false;      config.basicentities = false;     config.allowedcontent = "br[clear]";   }; 

following this bug, seems wasn't fixed yet (or might fixed , returned in newer versions).

however - comments there, 2 weeks ago j.swiderski added comment code fix problem:

ckeditor.instances.editor1.on( 'pluginsloaded', function( evt ){     evt.editor.dataprocessor.datafilter.addrules({         elements :{             br : function( element ) {                           //if next element br or <!--cke_br_comment-->, ignore it.                 if( element && element.next && ( element.next.name == 'br' || element.next.value == 'cke_br_comment' ) ){                     return;                 }else {                     var comment = new ckeditor.htmlparser.comment( 'cke_br_comment' );                     comment.insertafter( element );                  }             }         }     });      evt.editor.dataprocessor.datafilter.addrules({         elements :{             li : function( element ) {                 if( element && element.next && element.next.name == 'br' ){                     var nextelem = element.next;                             while( nextelem.next && nextelem.next.name == 'br' ){                         nextelem = nextelem.next;                     }                     var comment = new ckeditor.htmlparser.comment( 'cke_br_comment' );                     comment.insertafter( nextelem );                     }             }         }     }, 1 );//priority defaults 10      evt.editor.dataprocessor.htmlfilter.addrules({         comment : function( value, node ) {             if( value.indexof('cke_br_comment') >= 0 ) {                 return false;             }         }     }); 

});

here working example:
https://jsfiddle.net/8xpfq4ng/


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -