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.

JGilmartin
  • 8,683
  • 14
  • 66
  • 85
  • 1
    6 years later and there is still no solution... – Qullbrune Jan 31 '17 at 09: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 `{repeat}{/repeat}
    Something
    `. `verify_html: false` does not help here.
    – Roger Sep 11 '17 at 15:22

5 Answers5

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
JGilmartin
  • 8,683
  • 14
  • 66
  • 85
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?

Thomas Upton
  • 1,853
  • 12
  • 22
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

Alex Radevich
  • 101
  • 1
  • 2
  • 3
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: '',
charliefortune
  • 3,072
  • 5
  • 28
  • 48
-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.

Thariama
  • 50,002
  • 13
  • 138
  • 166