最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited Apr 24, 2023 at 16:03 dove 20.7k14 gold badges86 silver badges110 bronze badges asked Oct 21, 2010 at 13:28 TripTrip 27.1k48 gold badges162 silver badges281 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 14

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: ''

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>

发布评论

评论列表(0)

  1. 暂无评论