diff --git a/modules/rdocs/components/folk-docs-app.ts b/modules/rdocs/components/folk-docs-app.ts index 04d58a31..0e8f6cbb 100644 --- a/modules/rdocs/components/folk-docs-app.ts +++ b/modules/rdocs/components/folk-docs-app.ts @@ -354,6 +354,8 @@ class FolkDocsApp extends HTMLElement { } this.loading = false; this.render(); + // Auto-open first note of first notebook + this.autoOpenFirstNote(); return; } } @@ -494,7 +496,20 @@ Gear: EUR 400 (10%)
Maya is tracking expenses in rF
},
];
+ // Starter notebook with a blank note (always first)
+ const starterNote: Note = {
+ id: "demo-note-starter", title: "Untitled", content: "", content_plain: "",
+ content_format: 'tiptap-json',
+ type: "NOTE", tags: null, is_pinned: false, sort_order: 0,
+ created_at: new Date(now).toISOString(), updated_at: new Date(now).toISOString(),
+ };
+
this.demoNotebooks = [
+ {
+ id: "demo-nb-new", title: "New Documents", description: "",
+ cover_color: "#3b82f6", note_count: "1", updated_at: new Date(now).toISOString(),
+ notes: [starterNote],
+ } as any,
{
id: "demo-nb-1", title: "Alpine Explorer Planning", description: "Shared knowledge base for our July 2026 trip across France, Switzerland, and Italy",
cover_color: "#f59e0b", note_count: "8", updated_at: new Date(now - hour).toISOString(),
@@ -522,9 +537,28 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
}
this.loading = false;
this.render();
+
+ // Auto-open the blank starter note
+ this.selectedNotebook = { ...this.demoNotebooks[0] };
+ this.selectedNote = starterNote;
+ this.renderNav();
+ this.renderMeta();
+ this.mountEditor(starterNote);
+
this.saveDemoState(); // persist initial state
}
+ /** Open the first note of the first notebook (used on demo restore and fresh load). */
+ private autoOpenFirstNote() {
+ const firstNb = this.demoNotebooks[0];
+ if (!firstNb?.notes?.length) return;
+ this.selectedNotebook = { ...firstNb };
+ this.selectedNote = firstNb.notes[0];
+ this.renderNav();
+ this.renderMeta();
+ this.mountEditor(firstNb.notes[0]);
+ }
+
private demoSearchNotes(query: string) {
if (!query.trim()) {
this.searchResults = [];
@@ -1228,6 +1262,40 @@ Gear: EUR 400 (10%) Maya is tracking expenses in rF
}
this.loading = false;
this.render();
+
+ // Auto-scaffold a starter notebook with a blank note on first use
+ if (this.notebooks.length === 0 && !this.error) {
+ await this.scaffoldStarterNotebook();
+ }
+ }
+
+ /** Create a "New Documents" notebook with one blank note for first-time users. */
+ private async scaffoldStarterNotebook() {
+ try {
+ const base = this.getApiBase();
+ const res = await fetch(`${base}/api/notebooks`, {
+ method: "POST",
+ headers: this.authHeaders({ "Content-Type": "application/json" }),
+ body: JSON.stringify({ title: "New Documents", cover_color: "#3b82f6" }),
+ });
+ const nb = await res.json();
+ if (!nb?.id) return;
+
+ // Refresh notebook list so the new notebook appears
+ const listRes = await fetch(`${base}/api/notebooks`, { headers: this.authHeaders() });
+ const listData = await listRes.json();
+ this.notebooks = listData.notebooks || [];
+ this.render();
+
+ // Subscribe and create a blank note inside it
+ this.selectedNotebook = { ...nb, notes: [] };
+ this.expandedNotebooks.add(nb.id);
+ this.notebookNotes.set(nb.id, []);
+ await this.loadNotebook(nb.id);
+ this.createNoteViaSync();
+ } catch {
+ // Non-critical — user can still create manually
+ }
}
private async loadNotebook(id: string) {