Home » Php » javascript – TinyMCE 4 disable cleanup html

javascript – TinyMCE 4 disable cleanup html

Posted by: admin July 12, 2020 Leave a comment

Questions:

How can I disable the automatic cleaning of HTML code in TinyMCE 4.x
When I copy text from WORD, TinyMCE removes styles

How to&Answers:
tinyMCE.init({
    // ...
    cleanup : false,
    verify_html : false
});

Answer:

This might not fix all your problem but this allowed me to be able to use all html tags and attributes, so it might be a step in right direction.

tinyMCE.init({
    // ...
    valid_elements : '*[*]',
});

Edit :

This worked better for me:

tinyMCE.init({
    // ...
    extended_valid_elements : '*[*]',
});

Answer:

You will need to oppose this problem differtly because tinymce will cleanup the content no matter what.

Have a look at the tinymce config parameter paste_preprocess.

Using this param you can define a function in which you are able to modify the content to be inserted as you need to. This can be helpfull for debugging purposes too.

The other thing is you will need to define styles as valid using your valid_elements setting.