ReadOnly CKeditor

ReadOnly CKeditor

This code disable the editing in ckEditor.
(function() {
    var cancelEvent = function(evt) {
        evt.cancel();
    };
    CKEDITOR.editor.prototype.readOnly = function(isReadOnly) {
        // Turn off contentEditable. 
        this.element.$.disabled = isReadOnly;
        CKEDITOR.env.ie ? this.element.$.contentEditable = !isReadOnly : this.element.$.designMode = isReadOnly ? "off" : "on";
        // Prevent key handling. 
        this[isReadOnly ? 'on' : 'removeListener']('key', cancelEvent, null, null, 0);
        //this[isReadOnly ? 'on' : 'removeListener']('selectionChange', cancelEvent, null, null, 0); 
        // Disable all commands in wysiwyg mode. 
        var command, commands = this._.commands,
            mode = this.mode;
        for (var name in commands) {
            command = commands[name];
            isReadOnly ? command.disable() : command[command.modes[mode] ? 'enable' : 'disable']();
            this[isReadOnly ? 'on' : 'removeListener']('state', cancelEvent, null, null, 0);
        }
    }
})();
$(function() {
    // Advandec Toolbar 
    toolbarGroup = [{
        name: 'undo',
        groups: ['undo']
    }, {
        name: 'cleanup',
        groups: ['cleanup']
    }, '/', {
        name: 'basicstyles',
        groups: ['basicstyles', 'cleanup']
    }, {
        name: 'paragraph',
        groups: ['align', 'bidi']
    }, '/', {
        name: 'styles'
    }, {
        name: 'colors'
    }, {
        name: 'tools'
    }, {
        name: 'others'
    }, {
        name: 'about'
    }];
    editor = CKEDITOR.replace('<%= txaDocDescription.ClientId %>', {
        language: 'fa',
        toolbarGroups: toolbarGroup,
        pasteFromWordRemoveStyles: false,
        on: {
            instanceReady: function() {
                // Wait for the editor to be ready to set 
                // the language combo. 
            }
        }
    }).readOnly(true);
});