mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +00:00
Let user exit from command mode with esc, click out, etc.
This commit is contained in:
@@ -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()}
|
||||||
|
|||||||
Reference in New Issue
Block a user