Edit: Found it. The solution is: http://docs.ckeditor.com/#!/api/CKEDITOR.style
var style = new CKEDITOR.style( { element: 'h1' } );
So simple. CKEditor is awesome.
--------------
I tried searching for this all day, but I haven't been able to find a good resource on this yet.
I'd like to add a button that, when clicked, styles the selected text.
For example: (Sorry this is going to be a contrived example.)
In the editor, if I select the raw text,
"Helloworld"
Then if I press the button, I want the HTML to become :
"He<u>llowor</u>ld"
Seems straightforward, but I'm also concerned with how it might work when there's already other pre-existing tags.
For example, if I wanted a result like this: HelloWorld
He<u>llo</u><strong><u>W</u>or</strong>ld
CKE is able to split up the tags but still stylize it the way I expected it to. How is it doing that?
So basically, I'm looking for a way to:
1. Get selected text (I know how to do this)
2. Apply style to selected text
3. Replace selected text (I know how to do this)
How can I apply styles in the robust manner described above? Thanks!