fix(ai-copilot): tăng chiều cao prompt input rows=4 + resize-y, sửa ArrowUp/ArrowDown chỉ gọi history khi cursor ở đầu/cuối text
This commit is contained in:
@@ -15261,18 +15261,18 @@ const App = () => {
|
||||
value: aiPrompt,
|
||||
onChange: e => setAiPrompt(e.target.value),
|
||||
placeholder: "Nhập lệnh điều khiển DAW... (VD: Tạo track mới tên Beat, đặt BPM 128)",
|
||||
className: "w-full bg-[#1e1e1e] text-zinc-200 p-1.5 rounded border border-zinc-700 focus:outline-none focus:border-purple-600 font-mono text-xs resize-none",
|
||||
rows: 2,
|
||||
className: "w-full bg-[#1e1e1e] text-zinc-200 p-1.5 rounded border border-zinc-700 focus:outline-none focus:border-purple-600 font-mono text-xs resize-y",
|
||||
rows: 4,
|
||||
onKeyDown: e => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
handleAISend();
|
||||
} else if (e.key === 'ArrowUp' && promptHistRef.current.length > 0) {
|
||||
} else if (e.key === 'ArrowUp' && promptHistRef.current.length > 0 && e.target.selectionStart === 0) {
|
||||
e.preventDefault();
|
||||
const idx = promptHistIdx === -1 ? promptHistRef.current.length - 1 : Math.max(0, promptHistIdx - 1);
|
||||
setPromptHistIdx(idx);
|
||||
setAiPrompt(promptHistRef.current[idx]);
|
||||
} else if (e.key === 'ArrowDown') {
|
||||
} else if (e.key === 'ArrowDown' && e.target.selectionStart === aiPrompt.length) {
|
||||
e.preventDefault();
|
||||
if (promptHistIdx === -1) return;
|
||||
const idx = promptHistIdx + 1;
|
||||
|
||||
Reference in New Issue
Block a user