fix: source citations user message display issue

This commit is contained in:
Timothy Jaeryang Baek 2025-12-07 23:53:46 -05:00
parent 4d4ed743ae
commit 3c8f1cf8e5
2 changed files with 43 additions and 38 deletions

View file

@ -75,12 +75,11 @@
`<sup class="footnote-ref footnote-ref-text">${token.escapedText}</sup>` `<sup class="footnote-ref footnote-ref-text">${token.escapedText}</sup>`
) || ''} ) || ''}
{:else if token.type === 'citation'} {:else if token.type === 'citation'}
<SourceToken {id} {token} {sourceIds} onClick={onSourceClick} /> {#if (sourceIds ?? []).length > 0}
<!-- {#if token.ids && token.ids.length > 0} <SourceToken {id} {token} {sourceIds} onClick={onSourceClick} />
{#each token.ids as sourceId} {:else}
<Source id={sourceId - 1} title={sourceIds[sourceId - 1]} onClick={onSourceClick} /> <TextToken {token} {done} />
{/each} {/if}
{/if} -->
{:else if token.type === 'text'} {:else if token.type === 'text'}
<TextToken {token} {done} /> <TextToken {token} {done} />
{/if} {/if}

View file

@ -39,37 +39,43 @@
}; };
</script> </script>
{#if (token?.ids ?? []).length == 1} {sourceIds}
<Source id={token.ids[0] - 1} title={sourceIds[token.ids[0] - 1]} {onClick} />
{:else} {#if sourceIds}
<LinkPreview.Root openDelay={0} bind:open={openPreview}> {#if (token?.ids ?? []).length == 1}
<LinkPreview.Trigger> <Source id={token.ids[0] - 1} title={sourceIds[token.ids[0] - 1]} {onClick} />
<button {:else}
class="text-[10px] w-fit translate-y-[2px] px-2 py-0.5 dark:bg-white/5 dark:text-white/80 dark:hover:text-white bg-gray-50 text-black/80 hover:text-black transition rounded-xl" <LinkPreview.Root openDelay={0} bind:open={openPreview}>
on:click={() => { <LinkPreview.Trigger>
openPreview = !openPreview; <button
}} class="text-[10px] w-fit translate-y-[2px] px-2 py-0.5 dark:bg-white/5 dark:text-white/80 dark:hover:text-white bg-gray-50 text-black/80 hover:text-black transition rounded-xl"
on:click={() => {
openPreview = !openPreview;
}}
>
<span class="line-clamp-1">
{getDisplayTitle(formattedTitle(decodeString(sourceIds[token.ids[0] - 1])))}
<span class="dark:text-white/50 text-black/50">+{(token?.ids ?? []).length - 1}</span>
</span>
</button>
</LinkPreview.Trigger>
<LinkPreview.Content
class="z-[999]"
align="start"
strategy="fixed"
sideOffset={6}
el={containerElement}
> >
<span class="line-clamp-1"> <div class="bg-gray-50 dark:bg-gray-850 rounded-xl p-1 cursor-pointer">
{getDisplayTitle(formattedTitle(decodeString(sourceIds[token.ids[0] - 1])))} {#each token.ids as sourceId}
<span class="dark:text-white/50 text-black/50">+{(token?.ids ?? []).length - 1}</span> <div class="">
</span> <Source id={sourceId - 1} title={sourceIds[sourceId - 1]} {onClick} />
</button> </div>
</LinkPreview.Trigger> {/each}
<LinkPreview.Content </div>
class="z-[999]" </LinkPreview.Content>
align="start" </LinkPreview.Root>
strategy="fixed" {/if}
sideOffset={6} {:else}
el={containerElement} <span>{token.raw}</span>
>
<div class="bg-gray-50 dark:bg-gray-850 rounded-xl p-1 cursor-pointer">
{#each token.ids as sourceId}
<div class="">
<Source id={sourceId - 1} title={sourceIds[sourceId - 1]} {onClick} />
</div>
{/each}
</div>
</LinkPreview.Content>
</LinkPreview.Root>
{/if} {/if}