Search code examples
javascriptphpckeditorckeditor4.x

CKEditor 4.7x - Uncaught SyntaxError: Invalid shorthand property initializer


I am trying to get the imageuploader working with CKeditor and I get the following error:

Uncaught SyntaxError: Invalid shorthand property initializer load_ckeditor.js

Here is the contents of_ckeditor.js

CKEDITOR.plugins.addExternal( 
      'imageuploader', 
       '/themes/blog/imageuploader/', 
       'plugin.js' 
);

CKEDITOR.replace( 'editor1',{
    extraPlugins = 'imageuploader'
});

The error line number refers to this:

extraPlugins = 'imageuploader'

I have copied the code exactly per the example here: https://cdn.ckeditor.com/

When I remove, extraPlugins = 'imageuploader', the CKEditor loads properly but it is missing the plugin.


Solution

  • There's an error in your syntax, CKEDITOR.replace takes an object so it requires a colon not an equals. The correct implementation should be:

    CKEDITOR.replace( 'editor1',{
      extraPlugins: 'imageuploader'
    });