fix images

This commit is contained in:
Stefan Hardegger
2025-10-20 12:30:28 +02:00
parent c9d58173f3
commit 6a38189ef0
4 changed files with 106 additions and 3 deletions

View File

@@ -114,9 +114,10 @@ const htmlToSlate = (html: string): Descendant[] => {
const img = element as HTMLImageElement;
results.push({
type: 'image',
src: img.src || img.getAttribute('src') || '',
alt: img.alt || img.getAttribute('alt') || '',
caption: img.title || img.getAttribute('title') || '',
// Use getAttribute to preserve relative URLs instead of .src which converts to absolute
src: img.getAttribute('src') || '',
alt: img.getAttribute('alt') || '',
caption: img.getAttribute('title') || '',
children: [{ text: '' }] // Images need children in Slate
});
break;