Revert "refac"

This reverts commit a140d319fe.
This commit is contained in:
Timothy J. Baek 2024-08-06 11:43:47 +02:00
parent a140d319fe
commit ff90b125ee
2 changed files with 10 additions and 19 deletions

View File

@ -1,28 +1,14 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte';
import { marked } from 'marked';
import type { Token } from 'marked'; import type { Token } from 'marked';
import { revertSanitizedResponseContent, unescapeHtml } from '$lib/utils';
import {
replaceTokens,
revertSanitizedResponseContent,
sanitizeResponseContent,
unescapeHtml
} from '$lib/utils';
import CodeBlock from '$lib/components/chat/Messages/CodeBlock.svelte'; import CodeBlock from '$lib/components/chat/Messages/CodeBlock.svelte';
import { onMount } from 'svelte';
import MarkdownInlineTokens from '$lib/components/chat/Messages/MarkdownInlineTokens.svelte'; import MarkdownInlineTokens from '$lib/components/chat/Messages/MarkdownInlineTokens.svelte';
import { user } from '$lib/stores';
export let id: string; export let id: string;
export let tokens: Token[]; export let tokens: Token[];
export let model = null;
export let content = '';
export let top = true; export let top = true;
$: tokens = marked.lexer(
replaceTokens(sanitizeResponseContent(content), model?.name, $user?.name)
);
const headerComponent = (depth: number) => { const headerComponent = (depth: number) => {
return 'h' + depth; return 'h' + depth;
}; };

View File

@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { toast } from 'svelte-sonner'; import { toast } from 'svelte-sonner';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { marked } from 'marked';
import tippy from 'tippy.js'; import tippy from 'tippy.js';
import auto_render from 'katex/dist/contrib/auto-render.mjs'; import auto_render from 'katex/dist/contrib/auto-render.mjs';
import 'katex/dist/katex.min.css'; import 'katex/dist/katex.min.css';
@ -37,7 +38,7 @@
import Spinner from '$lib/components/common/Spinner.svelte'; import Spinner from '$lib/components/common/Spinner.svelte';
import WebSearchResults from './ResponseMessage/WebSearchResults.svelte'; import WebSearchResults from './ResponseMessage/WebSearchResults.svelte';
import Sparkles from '$lib/components/icons/Sparkles.svelte'; import Sparkles from '$lib/components/icons/Sparkles.svelte';
import Markdown from './Markdown.svelte'; import MarkdownTokens from './MarkdownTokens.svelte';
export let message; export let message;
export let siblings; export let siblings;
@ -76,6 +77,10 @@
let selectedCitation = null; let selectedCitation = null;
$: tokens = marked.lexer(
replaceTokens(sanitizeResponseContent(message?.content), model?.name, $user?.name)
);
$: if (message) { $: if (message) {
renderStyling(); renderStyling();
} }
@ -495,8 +500,8 @@
<!-- always show message contents even if there's an error --> <!-- always show message contents even if there's an error -->
<!-- unless message.error === true which is legacy error handling, where the error message is stored in message.content --> <!-- unless message.error === true which is legacy error handling, where the error message is stored in message.content -->
{#key message.id} {#key tokens}
<Markdown id={message.id} {model} content={message.content} /> <MarkdownTokens id={message.id} {tokens} />
{/key} {/key}
{/if} {/if}