Compare commits

...

3 Commits

Author SHA1 Message Date
MJ
10bfd1292d Merge a16941858c into 46541e6c0c 2025-02-03 10:47:09 +01:00
46541e6c0c feat(package): update markdown-to-jsx version 2025-02-02 14:31:18 +05:30
mj
a16941858c feat(MessageInput): add composition event handlers 2024-10-30 16:37:02 +09:00
3 changed files with 9 additions and 6 deletions

View File

@ -26,6 +26,7 @@ const MessageInput = ({
const [message, setMessage] = useState('');
const [textareaRows, setTextareaRows] = useState(1);
const [mode, setMode] = useState<'multi' | 'single'>('single');
const [isComposing, setIsComposing] = useState(false);
useEffect(() => {
if (textareaRows >= 2 && message && mode === 'single') {
@ -68,7 +69,7 @@ const MessageInput = ({
setMessage('');
}}
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey && !loading) {
if (e.key === 'Enter' && !e.shiftKey && !loading && !isComposing) {
e.preventDefault();
sendMessage(message);
setMessage('');
@ -91,6 +92,8 @@ const MessageInput = ({
ref={inputRef}
value={message}
onChange={(e) => setMessage(e.target.value)}
onCompositionStart={() => setIsComposing(true)}
onCompositionEnd={() => setIsComposing(false)}
onHeightChange={(height, props) => {
setTextareaRows(Math.ceil(height / props.rowHeight));
}}

View File

@ -18,7 +18,7 @@
"clsx": "^2.1.0",
"langchain": "^0.1.30",
"lucide-react": "^0.363.0",
"markdown-to-jsx": "^7.6.2",
"markdown-to-jsx": "^7.7.2",
"next": "14.1.4",
"next-themes": "^0.3.0",
"react": "^18",

View File

@ -2210,10 +2210,10 @@ lucide-react@^0.363.0:
resolved "https://registry.yarnpkg.com/lucide-react/-/lucide-react-0.363.0.tgz#2bb1f9d09b830dda86f5118fcd097f87247fe0e3"
integrity sha512-AlsfPCsXQyQx7wwsIgzcKOL9LwC498LIMAo+c0Es5PkHJa33xwmYAkkSoKoJWWWSYQEStqu58/jT4tL2gi32uQ==
markdown-to-jsx@^7.6.2:
version "7.6.2"
resolved "https://registry.yarnpkg.com/markdown-to-jsx/-/markdown-to-jsx-7.6.2.tgz#254cbf7d412a37073486c0a2dd52266d2191a793"
integrity sha512-gEcyiJXzBxmId2Y/kydLbD6KRNccDiUy/Src1cFGn3s2X0LZZ/hUiEc2VisFyA5kUE3SXclTCczjQiAuqKZiFQ==
markdown-to-jsx@^7.7.2:
version "7.7.2"
resolved "https://registry.yarnpkg.com/markdown-to-jsx/-/markdown-to-jsx-7.7.2.tgz#59c1dd64f48b53719311ab140be3cd51cdabccd3"
integrity sha512-N3AKfYRvxNscvcIH6HDnDKILp4S8UWbebp+s92Y8SwIq0CuSbLW4Jgmrbjku3CWKjTQO0OyIMS6AhzqrwjEa3g==
md5@^2.3.0:
version "2.3.0"