question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Return duplicates empty divs

See original GitHub issue

When you have content wrapped in a <div>, instead of <p>, hitting the Enter Key causes TinyMCE to create a new <div> with the same style and classes.

If you start with this example: <div class="example">Sample text, put cursor here and hit enter… this part of sentence is moved to a new div</div>

And hit the Enter Key in that sentence you get: <div class="example" style="padding: 20px;">Sample text, put cursor here and hit enter… </div> <div class="example" style="padding: 20px;">this part of sentence is moved to a new div</div>

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
blairzotroncommented, Apr 9, 2020

I have solved the newline issue, by adding an enter-key handler in editor.setup (doesn’t work if implemented anywhere else):

editor.on("keydown", function(e){
    if( e.which=="13" || e.keyCode=="13" ){
         editor.insertContent("<br> ");  //put a space at the end to reposition cursor
         e.preventDefault();
   }
});

There really should be an option like “always use <p> or <br> when they hit enter? It seems like an obvious option to have, especially, given that it was part of 3.x and 4.x, namely: “forced_root_block: p” and “force_p_newlines: true”. Why was this removed and replaced with “br_in_pre” which is far less common… who uses <pre> anyway? https://www.tiny.cloud/docs/configure/advanced-editing-behavior/#br_in_pre

BUG: The “end_container_on_empty_block” option does not work with nested divs; it skips the immediate block-wrapper and completely removes it’s parent block element. https://www.tiny.cloud/docs/configure/advanced-editing-behavior/#end_container_on_empty_block

0reactions
mariojsnunescommented, Jul 8, 2020

Thank you so much @blairzotron ! I wanted to add a div on iframes, to make them responsive with this css trick https://blog.theodo.com/2018/01/responsive-iframes-css-trick/ Was facing the same issue as mentioned. Your workaround saved me!

Still, I would like to reinforce to the team that a definite solution would be great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to display empty values after duplication of form
You need to empty the value of input on your clone like this. $(document).ready(function() { var id = 1; // get item var...
Read more >
pandas.DataFrame.duplicated — pandas 1.5.2 documentation
Return boolean Series denoting duplicate rows. ... Remove duplicate values from DataFrame. ... To find duplicates on specific column(s), use subset .
Read more >
Empty <div>s are rendered [#1049450] | Drupal.org
I'm using this to prevent duplicates caused by second rendering of timezone template.php /** * Cleans up empty DIVs within date.
Read more >
• Designing With Empty State Divs - Bugs - Forum | Webflow
I'd like to get some more insight into what's happening here—from the screenshot alone I can't tell quite is happening. There have been...
Read more >
600 empty divs disappear - KompoZer Bugs - SourceForge
line 179 of MarkupCleaner.js implies that a div should remain when empty if it has a class or id but it still gets...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found