fix: keep note drafts across mode toggle and external note publishes

Flush ref-only content before edit/preview remount, and skip prop→editor
setMarkdown while a local draft diverges from the last synced value.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
This commit is contained in:
Cursor Agentand陈大猫 committed 2026-08-07 14:38:00 +00:00
1 parent 4569e6aa95
commit 80d49e5d9f
3 files changed
+39 -4

No files matched your search

+8 -3
View File
@@ -679,9 +679,14 @@ export const NotesManager: React.FC<NotesManagerProps> = ({
data-note-mode-switch
aria-label={label}
className="app-no-drag h-8 w-8 shrink-0 rounded-md p-0 text-muted-foreground transition-colors hover:bg-secondary/70 hover:text-foreground"
onClick={() => setNoteEditorMode((currentMode) => (
currentMode === "edit" ? "preview" : "edit"
))}
onClick={() => {
// Flush ref-only content drafts before remounting MDX on mode
// toggle so preview/edit sees the in-progress body.
flushNoteDraft();
setNoteEditorMode((currentMode) => (
currentMode === "edit" ? "preview" : "edit"
));
}}
>
<Icon size={16} />
</Button>