将默认新行更改为 <p> 标记 tinymce rails

Change default new line to <p> tag tinymce rails

我正在使用 tinymce 并将我的内容保存到数据库。发生的事情是,当我在 tinymce 中按 enter 键时,它正在插入 <br> 标签。

所以我将 tinymce 配置中的一些内容更改为:

tinyMCE.init({
  force_br_newlines : false,
  force_p_newlines : true,
  ...
}

这与我的目的背道而驰。但是当我粘贴word中的内容时。它仍然插入 <br>.

是否有解决此问题的方法。

提前致谢。

注意:我的tinymce版本是3.4.7

是的,有。 您可以使用 paste_preprocess - Tinymce config parameter 随意修改粘贴的内容。

tinymce.init({
    paste_preprocess: function(plugin, args) {
        console.log(args.content);

        // your modifications here

        // example
        args.content = args.content.replace(/<br>/, '');
    }
});