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

feat: Remove copy & paste from context menu on desktop #2872

Merged
merged 7 commits into from
Jan 28, 2021
Merged

feat: Remove copy & paste from context menu on desktop #2872

merged 7 commits into from
Jan 28, 2021

Conversation

h7y
Copy link
Member

@h7y h7y commented Jan 28, 2021

Fixes #2868

@vercel
Copy link

vercel bot commented Jan 28, 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/ku8z1d92e
✅ Preview: https://excalidraw-git-fork-h7y-remove-copy-paste.excalidraw.vercel.app

@h7y h7y changed the title fix: Remove copy & paste from context menu on desktop improvement: Remove copy & paste from context menu on desktop Jan 28, 2021
@h7y h7y changed the title improvement: Remove copy & paste from context menu on desktop fix: Remove copy & paste from context menu on desktop Jan 28, 2021
@dwelle
Copy link
Member

dwelle commented Jan 28, 2021

I think you should move the helper over to is-mobile.tsx, because utils.ts are used by packages which do use that sass loader which allows importing scss files.

I'd also factor out this part and reuse in both places:

query.current = window.matchMedia
? window.matchMedia(variables.isMobileQuery)
: (({
matches: false,
addListener: () => {},
removeListener: () => {},
} as any) as MediaQueryList);

src/components/App.tsx Outdated Show resolved Hide resolved
@h7y
Copy link
Member Author

h7y commented Jan 28, 2021

Just noticed this. I'm on it!

@h7y
Copy link
Member Author

h7y commented Jan 28, 2021

I think you should move the helper over to is-mobile.tsx, because utils.ts are used by packages which do use that sass loader which allows importing scss files.

I'd also factor out this part and reuse in both places:

query.current = window.matchMedia
? window.matchMedia(variables.isMobileQuery)
: (({
matches: false,
addListener: () => {},
removeListener: () => {},
} as any) as MediaQueryList);

I've moved the helper to is-mobile.tsx. I'm having trouble understanding the factoring out part. Should I replicate the same logic in the helper?

@dwelle
Copy link
Member

dwelle commented Jan 28, 2021

I meant something like factoring this part out:

window.matchMedia 
   ? window.matchMedia(variables.isMobileQuery) 
   : (({ 
       matches: false, 
       addListener: () => {}, 
       removeListener: () => {}, 
     } as any) as MediaQueryList);

into a helper called getIsMobileMatcher()

which you'd then call in both of those places where you need it.

@@ -3630,7 +3630,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {

const elements = this.scene.getElements();
const element = this.getElementAtPosition(x, y);
const isMobile = getWhetherMobile();
const isMobile = getIsMobileMatcher().matches;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we still can (should) export const isMobile => getIsMobileMatcher().matches instead.

@dwelle
Copy link
Member

dwelle commented Jan 28, 2021

My suggestion above was incorrect, it should have been a function (well what I suggested wasn't even syntactically correct). Fixed.

@dwelle dwelle changed the title fix: Remove copy & paste from context menu on desktop feat: Remove copy & paste from context menu on desktop Jan 28, 2021
@dwelle
Copy link
Member

dwelle commented Jan 28, 2021

Made into feat coz it's quite radical change I think.

@h7y
Copy link
Member Author

h7y commented Jan 28, 2021

Perfect!

@dwelle
Copy link
Member

dwelle commented Jan 28, 2021

Thanks! ❤️

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.

Remove copy/paste items from contextmenu on desktop
2 participants