I'm trying to create a custom toolbar button that makes use of the command that's currently in the Format > Heading 2 combo box. However, I can't figure out the commandName to pass to the execCommand() function that would be able to call that specific command.
Is there a list of all the command names anywhere, or can anybody tell me how to execute the 'Heading 2' or 'H2' command? Thank you.
Is there a list of all the command names anywhere, or can anybody tell me how to execute the 'Heading 2' or 'H2' command? Thank you.
Re: execCommand help
I have the exact same problem as you.
I could not find any commands in the source code of CKEditor for heading 1, heading 2, etc.
But! this works. Where editor is a javascript variable being your CKEditor instance.
editor.focus();
editor.fire( 'saveSnapshot' );
var style = new CKEDITOR.style( editor.config[ 'format_' + 'h1' ] );
style.apply( editor.document );
editor.fire( 'saveSnapshot' );
I copy the same type of code that applies formats in /plugins/format/plugin.js its onclick method.
Anyway, it works, thats all I care about. Clearly ugly.
Thanks, Phil