Commit 88086935 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

feat: markdown image preview

parent ace3552e
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
export let copyToClipboard: Function; export let copyToClipboard: Function;
export let continueGeneration: Function; export let continueGeneration: Function;
export let regenerateResponse: Function; export let regenerateResponse: Function;
export let chatActionHandler: Function;
let model = null; let model = null;
$: model = $models.find((m) => m.id === message.model); $: model = $models.find((m) => m.id === message.model);
...@@ -528,6 +527,28 @@ ...@@ -528,6 +527,28 @@
code={revertSanitizedResponseContent(token?.text ?? '')} code={revertSanitizedResponseContent(token?.text ?? '')}
/> />
{/if} {/if}
{:else if token.type === 'paragraph'}
{#if token.tokens}
{#each token.tokens as inlineToken}
{#if inlineToken.type === 'image'}
<Image src={inlineToken.href} alt={inlineToken.text} />
{:else}
{@html marked.parseInline(inlineToken.raw, {
...defaults,
gfm: true,
breaks: true,
renderer
})}
{/if}
{/each}
{:else}
{@html marked.parseInline(token.raw, {
...defaults,
gfm: true,
breaks: true,
renderer
})}
{/if}
{:else} {:else}
{@html marked.parse(token.raw, { {@html marked.parse(token.raw, {
...defaults, ...defaults,
......
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
</script> </script>
<ImagePreview bind:show={showImagePreview} src={_src} {alt} /> <ImagePreview bind:show={showImagePreview} src={_src} {alt} />
<button
on:click={() => { <div class="w-full">
console.log('image preview'); <button
showImagePreview = true; on:click={() => {
}} showImagePreview = true;
> }}
<img src={_src} {alt} class=" max-h-96 rounded-lg" draggable="false" data-cy="image" /> >
</button> <img src={_src} {alt} class=" max-h-96 rounded-lg" draggable="false" data-cy="image" />
</button>
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment