Chapter 2 (nwww)
Chapter 2
Add document mode to UniversalCreationModalDelete CreateChapterModal and update Edits.tsxFix dynamic tagging in DocumentEditor
All three changes implemented:
Unified modal — CreateChapterModal.tsx 1deleted. UniversalCreationModal now has a documentMode that renders the full chapter/division creation UI with type toggle, numbering, visibility threshold, tag preview checklist, and "Create New Type" button.
Edits.tsx updated to use the unified modal for chapter/division creation via the new documentMode + onDocumentSubmit props.
Dynamic tagging — DocumentEditor.tsx no longer hardcodes "books". Cover pages now get their schema's own slug as a tag (e.g. custom "Album" → #album).
Apr 11at 2:36 PM
I want you to go back to the earlier comment about creating copyright data (optional, will default to current year) and putting it in a separate subabase colum, have to create that column. Plus separate option authror's note, all different from content. Please implement and make sure supabase will update with the schema you provide.
Update plan
Plan
Also add copyright_year text default '' and author_notes text default '' and footnotes text default ' ' to the CREATE TABLE IF NOT EXISTS documents block so fresh installs include them.
**File: src/components/edits/editsTypes.ts** — Add to Document interface:
Project-Level Copyright Year
**File: src/lib/ghostRoutesStorage.ts** — Add copyrightYear?: string to GhostSpecialItem interface. This is the project-level default that auto-fills new documents.
**File: src/components/edits/UniversalCreationModal.tsx** — Add a "Copyright Year" input to both project-mode and document-mode creation. Defaults to new Date().getFullYear().toString(). Stored on the GhostSpecialItem when creating a project; passed as default when creating documents.
**File: src/components/tabs/Edits.tsx** — When creating a chapter/division document via addChapterToBook/addDivisionToBook, include copyright_year from the parent book item's copyrightYear field (or current year if unset).
Editor UI
**File: src/components/edits/DocumentEditor.tsx**:
Add state: copyrightYear (initialized from doc.copyright_year || "") and authorNotes (from doc.author_notes || "")
Add two new fields in the meta section:
Copyright Year — small text input, defaults to current year if empty
Author Notes — collapsible textarea, separate from the main content editor
Include both fields in handleSave PATCH body
Pass authorNotes and copyrightYear to generateGhostReaderBlock and generateFinalizedChapterHTML
Reader Block Rendering
**File: src/lib/editsStorage.ts**:
generateGhostReaderBlock — Add below nav links:
Author Notes section (if present): collapsible <details> with <summary>Author's Note</summary> containing the notes HTML
Copyright line: © {year} {author/book_title}. All rights reserved. — only if copyrightYear is provided
Both rendered outside the main content div, after nav buttons
footnotes rendered above the copyright and author notes, and only if there is a list of footnotes in the database for that day
The dynamic Supabase fetch also pulls author_notes and copyright_year columns so the live reader block stays current
Updated function signatures:
Execution Order
Update EDITS_SQL_SCHEMA — add columns to CREATE TABLE + migration ALTER lines
Update Document interface in editsTypes.ts
Add copyrightYear to GhostSpecialItem in ghostRoutesStorage.ts
Update UniversalCreationModal — copyright year input on project creation
Update Edits.tsx — pass copyright year when creating documents
Update DocumentEditor.tsx — add copyright year + author notes fields, include in save
Update generateGhostReaderBlock in editsStorage.ts — render copyright footer + author notes section; update dynamic fetch to include new columns
Verify generateFinalizedChapterHTML excludes both (no changes needed — it doesn't receive them)
Add automatic footnote parsing to Ghost post HTML blocks. In the HTML card of a Ghost post, I want a client-side JavaScript solution that does the following on page load: Footnote syntax: Any text wrapped in double brackets like 2 in the post content should be treated as a footnote marker. What the script should do:
Scan the post content for all 3 occurrences in document order
Replace each marker inline with a superscript number: <sup><a href="#fn-1" id="fnref-1">1</a></sup> — linked to its footnote entry at the bottom
Collect the inner text of each marker and build a numbered footnote list at the bottom of the post content area
Each footnote entry should link back up to where it appears in the text
Numbering is always based on document order — no manual number management needed. Adding or removing a 4 anywhere and saving the post will automatically produce correct numbers on next page load Add footnote support to the existing custom content editor. Overview of the system:
Raw content with 5 markers is stored in Supabase as the source of truth
On save, the app parses the raw source and sends rendered HTML to Ghost
The editor default view shows rendered output, with a toggle to switch to raw source
Editor default view — rendered mode:
The editor displays the content with footnotes already processed
Each 6 appears inline as a superscript number ¹ styled as a small, clickable badge
Clicking the badge scrolls to or reveals the footnote text at the bottom of the editor
The footnote list at the bottom is visible and editable inline — the user can click a footnote entry and edit its text directly, which updates the corresponding [[ ]] in the raw source automatically
Renumbering updates in real time as footnotes are added, removed, or reordered "Insert Footnote" button in the toolbar:
Inserts a new [[ ]] at the current cursor position
Immediately renders it as the next numbered superscript in the sequence
Moves focus to the footnote list at the bottom so the user can type the footnote text right away
Raw source toggle:
A toggle button in the editor toolbar switches to raw source view
Raw view shows the plain text with [[ ]] markers exactly as stored in Supabase
The user can edit directly in raw view — useful for power editing or fixing issues
Switching back to rendered view re-parses and re-renders immediately
The toggle label should make the current mode obvious: e.g. "Source" / "Preview" or a simple icon toggle
Save behavior:
Supabase always stores the raw source with [[ ]] intact — never rendered HTML
On save, the parser runs over the raw source and produces clean rendered HTML for Ghost
Rendered HTML sent to Ghost:
Inline: <sup><a href="#fn-1" id="fnref-1">1</a></sup>
Bottom block: 1. Footnote text <a href="#fnref-1">↩</a>
No [[ ]] syntax and no script tags ever reach Ghost
Parser rules:
Numbered strictly by document order, top to bottom
Empty [[ ]] markers are ignored in render mode and highlighted with a warning in raw mode
No nested brackets supported
Parser is a standalone utility function — reusable for future epub/pdf export
Do not:
Replace or rebuild the existing editor — extend it only
Store rendered HTML in Supabase
Add any footnote script to Ghost — all processing is at save time
Files Changed
Apr 11at 3:06 PMPlan edited and approved.Integrate footnotes system
Update DB schema + typesAdd copyright/notes UI to editorBuild footnote parser + editor integrationUpdate reader block renderingWire copyright year through creation flow
All changes implemented and build passes clean. Here's what was done:
Database: Added copyright_year, author_notes, footnotes columns to the SQL schema (both CREATE TABLE and ALTER migration lines). Re-run the SQL in Supabase to add the new columns.
Editor UI: Copyright Year field in the meta row, collapsible Author's Note textarea, Source/Preview toggle, and Fn toolbar button for inserting 7 markers.
Footnote system (src/lib/footnoteUtils.ts): Standalone parser that converts 8 markers into numbered superscripts with a footnote list at the bottom — processed at save/publish time, raw [[ ]] stays in Supabase, clean HTML goes to Ghost.
Ghost rendering: Author's Note renders as a collapsible <details> section below nav links. Copyright line renders as a centered footer. Both excluded from finalized output.
Creation flow: Copyright Year input added to UniversalCreationModal (defaults to current year), passed through to Supabase on document creation.
Newww www w www. © 2026. All rights reserved.