How can I simulate user-selection of some style from the styles-box, through JS? I want to put some shortcut buttons that assign some of the popular styles with one click.
EDIT:
- I don’t care if it’ll be in-editor button or outer button.
- I don’t want css-style assignment; I want CKEditor-style assignment (those of the styles-box).
I haven’t used CKEditor, but, I saw your question and thought “That would be fun to figure out.” Well, here is what I figured out:
(yes, I found terrible documentation, but, that’s not the point…I will give them props for commenting their code, though.)
Here is a Javascript function to aid your click events:
Now, you can create a link like this:
and use a bit of jQuery to spice it up:
I am not 100% sure about the button icon part. I didn’t have an icon to try it with. But, according to a few posts, it should work fine. Regardless, the jQuery click binding works.
That should be pretty much it! I had to do quite a bit of digging around to figure this out, but it certainly is satisfying to see it work!