Copied to clipboard

Flag this post as spam?

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


  • Adrian 11 posts 41 karma points
    Apr 20, 2014 @ 04:27
    Adrian
    0

    tinymce add class to containing p tag

    I am trying to add a class to the contining p tag using the tinymce styles.

    eg.

    <p class="intro-text">test</p>

     

    however, when I select the style from the format drop down list, an additional span is inserted

     

    <p><span class="intro-text">test</span></p>

     

    i have tried by just clicking in on the text, and also highlighting the text and both insert the additional span.

    how can I add a class to the p tag directly?

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

    Hi Adrian and welcome to our :)

    I know it's a bit frustrating that the is added inside your

    but there is not something that can be done about to easily change it. It has behaved like this since the early versions of Umbraco - Not sure why but it's really an issue with the TinyMCE editor more than it's an Umbraco issue I think.

    However in my experience this is a random behavior - Sometimes the class is added directly on the elements, sometimes a with the class is inserted. You simply need to make sure that your CSS styling takes this into account.

    But I don't think it's a big issue - just something you need to accept even though it's not ideal. Ideally it should not be necessary to add classes to elements in a rich text editor. Consider if you can add them in your macroes or templates instead.

    I hope this helps.

    /Jan

  • Adrian 11 posts 41 karma points
    Apr 20, 2014 @ 11:28
    Adrian
    0

    Thanks Jan for your response.

    That's a bugger as it seems Tiny MCE does cater for it as seen in the example styles here http://www.tinymce.com/tryit/3_x/full.php 

    So it must be somewhere in the TinyMCE config and how Umbraco is implementing TinyMCE.

    Like you said - it's not a big problem as long as you cater for styles on necessary tag variation. 

    Thanks,

    Adrian

     

  • Antony Briggs 78 posts 103 karma points
    Apr 23, 2014 @ 15:33
    Antony Briggs
    0

    Hi Adrian & Jan,

    I'm seeing this behaviour in U7 too.

    Previously, if you had selected all the text in a p tag, applying a style would add the class to the p tag itself.

    Even after enabling the status bar to allow easy selection of an element, its still not possible to apply a class to an element directly so I think this is a new bug.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 23, 2014 @ 15:35
    Jan Skovgaard
    0

    Hi Antony

    I've seen it been added directly to the paragraph and sometimes wrapped in a span across versions so I have never thought of adding a class using the rich text editor as being reliable. Don't think it's a new issue to be honest.

    /Jan

  • Antony Briggs 78 posts 103 karma points
    Apr 24, 2014 @ 15:49
    Antony Briggs
    1

    Hi Jan/Adrian,

    I've looked into this issue further and have a possible solution but there are some discussions to be had. 

    If you'd like to contribute to the dicsussion, pls head over to issue U4-1736 and let me know your thoughts.

    TTFN

    Ant

  • Valerie 67 posts 163 karma points
    Jan 19, 2015 @ 11:01
    Valerie
    0

    Has there been any movement on this? What a pain! It used to work fine in previous versions :(

  • Valerie 67 posts 163 karma points
    Feb 06, 2015 @ 17:03
    Valerie
    0

    I ended up using this https://github.com/umbraco/Umbraco-CMS/pull/630/files in umbraco.controllers.js

     

     

Please Sign in or register to post replies

Write your reply to:

Draft