diff --git a/Journal.App/src/lib/components/EditorPanel.svelte b/Journal.App/src/lib/components/EditorPanel.svelte index b58a529..ad4dc61 100644 --- a/Journal.App/src/lib/components/EditorPanel.svelte +++ b/Journal.App/src/lib/components/EditorPanel.svelte @@ -27,6 +27,7 @@ export let calendarBusy = false; export let calendarError = ""; export let previewOnly = true; + export let onForceSave: () => Promise | void = () => {}; type CalendarCard = { id: string; @@ -160,6 +161,7 @@ {openDocumentName} {openDocumentContent} {onDocumentContentChange} + {onForceSave} {onOpenDocument} {previewOnly} /> diff --git a/Journal.App/src/lib/components/SidePanel.svelte b/Journal.App/src/lib/components/SidePanel.svelte index 8a82600..124cd41 100644 --- a/Journal.App/src/lib/components/SidePanel.svelte +++ b/Journal.App/src/lib/components/SidePanel.svelte @@ -82,6 +82,7 @@ let calendarTimelineDebounce: ReturnType | null = null; let lastActiveSection = ""; let calendarLastRefreshedAt = ""; + let calendarDateExplicitlySelected = false; const CALENDAR_SAVED_VIEWS_KEY = "journal.calendar.savedViews"; let selectedCalendarDate: { year: number; month: number; day: number; key: string } | null = { @@ -454,7 +455,9 @@ function handleDateActivate(payload: { year: number; month: number; day: number; key: string }) { selectedCalendarDate = payload; if (activeSection !== "calendar") return; - openOrCreateDailyEntry(payload.key); + calendarDateExplicitlySelected = true; + calendarStartDate = payload.key; + calendarEndDate = payload.key; } function toTemplateStoreId(filePath: string): string { @@ -505,13 +508,19 @@ } if (activeSection === "calendar") { - const selected = selectedCalendarDate ?? { - year: calendarYear, - month: calendarMonth, - day: 1, - key: toDateKey(calendarYear, calendarMonth, 1) - }; - openOrCreateDailyEntry(selected.key); + if (calendarDateExplicitlySelected) { + const selected = selectedCalendarDate ?? { + year: calendarYear, + month: calendarMonth, + day: 1, + key: toDateKey(calendarYear, calendarMonth, 1) + }; + openOrCreateDailyEntry(selected.key); + } else { + showNewItemInput = true; + newItemName = ""; + queueMicrotask(() => newItemInput?.focus()); + } } } @@ -571,6 +580,11 @@ entriesStore.update((items) => [item, ...items]); onEditItem(item); createTemplateMode = false; + } else if (activeSection === "calendar") { + const id = `entries/draft-${Date.now()}`; + const item = { id, label, initialContent: `# ${label}\n\n` }; + entriesStore.update((items) => [item, ...items]); + onEditItem(item); } else if (activeSection === "todos") { try { const { meta, items: todoItems } = await createTodoListFromLabel(label); @@ -694,6 +708,7 @@ } $: if (activeSection === "calendar" && lastActiveSection !== "calendar") { + calendarDateExplicitlySelected = false; void forceRefreshCalendar({ allowWhileBusy: true }); setTimeout(() => { void forceRefreshCalendar({ allowWhileBusy: true }); @@ -734,6 +749,19 @@ {#if isCalendarSection} + {#if showNewItemInput} +
+ +
+ {/if} +