如何将h4标签添加到refinerycms编辑器?

Cat*_*ish 6 ruby ruby-on-rails refinerycms ruby-on-rails-3

我正在尝试将一个h4标签添加到refinerycms wysiwyg编辑器中.我该怎么做呢?没有找到任何关于此的文件.

我假设我必须对此配置var做一些事情:

config.wymeditor_whitelist_tags = {}
Run Code Online (Sandbox Code Playgroud)

par*_*ndt 20

以下说明适用于Refinery CMS的2.xx和3.xx版本.

但是,在版本3.xx中,您将需要使用custom_visual_editor_boot_options而不是custom_wymeditor_boot_options.

使用此文件:https://github.com/refinery/refinerycms/blob/master/core/app/assets/javascripts/admin.js您可以为Refinery中的WYMeditor指定自定义选项.

首先,您需要覆盖该文件:

bundle exec rake refinery:override javascript=admin
Run Code Online (Sandbox Code Playgroud)

现在,打开app/assets/javascripts/admin.js并将其编辑为如下所示:

// Use this to customize the wymeditor boot process
// Just mirror the options specified in boot_wym.js with the new options here.
// This will completely override anything specified in boot_wym.js for that key.
// e.g. skin: 'something_else'
if (typeof(custom_wymeditor_boot_options) == "undefined") { 
  custom_wymeditor_boot_options = {
    containersItems: [
      {'name': 'h1', 'title':'Heading_1', 'css':'wym_containers_h1'}
      , {'name': 'h2', 'title':'Heading_2', 'css':'wym_containers_h2'}
      , {'name': 'h3', 'title':'Heading_3', 'css':'wym_containers_h3'}
      , {'name': 'h4', 'title':'Heading_4', 'css':'wym_containers_h4'}
      , {'name': 'p', 'title':'Paragraph', 'css':'wym_containers_p'}
    ]
  }; 
}
Run Code Online (Sandbox Code Playgroud)

请注意,您正在执行的操作是覆盖boot_wym.js.erb,它仅将h1,h2,h3和p指定为容器标记.请参阅:https://github.com/refinery/refinerycms/blob/2-0-stable/core/app/assets/javascripts/refinery/boot_wym.js.erb#L49-L54

您在custom_wymeditor_boot_options中指定的任何选项都会覆盖boot_wym.js.erb中wymeditor_boot_options内的任何内容,因此请确保它是有效的Javascript,否则编辑器根本不会加载.

希望有所帮助; 如果你需要澄清任何事情,请告诉我.

菲尔

  • 稍微纠正一下,覆盖admin.js的命令是"捆绑exec rake refinery:覆盖javascript = admin"w/out .js扩展名 (11认同)
  • 另请注意,在3.x中它已被重命名为`custom_visual_editor_boot_options` ...花了一些时间来弄清楚它为什么不起作用.https://github.com/parndt/refinerycms-wymeditor/blob/master/app/assets/javascripts/refinery/boot_wym.js.erb#L5 (2认同)