From 2c295760a3c5379f23eac096bbb3c5d79d663daf Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Mon, 15 Apr 2024 15:57:27 -0500 Subject: [PATCH 1/2] refine rich content --- src/lib/helpers/enums.js | 3 +- src/lib/scss/custom/pages/_chat.scss | 6 +- .../[conversationId]/chat-box.svelte | 29 ++++---- .../chatImage/chat-attachment.svelte | 9 +-- .../richContent/rc-complex-options.svelte | 11 ++-- .../richContent/rc-message.svelte | 12 ++++ .../richContent/rc-plain-options.svelte | 6 +- .../richContent/rich-content.svelte | 66 ------------------- .../richContent/rich-options.svelte | 52 +++++++++++++++ 9 files changed, 96 insertions(+), 98 deletions(-) create mode 100644 src/routes/chat/[agentId]/[conversationId]/richContent/rc-message.svelte delete mode 100644 src/routes/chat/[agentId]/[conversationId]/richContent/rich-content.svelte create mode 100644 src/routes/chat/[agentId]/[conversationId]/richContent/rich-options.svelte diff --git a/src/lib/helpers/enums.js b/src/lib/helpers/enums.js index 6ec07460..11c9e3c4 100644 --- a/src/lib/helpers/enums.js +++ b/src/lib/helpers/enums.js @@ -20,7 +20,8 @@ const richType = { QuickReply: 'quick_reply', Button: 'button_template', MultiSelect: 'multi-select_template', - Generic: 'generic_template' + Generic: 'generic_template', + Attachment: 'attachment' } export const RichType = Object.freeze(richType); diff --git a/src/lib/scss/custom/pages/_chat.scss b/src/lib/scss/custom/pages/_chat.scss index ccfff40e..b7775a9f 100644 --- a/src/lib/scss/custom/pages/_chat.scss +++ b/src/lib/scss/custom/pages/_chat.scss @@ -225,7 +225,6 @@ button { min-width: 50px; - text-align: left; border-radius: 10px; } } @@ -233,14 +232,14 @@ .complex-option-container { display: flex; flex-wrap: wrap; - gap: 5px; + gap: 3px; margin-top: 10px; .card-element { flex: 1 1 50%; border-radius: 10px; border-width: 2px; - max-width: 45%; + max-width: calc(50% - 2.5px); margin-bottom: 0px; @media (max-width: 620px) { @@ -271,7 +270,6 @@ .btn { display: block; margin-left: 0px !important; - text-align: left; border-radius: 10px; } } diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 3f7c64f3..b0d0bdb3 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -25,7 +25,8 @@ import { utcToLocal } from '$lib/helpers/datetime'; import { replaceNewLine } from '$lib/helpers/http'; import { EditorType, SenderAction, UserRole } from '$lib/helpers/enums'; - import RichContent from './richContent/rich-content.svelte'; + import RichOptions from './richContent/rich-options.svelte'; + import RcMessage from './richContent/rc-message.svelte'; import ContentLog from './contentLogs/content-log.svelte'; import _ from "lodash"; import { Pane, Splitpanes } from 'svelte-splitpanes'; @@ -36,6 +37,7 @@ import "sweetalert2/src/sweetalert2.scss"; import moment from 'moment'; + const options = { scrollbars: { visibility: 'auto', @@ -905,17 +907,20 @@ {/if}
- - + + {#if message.message_id === lastBotMsg?.message_id && lastBotMsg?.rich_content?.editor === EditorType.File} + + {/if} + {#if message.message_id === lastBotMsg?.message_id && !isSendingMsg && !isThinking} + + {/if}
{/if} diff --git a/src/routes/chat/[agentId]/[conversationId]/chatImage/chat-attachment.svelte b/src/routes/chat/[agentId]/[conversationId]/chatImage/chat-attachment.svelte index 279848d5..7d6f303b 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chatImage/chat-attachment.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chatImage/chat-attachment.svelte @@ -4,9 +4,6 @@ import { conversationUserAttachmentStore } from "$lib/helpers/store"; import { onMount } from "svelte"; - /** @type {boolean} */ - export let displayComponents = true; - /** @type {boolean} */ export let disabled = false; @@ -38,7 +35,5 @@ } -{#if displayComponents} - handleFileDrop(e)} /> - -{/if} \ No newline at end of file + handleFileDrop(e)} /> + \ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/richContent/rc-complex-options.svelte b/src/routes/chat/[agentId]/[conversationId]/richContent/rc-complex-options.svelte index d280620c..34e7560c 100644 --- a/src/routes/chat/[agentId]/[conversationId]/richContent/rc-complex-options.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/richContent/rc-complex-options.svelte @@ -1,9 +1,9 @@ + +
+
+ +
+
\ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/richContent/rc-plain-options.svelte b/src/routes/chat/[agentId]/[conversationId]/richContent/rc-plain-options.svelte index a85bee5e..f1c51846 100644 --- a/src/routes/chat/[agentId]/[conversationId]/richContent/rc-plain-options.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/richContent/rc-plain-options.svelte @@ -8,7 +8,7 @@ export let isMultiSelect = false; /** @type {boolean} */ - export let disableOption = false; + export let disabled = false; /** @type {any[]} */ export let options = []; @@ -135,7 +135,7 @@