-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix(core): implement deleteCurrentNode command & fix node joining on Delete key #3192
fix(core): implement deleteCurrentNode command & fix node joining on Delete key #3192
Conversation
This PR implements a "deleteCurrentNode" action in combination with registering this command inside the keymap for the delete key. This way, we editor will check, if the current node is empty before joining - if the current node is empty, the node will be removed. Joining will still work if the current node is not empty and the selection is at the end of the current node 2924
❌ Deploy Preview for tiptap-embed failed.
|
@bdbch This is awesome, thanks for taking the time to dig into this one. However, while attempting to fix this on my side (I couldn't), I found an edge case that I'm not sure if this implementation takes care of. The deployment seems to have failed, but I'll try to find some time today to check out this branch, and test it out. I'll let you know what I find as soon as possible. |
Thanks for your response @rfgamaral! I'm taking a look into the failed deployment right now. |
Seems like the Netlify cache was breaking the build. It's deployed now. Feel free to test here: |
What edge case did you find? |
@bdbch This one: firefox_mTdG8AWAPO.mp4Based on my experience with other editors, in this particular case, the blockquote node (or other block node like a list item) should indeed be removed, and the text joined with the paragraph where the cursor was. Short demo from Google Docs: firefox_59sdQyvkQN.mp4Hope you can fix this one as well 🤞 |
I'll take a look at this case too! |
@rfgamaral sorry didn't find time yesterday, was quite late already haha. I'll take a look at my PR later this day and I'll see if I can find a quick solution for the issue you showed me. |
@bdbch That's okay, I understand, take the time required to get it right 👍 |
…g-delete-on-an-empty-paragraph-clears-the-node-afterwards
@rfgamaral I worked on this a bit but couldn't figure out the "right" way to do it. What I'm on right now:
But I'm not 100% sure if this is the expected behaviour. I'm still experimenting - just a heads up for what is going on in here. |
…g-delete-on-an-empty-paragraph-clears-the-node-afterwards
…g-delete-on-an-empty-paragraph-clears-the-node-afterwards
…pty-paragraph-clears-the-node-afterwards
…de-afterwards' of github.com:ueberdosis/tiptap into 2924-pressing-delete-on-an-empty-paragraph-clears-the-node-afterwards
…g-delete-on-an-empty-paragraph-clears-the-node-afterwards
@rfgamaral since this PR takes longer I'll merge it soon and release it with the next release. I created a new issue for the edgecase you reported: #3454 |
/** | ||
* Delete the node that currently has the selection anchor. | ||
*/ | ||
deleteCurrentNode: () => ReturnType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command should be marked @internal
or at least have its behavior documented more clearly. I tried using it thinking it would delete the current node, but the current node was not empty, so it wasn't deleted, leading me to think Tiptap was broken.
This PR should fix #2924 by adding a new command called
deleteCurrentNode
.This command is then used inside the keymap core extension right before the
joinForward
command to check if the current node is empty - if it is, the current node will be simply deleted instead of joining the empty node with the next node.This way, if for example an empty paragraph node is followed by an blockquote, the empty paragraph node will be removed and the selection will be moved into the blockquote.
If the paragraph node is not empty, the blockquote will be transformed into a paragraph node as it used to be.