mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-24 14:40:22 +09:00
Merge branch 'ChatGPTNextWeb:main' into main
This commit is contained in:
commit
dfeb9e7f27
@ -960,9 +960,24 @@ function _Chat() {
|
|||||||
(scrollRef.current.scrollTop + scrollRef.current.clientHeight),
|
(scrollRef.current.scrollTop + scrollRef.current.clientHeight),
|
||||||
) <= 1
|
) <= 1
|
||||||
: false;
|
: false;
|
||||||
|
const isAttachWithTop = useMemo(() => {
|
||||||
|
const lastMessage = scrollRef.current?.lastElementChild as HTMLElement;
|
||||||
|
// if scrolllRef is not ready or no message, return false
|
||||||
|
if (!scrollRef?.current || !lastMessage) return false;
|
||||||
|
const topDistance =
|
||||||
|
lastMessage!.getBoundingClientRect().top -
|
||||||
|
scrollRef.current.getBoundingClientRect().top;
|
||||||
|
// leave some space for user question
|
||||||
|
return topDistance < 100;
|
||||||
|
}, [scrollRef?.current?.scrollHeight]);
|
||||||
|
|
||||||
|
const isTyping = userInput !== "";
|
||||||
|
|
||||||
|
// if user is typing, should auto scroll to bottom
|
||||||
|
// if user is not typing, should auto scroll to bottom only if already at bottom
|
||||||
const { setAutoScroll, scrollDomToBottom } = useScrollToBottom(
|
const { setAutoScroll, scrollDomToBottom } = useScrollToBottom(
|
||||||
scrollRef,
|
scrollRef,
|
||||||
isScrolledToBottom,
|
(isScrolledToBottom || isAttachWithTop) && !isTyping,
|
||||||
);
|
);
|
||||||
const [hitBottom, setHitBottom] = useState(true);
|
const [hitBottom, setHitBottom] = useState(true);
|
||||||
const isMobileScreen = useMobileScreen();
|
const isMobileScreen = useMobileScreen();
|
||||||
|
@ -248,6 +248,10 @@ function escapeBrackets(text: string) {
|
|||||||
|
|
||||||
function tryWrapHtmlCode(text: string) {
|
function tryWrapHtmlCode(text: string) {
|
||||||
// try add wrap html code (fixed: html codeblock include 2 newline)
|
// try add wrap html code (fixed: html codeblock include 2 newline)
|
||||||
|
// ignore embed codeblock
|
||||||
|
if (text.includes("```")) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
return text
|
return text
|
||||||
.replace(
|
.replace(
|
||||||
/([`]*?)(\w*?)([\n\r]*?)(<!DOCTYPE html>)/g,
|
/([`]*?)(\w*?)([\n\r]*?)(<!DOCTYPE html>)/g,
|
||||||
|
Loading…
Reference in New Issue
Block a user