mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
add copy clipboard button
This commit is contained in:
parent
46cb8ebe7a
commit
587c9c9832
@ -16,8 +16,17 @@
|
||||
<div ref="chatContainer" class="messages-scroll-container">
|
||||
<TransitionGroup class="messages" tag="div" name="chat">
|
||||
<div v-for="(message, index) in messages" :key="index" :class="['message', message.role]">
|
||||
<div class="message-content">
|
||||
<span v-html="message.content.replace(/\n/g, '<br>')"></span>
|
||||
<div class="message-content position-relative inner-container">
|
||||
<span v-html="formatMessage(message)"></span>
|
||||
<b-button
|
||||
v-if="message.role === 'assistant'"
|
||||
variant="light"
|
||||
class="copy-clipboard-button"
|
||||
:title="$t('copy-to-clipboard')"
|
||||
@click="copyToClipboard(message.content)"
|
||||
>
|
||||
<IBiClipboard></IBiClipboard>
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
@ -81,6 +90,15 @@ const textareaPlaceholder = computed(() =>
|
||||
loading.value ? t('ai.chat-placeholder-loading') : t('ai.chat-placeholder'),
|
||||
)
|
||||
|
||||
function formatMessage(message) {
|
||||
return message.content.replace(/\n/g, '<br>')
|
||||
}
|
||||
|
||||
function copyToClipboard(content) {
|
||||
navigator.clipboard.writeText(content)
|
||||
toastSuccess(t('copied-to-clipboard'))
|
||||
}
|
||||
|
||||
function openChat() {
|
||||
isChatOpen.value = true
|
||||
if (messages.value.length > 0) {
|
||||
@ -200,7 +218,7 @@ onMounted(async () => {
|
||||
|
||||
.chat-window {
|
||||
width: 550px;
|
||||
height: 300px;
|
||||
height: 330px;
|
||||
background-color: white;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 8px;
|
||||
@ -209,6 +227,15 @@ onMounted(async () => {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.copy-clipboard-button {
|
||||
position: absolute;
|
||||
top: 20%;
|
||||
right: -12%;
|
||||
padding-top: 2px;
|
||||
padding-left: 6px;
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.messages-scroll-container {
|
||||
border-radius: 8px;
|
||||
flex: 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user