Skip to content

Commit 733a31e

Browse files
author
Jicheng Lu
committed
refine markdown and add chat button in conversation page
1 parent c37bc33 commit 733a31e

File tree

6 files changed

+49
-14
lines changed

6 files changed

+49
-14
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
}
1818
</script>
1919
20-
<div class="ctext-wrap">
21-
<div class="flex-shrink-0 align-self-center">
22-
<span>{@html displayText}</span>
23-
</div>
24-
</div>
20+
<span class="markdown-container">
21+
{@html displayText}
22+
</span>

src/lib/scss/app.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,19 @@ button:focus {
248248

249249
.clickable {
250250
cursor: pointer;
251+
}
252+
253+
.markdown-container {
254+
pre {
255+
-ms-overflow-style: none !important;
256+
}
257+
258+
pre::-webkit-scrollbar {
259+
display: none !important;
260+
}
261+
262+
p {
263+
margin-top: 0 !important;
264+
margin-bottom: 0 !important;
265+
}
251266
}

src/routes/chat/[agentId]/[conversationId]/contentLogs/content-log-element.svelte

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script>
22
import { Button } from '@sveltestrap/sveltestrap';
33
import Link from 'svelte-link/src/Link.svelte';
4+
import Markdown from "$lib/common/Markdown.svelte";
45
import { replaceNewLine } from '$lib/helpers/http';
56
import { ContentLogSource } from '$lib/helpers/enums';
67
import { utcToLocal } from '$lib/helpers/datetime';
@@ -40,7 +41,7 @@
4041
}
4142
</script>
4243

43-
<div class={`log-element p-2 rounded`} id={`content-log-${data.message_id}`}>
44+
<div class="log-element rounded" style="padding: 3px;" id={`content-log-${data.message_id}`}>
4445
<div class="log-meta text-secondary">
4546
<div>
4647
{#if data?.name?.length > 0}
@@ -59,8 +60,12 @@
5960
<span class="ms-2">{`${utcToLocal(data?.created_at, 'hh:mm:ss.SSS A, MMM DD YYYY')} `}</span>
6061
</div>
6162
</div>
62-
<div class={`p-2 rounded log-content ${logDisplayStyle}`} class:log-collapse={includedSources.includes(data.source) && !!is_collapsed}>
63-
{@html replaceNewLine(data?.content)}
63+
<div
64+
class={`rounded log-content ${logDisplayStyle}`}
65+
style="padding: 5px 8px;"
66+
class:log-collapse={includedSources.includes(data.source) && !!is_collapsed}
67+
>
68+
<Markdown text={data?.content} />
6469
</div>
6570

6671
{#if includedSources.includes(data.source)}

src/routes/chat/[agentId]/[conversationId]/richContent/rich-content.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
import { RichType } from "$lib/helpers/enums";
3-
import RcMarkdown from "./rc-markdown.svelte";
3+
import Markdown from "$lib/common/Markdown.svelte";
44
import RcOptions from "./rc-options.svelte";
55
66
/** @type {any} */
@@ -23,7 +23,11 @@
2323
}
2424
</script>
2525

26-
<RcMarkdown text={message?.rich_content?.message?.text || message?.text} />
26+
<div class="ctext-wrap">
27+
<div class="flex-shrink-0 align-self-center">
28+
<Markdown text={message?.rich_content?.message?.text || message?.text} />
29+
</div>
30+
</div>
2731

2832
{#if displayExtraElements}
2933
{#if message?.rich_content?.message?.rich_type === RichType.QuickReply}

src/routes/page/conversation/[conversationId]/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646

4747
{#if conversation}
4848
<Row>
49-
<Col class="col-4">
49+
<Col style="flex: 40%;">
5050
<Overview conversation={conversation} />
5151
<States conversation={conversation} />
5252
</Col>
53-
<Col class="col-8">
53+
<Col style="flex: 60%;">
5454
<Dialog conversation={conversation} />
5555
</Col>
5656
</Row>

src/routes/page/conversation/[conversationId]/conv-dialogs.svelte

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script>
22
import { Card, CardBody, CardTitle, Col, Row } from '@sveltestrap/sveltestrap';
3+
import Link from 'svelte-link/src/Link.svelte';
34
import { GetDialogs } from '$lib/services/conversation-service.js';
45
import { utcToLocal } from '$lib/helpers/datetime';
56
import { onMount } from 'svelte';
6-
import { UserRole } from '$lib/helpers/enums';
77
import { _ } from 'svelte-i18n'
88
import { USER_SENDERS } from '$lib/helpers/constants';
99
@@ -24,11 +24,24 @@
2424
function showInRight(dialog) {
2525
return USER_SENDERS.includes(dialog?.sender?.role || '');
2626
}
27+
28+
function directToChat() {
29+
window.open(`/chat/${conversation.agent_id}/${conversation.id}`);
30+
}
2731
</script>
2832
2933
<Card>
3034
<CardBody>
31-
<CardTitle class="mb-5 h4">{$_('Dialogs')}</CardTitle>
35+
<div style="display: flex; justify-content: space-between;">
36+
<div>
37+
<CardTitle class="mb-5 h4">{$_('Dialogs')}</CardTitle>
38+
</div>
39+
<div>
40+
<Link class="btn btn-soft-info btn-sm btn-rounded" on:click={() => directToChat()}>
41+
<i class="mdi mdi-chat" />
42+
</Link>
43+
</div>
44+
</div>
3245
<div class="">
3346
<ul class="verti-timeline list-unstyled">
3447
{#each dialogs as dialog}

0 commit comments

Comments
 (0)