This commit is contained in:
Timothy Jaeryang Baek 2025-09-09 17:36:18 +04:00
parent d0b20df46c
commit 63ca0b8cba
2 changed files with 28 additions and 3 deletions

View file

@ -11,14 +11,16 @@
let showPercentage = false; let showPercentage = false;
let showRelevance = true; let showRelevance = true;
let citationModal = null;
let showCitationModal = false; let showCitationModal = false;
let selectedCitation: any = null; let selectedCitation: any = null;
let isCollapsibleOpen = false; let isCollapsibleOpen = false;
export const showSourceModal = (sourceIdx) => { export const showSourceModal = (sourceIdx) => {
if (citations[sourceIdx]) { if (citations[sourceIdx]) {
selectedCitation = citations[sourceIdx]; console.log('Showing citation modal for:', citations[sourceIdx]);
showCitationModal = true; citationModal?.showCitation(citations[sourceIdx]);
// showCitationModal = true;
} }
}; };
@ -94,7 +96,14 @@
} }
</script> </script>
<CitationsModal bind:show={showCitationModal} {id} {citations} {showPercentage} {showRelevance} /> <CitationsModal
bind:this={citationModal}
bind:show={showCitationModal}
{id}
{citations}
{showPercentage}
{showRelevance}
/>
{#if citations.length > 0} {#if citations.length > 0}
{@const urlCitations = citations.filter((c) => c?.source?.name?.startsWith('http'))} {@const urlCitations = citations.filter((c) => c?.source?.name?.startsWith('http'))}

View file

@ -5,6 +5,7 @@
import Modal from '$lib/components/common/Modal.svelte'; import Modal from '$lib/components/common/Modal.svelte';
import XMark from '$lib/components/icons/XMark.svelte'; import XMark from '$lib/components/icons/XMark.svelte';
import CitationModal from './CitationModal.svelte';
export let id = ''; export let id = '';
export let show = false; export let show = false;
@ -12,6 +13,14 @@
export let showPercentage = false; export let showPercentage = false;
export let showRelevance = true; export let showRelevance = true;
let showCitationModal = false;
let selectedCitation: any = null;
export const showCitation = (citation) => {
selectedCitation = citation;
showCitationModal = true;
};
const decodeString = (str: string) => { const decodeString = (str: string) => {
try { try {
return decodeURIComponent(str); return decodeURIComponent(str);
@ -21,6 +30,13 @@
}; };
</script> </script>
<CitationModal
bind:show={showCitationModal}
citation={selectedCitation}
{showPercentage}
{showRelevance}
/>
<Modal size="lg" bind:show> <Modal size="lg" bind:show>
<div> <div>
<div class=" flex justify-between dark:text-gray-300 px-5 pt-4 pb-2"> <div class=" flex justify-between dark:text-gray-300 px-5 pt-4 pb-2">