From 1681fade3bc541809620a9825357f22364889a2c Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Fri, 19 Jun 2026 11:38:40 +0200 Subject: [PATCH] Fix editor not rendering on every other source mode switch --- src/lib/components/Editor.svelte | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index ce8ecc2..d4a5bf4 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -4617,19 +4617,10 @@ if (!loadedPath) return; if (isSource && !lastSourceMode) { - // Switching TO source: fix blob images first, then extract markdown - if (hasPendingBlobs) { - hasPendingBlobs = false; - fixBlobImages().then(() => { - sourceContent = editor ? editorToMarkdown() : ($activeNote?.content ?? ''); - resetSourceHistory(sourceContent); - lastSourceMode = true; - }); - } else { - sourceContent = editor ? editorToMarkdown() : ($activeNote?.content ?? ''); - resetSourceHistory(sourceContent); - lastSourceMode = true; - } + // Switching TO source: extract markdown from editor + sourceContent = editor ? editorToMarkdown() : ($activeNote?.content ?? ''); + resetSourceHistory(sourceContent); + lastSourceMode = true; } else if (!isSource && lastSourceMode) { lastSourceMode = false; if (isMobile) { @@ -4646,6 +4637,11 @@ tick().then(() => { if (editorElement && !editor) { createEditor(content); + } else if (!editor) { + // editorElement not ready yet — retry next frame + requestAnimationFrame(() => { + if (editorElement && !editor) createEditor(content); + }); } }); }