Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to override CKEditor's config file for each instance of the editor?

I have a global size and height set

CKEDITOR.editorConfig = function( config )
{
  config.height = '400px';
  config.width = '600px';
  ...

And I would like to change this height and width for only one instance of the editor on a seperate page. Has anyone else accomplished this?

like image 299
Trip Avatar asked Oct 21 '10 13:10

Trip


People also ask

Where is the config file for CKEditor?

The main configuration file is named config. js . This file can be found in the root of the CKEditor 4 installation folder.

How do you increase CKEditor height?

The CKEDITOR. config. height option sets the height of the editing area with CKEditor 4 content — it does not include the toolbar or the bottom bar. This configuration option accepts an integer (to denote a value in pixels) or any CSS-defined length unit except percent ( % ) values which are not supported.

What is CKEditor replace?

The CKEditor 4 Find and Replace feature allows for finding and replacing any text in the editor easily. It helps the user find words, word parts or phrases matching the case of the searched text, which is especially helpful in lengthy documents and one that may utilize certain words in different contexts.

How do I edit CKEditor?

Classic Editor with Default Source Editing Area Source editing is provided by the Source Editing Area plugin. Follow the steps below to try it out: Click the Source button to display the HTML source of this text in the source editing area. Click the Source button again to return to the WYSIWYG view.


2 Answers

Yes. When you create the editor on the page, you can override

CKEDITOR.replace(editorName, {
            height: 448,
            width: 448,
            customConfig: '/path/to/yourconfig.js'
});

In fact as a performance recommendation you can put all the configuration options here and save the loading of the config file separately. You might do this in a shared JavaScript file of your own, parametrized to override specific values for a page.

UPDATE in response to comment

A separate config file can be used like any other setting (look above with customConfig. If you don't want any custom configs loaded use

customConfig: ''
like image 173
dove Avatar answered Oct 19 '22 13:10

dove


You can resize editor on instanceReady event:

CKEDITOR.on 'instanceReady', (evt) ->
  setCustomHeight(evt.editor)

setCustomHeight = (editor) ->
  height = $(editor.element.$).attr('height')
  return unless height

  editor.resize('100%', height)

Now you have to specify height attribute on the textarea for which you want to have custom height:

<textarea id="my-editor" height="250"></textrarea>

like image 23
Hirurg103 Avatar answered Oct 19 '22 14:10

Hirurg103