99d239c8bf
复用了画布agent的输入框: * 高度自适应 * 滑动条样式变为浅色和位置不再出界 before  after  Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/130 Co-authored-by: 王德宇 <kvtodev@outlook.com> Co-committed-by: 王德宇 <kvtodev@outlook.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import {
|
|
type ClipboardEventHandler,
|
|
type KeyboardEvent,
|
|
} from 'react';
|
|
|
|
import { AutoGrowTextArea } from '@/src/components/common/AutoGrowTextArea';
|
|
|
|
export function EditorAgentDraftTextarea({
|
|
value,
|
|
onChange,
|
|
onPaste,
|
|
}: {
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
onPaste?: ClipboardEventHandler<HTMLTextAreaElement>;
|
|
}) {
|
|
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
if (
|
|
event.key === 'Enter' &&
|
|
!event.shiftKey &&
|
|
!event.nativeEvent.isComposing &&
|
|
event.nativeEvent.keyCode !== 229
|
|
) {
|
|
event.preventDefault();
|
|
event.currentTarget.form?.requestSubmit();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<AutoGrowTextArea
|
|
className="editor-agent-conversation__draft-input min-w-0 flex-1 rounded-3xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-800 outline-none focus:border-slate-400"
|
|
aria-label="发送给画布 Agent"
|
|
value={value}
|
|
onChange={(event) => onChange(event.currentTarget.value)}
|
|
onPaste={onPaste}
|
|
onKeyDown={handleKeyDown}
|
|
/>
|
|
);
|
|
}
|