11 Commits
Author SHA1 Message Date
olivier 984a0ab44f release v1.8.0: reuse open tabs for periodic notes 2026-10-08 16:36:47 -04:00
olivier 695141383f release v1.7.1: native template autocomplete, durable indicator migration 2026-09-08 10:49:01 -04:00
olivier a0a3b50d94 docs: add QA coverage for indicator migration and native autocomplete 2026-09-08 10:33:10 -04:00
olivier 621bef0d29 fix: native template autocomplete and durable indicator migration
Template file fields used an unstyled <datalist>, not Obsidian's native suggest popup. Replace it with TemplateFileSuggest, an AbstractInputSuggest<TFile> matching Templater's own FileSuggest/FolderSuggest pattern exactly. Requires Obsidian >=1.4.10; minAppVersion corrected.

The coloured-indicator default never reached existing installs: every install that loaded before that default changed had already persisted the prior default (indicatorMode: 'any') to data.json as if it were a deliberate choice, and Object.assign-based settings merging always prefers a value already on disk over a new code default. Hand-editing data.json directly does not fix this durably either -- Obsidian holds settings in memory while a vault is open and overwrites external edits on its own save cycle.

Add a one-time, code-level migration: on load, an install with a persisted indicatorMode of 'any' and no indicatorModeMigrated flag is promoted to 'systems' and the flag is persisted immediately, so it survives even a session with no further settings changes. Any indicatorMode chosen after the flag exists, any (deliberately) included, is never touched again.
2026-09-08 10:32:54 -04:00
olivier e8ba4cd2ad release v1.7.0: redesigned calendar with coloured system indicators 2026-09-08 10:18:43 -04:00
olivier 5a9b7bfff8 docs: describe calendar indicator defaults and autocomplete 2026-09-07 21:53:03 -04:00
olivier 72a61e49ee fix: default calendar to system indicators
Use coloured system markers by default, preserve configured colours through settings migration, expose all template fields through native vault-path autocomplete, and remove the redundant Calendar heading.
2026-09-07 21:52:34 -04:00
olivier 069456799e feat: add coloured calendar system indicators
Add a selectable single-dot or per-system indicator mode. Date systems now carry configurable colours; results are cached per displayed month and invalidated when paths/settings change. Refine calendar hierarchy, spacing, hover, and today states.
2026-09-07 21:43:21 -04:00
olivier 12209155dc release v1.6.0: add calendar date systems 2026-09-07 21:34:32 -04:00
olivier e027ac4a9e fix: let Templater own date-system templates
Leave the default Journal and Meeting systems without a raw Waypoint template so Templater folder triggers own interactive rendering. Their fallback frontmatter now matches the journal and meeting types. Document the required folder-trigger setup and selected-date filename contract.
2026-09-07 21:33:03 -04:00
olivier 26a1a481ac feat: add date systems menu to calendar days
Right-clicking a calendar day now lists every configured date-prefixed note system. Journal notes are singletons; {title} formats support multiple notes per date, such as meetings.\n\nAdds default Journal and Meeting systems, configurable settings UI, safe filename/title handling, one shared dated-note creation path, and a compiled menu smoke test fixture in the test vault.
2026-09-07 21:07:18 -04:00
13 changed files with 1130 additions and 115 deletions

No files matched your search

