leemon
leemon

Reputation: 1061

Custom templates in CKEditor

I'm trying to load some custom templates in CKEditor but I can't manage to make it work.

This is the part of the config.js dealing with custom templates:

config.templates = 'default';
config.templates_files = [ '/mytemplates/mytemplates.js' ];
config.templates_replaceContent = false;

I've created a /mytemplates folder inside the root of the CKEditor folder and put the mytemplates.js (an exact copy of the default.js file that comes with the content templates plugin) inside it, but it seems the editor is not loading them. I'm getting the following error:

Uncaught TypeError: Cannot read property 'imagesPath' of undefined in the imagesPath = definition.imagesPath, line of the /plugins/templates/dialogs/templates.js file.

Any ideas?

Thanks in advance

Upvotes: 0

Views: 1852

Answers (1)

leemon
leemon

Reputation: 1061

I managed to fix this using the CKEDITOR.getUrl() function:

config.templates_files = [ CKEDITOR.getUrl( 'mytemplates/mytemplates.js' ) ];

I don't know if there's a way to use custom templates placed outside the CKEditor folder. If so, post a comment here, please.

Thanks

Upvotes: 3

Related Questions