Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a plugin on CKEditor when is used from the CDN?

I followed the steps on the CDN Guidelines page for CKEditior, but I can't make it work. The plugin that I'm trying to install is "autoembed" (or any plugin that lets me insert a video from YouTube, a Tweet and all of those different content types), but even when I tried different ways, I can't get it to work.

I was also reading the documentation on using a custom config file, where apparently they let you create a custom config config.js file, but it too doesn't work, or I'm not qualified to make it work.

like image 753
William Romero Avatar asked Oct 08 '15 19:10

William Romero


People also ask

Where do I put CKEditor config?

CKEditor 4 comes with a rich set of configuration options that make it possible to customize its appearance, features, and behavior. The main configuration file is named config. js . This file can be found in the root of the CKEditor 4 installation folder.


1 Answers

There's a method in CKEDITOR.resourceManager called addExternal. You can use it like

// Loads a plugin from '/myplugin/samples/plugin.js'.
CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' );

Then simply add autoembed to config.extraPlugins = 'autoembed' like

CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' );

CKEDITOR.replace( 'element', {
    extraPlugins: 'sample'
} );

or in config.js:

CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' );

CKEDITOR.editorConfig = function( config ) {
    config.plugins = 
        'sample,' +
        ...    
};
like image 103
oleq Avatar answered Sep 24 '22 17:09

oleq