2

I'm using tinyMCE 3 (in my django app with django-tinymce). It's a very restricted set of html that I want output and I don't want tinyMCE adding inline styles or span elements.

I've used the valid_elements parameter for tinyMCE.init(), but this seems to only effect the html tinyMCE passes to my database - it doesn't seem to control the html in the textarea (spans and inline style are still being added). I want wysiwyg.

I've included my init parameters below (they're in python - django-tinymce passes these to the javascript when tinyMCE is initiated).

TINYMCE_DEFAULT_CONFIG = {

    'plugins': "paste",

    'paste_remove_styles': 'true',
    'paste_remove_styles_if_webkit': 'true',
    'paste_strip_class_attributes': 'all',

    'content_css': (STATIC_URL + 'css/normalize.css, ' + STATIC_URL +
                    'css/BrandonG.css, ' + STATIC_URL +
                    'css/main.css'),
    'theme': "advanced",
    'theme_advanced_toolbar_location': "top",
    'theme_advanced_buttons1': "bold,italic,underline,separator,"
        "bullist,separator,outdent,indent,separator,undo,redo,"
        "link,unlink",
    'theme_advanced_buttons2': "",
    'theme_advanced_buttons3': "",
    'height': 400,
    'valid_elements': "a[!style,href|target=_blank],strong[!style],ul[!style],li[!style],p[!style]"
}

How to I control the html in editing textarea?

Aidan Ewen
  • 13,049
  • 8
  • 63
  • 88

1 Answers1

0

To clean on paste use: http://www.tinymce.com/wiki.php/Plugin3x:paste

You can have advanced control over the html on submit with the new Event API: http://www.tinymce.com/wiki.php/API3:class.tinymce.Editor

allcaps
  • 10,945
  • 1
  • 33
  • 54