Commit graph

36 commits

Author SHA1 Message Date
avi
b80aa798b2 fix(backup): exclude snapshots from recovery copy, harden change walk
Migration recovery backups no longer re-copy Folio-Backups (up to 21x bloat). bookChangedSince tracks visited dev:ino so a symlink loop in the book cannot wedge the main-process interval tick. Snapshot toggle check aligned to === false; drop dead home-shortening branch in Settings.
2026-09-19 17:20:31 -05:00
avi
542a545c0d feat: spellcheck menu, typewriter mode, file associations, updater hardening
English spellcheck suggestions with Add-to-dictionary in the native context menu plus a Settings toggle. Typewriter caret-centering mode. OS file associations for .md/.txt and Open File wording. Updater: release URL surfaced, single progress listener, two-byte tarball check, installer wait guard. Search/installer test suites registered; chapter-list layout polish; ignore KDE .directory files.
2026-09-19 16:38:17 -05:00
avi
1413e73015 feat(backup): autosave backend, continuous snapshots, and Settings modal
Background autosave toggle plus whole-book snapshots (default <book>/Folio-Backups, configurable location, retention, interval) with a one-minute change check in the main process. New Settings modal (sidebar, Ctrl+, , File menu) exposes autosave, snapshots, folder picker, and Snapshot now.
2026-09-19 16:37:56 -05:00
avi
ada5eee679 feat: open Markdown files and in-app updater
Markdown:
- File > Open Markdown File... and welcome-screen 'Open .md' import
  one or more .md files as new books (named after first H1 or the
  filename; originals never modified, collision-safe folder names).
- Book dirs and .md files passed on the command line or via desktop
  file associations now open directly; single-instance lock forwards
  second launches to the running window.

Updates:
- File > Check for Updates... and welcome-screen 'Update' button:
  queries the Gitea releases API, one-click installs a newer release
  into ~/.local/share/Folio via a detached swap script that waits for
  app exit, keeps the old tree until the swap succeeds, and relaunches.
  Download is gzip-verified and restricted to the trusted release host.
  No root, no reinstall.

Tests: 19 new assertions in tests/run-update-import-test.mjs (wired
into npm test); full suite green, tsc clean.
2026-09-19 00:02:58 -05:00
avi
43a03272bf refactor(tests): centralize test harness boilerplate into bundle.mjs helper 2026-08-24 21:15:06 -05:00
avi
b74cfe98ab Add Neon and Meridian glass themes, bundled fonts, configurable recovery backup location, autosave and UI polish 2026-08-24 18:58:16 -05:00
avi
aaa491424d Add Undo for book and chapter deletions
- Show an Undo toast after deleting a book from Home; Undo restores the
  folder from the system trash (XDG .trashinfo, URL-decoded path match).
- Chapter delete/cut now snapshots the chapter (title, color, content,
  position) and offers Undo to restore it in place.
- Add reusable showUndoToast/hideUndoToast and #undoToast UI + styles;
  expose restoreBook/restoreChapter over the preload bridge.
- Drop the now-redundant 'cannot be undone' confirm on chapter delete and
  the inaccurate 'permanently removes' wording on book delete.
2026-08-20 18:12:33 -05:00
avi
5ac7cdb593 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.
2026-08-20 17:35:13 -05:00
avi
aad1a9332a Add in-app search across chapters and switch to manual save
- Search: a 'Search' button in the sidebar footer (or Ctrl/Cmd+F) opens a
  modal that scans every chapter, lists matches grouped by chapter with
  highlighted snippets, and jumps to and scrolls the match on click. Includes
  a 'Match case' toggle.
- Manual save: remove the per-keystroke auto-save; a chapter is only persisted
  via the new Save button or Ctrl/Cmd+S. Switching chapters or closing the book
  with unsaved edits now prompts to save first.
- Extend the packaged self-test to exercise both features.
2026-08-20 15:35:28 -05:00
avi
beaf8715d8 Add whole-book vs selected-chapters export workflow
- Export menu (PDF/DOCX/ODT) opens a workflow to export the entire book or
  only selected chapters, with a canonical-order checklist + Select/Clear All
- Selected exports pass an ordered chapter list through the shared pipeline so
  output follows book order (not click order); empty selection is rejected
- Filenames use a ' - Selected Chapters' suffix for partial exports
- PDF renders only the chosen chapters into the print container; DOCX/ODT build
  from the selected chapters in order
2026-08-20 12:20:23 -05:00
avi
7037cd9fc0 Improve the export pipeline (shared ordering + chapter page breaks)
- buildDocx/buildOdt now accept an explicit ordered chapter list, making that
  list the single source of truth for export ordering (defaults to whole book)
- Emit real page breaks between chapters in DOCX, with none before the first
- Unify the DOCX/ODT handlers into one exportOffice pipeline (ODT still built
  from the same DOCX via LibreOffice)
2026-08-20 11:44:54 -05:00
avi
946a2967db Add chapter color customization
- Store an optional accent color on each ChapterEntry so it persists with the
  chapter across switching, reordering, close/reopen, and restart
