在 Rails 应用程序中将 CodeSnippet 插件添加到 CKEditor
Adding CodeSnippet Plugin to CKEditor in Rails App
我正在尝试添加 CodeSnippet plugin to CKEditor (installed in my Rails app using ckeditor-rails)。为此,我首先将 CodeSnippet 插件文件夹及其所有依赖项添加到目录 app > assets > javascripts > ckeditor > plugins(所以我的插件文件夹包含 codesnippet、dialog、dialogui、lineutils 和小部件)。
然后我更新了我的 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
参考codesnippets/plugin.js这一行:
editor.addContentsCss( path + 'lib/highlight/styles/' + editor.config.codeSnippet_theme + '.css' );
有人能够配置此 CKEditor 以在 Rails 应用程序中使用 CodeSnippet 插件吗?
我无法使用任何 ckeditor gems 来让它工作。结果,我完全删除了 ck_editor rails gem 并直接从 ckeditor 网站下载了一个构建,其中包含我想要添加的插件。
然后我将整个 ckeditors 文件夹放入我的 app > assets > javascripts 文件夹并将以下内容添加到 application.js
//= 要求 ckeditor/ckeditor.js
我最终不得不通过直接编辑 ckeditor/ckeditor.js 来进行一些自定义,但我终于能够让 CodeSnippet 插件以这种方式工作。
希望这对某人有所帮助!
我正在尝试添加 CodeSnippet plugin to CKEditor (installed in my Rails app using ckeditor-rails)。为此,我首先将 CodeSnippet 插件文件夹及其所有依赖项添加到目录 app > assets > javascripts > ckeditor > plugins(所以我的插件文件夹包含 codesnippet、dialog、dialogui、lineutils 和小部件)。
然后我更新了我的 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
参考codesnippets/plugin.js这一行:
editor.addContentsCss( path + 'lib/highlight/styles/' + editor.config.codeSnippet_theme + '.css' );
有人能够配置此 CKEditor 以在 Rails 应用程序中使用 CodeSnippet 插件吗?
我无法使用任何 ckeditor gems 来让它工作。结果,我完全删除了 ck_editor rails gem 并直接从 ckeditor 网站下载了一个构建,其中包含我想要添加的插件。
然后我将整个 ckeditors 文件夹放入我的 app > assets > javascripts 文件夹并将以下内容添加到 application.js
//= 要求 ckeditor/ckeditor.js
我最终不得不通过直接编辑 ckeditor/ckeditor.js 来进行一些自定义,但我终于能够让 CodeSnippet 插件以这种方式工作。
希望这对某人有所帮助!