diff --git a/src/lib/components/notes/utils.ts b/src/lib/components/notes/utils.ts index 8c6bd35242..6a3739740d 100644 --- a/src/lib/components/notes/utils.ts +++ b/src/lib/components/notes/utils.ts @@ -2,6 +2,7 @@ import DOMPurify from 'dompurify'; import { toast } from 'svelte-sonner'; import { createNewNote } from '$lib/apis/notes'; +import { safeImageUrl } from '$lib/utils/safeImageUrl'; export const downloadPdf = async (note) => { const [{ default: jsPDF }, { default: html2canvas }] = await Promise.all([ @@ -39,6 +40,14 @@ export const downloadPdf = async (note) => { contentNode.innerHTML = html; + for (const img of contentNode.querySelectorAll('img[src^="data://"]')) { + const fileId = img.getAttribute('src').replace('data://', ''); + const file = (note.data?.files ?? []).find((f) => f.id === fileId); + if (file) { + img.setAttribute('src', safeImageUrl(file.url || '')); + } + } + node.appendChild(contentNode); node.classList.add('text-black');