Explorar el Código

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

feat: DOMPurify to iframe to render HTML in citations
Timothy Jaeryang Baek hace 5 meses
padre
commit
90b40c82dd
Se han modificado 1 ficheros con 12 adiciones y 9 borrados
  1. 12 9
      src/lib/components/chat/Messages/CitationsModal.svelte

+ 12 - 9
src/lib/components/chat/Messages/CitationsModal.svelte

@@ -1,6 +1,4 @@
 <script lang="ts">
-	import DOMPurify from 'dompurify';
-
 	import { getContext, onMount, tick } from 'svelte';
 	import Modal from '$lib/components/common/Modal.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">
 							{$i18n.t('Content')}
 						</div>
-						<pre class="text-sm dark:text-gray-400 whitespace-pre-line">
-							{#if document.metadata?.html}
-								{@html DOMPurify(document.document)}
-							{:else}
-								{document.document}
-							{/if}
-						</pre>
+						{#if document.metadata?.html}
+							<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}
+							<pre class="text-sm dark:text-gray-400 whitespace-pre-line">
+                {document.document}
+              </pre>
+						{/if}
 					</div>
 
 					{#if documentIdx !== mergedDocuments.length - 1}