How to allow HTML blocks to breakout on enter?
See original GitHub issueHow can we allow HTML blocks to ‘break out’ when the user hits enter? In essence, when in an h1, if I hit enter, I want to set the default behavior to ‘break out’ of the h1 into a p.
- Open editor.
- Begin an h1 block and type.
- Hit enter.
- Continue typing.
- Desired behavior: second line should be in a
<p>
, not an<h1>
. - Actual behavior: second line is in an
<h1>
- Desired behavior: second line should be in a
This is handled in Draft.js with this plugin: https://github.com/icelab/draft-js-block-breakout-plugin.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Where Lines Break is Complicated. Here's all the ... - CSS-Tricks
Here's all the Related CSS and HTML. ... This is what a break-out text situation might be like: ... Allows words to be...
Read more >Break out of parent div's - css - Stack Overflow
Let's add another parent and move the position:relative one level up (or, in your context, you could maybe simply use an existing upper...
Read more >JavaScript break Statement - W3Schools
The break statement breaks out of a switch or a loop. In a switch, it breaks out of the switch block. This stops...
Read more >break - JavaScript - MDN Web Docs - Mozilla
let i = 0; ... The labeled statement can be any block statement; ... label statement that the break statement is intended to...
Read more >A guide to creating HTML emails | Help Center - Intercom
Add a HTML block to your email ... When you need to break out from the regular formatting options that the composer offers...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had issues with some of the solutions above:
To fix this:
@simpleshadow I did something similar but eliminated the need for a setTimeout because it was causing the new line to temporarily glitch. I just override the default behavior of the enter key and instead manually insert a new paragraph node with empty text: