mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-24 07:45:57 +02:00
Fix editor not rendering on every other source mode switch
This commit is contained in:
@@ -78,6 +78,7 @@
|
|||||||
let fixingBlobsPromise: Promise<void> = Promise.resolve();
|
let fixingBlobsPromise: Promise<void> = Promise.resolve();
|
||||||
let hasPendingBlobs = false;
|
let hasPendingBlobs = false;
|
||||||
let lastSourceMode = $sourceMode;
|
let lastSourceMode = $sourceMode;
|
||||||
|
let sourceSwapPending = false;
|
||||||
let linkContextMenu = $state<{ x: number; y: number; href: string; anchor: HTMLAnchorElement } | null>(null);
|
let linkContextMenu = $state<{ x: number; y: number; href: string; anchor: HTMLAnchorElement } | null>(null);
|
||||||
let titleWasStripped = false;
|
let titleWasStripped = false;
|
||||||
let strippedTitle = '';
|
let strippedTitle = '';
|
||||||
@@ -3327,7 +3328,7 @@
|
|||||||
// When editorElement appears in DOM, initialize TipTap.
|
// When editorElement appears in DOM, initialize TipTap.
|
||||||
// On mobile, pre-create editor with empty content so first note load is fast.
|
// On mobile, pre-create editor with empty content so first note load is fast.
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (editorElement && !editor) {
|
if (editorElement && !editor && !sourceSwapPending) {
|
||||||
if (pendingContent !== null) {
|
if (pendingContent !== null) {
|
||||||
createEditor(pendingContent);
|
createEditor(pendingContent);
|
||||||
pendingContent = null;
|
pendingContent = null;
|
||||||
@@ -4640,12 +4641,14 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Desktop: destroy old editor, wait for DOM swap, then recreate.
|
// Desktop: destroy old editor, wait for DOM swap, then recreate.
|
||||||
|
sourceSwapPending = true;
|
||||||
destroyEditor();
|
destroyEditor();
|
||||||
const content = sourceContent || ($activeNote?.content ?? '');
|
const content = sourceContent || ($activeNote?.content ?? '');
|
||||||
tick().then(() => {
|
tick().then(() => {
|
||||||
if (editorElement && !editor) {
|
if (editorElement && !editor) {
|
||||||
createEditor(content);
|
createEditor(content);
|
||||||
}
|
}
|
||||||
|
sourceSwapPending = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user