Hi All,
Perhaps an "easy" question.
I would like to configure CKEditor to toggle a style attribute between two states when clicking on a toolbar button (like bold):
- font-weight:normal;
- font-weight:bold;
When the selection is all bold, I'd like the button to show it as being applied. When the selection is mixed, I'd like the button to show it as not applied. Clicking on the button under the second scenario would cause the entire selection to be bolded using the corresponding style property above.
Is this possible out of the box? If not, is there an easy way to check the state of the current selection and create a button plugin to do this?
Any pointers would be appreciated.
There's a small detail in
There's a small detail in your question which perhaps makes it hard to solve :). This is - you want to switch between two styles. It is very easy to apply and remove one style, but not so easy to toggle between styles.
If it is enough for you to be able to apply/remove style using button, then check the basicstyles plugin: https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/basicstyles/plugin.js. As you can see it's trivial.
However, toggling is more complicated. I think that what you need to do is:
Anyway... it depends what effect will satisfy you. It should be possible to achieve something quickly, but polishing may require some effort.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+