Stage 5: live Markdown editor (source+preview), autosave, word count, find bar, save-state indicator

This commit is contained in:
avi 2026-08-16 14:51:06 -05:00
commit 25baae2950
9 changed files with 390 additions and 6 deletions

View file

@ -38,6 +38,7 @@ const {
deleteChapter,
duplicateChapter,
reorderChapters,
setChapterContent,
moveInOrder,
} = chapters;
@ -83,6 +84,13 @@ ok(dup.id !== c1.id, "duplicate has new id");
ok(getChapterContent(dir, dup.id) === "Hello world this is text", "duplicate copies content");
ok(loadBook(dir).chapterOrder.slice(-1)[0] === dup.id, "duplicate appended to order");
// setChapterContent writes markdown to disk by chapter id
setChapterContent(dir, c1.id, "# Introduction\n\nWelcome.");
ok(getChapterContent(dir, c1.id) === "# Introduction\n\nWelcome.", "setChapterContent persists markdown");
let threw2 = false;
try { setChapterContent(dir, "nope", "x"); } catch { threw2 = true; }
ok(threw2, "setChapterContent throws on unknown id");
// delete
const c3File = path.join(dir, c3.file);
deleteChapter(dir, c3.id);