CKeditor:如何加载自定义插件?
CKeditor: how to load custom plugin?
我正尝试在 this guide 之后为 CKeditor 创建一个自定义插件。我按照指示创建了文件 (myplugin.png、myplugin.js、plugin.js) 并添加了
CKEDITOR_CONFIGS = { 'default': { 'extraPlugins': ','.join( [ 'myplugin' ] ), } }
进入设置。
但是,当我尝试加载页面时,编辑器没有出现,我在控制台中收到以下错误:
GET
http://127.0.0.1:8000/static/ckeditor/ckeditor/plugins/myplugin/plugin.js?t=GB8C
404 (NOT FOUND)
并在 Firebug 中:
Error: [CKEDITOR.resourceManager.load] Resource name "myplugin" was
not found at
"http://127.0.0.1:8000/static/ckeditor/ckeditor/plugins/myplugin/plugin.js?t=GB8C".
所有文件都在此处显示的路径中。
我可能做错了什么,但我找不到什么。我会很感激一点帮助谢谢你。这是我的 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'
});
}
});
干杯
我确实发现了问题。它与 CKeditor 无关,而是与 Django 处理静态文件的方式有关。
我已将我的自定义插件放入位于静态文件夹中的 ckeditor 文件夹中。这是错误的。 STATIC_ROOT 指定的静态文件夹仅由 运行 collectstatic 填充。任何以其他方式添加的文件都将被忽略。
通过将与自定义插件相关的文件放入另一个文件夹,在 STATICFILES_DIRS 中列出,然后 运行 collectstatic,它被添加到 STATIC_ROOT 文件夹中,然后可以提供。
我仍然有错误,但与查找资源无关。
我正尝试在 this guide 之后为 CKeditor 创建一个自定义插件。我按照指示创建了文件 (myplugin.png、myplugin.js、plugin.js) 并添加了
CKEDITOR_CONFIGS = { 'default': { 'extraPlugins': ','.join( [ 'myplugin' ] ), } }
进入设置。
但是,当我尝试加载页面时,编辑器没有出现,我在控制台中收到以下错误:
GET http://127.0.0.1:8000/static/ckeditor/ckeditor/plugins/myplugin/plugin.js?t=GB8C 404 (NOT FOUND)
并在 Firebug 中:
Error: [CKEDITOR.resourceManager.load] Resource name "myplugin" was not found at "http://127.0.0.1:8000/static/ckeditor/ckeditor/plugins/myplugin/plugin.js?t=GB8C".
所有文件都在此处显示的路径中。 我可能做错了什么,但我找不到什么。我会很感激一点帮助谢谢你。这是我的 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'
});
}
});
干杯
我确实发现了问题。它与 CKeditor 无关,而是与 Django 处理静态文件的方式有关。 我已将我的自定义插件放入位于静态文件夹中的 ckeditor 文件夹中。这是错误的。 STATIC_ROOT 指定的静态文件夹仅由 运行 collectstatic 填充。任何以其他方式添加的文件都将被忽略。 通过将与自定义插件相关的文件放入另一个文件夹,在 STATICFILES_DIRS 中列出,然后 运行 collectstatic,它被添加到 STATIC_ROOT 文件夹中,然后可以提供。 我仍然有错误,但与查找资源无关。