mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-18 23:10:16 +02:00
feat: Remove copy & paste from context menu on desktop (#2872)
* Remove copy & paste from context menu on desktop * fix build * Make requested changes * More changes * make into function * update changelog * fix tests Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
@@ -3,6 +3,16 @@ import variables from "./css/variables.module.scss";
|
||||
|
||||
const context = React.createContext(false);
|
||||
|
||||
const getIsMobileMatcher = () => {
|
||||
return window.matchMedia
|
||||
? window.matchMedia(variables.isMobileQuery)
|
||||
: (({
|
||||
matches: false,
|
||||
addListener: () => {},
|
||||
removeListener: () => {},
|
||||
} as any) as MediaQueryList);
|
||||
};
|
||||
|
||||
export const IsMobileProvider = ({
|
||||
children,
|
||||
}: {
|
||||
@@ -10,13 +20,7 @@ export const IsMobileProvider = ({
|
||||
}) => {
|
||||
const query = useRef<MediaQueryList>();
|
||||
if (!query.current) {
|
||||
query.current = window.matchMedia
|
||||
? window.matchMedia(variables.isMobileQuery)
|
||||
: (({
|
||||
matches: false,
|
||||
addListener: () => {},
|
||||
removeListener: () => {},
|
||||
} as any) as MediaQueryList);
|
||||
query.current = getIsMobileMatcher();
|
||||
}
|
||||
const [isMobile, setMobile] = useState(query.current.matches);
|
||||
|
||||
@@ -29,6 +33,8 @@ export const IsMobileProvider = ({
|
||||
return <context.Provider value={isMobile}>{children}</context.Provider>;
|
||||
};
|
||||
|
||||
export const isMobile = () => getIsMobileMatcher().matches;
|
||||
|
||||
export default function useIsMobile() {
|
||||
return useContext(context);
|
||||
}
|
||||
|
Reference in New Issue
Block a user