forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #76 from xiaotianxt/main
feat: CmdEnter config for submitkey, bug fix for auto scrolling
This commit is contained in:
commit
adc0db4c74
@ -131,10 +131,12 @@ function useSubmitHandler() {
|
|||||||
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
|
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
|
||||||
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
|
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
|
||||||
(config.submitKey === SubmitKey.ShiftEnter && e.shiftKey) ||
|
(config.submitKey === SubmitKey.ShiftEnter && e.shiftKey) ||
|
||||||
|
(config.submitKey === SubmitKey.MetaEnter && e.metaKey) ||
|
||||||
(config.submitKey === SubmitKey.Enter &&
|
(config.submitKey === SubmitKey.Enter &&
|
||||||
!e.altKey &&
|
!e.altKey &&
|
||||||
!e.ctrlKey &&
|
!e.ctrlKey &&
|
||||||
!e.shiftKey)
|
!e.shiftKey &&
|
||||||
|
!e.metaKey)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,6 +165,7 @@ export function Chat(props: { showSideBar?: () => void }) {
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
onUserInput(userInput).then(() => setIsLoading(false));
|
onUserInput(userInput).then(() => setIsLoading(false));
|
||||||
setUserInput("");
|
setUserInput("");
|
||||||
|
inputRef.current?.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
// stop response
|
// stop response
|
||||||
@ -203,6 +206,7 @@ export function Chat(props: { showSideBar?: () => void }) {
|
|||||||
|
|
||||||
// for auto-scroll
|
// for auto-scroll
|
||||||
const latestMessageRef = useRef<HTMLDivElement>(null);
|
const latestMessageRef = useRef<HTMLDivElement>(null);
|
||||||
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
// wont scroll while hovering messages
|
// wont scroll while hovering messages
|
||||||
const [autoScroll, setAutoScroll] = useState(false);
|
const [autoScroll, setAutoScroll] = useState(false);
|
||||||
@ -371,6 +375,7 @@ export function Chat(props: { showSideBar?: () => void }) {
|
|||||||
<div className={styles["chat-input-panel"]}>
|
<div className={styles["chat-input-panel"]}>
|
||||||
<div className={styles["chat-input-panel-inner"]}>
|
<div className={styles["chat-input-panel-inner"]}>
|
||||||
<textarea
|
<textarea
|
||||||
|
ref={inputRef}
|
||||||
className={styles["chat-input"]}
|
className={styles["chat-input"]}
|
||||||
placeholder={Locale.Chat.Input(submitKey)}
|
placeholder={Locale.Chat.Input(submitKey)}
|
||||||
rows={3}
|
rows={3}
|
||||||
|
@ -21,6 +21,7 @@ export enum SubmitKey {
|
|||||||
CtrlEnter = "Ctrl + Enter",
|
CtrlEnter = "Ctrl + Enter",
|
||||||
ShiftEnter = "Shift + Enter",
|
ShiftEnter = "Shift + Enter",
|
||||||
AltEnter = "Alt + Enter",
|
AltEnter = "Alt + Enter",
|
||||||
|
MetaEnter = "Meta + Enter",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Theme {
|
export enum Theme {
|
||||||
|
Loading…
Reference in New Issue
Block a user