CHUNK #3: Writing Surface — editor wiring, storage view, polish

Complete the Writing Surface chunk: wire the web writing view to the
offline-first storage adapter, finish the editor package exports, and
apply Step 4 polish (SVG monogram logo, real project in the sidebar,
font settings → CSS variables).

Editor package
- Re-export EditorContent + Editor type from @pubscript/editor so the
  web app never imports TipTap directly.

Web writing view (apps/web)
- project-store (zustand) over storageLocal: project, chapters, active
  chapter, autosave via createAutosave, idle detection via
  createIdleDetector.
- Client-side seed mirroring the server seed ("The Glass Harbor").
- WritingView component: editor + autosave label + word/scene count +
  chapter nav; wire the /write route inside AppShell.
- Import editor.css in main.tsx.

Core storage contract
- Extend StorageAdapter with createBook/listBooks/listChapters;
  implement in local + server adapters; update contract test mock.

Polish
- Sidebar: SVG monogram logo + live project title/word count instead
  of the placeholder "The Silent Cartographer".
- Fonts: applyFontSettings() in the theme engine writes --ps-font-*
  variables; .ps-content reads --ps-font-size/leading/measure; settings
  store applies fontSize on boot and change.

Docs
- PLAN.md: CHUNK #3 → in progress.
- CHUNK#3_PROGRESS.md: steps 1–3 done, step 4 polish in progress.

Verified: full workspace typecheck clean, lint clean, core 24 / ui 5 /
editor 7 tests pass, web build clean. (server vitest hits EADDRINUSE on
8080 — pre-existing Docker WordPress port conflict, unrelated.)
This commit is contained in:
Schwitzz
2026-10-25 13:57:07 -05:00
parent 9a965745ee
commit bb68d9d5d2
21 changed files with 804 additions and 74 deletions
+5 -5
View File
@@ -47,8 +47,8 @@ export interface PubScriptEditorHookOptions extends Omit<UseEditorOptions, "exte
editor?: TipTapEditor;
/** Decoration source to render. Defaults to the empty stub. */
decorationSource?: PubScriptDecorationSource;
/** Initial document content (ProseMirror JSON or HTML string). */
content?: string;
/** Initial document content (ProseMirror JSON). */
content?: Content;
/** Called on every transaction with the live editor instance. */
onUpdate?: (editor: TipTapEditor) => void;
/** Whether the editor is editable. */
@@ -72,7 +72,7 @@ export function usePubScriptEditor(options: PubScriptEditorHookOptions = {}) {
const editor = useEditor({
editable,
extensions: pubScriptExtensions,
...(content !== undefined ? { content: content as Content } : {}),
...(content !== undefined ? { content } : {}),
...useEditorOptions,
});
@@ -117,8 +117,8 @@ export function usePubScriptEditor(options: PubScriptEditorHookOptions = {}) {
/**
* Convenience factory for a headless editor instance, shared across the app.
*/
export function createEditorInstance(content?: string): TipTapEditor {
return createPubScriptEditor(content === undefined ? {} : { content: content as Content });
export function createEditorInstance(content?: Content): TipTapEditor {
return createPubScriptEditor(content === undefined ? {} : { content });
}
export { createPubScriptEditor, pubScriptExtensions };
+5
View File
@@ -43,3 +43,8 @@ export {
export { serializeToMarkdown, parseMarkdown, markdownInputRules, markdownPasteRules } from "./markdown.js";
export { throttle, createIdleDetector } from "./perf.js";
// Re-export the TipTap render surface and editor type so consumers of the
// package never import TipTap directly.
export { EditorContent } from "@tiptap/react";
export type { Editor } from "@tiptap/core";