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

fix: Allow copy of excalidraw elements only when inside excalidraw #3206

Merged
merged 10 commits into from Mar 9, 2021

Conversation

ad1992
Copy link
Member

@ad1992 ad1992 commented Mar 8, 2021

fixes #3205
Try here

  • update changelog

@vercel
Copy link

vercel bot commented Mar 8, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/excalidraw/excalidraw/2qHwyH64UkWhLNAj5jZjVfxCQKLP
✅ Preview: https://excalidraw-git-aakansha-copy-excalidraw.vercel.app

@ad1992 ad1992 requested a review from dwelle March 8, 2021 11:44
src/components/App.tsx Outdated Show resolved Hide resolved
src/components/App.tsx Outdated Show resolved Hide resolved
@dwelle
Copy link
Member

dwelle commented Mar 8, 2021

I suggest we start with a partial fix (but current solution in this PR is partial anyway), and simply prevent copy if there's an active selection outside the component.

Something like:

if (
	selection?.toString().length &&
    !document.querySelector(".excalidraw")?.contains(selection.anchorNode)
) {
	return
}

This PR will help in this (if we end up merging it) #3207 which should ensure that clicking on canvas deselects external selection.


Btw, I was wrong and we do handle copy via the keydown manager.

@ad1992
Copy link
Member Author

ad1992 commented Mar 8, 2021

Btw, I was wrong and we do handle copy via the keydown manager.

Yes but that also uses copyToClipboard which is the same as copyAll so should be fine right? Or some use case I am missing ?

@dwelle
Copy link
Member

dwelle commented Mar 8, 2021

Btw, I was wrong and we do handle copy via the keydown manager.

Yes but that also uses copyToClipboard which is the same as copyAll so should be fine right? Or some use case I am missing ?

Yea, I suppose.

But current solution has too many false negatives. E.g. you click on any excalidraw UI, or you click inside wysiwyg and them confirm/cancel via keyboard.

@ad1992
Copy link
Member Author

ad1992 commented Mar 8, 2021

So any text inside modal was also not getting copied which is also fixed

@ad1992
Copy link
Member Author

ad1992 commented Mar 8, 2021

So any text inside modal was also not getting copied which is also fixed

For cut the issue still exists so will push the change for cut as well.
No need to worry about this since when using cmd +x it willl use previous copy event so we need not worry and why will someone use cmd+x though :D

@ad1992 ad1992 requested a review from dwelle March 8, 2021 18:00
src/components/App.tsx Outdated Show resolved Hide resolved
@dwelle
Copy link
Member

dwelle commented Mar 8, 2021

🎉

@ad1992 ad1992 changed the title fix: Allow copy event only inside canvas fix: Allow copy of excalidraw elements only when inside excalidraw Mar 9, 2021
@ad1992 ad1992 merged commit 00ac804 into master Mar 9, 2021
@ad1992 ad1992 deleted the aakansha-copy branch March 9, 2021 06:22
dwelle added a commit that referenced this pull request Mar 17, 2021
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.

Not able to copy anything outside Excalidraw when embedded
2 participants