mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-02 02:12:25 +00:00
fix: include pasted images when exporting a note as PDF (#30975)
This commit is contained in:
parent
9630717680
commit
0663009694
1 changed files with 9 additions and 0 deletions
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue