Javascript 在Rails应用程序中将代码片段插件添加到CKEditor
我正在尝试将添加到CKEditor(使用安装在我的Rails应用程序中)。为此,我首先将CodeSnippet插件文件夹及其所有依赖项添加到目录app>assets>javascripts>ckeditor>plugins(因此我的插件文件夹包含CodeSnippet、dialog、dialogui、lineutils和widget的文件夹) 然后,我更新了我的app/assets/javascripts/ckeditor/config.js.coffee,包括以下内容:Javascript 在Rails应用程序中将代码片段插件添加到CKEditor,javascript,ruby-on-rails,ckeditor,code-snippets,Javascript,Ruby On Rails,Ckeditor,Code Snippets,我正在尝试将添加到CKEditor(使用安装在我的Rails应用程序中)。为此,我首先将CodeSnippet插件文件夹及其所有依赖项添加到目录app>assets>javascripts>ckeditor>plugins(因此我的插件文件夹包含CodeSnippet、dialog、dialogui、lineutils和widget的文件夹) 然后,我更新了我的app/assets/javascripts/ckeditor/config.js.coffee,包括以下内容: CKEDITOR.ed
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( {
editor.addContentsCss( path + 'lib/highlight/styles/' + editor.config.codeSnippet_theme + '.css' );
同样的错误
Uncaught TypeError: undefined is not a function
参考这行代码片段/plugin.js:
CKEDITOR.style.addCustomHandler( {
editor.addContentsCss( path + 'lib/highlight/styles/' + editor.config.codeSnippet_theme + '.css' );
有没有人能够将这个CKEditor配置为在Rails应用程序中使用CodeSnippet插件?我根本无法使用任何CKEditor gems实现这个功能。因此,我完全删除了ck_编辑器rails gem,直接从ckeditor网站下载了一个构建,并添加了我想要的插件 然后,我将整个ckeditors文件夹放入我的app>assets>javascripts文件夹,并将以下内容添加到application.js //=需要ckeditor/ckeditor.js 我最终不得不通过直接编辑ckeditor/ckeditor.js来进行一些定制,但我最终能够让代码片段插件以这种方式工作
希望这对别人有帮助 @scientific您需要做什么定制?