WYSIWYG adds line break to list element

Support MB Blocks WYSIWYG adds line break to list elementResolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #47684
    metafanmetafan
    Participant

    Hi,

    I added a wysiwyg field in my block.

    [
       'name'              => __( 'Text', 'custom-blocks' ),
       'id'                => $prefix . 'teaser-textarea',
       'type'              => 'wysiwyg',
       'options' => [
    	'textarea_rows' => 5,				
       ],
    ],

    Adding list elements in this field outputs something like this:

    <ul>
      <li>...</li>
      <br>
      <li>...</li>
      <br>
    </ul>

    How to prevent these line breaks?
    Are there any special configurations?

    The preview and code in the TinyMCE Editor looks good, but not in the Gutenberg Editor (lefthand).

    Thanks!

    #47688
    PeterPeter
    Moderator

    Hello,

    You can try to use a custom sanitize callback to stripe the break tag <br>, following the documentation https://docs.metabox.io/sanitization/

    Meanwhile, I'm not able to reproduce the issue on my end. The break tag is not added to the unordered list elements. Here is the screen record
    https://imgur.com/xz3xeEX

    #47689
    metafanmetafan
    Participant

    Hi Peter,

    please have a look at the output on the left of your screen. Need to wait a second to render the list (on your green background).

    Thanks.

    #47701
    PeterPeter
    Moderator

    Hello,

    I still cannot reproduce the issue, screenshot https://imgur.com/rsyJZid

    Can you please share some screenshots or a screen record of the issue on your site?

    #47707
    metafanmetafan
    Participant

    Hi Peter,

    please have a look here:
    https://www.statmaps.com/screen_1.png
    https://www.statmaps.com/screen_2.png

    Theme GeneratePress,but the same on Twenty Twenty-Five.

    #47712
    PeterPeter
    Moderator

    Hello,

    Please share your site admin account by submitting this contact form https://metabox.io/contact/
    I will take a look.

    #47727
    PeterPeter
    Moderator

    Hello,

    You are using this code to output the field WYSIWYG value:

    if($mc_text)
    	    echo '<p>'.nl2br($mc_text).'</p>';

    removing the function nl2br() will solve the issue, screenshot https://imgur.com/UcfqfN4

    if($mc_text)
    	    echo $mc_text;
    #47732
    metafanmetafan
    Participant

    Oh, yes!!
    Thanks for checking!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.