mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-10 03:28:14 +00:00
cleaner
This commit is contained in:
commit
6216f5f9d3
4 changed files with 30 additions and 2 deletions
|
|
@ -131,6 +131,13 @@ export default function ContentApp({
|
|||
});
|
||||
}
|
||||
});
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (isPopoverOpen) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", handleKeyDown, true);
|
||||
|
||||
const portalDiv = document.createElement("div");
|
||||
portalDiv.id = "popover-portal";
|
||||
|
|
@ -139,6 +146,7 @@ export default function ContentApp({
|
|||
|
||||
return () => {
|
||||
document.removeEventListener("mousemove", () => {});
|
||||
document.removeEventListener("keydown", handleKeyDown, true);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import { createMemory, createSpace } from "../actions/doers";
|
|||
import ComboboxWithCreate from "@repo/ui/shadcn/combobox";
|
||||
import { StoredSpace } from "@/server/db/schema";
|
||||
import useMeasure from "react-use-measure";
|
||||
import { useKeyPress } from "@/lib/useKeyPress";
|
||||
|
||||
function Menu() {
|
||||
const [spaces, setSpaces] = useState<StoredSpace[]>([]);
|
||||
|
|
@ -48,7 +49,11 @@ function Menu() {
|
|||
setSpaces(spaces.data);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
useKeyPress("a", () => {
|
||||
if (!dialogOpen) {
|
||||
setDialogOpen(true);
|
||||
}
|
||||
});
|
||||
const menuItems = [
|
||||
{
|
||||
icon: HomeIconWeb,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ async function page() {
|
|||
</div>
|
||||
|
||||
<h3 className="fixed left-1/2 -translate-x-1/2 bottom-4 text-gray-400 pt-20 text-center">
|
||||
*this is under beta and only one canvas is allowed per user
|
||||
Thinkpads is under beta and only one thinkpad is allowed per user.
|
||||
</h3>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
15
apps/web/lib/useKeyPress.ts
Normal file
15
apps/web/lib/useKeyPress.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { useEffect } from "react";
|
||||
|
||||
export const useKeyPress = (key: string, callback: () => void) => {
|
||||
useEffect(() => {
|
||||
const handler = (e: KeyboardEvent) => {
|
||||
if (e.key === key && e.altKey) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
window.addEventListener("keydown", handler);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handler);
|
||||
};
|
||||
}, [key, callback]);
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue