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 edit = false;
|
||||||
let editedContent = '';
|
let editedContent = '';
|
||||||
|
let messageEditTextArea: HTMLTextAreaElement;
|
||||||
const editMessageHandler = async () => {
|
const editMessageHandler = async () => {
|
||||||
edit = true;
|
edit = true;
|
||||||
editedContent = message.content;
|
editedContent = message.content;
|
||||||
|
|
||||||
await tick();
|
await tick();
|
||||||
const editElement = document.getElementById(`message-edit-${message.id}`);
|
|
||||||
|
|
||||||
editElement.style.height = '';
|
messageEditTextArea.style.height = '';
|
||||||
editElement.style.height = `${editElement.scrollHeight}px`;
|
messageEditTextArea.style.height = `${messageEditTextArea.scrollHeight}px`;
|
||||||
|
|
||||||
editElement?.focus();
|
messageEditTextArea?.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
const editMessageConfirmHandler = async () => {
|
const editMessageConfirmHandler = async () => {
|
||||||
|
@ -165,10 +164,11 @@
|
||||||
<div class=" w-full">
|
<div class=" w-full">
|
||||||
<textarea
|
<textarea
|
||||||
id="message-edit-{message.id}"
|
id="message-edit-{message.id}"
|
||||||
|
bind:this={messageEditTextArea}
|
||||||
class=" bg-transparent outline-none w-full resize-none"
|
class=" bg-transparent outline-none w-full resize-none"
|
||||||
bind:value={editedContent}
|
bind:value={editedContent}
|
||||||
on:input={(e) => {
|
on:input={(e) => {
|
||||||
e.target.style.height = `${e.target.scrollHeight}px`;
|
messageEditTextArea.style.height = `${messageEditTextArea.scrollHeight}px`;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue