Skip to content

feat(publication): foundation for multi-file publication workflow - #443

Open
ateto3 wants to merge 7 commits into
petertzy:mainfrom
ateto3:feat/publicaton-preparation
Open

ateto3 wants to merge 7 commits into
petertzy:mainfrom
ateto3:feat/publicaton-preparation

Conversation

@ateto3

@ateto3 ateto3 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Summary

First architectural step toward #359: a deterministic “prepare publication” flow that combines multiple Markdown files into a single structured draft and generates a table of contents. AI-assisted editing and final export are intentionally out of scope for this PR — this establishes the pipeline and UI entry point.

Changes

  • Backend: new POST /api/markdown/publication/prepare endpoint that accepts an ordered list of files and returns combined, toc, and file_count. Reuses the existing _extract_outline helper for heading extraction (ATX, Setext, fenced-code aware).
  • API client: typed Markdown.preparePublication wrapper routed through the shared authenticated backend proxy (proxy_backend_request), matching the existing Markdown.wordCount pattern.
  • UI: new PublicationPanel lets the user select open tabs, reorder them, and preview the combined draft + generated TOC. Toggle button added to the toolbar via the existing PANELS mechanism.
  • Tests: pure preparePublication helper covered with the repo's node --test runner (mocked shared API, empty-selection rejection).
  • Docs: README feature bullet.

Not included (future PRs)

  • AI-assisted chapter ordering / structure normalization
  • Final PDF/EPUB export
  • Asset (image/footnote) handling
  • Non-destructive source guarantees (only reads content)

How to test

  1. Start backend + frontend.
  2. Open two or more Markdown files as tabs.
  3. Click Publication in the toolbar.
  4. Check the files, reorder them with ↑ / ↓.
  5. Click Preview publication — verify the TOC and combined Markdown are shown.

Checklist

  • Reuses existing _extract_outline logic
  • Uses shared proxy_backend_request transport (no raw fetch)
  • No new dependencies
  • node --test compatible
  • Source files are not modified

Refs #359

@petertzy

Copy link
Copy Markdown
Owner

@ateto3, CI/Frontend check failed. Please resolve this issue before we can preview your PR. Thank you.

@ateto3

ateto3 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Lint / CI fixes

The Frontend lint job was failing after the merge with main. All issues are resolved in the latest push:

page.tsx

  • Added missing DocumentStats import — 'DocumentStats' is not defined at the render site. It now imports from @/components/DocumentStats and renders above StatusBar with the active tab content.
  • Wired Toolbar.onOpenProject to the existing openProject callback in page.tsx (previously pointed at a non-existent fileIO.handleOpenProject).
  • Restored showPreview as a constant (const showPreview = true) — the state setter was flagged as unused and the variable had been lost during the merge.
  • Removed duplicate projectRoot local state — it already comes from useProjectWorkspace(), so setProjectRoot was dead code.
  • Removed unused ProjectExplorer import left over from an earlier draft (the component is rendered via PANELS.EXPLORER and uses projectRoot, not the projectWork object).
  • Updated AIPanel props for the merged interface: now passes documentId={editor.activeTab.id}, projectRoot, and projectWork.
  • Updated ProjectExplorer props to rootPath={projectRoot ?? ""} (string) instead of the projectWork object, matching the merged ProjectExplorerProps.
  • Integrated PublicationPanel via PANELS.PUBLICATION with tabs={editor.tabs} and onClose={() => togglePanel(PANELS.PUBLICATION)}.

DocumentStats.tsx

  • Uses the shared authenticated client (Markdown.wordCount via proxy_backend_request) instead of a raw fetch("/api/markdown/wordcount").
  • WordCountResult extended with heading_count to match the backend response.

@petertzy

Copy link
Copy Markdown
Owner

@ateto3, I noticed that all the checks passed yesterday, but today the frontend check is failing again. Please see the screenshot below for details and try to fix the issue. Thank you!
Bildschirmfoto 2026-10-21 um 09 26 28

@ateto3

ateto3 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author
image All verifications passed

@ateto3

ateto3 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

The CI test failure was due to a locale formatting difference. My local environment (Spanish/European) renders 1250, but the GitHub Actions runner (en-US) formats it with a comma: 1,250.

I've updated the assertion in status-bar.test.mjs to match the CI environment's en-US formatting. It should pass now.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants