![](/img/trans.png)
[英]CKEditor codesnippet plugin is not working with ckeditor gem
[英]Adding CodeSnippet Plugin to CKEditor in Rails App
我正在尝试将CodeSnippet插件添加到CKEditor(使用ckeditor-rails安装在我的Rails应用程序中)。 为此,我首先将CodeSnippet插件文件夹及其所有依赖项添加到目录应用>资产> javascripts> ckeditor>插件(因此我的plugins文件夹包含用于codenippet,dialog,dialogui,lineutils和widget的文件夹)。
然后,我更新了我的app / assets / javascripts / ckeditor / config.js.coffee,使其包含以下内容:
CKEDITOR.editorConfig = (config) ->
config.startupShowBorders = true
config.resize_enabled = false
config.scayt_autoStartup = true
config.language = 'en'
config.width = '445px'
config.extraPlugins = 'widget,dialog,dialogui,lineutils,codesnippet'
config.toolbar_Default = [
{ name: 'basicstyles', items: [ 'Bold','Italic','Underline', '-', 'NumberedList','BulletedList', 'Link','Unlink', 'CodeSnippet','RemoveFormat' ] }
]
config.toolbar = 'Default'
true
当我尝试使用CKEditor加载网页时,我的JavaScript控制台出现以下错误:
Uncaught TypeError: undefined is not a function
引用此行的widgets / plugin.js:
CKEDITOR.style.addCustomHandler( {
和同样的错误
Uncaught TypeError: undefined is not a function
引用这行代码片段/plugin.js:
editor.addContentsCss( path + 'lib/highlight/styles/' + editor.config.codeSnippet_theme + '.css' );
任何人都可以配置此CKEditor在Rails应用程序中使用CodeSnippet插件吗?
使用任何ckeditor宝石,我都无法使它正常工作。 结果,我完全删除了ck_editor rails gem,并直接从ckeditor网站上下载了要添加插件的构建。
然后,我将整个ckeditors文件夹放入我的应用程序>资产> javascripts文件夹中,并将以下内容添加到application.js
// =需要ckeditor / ckeditor.js
我最终不得不通过直接编辑ckeditor / ckeditor.js进行一些自定义,但是我终于能够使CodeSnippet插件以这种方式工作。
希望这对某人有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.