13

I'm using N2CMS which in turn uses TinyMCE to edit HTML content.

what i need to do is disable the TinyMCE HTML validation completely.

Its stripping out anything out that doesn't adhere to its settings.

If I add a custom attribute <a href="{0}" test="tester1" /> it just removes it the custom attribute!

also, it always add <p> tags around every bit of HTML content.

how can i disable the validation?

any help is very much appreciated.

2
  • 1
    6 years later and there is still no solution...
    – Qullbrune
    Jan 31, 2017 at 9:09
  • verify_html: false seemed to work fine for me, for the custom attribute problem in the OQ. However, you cannot have customer attributes in tables, like this <table><tbody>{repeat}<tr><td>Something</td><td></tr>{/repeat}</tbody></table>. verify_html: false does not help here.
    – Mr Baloon
    Sep 11, 2017 at 15:22

5 Answers 5

16

to resove this, add these into the tinyMCE settings, or init

    cleanup_on_startup: false,
    trim_span_elements: false,
    verify_html: false,
    cleanup: false,
    convert_urls: false
3

There are a relatively large number of TinyMCE options related to cleaning up and validating HTML.

The valid_elements or extended_valid_elements option can definitely help you with custom attributes:

extended_valid_elements: "a[href|test]",

That option would specifically allow href and test attributes on anchor tags per your example.

As far as your second question is concerned, could you please clarify? Are you asking how to avoid escaping HTML code that is pasted into the WYSIWYG editor or are you asking how to avoid wrapping text in paragraph or div tags?

0
1

another solution, settings:

verify_html:false,
fix_table_elements:false,
schema:'html4',
invalid_elements:'', 
valid_elements:'[]', 
valid_children: '[]',

and I'm saving the html content to the hidden field by calling

tinymce.activeEditor.getContent({format: 'raw'})

this helps to prevent any html fixes

0

This is how I remove all sanitisation:

valid_elements: '*[*]',
plugins: "fullpage"

The valid_elements directive allows all elements and all of their attributes.

The fullpage plugin preserves the <html>,<head> tags etc.


To stop TinyMCE wrapping everything in <p> tags;

force_br_newlines: false,
force_p_newlines: false,
forced_root_block: '',
-3

Those tags are usually paragraphs or divs. They are essential for every rte. Tinymce puts them around every bit of html because it needs to in order to for example be able to style passages of text.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.