Remove formatting (inline styles) when pasting HTML into Tiny MCE
Hi,
We're moving an old site to Umbraco, and part of the process is to copy and paste content into the form fields.
The problem is that when I copy the HTML and paste it into my RichTextField, all teh formatting and inline styles are kept. This is a pain as the styles override my current CSS.
I'm sure this is by design, but I was wondering if anyone has had the same problem, and has a clever work around?
At the moment I just have to paste it into notepad or something.
In /config/tinyMceConfig.config you can specify what attributes are allowed for each tag. So if you know what tag(s) have inline styles you can prevent the style attribute from being used on it.
Check /config/tinyMceConfig.config in the <validElements> area.
For example, to prevent the style attribute from being used on <a tags, change
......... +a[id|style|rel| .........
to
.........+a[id|rel| .........
Remember to touch the web.config file to apply the changes
The "ValidElements" property no longer appears to work in the same way in Umbraco 11.
It's now entered in appsettings.json.
"ValidElements" will prevent HTML properties added by clicking the RTE TinyMCE buttons, but will not prevent those same properties when content is pasted into the RTE.
TinyMCE promotes a PowerPaste plugin in the Professional plan ($130 per month!) and Enterprise plan (Custom pricing?).
This gives me the impression TinyMCE removed previous functionality so that they could charge for it? But I may not have the whole picture?
Remove formatting (inline styles) when pasting HTML into Tiny MCE
Hi,
We're moving an old site to Umbraco, and part of the process is to copy and paste content into the form fields.
The problem is that when I copy the HTML and paste it into my RichTextField, all teh formatting and inline styles are kept. This is a pain as the styles override my current CSS.
I'm sure this is by design, but I was wondering if anyone has had the same problem, and has a clever work around?
At the moment I just have to paste it into notepad or something.
Thanks in advance!
-Evan
Hi Evan,
In /config/tinyMceConfig.config you can specify what attributes are allowed for each tag. So if you know what tag(s) have inline styles you can prevent the style attribute from being used on it.
Check /config/tinyMceConfig.config in the <validElements> area.
For example, to prevent the style attribute from being used on <a tags, change
......... +a[id|style|rel| .........
to
.........+a[id|rel| .........
Remember to touch the web.config file to apply the changes
More info: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements
Tom, this worked excellently! Thank you so much!
It also works great for posting from Word etc (as I'm sure you know).
Thanks again!
The "ValidElements" property no longer appears to work in the same way in Umbraco 11.
It's now entered in appsettings.json.
"ValidElements" will prevent HTML properties added by clicking the RTE TinyMCE buttons, but will not prevent those same properties when content is pasted into the RTE.
TinyMCE promotes a PowerPaste plugin in the Professional plan ($130 per month!) and Enterprise plan (Custom pricing?).
This gives me the impression TinyMCE removed previous functionality so that they could charge for it? But I may not have the whole picture?
is working on a reply...