Copied to clipboard

Flag this post as spam?

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

  • MB 109 posts 398 karma points
    Dec 08, 2018 @ 23:30

    Adding to the Formats drop-down of the RTEditor using a custom stylesheet configured from the backkoffice and added to the datatype.

    The formats appear in the dropdown ok, but when selected, are applied to the entire paragraph instead of just the selected text.

    e.g. If myformats.css is configured for the rteditor and the formats drop-down, and it contains a rule: {color:red;}

    When I select some text and apply a format from the drop-down, instead of getting something like:

    This is some text where we have a selected RED TEXT section in the middle

    I actually end up with:

    This is some text where we have a selected RED TEXT section in the middle

    i.e. The entire paragraph containing the selected text has the format applied to it, instead of just the selected text in the paragraph.

    Other styles such as bold, underline, italics, etc, all behave as expected and are only applied to the selected text, but formats are always applied to the entire paragraph the selection is made on.

    Not sure what I'm doing wrong, but would appreciate any suggestions.

  • Tomasz 22 posts 95 karma points
    Jun 14, 2021 @ 22:40

    Can't believe no one answered this before / so far. I'm sure you have either solved it or moved on, but the same thing happened to me.

    The problem here is the CSS definition and how tinymcs works inside the RTE. You only need the following definition

    .red { color:red; }

    as the RTE will auto-wrap your selected text (words, characters, etc) into it's "own" span element with the class "red" applied to it.

    So defining the CSS as {} will cause the whole "block" (paragraph) to be "selected" as unwanted in your case.

    Hope this helps others...

Please Sign in or register to post replies

Write your reply to: