perf: Optimization of chat input with line break when pressing enter

This commit is contained in:
wangdan-fit2cloud 2025-02-28 16:47:48 +08:00 committed by GitHub
parent 463ad49c9f
commit 8a02f62c70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -535,10 +535,20 @@ function sendChatHandle(event?: any) {
}
}
} else {
// ctrl+
inputValue.value += '\n'
// ctrl+
insertNewlineAtCursor()
}
}
const insertNewlineAtCursor = () => {
const textarea = document.querySelector('.el-textarea__inner') as HTMLTextAreaElement
const startPos = textarea.selectionStart
const endPos = textarea.selectionEnd
//
inputValue.value = inputValue.value.slice(0, startPos) + '\n' + inputValue.value.slice(endPos)
nextTick(() => {
textarea.setSelectionRange(startPos + 1, startPos + 1) //
})
}
function deleteFile(index: number, val: string) {
if (val === 'image') {

View File

@ -11,9 +11,7 @@
margin: 0;
padding: 0;
}
[v-cloak] {
display: none !important;
}
html {
height: 100%;
box-sizing: border-box;