mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Let user exit from command mode with esc, click out, etc.
This commit is contained in:
parent
a121d67b10
commit
0bd78791ca
1 changed files with 10 additions and 2 deletions
|
@ -72,6 +72,8 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
|
||||||
const [progressValue, setProgressValue] = useState(0);
|
const [progressValue, setProgressValue] = useState(0);
|
||||||
const [isDragAndDropping, setIsDragAndDropping] = useState(false);
|
const [isDragAndDropping, setIsDragAndDropping] = useState(false);
|
||||||
|
|
||||||
|
const [showCommandList, setShowCommandList] = useState(false);
|
||||||
|
|
||||||
const chatInputRef = ref as React.MutableRefObject<HTMLTextAreaElement>;
|
const chatInputRef = ref as React.MutableRefObject<HTMLTextAreaElement>;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!uploading) {
|
if (!uploading) {
|
||||||
|
@ -275,6 +277,12 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
|
||||||
chatInputRef.current.style.height = "auto";
|
chatInputRef.current.style.height = "auto";
|
||||||
chatInputRef.current.style.height =
|
chatInputRef.current.style.height =
|
||||||
Math.max(chatInputRef.current.scrollHeight - 24, 64) + "px";
|
Math.max(chatInputRef.current.scrollHeight - 24, 64) + "px";
|
||||||
|
|
||||||
|
if (message.startsWith("/") && message.split(" ").length === 1) {
|
||||||
|
setShowCommandList(true);
|
||||||
|
} else {
|
||||||
|
setShowCommandList(false);
|
||||||
|
}
|
||||||
}, [message]);
|
}, [message]);
|
||||||
|
|
||||||
function handleDragOver(event: React.DragEvent<HTMLDivElement>) {
|
function handleDragOver(event: React.DragEvent<HTMLDivElement>) {
|
||||||
|
@ -360,9 +368,9 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
)}
|
)}
|
||||||
{message.startsWith("/") && message.split(" ").length === 1 && (
|
{showCommandList && (
|
||||||
<div className="flex justify-center text-center">
|
<div className="flex justify-center text-center">
|
||||||
<Popover open={message.startsWith("/")}>
|
<Popover open={showCommandList} onOpenChange={setShowCommandList}>
|
||||||
<PopoverTrigger className="flex justify-center text-center"></PopoverTrigger>
|
<PopoverTrigger className="flex justify-center text-center"></PopoverTrigger>
|
||||||
<PopoverContent
|
<PopoverContent
|
||||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||||
|
|
Loading…
Add table
Reference in a new issue