feat(plot): Chunk #5 story whiteboard, timeline & plot beats
Story whiteboard built on React Flow v11: free-form canvas of typed nodes (character, world, chapter, note, image, group) with draggable leads-to/contrasts/causes edges, cross-link selectors (chapter/entity), linked-node badges, and an "Add beats to board" import from the plot. Plot beats feature set: - Status/locking (draft/revised/locked) with a progress bar - Beat templates (three-act, save-the-cat, seven-point, custom) - Timeline route with search/chapter/character filters - Entity cross-links (entityIds) on beats and board nodes - getBoard added to the StorageAdapter contract (local + server) and REST endpoints; loadBoard now restores persisted board state Storage & server: - PlotBeat type (status, entityIds) across core types, Dexie schema, and server mapping/routes/migration (002_plot_beats.sql) - SQLite-safe column names (beat_order, entity_ids) - Server seed data for plot beats UI: accent Button variant, Badge variants, plot/timeline/whiteboard stylesheets. Tests: templates module, plot-beat store round-trip, board getBoard. typecheck, lint, test, and build all green.
This commit is contained in:
@@ -7,6 +7,7 @@ import type {
|
||||
DocumentRef,
|
||||
Entity,
|
||||
NewProject,
|
||||
PlotBeat,
|
||||
Project,
|
||||
ProjectMeta,
|
||||
} from "./types.js";
|
||||
@@ -28,6 +29,7 @@ class PubScriptDB extends Dexie {
|
||||
chapters!: Table<Chapter, string>;
|
||||
entities!: Table<EntityRec, string>;
|
||||
boards!: Table<Board, string>;
|
||||
plotBeats!: Table<PlotBeat, string>;
|
||||
aiSessions!: Table<AISession, string>;
|
||||
|
||||
constructor() {
|
||||
@@ -38,6 +40,8 @@ class PubScriptDB extends Dexie {
|
||||
chapters: "id, bookId, projectId",
|
||||
entities: "key, projectId, kind",
|
||||
boards: "id, projectId",
|
||||
// Plot beats — atomic units of story structure (CHUNK #5).
|
||||
plotBeats: "id, [projectId+act], projectId, chapterId",
|
||||
aiSessions: "id, projectId",
|
||||
});
|
||||
}
|
||||
@@ -194,6 +198,35 @@ export const storageLocal: StorageAdapter = {
|
||||
await db.boards.put(b);
|
||||
},
|
||||
|
||||
async getBoard(projectId: string): Promise<Board | null> {
|
||||
const rows = await db.boards
|
||||
.where("projectId")
|
||||
.equals(projectId)
|
||||
.toArray();
|
||||
return rows[0] ?? null;
|
||||
},
|
||||
|
||||
async listPlotBeats(projectId: string): Promise<PlotBeat[]> {
|
||||
const rows = await db.plotBeats
|
||||
.where("projectId")
|
||||
.equals(projectId)
|
||||
.toArray();
|
||||
// Stable order: by act, then order within act.
|
||||
return rows.sort((a, b) => a.act - b.act || a.order - b.order);
|
||||
},
|
||||
|
||||
async savePlotBeat(b: PlotBeat): Promise<void> {
|
||||
await db.plotBeats.put(b);
|
||||
},
|
||||
|
||||
async deletePlotBeat(projectId: string, id: string): Promise<void> {
|
||||
const existing = await db.plotBeats.get(id);
|
||||
if (!existing || existing.projectId !== projectId) {
|
||||
throw new Error(`No plot beat ${id} in project ${projectId}.`);
|
||||
}
|
||||
await db.plotBeats.delete(id);
|
||||
},
|
||||
|
||||
async saveAISession(s: AISession): Promise<void> {
|
||||
await db.aiSessions.put(s);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user