Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 364 posts 918 karma points
    Apr 30, 2015 @ 10:46
    Craig O'Mahony
    0

    Add a default class when anchors are created in the RTE

    Hi folks,

    I'm integrating a design into Umbraco and the designers have specified a few classes that should be applied to anchors

    <a href="#" class="blueLink">Link</a>
    <a href="#" class="blackLink">Link</a>
    <a href="#" class="redLink">Link</a>

    So what I've created is a few styles that can be applied using the formats dropdown in the RTE. All is well and works ok but 95% of the time the class that needs be applied is blueLink and I was wondering if there's any way to apply this class automatically when the user initially creates the link negating the need to select the respective class as it will have already been applied?

    Thanks,

    Craig

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 30, 2015 @ 11:29
    Jan Skovgaard
    0

    Hi Craig

    Wouldn't that be to simply just make the default anchor color inside a rich text editor always be blue? And then the editor will only add classes to those that should be colored differently?

    Say you wrap you rich text editor content in a div with the class rte-content. Like this

    HTML

    <div class="rte-content">
     <a href="#">I don't have a class - I'm just a standard link</a>
     <a href="#" class="redLink">Uuuh! Look at me! I'm a red link - I'm soooo beyond standard.</a>
    </div>
    

    CSS

    .rte-content a{
      color:blue;
    }
    
    .rte-content .redLink{
     color:red;
    }
    

    Is this approach useful and does it make sense in your context?

    /Jan

  • Craig O'Mahony 364 posts 918 karma points
    Apr 30, 2015 @ 15:30
    Craig O'Mahony
    0

    Hi Jan,

    Thanks for your response I did think of that but the problem is the design team (who are external) are constantly changing the CSS themselves and I'm concerned that any changes I make to the base CSS will get overwritten on the next update hence the request to try and change the behavior of the RTE.

    Craig

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 30, 2015 @ 16:34
    Jan Skovgaard
    100

    Hi Craig

    But won't that be a risk no matter the approach you take?

    /Jan

  • Craig O'Mahony 364 posts 918 karma points
    May 01, 2015 @ 12:48
    Craig O'Mahony
    0

    Actually you're probably right!

    Sorted!

Please Sign in or register to post replies

Write your reply to:

Draft