我正在尝试在this guide之后为CKeditor创建一个自定义插件 . 我按照指示创建了文件(myplugin.png,myplugin.js,plugin.js)并添加了
CKEDITOR_CONFIGS = { 'default': { 'extraPlugins': ','.join( [ 'myplugin' ] ), } }
到设置 .
但是,当我尝试加载页面时,编辑器没有出现,我在控制台中收到以下错误:
获取http://127.0.0.1:8000/static/ckeditor/ckeditor/plugins/myplugin/plugin.js?t=GB8C 404(未找到)
在Firebug中:
错误:[CKEDITOR.resourceManager.load]在“http://127.0.0.1:8000/static/ckeditor/ckeditor/plugins/myplugin/plugin.js?t=GB8C”中找不到资源名称“myplugin” .
所有文件都完全位于此处显示的路径中 . 我可能做错了但我找不到什么 . 我很感激你的帮助谢谢 . 这是我的plugin.js文件的内容:
CKEDITOR.plugins.add( 'myplugin', {
icons: 'myplugin',
init: function( editor ) {
// Plugin logic goes here...
editor.addCommand( 'myplugin', new CKEDITOR.dialogCommand( 'mypluginDialog' ) );
editor.ui.addButton( 'myplugin', {
label: 'My Plugin',
command: 'myplugin',
toolbar: 'insert'
});
}
});
干杯
1 回答
我实际上发现了这个问题 . 它与CKeditor无关,而是与Django处理静态文件的方式有关 . 我已将自定义插件放入静态文件夹中的ckeditor文件夹中 . 这是错的 . STATIC_ROOT指定的静态文件夹只能通过运行collectstatic来填充 . 以其他方式添加的任何文件都将被忽略 . 通过将与自定义插件相关的文件放入STATICFILES_DIRS中列出的另一个文件夹中,然后运行collectstatic,它将被添加到STATIC_ROOT文件夹中,然后可以提供 . 我仍然有错误,但与查找资源无关 .