Merge pull request #5632 from jannikstdl/dev

enh: open PDF citations on the associated page
This commit is contained in:
Timothy Jaeryang Baek 2024-09-24 11:27:53 +02:00 committed by GitHub
commit deedfdceae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 15 deletions

View File

@ -1,6 +1,7 @@
<script lang="ts">
import { getContext, onMount, tick } from 'svelte';
import Modal from '$lib/components/common/Modal.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
const i18n = getContext('i18n');
export let show = false;
@ -55,19 +56,28 @@
</div>
{#if document.source?.name}
<div class="text-sm dark:text-gray-400">
<a
href={document?.metadata?.file_id
? `/api/v1/files/${document?.metadata?.file_id}/content`
: document.source.name.includes('http')
? document.source.name
: `#`}
target="_blank"
>
{document?.metadata?.name ?? document.source.name}
</a>
{document?.metadata?.page ? `(page ${document.metadata.page + 1})` : ''}
</div>
<Tooltip
content={$i18n.t('Open file')}
placement="left"
tippyOptions={{ duration: [500, 0], animation: 'perspective' }}
>
<div class="text-sm dark:text-gray-400">
<a
class="hover:text-gray-500 hover:dark:text-gray-100 underline"
href={document?.metadata?.file_id
? `/api/v1/files/${document?.metadata?.file_id}/content${document?.metadata?.page !== undefined ? `#page=${document.metadata.page + 1}` : ''}`
: document.source.name.includes('http')
? document.source.name
: `#`}
target="_blank"
>
{document?.metadata?.name ?? document.source.name}
</a>
{document?.metadata?.page
? `(${$i18n.t('page')} ${document.metadata.page + 1})`
: ''}
</div>
</Tooltip>
{:else}
<div class="text-sm dark:text-gray-400">
{$i18n.t('No source available')}

View File

@ -13,6 +13,7 @@
export let className = 'flex';
export let theme = '';
export let allowHTML = true;
export let tippyOptions = {};
let tooltipElement;
let tooltipInstance;
@ -28,7 +29,8 @@
touch: touch,
...(theme !== '' ? { theme } : { theme: 'dark' }),
arrow: false,
offset: [0, 4]
offset: [0, 4],
...tippyOptions
});
}
} else if (tooltipInstance && content === '') {

View File

@ -754,5 +754,7 @@
"Your account status is currently pending activation.": "Ihr Kontostatus ist derzeit ausstehend und wartet auf Aktivierung.",
"Your entire contribution will go directly to the plugin developer; Open WebUI does not take any percentage. However, the chosen funding platform might have its own fees.": "",
"Youtube": "YouTube",
"Youtube Loader Settings": "YouTube-Ladeeinstellungen"
"Youtube Loader Settings": "YouTube-Ladeeinstellungen",
"page": "Seite",
"Open file": "Datei öffnen"
}