-
-
Notifications
You must be signed in to change notification settings - Fork 549
fix: Cut/copy handling in non-editable blocks and empty selections #1427
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Nice. What was the reason for working on this? Curious how / where you ran into it!
Code-wise, some questions / feedback:
- what if you're within a contenteditable="true" nested in a contenteditable="false"?
- you might be able to use
closest()
instead of looping upo the tree
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.
lgtm
Good point r.e. the |
Ok looks like putting your Long story short looks like the current behaviour is fine |
Also r.e. using |
This PR does 2 things:
When the selection is empty, we no longer use our own cut/copy handling and instead let the browser handle the event (so nothing happens). Currently an error is thrown as we attempt to create clipboard data from an empty selection.
When the selection is within a descendant of a
"contenteditable"="false"
element, we no longer use our own cut/copy handling and instead let the browser handle the event. This means the user is selecting some content in a non-editable block. Currently the editor selection is copied instead as this scenario still triggers PM event handlers.TODO: Unit tests?