1

I'm using the latest version (4.7.0) of ckeditor.

I installed it via npm and it lives inside a regular frontend (no fancy js framework).

Problem: The translation js-file - im my case "de.js" is loaded from the wrong url.

When I check the code I see the following in the code:

CKEDITOR.scriptLoader.load(CKEDITOR.getUrl("lang/"+a+".js"),f,this)

Which add just lang/de.js to my current url instead of going to my static file folder.

My config looks like this:

CKEDITOR.editorConfig = function (config) {
config.toolbar = 'Custom';

config.toolbar_Custom = [

{
  name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Styles',
  'Format', 'NumberedList', 'BulletedList', 'Undo', 'Redo', 'Image',   'Smiley'],
 },
];
config.extraPlugins = 'clipboard,dialog,uploadimage,uploadfile';
config.imageUploadUrl = '/uploader/';
config.uploadUrl = '/uploader/';    
};

I tried to add:

config.baseHref = '/static/ckeditor/';

and

config.path = '/static/ckeditor/';  

and

config.basepath = '/static/ckeditor/'; 

But still, the code is loaded from the relative URL.

Does anybody know how to properly configure the editor so it's not loading the files from a (wrong) relative path?

Thx

Ron

UPDATE:

This is my config file, I add it via the customConfig parameter:

CKEDITOR.editorConfig = function( config ) {
 config.toolbar = 'Custom';

  config.toolbar_Custom = [

    {
      name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Styles',
      'Format', 'NumberedList', 'BulletedList', 'Undo', 'Redo', 'Image', 'Smiley'],
    },
  ];
  config.extraPlugins = 'clipboard,dialog,uploadimage,uploadfile';
  config.imageUploadUrl = '/uploader/';
  config.uploadUrl = '/uploader/';
  config.basePath = '/static/ckeditor/';
};
Ron
  • 22,128
  • 31
  • 108
  • 206

1 Answers1

4

There is CKEDITOR.basePath which defines:

The full URL for the CKEditor installation directory.

So the paths for files loaded by CKEditor will be based on this config option if it is set.


You can also use window.CKEDITOR_BASEPATH (see this answer for detailed description):

It is possible to manually provide the base path by setting a global variable named CKEDITOR_BASEPATH. This global variable must be set before the editor script loading.


Any of this two should solve your issue, just use:

CKEDITOR.basePath = '/static/ckeditor/';

or

window.CKEDITOR_BASEPATH = '/static/ckeditor/';

The second one is useful when loading CKEditor by any module loader (like browserify). If it is not the case for you, the first option should be sufficient.

f1ames
  • 1,714
  • 1
  • 19
  • 36
  • Ok, false alarm. I thought it works but still no effect on the server. Do you maybe have a plan b? – Ron Sep 22 '17 at 15:23
  • Do you have any browser console output which shows from what urls/path CKEditor is trying to load those files? Does using `CKEDITOR.basePath` or `CKEDITOR_BASEPATH ` changes the urls requested by CKEditor? – f1ames Sep 22 '17 at 15:51
  • I have it now. The url ist just the current url, the basePath is not taken it seems. I'm going via "customConfig" and include a config file. – Ron Sep 25 '17 at 08:34
  • ok, was a problem with the serving of the static files. django-assets was the bad guy. Thx for your help! – Ron Sep 25 '17 at 10:19