【问题标题】:Adding CodeSnippet Plugin to CKEditor in Rails App在 Rails 应用程序中将 CodeSnippet 插件添加到 CKEditor
【发布时间】:2015-03-23 01:59:19
【问题描述】:

我正在尝试将 CodeSnippet plugin 添加到 CKEditor(使用 ckeditor-rails 安装在我的 Rails 应用程序中)。为此,我首先将 CodeSnippet 插件文件夹及其所有依赖项添加到目录 app > assets > javascripts > ckeditor > plugins (因此我的插件文件夹包含用于 codesn-p、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

参考这行代码n-ps/plugin.js:

editor.addContentsCss( path + 'lib/highlight/styles/' + editor.config.codeSnippet_theme + '.css' );

谁能配置这个 CKEditor 以在 Rails 应用程序中使用 CodeSnippet 插件?

【问题讨论】:

    标签: javascript ruby-on-rails ckeditor code-snippets


    【解决方案1】:

    我无法使用任何 ckeditor gems 让它工作。结果,我完全删除了 ck_editor rails gem,并直接从 ckeditor 网站下载了一个带有我想要添加的插件的构建。

    然后我将整个 ckeditors 文件夹放入我的 app > assets > javascripts 文件夹中,并将以下内容添加到 application.js

    //= 需要 ckeditor/ckeditor.js

    我最终不得不通过直接编辑 ckeditor/ckeditor.js 进行一些自定义,但我终于能够让 CodeSnippet 插件以这种方式工作。

    希望这对某人有所帮助!

    【讨论】:

    • @scientific 你需要做什么定制?
    猜你喜欢
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 2017-04-14
    • 2021-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多