fix: include pasted images when exporting a note as PDF (#30975)

This commit is contained in:
G30 2026-09-25 00:15:12 -04:00 • committed by GitHub
parent 9630717680
commit 0663009694
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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');