Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing incorrect deletion in case of embed blot #3568

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

rishavag1995
Copy link

@rishavag1995 rishavag1995 commented Apr 21, 2022

Embedblots have a left guard and a right guard. On placing the cursor after an embedblot and pressing backspace, the character just before embed blot is deleted instead of the embed blot. This is because the getSelection api returns incorrect value (actual value -1). This was happening because in the normalizedToRange function, the node was correctly found to be the right guard dom node, with an offset of zero. The index was also correctly found to be the index of the embed blot. However, before the offset had a chance to be corrected by calling the blot.index(node,offset) function (which would have returned 1 for right guard), the incorrect value was returned by the if statement above it.

FIX: Move the check for LeafBlot above the offset===0 check.

Embedblots have a left guard and a right guard. On placing the cursor after an embedblot and pressing backspace, the character just before embed blot is deleted instead of the embed blot. This is because the getSelection api returns incorrect value (actual value -1). This was happening because in the normalizedToRange function, the node was correctly found to be the right guard dom node, with an offset of zero. The index was also correctly found to be the index of the embed blot. However, before the offset had a change to be corrected by calling the blot.index(node,offset) function (which would have returned 1 for right guard), the incorrect value was returned by the if statement above it. 

FIX: Move the check for LeafBlot above the offset===0 check.
@rishavag1995
Copy link
Author

@jhchen Please have a look at this fix.

@luin luin self-requested a review December 14, 2022 08:31
@luin luin added this to the 2.0 milestone Dec 14, 2022
mattheusbr added a commit to Facil-Espaider/quill that referenced this pull request Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants