mirror of
https://github.com/open-webui/open-webui
synced 2025-05-20 13:15:13 +00:00
enh: user message edit
This commit is contained in:
parent
d79d3f1352
commit
330eb0fbb1
@ -51,7 +51,8 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const confirmEditMessage = async (messageId, content) => {
|
const confirmEditMessage = async (messageId, content, submit = true) => {
|
||||||
|
if (submit) {
|
||||||
let userPrompt = content;
|
let userPrompt = content;
|
||||||
let userMessageId = uuidv4();
|
let userMessageId = uuidv4();
|
||||||
|
|
||||||
@ -79,6 +80,14 @@
|
|||||||
|
|
||||||
await tick();
|
await tick();
|
||||||
await sendPrompt(userPrompt, userMessageId);
|
await sendPrompt(userPrompt, userMessageId);
|
||||||
|
} else {
|
||||||
|
history.messages[messageId].content = content;
|
||||||
|
await tick();
|
||||||
|
await updateChatById(localStorage.token, chatId, {
|
||||||
|
messages: messages,
|
||||||
|
history: history
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateChatMessages = async () => {
|
const updateChatMessages = async () => {
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
messageEditTextAreaElement?.focus();
|
messageEditTextAreaElement?.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
const editMessageConfirmHandler = async () => {
|
const editMessageConfirmHandler = async (submit = true) => {
|
||||||
confirmEditMessage(message.id, editedContent);
|
confirmEditMessage(message.id, editedContent, submit);
|
||||||
|
|
||||||
edit = false;
|
edit = false;
|
||||||
editedContent = '';
|
editedContent = '';
|
||||||
@ -140,7 +140,20 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class=" mt-2 mb-1 flex justify-end space-x-1.5 text-sm font-medium">
|
<div class=" mt-2 mb-1 flex justify-between text-sm font-medium">
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
id="save-edit-message-button"
|
||||||
|
class=" px-4 py-2 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 border dark:border-gray-700 text-gray-700 dark:text-gray-200 transition rounded-3xl"
|
||||||
|
on:click={() => {
|
||||||
|
editMessageConfirmHandler(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{$i18n.t('Save')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex space-x-1.5">
|
||||||
<button
|
<button
|
||||||
id="close-edit-message-button"
|
id="close-edit-message-button"
|
||||||
class="px-4 py-2 bg-white dark:bg-gray-900 hover:bg-gray-100 text-gray-800 dark:text-gray-100 transition rounded-3xl"
|
class="px-4 py-2 bg-white dark:bg-gray-900 hover:bg-gray-100 text-gray-800 dark:text-gray-100 transition rounded-3xl"
|
||||||
@ -162,6 +175,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<div class="flex {($settings?.chatBubble ?? true) ? 'justify-end pb-1' : 'w-full'}">
|
<div class="flex {($settings?.chatBubble ?? true) ? 'justify-end pb-1' : 'w-full'}">
|
||||||
|
Loading…
Reference in New Issue
Block a user