forked from open-webui/open-webui
rf: dom queries in UserMessage component
This commit is contained in:
parent
a5c1ac9680
commit
13f0052122
1 changed files with 6 additions and 6 deletions
|
@ -20,18 +20,17 @@
|
|||
|
||||
let edit = false;
|
||||
let editedContent = '';
|
||||
|
||||
let messageEditTextArea: HTMLTextAreaElement;
|
||||
const editMessageHandler = async () => {
|
||||
edit = true;
|
||||
editedContent = message.content;
|
||||
|
||||
await tick();
|
||||
const editElement = document.getElementById(`message-edit-${message.id}`);
|
||||
|
||||
editElement.style.height = '';
|
||||
editElement.style.height = `${editElement.scrollHeight}px`;
|
||||
messageEditTextArea.style.height = '';
|
||||
messageEditTextArea.style.height = `${messageEditTextArea.scrollHeight}px`;
|
||||
|
||||
editElement?.focus();
|
||||
messageEditTextArea?.focus();
|
||||
};
|
||||
|
||||
const editMessageConfirmHandler = async () => {
|
||||
|
@ -165,10 +164,11 @@
|
|||
<div class=" w-full">
|
||||
<textarea
|
||||
id="message-edit-{message.id}"
|
||||
bind:this={messageEditTextArea}
|
||||
class=" bg-transparent outline-none w-full resize-none"
|
||||
bind:value={editedContent}
|
||||
on:input={(e) => {
|
||||
e.target.style.height = `${e.target.scrollHeight}px`;
|
||||
messageEditTextArea.style.height = `${messageEditTextArea.scrollHeight}px`;
|
||||
}}
|
||||
/>
|
||||
|
||||
|
|
Loading…
Reference in a new issue