Skip to content

Commit

Permalink
ui: mod + enter to ask
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed May 22, 2024
1 parent 65ba782 commit 44d02f5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"@tailwindcss/typography": "^0.5.10",
"@tanstack/table-core": "^8.11.7",
"@types/hast": "^3.0.3",
"@types/is-hotkey": "^0.1.10",
"@types/lodash": "^4.14.202",
"@types/mdast": "^4.0.3",
"@types/micromatch": "^4.0.6",
Expand All @@ -127,6 +128,7 @@
"client-zip": "^2.4.4",
"eslint": "^8",
"eslint-config-next": "14.2.1",
"is-hotkey": "^0.2.0",
"kysely-codegen": "^0.11.0",
"lodash": "^4.17.21",
"lucide-react": "^0.342.0",
Expand Down
53 changes: 51 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/components/message-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { ChatEngine } from '@/core/repositories/chat_engine';
import type { Page } from '@/lib/database';
import { fetcher } from '@/lib/fetch';
import { cn } from '@/lib/utils';
import isHotkey from 'is-hotkey';
import { ArrowRightIcon } from 'lucide-react';
import { useSession } from 'next-auth/react';
import { type ChangeEvent, type RefObject, useCallback, useRef, useState } from 'react';
Expand Down Expand Up @@ -48,7 +49,7 @@ export function MessageInput ({
<TextareaAutosize
placeholder="Input your question here..."
onKeyDown={e => {
if (!e.nativeEvent.isComposing && e.key === 'Enter' && !disabled) {
if (!e.nativeEvent.isComposing && isHotkey('mod+Enter', e) && !disabled) {
e.preventDefault();
buttonRef.current?.click();
}
Expand Down

0 comments on commit 44d02f5

Please sign in to comment.