2017-08-06 91 views
0

我想在CKEditor中加载一些自定义模板,但我无法设法使其工作。CKEditor中的自定义模板

这是处理自定义模板的config.js的一部分:我创建了CKEditor的文件夹的根目录内的文件夹/mytemplates,把default.jsmytemplates.js(精确复制

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

内容模板插件附带的文件),但编辑器似乎没有加载它们。我收到以下错误:

Uncaught TypeError: Cannot read property 'imagesPath' of undefinedimagesPath = definition.imagesPath,行的/plugins/templates/dialogs/templates.js文件。

任何想法?

在此先感谢

回答

3

我管理这个使用CKEDITOR.getUrl()功能来修复:

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

我不知道是否有使用放置在CKEditor的文件夹以外的自定义模板的方法。如果是这样,请在这里发表评论。

感谢

+1

路径模板文件,您使用的是相对的,可能不适用于当前的CKEditor目录,'CKEDITOR.getUrl()'是一个不错的办法。要从CKEditor目录之外加载文件,您可以使用完整的URL(例如'http://yourdomain.com /.../ mytemplates.js')或适当的相对URL(如果文件是正确加载)。 – f1ames

+0

感谢您的洞察! – user1991185