|
23 | 23 | import { onMount, setContext, tick } from 'svelte'; |
24 | 24 | import Viewport from 'svelte-viewport-info'; |
25 | 25 | import { PUBLIC_LIVECHAT_ENTRY_ICON } from '$env/static/public'; |
26 | | - import { BOT_SENDERS, USER_SENDERS } from '$lib/helpers/constants'; |
| 26 | + import { BOT_SENDERS, FILE_EDITORS, TEXT_EDITORS, USER_SENDERS } from '$lib/helpers/constants'; |
27 | 27 | import { signalr } from '$lib/services/signalr-service.js'; |
28 | 28 | import { webSpeech } from '$lib/services/web-speech.js'; |
29 | 29 | import { newConversation } from '$lib/services/conversation-service'; |
|
118 | 118 | let isThinking = false; |
119 | 119 | let isLite = false; |
120 | 120 | let isFrame = false; |
| 121 | + let loadEditor = false; |
| 122 | + let loadTextEditor = false; |
| 123 | + let loadFileEditor = false; |
| 124 | +
|
| 125 | + $: { |
| 126 | + loadTextEditor = TEXT_EDITORS.includes(lastBotMsg?.rich_content?.editor || ''); |
| 127 | + loadFileEditor = FILE_EDITORS.includes(lastBotMsg?.rich_content?.editor || ''); |
| 128 | + loadEditor = !isSendingMsg && !isThinking && (loadTextEditor || loadFileEditor); |
| 129 | + } |
121 | 130 |
|
122 | 131 | setContext('chat-window-context', { |
123 | 132 | autoScrollToBottom: autoScrollToBottom |
|
856 | 865 | <Pane minSize={20}> |
857 | 866 | <div style="height: 100vh;"> |
858 | 867 | <div class="card mb-0" style="height: 100vh;"> |
859 | | - <div class="border-bottom chat-head" style="height: 10%;"> |
| 868 | + <div class="border-bottom chat-head"> |
860 | 869 | <div class="row"> |
861 | 870 | <div class="col-md-4 col-7 head-left"> |
862 | 871 | <div class="m-1">{agent?.name}</div> |
|
922 | 931 | </div> |
923 | 932 | </div> |
924 | 933 |
|
925 | | - <div class="chat-scrollbar scroll-bottom-to-top" style="height: 82%;"> |
| 934 | + <div class={`chat-scrollbar chat-content scroll-bottom-to-top ${!loadEditor ? 'chat-content-expand' : ''}`}> |
926 | 935 | <div class="chat-conversation p-3"> |
927 | 936 | <ul class="list-unstyled mb-0"> |
928 | 937 | {#each Object.entries(groupedDialogs) as [createDate, dialogGroup]} |
|
1020 | 1029 | <ChatImageGallery disabled={isSendingMsg || isThinking} /> |
1021 | 1030 | {/if} |
1022 | 1031 | {#if !!lastBotMsg && !isSendingMsg && !isThinking} |
1023 | | - <div> |
1024 | | - <RichContent |
1025 | | - message={lastBotMsg} |
1026 | | - disabled={isSendingMsg || isThinking} |
1027 | | - onConfirm={confirmSelectedOption} |
1028 | | - /> |
1029 | | - </div> |
| 1032 | + <RichContent |
| 1033 | + message={lastBotMsg} |
| 1034 | + disabled={isSendingMsg || isThinking} |
| 1035 | + onConfirm={confirmSelectedOption} |
| 1036 | + /> |
1030 | 1037 | {/if} |
1031 | 1038 | |
1032 | 1039 | </div> |
1033 | 1040 | </div> |
1034 | 1041 |
|
1035 | | - <div class="chat-input-section" style="height: 8%;"> |
| 1042 | + <div class={`chat-input-section ${!loadEditor ? 'chat-input-hide' : ''}`}> |
1036 | 1043 | <div class="row"> |
1037 | | - <div class="col-auto"> |
1038 | | - <button |
1039 | | - type="submit" |
1040 | | - class="btn btn-primary btn-rounded waves-effect waves-light" |
1041 | | - disabled={isSendingMsg || isThinking || lastBotMsg?.rich_content?.editor == EditorType.None} |
1042 | | - on:click={startListen} |
1043 | | - > |
1044 | | - <i class="mdi mdi-{microphoneIcon} md-36" /> |
1045 | | - </button> |
1046 | | - </div> |
1047 | | - <div class="col"> |
1048 | | - <div class="position-relative"> |
1049 | | - <ChatTextArea |
1050 | | - className={`chat-input ${lastBotMsg?.rich_content?.editor == EditorType.File ? 'chat-input-image' : ''}`} |
1051 | | - bind:text={text} |
1052 | | - disabled={isSendingMsg || isThinking || lastBotMsg?.rich_content?.editor == EditorType.None} |
1053 | | - editor={lastBotMsg?.rich_content?.editor || ''} |
1054 | | - onKeyDown={e => onSendMessage(e)} |
1055 | | - /> |
1056 | | - {#if lastBotMsg?.rich_content?.editor == EditorType.File} |
1057 | | - <ChatImageUploader /> |
1058 | | - {/if} |
| 1044 | + {#if loadTextEditor} |
| 1045 | + <div class="col-auto"> |
| 1046 | + <button |
| 1047 | + type="submit" |
| 1048 | + class="btn btn-primary btn-rounded waves-effect waves-light" |
| 1049 | + disabled={isSendingMsg || isThinking} |
| 1050 | + on:click={startListen} |
| 1051 | + > |
| 1052 | + <i class="mdi mdi-{microphoneIcon} md-36" /> |
| 1053 | + </button> |
1059 | 1054 | </div> |
1060 | | - </div> |
1061 | | - <div class="col-auto"> |
1062 | | - <button |
1063 | | - type="submit" |
1064 | | - class="btn btn-primary btn-rounded chat-send waves-effect waves-light" |
1065 | | - disabled={!!!_.trim(text) || isSendingMsg || isThinking} |
1066 | | - on:click={() => sentTextMessage()} |
1067 | | - ><span class="d-none d-md-inline-block me-2">Send</span> |
1068 | | - <i class="mdi mdi-send" /> |
1069 | | - </button> |
1070 | | - </div> |
| 1055 | + <div class="col"> |
| 1056 | + <div class="position-relative"> |
| 1057 | + <ChatTextArea |
| 1058 | + className={`chat-input`} |
| 1059 | + bind:text={text} |
| 1060 | + disabled={isSendingMsg || isThinking} |
| 1061 | + editor={lastBotMsg?.rich_content?.editor || ''} |
| 1062 | + onKeyDown={e => onSendMessage(e)} |
| 1063 | + /> |
| 1064 | + </div> |
| 1065 | + </div> |
| 1066 | + <div class="col-auto"> |
| 1067 | + <button |
| 1068 | + type="submit" |
| 1069 | + class="btn btn-primary btn-rounded chat-send waves-effect waves-light" |
| 1070 | + disabled={!!!_.trim(text) || isSendingMsg || isThinking} |
| 1071 | + on:click={() => sentTextMessage()} |
| 1072 | + ><span class="d-none d-md-inline-block me-2">Send</span> |
| 1073 | + <i class="mdi mdi-send" /> |
| 1074 | + </button> |
| 1075 | + </div> |
| 1076 | + {:else if loadFileEditor} |
| 1077 | + <ChatImageUploader /> |
| 1078 | + {/if} |
1071 | 1079 | </div> |
1072 | 1080 | </div> |
1073 | 1081 | </div> |
|
0 commit comments