grustamli
grustamli

Reputation: 466

Remove inline styles from django-tinymce html content

When I save content through django-tinymce it adds its own inline styles. However I'd like to remove this behaviour and just save the content in plain html. Can you please help me on this issue?

Upvotes: 1

Views: 1303

Answers (2)

yestema
yestema

Reputation: 8102

You can use any of tinyMCE configs like this:

Put this to your Django settings.py (this will tell tinyMCE which elements are allowed`)

DJANGO settings.py

TINYMCE_DEFAULT_CONFIG = {
    'theme': "advanced",
    'valid_elements' : 'a[href|target=_blank],strong/b,div[align],br,p'
}

And push Clean Button in TinyMCE.

All TinyMCE configs is here:

Try also look at invalid_elements and invalid_styles

P.S. It would have more sense to set:

'invalid_elements': 'p[styles], span'

to remove all styles But It didn't work.

Hope it helps.

Upvotes: 1

user7881930
user7881930

Reputation:

You could try writing your own implementation of a save function using

getContent({format: 'text'})

I'm no Djanjo expert but it sounds like the problem is being caused by them, and not TinyMCE itself.

Upvotes: 0

Related Questions