How to always keep a codeBlock even if the user selects everything and then deletes? #5956
Unanswered
CharlieBrownCharacter
asked this question in
Questions & Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone 👋 I'm working on something cool that allows users to add different blocks to their workspace. The idea here is to allow people to add a code block and edit it.
I have the following two scenarios:
When the user presses Backspace I would like to delete the block
I managed to achieve this by checking
editor.isEmpty
and invoking a callback.When teh user selects everything and presses backspace, it should erase all the content of the
<pre><code> ... </code> </pre>
but still not delete the block itself.This is a bit trickier than I initially thought and I managed to keep the
<pre><code> ... </code> </pre>
but unfortunately a paragraph is being added:I think the issue is as follow:
Backspace
Paragraph
to maintain validity of the documentHere are two screenshots to demonstrate the issue:
Before selecting everything and pressing
Backspace
After selecting everything and pressing
Backspace
- notice the paragraph addedIs there any way I can allow the user to select everything, delete it and still keep the code block so that the user can write again the code block he wishes?
Beta Was this translation helpful? Give feedback.
All reactions