JGilmartin
JGilmartin

Reputation: 9298

TinyMCE - Completely disable validation

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.

Upvotes: 13

Views: 12311

Answers (5)

Alex Radevich
Alex Radevich

Reputation: 111

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

Upvotes: 1

charliefortune
charliefortune

Reputation: 3198

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: '',

Upvotes: 0

Thomas Upton
Thomas Upton

Reputation: 1899

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?

Upvotes: 3

Thariama
Thariama

Reputation: 50832

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.

Upvotes: -3

JGilmartin
JGilmartin

Reputation: 9298

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

Upvotes: 16

Related Questions