diff --git a/src/components/CreateCellDialog.tsx b/src/components/CreateCellDialog.tsx index 6d9a842..bf3aae3 100644 --- a/src/components/CreateCellDialog.tsx +++ b/src/components/CreateCellDialog.tsx @@ -96,6 +96,16 @@ export function CreateCellDialog({ } }; + // Handle keyboard shortcuts + const handleKeyDown = (e: React.KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { + e.preventDefault(); + if (!isCreatingCell && canCreateCell) { + form.handleSubmit(onSubmit)(); + } + } + }; + return ( @@ -108,7 +118,7 @@ export function CreateCellDialog({ Create New Cell
- + { } }; + // Handle keyboard shortcuts + const handleKeyDown = (e: React.KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { + e.preventDefault(); + if (!isCreatingComment && newComment.trim()) { + handleCreateComment(e as React.FormEvent); + } + } + }; + const handleVotePost = async (isUpvote: boolean) => { // ✅ Permission checking handled in hook await votePost(post.id, isUpvote); @@ -255,7 +265,7 @@ const PostDetail = () => { {/* Comment Form */} {canComment && (
- +

Add a comment diff --git a/src/components/PostList.tsx b/src/components/PostList.tsx index e725c20..e4ca0b3 100644 --- a/src/components/PostList.tsx +++ b/src/components/PostList.tsx @@ -124,6 +124,16 @@ const PostList = () => { } }; + // Handle keyboard shortcuts + const handleKeyDown = (e: React.KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { + e.preventDefault(); + if (!isCreatingPost && newPostContent.trim() && newPostTitle.trim()) { + handleCreatePost(e as React.FormEvent); + } + } + }; + const handleVotePost = async (postId: string, isUpvote: boolean) => { // ✅ Permission checking handled in hook await votePost(postId, isUpvote); @@ -198,7 +208,7 @@ const PostList = () => { {canPost && (
- +

New Thread