Atomic block's entity should be deleted on backspace command too
See original GitHub issueI have a simple use case which bothers me since a week. When I add an atomic block:
"‸"
"Some text...‸"
- add atomic block with entity space (programatically)
"Sometext..."
" "
"‸"
- Hit backspace (we jump on line 1, atomic block is deleted how we except BUT the space from the atomic block with the entity in it is now on line 1 right next to the cursor.)
"Sometext...‸ "
Normally you not recognize this space with the entity - but when you render the content state side-by-side to the editor you recognize that an entity in still present there on line 1. You can delete this space, than it’s solved theoretically.
I except that the entity space should be removed too when I delete an atomic block by a backspace operation.
Otherwise the content state is now just invalid - there is an atomic entity somewhere free outside of an atomic block.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:16
Top Results From Across the Web
Developers - Atomic block's entity should be deleted on backspace ...
Atomic block's entity should be deleted on backspace command too.
Read more >How to prevent draft.js from removing blocks on Backspace
JS and React.JS and I want to prevent Draft.JS from deleting inserted atomic blocks on backspace, but rather move the cursor into the...
Read more >Pressing backspace key while renaming a flow/subflow ...
You should see that there is a Delete Entity command for the backspace key. Just click "Unbind Command" for that command. Expand Post....
Read more >https://www.aviationweather.gov/javascript/tinymce...
Fixed bug where blocks would be merged in incorrect order on backspace/delete. Fixed bug where zero length text nodes would cause issues with...
Read more >wiki:syntax [DokuWiki]
You can mark something as <del>deleted</del> as well. Paragraphs are created from blank lines. If you want to force a newline without a ......
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
RichUtils.handleKeyCommand
is not bound by default to handle commands. That’s the truth. In theRichUtils.handleKeyCommand
method you see all the commands this method handles. They are several, but in most cases it’s okey.Simple example:
Detailed explanation When you don’t want that
RichUtils.handleKeyCommand
handle some command (for example some inline styles) just catch those commands and don’t callRichUtils.handleKeyCommand
for it.The most important point however is that you return the handled string when your custom code or
RichUtils.handleKeyCommand
handled the command - this will prevent the default key action. When you don’t return handled even whenRichUtils.handleKeyCommand
was handled the command and updated the editor state, still 90% of the commands are working as excepted. But deleting atomic block will not work correctly since draft.js thinks the command was not handled and executes the default action which break the atomic block removal.It’s a tricky point.
I suggested that draft.js should warn the user when handleKeyCommand function not returns explicitly “handled” or “not-handled”. Or clarify this case in the docs even more. (–> https://facebook.github.io/draft-js/docs/advanced-topics-key-bindings.html)
Sorry that’s a slightly older version. This one’s been cleaned up.