Copied to clipboard

Flag this post as spam?

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


  • Adriana Cerqueiro 38 posts 177 karma points
    Oct 12, 2016 @ 14:38
    Adriana Cerqueiro
    0

    Richtext editor removing <i> tag for font-awesome

    Hi everyone =D

    I am trying to add some html in a RTE I have in Grid, but TinyMCE keeps removing it. It doesn't work on a regular RTE, as part of a doctype, either

    <p><i class="fa fa-envelope"></i><a>website</a></p>
    

    I already tried adding the i tag in tinyMceConfig like

    -em[class|style],+i[class|style],
    previously it was like this
    -em/-i[class|style]
    

    Maybe there is something obvious that I'm missing or that I did wrong Does anyone have any ideas?

    Thanks!!

    Adriana

  • Alain Bora 1 post 91 karma points
    Oct 13, 2016 @ 13:04
    Alain Bora
    100

    I had the same issue and dirty fixed it by setting the font awesome class to another tag instead of using an i tag :

    <p><span class="fa fa-envelope">&nbsp;</span> <a>website</a></p>
    

    Make sure you add a blank space (&nbsp;) inside your span or other tag to force TinyMCE keep your content.

    It shouldn't break your layout as the icon usually takes more pixels than an empty space (double check your font-size, line-height etc. though) and you'll live happily ever after :)

  • Adriana Cerqueiro 38 posts 177 karma points
    Nov 03, 2016 @ 10:38
    Adriana Cerqueiro
    0

    Thanks Alain! it worked!!!

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Oct 15, 2016 @ 11:55
    Marc Goodson
    1

    Hi Adriana

    You can has Alain suggests use span tags instead of the i tag for font awesome, but if you tweak your tinymce valid elements to be:

    -em[class|style],#i[class|style],
    

    eg as you had it before but with a # infront of the i instead of a -, this tells tinymce that it is ok to have empty elements for this tag.

    The problem you had before was that even though you had allowed i tags to be used in tinymce, when they had no content (which is always the case when you are using them for font awesome ) then tinymce was stripping them out for being empty!

    regards

    Marc

  • Adriana Cerqueiro 38 posts 177 karma points
    Nov 03, 2016 @ 10:38
    Adriana Cerqueiro
    0

    Hi Marc,

    Thanks for the tip. I did it, but it still doesn't work. For some reason, if it's empty it just deletes the i tag.

    Regards.

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Nov 03, 2016 @ 11:07
    Dennis Adolfi
    2

    Hi Adriana.

    I just tried the #i solution that marc posted and it works perfect for me. (Wierd coincidence that I needed exact this fix and it was the top post on our.umbraco since you commented it) :)

    However, the changes will not take affect directly without bumping the client dependency version number.

    You do that by opening the file /Config/ClientDependecy.config and increase the clientDependecy version by 1. That will force Umbraco to clear cache and thereby read your new tinyMce settings.

    Hope it works out for you! Otherwise i´ll pull the "works on my machine"-card! :)

  • Adriana Cerqueiro 38 posts 177 karma points
    Nov 03, 2016 @ 11:27
    Adriana Cerqueiro
    1

    Thanks! That made it work =D

    So the two versions work now, cool!

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Nov 03, 2016 @ 11:51
    Dennis Adolfi
    0

    Awesome, glad it worked out for you!! :)

Please Sign in or register to post replies

Write your reply to:

Draft