Line breaks and backspace/delete #2963
sadikyalcin
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
To put it bluntly, I do not agree or think the way enter and backspace is handled correctly. Letting the browser handle it produced the best results for my use case along with a simple tweak. Although, I use a fork with some custom behaviour, backspace and line break is still relevant to the main repo. Additional context: I don't allow creating blocks by hitting enter, merging blocks, splitting blocks. I also prevent deleting empty blocks by pressing backspace.
Currently, there are multiple issues around line breaks: #2730, #2854, #2854.
Issues
shift+enterat the start of the block. You cannot delete the line breaks (main repo: see live demo on the website).brtags, blocks are deleted when you have line breaks at the start of the block and some text. Create a line break or a few at the start of the block, write some text, backspace to delete the text. Once text is removed, the block is deleted (main repo: see live demo on the website).enteris pressed, a new block is created. With linebreaksenabled and changing the behaviour on my fork to be:entercreates a new line (default browser behaviour). The line break is wrapped around adivor aspan. I haven't checked all browsers but chromium seems to be doing this.Now what I propose involves important changes on
enterandbackspaceevents inblockEvents.backspacehandler should onlydeletea block if the entire block is empty (check the node forbrtags), everything else should be left to the browser or should just delete the previous character/line break.entershould create a custom line break and work exactly likeshift+enterdoes when line breaks are enabled (browser override to prevent<div><br /></div>.entershould only create a new block if caret is at the end of the block, not split blocks between line breaks - this one is a bit personal to my use case so it may be irrelevant generically.I also haven't considered other scenarios or side affects this may cause with multi input blocks like quote / list elements.
Please let me know what you think, what I'm missing, if/why I'm wrong.
Beta Was this translation helpful? Give feedback.
All reactions