mirror of
https://github.com/open-webui/open-webui
synced 2025-03-28 11:22:31 +00:00
enh: mermaid copy content button
This commit is contained in:
parent
ba2df1c33a
commit
63d297756a
@ -191,7 +191,7 @@
|
|||||||
showArtifacts.set(false);
|
showArtifacts.set(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ArrowLeft className="size-3.5" />
|
<ArrowLeft className="size-3.5 text-gray-900 dark:text-white" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -302,6 +302,7 @@ __builtins__.input = input`);
|
|||||||
<SvgPanZoom
|
<SvgPanZoom
|
||||||
className=" border border-gray-50 dark:border-gray-850 rounded-lg max-h-fit overflow-hidden"
|
className=" border border-gray-50 dark:border-gray-850 rounded-lg max-h-fit overflow-hidden"
|
||||||
svg={mermaidHtml}
|
svg={mermaidHtml}
|
||||||
|
content={_token.text}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<pre class="mermaid">{code}</pre>
|
<pre class="mermaid">{code}</pre>
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount, getContext } from 'svelte';
|
||||||
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
import panzoom from 'panzoom';
|
import panzoom from 'panzoom';
|
||||||
|
|
||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
|
import DocumentDuplicate from '../icons/DocumentDuplicate.svelte';
|
||||||
|
import { copyToClipboard } from '$lib/utils';
|
||||||
|
import { toast } from 'svelte-sonner';
|
||||||
|
import Tooltip from './Tooltip.svelte';
|
||||||
|
import Clipboard from '../icons/Clipboard.svelte';
|
||||||
|
|
||||||
export let className = '';
|
export let className = '';
|
||||||
export let svg = '';
|
export let svg = '';
|
||||||
|
export let content = '';
|
||||||
|
|
||||||
let instance;
|
let instance;
|
||||||
|
|
||||||
@ -22,8 +30,24 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={sceneParentElement} class={className}>
|
<div bind:this={sceneParentElement} class="relative {className}">
|
||||||
<div bind:this={sceneElement} class="flex h-full max-h-full justify-center items-center">
|
<div bind:this={sceneElement} class="flex h-full max-h-full justify-center items-center">
|
||||||
{@html svg}
|
{@html svg}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if content}
|
||||||
|
<div class=" absolute top-1 right-1">
|
||||||
|
<Tooltip content={$i18n.t('Copy to clipboard')}>
|
||||||
|
<button
|
||||||
|
class="p-1.5 rounded-lg border border-gray-100 dark:border-none dark:bg-gray-850 hover:bg-gray-50 dark:hover:bg-gray-800 transition"
|
||||||
|
on:click={() => {
|
||||||
|
copyToClipboard(content);
|
||||||
|
toast.success($i18n.t('Copied to clipboard'));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Clipboard className=" size-4" strokeWidth="1.5" />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user