Merge pull request #6890 from michaelpoluektov/revert-6879-fix/render-html-in-citations

feat: DOMPurify to iframe to render HTML in citations
This commit is contained in:
Timothy Jaeryang Baek 2024-11-12 16:15:05 -08:00 committed by GitHub
commit 90b40c82dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import DOMPurify from 'dompurify';
import { getContext, onMount, tick } from 'svelte'; import { getContext, onMount, tick } from 'svelte';
import Modal from '$lib/components/common/Modal.svelte'; import Modal from '$lib/components/common/Modal.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte';
@ -150,13 +148,18 @@
<div class=" text-sm font-medium dark:text-gray-300 mt-2"> <div class=" text-sm font-medium dark:text-gray-300 mt-2">
{$i18n.t('Content')} {$i18n.t('Content')}
</div> </div>
<pre class="text-sm dark:text-gray-400 whitespace-pre-line">
{#if document.metadata?.html} {#if document.metadata?.html}
{@html DOMPurify(document.document)} <iframe
class="w-full border-0 h-auto rounded-none"
sandbox="allow-scripts allow-forms allow-same-origin"
srcdoc={document.document}
title={$i18n.t('Content')}
></iframe>
{:else} {:else}
<pre class="text-sm dark:text-gray-400 whitespace-pre-line">
{document.document} {document.document}
{/if}
</pre> </pre>
{/if}
</div> </div>
{#if documentIdx !== mergedDocuments.length - 1} {#if documentIdx !== mergedDocuments.length - 1}