TinyMCE Rich Text Editor: Remove Styling When Pasting From Word

I am trying to configure the TinyMCERTE Editor so that when I copy & paste from a Word doc, it doesn’t carry over any styling. I have added a json config file that has the following:

{
“invalid_elements” : “span”
}

This works to remove any styling that is part of a span tag. I am trying to remove any additional inline styling such as for example:

  • Removing the aria-level=“1” would be great as well.

    Thanks in advance.

  • Hey …

    Two things you may have missed:

    … and there’s also a system setting which switches to plain text as default:

    tinymcerte.paste_as_text
    

    image

    Hopefully this helps.

    HI @dejaya thanks! I don’t want to paste as plain text because that will lose the formatting that I want to keep such as < strong > or < em >, etc.

    In that case - can you not populate the tinymcerte.valid_elements System Setting with strong and em etc.

    As I understand it that would then exclude other elements.

    From what I tried previously, setting a list of valid elements in tinymcerte.valid_elements as you mentioned (i.e. h1,h2,h3,h4,h5,h6,p,strong,em,b,li,ul,ol,a,blockquote), for a tags (i.e. < a href=" >), the href=“” doesn’t get pasted, it just appears as < a >.

    Check out the valid elements docs - I think you can specify valid attributes within valid elements.

    E.g.,

    valid_elements: 'a[href|target=_blank],strong,em'
    

    Don’t forget that TinyMCE RTE is on Tiny version 5

    1 Like

    :+1: have updated the link

    Thank you for this! I set the Valid Eelements as follows:
    h1,h2,h3,h4,h5,h6,p,strong,em,b,li,ul,ol,a[href|target=_blank],iframe[width|height|src]

    This is working great for me so far.

    1 Like

    This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.