0

我正在从任何来源(如 MS word、Open office writer 或任何网站)复制文本并将其粘贴到富文本编辑器中。但是在网站上粘贴之后,我们要删除除粗体、斜体和下划线之外的所有样式。下面是我尝试实现的示例代码,但在 h1、h2、h3 等情况下仍然没有。请建议如何实现它。提前致谢。

tinymce.init({
         selector : "#job_description",
         menubar : false,
         statusbar : false,
         theme : "modern",
         toolbar : "bold italic underline | bullist numlist",
         content_css : "resources/css/richTextEditor.css",
         plugins: 'paste',
         paste_auto_cleanup_on_paste : true,
         paste_remove_styles: true,
         paste_remove_styles_if_webkit: true,
         paste_strip_class_attributes: true

      });

richTextEditor.css:-

.mce-item-table {
    /*overflow-x:hidden!important;*/
    width: auto!important;
}

.mce-content-body span,p{
    font-size: 16px!important;
    text-decoration: none!important;
    color: #858585!important;
    font-weight: 400!important;
    font-family: 'Roboto', sans-serif !important;
}
4

1 回答 1

0

粘贴插件不会删除语义正确的标签,比如<h1>- 如果你想这样做,我会实现paste_postprocess过滤器,然后你可以将这些标签转换成你喜欢的任何东西。

https://www.tinymce.com/docs/plugins/paste/#paste_postprocess

于 2017-03-02T16:52:57.857 回答