- Add a per-row color button that opens a palette popover (assign / change /
  remove) and shows a small color dot in the sidebar, readable in Light/Dark
- Expose setChapterColor through the main/preload IPC bridge
2026-08-20 11:21:14 -05:00
avi
786a65ae2a Replace markdown editor with native Tiptap editor and add Home navigation
- Migrate renderer from md-editor/md-format to a Tiptap-based native editor
  (native-doc pipeline: native-doc, markdown-to-native, native-to-markdown,
  native-assembly, migration, backup)
- Use pointer-event-based chapter reordering with grab/grabbing cursors to
  avoid the Wayland prohibited-drop cursor while preserving reordering
- Add a persistent Home button that closes the open book and returns to the
  Folio library/welcome screen
- Update app icons, package deps, theme styles, and tests
2026-08-20 11:12:17 -05:00
avi
0df26d4ce6 Match the editor's spacing in PDF/DOCX/ODT and fix the toolbar dropdown
Exports now use the same typography as the Full Book editor — Georgia
serif at 12pt, 1.7 line spacing, and a blank-line gap between paragraphs -
so the on-screen editor and every exported format look consistent. DOCX/
ODT also gain a chapter break before each chapter after the first.
2026-08-18 18:39:21 -05:00
avi
247f16baa5 Add a built-in Light theme
Replaces the old Default theme (which followed the OS color scheme) with a
fixed warm, writing-focused Light theme: off-white editor surface, charcoal
text, subtle warm-gray borders, and a restrained deep teal-green accent. The
selector now offers Light and Neonflux. Old saves storing "default" are
migrated to "light" in both the renderer and the main process, and the e2e
scenario now covers Light + Neonflux application, light/dark checks, theme
round-trips, and content preservation.
2026-08-18 17:15:10 -05:00
avi
6679294231 Add DOCX and ODT export for the Full Book view
The main process now assembles the manuscript from the chapter files and
renders it to a Word document with the docx library, using the same
markdown-it plugin set as the on-screen renderer (highlight, callouts,
wikilinks). ODT is converted from that DOCX with LibreOffice running
headless, keeping the two formats consistent; a clear error is returned
when LibreOffice is missing. The Full Book header's single Export PDF
button becomes an Export menu (PDF/DOCX/ODT) wired to the File menu.

Tests: new run-office-export-test.mjs verifies DOCX/ODT structure,
chapter order and formatting; the e2e scenario exports through the real
IPC chain and checks magic bytes, extensions and the status notices.
2026-08-18 17:06:32 -05:00
avi
ad0329bbf9 Add a reusable theme system with a Neonflux theme
Introduce a theme layer on top of the existing CSS custom properties.
All color tokens now live in themes.css, scoped by a data-theme
attribute on <html>, so a theme is just a new token block plus a
dropdown option - no code changes needed. The Default theme preserves
the existing light/dark behavior; Neonflux adds an electric-cyan dark
theme.

The active theme is chosen via a Theme selector in the sidebar footer
and persisted in a new main-process settings file (userData
settings.json) through getTheme/setTheme IPC, so it survives restarts.
Hard-coded on-accent, selection, shadow and backdrop colors across the
renderer were converted to semantic tokens so every theme stays
consistent.
2026-08-18 12:42:09 -05:00
avi
7011d0655b Add chapter navigation to the Full Book view
Add a chapter dropdown plus Previous/Next buttons to the Full Book
toolbar. The dropdown lists every chapter in canonical order and the
buttons jump between them, scrolling the assembled manuscript so the
target chapter begins near the top of the viewport. Manual scrolling
keeps the dropdown in sync with the chapter currently on screen, and
reordering chapters while Full Book is open re-renders navigation to
match the new order immediately.

Navigation reuses the same chapter boundaries that drive page breaks,
so it can never drift from the assembled chapter order.
2026-08-18 12:40:57 -05:00
avi
d510a48742 Preserve formatting in the exported PDF
The printed book is rendered from the same markdown the editor writes, but
markdown-it escaped HTML and did not understand Folio's extensions, so
underlines, text/highlight colors, alignments, ==highlights==, callouts and
wikilinks all showed up as raw source text in the PDF. Render the print book
with a purpose-built print-format renderer that keeps every feature:
  - html: true so the toolbar's <u>, <span style=...> and <div align=...>
    pass through and render instead of appearing literally,
  - ==highlight== rendered as <mark> (new inline rule),
  - Obsidian callouts (> [!note] Title) rendered as styled divs with a bold
    title (new core rule),
  - wikilinks resolved to links via the shared wikilink plugin.
Add matching print styles for mark, underline and callout types, and e2e
assertions that none of these features leak as raw source into #printBook.
2026-08-18 10:59:28 -05:00
avi
d2118f080f Fix PDF export to always include the full book
The previous export printed the CodeMirror editor, which only keeps a
virtualized window of lines in the DOM; on larger books the PDF could come
out truncated (only what was rendered around the viewport). Replace the
print path with a dedicated #printBook container: the renderer renders each
chapter of the assembled manuscript to plain HTML with markdown-it, and the
print stylesheet hides the entire app and shows that container instead.
Plain HTML paginates reliably regardless of editor viewport or scroll
position, every chapter after the first still starts on its own page, and
output is a properly formatted manuscript instead of raw markdown. Keep the
screen-only chapter-break separator in the Full Book editor.

