mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-23 11:50:14 +01:00
📶 fix: Mobile Stylings (#2639)
* chore: remove unused mobile nav * fix: mobile nav fix for 'more' and 'archive' buttons div * refactor(useTextarea): rewrite handleKeyUp for backwards compatibility refactor(useTextarea): rewrite handleKeyUp for backwards compatibility * experimental: add processing delay to azure streams for better performance/UX * experiemental: adjust gpt-3 azureDelay * fix: perplexity titles
This commit is contained in:
parent
b6d6343f54
commit
3c5fa40435
7 changed files with 49 additions and 105 deletions
|
|
@ -14,6 +14,11 @@ import store from '~/store';
|
|||
|
||||
type KeyEvent = KeyboardEvent<HTMLTextAreaElement>;
|
||||
|
||||
const keyMap = {
|
||||
50: '2',
|
||||
192: '@',
|
||||
};
|
||||
|
||||
export default function useTextarea({
|
||||
textAreaRef,
|
||||
submitButtonRef,
|
||||
|
|
@ -138,24 +143,30 @@ export default function useTextarea({
|
|||
|
||||
const handleKeyUp = useCallback(
|
||||
(e: KeyEvent) => {
|
||||
let isMention = false;
|
||||
if (e.key === '@' || e.key === '2') {
|
||||
const text = textAreaRef.current?.value;
|
||||
isMention = !!(text && text[text.length - 1] === '@');
|
||||
let normalizedKey = e.key;
|
||||
|
||||
if (!normalizedKey || normalizedKey === 'Unidentified') {
|
||||
normalizedKey = keyMap[e.keyCode] || normalizedKey;
|
||||
}
|
||||
|
||||
if (isMention) {
|
||||
const startPos = textAreaRef.current?.selectionStart;
|
||||
const isAtStart = startPos === 1;
|
||||
const isPrecededBySpace =
|
||||
startPos && textAreaRef.current?.value.charAt(startPos - 2) === ' ';
|
||||
|
||||
if (isAtStart || isPrecededBySpace) {
|
||||
setShowMentionPopover(true);
|
||||
} else {
|
||||
setShowMentionPopover(false);
|
||||
}
|
||||
if (normalizedKey !== '@' && normalizedKey !== '2') {
|
||||
return;
|
||||
}
|
||||
|
||||
const text = textAreaRef.current?.value;
|
||||
if (!(text && text[text.length - 1] === '@')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const startPos = textAreaRef.current?.selectionStart;
|
||||
if (!startPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isAtStart = startPos === 1;
|
||||
const isPrecededBySpace = textAreaRef.current?.value.charAt(startPos - 2) === ' ';
|
||||
|
||||
setShowMentionPopover(isAtStart || isPrecededBySpace);
|
||||
},
|
||||
[textAreaRef, setShowMentionPopover],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue