mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 15:41:17 +00:00
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:
3 files changed
+39
-4
No files matched your search
@@ -68,6 +68,14 @@ test("notes manager prefetches the MDXEditor chunk when becoming active", () =>
|
||||
);
|
||||
});
|
||||
|
||||
test("mode toggle flushes ref-only content drafts before remounting the editor", () => {
|
||||
assert.match(
|
||||
managerSource,
|
||||
/flushNoteDraft\(\);\s*\n\s*setNoteEditorMode/,
|
||||
"preview/edit remount must see the in-progress body",
|
||||
);
|
||||
});
|
||||
|
||||
test("host-link annotation does not re-run on every markdown value keystroke", () => {
|
||||
const editorSource = readFileSync(
|
||||
new URL("./InlineMarkdownEditor.tsx", import.meta.url),
|
||||
@@ -79,4 +87,13 @@ test("host-link annotation does not re-run on every markdown value keystroke", (
|
||||
"value in annotateHostLinks effect deps walks the DOM on every keystroke",
|
||||
);
|
||||
assert.match(editorSource, /\[annotateHostLinks, editorMode\]/);
|
||||
assert.match(
|
||||
editorSource,
|
||||
/syncedPropValueRef/,
|
||||
"external note publishes must not clobber an in-progress local draft",
|
||||
);
|
||||
assert.match(
|
||||
editorSource,
|
||||
/latestMarkdownRef\.current !== syncedPropValueRef\.current/,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user