Support

Account

Home Forums Backend Issues (wp-admin) WYSIWYG Editor adds unwanted linebreak tags

Solving

WYSIWYG Editor adds unwanted linebreak tags

  • I am using the wysiwyg editor to add a HTML list to documents of our headless CMS

    When I enter

    <ul>
     <li>Topic 1</li>
     <li>Topic 2.</li>
    </ul>

    I am getting this from the REST API

    
    <ul><br />\r\n \t<li>Topic 1</li><br />\r\n \t<li>Topic 2.</li><br />\r\n</ul><br />\r\n

    This is not good. I do not want line break tags in the middle of my list.
    How do I stop this behaviour?
    Interestingly, the standard classic WP editor does not do this, so I assume it has to do with the tinymce settings of the ACF plugin.

  • Did you not tried to add that string in “Text Editor” mode rather than “Visual Editor” mode ?
    it looks like this is just parsed as a string rather than html

  • I tried everything actually.
    I typed the two lines into the text editor and added the tags there myself.
    Result as above.
    Then I typed the two lines into the Visual editor and used the list button.
    Same result.
    The only way to not have those br tags is to use the text editor and write everything in one line, including the tags.

    I believe the editor always adds line breaks for newlines as default behaviour.
    Normally I’d say that’s OK – but not in UL containers….
    Is there any way to turn that off? I cannot expect my cleint to use a text editor and/or strip all newlines from his lists 🙂

  • oh, sorry, I did not realize that you were using the REST API to get the fields content.

    but in this case, what do you expect as a result. this content is actually what is stored in the field (line breaks are stored to be rendered).

    what do you want to use this string for exactly?

  • The thing is that when I submit the entry it is saved as

    <ul>\r\n\t<br/><li>Topic 1</li>\r\n\t<br/><li>Topic 2</li>\r\n<br/></ul>

    and the linebreaks are parsed in the browser, resulting in huge gaps between the list entries.
    Try it.
    I can possibly remedy that by adding a style to all LI elements but for all practival purposes the BR tag shouldn’t be there.
    So if you have an idea how I could tell the editor not to do that I’d be happy 🙂

  • Sorry again, you are right the <br/> tag that don’t really make sense here.

    Just tested this in my development website with ACF PRO 6.7.0.2 and the stored value is actually not containing <br/> tags:

    
    <ul>\r\n \t<li>1</li>\r\n \t<li>2</li>\r\n</ul>
    

    what version are you running? any special config or plugin that might alter the wysiwyg editor ?

  • I am running 6.7.0.2, too.
    We have the standard Twenty Twenty-Five theme installed.
    The only plugin I could think of right now is the Classic Editor plugin.
    Otherwise we don’t have many plugins that are layout heavy.
    Indeed Ultimate Membership Pro, Super Store Finder, The Events Calendar. That’s it.
    But they are not engaged in editing a simple page…
    Is there no way I can see the tinymce config somewhere?

  • Just tried installing Classic Editor and tested but I don’t get the added <br/> tag in the database.
    Can you check which version of TinyMCE is running? which version of worpdress?

  • First of all, thanks for your endless patience !

    Looking at the output of the broweser console we have this TinyMCE:
    majorVersion: “4”, minorVersion: “9.11”, releaseDate: “2020-07-13”

    Doesn’t look very recent..
    WP itself is the latest version (6.9.1)

    Looking at the source of our admin page I identified two plugins that inserted extra css into the tinymce editor. I disabled them, now it looks like I have the pristine WP tinymce setup here.

    I deleted the text block inquestion and re added it – no success.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.