2.5 KiB
2.5 KiB
CHUNK #3 — Editor & Writing View
Status: In progress. Steps 1–3 committed. Step 4 (polish) in progress.
Bug fixes
- UI disappears when navigating to Write — WritingView passed
chapter.doc.content(a bare ProseMirror node array) as editorcontent, soEditorState.createbuilt a doc node with an undefined type and threwCannot read properties of undefined (reading 'schema'), unmounting the write view. Fixed by passing the full doc object ({ type: 'doc', content }) on init and onsetContentsync. Verified in a headless browser: editor renders the seeded chapter ("The Glass Harbor") with no console errors. Regression tests inpackages/editor/src/use-editor-doc.test.ts.
Progress
- Step 1: Editor package (TipTap 3 schema, wrapper, markdown, key bindings) — committed
- Step 2: Writing view in apps/web wired to storage adapter
- Add @pubscript/editor to web deps
- project-store (zustand) over storageLocal
- client-side seed for local adapter
- WritingView component (editor + autosave + word/scene count + chapter nav)
- wire Write route
- Step 3: Performance (autosave via createAutosave, idle detection via createIdleDetector)
- Step 4: Polish (editor.css import ✅, fonts 🟡, SVG monogram logo ✅)
- editor.css import in main.tsx
- SVG monogram logo in Sidebar
- Sidebar reflects the real seeded project ("The Glass Harbor") + live word count
- font family/size/leading/measure controls wired to CSS variables (size only so far)
Key facts
- Editor package exports: usePubScriptEditor, createEditorInstance, emptyDecorationSource, throttle, createIdleDetector, serializeToMarkdown, parseMarkdown, node types + constants.
- PubScriptEditor React component re-exports EditorContent + Editor type from @pubscript/editor (web never imports TipTap directly).
- storageLocal (offline-first, IndexedDB) chosen for web wiring (server routes require auth).
- Demo prose lives in server/src/seed.ts ("The Glass Harbor", 3 chapters, 4 chars, 1 world, 1 board).
- Web app uses @pubscript/core/local (storageLocal) — no server needed to run offline.
- Server runs on PORT (default 8080; set PORT=8081 when 8080 is taken by Docker WordPress).
Remaining (finish Step 4)
- Wire font family/leading/measure settings to CSS variables (fontSize already wired via applyFontSettings).
- Add a settings UI control for font size (or confirm existing one applies).
- Final polish pass: focus mode visual, empty-state copy, a11y labels.