0

I am copying text from any of the sources like MS word, Open office writer or from any website and paste it in the rich text editor. But after pasting it in the website, we want to remove all the styles except bold, Italic and underline. Below is the sample code which I have tried to achieve it but it's still not in case of h1,h2,h3 and so on. Please suggest how to achieve it. Thanks in advance.

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;
}

1 Answers1

0

The paste plugin won't remove semantically correct tags like <h1> - if you want to do this I would implement the paste_postprocess filter and then you can transform these tags into whatever you like.

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

Michael Fromin
  • 13,131
  • 2
  • 20
  • 31