mirror of
https://github.com/coaidev/coai.git
synced 2025-05-29 01:40:17 +09:00
use textarea instead of chat input
This commit is contained in:
parent
b417368184
commit
574f26dfee
@ -678,14 +678,15 @@
|
|||||||
.chat-box {
|
.chat-box {
|
||||||
position: relative;
|
position: relative;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
margin-right: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-box {
|
.input-box {
|
||||||
|
resize: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
color: hsl(var(--text));
|
color: hsl(var(--text));
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
padding-right: 0.25rem;
|
scrollbar-width: thin;
|
||||||
|
padding-right: 3rem;
|
||||||
|
|
||||||
&.align {
|
&.align {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -719,7 +720,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.action-button {
|
.action-button {
|
||||||
|
position: absolute;
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
|
right: 0.5rem;
|
||||||
|
bottom: 0.5rem;
|
||||||
|
|
||||||
.send-icon {
|
.send-icon {
|
||||||
fill: hsl(var(--text));
|
fill: hsl(var(--text));
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Input } from "@/components/ui/input.tsx";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { setMemory } from "@/utils/memory.ts";
|
import { setMemory } from "@/utils/memory.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {Textarea} from "@/components/ui/textarea.tsx";
|
||||||
|
|
||||||
type ChatInputProps = {
|
type ChatInputProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
target?: React.RefObject<HTMLInputElement>;
|
target?: React.RefObject<HTMLTextAreaElement>;
|
||||||
value: string;
|
value: string;
|
||||||
onValueChange: (value: string) => void;
|
onValueChange: (value: string) => void;
|
||||||
onEnterPressed: () => void;
|
onEnterPressed: () => void;
|
||||||
@ -19,20 +19,29 @@ function ChatInput({
|
|||||||
onEnterPressed,
|
onEnterPressed,
|
||||||
}: ChatInputProps) {
|
}: ChatInputProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [stamp, setStamp] = React.useState(0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Input
|
<Textarea
|
||||||
id={`input`}
|
id={`input`}
|
||||||
className={`input-box ${className || ""}`}
|
className={`input-box ${className || ""}`}
|
||||||
ref={target}
|
ref={target}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
rows={3}
|
||||||
|
onChange={(e) => {
|
||||||
onValueChange(e.target.value);
|
onValueChange(e.target.value);
|
||||||
setMemory("history", e.target.value);
|
setMemory("history", e.target.value);
|
||||||
}}
|
}}
|
||||||
placeholder={t("chat.placeholder")}
|
placeholder={t("chat.placeholder")}
|
||||||
onKeyDown={async (e: React.KeyboardEvent<HTMLInputElement>) => {
|
onKeyDown={async (e) => {
|
||||||
if (e.key === "Enter") onEnterPressed();
|
if (e.key === "Control") {
|
||||||
|
setStamp(Date.now());
|
||||||
|
} else if (e.key === "Enter" && !e.shiftKey) {
|
||||||
|
if (stamp > 0 && Date.now() - stamp < 200) {
|
||||||
|
e.preventDefault();
|
||||||
|
onEnterPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -7,7 +7,7 @@ export const settingsSlice = createSlice({
|
|||||||
initialState: {
|
initialState: {
|
||||||
dialog: false,
|
dialog: false,
|
||||||
context: getMemory("context") !== "false",
|
context: getMemory("context") !== "false",
|
||||||
align: getMemory("align") !== "false",
|
align: getMemory("align") === "true",
|
||||||
},
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
toggleDialog: (state) => {
|
toggleDialog: (state) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user