简体   繁体   中英

content css ignored after setData in CKEditor

I get the text and add some classes to spans. setData updates the content but the content css is not applied.

I can inspect(in Chrome) and see the new classes. I toggle on a Drupal page between flat text and WYSIWYG(disable-enable rich text) and it looks fine.

it is as if the editor forgets or stops applying the content css on setData

I tried:

 function submitaftersetdata() { this.updateElement(); this.checkdirty; CKEDITOR.config.contentsCss = 'http://www.mooyai.com/sites/all/modules/custom/languagetool/atd-ckeditor/atd.css'; alert('done'); } editor.setData(editorContents, submitaftersetdata); 

 editor.insertHtml(editorContents); 

works fine to add the new text and looks correct(the content css is applied)

setData to empty '' then insert works but again breaks the css

I found a weak work around:

 editor.execCommand( 'selectAll' ); editor.insertHtml(editorContents); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM