Disable CKEditor 3 (Rich Text Editor) inside APEX

Von Tobias Arnhold 11.09.2011
If you want to disable the "Richt Text Editor" inside APEX and still show everything in the right HTML format. Just add this code snippet inside the "Page Footer Text":
<script>
/* HowtTo: http://cksource.com/forums/viewtopic.php?t=15659 */
$(document).ready( function() {
( function()
{
   var cancelEvent = function( evt )
      {
         evt.cancel();
      };

   CKEDITOR.editor.prototype.readOnly = function( isReadOnly )
   {
      /* Turn off contentEditable. */
      this.document.$.body.disabled = isReadOnly;
      CKEDITOR.env.ie ? this.document.$.body.contentEditable = !isReadOnly
      : this.document.$.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 );
      }
   }
} )();
setTimeout ('CKEDITOR.instances.<YOUR_APEX_ITEM>.readOnly( true )',1000);
});
</script>
The result will look like this:

Post Tags:

3 Comments " Disable CKEditor 3 (Rich Text Editor) inside APEX "

brian 17 September, 2012 01:32

Nice bit of code. Cheers, spent a daft amount of time looking for this.

Clive Bostock 01 December, 2015 20:05

Hi. I tried this in APEX 5. Not sure if the version is a factor, but couldn't
get it to work.

I modified the line:

setTimeout ('CKEDITOR.instances..readOnly( true )',1000);

to

setTimeout ('CKEDITOR.instances.p14_narrative.readOnly( true )',1000);

Where p14_narrative is the Rich Text Edit item in my region. Any ideas where I might be going wrong here?

Anonymous

its not working apex 5