mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-24 07:45:57 +02:00
Fix pasted images disappearing when switching to source mode (#87)
This commit is contained in:
@@ -4634,23 +4634,23 @@
|
|||||||
}
|
}
|
||||||
} else if (!isSource && lastSourceMode) {
|
} else if (!isSource && lastSourceMode) {
|
||||||
lastSourceMode = false;
|
lastSourceMode = false;
|
||||||
const content = sourceContent || ($activeNote?.content ?? '');
|
if (isMobile) {
|
||||||
// Wait for Svelte to toggle display back to the editor element,
|
// Mobile: editor stays in DOM, just update its content
|
||||||
// then update content. The editor stays alive (no destroy/recreate).
|
const content = sourceContent || ($activeNote?.content ?? '');
|
||||||
tick().then(() => {
|
|
||||||
if (editor) {
|
if (editor) {
|
||||||
ignoreNextUpdate = true;
|
ignoreNextUpdate = true;
|
||||||
editor.commands.setContent(markdownToHtml(content));
|
editor.commands.setContent(markdownToHtml(content));
|
||||||
// Force image re-render for WebViews that don't trigger loads on setContent
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
if (!editor) return;
|
|
||||||
editor.view.dom.querySelectorAll('img').forEach((img) => {
|
|
||||||
const src = img.getAttribute('src');
|
|
||||||
if (src) img.setAttribute('src', src);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
// Desktop: destroy old editor, wait for DOM swap, then recreate.
|
||||||
|
destroyEditor();
|
||||||
|
const content = sourceContent || ($activeNote?.content ?? '');
|
||||||
|
tick().then(() => {
|
||||||
|
if (editorElement && !editor) {
|
||||||
|
createEditor(content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user