Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CkEditor Cannot set property 'dir' of undefined

I want to use CKEditor.

I have currently install CKEditor using npm

So it is installed in node_modules folder

My folder structure is like

app --> index.js

node_modules -->ckeditor -->...

and I have required it in index.js

also set variable before initialization of library

 var CKEDITOR_BASEPATH = '../node_modules/ckeditor'

still getting the dir error

suggest some help

like image 435
Hopp Avatar asked Jan 18 '17 11:01

Hopp


2 Answers

Try changing

var CKEDITOR_BASEPATH = '../node_modules/ckeditor';

to

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

Don't forget the trailing slash on the directory

And try putting the window declaration above your import of ckeditor

Check out this link for more information: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Specifying_the_Editor_Path

like image 90
NoToBagels Avatar answered Nov 09 '22 16:11

NoToBagels


For others with this problem (since it still persists as of the newest version at this time), if you have self-hosted the CKEditor script in your solution (for example for a classic ASP.NET application) and you do not have all the localization files of the plugin in your CKEditor folder, that can cause this issue to happen. I tried using NoToBagels solution, but it changed nothing for me.

We for example only had the en.js file in our /CKEditor/lang/ folder, and the bug occurred when a user that had both english and danish as his browser languages. CKEditor tried to automatically set the language of the editor to Danish, and tried to load the /CKEditor/lang/da.js file, which did not exist (which caused a 404 error). Adding the following to the config.js file fixed the problem for us:

config.language = 'en';

setting config.language ensures that the language of the editor is set to english instead of it being auto detected.

like image 3
Loyalar Avatar answered Nov 09 '22 17:11

Loyalar