Fix blank editor on book open and add home delete + auto-folder new book
- Auto-select the first chapter when a book opens so the editor is no longer left on the placeholder (was the main `all I see is the title` symptom). - Stop markdownToNative from emitting text nodes with empty content and defensively strip them in setEditorDoc; ProseMirror rejects such nodes, which made editor.commands.setContent silently empty the whole editor. - Home screen: delete a book (sent to trash, recoverable) and create a new book in a folder named after it under ~/Documents. - Add self-test coverage for new book + delete.
This commit is contained in:
parent
80898c2e2a
commit
5ac7cdb593
9 changed files with 184 additions and 41 deletions
|
|
@ -92,10 +92,10 @@
|
|||
|
||||
// Manual save: typing marks the chapter Unsaved; the Save button (or
|
||||
// Ctrl/Cmd+S) is required to persist. No auto-save should occur.
|
||||
const ed = window.__folioEditor;
|
||||
if (ed) {
|
||||
ed.commands.focus("end");
|
||||
ed.commands.insertContent(" manual-save-check");
|
||||
const edSave = window.__folioEditor;
|
||||
if (edSave) {
|
||||
edSave.commands.focus("end");
|
||||
edSave.commands.insertContent(" manual-save-check");
|
||||
await sleep(150);
|
||||
const unsaved = document.getElementById("saveState");
|
||||
step("afterTypeUnsaved", unsaved ? unsaved.textContent : "n/a");
|
||||
|
|
@ -170,6 +170,18 @@
|
|||
}
|
||||
step("exports", ex);
|
||||
|
||||
// New book auto-creates a folder inside Documents; then delete it.
|
||||
const nb = await api.newBookNamed("Folio Selftest Temp");
|
||||
step("newBookNamed", {
|
||||
ok: !!(nb && nb.path && nb.title),
|
||||
path: nb && nb.path,
|
||||
title: nb && nb.title,
|
||||
});
|
||||
if (nb && nb.path) {
|
||||
const del = await api.deleteBook(nb.path);
|
||||
step("deleteBook", del && del.ok ? "ok" : del && del.error);
|
||||
}
|
||||
|
||||
out.ok = true;
|
||||
} catch (e) {
|
||||
out.error = String((e && e.stack) || e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue