微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – 如何将h4标签添加到refinerycms编辑器?

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

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

config.wymeditor_whitelist_tags = {}

解决方法

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

但是,在版本3.x.x中,您将需要使用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

现在,打开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'}
    ]
  }; 
}

请注意,您正在执行的操作是覆盖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,否则编辑器根本不会加载.

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

菲尔

原文地址:https://www.jb51.cc/ruby/267509.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