From a1913558b99a0fd2dc34ec3af6072ae3e78acb30 Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Fri, 19 Jun 2026 11:18:06 +0200 Subject: [PATCH] Fix pasted images disappearing when switching to source mode (#87) --- src/lib/components/Editor.svelte | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 627d6e9..70dd49a 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -4617,10 +4617,21 @@ if (!loadedPath) return; if (isSource && !lastSourceMode) { - // Switching TO source: extract markdown from editor - sourceContent = editor ? editorToMarkdown() : ($activeNote?.content ?? ''); - resetSourceHistory(sourceContent); - lastSourceMode = true; + // Switching TO source: fix blob images first, then extract markdown + if (hasPendingBlobs) { + hasPendingBlobs = false; + fixingBlobsPromise = fixBlobImages(); + } + const doSwap = () => { + sourceContent = editor ? editorToMarkdown() : ($activeNote?.content ?? ''); + resetSourceHistory(sourceContent); + lastSourceMode = true; + }; + if (fixingBlobsPromise) { + fixingBlobsPromise.then(doSwap); + } else { + doSwap(); + } } else if (!isSource && lastSourceMode) { lastSourceMode = false; if (isMobile) {