forked from open-webui/open-webui
fix: code block unmount issue
This commit is contained in:
parent
917ab08f5c
commit
52e7684ff4
2 changed files with 330 additions and 326 deletions
|
@ -20,11 +20,12 @@
|
||||||
$: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : '';
|
$: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : '';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if code}
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<div
|
<div
|
||||||
class="flex justify-between bg-[#202123] text-white text-xs px-4 pt-1 pb-0.5 rounded-t-lg overflow-x-auto"
|
class="flex justify-between bg-[#202123] text-white text-xs px-4 pt-1 pb-0.5 rounded-t-lg overflow-x-auto"
|
||||||
>
|
>
|
||||||
<div class="p-1">{lang}</div>
|
<div class="p-1">{@html lang}</div>
|
||||||
<button class="copy-code-button bg-none border-none p-1" on:click={copyCode}
|
<button class="copy-code-button bg-none border-none p-1" on:click={copyCode}
|
||||||
>{copied ? 'Copied' : 'Copy Code'}</button
|
>{copied ? 'Copied' : 'Copy Code'}</button
|
||||||
>
|
>
|
||||||
|
@ -34,3 +35,4 @@
|
||||||
class="language-{lang} rounded-t-none whitespace-pre">{@html highlightedCode || code}</code
|
class="language-{lang} rounded-t-none whitespace-pre">{@html highlightedCode || code}</code
|
||||||
></pre>
|
></pre>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
|
@ -154,6 +154,7 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#key message.id}
|
||||||
<div class=" flex w-full message-{message.id}">
|
<div class=" flex w-full message-{message.id}">
|
||||||
<ProfileImage src={modelfiles[message.model]?.imageUrl ?? '/favicon.png'} />
|
<ProfileImage src={modelfiles[message.model]?.imageUrl ?? '/favicon.png'} />
|
||||||
|
|
||||||
|
@ -240,9 +241,9 @@
|
||||||
{:else}
|
{:else}
|
||||||
{#each tokens as token}
|
{#each tokens as token}
|
||||||
{#if token.type === 'code'}
|
{#if token.type === 'code'}
|
||||||
|
<!-- {token.text} -->
|
||||||
<CodeBlock lang={token.lang} code={token.text} />
|
<CodeBlock lang={token.lang} code={token.text} />
|
||||||
{:else}
|
{:else}
|
||||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
||||||
{@html marked.parse(token.raw, {
|
{@html marked.parse(token.raw, {
|
||||||
...defaults,
|
...defaults,
|
||||||
gfm: true,
|
gfm: true,
|
||||||
|
@ -502,3 +503,4 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/key}
|
||||||
|
|
Loading…
Reference in a new issue