Hello, I am trying to figure out how to add a stylesheet through my plugin. I have a folder /MyModule/ and inside that i have /MyModule/styles.css. I don't want to override all the other styles that have been set for CKEditor, I want to append new ones.
I'm placing all my code inside
CKEDITOR.plugins.add( 'MyModule', {
init: function( editor )
{....code inserted here
}
}
Things I've tried:
- editor.addCss( 'body { background-color: grey; }' );
- editor.config.contentsCss += ','+this.path+'styles.css';
- CKEDITOR.config.stylesSet = 'custom_styles:' + this.path + 'styles.css';
- CKEDITOR.document.appendStyleSheet( this.path + 'styles.css');
- var head = document.getElementsByTagName("head")[0];
var style = document.createElement("link");
style.setAttribute("rel", "stylesheet");
style.setAttribute("type", "text/css");
style.setAttribute("id", "__MyModule__");
style.setAttribute("href", this.path + "styles.css");
head.appendChild(style); -
var link = new CKEDITOR.dom.element( 'link' );
link.setAttributes( {
rel: 'stylesheet',
type: 'text/css',
href: this.path + "styles.css"
} );CKEDITOR.document.getHead().append(link);
If i go in source and add a <span class='newclass'>asdfa</span> and switch back I do not see any styles being apply to my content. Also if I inspect the element and go to the CKEditors IFrame, I can see it applying all the other styles but not the one I'm trying to append.
Thanks
I am running on Drupal 7 with ckeditor 4.3.