+148 -30
View File
@@ -9,12 +9,13 @@
``` ```
src/ src/
├── main.ts Plugin entry — lifecycle, commands, events, data persistence ├── main.ts Plugin entry — lifecycle, commands, events, data persistence
├── settings.ts Interface definitions + DEFAULT_SETTINGS constant ├── settings.ts Interface definitions + DEFAULT_SETTINGS / DEFAULT_DATE_SYSTEM constants
├── settings-tab.ts PluginSettingTab UI — tabs: calendar, periodic, recent, display, about ├── settings-tab.ts PluginSettingTab UI — calendar, periodic, date systems, recent, display, about
├── models/ ├── models/
│ └── bookmark.ts BookmarkItem + WaypointData interfaces │ └── bookmark.ts BookmarkItem + WaypointData interfaces
├── utils/ ├── utils/
│ ├── date-utils.ts Moment.js helpers: period formatting, month grid, navigation │ ├── date-utils.ts Moment.js helpers: period formatting, month grid, navigation
│ ├── date-systems.ts Pure date-system filename helpers (no `obsidian` import, unit-testable)
│ └── path-utils.ts Pure path helper: rename remapping (no `obsidian` import, unit-testable) │ └── path-utils.ts Pure path helper: rename remapping (no `obsidian` import, unit-testable)
└── views/ └── views/
└── waypoint-view.ts ItemView subclass — full sidebar rendering + interaction └── waypoint-view.ts ItemView subclass — full sidebar rendering + interaction
@@ -30,7 +31,7 @@ src/
### `onload()` ### `onload()`
1. **Load data** — `loadSettings()` then `loadWaypointData()`, both merge saved partials over defaults via `Object.assign({}, DEFAULT, partial)`. 1. **Load data** — reads `data.json` exactly once, then `applySettings(saved)` and `applyWaypointData(saved)` merge its partial data over defaults.
2. **Register view** — `WAYPOINT_VIEW_TYPE = "waypoint-view"` maps to `WaypointView` factory `(leaf) => new WaypointView(leaf, this)`. 2. **Register view** — `WAYPOINT_VIEW_TYPE = "waypoint-view"` maps to `WaypointView` factory `(leaf) => new WaypointView(leaf, this)`.
3. **Settings tab** — `WaypointSettingTab` receives the live `settings` object + `() => this.redrawAll()` callback for live preview. 3. **Settings tab** — `WaypointSettingTab` receives the live `settings` object + `() => this.redrawAll()` callback for live preview.
4. **Register commands** (see Commands section below). 4. **Register commands** (see Commands section below).
@@ -50,13 +51,15 @@ Detaches all leaves of `WAYPOINT_VIEW_TYPE`.
```typescript ```typescript
interface WaypointSettings { interface WaypointSettings {
calendar: CalendarSettings; // firstDayOfWeek (0=Sun,1=Mon), showNoteIndicators calendar: CalendarSettings; // week start, indicator visibility/style, daily indicator colour
daily: PeriodNoteSettings; daily: PeriodNoteSettings;
reusePeriodicNoteTabs: boolean; // defaults to false; all periodic-note openers reuse an open tab
weekly: PeriodNoteSettings; weekly: PeriodNoteSettings;
monthly: PeriodNoteSettings; monthly: PeriodNoteSettings;
quarterly: PeriodNoteSettings; quarterly: PeriodNoteSettings;
yearly: PeriodNoteSettings; yearly: PeriodNoteSettings;
recentFiles: RecentFilesSettings; // maxItems, updateOn, omittedPaths[], omittedTags[], filterTags[] dateSystems: DateSystemSettings[]; // day-scoped systems beyond the daily note, in menu order
recentFiles: RecentFilesSettings; // maxItems, updateOn, omittedPaths[], omittedTags[], filterTags[]
display: DisplaySettings; // px sizing for bookmark rows, fonts, icons, calendar cells display: DisplaySettings; // px sizing for bookmark rows, fonts, icons, calendar cells
} }
@@ -68,8 +71,10 @@ interface PeriodNoteSettings {
} }
interface CalendarSettings { interface CalendarSettings {
firstDayOfWeek: number; // 0 = Sunday, 1 = Monday firstDayOfWeek: number; // 0 = Sunday, 1 = Monday
showNoteIndicators: boolean; // dot on days with existing .md files showNoteIndicators: boolean; // show or hide all calendar markers
indicatorMode: 'any' | 'systems'; // defaults to systems; one neutral dot or one per date system
dailyIndicatorColor: string; // daily's colour in systems mode
} }
interface RecentFilesSettings { interface RecentFilesSettings {
@@ -90,6 +95,8 @@ interface DisplaySettings {
} }
``` ```
`dateSystems` holds the user's configured date systems in menu order — see the Date Systems section for the `DateSystemSettings` shape and the two systems shipped by default.
### BookmarkItem (recursive tree) ### BookmarkItem (recursive tree)
```typescript ```typescript
@@ -126,7 +133,7 @@ The bookmark tree is stored under `waypointData.bookmarks` and rendered recursiv
| `waypoint-go-to-quarterly` | Go to quarterly note | `Mod+Shift+Alt+Q` | | `waypoint-go-to-quarterly` | Go to quarterly note | `Mod+Shift+Alt+Q` |
| `waypoint-go-to-yearly` | Go to yearly note | `Mod+Shift+Alt+Y` | | `waypoint-go-to-yearly` | Go to yearly note | `Mod+Shift+Alt+Y` |
All call `openPeriodNote(period, moment())` — opens or creates the current period's note. All five commands call `openPeriodNote(period, moment())` — opening or creating the current period's note. **Periodic Notes → Use existing tabs** defaults to off. When enabled, the shared opener focuses a Markdown tab for the exact configured file path, including in another pane or window, without reopening the file or resetting its editor position. This also applies to next/previous navigation and regular calendar clicks. With no matching tab, normal note creation/opening is unchanged. Explicit open-in-new-tab actions still win; existing duplicate tabs are not closed.
### Next/Previous period (no default hotkeys) ### Next/Previous period (no default hotkeys)
@@ -147,6 +154,116 @@ These call `navigatePeriodNote(direction)` which:
--- ---
## Date Systems
A **date system** is a folder of notes whose filenames begin with a date. Daily notes, a journal and meeting notes are all the same shape, so they share one settings model, one discovery pass and one creation path.
### `DateSystemSettings`
interface DateSystemSettings {
id: string; // stable across edits + reordering, so settings rows can key on it
name: string; // menu label, e.g. "Journal"
folder: string; // e.g. "periodic/journal"
nameFormat: string; // moment format string; may contain "{title}"
templateFile: string; // may omit the .md extension
typeProperty: string; // fallback frontmatter `type:` value
icon: string; // Lucide icon name for the menu item
indicatorColor: string; // calendar dot colour in systems mode
}
```
Configured systems live in `settings.dateSystems`, where array order is menu order. `DEFAULT_DATE_SYSTEM` (in `settings.ts`, typed `Omit<DateSystemSettings, 'id'>`) supplies the field defaults for a newly added row **and** the merge base for saved ones, so a system persisted before a field existed still loads with that field defined. `DEFAULT_SETTINGS.dateSystems` ships two:
| `id` | `name` | Folder | `nameFormat` | Indicator colour | Notes per date |
|---|---|---|---|---|---|
| `journal` | Journal | `periodic/journal` | `YYYY-MM-DD - [Journal]` | green (`#22c55e`) | one |
| `meetings` | Meeting | `periodic/meetings` | `YYYY-MM-DD - {title}` | violet (`#a855f7`) | many |
The default calendar mode is `systems`, while `any` preserves the older one-neutral-dot behaviour. Existing installs that silently persisted the pre-`systems` default of `any` are promoted to `systems` exactly once, on load, via a `data.json`-level `indicatorModeMigrated` flag; a value chosen after that flag is set (including `any`) is never touched again. Template file fields in both Periodic Notes and Date systems use `TemplateFileSuggest`, an `AbstractInputSuggest<TFile>` (the same base class Templater's own template pickers use — Obsidian's native fuzzy-suggest popup, not an unstyled `<datalist>`), searching every Markdown path in the vault. `AbstractInputSuggest` requires Obsidian ≥1.4.10, hence `manifest.json`'s `minAppVersion`.
### Templater folder triggers
Waypoint deliberately does not evaluate Templater syntax. For an interactive Templater template, configure Templater's **Trigger Templater on new file creation** mode for the relevant folder, then leave that date system's `templateFile` blank in Waypoint. Waypoint creates a safe fallback note from `typeProperty` and the selected `YYYY-MM-DD` date; Templater's folder trigger owns the rendered content, prompts, scripts, and cursor placement.
The target filename is the contract between them. A calendar-created journal note is already named `YYYY-MM-DD - Journal`; a meeting is already `YYYY-MM-DD - {title}`. Templates must extract the date from `tp.file.title`, not `tp.date` or `tp.file.creation_date()`, because those refer to when Templater runs rather than the date selected in the calendar.
The journal template may retain a manual fallback: only prompt for a date and rename when `tp.file.title` does **not** match the date-system filename. That preserves manual note creation without a prompt or rename race on calendar creation.
### The `{title}` convention
`nameFormat` is a moment format string, so literal text needs bracket escaping — `YYYY-MM-DD - [Journal]` — the same convention the periodic formats `GGGG-[W]WW` and `YYYY-[Q]Q` already use.
When the format contains `{title}`, the system holds **many** notes per date: the text before the token is the date prefix used to discover them, and the token marks where a typed free-text title goes on creation. Without the token, a date maps to **exactly one** filename.
**Why the token is split out before moment sees the string:** `t`, `i`, `l` and `e` are all live moment format tokens — `l` on its own expands to an entire localized date. Passing `{title}` through `date.format()` would expand those letters and destroy the placeholder, with no way to recover it afterwards. `splitNameFormat()` therefore cuts the format at the token *first*, and callers format `before` and `after` separately, then join the two results around the title. It is also why discovery matches on formatted affixes instead of on a regex derived from the raw format.
### Helpers (`src/utils/date-systems.ts`)
Imports nothing from `'obsidian'` — callers make every moment call and pass the resulting strings in, which keeps the module unit-testable in plain node (same rationale as `path-utils.ts`).
| Export | Signature | Purpose |
|---|---|---|
| `TITLE_TOKEN` | `'{title}'` | The literal placeholder. |
| `splitNameFormat(nameFormat)` | `string → NameFormatParts` | `{ before, after, hasTitle }` — the format cut around the token. |
| `isInFolder(path, folder)` | `string, string → boolean` | Path sits in `folder` or any subfolder. An empty folder means the vault root, so everything matches. |
| `matchesSystemName(basename, before, after, hasTitle)` | `string, string, string, boolean → boolean` | One-per-date: the basename must equal `before + after`. Many-per-date: prefix/suffix match, since the middle is free text. |
| `titleFromBasename(basename, before, after)` | `string, string, string → string` | Strips the affixes to recover the menu label; falls back to the whole basename when they do not line up. |
| `sanitizeTitle(title)` | `string → string` | Collapses filename-illegal and link-syntax characters (`\ / : * ? " < > \| # ^ [ ]`) to `-`, squeezes runs of whitespace, trims — so a typed "Meeting w/ Mark" still yields a creatable filename. |
| `formatHasDateToken(nameFormat)` | `string → boolean` | Strips bracket-escaped literals out of `before`, then looks for any moment date token. Drives the settings warning. |
`matchesSystemName` deliberately returns `false` for a many-per-date format whose `before` is empty (a format of just `{title}`): an empty date prefix would otherwise claim every file in the folder for every date. The settings tab flags formats with no date token, and `findDateSystemNotes()` excludes them from the menu; `openDateSystemNote()` also refuses them. An unfinished or invalid row therefore cannot create `.md` or a static filename.
### Plugin API (`main.ts`)
```typescript
interface DateSystemNote {
file: TFile;
label: string; // free-text title for many-per-date systems, else the system name
}
interface DateSystemNotes {
system: DateSystemSettings;
notes: DateSystemNote[];
multiple: boolean; // nameFormat carries {title}
}
interface DateSystemIndicator {
id: string;
name: string;
color: string;
}
dateSystems(): DateSystemSettings[]
findDateSystemNotes(date: moment.Moment): DateSystemNotes[]
getDateSystemIndicators(dates: moment.Moment[]): Map<string, DateSystemIndicator[]>
openDateSystemNote(
system: DateSystemSettings,
date: moment.Moment,
opts?: { title?: string; leaf?: WorkspaceLeaf; reuseExistingLeaf?: boolean },
): Promise<void>
```
**`getDateSystemIndicators(dates)`** — returns one `{ id, name, color }` marker per configured system with one or more notes on a requested day. The calendar calls it once for the visible month only in `indicatorMode: 'systems'`. It makes one vault pass, caches the result by displayed dates and date-system settings, and invalidates it on markdown create/delete/rename or any Settings change. It does not run on ordinary markdown edits: content edits cannot change a filename-derived indicator.
**`dateSystems()`** — every day-scoped system in menu order: the daily periodic note, synthesized into a `DateSystemSettings` from `settings.daily`, followed by `settings.dateSystems`. The daily note is therefore not a special case in any consumer.
**`findDateSystemNotes(date)`** — **one** vault scan per call, not one per system. It formats each usable system's `before`/`after` affixes for `date` once, then walks the markdown file list a single time, bucketing each file into the system that claims it (`isInFolder` + `matchesSystemName`). Systems whose formats have no date token are omitted rather than offering an unsafe create action. It returns the remaining `DateSystemNotes` in `dateSystems()` order, each bucket sorted by basename. The calendar's day context menu is built from exactly one of these calls per right-click.
**`openDateSystemNote(system, date, opts)`** — the single opener for every dated note:
1. **Filename** — `splitNameFormat(system.nameFormat)`, format `before` and `after` against `date`, and for a many-per-date system join `sanitizeTitle(opts.title)` between them. Append `.md`; prepend `system.folder` when it is set.
2. **Existing note** — a `vault.getFileByPath()` hit is opened as-is, never overwritten. A date that already has notes can still gain another in a many-per-date system, because the title makes the filename unique.
3. **Missing note** — created via `createDatedNote`, then opened.
4. **Leaf** — an explicit `opts.leaf` always wins (middle-click and Ctrl/Cmd-click pass a tab leaf). Otherwise, when `opts.reuseExistingLeaf` is true, scan Markdown leaves by `getViewState().state.file` so deferred tabs also match; compare the complete file path, not the basename. Await `workspace.revealLeaf(existing)` to reveal/load the tab, then call `workspace.setActiveLeaf(existing, { focus: true })` to activate it and focus its editor. Return without calling `openFile`, preserving editor position. With no matching tab, or when reuse is disabled, open in `workspace.getLeaf(false)` as before.
### Note creation (`createDatedNote`)
A single creation path shared by periodic notes and date systems; it replaced the period-only `createPeriodNote`.
1. With a non-empty `system.templateFile`, reads it (appending `.md` when omitted) and creates the note with its raw contents. This is for plain, non-Templater templates.
2. With no template, the note is created with minimal frontmatter instead: `type: {system.typeProperty}` + `date: YYYY-MM-DD`. Use this mode with a Templater folder trigger, which replaces that fallback content with its rendered template.
---
## Period Note Creation (`openPeriodNote`) ## Period Note Creation (`openPeriodNote`)
```typescript ```typescript
@@ -157,16 +274,9 @@ openPeriodNote(
): Promise<void> ): Promise<void>
``` ```
Single unified opener — there is no separate `openPeriodNoteInLeaf`. For a given period + moment date: Single unified opener — there is no separate `openPeriodNoteInLeaf`, and since the date-systems refactor there is no separate creation path either. `openPeriodNote` synthesizes the period's `PeriodNoteSettings` into a `DateSystemSettings` (`folder`, `nameFormat`, `templateFile` and `typeProperty` carry over verbatim; a period format never contains `{title}`, so a period maps to exactly one filename) and delegates to `openDateSystemNote(system, date, { leaf, reuseExistingLeaf: settings.reusePeriodicNoteTabs })`. All five periodic-note types therefore share the same tab-reuse policy, with an explicit `leaf` taking precedence.
1. **Build filename:** `date.format(periodSettings.nameFormat) + ".md"`. Filename building, the existence check, template-or-frontmatter creation and leaf selection are therefore documented once, under Date Systems above.
2. **Build full path:** If `periodSettings.folder` is set, prepend it; otherwise root.
3. **Check existence:** `vault.getFileByPath(fullPath)`.
4. **If not found, create:**
- Try to read template at `periodSettings.templateFile + ".md"`.
- If template exists → `vault.create(fullPath, templateContent)`.
- If no template → `vault.create(fullPath, minimalFrontmatter)` where frontmatter is `type: {typeProperty}` + `date: YYYY-MM-DD`.
5. **Open:** in `leaf` when one is supplied, otherwise in `workspace.getLeaf(false)`.
Middle-click handlers in the view pass an explicit tab leaf: `openPeriodNote(period, date, this.app.workspace.getLeaf('tab'))`. Middle-click handlers in the view pass an explicit tab leaf: `openPeriodNote(period, date, this.app.workspace.getLeaf('tab'))`.
@@ -202,7 +312,7 @@ Both update the markdown-basename set used for calendar note indicators, then tr
recentFiles: { path: string; basename: string }[] recentFiles: { path: string; basename: string }[]
``` ```
Backed by `waypointData.recentFiles` in `data.json`, so the list survives vault reload. `loadWaypointData()` restores it and re-applies the current `maxItems` limit (in case the setting shrank since the last save). Backed by `waypointData.recentFiles` in `data.json`, so the list survives vault reload. `applyWaypointData(saved)` restores it and re-applies the current `maxItems` limit (in case the setting shrank since the last save).
**Update flow:** **Update flow:**
1. `addToRecentFiles(file)` — omission check, then dedupes (removes existing entry), prepends to front, truncates to `maxItems`. 1. `addToRecentFiles(file)` — omission check, then dedupes (removes existing entry), prepends to front, truncates to `maxItems`.
@@ -250,9 +360,16 @@ The last section (`waypoint-section:last-child`) gets `margin-top: auto`, pushin
- **Breadcrumb:** Q-label, month name, year — each clickable to open that period note. - **Breadcrumb:** Q-label, month name, year — each clickable to open that period note.
- **Nav buttons:** ◀/▶ shift month ±1. "Today" resets to current month. - **Nav buttons:** ◀/▶ shift month ±1. "Today" resets to current month.
- **Week number column:** Clicking a week number opens the weekly note for that week's Monday; middle-clicking opens it in a new tab. - **Week number column:** Clicking a week number opens the weekly note for that week's Monday; middle-clicking opens it in a new tab.
- **Day cells:** Click opens daily note, middle-click opens it in a new tab. `.other-month` dimmed. `.today` has accent border. `.has-note` gets a dot indicator, decided by the synchronous O(1) `plugin.hasNoteForDate(dateStr)` (a `Set` lookup — no per-cell vault scan). - **Day cells:** Left-click opens the daily note, middle-click opens it in a new tab, right-click opens the day context menu (below). `.other-month` is muted; `.today` has an inset accent ring; hover receives a quiet fill. With `indicatorMode: 'any'`, `.has-note` shows the existing single neutral dot through the O(1) `plugin.hasNoteForDate(dateStr)` lookup. With `indicatorMode: 'systems'`, the view calls `getDateSystemIndicators()` once for the month and renders one tooltip-labelled coloured dot per matching daily/journal/meeting/custom system.
- **Grid generation:** `getMonthGrid(year, month, firstDayOfWeek)` in `date-utils.ts` produces up to 6 weeks, each with 7 `CalendarDay` objects containing `moment`, `dayOfMonth`, `isToday`, `isCurrentMonth`, `isoWeekNumber`. - **Grid generation:** `getMonthGrid(year, month, firstDayOfWeek)` in `date-utils.ts` produces up to 6 weeks, each with 7 `CalendarDay` objects containing `moment`, `dayOfMonth`, `isToday`, `isCurrentMonth`, `isoWeekNumber`.
**Day context menu (right-click):** Built from a single `plugin.findDateSystemNotes(day.date)` call. The first entry is a non-clickable header showing the full date. Then, per system in `dateSystems()` order:
- Each existing note, labelled with its `DateSystemNote.label` and the system's `icon`. Click opens it in the current leaf; Ctrl/Cmd-click opens it in a new tab.
- A create entry (icon `plus`) labelled `New {lowercased system name} note`. Many-per-date systems always show one, with a trailing ellipsis because it first opens a `PromptModal` for the title (`New meeting note…`). A one-per-date system shows one without the ellipsis only while its note is missing (`New journal note`); once the note exists, the existing-note entry is all it gets.
Every label is derived from `system.name`, so a renamed or newly added system needs no view changes. Left-click and middle-click on the cell are untouched.
### Recent Files Panel ### Recent Files Panel
Renders `plugin.recentFiles` as Obsidian-native `nav-file` elements using the file explorer's CSS classes (`tree-item`, `nav-file-title`, `nav-file-title-content`). Renders `plugin.recentFiles` as Obsidian-native `nav-file` elements using the file explorer's CSS classes (`tree-item`, `nav-file-title`, `nav-file-title-content`).
@@ -292,7 +409,7 @@ Renders `plugin.recentFiles` as Obsidian-native `nav-file` elements using the fi
**Context menu (right-click):** **Context menu (right-click):**
- File items: "Open in new tab" - File items: "Open in new tab"
- File/Group items: "Rename" (opens `RenameModal`), "Change icon" (opens `IconSuggestModal`) - File/Group items: "Rename" (opens `PromptModal`), "Change icon" (opens `IconSuggestModal`)
- "Move to group" submenu: Lists all available groups (excluding self + descendants) + "(Root)" for ungrouping - "Move to group" submenu: Lists all available groups (excluding self + descendants) + "(Root)" for ungrouping
- Group items: "Expand/Collapse", "Add bookmark here", "New sub-group" - Group items: "Expand/Collapse", "Add bookmark here", "New sub-group"
- All items: "Insert separator above/below", "Insert spacer above/below", "Remove" - All items: "Insert separator above/below", "Insert spacer above/below", "Remove"
@@ -302,13 +419,13 @@ Renders `plugin.recentFiles` as Obsidian-native `nav-file` elements using the fi
2. If targetGroupId: find group, set `item.indent = group.indent + 1`, push to group's children. 2. If targetGroupId: find group, set `item.indent = group.indent + 1`, push to group's children.
3. If null (root): set `item.indent = 0`, push to `waypointData.bookmarks`. 3. If null (root): set `item.indent = 0`, push to `waypointData.bookmarks`.
**Rename modal (`RenameModal`):** Simple Modal with text input + Cancel/Save buttons. Enter key submits. **Prompt modal (`PromptModal`):** Simple Modal with a text input plus Cancel and CTA buttons. Enter key submits. Constructed as `new PromptModal(app, options, onSubmit)`, where `options` is `{ title, placeholder?, initialValue?, cta? }` and `cta` (the submit button label) defaults to `Save`. Generalized from the old rename-only `RenameModal` so the calendar's day context menu can reuse it to prompt for a note title.
**Icon picker (`IconSuggestModal`):** Modal with: **Icon picker (`IconSuggestModal`):** Modal with:
- Live preview of selected icon. - Live preview of selected icon.
- Search input with 60ms debounce. - Search input with 60ms debounce.
- Grid of matching icons (max 80 shown), loaded from `https://cdn.jsdelivr.net/npm/lucide-static@0.517.0/tags.json` with fallback to `https://lucide.dev/api/tags` and a hardcoded `FALLBACK_ICONS` object (~300 icons). The fetch result is cached for the session, so at most one network round-trip happens no matter how often the picker is opened. - Grid of matching icons (max 80 shown), loaded from `https://cdn.jsdelivr.net/npm/lucide-static@0.517.0/tags.json` with fallback to `https://lucide.dev/api/tags` and a hardcoded `FALLBACK_ICONS` object (~300 icons). The fetch result is cached for the session, so at most one network round-trip happens no matter how often the picker is opened.
- Click to select, "No icon" link to clear, Save/Cancel buttons. - Click to select, **No icon** button to clear, Save/Cancel buttons.
--- ---
@@ -317,18 +434,19 @@ Renders `plugin.recentFiles` as Obsidian-native `nav-file` elements using the fi
All classes prefixed with `waypoint-`. Uses Obsidian CSS variables throughout: All classes prefixed with `waypoint-`. Uses Obsidian CSS variables throughout:
- `--font-ui-small`, `--font-ui-medium`, `--font-semibold`, `--font-medium`, `--font-light` - `--font-ui-small`, `--font-ui-medium`, `--font-semibold`, `--font-medium`, `--font-light`
- `--text-muted`, `--text-faint`, `--text-accent`, `--text-on-accent` - `--text-muted`, `--text-faint`, `--text-accent`, `--text-on-accent`, `--text-error`
- `--background-modifier-border`, `--background-modifier-active-hover`, `--background-primary`, `--background-secondary` - `--background-modifier-border`, `--background-modifier-active-hover`, `--background-modifier-hover`, `--background-primary`, `--background-primary-alt`, `--background-secondary`
- `--interactive-accent` - `--interactive-accent`
- `--cursor` (for custom cursor support) - `--cursor-link` (pointer cursor, with a `pointer` fallback)
Key layout: Key layout:
- `.waypoint-view` — flex column, `overflow-y: auto`, 8px padding. - `.waypoint-view` — flex column, `overflow-y: auto`, 8px padding.
- `.waypoint-section` — `flex-shrink: 0`, 16px bottom margin. Last section gets `margin-top: auto` (pins calendar to bottom). - `.waypoint-section` — `flex-shrink: 0`, 16px bottom margin. Last section gets `margin-top: auto` (pins calendar to bottom).
- `.waypoint-section-header` — uppercase, muted, with bottom border. - `.waypoint-calendar` — padded, bordered surface with separated day cells for clear scan lines.
- Calendar table — `table-layout: fixed`, `border-collapse: collapse`. - Calendar table — `table-layout: fixed`, `border-collapse: separate`, 2px horizontal / 3px vertical cell spacing.
- `.waypoint-day.today` — accent color text + 1px accent border. - `.waypoint-day.today` — accent text with an inset accent ring, avoiding layout shifts.
- `.waypoint-day.has-note::after` — 4px dot indicator. - `.waypoint-day.has-note::after` — neutral single-dot indicator.
- `.waypoint-day-indicators` / `.waypoint-day-indicator` — compact ordered dot row; `--waypoint-indicator-color` carries each configured system colour.
- `.waypoint-bm-chevron` — `rotate(-90deg)` on collapsed groups. - `.waypoint-bm-chevron` — `rotate(-90deg)` on collapsed groups.
- `.waypoint-bm-drop-line` / `.waypoint-bm-drop-below` — 3px accent border for drag indicators. - `.waypoint-bm-drop-line` / `.waypoint-bm-drop-below` — 3px accent border for drag indicators.
@@ -372,7 +490,7 @@ Settings and waypoint data share a single `data.json` via Obsidian's `Plugin.loa
} }
``` ```
Both `loadSettings()` and `loadWaypointData()` read from the same file, merging partials over defaults. `saveSettings()` and `saveWaypointData()` each re-read the full data, update their key, and write back — so they are serialized through a single-writer save queue: each call chains onto the previous one's promise instead of racing it. Recent-file writes additionally go through the 300ms debounce in `persistRecentFiles()`. `onload()` reads `data.json` once, then `applySettings(saved)` and `applyWaypointData(saved)` merge partial persisted values over defaults. `persistAll()` writes both in-memory keys through one promise chain; it never re-reads stale disk state. Recent-file writes additionally go through the 300ms debounce in `persistRecentFiles()`.
--- ---
+42
View File
@@ -58,6 +58,17 @@
- [ ] Bookmarks persist across vault reload - [ ] Bookmarks persist across vault reload
- [ ] Move a folder containing bookmarked files to a new location → those bookmarks survive and still open the moved files - [ ] Move a folder containing bookmarked files to a new location → those bookmarks survive and still open the moved files
## Periodic Notes: Reuse Existing Tabs
- [ ] An existing configuration without `reusePeriodicNoteTabs` loads with the toggle off
- [ ] Enable **Periodic Notes → Use existing tabs**, reload the plugin, and verify it stays enabled
- [ ] For each of daily, weekly, monthly, quarterly, and yearly: open the current note in another pane, run its **Go to…** command repeatedly → that tab becomes active, its editor position is preserved, and no duplicate opens
- [ ] For each type, a note with the same basename in another folder is not reused; the configured path opens or is created normally
- [ ] Regular calendar clicks and next/previous navigation focus existing periodic-note tabs when enabled
- [ ] With the toggle off, all five commands retain their original active-leaf opening behaviour
- [ ] With the toggle on, an explicit open-in-new-tab action still creates a new tab
- [ ] A deferred periodic-note tab or a periodic-note tab in a pop-out window is revealed and focused instead of duplicated
## Calendar (Regression) ## Calendar (Regression)
- [ ] Calendar renders with correct month grid - [ ] Calendar renders with correct month grid
@@ -70,6 +81,37 @@
- [ ] Note indicator dots show on days with existing .md files - [ ] Note indicator dots show on days with existing .md files
- [ ] Today is highlighted with accent border - [ ] Today is highlighted with accent border
## Calendar: System-coloured indicators
- [ ] Calendar → Indicator style → **Single dot** keeps one neutral dot for an existing date-named note
- [ ] Calendar → Indicator style → **Colour by note system** shows a blue dot for Daily, green for Journal, and violet for Meeting by default
- [ ] A day holding multiple meeting notes still shows exactly one Meeting dot
- [ ] A day holding Daily, Journal, and Meeting notes shows three compact dots in that order
- [ ] Hover each coloured dot → its date-system name is identified by a tooltip
- [ ] Change Daily/Journal/Meeting indicator colours in Settings → the visible calendar refreshes immediately
- [ ] Add a custom date system with its own colour and a matching note → its dot appears in system order
- [ ] Create, delete, or rename a date-system note → coloured dots refresh without changing months
- [ ] An install that previously had **Single dot** as its silently-defaulted, never-touched setting shows **Colour by note system** after upgrading and reloading the plugin
- [ ] After that one-time change, manually selecting **Single dot** and reloading again keeps **Single dot** — the migration never re-fires
- [ ] Typing in any Template file field opens Obsidian's native fuzzy-suggest popup (matching the look of Templater's own template pickers), not a plain browser dropdown
## Calendar: Date systems
- [ ] Right-click a date with a daily note, journal note, and meeting note → full-date header, then all three systems appear in the menu
- [ ] Right-click a date with no date-system notes → each single-note system offers a create action and the many-note system offers “New …”
- [ ] Right-click a date with one meeting → the existing meeting and “New meeting note…” both appear
- [ ] Create a second meeting for the same date → it is created with that date prefix and both meetings appear on the next right-click
- [ ] Ctrl/Cmd-click an existing date-system menu entry → it opens in a new tab
- [ ] Submit an empty title for a new many-note system → a clear notice appears and no malformed file is created
- [ ] Add a date system in Settings → Date systems → it appears in the day menu
- [ ] Reorder and delete date systems → the day menu immediately follows the configured order and removes the deleted system
- [ ] Enter a non-empty name format with no date token → Settings shows the inline warning
- [ ] Left-click a day still opens/creates its daily note; middle-click still opens it in a new tab
- [ ] With Templater folder mappings for journal and meetings, create a date-system note → Templater expands `<% … %>` syntax rather than leaving it literal
- [ ] Create a journal from the calendar → no duplicate date prompt and no rename; its frontmatter `date` equals the selected calendar day
- [ ] Create a meeting from the calendar for a non-today date → its frontmatter `date` equals the selected calendar day
## Recent Files (Regression) ## Recent Files (Regression)
- [ ] Opening a file adds it to recent files - [ ] Opening a file adds it to recent files
+34 -1
View File
@@ -4,7 +4,8 @@ Calendar, recent files, and custom bookmarks sidebar for Obsidian.
## Features ## Features
- **Calendar panel** — month grid with clickable days, week numbers, period indicators (day/week/month/quarter/year) - **Calendar panel** — refined month grid; left-click a day opens its daily note, middle-click opens it in a tab, and right-click reveals every configured note system for that date
- **Calendar indicators** — retain a single neutral note dot or show a coloured dot per daily, journal, meeting, or custom date system
- **Recent files** — track recently opened/edited files - **Recent files** — track recently opened/edited files
- **Favorites** — custom bookmarks with groups, icons, and rename - **Favorites** — custom bookmarks with groups, icons, and rename
@@ -19,6 +20,38 @@ Calendar, recent files, and custom bookmarks sidebar for Obsidian.
| Go to yearly note | `Ctrl+Shift+Alt+Y` | | Go to yearly note | `Ctrl+Shift+Alt+Y` |
| Next/Previous daily/weekly/monthly/quarterly/yearly note | — | | Next/Previous daily/weekly/monthly/quarterly/yearly note | — |
Under **Settings → Waypoint Sidebar → Periodic Notes**, turn on **Use existing tabs** to switch to a daily, weekly, monthly, quarterly, or yearly note's tab if it is already open. This works with the five **Go to…** commands, next/previous navigation, and regular calendar clicks. If the note is not open, it opens or is created as usual. The setting is off by default. It keeps your place in the note and leaves existing duplicate tabs alone. Choosing to open a new tab still opens a new tab.
## Date systems
Right-click any calendar day to open its **date systems** menu. The daily note always appears first; left-click behaviour is unchanged. The included defaults match this vault's common layouts:
| System | Folder | Name format | Behaviour |
|---|---|---|---|
| Journal | `periodic/journal` | `YYYY-MM-DD - [Journal]` | Opens or creates one journal note for the date |
| Meeting | `periodic/meetings` | `YYYY-MM-DD - {title}` | Lists every meeting for the date and can create another |
Configure systems in **Settings → Waypoint Sidebar → Date systems**. Each system has a folder, filename format, template, fallback frontmatter type, Lucide icon, and indicator colour. Template file fields autocomplete every Markdown path in the vault.
`Name format` uses moment.js tokens. Bracket-escape literal text: `YYYY-MM-DD - [Journal]`. Add `{title}` when a date can have multiple notes; it is replaced with the title requested when creating a note. Without `{title}`, the system has exactly one note per date.
Ctrl/Cmd-click a menu entry opens it in a new tab.
### Calendar indicators
Under **Settings → Waypoint Sidebar → Calendar**, choose either:
- **Colour by note system** — the default; one compact coloured dot per configured date system that has a note on that day. Hover a dot to identify its system.
- **Single dot** — a neutral marker for any note whose filename is exactly the date.
Daily uses the Calendar tab’s colour picker. Journal, Meeting, and every custom system have their own **Indicator colour** picker under **Date systems**. The defaults are blue for Daily, green for Journal, and violet for Meeting.
### Templater folder templates
If a date system uses a Templater folder mapping, leave its Waypoint **Template file** field blank. Waypoint then creates a safe fallback note while Templater owns prompts, scripts, cursors, and rendered content.
The selected calendar date is encoded in the filename. Templater templates should derive their `date` from `tp.file.title`, not from `tp.date` or `tp.file.creation_date()`. A journal template can retain a prompt-and-rename fallback for manual note creation, but it must skip that flow when the filename already follows `YYYY-MM-DD - Journal`.
## Installation ## Installation
### Via BRAT ### Via BRAT
+20 -20
View File
@@ -2,26 +2,26 @@
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
*/ */
var q=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(g,m)=>{for(var e in m)q(g,e,{get:m[e],enumerable:!0})},ie=(g,m,e,i)=>{if(m&&typeof m=="object"||typeof m=="function")for(let s of J(m))!ee.call(g,s)&&s!==e&&q(g,s,{get:()=>m[s],enumerable:!(i=X(m,s))||i.enumerable});return g};var ne=g=>ie(q({},"__esModule",{value:!0}),g);var le={};te(le,{default:()=>O});module.exports=ne(le);var y=require("obsidian");var P={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var w=require("obsidian");var R=class extends w.PluginSettingTab{constructor(e,i,s,n){super(e,i);this.activeTab="calendar";this.plugin=i,this.settings=s,this.onSettingsChange=n}display(){let{containerEl:e}=this;e.empty();let i=e.createDiv({cls:"waypoint-settings-tabs"}),s=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let t of s)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===t.key?" is-active":""}`,text:t.label}).addEventListener("click",()=>{this.activeTab=t.key,this.display()});let n=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(n);break;case"periodic":this.renderPeriodicTab(n);break;case"recent":this.renderRecentTab(n);break;case"display":this.renderDisplayTab(n);break;case"about":this.renderAboutTab(n);break}}renderCalendarTab(e){new w.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(i=>{i.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(s=>{this.settings.calendar.firstDayOfWeek=parseInt(s,10),this.saveAndRefresh()})}),new w.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(i=>{i.setValue(this.settings.calendar.showNoteIndicators).onChange(s=>{this.settings.calendar.showNoteIndicators=s,this.saveAndRefresh()})})}renderPeriodicTab(e){this.addPeriodNoteSettings(e,"Daily",this.settings.daily),this.addPeriodNoteSettings(e,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(e,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(e,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(e,"Yearly",this.settings.yearly)}addPeriodNoteSettings(e,i,s){new w.Setting(e).setHeading().setName(i),new w.Setting(e).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(n=>{n.setPlaceholder("periodic/daily"),n.setValue(s.folder),n.onChange(t=>{s.folder=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Name format").setDesc(`Date format for ${i.toLowerCase()} note filenames (moment.js format).`).addText(n=>{n.setPlaceholder("yyyy-MM-dd"),n.setValue(s.nameFormat),n.onChange(t=>{s.nameFormat=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(n=>{n.setPlaceholder("Templates/Daily note"),n.setValue(s.templateFile),n.onChange(t=>{s.templateFile=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(n=>{n.setPlaceholder("daily-note"),n.setValue(s.typeProperty),n.onChange(t=>{s.typeProperty=t,this.saveAndRefresh()})})}renderRecentTab(e){new w.Setting(e).setName("Max items").setDesc("Maximum number of recent files to track.").addText(t=>{t.inputEl.setAttr("type","number"),t.inputEl.setAttr("placeholder","50"),t.setValue(String(this.settings.recentFiles.maxItems)),t.inputEl.onblur=()=>{let a=parseInt(t.getValue(),10);!isNaN(a)&&a>0&&(this.settings.recentFiles.maxItems=a,this.saveAndRefresh())}}),new w.Setting(e).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(t=>{t.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(a=>{this.settings.recentFiles.updateOn=a,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(e).setName("OmittLine truncated var Q=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var fe=(p,d)=>{for(var e in d)Q(p,e,{get:d[e],enumerable:!0})},ye=(p,d,e,n)=>{if(d&&typeof d=="object"||typeof d=="function")for(let i of ue(d))!ge.call(p,i)&&i!==e&&Q(p,i,{get:()=>d[i],enumerable:!(n=he(d,i))||n.enumerable});return p};var ve=p=>ye(Q({},"__esModule",{value:!0}),p);var Fe={};fe(Fe,{default:()=>G});module.exports=ve(Fe);var f=require("obsidian");var $={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file",indicatorColor:"#64748b"},T={calendar:{firstDayOfWeek:1,showNoteIndicators:!0,indicatorMode:"systems",dailyIndicatorColor:"#3b82f6"},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},reusePeriodicNoteTabs:!1,weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},dateSystems:[{id:"journal",name:"Journal",folder:"periodic/journal",nameFormat:"YYYY-MM-DD - [Journal]",templateFile:"",typeProperty:"journal",icon:"book-open",indicatorColor:"#22c55e"},{id:"meetings",name:"Meeting",folder:"periodic/meetings",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"meeting",icon:"users",indicatorColor:"#a855f7"}],recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var y=require("obsidian");var oe="{title}";function R(p){let d=p.indexOf(oe);return d<0?{before:p,after:"",hasTitle:!1}:{before:p.slice(0,d),after:p.slice(d+oe.length),hasTitle:!0}}function U(p,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return p.startsWith(e)}function Z(p,d,e,n){return n?!d||p.length<d.length+e.length?!1:p.startsWith(d)&&p.endsWith(e):p===d+e}function re(p,d,e){let n=p.startsWith(d)?d.length:0,i=e&&p.endsWith(e)?p.length-e.length:p.length;return i<=n?p:p.slice(n,i).trim()||p}var ke=/[\\/:*?"<>|#^[\]]/g;function le(p){return p.replace(ke,"-").replace(/\s+/g," ").trim()}function A(p){let{before:d}=R(p),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var z=class extends y.AbstractInputSuggest{constructor(e,n){super(e,n);this.inputEl=n}getSuggestions(e){let n=e.toLowerCase();return this.app.vault.getMarkdownFiles().filter(i=>i.path.toLowerCase().includes(n)).slice(0,200)}renderSuggestion(e,n){n.setText(e.path.replace(/\.md$/,""))}selectSuggestion(e){this.setValue(e.path.replace(/\.md$/,"")),this.inputEl.trigger("input"),this.close()}},V=class extends y.PluginSettingTab{constructor(e,n,i,t){super(e,n);this.activeTab="calendar";this.plugin=n,this.settings=i,this.onSettingsChange=t}display(){let{containerEl:e}=this;e.empty();let n=e.createDiv({cls:"waypoint-settings-tabs"}),i=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"systems",label:"Date systems"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let a of i)n.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===a.key?" is-active":""}`,text:a.label}).addEventListener("click",()=>{this.activeTab=a.key,this.display()});let t=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(t);break;case"periodic":this.renderPeriodicTab(t);break;case"systems":this.renderSystemsTab(t);break;case"recent":this.renderRecentTab(t);break;case"display":this.renderDisplayTab(t);break;case"about":this.renderAboutTab(t);break}}renderCalendarTab(e){new y.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(n=>{n.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(i=>{this.settings.calendar.firstDayOfWeek=parseInt(i,10),this.saveAndRefresh()})}),new y.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(n=>{n.setValue(this.settings.calendar.showNoteIndicators).onChange(i=>{this.settings.calendar.showNoteIndicators=i,this.saveAndRefresh()})}),new y.Setting(e).setName("Indicator style").setDesc("Show one neutral dot for any dated note, or one coloured dot for each configured date system.").addDropdown(n=>{n.addOption("any","Single dot").addOption("systems","Colour by note system").setValue(this.settings.calendar.indicatorMode).onChange(i=>{this.settings.calendar.indicatorMode=i,this.saveAndRefresh()})}),new y.Setting(e).setName("Daily indicator colour").setDesc(Line truncated
\\.png$`),t.setValue(this.settings.recentFiles.omittedPaths.join(` \\.png$`),a.setValue(this.settings.recentFiles.omittedPaths.join(`
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=t.getValue().split(` `)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=a.getValue().split(`
`).filter(a=>a.trim()),this.saveAndRefresh()}});let s=new DocumentFragment;s.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(e).setName("Omitted tags").setDesc(s).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`ignore `).filter(o=>o.trim()),this.saveAndRefresh()}});let i=new DocumentFragment;i.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new y.Setting(e).setName("Omitted tags").setDesc(i).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`ignore
archive`),t.setValue(this.settings.recentFiles.omittedTags.join(` archive`),a.setValue(this.settings.recentFiles.omittedTags.join(`
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=t.getValue().split(` `)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=a.getValue().split(`
`).filter(a=>a.trim()),this.saveAndRefresh()}});let n=new DocumentFragment;n.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new w.Setting(e).setName("Filter tags").setDesc(n).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`meeting `).filter(o=>o.trim()),this.saveAndRefresh()}});let t=new DocumentFragment;t.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new y.Setting(e).setName("Filter tags").setDesc(t).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`meeting
person person
project`),t.setValue(this.settings.recentFiles.filterTags.join(` project`),a.setValue(this.settings.recentFiles.filterTags.join(`
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=t.getValue().split(` `)),a.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=a.getValue().split(`
`).filter(a=>a.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new w.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new w.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(e).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...P.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,i,s,n,t,a,o,r,c){let l=new w.Setting(e).setName(i).setDesc(`${s} (${n[t]}${c})`);l.addSlider(h=>{h.setLimits(a,o,r).setValue(n[t]).setDynamicTooltip().onChange(p=>{n[t]=p,l.setDesc(`${s} (${p}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let i=this.plugin.manifest.version,s=e.createDiv();s.style.display="flex",s.style.alignItems="center",s.style.gap="12px",s.style.marginBottom="16px";let n=s.createDiv();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.width="48px",n.style.height="48px",n.style.borderRadius="12px",n.style.background="var(--interactive-accent)",n.style.color="var(--text-on-accent)",n.style.fontSize="24px",(0,w.setIcon)(n,"compass");let t=s.createDiv(),a=t.createEl("h2",{text:"Waypoint Sidebar"});a.style.margin="0",a.style.lineHeight="1.2";let o=t.createDiv({text:`v${i}`});o.style.color="var(--text-muted)",o.style.fontSize="var(--font-ui-small)";let r=e.createDiv();r.style.marginBottom="20px",r.style.lineHeight="1.6",r.style.color="var(--text-normal)",r.innerHTML=["<p><strong>Waypoint</strong> is a sidebar plugin that brings three essential panels into one view:</p>",'<ul style="padding-left: 20px; margin: 8px 0;">',"<li><strong>Calendar</strong> \u2014 a monthly grid for your periodic notes (daily, weekly, monthly, quarterly, yearly). Click any day, week, or month to open or create the corresponding note.</li>","<li><strong>Recent Files</strong> \u2014 a list of recently opened files with type filtering, drag-and-drop, and right-click actions.</li>","<li><strong>Bookmarks</strong> \u2014 custom bookmarks with icons, groups, nesting, and drag-and-drop reordering. Separate from Obsidian's native bookmarks.</li>","</ul>",'<p style="color: var(--text-muted); font-size: var(--font-ui-small);">Made by Olivier. Licensed under MIT.</p>'].join(` `).filter(o=>o.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new y.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new y.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new y.Setting(e).addButton(n=>n.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...T.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,n,i,t,a,o,s,r,c){let l=new y.Setting(e).setName(n).setDesc(`${i} (${t[a]}${c})`);l.addSlider(m=>{m.setLimits(o,s,r).setValue(t[a]).setDynamicTooltip().onChange(u=>{t[a]=u,l.setDesc(`${i} (${u}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let n=this.plugin.manifest.version,i=e.createDiv();i.style.display="flex",i.style.alignItems="center",i.style.gap="12px",i.style.marginBottom="16px";let t=i.createDiv();t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="48px",t.style.height="48px",t.style.borderRadius="12px",t.style.background="var(--interactive-accent)",t.style.color="var(--text-on-accent)",t.style.fontSize="24px",(0,y.setIcon)(t,"compass");let a=i.createDiv(),o=a.createEl("h2",{text:"Waypoint Sidebar"});o.style.margin="0",o.style.lineHeight="1.2";let s=a.createDiv({text:`v${n}`});s.style.color="var(--text-muted)",s.style.fontSize="var(--font-ui-small)";let r=e.createDiv();r.style.marginBottom="20px",r.style.lineHeight="1.6",r.style.color="var(--text-normal)",r.innerHTML=["<p><strong>Waypoint</strong> is a sidebar plugin that brings three essential panels into one view:</p>",'<ul style="padding-left: 20px; margin: 8px 0;">',"<li><strong>Calendar</strong> \u2014 a monthly grid for your periodic notes (daily, weekly, monthly, quarterly, yearly). Click any day, week, or month to open or create the corresponding note.</li>","<li><strong>Recent Files</strong> \u2014 a list of recently opened files with type filtering, drag-and-drop, and right-click actions.</li>","<li><strong>Bookmarks</strong> \u2014 custom bookmarks with icons, groups, nesting, and drag-and-drop reordering. Separate from Obsidian's native bookmarks.</li>","</ul>",'<p style="color: var(--text-muted); font-size: var(--font-ui-small);">Made by Olivier. Licensed under MIT.</p>'].join(`
`)}};var d=require("obsidian");var I=require("obsidian");function Q(g,m,e){let i=(0,I.moment)({year:g,month:m,day:1}),s=(0,I.moment)(i).endOf("month"),n=(0,I.moment)(i).subtract((i.day()-e+7)%7,"days"),t=(0,I.moment)().startOf("day"),a=[],o=(0,I.moment)(n);for(;o.isBefore(s)||o.month()===m;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,I.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(t,"day"),isCurrentMonth:o.month()===m,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(a.push({weekNumber:r[0].isoWeekNumber,days:r}),a.length>=6)break}return a}var T="waypoint-view";function ae(g){return g.dragManager}var L=class extends d.ItemView{constructor(e,i){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,d.moment)().month();this.currentDisplayYear=(0,d.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=i}getViewType(){return T}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let e=this.contentEl.createDiv({cls:"waypoint-section"});e.createDiv({cls:"waypoint-section-header",text:"Calendar"});let i=e.createDiv({cls:"waypoint-calendar"}),s=(0,d.moment)(),n=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),t=i.createDiv({cls:"waypoint-calendar-top"}),a=t.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=n.format("[Q]Q"),r=a.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",n)}),r.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("quarter",n,this.app.workspace.getLeaf("tab")))});let c=n.format("MMMM"),l=a.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",n)}),l.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("month",n,this.app.workspace.getLeaf("tab")))});let h=n.format("YYYY"),p=a.createSpan({cls:"waypoint-clickable",text:h});p.addEventListener("click",()=>{this.plugin.openPeriodNote("year",n)}),p.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("year",n,this.app.workspace.getLeaf("tab")))});let u=t.createDiv({cls:"waypoint-calendar-today-group"}),D=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(D,"chevron-left"),D.addEventListener("click",()=>this.navigateMonth(-1)),u.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,d.moment)().month(),this.currentDisplayYear=(0,d.moment)().year(),this.redraw()});let k=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(k,"chevron-right"),k.addEventListener("click",()=>this.navigateMonth(1));let b=i.createEl("table"),f=b.createEl("thead").createEl("tr");f.createEl("th",{text:""});let C=["sun","mon","tue","wed","thu","fri","sat"],$=this.plugin.settings.calendar.firstDayOfWeek;for(let F=0;F<7;F++){let A=($+F)%7;f.createEl("th",{text:C[A]})}let S=b.createEl("tbody"),U=Q(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let F of U){let A=S.createEl("tr"),z=A.createEl("td",{cls:"waypoint-weeknum"});z.setText(String(F.weekNumber));let K=F.days[0].date;z.addEventListener("click",()=>{this.plugin.openPeriodNote("week",K)}),z.addEventListener("mousedown",E=>{E.button===1&&(E.preventDefault(),this.plugin.openPeriodNote("week",K,this.app.workspace.getLeaf("tab")))});for(let E of F.days){let M=A.createEl("td",{cls:"waypoint-day"});if(M.setText(String(E.dayOfMonth)),E.isCurrentMonth||M.addClass("other-month"),E.isToday&&M.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let N=E.date.format("YYYY-MM-DD");this.plugin.hasNoteForDate(N)&&M.addClass("has-note")}M.addEventListener("click",()=>{this.plugin.openPeriodNote("day",E.date)}),M.addEventListener("mousedown",N=>{N.button===1&&(N.preventDefault(),this.plugin.openPeriodNote("day",E.date,this.app.workspace.getLeaf("tab")))})}}}navigateMonth(e){let i=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(e,"month");this.currentDisplayMonth=i.month(),this.currentDisplayYear=i.year(),this.redraw()}renderRecentFiles(){var r,c;let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(e.createDiv({cls:"waypoint-section-header",text:"Re Line truncated `)}};var h=require("obsidian");var C=require("obsidian");function ce(p,d,e){let n=(0,C.moment)({year:p,month:d,day:1}),i=(0,C.moment)(n).endOf("month"),t=(0,C.moment)(n).subtract((n.day()-e+7)%7,"days"),a=(0,C.moment)().startOf("day"),o=[],s=(0,C.moment)(t);for(;s.isBefore(i)||s.month()===d;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,C.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(a,"day"),isCurrentMonth:s.month()===d,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(o.push({weekNumber:r[0].isoWeekNumber,days:r}),o.length>=6)break}return o}var E="waypoint-view";function we(p){return p.dragManager}var W=class extends h.ItemView{constructor(e,n){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=n}getViewType(){return E}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let n=this.contentEl.createDiv({cls:"waypoint-section"}).createDiv({cls:"waypoint-calendar"}),i=(0,h.moment)(),t=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),a=n.createDiv({cls:"waypoint-calendar-top"}),o=a.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=t.format("[Q]Q"),r=o.createSpan({cls:"waypoint-clickable",text:s});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",t)}),r.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("quarter",t,this.app.workspace.getLeaf("tab")))});let c=t.format("MMMM"),l=o.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",t)}),l.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("month",t,this.app.workspace.getLeaf("tab")))});let m=t.format("YYYY"),u=o.createSpan({cls:"waypoint-clickable",text:m});u.addEventListener("click",()=>{this.plugin.openPeriodNote("year",t)}),u.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("year",t,this.app.workspace.getLeaf("tab")))});let g=a.createDiv({cls:"waypoint-calendar-today-group"}),S=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(S,"chevron-left"),S.addEventListener("click",()=>this.navigateMonth(-1)),g.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,h.moment)().month(),this.currentDisplayYear=(0,h.moment)().year(),this.redraw()});let w=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(w,"chevron-right"),w.addEventListener("click",()=>this.navigateMonth(1));let b=n.createEl("table"),v=b.createEl("thead").createEl("tr");v.createEl("th",{text:""});let L=["sun","mon","tue","wed","thu","fri","sat"],K=this.plugin.settings.calendar.firstDayOfWeek;for(let D=0;D<7;D++){let N=(K+D)%7;v.createEl("th",{text:L[N]})}let P=b.createEl("tbody"),te=ce(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek),_=this.plugin.settings.calendar.showNoteIndicators&&this.plugin.settings.calendar.indicatorMode==="systems"?this.plugin.getDateSystemIndicators(te.reduce((D,N)=>D.concat(N.days.map(Y=>Y.date)),[])):null;for(let D of te){let N=P.createEl("tr"),Y=N.createEl("td",{cls:"waypoint-weeknum"});Y.setText(String(D.weekNumber));let ie=D.days[0].date;Y.addEventListener("click",()=>{this.plugin.openPeriodNote("week",ie)}),Y.addEventListener("mousedown",x=>{x.button===1&&(x.preventDefault(),this.plugin.openPeriodNote("week",ie,this.app.workspace.getLeaf("tab")))});for(let x of D.days){let I=N.createEl("td",{cls:"waypoint-day"});if(I.setText(String(x.dayOfMonth)),x.isCurrentMonth||I.addClass("other-month"),x.isToday&&I.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let M=x.date.format("YYYY-MM-DD");if(this.plugin.settings.calendar.indicatorMode==="any")this.plugin.hasNoteForDate(M)&&I.addClass("has-note");else{let ne=(_==null?void 0:_.get(M))||[];if(ne.length>0){let me=I.createDiv({cls:"waypoint-day-indicators"});for(let ae of ne){let se=me.createSpan({cls:"waypoint-day-indicator"});se.style.setProperty("--waypoint-indicator-color",ae.color),(0,h.setTooltip)(se,ae.name)}}}}I.addEventListener("click",()=>{this.plugin.openPeriodNote("day",x.date)}),I.addEventListener("mousedown",M=>{M. Line truncated
${j(p)} ${ee(m)}
Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,B),null}let r=i.templateFile,c=this.resolveTemplateFile(r),l;if(c)try{l=await this.app.vault.read(c)}catch(p){return new y.Notice(`Waypoint: could not read the template "${c.path}" for the ${t} note. Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,O),null}let s=n.templateFile,r=this.resolveTemplateFile(s),c;if(r)try{c=await this.app.vault.read(r)}catch(m){return new f.Notice(`Waypoint: could not read the template "${r.path}" for the ${t} note.
`+j(p),B),null}else l=`--- `+ee(m),O),null}else c=`---
type: ${i.typeProperty} type: ${n.typeProperty}
date: ${s.format("YYYY-MM-DD")} date: ${i.format("YYYY-MM-DD")}
--- ---
`;let h;try{h=await this.app.vault.create(e,l)}catch(p){return new y.Notice(`Waypoint: could not create the ${t} note at "${e}". `;let l;try{l=await this.app.vault.create(e,c)}catch(m){return new f.Notice(`Waypoint: could not create the ${t} note at "${e}".
${j(p)}`,B),null}return r&&!c?new y.Notice(`Created ${t} note: ${h.basename} ${ee(m)}`,O),null}return s&&!r?new f.Notice(`Created ${t} note: ${l.basename}
Template "${r}" was not found, so a basic note was created instead.`,B):new y.Notice(`Created ${t} note: ${h.basename}`),h}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof y.TFolder)return;let i="";for(let s of e.split("/"))if(s&&(i=i?`${i}/${s}`:s,!(this.app.vault.getAbstractFileByPath(i)instanceof y.TFolder)))try{await this.app.vault.createFolder(i)}catch(n){if(!(this.app.vault.getAbstractFileByPath(i)instanceof y.TFolder))throw n}}resolveTemplateFile(e){if(!e)return null;let i=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(i)}detectPeriodType(e){for(let i of _){let s=this.settings[Y[i].key].nameFormat;if(!s)continue;let n=(0,y.moment)(e,s,!0);if(n.isValid())return{period:i,date:n}}return null}async navigatePeriodNote(e){let i=this.app.workspace.getActiveFile();if(!i){new y.Notice("No active file");return}let s=this.detectPeriodType(i.basename);if(!s){let r=_.map(c=>`${Y[c].label.toLowerCase()} "${this.settings[Y[c].key].nameFormat}"`).join(", ");new y.Notice(`Waypoint: "${i.basename}" does not match any configured periodic note format. Template "${s}" was not found, so a basic note was created instead.`,O):new f.Notice(`Created ${t} note: ${l.basename}`),l}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof f.TFolder)return;let n="";for(let i of e.split("/"))if(i&&(n=n?`${n}/${i}`:i,!(this.app.vault.getAbstractFileByPath(n)instanceof f.TFolder)))try{await this.app.vault.createFolder(n)}catch(t){if(!(this.app.vault.getAbstractFileByPath(n)instanceof f.TFolder))throw t}}resolveTemplateFile(e){if(!e)return null;let n=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(n)}detectPeriodType(e){for(let n of de){let i=this.settings[j[n].key].nameFormat;if(!i)continue;let t=(0,f.moment)(e,i,!0);if(t.isValid())return{period:n,date:t}}return null}async navigatePeriodNote(e){let n=this.app.workspace.getActiveFile();if(!n){new f.Notice("No active file");return}let i=this.detectPeriodType(n.basename);if(!i){let r=de.map(c=>`${j[c].label.toLowerCase()} "${this.settings[j[c].key].nameFormat}"`).join(", ");new f.Notice(`Waypoint: "${n.basename}" does not match any configured periodic note format.
Expected one of: ${r}.`,B);return}let{period:n,date:t}=s,a=e==="next"?1:-1,o=n==="quarter"?t.clone().add(a*3,"months"):t.clone().add(a,`${n}s`);await this.openPeriodNote(n,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(T);for(let i of e)i.view instanceof L&&i.view.redraw()}},re=["daily","weekly","monthly","quarterly","yearly"],Y={day:{key:"daily",label:"Daily"},week:{key:"weekly",label:"Weekly"},month:{key:"monthly",label:"Monthly"},quarter:{key:"quarterly",label:"Quarterly"},year:{key:"yearly",label:"Yearly"}},_=["day","week","month","quarter","year"];function Z(g){return g.slice(g.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var B=1e4;function j(g){return g instanceof Error?g.message:String(g)} Expected one of: ${r}.`,O);return}let{period:t,date:a}=i,o=e==="next"?1:-1,s=t==="quarter"?a.clone().add(o*3,"months"):a.clone().add(o,`${t}s`);await this.openPeriodNote(t,s)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(E);for(let n of e)n.view instanceof W&&n.view.redraw()}},Se=["daily","weekly","monthly","quarterly","yearly"],j={day:{key:"daily",label:"Daily"},week:{key:"weekly",label:"Weekly"},month:{key:"monthly",label:"Monthly"},quarter:{key:"quarterly",label:"Quarterly"},year:{key:"yearly",label:"Yearly"}},de=["day","week","month","quarter","year"];function pe(p){return p.slice(p.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var O=1e4;function ee(p){return p instanceof Error?p.message:String(p)}function B(p,d){return d?p.format(d):""}
+2 -2
View File
@@ -1,8 +1,8 @@
{ {
"id": "waypoint-sidebar", "id": "waypoint-sidebar",
"name": "Waypoint Sidebar", "name": "Waypoint Sidebar",
"version": "1.5.2", "version": "1.8.0",
"minAppVersion": "1.4.4", "minAppVersion": "1.4.10",
"description": "Calendar, recent files, and custom bookmarks sidebar.", "description": "Calendar, recent files, and custom bookmarks sidebar.",
"author": "Olivier", "author": "Olivier",
"isDesktopOnly": false "isDesktopOnly": false
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "waypoint", "name": "waypoint",
"version": "1.5.1", "version": "1.8.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "waypoint", "name": "waypoint",
"version": "1.5.1", "version": "1.8.0",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"builtin-modules": "4.0.0", "builtin-modules": "4.0.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "waypoint", "name": "waypoint",
"version": "1.5.2", "version": "1.8.0",
"description": "Calendar, recent files, and custom bookmarks sidebar.", "description": "Calendar, recent files, and custom bookmarks sidebar.",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
+301 -23
View File
@@ -10,14 +10,45 @@ import {
getAllTags, getAllTags,
moment, moment,
} from 'obsidian'; } from 'obsidian';
import { WaypointSettings, DEFAULT_SETTINGS, PeriodNoteSettings } from 'src/settings'; import { WaypointSettings, DEFAULT_SETTINGS, DateSystemSettings, DEFAULT_DATE_SYSTEM } from 'src/settings';
import { WaypointSettingTab } from 'src/settings-tab'; import { WaypointSettingTab } from 'src/settings-tab';
import { WaypointView, WAYPOINT_VIEW_TYPE } from 'src/views/waypoint-view'; import { WaypointView, WAYPOINT_VIEW_TYPE } from 'src/views/waypoint-view';
import { BookmarkItem, WaypointData } from 'src/models/bookmark'; import { BookmarkItem, WaypointData } from 'src/models/bookmark';
import { remapRenamedPath } from 'src/utils/path-utils'; import { remapRenamedPath } from 'src/utils/path-utils';
import {
splitNameFormat,
isInFolder,
matchesSystemName,
titleFromBasename,
sanitizeTitle,
formatHasDateToken,
} from 'src/utils/date-systems';
export type PeriodKey = 'day' | 'week' | 'month' | 'quarter' | 'year'; export type PeriodKey = 'day' | 'week' | 'month' | 'quarter' | 'year';
/** One existing note of a date system, with the label the menu should show. */
export interface DateSystemNote {
file: TFile;
/** Free-text title for many-per-date systems, else the system name. */
label: string;
}
/** A day-scoped system and the notes it already holds for one date. */
export interface DateSystemNotes {
system: DateSystemSettings;
/** Sorted by basename. Empty when the date has no note in this system. */
notes: DateSystemNote[];
/** True when nameFormat carries {title}, i.e. many notes per date. */
multiple: boolean;
}
/** One coloured calendar marker for a date system that has a note on a day. */
export interface DateSystemIndicator {
id: string;
name: string;
color: string;
}
export default class WaypointPlugin extends Plugin { export default class WaypointPlugin extends Plugin {
public settings: WaypointSettings; public settings: WaypointSettings;
public waypointData: WaypointData; public waypointData: WaypointData;
@@ -27,14 +58,29 @@ export default class WaypointPlugin extends Plugin {
private savePromise: Promise<void> = Promise.resolve(); private savePromise: Promise<void> = Promise.resolve();
/** Basenames of every markdown file in the vault, for O(1) calendar lookups. */ /** Basenames of every markdown file in the vault, for O(1) calendar lookups. */
private markdownBasenames: Set<string> = new Set(); private markdownBasenames: Set<string> = new Set();
/** Results for the displayed month; invalidated by markdown-file changes. */
private dateSystemIndicators: Map<string, DateSystemIndicator[]> | null = null;
private dateSystemIndicatorKey = '';
/**
* True once `data.json` carries the post-migration schema. Set on every
* load and included in every save, so a single migration run is durable
* even if this session never triggers another settings write.
*/
private indicatorModeMigrated = false;
async onload(): Promise<void> { async onload(): Promise<void> {
console.debug('Waypoint: loading plugin v' + this.manifest.version); console.debug('Waypoint: loading plugin v' + this.manifest.version);
// Load persisted data — data.json is read exactly once here. // Load persisted data — data.json is read exactly once here.
const saved = await this.loadData() as Record<string, unknown> | null; const saved = await this.loadData() as Record<string, unknown> | null;
this.applySettings(saved); const migrated = this.applySettings(saved);
this.applyWaypointData(saved); this.applyWaypointData(saved);
if (migrated) {
// Persist immediately: an install that only ever reads data.json
// (never changes a setting or bookmark this session) must still
// keep the migrated value instead of re-migrating every load.
void this.persistAll();
}
// Register the sidebar view // Register the sidebar view
this.registerView( this.registerView(
@@ -49,6 +95,7 @@ export default class WaypointPlugin extends Plugin {
this.settings, this.settings,
() => { () => {
this.enforceRecentFilesLimit(); this.enforceRecentFilesLimit();
this.invalidateDateSystemIndicators();
this.redrawAll(); this.redrawAll();
}, },
)); ));
@@ -210,9 +257,11 @@ export default class WaypointPlugin extends Plugin {
/** /**
* Merge persisted settings over the defaults. Nested objects are merged * Merge persisted settings over the defaults. Nested objects are merged
* individually so existing configs keep their values while picking up * individually so existing configs keep their values while picking up
* fields added in newer versions. * fields added in newer versions. Returns true the one time a one-off
* migration (see `indicatorModeMigrated` below) actually changes a value,
* so the caller can persist that change immediately.
*/ */
private applySettings(saved: Record<string, unknown> | null): void { private applySettings(saved: Record<string, unknown> | null): boolean {
const s = (saved?.settings || {}) as Partial<WaypointSettings>; const s = (saved?.settings || {}) as Partial<WaypointSettings>;
this.settings = Object.assign({}, DEFAULT_SETTINGS, s); this.settings = Object.assign({}, DEFAULT_SETTINGS, s);
this.settings.recentFiles = Object.assign({}, DEFAULT_SETTINGS.recentFiles, s.recentFiles || {}); this.settings.recentFiles = Object.assign({}, DEFAULT_SETTINGS.recentFiles, s.recentFiles || {});
@@ -221,6 +270,33 @@ export default class WaypointPlugin extends Plugin {
for (const key of PERIOD_SETTING_KEYS) { for (const key of PERIOD_SETTING_KEYS) {
this.settings[key] = Object.assign({}, DEFAULT_SETTINGS[key], s[key] || {}); this.settings[key] = Object.assign({}, DEFAULT_SETTINGS[key], s[key] || {});
} }
// Cloned, not Object.assign'd in: the defaults array would otherwise be
// aliased into the live settings and the settings UI would edit
// DEFAULT_DATE_SYSTEM so older configs pick up fields added since. Known
// built-ins use their own defaults too, preserving Journal/Meeting colours
// when this field is first introduced.
this.settings.dateSystems = Array.isArray(s.dateSystems)
? s.dateSystems.map(sys => {
const builtIn = DEFAULT_SETTINGS.dateSystems.find(defaultSystem => defaultSystem.id === sys.id);
return Object.assign({}, builtIn || DEFAULT_DATE_SYSTEM, sys);
})
: DEFAULT_SETTINGS.dateSystems.map(sys => Object.assign({}, sys));
// `indicatorMode` shipped with a default of 'any' before per-system
// colours existed, so every install that loaded before that default
// changed silently persisted 'any' to disk as if it were a deliberate
// choice — changing DEFAULT_SETTINGS alone can never reach an install
// that already has an explicit value on disk. Promote that one-time
// default to the current default exactly once; any choice made after
// this flag is set is real and must never be touched again.
const alreadyMigrated = saved?.indicatorModeMigrated === true;
let didMigrateValue = false;
if (!alreadyMigrated && s.calendar?.indicatorMode === 'any') {
this.settings.calendar.indicatorMode = 'systems';
didMigrateValue = true;
}
this.indicatorModeMigrated = true;
return didMigrateValue;
} }
private applyWaypointData(saved: Record<string, unknown> | null): void { private applyWaypointData(saved: Record<string, unknown> | null): void {
@@ -255,6 +331,7 @@ export default class WaypointPlugin extends Plugin {
return this.saveData({ return this.saveData({
settings: this.settings, settings: this.settings,
waypointData: this.waypointData, waypointData: this.waypointData,
indicatorModeMigrated: this.indicatorModeMigrated,
}); });
}); });
// Keep the queue usable after a failed write without leaving an // Keep the queue usable after a failed write without leaving an
@@ -361,6 +438,7 @@ export default class WaypointPlugin extends Plugin {
* inside a renamed folder. * inside a renamed folder.
*/ */
private onRename(file: TAbstractFile, oldPath: string): void { private onRename(file: TAbstractFile, oldPath: string): void {
this.invalidateDateSystemIndicators();
const indexChanged = this.syncIndexForRename(file, oldPath); const indexChanged = this.syncIndexForRename(file, oldPath);
let dataChanged = false; let dataChanged = false;
@@ -396,6 +474,7 @@ export default class WaypointPlugin extends Plugin {
private onVaultCreate(file: TAbstractFile): void { private onVaultCreate(file: TAbstractFile): void {
if (file instanceof TFile && file.extension === 'md') { if (file instanceof TFile && file.extension === 'md') {
this.markdownBasenames.add(file.basename); this.markdownBasenames.add(file.basename);
this.invalidateDateSystemIndicators();
} }
this.broadcastRedraw(); this.broadcastRedraw();
} }
@@ -403,6 +482,7 @@ export default class WaypointPlugin extends Plugin {
private onVaultDelete(file: TAbstractFile): void { private onVaultDelete(file: TAbstractFile): void {
if (file instanceof TFile && file.extension === 'md') { if (file instanceof TFile && file.extension === 'md') {
this.removeFromMarkdownIndex(file.basename, file.path); this.removeFromMarkdownIndex(file.basename, file.path);
this.invalidateDateSystemIndicators();
} }
this.broadcastRedraw(); this.broadcastRedraw();
} }
@@ -416,6 +496,12 @@ export default class WaypointPlugin extends Plugin {
} }
} }
/** Forget a month result when markdown paths or date-system settings change. */
private invalidateDateSystemIndicators(): void {
this.dateSystemIndicators = null;
this.dateSystemIndicatorKey = '';
}
/** /**
* Drop a basename from the index, unless another markdown file still * Drop a basename from the index, unless another markdown file still
* carries it. `path` is excluded from that check because the vault may not * carries it. `path` is excluded from that check because the vault may not
@@ -510,44 +596,227 @@ export default class WaypointPlugin extends Plugin {
} }
} }
// ── Period note creation/opening ── // ── Date systems: discovery, creation, opening ──
/** /** Periodic notes are date systems with a fixed one-note-per-period format. */
* Open (creating if needed) the period note for `date`. private periodAsDateSystem(period: PeriodKey): DateSystemSettings {
* Opens in `leaf` when given, otherwise in the active leaf.
*/
async openPeriodNote(period: PeriodKey, date: moment.Moment, leaf?: WorkspaceLeaf): Promise<void> {
const config = PERIOD_CONFIGS[period]; const config = PERIOD_CONFIGS[period];
const periodSettings = this.settings[config.key]; const periodSettings = this.settings[config.key];
const filename = date.format(periodSettings.nameFormat) + '.md'; return {
const fullPath = periodSettings.folder id: config.key,
? `${periodSettings.folder}/${filename}` name: config.label,
: filename; folder: periodSettings.folder,
nameFormat: periodSettings.nameFormat,
templateFile: periodSettings.templateFile,
typeProperty: periodSettings.typeProperty,
icon: 'calendar',
indicatorColor: this.settings.calendar.dailyIndicatorColor,
};
}
/** All day-scoped systems: the daily periodic note first, then settings.dateSystems. */
dateSystems(): DateSystemSettings[] {
return [this.periodAsDateSystem('day'), ...this.settings.dateSystems];
}
/**
* Bucket the notes every day-scoped system already holds for `date`.
*
* One vault scan serves all systems at once. That is affordable because
* this runs once per right-click, not once per calendar cell, and it keeps
* arbitrary user-defined name formats out of the incremental index.
*/
findDateSystemNotes(date: moment.Moment): DateSystemNotes[] {
const buckets = this.dateSystems().map(system => {
const parts = splitNameFormat(system.nameFormat);
return {
result: { system, notes: [] as DateSystemNote[], multiple: parts.hasTitle },
// Each half is formatted on its own: the raw format may still
// hold {title}, whose letters are live moment tokens.
before: formatDatePart(date, parts.before),
after: formatDatePart(date, parts.after),
hasTitle: parts.hasTitle,
// Empty/date-less formats have no date-specific filename. They stay
// editable in Settings but must not contribute a menu action.
skip: !formatHasDateToken(system.nameFormat),
};
});
for (const file of this.app.vault.getMarkdownFiles()) {
for (const bucket of buckets) {
if (bucket.skip) continue;
const system = bucket.result.system;
if (!isInFolder(file.path, system.folder)) continue;
if (!matchesSystemName(file.basename, bucket.before, bucket.after, bucket.hasTitle)) continue;
bucket.result.notes.push({
file,
label: bucket.hasTitle
? titleFromBasename(file.basename, bucket.before, bucket.after)
: system.name,
});
}
}
for (const bucket of buckets) {
bucket.result.notes.sort((a, b) => a.file.basename.localeCompare(b.file.basename));
}
return buckets
.filter(bucket => !bucket.skip)
.map(bucket => bucket.result);
}
/**
* Return one coloured indicator per system with a note on each requested day.
*
* The day grid calls this once per render. Its result is cached by the
* displayed dates and system settings, then invalidated by file changes, so
* a 42-cell calendar never repeats the vault scan per cell or per redraw.
*/
getDateSystemIndicators(dates: moment.Moment[]): Map<string, DateSystemIndicator[]> {
const dateStrings = dates.map(date => date.format('YYYY-MM-DD'));
const systems = this.dateSystems()
.filter(system => formatHasDateToken(system.nameFormat))
.map(system => {
const parts = splitNameFormat(system.nameFormat);
return {
system,
hasTitle: parts.hasTitle,
dates: dates.map((date, index) => ({
dateStr: dateStrings[index],
before: formatDatePart(date, parts.before),
after: formatDatePart(date, parts.after),
})),
};
});
const key = JSON.stringify({
dates: dateStrings,
systems: systems.map(({ system }) => [
system.id,
system.name,
system.folder,
system.nameFormat,
system.indicatorColor,
]),
});
if (this.dateSystemIndicators && this.dateSystemIndicatorKey === key) {
return this.dateSystemIndicators;
}
const matchingIds = new Map<string, Set<string>>();
for (const dateStr of dateStrings) matchingIds.set(dateStr, new Set());
// The only vault traversal: filter a file by system folder first, then
// test it against the month's at-most-42 formatted day patterns.
for (const file of this.app.vault.getMarkdownFiles()) {
for (const entry of systems) {
if (!isInFolder(file.path, entry.system.folder)) continue;
for (const match of entry.dates) {
if (matchesSystemName(file.basename, match.before, match.after, entry.hasTitle)) {
matchingIds.get(match.dateStr)?.add(entry.system.id);
}
}
}
}
const result = new Map<string, DateSystemIndicator[]>();
for (const dateStr of dateStrings) {
const ids = matchingIds.get(dateStr);
result.set(dateStr, systems
.filter(({ system }) => ids?.has(system.id))
.map(({ system }) => ({
id: system.id,
name: system.name,
color: system.indicatorColor,
})));
}
this.dateSystemIndicatorKey = key;
this.dateSystemIndicators = result;
return result;
}
/**
* Open (creating if needed) the note `system` holds for `date`.
*
* `opts.title` fills the `{title}` token of a many-per-date system and is
* ignored by systems without one. An explicit `opts.leaf` takes precedence;
* otherwise `opts.reuseExistingLeaf` reveals an open Markdown tab for the
* exact file path, falling back to the active leaf when none is open.
*/
async openDateSystemNote(
system: DateSystemSettings,
date: moment.Moment,
opts?: { title?: string; leaf?: WorkspaceLeaf; reuseExistingLeaf?: boolean },
): Promise<void> {
if (!formatHasDateToken(system.nameFormat)) {
new Notice(`Waypoint: ${system.name || 'This'} name format needs a date placeholder.`);
return;
}
const parts = splitNameFormat(system.nameFormat);
const before = formatDatePart(date, parts.before);
const after = formatDatePart(date, parts.after);
let basename: string;
if (parts.hasTitle) {
const title = sanitizeTitle(opts?.title || '');
// Public method, so a caller can legitimately hand us nothing;
// creating "2026-09-07 - .md" would be worse than refusing.
if (!title) {
new Notice(`Waypoint: a ${system.name.toLowerCase()} note needs a title.`);
return;
}
basename = before + title + after;
} else {
basename = before + after;
}
const fullPath = system.folder ? `${system.folder}/${basename}.md` : `${basename}.md`;
let file = this.app.vault.getFileByPath(fullPath); let file = this.app.vault.getFileByPath(fullPath);
if (!file) { if (!file) {
file = await this.createPeriodNote(fullPath, periodSettings, date, config.label); file = await this.createDatedNote(fullPath, system, date);
if (!file) return; if (!file) return;
} }
const target = leaf || this.app.workspace.getLeaf(false); if (opts?.reuseExistingLeaf && !opts.leaf) {
// View state also identifies deferred tabs whose view is not loaded yet.
const existing = this.app.workspace.getLeavesOfType('markdown')
.find(leaf => leaf.getViewState().state?.file === file.path);
if (existing) {
await this.app.workspace.revealLeaf(existing);
this.app.workspace.setActiveLeaf(existing, { focus: true });
return;
}
}
const target = opts?.leaf || this.app.workspace.getLeaf(false);
await target.openFile(file); await target.openFile(file);
} }
/** /**
* Create a period note from its template, or from minimal frontmatter. * Open (creating if needed) the period note for `date`.
* An explicit `leaf` wins; otherwise reuse an open tab when enabled.
*/
async openPeriodNote(period: PeriodKey, date: moment.Moment, leaf?: WorkspaceLeaf): Promise<void> {
await this.openDateSystemNote(this.periodAsDateSystem(period), date, {
leaf,
reuseExistingLeaf: this.settings.reusePeriodicNoteTabs,
});
}
/**
* Create a date system's note from its template, or from minimal frontmatter.
* *
* Every failure path names the offending path and the reason: the usual * Every failure path names the offending path and the reason: the usual
* cause is a configured folder that does not exist yet, which `vault.create` * cause is a configured folder that does not exist yet, which `vault.create`
* refuses outright rather than creating. * refuses outright rather than creating.
*/ */
private async createPeriodNote( private async createDatedNote(
fullPath: string, fullPath: string,
periodSettings: PeriodNoteSettings, system: DateSystemSettings,
date: moment.Moment, date: moment.Moment,
label: string,
): Promise<TFile | null> { ): Promise<TFile | null> {
const noun = label.toLowerCase(); const noun = system.name.toLowerCase();
const slash = fullPath.lastIndexOf('/'); const slash = fullPath.lastIndexOf('/');
const folder = slash < 0 ? '' : fullPath.slice(0, slash); const folder = slash < 0 ? '' : fullPath.slice(0, slash);
@@ -563,7 +832,7 @@ export default class WaypointPlugin extends Plugin {
return null; return null;
} }
const configuredTemplate = periodSettings.templateFile; const configuredTemplate = system.templateFile;
const templateFile = this.resolveTemplateFile(configuredTemplate); const templateFile = this.resolveTemplateFile(configuredTemplate);
let content: string; let content: string;
@@ -579,7 +848,7 @@ export default class WaypointPlugin extends Plugin {
return null; return null;
} }
} else { } else {
content = `---\ntype: ${periodSettings.typeProperty}\ndate: ${date.format('YYYY-MM-DD')}\n---\n\n`; content = `---\ntype: ${system.typeProperty}\ndate: ${date.format('YYYY-MM-DD')}\n---\n\n`;
} }
let file: TFile; let file: TFile;
@@ -733,3 +1002,12 @@ const DIAGNOSTIC_NOTICE_MS = 10000;
function describeError(err: unknown): string { function describeError(err: unknown): string {
return err instanceof Error ? err.message : String(err); return err instanceof Error ? err.message : String(err);
} }
/**
* Format one half of a split name format. Moment falls back to its default
* ISO output when handed an empty format string, so an empty half must never
* reach it.
*/
function formatDatePart(date: moment.Moment, part: string): string {
return part ? date.format(part) : '';
}
+221 -4
View File
@@ -1,12 +1,41 @@
import { Setting, PluginSettingTab, App, setIcon } from 'obsidian'; import { Setting, PluginSettingTab, App, setIcon, AbstractInputSuggest, TFile } from 'obsidian';
import type WaypointPlugin from 'src/main'; import type WaypointPlugin from 'src/main';
import { WaypointSettings, DEFAULT_SETTINGS, PeriodNoteSettings } from 'src/settings'; import { WaypointSettings, DEFAULT_SETTINGS, DEFAULT_DATE_SYSTEM, PeriodNoteSettings } from 'src/settings';
import { formatHasDateToken } from 'src/utils/date-systems';
/**
* Vault-wide Markdown-file suggester for template-path fields, matching
* Obsidian's native suggest popup (same base class Templater's own template
* pickers use) rather than the browser's unstyled `<datalist>` dropdown.
*/
class TemplateFileSuggest extends AbstractInputSuggest<TFile> {
constructor(app: App, private inputEl: HTMLInputElement) {
super(app, inputEl);
}
getSuggestions(query: string): TFile[] {
const q = query.toLowerCase();
return this.app.vault.getMarkdownFiles()
.filter(file => file.path.toLowerCase().includes(q))
.slice(0, 200);
}
renderSuggestion(file: TFile, el: HTMLElement): void {
el.setText(file.path.replace(/\.md$/, ''));
}
selectSuggestion(file: TFile): void {
this.setValue(file.path.replace(/\.md$/, ''));
this.inputEl.trigger('input');
this.close();
}
}
export class WaypointSettingTab extends PluginSettingTab { export class WaypointSettingTab extends PluginSettingTab {
private plugin: WaypointPlugin; private plugin: WaypointPlugin;
private settings: WaypointSettings; private settings: WaypointSettings;
private onSettingsChange: () => void; private onSettingsChange: () => void;
private activeTab: 'calendar' | 'periodic' | 'recent' | 'display' | 'about' = 'calendar'; private activeTab: 'calendar' | 'periodic' | 'systems' | 'recent' | 'display' | 'about' = 'calendar';
constructor(app: App, plugin: WaypointPlugin, settings: WaypointSettings, onSettingsChange: () => void) { constructor(app: App, plugin: WaypointPlugin, settings: WaypointSettings, onSettingsChange: () => void) {
super(app, plugin); super(app, plugin);
@@ -24,6 +53,7 @@ export class WaypointSettingTab extends PluginSettingTab {
const tabs = [ const tabs = [
{ key: 'calendar' as const, label: 'Calendar' }, { key: 'calendar' as const, label: 'Calendar' },
{ key: 'periodic' as const, label: 'Periodic Notes' }, { key: 'periodic' as const, label: 'Periodic Notes' },
{ key: 'systems' as const, label: 'Date systems' },
{ key: 'recent' as const, label: 'Recent Files' }, { key: 'recent' as const, label: 'Recent Files' },
{ key: 'display' as const, label: 'Display' }, { key: 'display' as const, label: 'Display' },
{ key: 'about' as const, label: 'About' }, { key: 'about' as const, label: 'About' },
@@ -49,6 +79,9 @@ export class WaypointSettingTab extends PluginSettingTab {
case 'periodic': case 'periodic':
this.renderPeriodicTab(tabContent); this.renderPeriodicTab(tabContent);
break; break;
case 'systems':
this.renderSystemsTab(tabContent);
break;
case 'recent': case 'recent':
this.renderRecentTab(tabContent); this.renderRecentTab(tabContent);
break; break;
@@ -91,6 +124,32 @@ export class WaypointSettingTab extends PluginSettingTab {
this.saveAndRefresh(); this.saveAndRefresh();
}); });
}); });
new Setting(container)
.setName('Indicator style')
.setDesc('Show one neutral dot for any dated note, or one coloured dot for each configured date system.')
.addDropdown((dropdown) => {
dropdown
.addOption('any', 'Single dot')
.addOption('systems', 'Colour by note system')
.setValue(this.settings.calendar.indicatorMode)
.onChange((value: 'any' | 'systems') => {
this.settings.calendar.indicatorMode = value;
this.saveAndRefresh();
});
});
new Setting(container)
.setName('Daily indicator colour')
.setDesc('Colour for daily-note dots when using “Colour by note system”.')
.addColorPicker((color) => {
color
.setValue(this.settings.calendar.dailyIndicatorColor)
.onChange((value) => {
this.settings.calendar.dailyIndicatorColor = value;
this.saveAndRefresh();
});
});
} }
// ═══════════════════════════════ // ═══════════════════════════════
@@ -98,6 +157,17 @@ export class WaypointSettingTab extends PluginSettingTab {
// ═══════════════════════════════ // ═══════════════════════════════
private renderPeriodicTab(container: HTMLElement): void { private renderPeriodicTab(container: HTMLElement): void {
new Setting(container)
.setName('Use existing tabs')
.setDesc('If a periodic note is already open, switch to its tab instead of opening it again.')
.addToggle((toggle) => {
toggle
.setValue(this.settings.reusePeriodicNoteTabs)
.onChange((value) => {
this.settings.reusePeriodicNoteTabs = value;
this.saveAndRefresh();
});
});
this.addPeriodNoteSettings(container, 'Daily', this.settings.daily); this.addPeriodNoteSettings(container, 'Daily', this.settings.daily);
this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly); this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly);
this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly); this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly);
@@ -134,10 +204,11 @@ export class WaypointSettingTab extends PluginSettingTab {
new Setting(container) new Setting(container)
.setName('Template file') .setName('Template file')
.setDesc(`Path to the template file (without .md extension).`) .setDesc('Path to the template file. The .md extension is optional.')
.addText((text) => { .addText((text) => {
text.setPlaceholder('Templates/Daily note'); text.setPlaceholder('Templates/Daily note');
text.setValue(period.templateFile); text.setValue(period.templateFile);
new TemplateFileSuggest(this.app, text.inputEl);
text.onChange((value) => { text.onChange((value) => {
period.templateFile = value; period.templateFile = value;
this.saveAndRefresh(); this.saveAndRefresh();
@@ -157,6 +228,152 @@ export class WaypointSettingTab extends PluginSettingTab {
}); });
} }
// ═══════════════════════════════
// Date systems tab
// ═══════════════════════════════
private renderSystemsTab(container: HTMLElement): void {
const intro = new DocumentFragment();
intro.createDiv({ text: 'A date system is a folder of notes whose filenames start with a date. Each one appears in the calendar\'s right-click menu for that day.' });
intro.createDiv({ text: 'The daily note is configured under Periodic Notes and always comes first in that menu.' });
intro.createDiv({ text: 'Name format is a moment.js format. Literal words need bracket escaping, e.g. YYYY-MM-DD - [Journal].' });
intro.createDiv({ text: 'Include {title} for systems that hold many notes per date, such as meetings: the text before the token finds the existing notes, and the token marks where a typed title goes. Without it, a date has exactly one note.' });
new Setting(container)
.setHeading()
.setName('Date systems')
.setDesc(intro);
this.settings.dateSystems.forEach((system, i, arr) => {
new Setting(container)
.setHeading()
.setName(system.name || 'Untitled system')
.addExtraButton((btn) => {
btn
.setIcon('arrow-up')
.setTooltip('Move up')
.setDisabled(i === 0)
.onClick(async () => {
if (i === 0) return;
const above = arr[i - 1];
arr[i - 1] = arr[i];
arr[i] = above;
await this.saveAndRefresh();
this.display();
});
})
.addExtraButton((btn) => {
btn
.setIcon('arrow-down')
.setTooltip('Move down')
.setDisabled(i === arr.length - 1)
.onClick(async () => {
if (i === arr.length - 1) return;
const below = arr[i + 1];
arr[i + 1] = arr[i];
arr[i] = below;
await this.saveAndRefresh();
this.display();
});
})
.addExtraButton((btn) => {
btn
.setIcon('trash')
.setTooltip('Delete this date system')
.onClick(async () => {
arr.splice(i, 1);
await this.saveAndRefresh();
this.display();
});
});
this.addSystemTextSetting(container,
'Name', 'Label shown in the calendar right-click menu.',
system, 'name', 'Journal',
);
this.addSystemTextSetting(container,
'Folder', 'Folder these notes live in.',
system, 'folder', 'periodic/journal',
);
const formatSetting = this.addSystemTextSetting(container,
'Name format', 'Filename format (moment.js format). Include {title} for many notes per date.',
system, 'nameFormat', 'YYYY-MM-DD - {title}',
);
// A blank row is still being filled in, so only warn once something was typed.
if (system.nameFormat && !formatHasDateToken(system.nameFormat)) {
formatSetting.descEl.createDiv({
cls: 'waypoint-settings-warning',
text: 'This name format has no date placeholder, so it will never match or create dated notes.',
});
}
this.addSystemTextSetting(container,
'Template file', 'Path to the template file. The .md extension is optional.',
system, 'templateFile', 'resources/template/journal', true,
);
this.addSystemTextSetting(container,
'Type property', `Fallback value for the 'type' frontmatter property, used when no template is found.`,
system, 'typeProperty', 'journal-note',
);
this.addSystemTextSetting(container,
'Icon', 'Lucide icon name for the menu item. Browse names at lucide.dev.',
system, 'icon', 'book-open',
);
new Setting(container)
.setName('Indicator colour')
.setDesc('Colour for this system’s dot when using “Colour by note system”.')
.addColorPicker((color) => {
color
.setValue(system.indicatorColor)
.onChange((value) => {
system.indicatorColor = value;
this.saveAndRefresh();
});
});
});
new Setting(container)
.addButton((btn) =>
btn
.setButtonText('Add date system')
.setCta()
.onClick(async () => {
this.settings.dateSystems.push(Object.assign(
{ id: `ds-${Date.now()}-${Math.random().toString(36).slice(2, 6)}` },
DEFAULT_DATE_SYSTEM,
));
await this.saveAndRefresh();
this.display();
}),
);
}
/** Returns the Setting so callers can append validation notices to its description. */
private addSystemTextSetting<K extends string>(
container: HTMLElement,
name: string,
desc: string,
obj: Record<K, string>,
key: K,
placeholder: string,
suggestTemplates?: boolean,
): Setting {
return new Setting(container)
.setName(name)
.setDesc(desc)
.addText((text) => {
text.setPlaceholder(placeholder);
text.setValue(obj[key]);
if (suggestTemplates) new TemplateFileSuggest(this.app, text.inputEl);
text.onChange((value) => {
obj[key] = value;
this.saveAndRefresh();
});
});
}
// ═══════════════════════════════ // ═══════════════════════════════
// Recent Files tab // Recent Files tab
// ═══════════════════════════════ // ═══════════════════════════════
+68
View File
@@ -7,9 +7,48 @@ export interface PeriodNoteSettings {
typeProperty: string; typeProperty: string;
} }
/**
* A folder of notes whose filenames begin with a date — the vault's "systems":
* daily notes, a journal, meeting notes.
*
* `nameFormat` is a moment format string, so literal text needs bracket
* escaping (`YYYY-MM-DD - [Journal]`). When it contains `{title}` the system
* holds many notes per date and the token marks where the free-text title
* goes; without it a date maps to exactly one filename.
*/
export interface DateSystemSettings {
/** Stable across edits and reordering, so the settings UI can key rows. */
id: string;
/** Shown in the calendar's right-click menu. */
name: string;
folder: string;
nameFormat: string;
templateFile: string;
typeProperty: string;
/** Lucide icon name for the menu item. */
icon: string;
/** CSS colour for this system's calendar indicator. */
indicatorColor: string;
}
/** Field defaults for a newly added system, and the merge base for saved ones. */
export const DEFAULT_DATE_SYSTEM: Omit<DateSystemSettings, 'id'> = {
name: '',
folder: '',
nameFormat: 'YYYY-MM-DD - {title}',
templateFile: '',
typeProperty: '',
icon: 'file',
indicatorColor: '#64748b',
};
export interface CalendarSettings { export interface CalendarSettings {
firstDayOfWeek: number; // 0=Sunday, 1=Monday firstDayOfWeek: number; // 0=Sunday, 1=Monday
showNoteIndicators: boolean; showNoteIndicators: boolean;
/** Single neutral dot, or a dot per day-scoped date system. */
indicatorMode: 'any' | 'systems';
/** Colour used by the synthesized daily system in `systems` mode. */
dailyIndicatorColor: string;
} }
export interface RecentFilesSettings { export interface RecentFilesSettings {
@@ -32,10 +71,14 @@ export interface DisplaySettings {
export interface WaypointSettings { export interface WaypointSettings {
calendar: CalendarSettings; calendar: CalendarSettings;
daily: PeriodNoteSettings; daily: PeriodNoteSettings;
/** Focus an open tab when opening a periodic note without an explicit leaf. */
reusePeriodicNoteTabs: boolean;
weekly: PeriodNoteSettings; weekly: PeriodNoteSettings;
monthly: PeriodNoteSettings; monthly: PeriodNoteSettings;
quarterly: PeriodNoteSettings; quarterly: PeriodNoteSettings;
yearly: PeriodNoteSettings; yearly: PeriodNoteSettings;
/** Day-scoped systems beyond the daily note, in menu order. */
dateSystems: DateSystemSettings[];
recentFiles: RecentFilesSettings; recentFiles: RecentFilesSettings;
display: DisplaySettings; display: DisplaySettings;
} }
@@ -44,6 +87,8 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
calendar: { calendar: {
firstDayOfWeek: 1, // Monday firstDayOfWeek: 1, // Monday
showNoteIndicators: true, showNoteIndicators: true,
indicatorMode: 'systems',
dailyIndicatorColor: '#3b82f6',
}, },
daily: { daily: {
folder: 'periodic/daily', folder: 'periodic/daily',
@@ -51,6 +96,7 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
nameFormat: 'YYYY-MM-DD', nameFormat: 'YYYY-MM-DD',
typeProperty: 'daily-note', typeProperty: 'daily-note',
}, },
reusePeriodicNoteTabs: false,
weekly: { weekly: {
folder: 'periodic/weekly', folder: 'periodic/weekly',
templateFile: 'Templates/Weekly note', templateFile: 'Templates/Weekly note',
@@ -75,6 +121,28 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
nameFormat: 'YYYY', nameFormat: 'YYYY',
typeProperty: 'yearly-note', typeProperty: 'yearly-note',
}, },
dateSystems: [
{
id: 'journal',
name: 'Journal',
folder: 'periodic/journal',
nameFormat: 'YYYY-MM-DD - [Journal]',
templateFile: '',
typeProperty: 'journal',
icon: 'book-open',
indicatorColor: '#22c55e',
},
{
id: 'meetings',
name: 'Meeting',
folder: 'periodic/meetings',
nameFormat: 'YYYY-MM-DD - {title}',
templateFile: '',
typeProperty: 'meeting',
icon: 'users',
indicatorColor: '#a855f7',
},
],
recentFiles: { recentFiles: {
maxItems: 50, maxItems: 50,
updateOn: 'file-open', updateOn: 'file-open',
+103
View File
@@ -0,0 +1,103 @@
// ── Date system filename helpers ──
//
// A "date system" is a folder of notes whose filenames begin with a date:
//
// periodic/daily/2026-09-07.md one per date
// periodic/journal/2026-09-07 - Journal.md one per date
// periodic/meetings/2026-09-07 - Meeting w Mark.md many per date
//
// The system's `nameFormat` is a moment format string. When it contains
// `{title}` the system holds many notes per date: the part before the token is
// the date prefix used to find them, and the token marks where a free-text
// title goes when creating one.
//
// This module imports nothing from 'obsidian' so it stays unit-testable in
// plain node. Callers do the moment formatting and pass the results in.
export const TITLE_TOKEN = '{title}';
export interface NameFormatParts {
/** Moment format for the text before the title. */
before: string;
/** Moment format for the text after the title. Empty for most systems. */
after: string;
/** True when the format carries a title token, i.e. many notes per date. */
hasTitle: boolean;
}
/**
* Split a name format around its title token.
*
* The split has to happen before moment sees the string: `t`, `i`, `l` and `e`
* are all live moment tokens, so formatting `{title}` directly would mangle it.
*/
export function splitNameFormat(nameFormat: string): NameFormatParts {
const idx = nameFormat.indexOf(TITLE_TOKEN);
if (idx < 0) return { before: nameFormat, after: '', hasTitle: false };
return {
before: nameFormat.slice(0, idx),
after: nameFormat.slice(idx + TITLE_TOKEN.length),
hasTitle: true,
};
}
/** Whether `path` sits in `folder` or any subfolder. An empty folder is the vault root. */
export function isInFolder(path: string, folder: string): boolean {
if (!folder) return true;
const prefix = folder.endsWith('/') ? folder : `${folder}/`;
return path.startsWith(prefix);
}
/**
* Whether `basename` is a note of a system whose formatted name parts are
* `before` and `after`.
*
* One-per-date systems must match the whole basename. Many-per-date systems
* match on the date prefix, since the middle is a free-text title.
*/
export function matchesSystemName(
basename: string,
before: string,
after: string,
hasTitle: boolean,
): boolean {
if (!hasTitle) return basename === before + after;
// A format of just `{title}` formats to an empty prefix, which would claim
// every file in the folder for every date. Treat it as matching nothing;
// the settings tab flags the format as missing a date instead.
if (!before) return false;
if (basename.length < before.length + after.length) return false;
return basename.startsWith(before) && basename.endsWith(after);
}
/**
* The free-text part of a many-per-date basename, for use as a menu label.
* Falls back to the whole basename when the affixes do not line up.
*/
export function titleFromBasename(basename: string, before: string, after: string): string {
const start = basename.startsWith(before) ? before.length : 0;
const end = after && basename.endsWith(after)
? basename.length - after.length
: basename.length;
if (end <= start) return basename;
return basename.slice(start, end).trim() || basename;
}
/**
* Characters Obsidian rejects in filenames, plus the link-syntax characters
* (`#^[]|`) it refuses to index cleanly. Collapsed to a dash so a typed title
* like "Meeting w/ Mark" still produces a creatable filename.
*/
const ILLEGAL_FILENAME_CHARS = /[\\/:*?"<>|#^[\]]/g;
export function sanitizeTitle(title: string): string {
return title.replace(ILLEGAL_FILENAME_CHARS, '-').replace(/\s+/g, ' ').trim();
}
/** Whether a name format resolves to a usable date prefix at all. */
export function formatHasDateToken(nameFormat: string): boolean {
const { before } = splitNameFormat(nameFormat);
// Strip bracket-escaped literals, then look for any moment date token.
const unescaped = before.replace(/\[[^\]]*\]/g, '');
return /[YMDQGWEwdgeo]/.test(unescaped);
}
+120 -12
View File
@@ -15,6 +15,7 @@ import {
type PaneType, type PaneType,
} from 'obsidian'; } from 'obsidian';
import type WaypointPlugin from 'src/main'; import type WaypointPlugin from 'src/main';
import type { DateSystemNotes } from 'src/main';
import { getMonthGrid } from 'src/utils/date-utils'; import { getMonthGrid } from 'src/utils/date-utils';
import { BookmarkItem } from 'src/models/bookmark'; import { BookmarkItem } from 'src/models/bookmark';
@@ -90,7 +91,6 @@ export class WaypointView extends ItemView {
private renderCalendar(): void { private renderCalendar(): void {
const section = this.contentEl.createDiv({ cls: 'waypoint-section' }); const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
section.createDiv({ cls: 'waypoint-section-header', text: 'Calendar' });
const cal = section.createDiv({ cls: 'waypoint-calendar' }); const cal = section.createDiv({ cls: 'waypoint-calendar' });
@@ -180,6 +180,14 @@ export class WaypointView extends ItemView {
this.plugin.settings.calendar.firstDayOfWeek, this.plugin.settings.calendar.firstDayOfWeek,
); );
const systemIndicators = this.plugin.settings.calendar.showNoteIndicators
&& this.plugin.settings.calendar.indicatorMode === 'systems'
? this.plugin.getDateSystemIndicators(weeks.reduce<moment.Moment[]>(
(dates, week) => dates.concat(week.days.map(day => day.date)),
[],
))
: null;
for (const week of weeks) { for (const week of weeks) {
const row = tbody.createEl('tr'); const row = tbody.createEl('tr');
@@ -210,8 +218,20 @@ export class WaypointView extends ItemView {
if (this.plugin.settings.calendar.showNoteIndicators) { if (this.plugin.settings.calendar.showNoteIndicators) {
const dateStr = day.date.format('YYYY-MM-DD'); const dateStr = day.date.format('YYYY-MM-DD');
if (this.plugin.hasNoteForDate(dateStr)) { if (this.plugin.settings.calendar.indicatorMode === 'any') {
cell.addClass('has-note'); if (this.plugin.hasNoteForDate(dateStr)) {
cell.addClass('has-note');
}
} else {
const indicators = systemIndicators?.get(dateStr) || [];
if (indicators.length > 0) {
const dots = cell.createDiv({ cls: 'waypoint-day-indicators' });
for (const indicator of indicators) {
const dot = dots.createSpan({ cls: 'waypoint-day-indicator' });
dot.style.setProperty('--waypoint-indicator-color', indicator.color);
setTooltip(dot, indicator.name);
}
}
} }
} }
@@ -224,6 +244,11 @@ export class WaypointView extends ItemView {
this.plugin.openPeriodNote('day', day.date, this.app.workspace.getLeaf('tab')); this.plugin.openPeriodNote('day', day.date, this.app.workspace.getLeaf('tab'));
} }
}); });
cell.addEventListener('contextmenu', (event: MouseEvent) => {
event.preventDefault();
event.stopPropagation();
this.showDayContextMenu(event, day.date);
});
} }
} }
@@ -236,6 +261,79 @@ export class WaypointView extends ItemView {
this.redraw(); this.redraw();
} }
/**
* Right-click menu for a day cell: every date system's existing notes for
* that date, plus the actions that would create the ones it is missing.
*/
private showDayContextMenu(event: MouseEvent, date: moment.Moment): void {
const menu = new Menu();
menu.addItem((i) => i.setTitle(date.format('dddd, MMMM D, YYYY')).setIsLabel(true));
for (const bucket of this.plugin.findDateSystemNotes(date)) {
// Many-per-date systems can always take another note; one-per-date
// systems only offer creation while their single note is missing.
const canCreate = bucket.multiple || bucket.notes.length === 0;
if (bucket.notes.length + (canCreate ? 1 : 0) === 0) continue;
menu.addSeparator();
for (const note of bucket.notes) {
menu.addItem((i) =>
i
.setTitle(note.label)
.setIcon(bucket.system.icon)
.onClick((evt) => this.focusFile(note.file, Keymap.isModEvent(evt))),
);
}
if (!canCreate) continue;
const noun = bucket.system.name.toLowerCase();
menu.addItem((i) =>
i
// The ellipsis promises the prompt that a free-text title needs.
.setTitle(bucket.multiple ? `New ${noun} note…` : `New ${noun} note`)
.setIcon('plus')
.onClick((evt) => this.createDateSystemNote(bucket, date, Keymap.isModEvent(evt))),
);
}
menu.showAtPosition({ x: event.clientX, y: event.clientY });
}
/**
* Creates a date system's note, asking for a title first when the system
* holds many notes per date. A held modifier opens the result in a new pane.
*/
private createDateSystemNote(bucket: DateSystemNotes, date: moment.Moment, newLeaf: PaneType | boolean): void {
if (!bucket.multiple) {
void this.plugin.openDateSystemNote(bucket.system, date, {
leaf: newLeaf ? this.app.workspace.getLeaf(newLeaf) : undefined,
});
return;
}
const name = bucket.system.name;
new PromptModal(
this.app,
{
title: `New ${name.toLowerCase()} note`,
placeholder: `${name} with…`,
cta: 'Create',
},
(title) => {
// `getLeaf` materialises the pane immediately, so the target pane is
// resolved only after the title is confirmed — cancelling the prompt
// must not leave an empty tab behind.
void this.plugin.openDateSystemNote(bucket.system, date, {
title,
leaf: newLeaf ? this.app.workspace.getLeaf(newLeaf) : undefined,
});
},
).open();
}
// ════════════════════════════════════════ // ════════════════════════════════════════
// Recent Files panel // Recent Files panel
// ════════════════════════════════════════ // ════════════════════════════════════════
@@ -1062,7 +1160,7 @@ export class WaypointView extends ItemView {
} }
private promptRename(item: BookmarkItem): void { private promptRename(item: BookmarkItem): void {
new RenameModal(this.app, item.label, (newLabel) => { new PromptModal(this.app, { title: 'Rename bookmark', initialValue: item.label }, (newLabel) => {
if (newLabel && newLabel.trim()) { if (newLabel && newLabel.trim()) {
this.plugin.updateBookmark(item.id, { label: newLabel.trim() }); this.plugin.updateBookmark(item.id, { label: newLabel.trim() });
} }
@@ -1077,24 +1175,34 @@ export class WaypointView extends ItemView {
} }
} }
// ── Rename modal ── // ── Text prompt modal ──
class RenameModal extends Modal { interface PromptModalOptions {
private currentValue: string; title: string;
placeholder?: string;
initialValue?: string;
/** Submit button label. Defaults to 'Save'. */
cta?: string;
}
/** Single-line text prompt, shared by bookmark renaming and note creation. */
class PromptModal extends Modal {
private options: PromptModalOptions;
private onSubmit: (value: string) => void; private onSubmit: (value: string) => void;
constructor(app: App, currentValue: string, onSubmit: (value: string) => void) { constructor(app: App, options: PromptModalOptions, onSubmit: (value: string) => void) {
super(app); super(app);
this.currentValue = currentValue; this.options = options;
this.onSubmit = onSubmit; this.onSubmit = onSubmit;
} }
onOpen(): void { onOpen(): void {
this.titleEl.setText('Rename bookmark'); this.titleEl.setText(this.options.title);
const input = this.contentEl.createEl('input', { const input = this.contentEl.createEl('input', {
type: 'text', type: 'text',
value: this.currentValue, value: this.options.initialValue ?? '',
placeholder: this.options.placeholder ?? '',
}); });
input.style.width = '100%'; input.style.width = '100%';
input.style.marginBottom = '12px'; input.style.marginBottom = '12px';
@@ -1107,7 +1215,7 @@ class RenameModal extends Modal {
cancelBtn.style.marginRight = '8px'; cancelBtn.style.marginRight = '8px';
cancelBtn.addEventListener('click', () => this.close()); cancelBtn.addEventListener('click', () => this.close());
const saveBtn = btnContainer.createEl('button', { text: 'Save', cls: 'mod-cta' }); const saveBtn = btnContainer.createEl('button', { text: this.options.cta ?? 'Save', cls: 'mod-cta' });
saveBtn.addEventListener('click', () => { saveBtn.addEventListener('click', () => {
this.onSubmit(input.value); this.onSubmit(input.value);
this.close(); this.close();
+68 -20
View File
@@ -58,29 +58,34 @@
.waypoint-calendar { .waypoint-calendar {
font-size: var(--font-ui-small); font-size: var(--font-ui-small);
padding: 8px;
border: 1px solid var(--background-modifier-border);
border-radius: 10px;
background: var(--background-primary-alt);
} }
.waypoint-calendar-top { .waypoint-calendar-top {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-bottom: 10px; margin-bottom: 8px;
} }
.waypoint-calendar-breadcrumb { .waypoint-calendar-breadcrumb {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 4px;
font-size: var(--font-ui-medium); font-size: var(--font-ui-medium);
font-weight: var(--font-semibold); font-weight: var(--font-semibold);
padding: 4px 0; padding: 2px 0;
} }
.waypoint-calendar-breadcrumb .waypoint-clickable { .waypoint-calendar-breadcrumb .waypoint-clickable {
color: var(--text-muted); color: var(--text-muted);
cursor: var(--cursor-link, pointer); cursor: var(--cursor-link, pointer);
padding: 1px 4px; padding: 2px 4px;
border-radius: 4px; border-radius: 4px;
transition: color 80ms, background-color 80ms;
} }
.waypoint-calendar-breadcrumb .waypoint-clickable:hover { .waypoint-calendar-breadcrumb .waypoint-clickable:hover {
@@ -90,23 +95,25 @@
.waypoint-calendar .waypoint-separator { .waypoint-calendar .waypoint-separator {
color: var(--text-faint); color: var(--text-faint);
margin: 0 2px; margin: 0;
} }
.waypoint-calendar-today-group { .waypoint-calendar-today-group {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 2px; gap: 1px;
} }
.waypoint-calendar-today-group button { .waypoint-calendar-today-group button {
background: none; background: none;
border: none; border: none;
cursor: var(--cursor-link, pointer); cursor: var(--cursor-link, pointer);
padding: 2px 6px; padding: 2px 5px;
border-radius: 4px; border-radius: 4px;
color: var(--text-muted); color: var(--text-muted);
font-size: var(--font-ui-small); font-size: var(--font-ui-small);
transition: color 80ms, background-color 80ms;
box-shadow: none;
} }
.waypoint-calendar-today-group button:hover { .waypoint-calendar-today-group button:hover {
@@ -121,30 +128,34 @@
.waypoint-calendar table { .waypoint-calendar table {
table-layout: fixed; table-layout: fixed;
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: separate;
border-spacing: 2px 3px;
} }
.waypoint-calendar th, .waypoint-calendar th,
.waypoint-calendar td { .waypoint-calendar td {
text-align: center; text-align: center;
padding: 4px 2px; padding: 0;
font-size: var(--font-ui-small); font-size: var(--font-ui-small);
line-height: 1.6;
} }
.waypoint-calendar th { .waypoint-calendar th {
padding-bottom: 2px;
font-weight: var(--font-medium); font-weight: var(--font-medium);
color: var(--text-faint); color: var(--text-faint);
font-size: calc(var(--font-ui-small) * 0.85); font-size: calc(var(--font-ui-small) * 0.78);
letter-spacing: 0.04em;
text-transform: uppercase;
} }
.waypoint-calendar .waypoint-weeknum { .waypoint-calendar .waypoint-weeknum {
font-size: calc(var(--font-ui-small) * 0.75); width: 18px;
font-size: calc(var(--font-ui-small) * 0.72);
color: var(--text-faint); color: var(--text-faint);
font-weight: var(--font-light); font-weight: var(--font-light);
cursor: var(--cursor-link, pointer); cursor: var(--cursor-link, pointer);
padding: 2px 0;
border-radius: 4px; border-radius: 4px;
transition: color 80ms, background-color 80ms;
} }
.waypoint-calendar .waypoint-weeknum:hover { .waypoint-calendar .waypoint-weeknum:hover {
@@ -154,42 +165,71 @@
.waypoint-calendar .waypoint-day { .waypoint-calendar .waypoint-day {
cursor: var(--cursor-link, pointer); cursor: var(--cursor-link, pointer);
min-height: var(--wp-cal-cell-size, 32px); height: var(--wp-cal-cell-size, 32px);
padding: 2px 0; box-sizing: border-box;
padding: 2px 0 7px;
border-radius: 6px; border-radius: 6px;
position: relative; position: relative;
width: 100%; width: 100%;
vertical-align: middle; vertical-align: middle;
transition: color 80ms, background-color 80ms, box-shadow 80ms;
} }
.waypoint-calendar .waypoint-day:hover { .waypoint-calendar .waypoint-day:hover {
background-color: var(--background-modifier-active-hover); background-color: var(--background-modifier-hover);
} }
.waypoint-calendar .waypoint-day.other-month { .waypoint-calendar .waypoint-day.other-month {
opacity: 0.35; color: var(--text-faint);
opacity: 0.5;
} }
.waypoint-calendar .waypoint-day.today { .waypoint-calendar .waypoint-day.today {
color: var(--text-accent); color: var(--text-accent);
border: 1px solid var(--text-accent);
font-weight: var(--font-semibold); font-weight: var(--font-semibold);
box-shadow: inset 0 0 0 1px var(--text-accent);
} }
.waypoint-calendar .waypoint-day.today:hover {
background-color: var(--background-modifier-active-hover);
}
/* Single-dot mode preserves the pre-date-systems indicator. */
.waypoint-calendar .waypoint-day.has-note::after { .waypoint-calendar .waypoint-day.has-note::after {
content: ''; content: '';
display: block; position: absolute;
left: 50%;
bottom: 3px;
width: 4px; width: 4px;
height: 4px; height: 4px;
border-radius: 50%; border-radius: 50%;
background-color: var(--text-faint); background-color: var(--text-faint);
margin: 0 auto; transform: translateX(-50%);
} }
.waypoint-calendar .waypoint-day.today.has-note::after { .waypoint-calendar .waypoint-day.today.has-note::after {
background-color: var(--text-accent); background-color: var(--text-accent);
} }
/* Colour-by-system mode: one dot per matching system, in Settings order. */
.waypoint-day-indicators {
position: absolute;
right: 0;
bottom: 3px;
left: 0;
display: flex;
justify-content: center;
gap: 3px;
}
.waypoint-day-indicator {
width: 5px;
height: 5px;
border-radius: 50%;
background-color: var(--waypoint-indicator-color);
box-shadow: 0 0 0 1px var(--background-primary);
}
/* ── Recent Files ── */ /* ── Recent Files ── */
.waypoint-recent-filter { .waypoint-recent-filter {
@@ -420,3 +460,11 @@ button.waypoint-calendar-today-btn {
margin-right: auto; margin-right: auto;
cursor: var(--cursor-link, pointer); cursor: var(--cursor-link, pointer);
} }
/* ── Settings: date systems ── */
.waypoint-settings-warning {
margin-top: 4px;
color: var(--text-error);
font-size: var(--font-ui-smaller);
}