javascriptckeditorckfinder

CKFinder 3 'Cannot set property 'filebrowserBrowseUrl' of undefined'


I'm new to Javascript. I've got a CKEditor text box, and would like to add CKFinder to it. I've followed the instructions found here:

https://ckeditor.com/docs/ckfinder/ckfinder3/#!/guide/dev_ckeditor

But when I try to execute the code, I get the following error:

Uncaught TypeError: Cannot set property 'filebrowserBrowseUrl' of undefined at Object.setupCKEditor (ckfinder.js:5)

Here is the block of Javascript where filebrowserBrowseUrl is defined:

CKEDITOR.replace( 'current_answer',
{
    filebrowserBrowseUrl      : '/ckfinder/ckfinder.html',
    filebrowserImageBrowseUrl : '/ckfinder/ckfinder.html?type=Images',
    filebrowserFlashBrowseUrl : '/ckfinder/ckfinder.html?type=Flash',
    filebrowserUploadUrl      : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
    filebrowserImageUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
    filebrowserFlashUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
});

    
CKFinder.setupCKEditor( current_answer );

I'm using the latest release of version 4 of CKEditor and the latest version of version 3 of CKFinder.

I get the same error when I comment out this line:

filebrowserBrowseUrl      : '/ckfinder/ckfinder.html',

Any help would be appreciated - thanks!


Solution

  • Looks like CKEDITOR.replace returns an object that you need to pass into CKFinder.setupCKEditor but you're currently not saving it.

    Try:

    let current_answer = CKEDITOR.replace( 'current_answer',
    {
        filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
        filebrowserImageBrowseUrl: '/ckfinder/ckfinder.html?type=Images',
        filebrowserFlashBrowseUrl: '/ckfinder/ckfinder.html?type=Flash',
        filebrowserUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
        filebrowserImageUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
        filebrowserFlashUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
    });
    
    
    CKFinder.setupCKEditor( current_answer );