diff --git a/islands/PostEdit.tsx b/islands/PostEdit.tsx index 590448a..553891f 100644 --- a/islands/PostEdit.tsx +++ b/islands/PostEdit.tsx @@ -39,7 +39,15 @@ export default function Edit(props: { post: Post }) { }, textarea.current); useEffect(() => { - if (!preview.value) { + if (preview.value) { + Mousetrap.bind( + "mod+p", + () => { + displayEdit(); + return false; + }, + ); + } else { Mousetrap(textarea.current).bind( "mod+enter", () => { @@ -54,14 +62,6 @@ export default function Edit(props: { post: Post }) { return false; }, ); - } else { - Mousetrap.bind( - "mod+p", - () => { - displayEdit(); - return false; - }, - ); } }, [preview.value]); diff --git a/islands/PostNew.tsx b/islands/PostNew.tsx index 235fecd..2d0762f 100644 --- a/islands/PostNew.tsx +++ b/islands/PostNew.tsx @@ -36,7 +36,15 @@ export default function Post() { }, textarea.current); useEffect(() => { - if (!preview.value) { + if (preview.value) { + Mousetrap.bind( + "mod+p", + () => { + displayEdit(); + return false; + }, + ); + } else { Mousetrap(textarea.current).bind( "mod+enter", () => { @@ -51,14 +59,6 @@ export default function Post() { return false; }, ); - } else { - Mousetrap.bind( - "mod+p", - () => { - displayEdit(); - return false; - }, - ); } }, [preview.value]);