@@ -16,10 +16,19 @@ import {
1616import type { JSONContent } from '@tiptap/core'
1717import sharp from 'sharp'
1818import { parseServerMarkdownToDoc } from '@/lib/collab-doc/server-markdown'
19- import { embeddedFileRefKey , extractEmbeddedFileRef } from '@/lib/uploads/utils/embedded-image-ref'
19+ import {
20+ type EmbeddedFileRef ,
21+ extractEmbeddedFileRef ,
22+ } from '@/lib/uploads/utils/embedded-image-ref'
2023import { splitFrontmatter } from '@/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/markdown-fidelity'
2124
2225type PdfImage = { data : Buffer ; format : 'png' }
26+ type ResolvedPdfImageRef = Exclude < EmbeddedFileRef , null >
27+
28+ /** PDF-local map key for either embedded workspace-image reference spelling. */
29+ export function markdownPdfImageKey ( ref : ResolvedPdfImageRef ) : string {
30+ return 'key' in ref ? `key:${ ref . key } ` : `id:${ ref . fileId } `
31+ }
2332
2433interface GlyphFont {
2534 hasGlyphForCodePoint ( codePoint : number ) : boolean
@@ -426,7 +435,7 @@ function renderImage(
426435) : ReactNode {
427436 const src = stringAttr ( node , 'src' ) ?? ''
428437 const ref = extractEmbeddedFileRef ( src )
429- const image = ref ? images . get ( embeddedFileRefKey ( ref ) ) : undefined
438+ const image = ref ? images . get ( markdownPdfImageKey ( ref ) ) : undefined
430439 if ( ! image ) {
431440 const alt = stringAttr ( node , 'alt' )
432441 return (
0 commit comments