Thursday, May 3, 2012

How to convert Salesforce rich text editor to a “full mode” editor?

New CKEditor is object rather than URL based and a new approach is needed. In case anyone needs it, the following script will replace CKEDITOR editor layout with a full version allowing additional formating options (fonts, colors, etc). Note, I set the height to 500px, adjust for your own needs. Also, as before, this can only work in your own VF pages.
$(document).ready(function(){
        CKEDITOR.on('instanceReady', function(e) {
            if (e.editor.config.magic) return;
            var target = e.editor.config.bodyId;
            var name = e.editor.name;
            e.editor.destroy();
            CKEDITOR.editorConfig = function( config ) { config.magic = true; }
            CKEDITOR.replace(name, {
                        height : 500, 
                        bodyId : target
            });
        });
});
The result:
enter image description here

1 comment: