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

javascript - config.js doesn't work for CKEditor - Stack Overflow

programmeradmin2浏览0评论

I have the following in my config.js for CKEditor:

CKEDITOR.editorConfig = function( config )
{
    config.toolbar =
    [
        [ 'Source', '-', 'Bold', 'Italic' ]
    ];
    // config.toolbar_Basic =
    // [
    //     [ 'Source', '-', 'Bold', 'Italic' ]
    // ];
    // config.toolbar = 'Basic';
}

The editor is still showing with all the options in the toolbar.

It is also loading the JS files in the right order:

<script src="/assets/ckeditor/init.js?body=1" type="text/javascript"></script>
<script src="/assets/ckeditor/ckeditor.js?body=1" type="text/javascript"></script>
<script src="/assets/ckeditor/config.js?body=1" type="text/javascript"></script>

So I am not sure what is happening here. Any thoughts?

Also important to note that I tried the alternative way of declaring that Basic toolbar (see the mented out code in the snippet above) and it didn't work either.

After every change, I restart my server.

I have the following in my config.js for CKEditor:

CKEDITOR.editorConfig = function( config )
{
    config.toolbar =
    [
        [ 'Source', '-', 'Bold', 'Italic' ]
    ];
    // config.toolbar_Basic =
    // [
    //     [ 'Source', '-', 'Bold', 'Italic' ]
    // ];
    // config.toolbar = 'Basic';
}

The editor is still showing with all the options in the toolbar.

It is also loading the JS files in the right order:

<script src="/assets/ckeditor/init.js?body=1" type="text/javascript"></script>
<script src="/assets/ckeditor/ckeditor.js?body=1" type="text/javascript"></script>
<script src="/assets/ckeditor/config.js?body=1" type="text/javascript"></script>

So I am not sure what is happening here. Any thoughts?

Also important to note that I tried the alternative way of declaring that Basic toolbar (see the mented out code in the snippet above) and it didn't work either.

After every change, I restart my server.

Share Improve this question edited Dec 30, 2012 at 22:04 Andrew Marshall 97k20 gold badges227 silver badges217 bronze badges asked Dec 30, 2012 at 22:02 marcamillionmarcamillion 33.8k57 gold badges199 silver badges393 bronze badges 2
  • Can you post a URL / jsFiddle with your issue? – Jeffery To Commented Jan 14, 2013 at 10:32
  • Not quite sure how to require ckeditor on jsFiddle. Also...not sure if the issue is related to Rails or just JS. I suspect it may be more of a Rails issue and not a JS issue. i.e. Rails pipeline is having some issues...or something of that nature. But, I can't put my finger on it. – marcamillion Commented Jan 16, 2013 at 4:17
Add a ment  | 

5 Answers 5

Reset to default 4

How do you load you ckeditor in place of the textarea? Maybe the toolbar is overridden there.

Your config.js file looks OK (both versions of it).

What may be wrong is how you load CKEditor. First of all - you don't need to load config.js - CKEditor will do that. Second, what's in the init.js file?

Have you cleared a cache in your browser? On some it can be really hard to do that automatically.

Download CKEditor 3.2.1 here: http://ckeditor./download

Extract the downloaded .tar.gz file.

Copy the contents of the ckeditor folder into /sites/all/modules/contrib/ckeditor/ckeditor

At this point you may want to edit the available toolbar options removing any unnecessary items. In most cases, I prefer the following configuration as it allows maximum fanciness while minimizing the types of markup which could override the site's styling

edit /sites/all/modules/contrib/ckeditor/ckeditor.config.js

Create a new toolbar by adding the following configuration to ckeditor.config.js:

**

config.toolbar_DrupalCustom = [
      ['Source'],
      ['Cut','Copy','Paste','PasteText','-','SpellChecker', 'Scayt'],
      ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
      ['Image','HorizontalRule','Smiley','SpecialChar'],
      ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
      ['NumberedList','BulletedList','-','Blockquote'],
      ['Link','Unlink','Anchor','LinkToNode', 'LinkToMenu'],      
      ['Format','Font','FontSize'],
      ['TextColor','BGColor'],
      ['Maximize', 'ShowBlocks'],
      ['DrupalBreak', 'DrupalPageBreak']
     ];

** You can now select this option within the CKEditor Appearance section at /admin/settings/ckeditor/edit/Advanced

I too had problems with CKEditor and the "caching" issue. Cleared cache, loaded a custom config file... and timestamps...

http://ckeditor./forums/CKEditor/Problem-with-config.js-not-updating

Nothing worked. Then i simply added it as options when instantiating the editor:

CKEDITOR.replace( 'controls_' + int_control_cnt + '_label_text' ,
            {
            toolbar: [
                ['Bold', 'Italic', 'Underline', '-', 'TextColor', '-', 'RemoveFormat'],
                ['Cut', 'Copy', 'Paste', '-', 'Undo', 'Redo']
            ]
            });

This did the trick

use only: <script src="ckeditor/ckeditor.js"></script>

and be sure to clear your browser cache!

发布评论

评论列表(0)

  1. 暂无评论