Search code examples
javascriptjqueryckeditortextinput

Use Ckeditor like a simple input text


I need to use CKEDITOR ( http://ckeditor.com/ ) like a simple

<input type="text" />

I modified the file config.js adding the following settings:

config.toolbar = 'SimpleVersion';
config.toolbar_SimpleVersion =
    [
        ['Cut','Copy','Paste','PasteText'],
    ];

Then, in the main page:

editor = CKEDITOR.replace("mydiv", { toolbar : 'SimpleVersion' });
editor.config.height = 50;
editor.config.removePlugins = 'resize';
editor.config.resize_enabled = false;

It works, but I need, if it's possible, to remove the bottom part where "body" is written, and also inhibit the new line whenever the Return button is pressed.

I think that for the last one, it may be possible to use a JQuery trigger.


Solution

  • I found the solution:

    1) when I create the editor there is a configuration option to toggle the bottom part of the editor

    editor = CKEDITOR.replace("mydiv", { toolbar : 'SimpleVersion', removePlugins : 'elementspath' });
    

    2) to inhibite the return button I've created the following trigger on key:

    editor.on('key', function(e) {
       var key = e.data.keyCode;      
           if(key==13){
              return false;
           }
    }
    );