I recently added CKEditor to my app and I would like to include my own CSS stylesheets within the editor so that I can select them within the editor.
How do I accomplish this? My code so far looks like this:
I recently added CKEditor to my app and I would like to include my own CSS stylesheets within the editor so that I can select them within the editor.
How do I accomplish this? My code so far looks like this:
Please look at @metavida answer for a better answer than this
Though if you're using this in more than one place it'd be best to look at putting this into the stylescombo\styles\default.js file and updating your config.js file accordingly as per api.
You can also read the full documentation of the stylesSet.add
syntax:
This works for me
CKEDITOR.addCss('body{background:blue;}');
As has already been mentioned, there is a page explaining how to set up a set of custom styles. What the little gem hidden on that page (and not really clear) is that rather than creating a named set of styles, you can define the styles inline in your configuration, like this:
stylesSet : [ { name : 'Green Title', element : 'h3', styles : { 'color' : 'Green' } } ],
Little late to the party here, but the default styles are in _source/plugins/styles/styles/default.js
. You could use that as your style config and add styles and it would effectively be appending.
The best way is to use this plugin: http://ckeditor.com/addon/stylesheetparser
Paste it inside the 'ckeditor/plugins' directory, then include something like this in your 'ckeditor/config.js':
config.extraPlugins = 'stylesheetparser'; config.contentsCss = '/css/inline-text-styles.css'; config.stylesSet = [];
Where '/css/inline-text-styles.css' is a path to your own css folder in your webroot, outside of ckeditor. That saves you having to mix css with javascript.