5

I'm using the CKEditor module and I need to adjust config.js in the module's root. The problem is I don't want to make changes to any files part of the module because all those changes will get blasted when I do a code update.

How can I apply changes to CKEditor's config.js without modifying the module's copy of config.js?

1

4 Answers 4

3

Can you add the setting inside the Custom JavaScript configuration field of the Advanced Options for a particular profile?

There's also the ability to load your own custom config.js file in the 'Load ckeditor.config.js from the theme path' setting under the 'Advanced' section in the CKEditor profile settings.

1
  • I upvoted your answer
    – B2F
    Commented Sep 29, 2014 at 21:07
3

Add a custom javascript to your theme/module with next content:

(function ($) {
  Drupal.behaviors.MYMODULE = {
    attach: function () {
      if (CKEDITOR !== undefined) {
        // Extend CKEDITOR.config here...
        // For example:
        CKEDITOR.config.wordcount = {
          showWordCount: true,
          showCharCount: true
        }
      }
    }
  }
}(jQuery));
1
  • 1
    This still works in D8 .. :D
    – rémy
    Commented Aug 5, 2020 at 22:35
1

Well, since you are not using the WYSIWYG module but the CKEditor module, you can put a ckeditor.plugin.js in your theme root dir.

You will then have to check the "Load ckeditor.config.js from the theme path" radio button in your module Advanced Options. It is located at /admin/config/content/ckeditor/edit/"Profile" and read:

When enabled, the editor will try to load the ckeditor.config.js file from the theme directory.

You could also put string settings in the "Custom JavaScript configuration" UI area directly.

Edit: in short you could have accepted "geerlingguy" answer back then, I would have noticed it.

1
  • The path /admin/config/content/ckeditor/edit/ doesn't appear to exist anymore. Using D10.
    – Pegues
    Commented Jun 28 at 9:29
0

If you use the WYSIWYG module you can install CKEditor as a library and then it is separate from the module code.

EDIT: As Lester pointed out, this wont work out of the box, see my answer on his other post WYSIWYG CKEditor config.js not being used?

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.