Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine mark down style #241

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/common/Markdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
export let containerClasses = "";

/** @type {boolean} */
export let replaceText = false;
export let rawText = false;

let displayText = '';
$: {
const markedText = replaceNewLine(marked(replaceText ? replaceMarkdown(text || '') : text || '')?.toString());
const markedText = !rawText ? replaceNewLine(marked(replaceMarkdown(text || ''))?.toString()) : marked(text || '')?.toString();
if (!!markedText && markedText.endsWith('<br>')) {
const idx = markedText.lastIndexOf('<br>');
displayText = markedText.substring(0, idx);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scss/custom/common/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ button:focus {
}

p {
margin-top: 0 !important;
margin-bottom: 0 !important;
margin-top: 1em !important;
margin-bottom: 1em !important;
}

a {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scss/custom/pages/_chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@
}

span p {
margin-top: 0px !important;
margin-bottom: 0px !important;
margin-top: 1em !important;
margin-bottom: 1em !important;
}

.chat-indication {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
let logTextStyle = '';
let is_collapsed = true;
const unknownAgent = "Uknown";
const includedSources = [
const collapsedSources = [
ContentLogSource.Prompt,
ContentLogSource.AgentResponse,
ContentLogSource.FunctionCall,
ContentLogSource.Notification
];

const rawTextSources = [
ContentLogSource.AgentResponse,
ContentLogSource.FunctionCall,
];

$: {
if (data.source === ContentLogSource.AgentResponse || data.source === ContentLogSource.Notification) {
logDisplayStyle = 'border border-secondary';
Expand Down Expand Up @@ -63,11 +68,11 @@
class={`rounded log-content ${logDisplayStyle}`}
style="padding: 5px 8px;"
>
<div class:log-collapse={includedSources.includes(data.source) && !!is_collapsed}>
<Markdown containerClasses={logTextStyle} text={data?.content} replaceText />
<div class:log-collapse={collapsedSources.includes(data.source) && !!is_collapsed}>
<Markdown containerClasses={logTextStyle} text={data?.content} rawText={rawTextSources.includes(data.source)} />
</div>

{#if includedSources.includes(data.source)}
{#if collapsedSources.includes(data.source)}
<Button class='toggle-btn btn-sm' color="link" on:click={(e) => toggleText(e)}>
{`${is_collapsed ? 'More +' : 'Less -'}`}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

<div class="ctext-wrap bg-primary">
<div class="flex-shrink-0 align-self-center">
<Markdown text={message?.rich_content?.message?.text || message?.text} />
<Markdown text={message?.rich_content?.message?.text || message?.text} rawText />
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Markdown
containerClasses={'dialog-item-text'}
text={dialog?.rich_content?.message?.text || dialog?.text}
replaceText
rawText
/>
</div>

Expand Down
Loading