mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-24 07:45:57 +02:00
Fix images not rendering when switching back from source mode
This commit is contained in:
@@ -4634,24 +4634,23 @@
|
|||||||
}
|
}
|
||||||
} else if (!isSource && lastSourceMode) {
|
} else if (!isSource && lastSourceMode) {
|
||||||
lastSourceMode = false;
|
lastSourceMode = false;
|
||||||
// Both desktop and mobile: keep editor alive, just update content.
|
|
||||||
// Destroying/recreating the editor on desktop caused images not to
|
|
||||||
// render on the first switch back from source mode.
|
|
||||||
const content = sourceContent || ($activeNote?.content ?? '');
|
const content = sourceContent || ($activeNote?.content ?? '');
|
||||||
if (editor) {
|
// Wait for Svelte to toggle display back to the editor element,
|
||||||
ignoreNextUpdate = true;
|
// then update content. The editor stays alive (no destroy/recreate).
|
||||||
editor.commands.setContent(markdownToHtml(content));
|
tick().then(() => {
|
||||||
// Force a re-render of images that may not load after setContent
|
if (editor) {
|
||||||
requestAnimationFrame(() => {
|
ignoreNextUpdate = true;
|
||||||
if (!editor) return;
|
editor.commands.setContent(markdownToHtml(content));
|
||||||
editor.view.dom.querySelectorAll('img').forEach((img) => {
|
// Force image re-render for WebViews that don't trigger loads on setContent
|
||||||
const src = img.getAttribute('src');
|
requestAnimationFrame(() => {
|
||||||
if (src) {
|
if (!editor) return;
|
||||||
img.setAttribute('src', src);
|
editor.view.dom.querySelectorAll('img').forEach((img) => {
|
||||||
}
|
const src = img.getAttribute('src');
|
||||||
|
if (src) img.setAttribute('src', src);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user