delete keybind

This commit is contained in:
Kisuyo
2024-09-06 14:51:12 +02:00
parent 655e4d78b6
commit bb080020bf
4 changed files with 177 additions and 27 deletions
+10
View File
@@ -14,6 +14,7 @@ import { PersonalLink } from "@/lib/schema"
import { ID } from "jazz-tools"
import { globalLinkFormExceptionRefsAtom } from "./partials/form/link-form"
import { toast } from "sonner"
import { useKeybind } from "@/lib/providers/keybind-provider"
interface ToolbarButtonProps {
icon: keyof typeof icons
@@ -64,6 +65,8 @@ export const LinkBottomBar: React.FC = () => {
const plusBtnRef = useRef<HTMLButtonElement>(null)
const plusMoreBtnRef = useRef<HTMLButtonElement>(null)
const { addKeybind, removeKeybind } = useKeybind()
const confirm = useConfirm()
useEffect(() => {
@@ -151,6 +154,13 @@ export const LinkBottomBar: React.FC = () => {
const shortcutKeys = getSpecialShortcut("expandToolbar")
const shortcutText = formatShortcut(shortcutKeys)
useEffect(() => {
if (personalLink) {
addKeybind({ key: "Control+x", callback: handleDelete })
return () => removeKeybind("Control+x")
}
}, [personalLink])
return (
<motion.div
className="bg-background absolute bottom-0 left-0 right-0 border-t"