更改CKEditor渲染的默认HTML

时间:2018-11-06 08:09:52

标签: javascript ruby-on-rails ckeditor ckeditor4.x

我在我的Rails 5应用程序中使用了CKEditor gem。 CKEditor中的文本呈现为:

<p>Foo</p>

我想做的是使其像在显示视图上一样呈现(在使用CKEditor创建记录之后):

<p class="lead">Foo</p>

Reading the documentation,我看到<p>,`format_p',

有一个配置选项

因此我基于documentation添加了一个javascripts/ckeditor/config.js文件:

CKEDITOR.editorConfig = function (config) {
  config.format_p = { element: 'p', attributes: { 'class': 'lead' } };
}

在application.js中,我有这个:

//= require_directory .

但是,它仍然仅使用<p>进行渲染。

application.js

//= require jquery3.min
//= require rails-ujs
//= require jquery-ui
//= require popper.min
//= require bootstrap.min
//= require jquery.slimscroll
//= require jquery.core
//= require jquery.app
//= require datatables
//= require activestorage
//= require turbolinks
//= require footable.min
//= require select2-full
//= require moment
//= require datepicker-init
//= require daterangepicker-init
//= require daterangepicker
//= require jquery.counterup.min
//= require jquery.scrollTo.min
//= require metisMenu.min
//= require modernizr.min
//= require bootstrap-datepicker.min
//= require bootstrap-filestyle.min
//= require bootstrap-notify.min
//= require cable
//= require tags_field
//= require symbol_field
//= require waves
//= require wow.min
//= require ckeditor/init
//= require_directory 

0 个答案:

没有答案