Extend the e2e selftest to assert #printBook holds every chapter, is hidden
on screen, and that a 1500-line chapter reaches the print DOM and exported
PDF in full.
2026-08-18 10:41:56 -05:00
avi
778b480ea2 Export Full Book as PDF with automatic chapter page breaks
Print the Full Book window via webContents.printToPDF (A4, 1in margins),
reusing the existing print stylesheet so every chapter after the first
starts on its own page and all app chrome is stripped from the output.
Expose it as an Export PDF button in the Full Book header and a File menu
item, save via a native save dialog (self-test writes to FOLIO_TEST_PDF),
and force light-on-white colors in print so dark-mode exports stay readable.
Add e2e coverage that exports through the real renderer->IPC->print chain
and verifies a valid non-empty PDF is written.
2026-08-18 10:11:06 -05:00
avi
ebbb424ee5 Add automatic chapter page breaks to Full Book 2026-08-18 09:05:05 -05:00
avi
424aeab8a1 Fix Full Book view layout so the entire manuscript is scrollable
The Full Book pane had no CSS rule, so it fell back to block layout:
the CodeMirror editor grew to the full manuscript height and was
clipped by the overflow-hidden workspace, leaving the content below
the first screen unreachable and making a multi-chapter book appear
as a single chapter. Give .full-book-view the same flex-column layout
as .chapter-view so the editor is bounded and scrolls internally.

Add an e2e assertion (fbLayoutOk) that checks the computed layout is a
flex column with the editor bounded to the viewport, so this class of
rendering regression is caught in future runs.
2026-08-17 20:17:52 -05:00
avi
6b1a9da5cc Fix Full Book assembly to always render from canonical chapter metadata
Full Book now assembles from a fresh read of the canonical book metadata
(chapter order + chapter entries) instead of the renderer's in-memory
chapter array, so it always contains every chapter in the current order
and can never render from stale or partially-loaded state. The chapter
sidebar and Full Book share the same single source of truth.

Also refresh Full Book whenever book metadata loads, and extend the e2e
scenario to cover reordering to a new order, order persistence across
reopen, and delete/rename/new-empty chapters all being reflected.
2026-08-17 19:33:41 -05:00
avi
46eca18cdf Complete Full Book view: wire Ctrl+A select-all and add e2e coverage
Route the renderer select-all listener (previously sent but never handled) to
the active editor, and extend the e2e scenario to verify the Full Book
assembly, stats, Copy All clipboard content, and read-only select-all.
2026-08-17 18:13:40 -05:00
avi
11dd692ec4 Add Obsidian-like full-featured editor toolbar 2026-08-17 14:34:36 -05:00
avi
45990bbd62 Add strikethrough shortcut, fenced code toggle, and CodeMirror-aware undo/redo
- Bind Ctrl+Shift+S to strikethrough
- Smart code toggle: fenced block for multi-line selections, inline otherwise
- Link editing: selecting an existing link now selects its URL for editing
- Route undo/redo shortcuts through IPC so CodeMirror history is used when
  the editor has focus instead of Electron's native menu-role undo/redo
- Add Indent/Outdent toolbar buttons
2026-08-17 13:02:42 -05:00
avi
c09f4adc30 Add Markdown formatting toolbar and editor shortcuts 2026-08-17 12:28:49 -05:00
avi
1ae9744b2b Replace split textarea/preview editor with a single CodeMirror Markdown editor 2026-08-17 11:15:23 -05:00
avi
17a895dffe Replace unsupported window prompt/confirm/alert with an in-app modal dialog 2026-08-17 11:15:14 -05:00
avi
1d705ac607 Add wikilink support as a markdown-it plugin with unit tests 2026-08-17 11:15:06 -05:00
avi
5dcdec86b9 Stage 6: export book as combined Markdown or ZIP bundle (title page, book.md, chapters/, manifest) with File menu + toolbar entries and export tests 2026-08-17 09:22:41 -05:00
avi
25baae2950 Stage 5: live Markdown editor (source+preview), autosave, word count, find bar, save-state indicator 2026-08-16 14:51:06 -05:00
avi
4b8d78458c Stage 4: drag-and-drop + keyboard chapter reordering (moveInList), chapters-changed broadcast, DnD/keyboard e2e 2026-08-16 14:43:42 -05:00
avi
d3ab261346 Stage 3: chapter management — create/rename/delete/duplicate, sidebar list, select, read-only preview, word count, IPC + tests + e2e self-test 2026-08-16 14:34:34 -05:00
avi
2862c433bd Stage 2: local project creation — folder dialog, folio.json, recents, menu, book open/new/reveal, welcome UI 2026-08-16 14:11:51 -05:00