Click to copy LaTeX from UI

This commit is contained in:
muntedcrocodile 2026-04-27 12:08:12 +10:00
parent 4e2240aada
commit 83dd99e74f

View file

@ -17,6 +17,12 @@
<script lang="ts">
import { onMount } from 'svelte';
import { copyToClipboard } from '$lib/utils';
import { toast } from 'svelte-sonner';
import { getContext } from 'svelte';
const i18n = getContext('i18n');
export let content: string;
export let displayMode: boolean = false;
@ -29,5 +35,15 @@
</script>
{#if renderToString}
{@html renderToString(content, { displayMode, throwOnError: false })}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<code
class="cursor-pointer {displayMode ? 'block text-center my-4' : 'inline'}"
onclick={() => {
copyToClipboard(content);
toast.success($i18n.t('Copied to clipboard'));
}}
>
{@html renderToString(content, { displayMode, throwOnError: false })}
</code>
{/if}