Skip to content

Commit

Permalink
Merge branch 'main' into feat/api_elysia_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Mar 3, 2025
2 parents 0d40d92 + ce6725a commit 924e943
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lib/components/CodeBlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
interface Props {
code?: string;
lang?: string;
rawCode?: string;
}
let { code = "" }: Props = $props();
let { code = "", rawCode = "" }: Props = $props();
</script>

<div class="group relative my-4 rounded-lg">
Expand All @@ -17,6 +17,6 @@
></pre>
<CopyToClipBoardBtn
classNames="btn rounded-lg border border-gray-200 px-2 py-2 text-sm shadow-sm transition-all hover:border-gray-300 active:shadow-inner dark:border-gray-700 dark:hover:border-gray-500 absolute top-2 right-2 invisible opacity-0 group-hover:visible group-hover:opacity-100 dark:text-gray-700 text-gray-200"
value={code}
value={rawCode}
/>
</div>
4 changes: 2 additions & 2 deletions src/lib/components/chat/ChatWindow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@
{/if}

{#if messages.length > 0}
<div class="flex h-max flex-col-reverse gap-8 pb-52">
{#each messages.toReversed() as message, idx (message.id)}
<div class="flex h-max flex-col gap-8 pb-52">
{#each messages as message, idx (message.id)}
<ChatMessage
{loading}
{message}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/chat/MarkdownRenderer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@
{@html DOMPurify.sanitize(html)}
{/await}
{:else if token.type === "code"}
<CodeBlock code={token.code} />
<CodeBlock code={token.code} rawCode={token.rawCode} />
{/if}
{/each}
3 changes: 3 additions & 0 deletions src/lib/utils/marked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type CodeToken = {
type: "code";
lang: string;
code: string;
rawCode: string;
};

type TextToken = {
Expand All @@ -190,6 +191,7 @@ export async function processTokens(content: string, sources: WebSearchSource[])
type: "code" as const,
lang: token.lang,
code: hljs.highlightAuto(token.text, hljs.getLanguage(token.lang)?.aliases).value,
rawCode: token.text,
};
} else {
return {
Expand All @@ -212,6 +214,7 @@ export function processTokensSync(content: string, sources: WebSearchSource[]):
type: "code" as const,
lang: token.lang,
code: hljs.highlightAuto(token.text, hljs.getLanguage(token.lang)?.aliases).value,
rawCode: token.text,
};
}
return { type: "text" as const, html: marked.parse(token.raw) };
Expand Down

0 comments on commit 924e943

Please sign in to comment.