|
@@ -1,12 +1,17 @@
|
|
|
<script lang="ts">
|
|
|
import DOMPurify from 'dompurify';
|
|
|
+ import { toast } from 'svelte-sonner';
|
|
|
+
|
|
|
import type { Token } from 'marked';
|
|
|
- import { revertSanitizedResponseContent, unescapeHtml } from '$lib/utils';
|
|
|
- import { onMount } from 'svelte';
|
|
|
- import Image from '$lib/components/common/Image.svelte';
|
|
|
+ import { getContext } from 'svelte';
|
|
|
+
|
|
|
+ const i18n = getContext('i18n');
|
|
|
|
|
|
- import KatexRenderer from './KatexRenderer.svelte';
|
|
|
import { WEBUI_BASE_URL } from '$lib/constants';
|
|
|
+ import { copyToClipboard, revertSanitizedResponseContent, unescapeHtml } from '$lib/utils';
|
|
|
+
|
|
|
+ import Image from '$lib/components/common/Image.svelte';
|
|
|
+ import KatexRenderer from './KatexRenderer.svelte';
|
|
|
|
|
|
export let id: string;
|
|
|
export let tokens: Token[];
|
|
@@ -37,7 +42,15 @@
|
|
|
<svelte:self id={`${id}-em`} tokens={token.tokens} />
|
|
|
</em>
|
|
|
{:else if token.type === 'codespan'}
|
|
|
- <code class="codespan">{unescapeHtml(token.text)}</code>
|
|
|
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
+ <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
|
+ <code
|
|
|
+ class="codespan cursor-pointer"
|
|
|
+ on:click={() => {
|
|
|
+ copyToClipboard(unescapeHtml(token.text));
|
|
|
+ toast.success($i18n.t('Copied to clipboard'));
|
|
|
+ }}>{unescapeHtml(token.text)}</code
|
|
|
+ >
|
|
|
{:else if token.type === 'br'}
|
|
|
<br />
|
|
|
{:else if token.type === 'del'}
|