CSS flexbox conflicting with Wysiwyg editor
-
There seems to be a problem creating blocks of text in the Wysiwyg editor when the block is within a div that uses display: flex
Here is an example of a textfield I am using for the theme and how it is set up in HTML/CSS
Image: https://pasteboard.co/Jv8LvHu.pnghtml:
<div class="textbox1"> <p><span style="font-size: 2em;">?legilde</span> <br> <br> Fredag den 25. September 2020 <br> Fra klokken 17:30 <br> <br> <span style="font-weight:600">Menu</span> <br> <br> <span style="font-style: italic">To slags hjemmelavede sild</span> <br> <br> <span style="font-weight:600">Hovedret</span> <br> <br> <span style="font-style: italic">Sm?rstegte vild-?l <br> Stuvede dildkartofler <br> Stegesky, r?syltede tytteb?r, agurkesalat og citron</span> <br> <br> <span style="font-weight:600">Dessert</span> <br> <br> <span style="font-style: italic;">Dessertkage med mango mousse</span> <br> <br> <span style="font-weight: 600; font-size: 2em;">Pris 365 kr.</span> <br> <br> Bestilling til arrangementet skal foretages p? telefon <span style="font-weight: bold;">24 46 01 24</span></p> </div>
css:
.textbox1 { display: flex; justify-content: center; text-align: center; background-color: #f0f0f0; }
Now, in my php file for wordpress, I changed the HTML to:
<?php $text = get_field('text_fields');?> <div class="textbox"> <p><?php echo $text['textbox1'];?></p> </div>
Then I just entered the text with all the inline styling into the Wysiwyg editor, and the result came out looking like this:
https://pasteboard.co/Jv8PaJs.pngI discovered that if I remove display: flex it will show up normally, but with missing break points.
https://pasteboard.co/Jv8R4jy.pngWhile inspecting the element, I noticed that not only does the Wysiwyg editor remove <br> tags, but it also ADDS <p> tags to every single line of text, and I think this is what causes the flexbox layout to get messed up.
Is there any function or plugin that can solve my problem?
I know that you can stop the removal of <br> tags with the following code:function uncoverwp_tiny_mce_fix( $init ) { // don't remove line breaks $init['remove_linebreaks'] = false; // convert newline characters to BR $init['convert_newlines_to_brs'] = true; // don't remove redundant BR $init['remove_redundant_brs'] = false; // pass back to wordpress return $init; } add_filter( 'tiny_mce_before_init', 'uncoverwp_tiny_mce_fix' );
But sadly it has NOT worked.
So I need three things:
1: Being able to show CSS flexbox elements correctly.
2: Removing the extra <p> tags that are added in the editor.
3: Stopping the editor from removing <br> tags.Any suggestions?
- The topic ‘CSS flexbox conflicting with Wysiwyg editor’ is closed to new replies.