We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38318
    • 128 Posts
    I've set up a couple of styles for the Rich Text Editor and added to both the main css file and a tinystyle. For some reason when I apply the style it's adding a span class which means the style doesn't work.

    It should be
    <h1 class="blogNewsSubhead"> … </h1>

    but instead I'm getting
    <h1><span class="blogNewsSubhead"> … </span></h1>

    Me as the developer can manually correct this but a standard user won't.

    Does anyone know how I stop it adding this span class?
      • 10525
      • 247 Posts
      Good question, I'd be interested to know the answer to this too.

        • 38318
        • 128 Posts
        I never did find a solution to this. Perhaps someone out there will know.
        • Rich text editors can sometimes accommodate things like that, but if you need absolute 100% control over the created markup, you'll need something like ContentBlocks: https://www.modmore.com/extras/contentblocks/
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 5430
            • 247 Posts
            With some editors, you'll have much better luck applying styles to block level elements if you don't actually select text but rather simply place your cursor inside the block element. Editors often associate selected text as a portion of the parent block even if you've selected the entire block, hence the span tag.

            If you're using TinyMCE, which it sounds like you are, the best way around this is to train your clients to use the handy path indicator at the bottom of the editor window which will show the current location within the underlying markup. You can click on elements in this path to select a parent block and then apply styles to that block.

            You might want to look at Redactor as well http://www.modmore.com/extras/redactor/. TinyMCE is a bloated mess at this point in my opinion.