Ho folks.
I've changed my CKEditor styles in this file, and they look great inside the editor:
ckeditor/plugins/styles/styles/default.js
I store the html generated from this into a database. At the moment, it will store data like this:
<p>Whatever</p>
<table><tr><td>asdas</td></tr></table>
but is there any way for me to append class names to these elements, so I can display them properly on another page? For example:
<p class="whatever">Whatever</p>
<table class="anotherwhatever"><tr><td class="andanotherwhatever">asdas</td></tr></table>
Or even style tags would do the trick?
<p Style="font-size:16px;">Whatever</p>
Thanks for any help.
I've changed my CKEditor styles in this file, and they look great inside the editor:
ckeditor/plugins/styles/styles/default.js
I store the html generated from this into a database. At the moment, it will store data like this:
<p>Whatever</p>
<table><tr><td>asdas</td></tr></table>
but is there any way for me to append class names to these elements, so I can display them properly on another page? For example:
<p class="whatever">Whatever</p>
<table class="anotherwhatever"><tr><td class="andanotherwhatever">asdas</td></tr></table>
Or even style tags would do the trick?
<p Style="font-size:16px;">Whatever</p>
Thanks for any help.
Re: Adding 'class' attributes?
Is there any way that, when I insert a table by default, that the border is set to '1px solid #000000' as opposed to what it is?
I set a custom style up for 'td' elements in ckeditor/plugins/styles/styles/default.js but it appears to apply the td style to the table for some reason, and screws it up.
The reason I ask is because I need inline style as I'm using the html generated in here to send an email etc.
Thanks.....
Re: Adding 'class' attributes?
Re: Adding 'class' attributes?
I've done this:

CKEDITOR.stylesSet.add('default', [
{ name: 'Paragraph', element: 'p', styles: { 'font-size': '24px'} }
]);
And when I initially write, I get:
<p>asdfasdfsd</p>
Then if I select my 'Paragraph' style, every paragraph therein is like this:
<p style="font-size: 24px">asdasdas</p>
Which is what I want!! But how do I get this style to apply without having to select my 'Paragraph' style???? I want it to apply straight away. Is this possible?
Re: Adding 'class' attributes?
Re: Adding 'class' attributes?
Table has an advanced tab, where you can specify the Style and Stylesheet Classes. I'd leverage that.
I would suggest something like this...
I didn't run this code, but I do very similar stuff in other dialogs, just not to styles.
You can find out where to include the code under "ckedit configuration", there's options. Anyway use the "source" button to test your changes.
Hope that helps, good luck
Re: Adding 'class' attributes?
Re: Adding 'class' attributes?
Re: Adding 'class' attributes?
And why don't you set it as default in your css file? Very curious.
Re: Adding 'class' attributes?
Re: Adding 'class' attributes?
Re: Adding 'class' attributes?
put this in your afterinit event.
and just add for every element you want to rewrite with inline styles.
There are several dataProcessor examples in the docs and good examples in the _source/plugins folder.
Hope that helps.
Re: Adding 'class' attributes?
I reworked things a different way but this looks much nicer.
- Tim