Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Evan 40 posts 59 karma points
    Nov 19, 2010 @ 01:33
    Evan
    0

    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

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 19, 2010 @ 14:35
    Tom Fulton
    0

    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

  • Evan 40 posts 59 karma points
    Nov 23, 2010 @ 12:22
    Evan
    0

    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!

  • Nicholas Welsh 3 posts 71 karma points
    Dec 12, 2023 @ 05:18
    Nicholas Welsh
    0

    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?

Please Sign in or register to post replies

Write your reply to:

Draft