Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
165a3d1f27 | ||
|
|
c9afc16c53 | ||
|
|
ff15470a06 |
No files matched your search
+39
-26
@@ -59,7 +59,7 @@ interface WaypointSettings {
|
||||
quarterly: PeriodNoteSettings;
|
||||
yearly: PeriodNoteSettings;
|
||||
dateSystems: DateSystemSettings[]; // day-scoped systems beyond the daily note, in menu order
|
||||
recentFiles: RecentFilesSettings; // maxItems, updateOn, omittedPaths[], omittedTags[], filterTags[]
|
||||
recentFiles: RecentFilesSettings; // maxItems, show, omittedPaths[], omittedTags[], types[]
|
||||
display: DisplaySettings; // px sizing for bookmark rows, fonts, icons, calendar cells
|
||||
}
|
||||
|
||||
@@ -78,13 +78,17 @@ interface CalendarSettings {
|
||||
}
|
||||
|
||||
interface RecentFilesSettings {
|
||||
maxItems: number; // default 50
|
||||
updateOn: 'file-open' | 'file-edit'; // trigger mode
|
||||
maxItems: number; // default 50, per kind (opened / changed)
|
||||
show: 'all' | 'opened' | 'changed'; // header switch, default 'all'
|
||||
omittedPaths: string[]; // regex patterns (one per line)
|
||||
omittedTags: string[]; // regex patterns for frontmatter/inline tags
|
||||
filterTags: string[]; // tags shown as filter pills (empty = auto-detect from frontmatter)
|
||||
types: { type: string; icon: string }[]; // frontmatter types with a row icon each
|
||||
}
|
||||
```
|
||||
|
||||
Migration in `applySettings`: the saved `filterTags`, `showTypeFilter` (the removed type filter), and `updateOn` (both kinds are always tracked) are dropped.
|
||||
|
||||
```typescript
|
||||
interface DisplaySettings {
|
||||
rowSize: number; // px, base height of bookmark items (18–40)
|
||||
rowSpacing: number; // px, gap between items (0–12)
|
||||
@@ -151,6 +155,7 @@ These call `navigatePeriodNote(direction)` which:
|
||||
|---|---|
|
||||
| `waypoint-open-view` | Open Waypoint sidebar |
|
||||
| `waypoint-add-bookmark` | Add current file as Waypoint bookmark |
|
||||
| `waypoint-open-date` | Open daily note for a date… — `DatePickerModal` (`src/modals/date-picker-modal.ts`, native `<input type="date">`), then `showDateInViews(date)` and `openPeriodNote('day', date)` |
|
||||
|
||||
---
|
||||
|
||||
@@ -286,15 +291,15 @@ Middle-click handlers in the view pass an explicit tab leaf: `openPeriodNote(per
|
||||
|
||||
### `file-open`
|
||||
|
||||
Tracks the opened file into recent files **only** when `settings.recentFiles.updateOn === 'file-open'`.
|
||||
Records the previously active path in `previouslyActive` (valid for `PENDING_SAVE_GRACE_MS` = 5 s) and the new one in `activePath`, then `recordRecentFile(file, 'opened')`: sets `openedAt` and clears `changedInBackground`.
|
||||
|
||||
### `vault:modify`
|
||||
|
||||
Tracks the modified file (guarded to `TFile`) into recent files **only** when `updateOn === 'file-edit'`. Exactly one of the two modes is active at a time, so `'file-edit'` is a working mode rather than a no-op.
|
||||
`onFileChange(file)` (guarded to `TFile`) calls `recordRecentFile(file, 'changed', isBackgroundChange(file))`: sets `changedAt`, and `changedInBackground` when the file is neither `getActiveFile()` nor left less than 5 s ago (its editor flushing a pending save after a tab switch). When the file already leads both the `all` and `changed` orderings and the dot does not change — the editor saving while you type — only the timestamp moves and no redraw happens.
|
||||
|
||||
### `vault:create` / `vault:delete`
|
||||
|
||||
Both update the markdown-basename set used for calendar note indicators, then trigger `broadcastRedraw()` — telling all WaypointView instances to re-render (needed for the indicators and for stale recent file references).
|
||||
Both update the markdown-basename set used for calendar note indicators, then trigger `broadcastRedraw()` — telling all WaypointView instances to re-render (needed for the indicators and for stale recent file references). After layout-ready, `create` also goes through `onFileChange` (synced or plugin-created notes); the initial vault scan fires `create` for every file before layout-ready and is skipped.
|
||||
|
||||
### `vault:rename`
|
||||
|
||||
@@ -309,19 +314,21 @@ Both update the markdown-basename set used for calendar note indicators, then tr
|
||||
## Recent Files (persisted)
|
||||
|
||||
```typescript
|
||||
recentFiles: { path: string; basename: string }[]
|
||||
recentFiles: { path: string; basename: string; changedInBackground?: boolean }[] // RecentFileEntry
|
||||
```
|
||||
|
||||
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).
|
||||
Backed by `waypointData.recentFiles` in `data.json`, so the list survives vault reload. `applyWaypointData(saved)` restores it; entries saved before per-kind timestamps get small descending `openedAt` values (or `changedAt` if the old `updateOn` was `'file-edit'`), keeping their order and sorting after anything new.
|
||||
|
||||
**Ordering and trimming** (`src/utils/recent-files.ts`, pure): `recentFilesFor(entries, show)` lists entries with an `openedAt` (`opened`), a `changedAt` (`changed`), or either (`all`, by the later of the two), most recent first. `trimRecentFiles(entries, max)` keeps an entry while it is among the `max` most recently opened **or** the `max` most recently changed, so a burst of synced changes cannot evict opened files. `this.recentFiles` is stored in `all` order.
|
||||
|
||||
**Update flow:**
|
||||
1. `addToRecentFiles(file)` — omission check, then dedupes (removes existing entry), prepends to front, truncates to `maxItems`.
|
||||
1. `recordRecentFile(file, kind, background)` — omission check, stamp (creating the entry if needed), `trimRecentFiles`.
|
||||
2. `persistRecentFiles()` — mirrors the array into `waypointData.recentFiles` and schedules a debounced (300ms) `saveWaypointData()`.
|
||||
3. Calls `broadcastRedraw()`.
|
||||
3. Calls `broadcastRedraw()` unless the change was quiet (see `vault:modify`).
|
||||
|
||||
**Omitted paths/tags:** Both filters are applied in `addToRecentFiles`. `omittedPaths` entries are treated as regexes tested against `file.path`; `omittedTags` entries are regexes tested against the file's tags, read via `getAllTags(metadataCache.getFileCache(file))` with the leading `#` stripped. An invalid regex is skipped rather than throwing.
|
||||
**Omitted paths/tags:** Both filters are applied in `recordRecentFile`. `omittedPaths` entries are treated as regexes tested against `file.path`; `omittedTags` entries are regexes tested against the file's tags, read via `getAllTags(metadataCache.getFileCache(file))` with the leading `#` stripped. An invalid regex is skipped rather than throwing.
|
||||
|
||||
**`enforceRecentFilesLimit()`:** Called from the settings-change callback — trims the list when `maxItems` is lowered and persists the result.
|
||||
**`enforceRecentFilesLimit()`:** Called from the settings-change callback — re-trims when `maxItems` is lowered and persists the result.
|
||||
|
||||
**On file not found:** When clicking a recent file that no longer exists, `focusFile()` shows a Notice and removes the stale entry from `recentFiles`.
|
||||
|
||||
@@ -333,32 +340,32 @@ Extends `ItemView`. View type: `"waypoint-view"`, icon: `compass`.
|
||||
|
||||
### Rendering (`redraw`)
|
||||
|
||||
Called on every change. Full DOM rebuild — `contentEl.empty()` then three sections in order:
|
||||
Called on every change. Full DOM rebuild — `contentEl.empty()`, then Favorites and Recent Files inside a `.waypoint-lists` wrapper, then the Calendar:
|
||||
|
||||
1. **Favorites** (`renderFavorites`) — bookmark tree
|
||||
2. **Recent Files** (`renderRecentFiles`) — flat list
|
||||
3. **Calendar** (`renderCalendar`) — month grid
|
||||
1. **Favorites** (`renderFavorites(lists)`) — bookmark tree
|
||||
2. **Recent Files** (`renderRecentFiles(lists)`) — flat list
|
||||
3. **Calendar** (`renderCalendar`) — month grid, `.waypoint-calendar-section`
|
||||
|
||||
The last section (`waypoint-section:last-child`) gets `margin-top: auto`, pushing it to the bottom of the sidebar.
|
||||
`.waypoint-calendar-section` gets `margin-top: auto`, pushing it to the bottom of the sidebar. On desktop `.waypoint-lists` is `display: contents`, so the whole view scrolls as before. On mobile (`.is-mobile`) the wrapper becomes the only scroller and the view itself stops scrolling, so the full calendar is always on screen when the drawer opens.
|
||||
|
||||
### Calendar Panel
|
||||
|
||||
**State:** `currentDisplayMonth` (0-indexed), `currentDisplayYear` — allows navigating months independently of today.
|
||||
**State:** `currentDisplayMonth` (0-indexed), `currentDisplayYear` — allows navigating months independently of today. `selectedDate` — day reached through the date picker or the "Open date" command (`showDate(date)`), drawn as `.is-selected`; Today and ◀/▶ clear it.
|
||||
|
||||
**Layout:**
|
||||
|
||||
```
|
||||
┌────────────────────────────────────┐
|
||||
│ Q2 June 2026 ◀ Today ▶ │ ← breadcrumb (clickable) + nav
|
||||
│ Q2 Jun 2026 ◀ Today ▶ │ ← breadcrumb (clickable) + nav
|
||||
├──┬───┬───┬───┬───┬───┬───┬───┤
|
||||
│24│sun│mon│tue│wed│thu│fri│sat│ ← header row + week# col
|
||||
│24│ S │ M │ T │ W │ T │ F │ S │ ← header row + week# col
|
||||
├──┼───┼───┼───┼───┼───┼───┼───┤
|
||||
│25│ 1 │ 2 │ 3 │... ← day cells (clickable)
|
||||
└──┴───┴───┴───┴───┴───┴───┴───┘
|
||||
```
|
||||
|
||||
- **Breadcrumb:** Q-label, month name, year — each clickable to open that period note.
|
||||
- **Nav buttons:** ◀/▶ shift month ±1. "Today" resets to current month.
|
||||
- **Breadcrumb:** Q-label, 3-letter month (`MMM`), year — each clickable to open that period note. Weekday headers are single letters.
|
||||
- **Nav buttons:** ◀/▶ shift month ±1. "Today" resets to current month. The `calendar-search` button calls `showPicker()` on a hidden native `<input type="date">` (`.waypoint-calendar-pick-input`); picking a date calls `showDate()` — the calendar jumps to that month and marks the day without opening or creating a note.
|
||||
- **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:** 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`.
|
||||
@@ -372,11 +379,16 @@ Every label is derived from `system.name`, so a renamed or newly added system ne
|
||||
|
||||
### 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 `recentFilesFor(plugin.recentFiles, settings.show)` as Obsidian-native `nav-file` elements using the file explorer's CSS classes (`tree-item`, `nav-file-title`, `nav-file-title-content`).
|
||||
|
||||
**Header switch** (`.waypoint-recent-show`): `all` / `opened` / `changed`, saved to `settings.recentFiles.show`.
|
||||
|
||||
**Type icons** (`.waypoint-recent-icon`): a file whose frontmatter `type` matches a configured type with an icon shows that Lucide icon before its name. Once any type has an icon, every row reserves the slot so names stay aligned.
|
||||
|
||||
**Per-file features:**
|
||||
- **Active indicator:** `.is-active` class if path matches `workspace.getActiveFile()`.
|
||||
- **Remove button:** × icon, appears on hover (`.waypoint-recent-remove`), drops the entry from `plugin.recentFiles`, calls `persistRecentFiles()`, then redraws.
|
||||
- **Background-change dot:** `.waypoint-recent-changed` after the name when `changedInBackground` is set, with tooltip "Changed in the background". Cleared when the file is opened.
|
||||
- **Drag:** Uses `app.dragManager.dragFile()` for native Obsidian drag.
|
||||
- **Hover preview:** Triggers `hover-link` event for Obsidian's page preview popup.
|
||||
- **Context menu:** "Open in new tab" + Obsidian's native `file-menu` event.
|
||||
@@ -440,8 +452,9 @@ All classes prefixed with `waypoint-`. Uses Obsidian CSS variables throughout:
|
||||
- `--cursor-link` (pointer cursor, with a `pointer` fallback)
|
||||
|
||||
Key layout:
|
||||
- `.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-view` — flex column, `overflow-y: auto` (hidden on mobile, where `.waypoint-lists` scrolls instead), 8px padding.
|
||||
- `.waypoint-section` — `flex-shrink: 0`, 16px bottom margin. `.waypoint-calendar-section` gets `margin-top: auto` (pins calendar to bottom).
|
||||
- `.waypoint-settings-tabs` — wraps onto several rows; on mobile the tabs become rounded pills without the underline overlap.
|
||||
- `.waypoint-calendar` — padded, bordered surface with separated day cells for clear scan lines.
|
||||
- Calendar table — `table-layout: fixed`, `border-collapse: separate`, 2px horizontal / 3px vertical cell spacing.
|
||||
- `.waypoint-day.today` — accent text with an inset accent ring, avoiding layout shifts.
|
||||
|
||||
@@ -121,3 +121,32 @@
|
||||
- [ ] Left-click opens file, middle-click opens in new tab
|
||||
- [ ] Right-click shows "Open in new tab" + native file menu
|
||||
- [ ] Hover preview popup works
|
||||
|
||||
## Calendar: Date picker and "Open date" command
|
||||
|
||||
- [ ] The calendar-search button right of ▶ opens the native date picker (desktop popup, mobile sheet)
|
||||
- [ ] Picking a date jumps the calendar to that month and fills that day with the accent colour; no note is opened or created
|
||||
- [ ] "Today" or ◀/▶ clears the picked-day highlight
|
||||
- [ ] Command "Open daily note for a date…" opens a modal prefilled with today; Enter or Open opens/creates that day's daily note and the calendar shows its month with the day marked
|
||||
- [ ] Cancel or Escape closes the modal without opening anything
|
||||
|
||||
## Recent Files: Opened / changed, background dot, type icons
|
||||
|
||||
- [ ] The header switch beside "Recent Files" shows all / opened / changed; the choice survives a reload
|
||||
- [ ] "opened" lists only files you opened; "changed" lists files that changed (yours and background); "all" orders by the later of the two
|
||||
- [ ] A file changed while another note is active (sync, another plugin) moves to the top of all/changed with a dot; tooltip "Changed in the background"
|
||||
- [ ] Opening that file clears the dot
|
||||
- [ ] Editing the active note never shows a dot; neither does switching tabs right after typing (late save of the note you just left)
|
||||
- [ ] Typing in the active note does not rebuild the sidebar on every save
|
||||
- [ ] A note created in the background (e.g. synced) appears with a dot; a note you create and open yourself does not keep one
|
||||
- [ ] Vault startup does not flood the list with every file
|
||||
- [ ] With Max items = N, many background changes do not push out the N most recently opened files
|
||||
- [ ] An existing list from before this version keeps its order (all entries appear under "opened")
|
||||
- [ ] File types: add a type, pick an icon in the picker, matching recent files show the icon; names stay aligned; trash removes the type
|
||||
- [ ] Settings → Recent Files has no "Type filter" toggle and no pills appear above the list; an old saved `filterTags`/`showTypeFilter` loads without error and is dropped
|
||||
|
||||
## Mobile
|
||||
|
||||
- [ ] Opening the left drawer shows the whole calendar at the bottom; bookmarks and recent files scroll above it
|
||||
- [ ] The date button fits inside the calendar header next to ◀ Today ▶
|
||||
- [ ] Settings tabs wrap onto several rows instead of overflowing
|
||||
@@ -2,11 +2,17 @@
|
||||
|
||||
Calendar, recent files, and custom bookmarks sidebar for Obsidian.
|
||||
|
||||
## v1.10.0
|
||||
|
||||
- Calendar weekday headings use single English letters and month names use English abbreviations.
|
||||
- Removed Recent Files type-filter pills and their toggle; **File types** icons and **Omitted tags** remain available.
|
||||
|
||||
## Features
|
||||
|
||||
- **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 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. The date button beside **Today** jumps to any 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** — files you opened and files that changed. The switch beside the title shows all, only opened, or only changed files. A dot marks a file changed in the background (sync, another plugin) until you open it. Give frontmatter types (meeting, daily-note…) an icon under **Settings → Recent Files → File types**.
|
||||
- **Mobile** — the whole calendar stays on screen when the sidebar opens; the lists above it scroll on their own.
|
||||
- **Favorites** — custom bookmarks with groups, icons, and rename
|
||||
|
||||
## Commands
|
||||
@@ -19,6 +25,7 @@ Calendar, recent files, and custom bookmarks sidebar for Obsidian.
|
||||
| Go to quarterly note | `Ctrl+Shift+Alt+Q` |
|
||||
| Go to yearly note | `Ctrl+Shift+Alt+Y` |
|
||||
| Next/Previous daily/weekly/monthly/quarterly/yearly note | — |
|
||||
| Open daily note for a date… | — |
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -2,26 +2,22 @@
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
*/
|
||||
|
||||
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$`),a.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=a.getValue().split(`
|
||||
`).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`),a.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=a.getValue().split(`
|
||||
`).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
|
||||
project`),a.setValue(this.settings.recentFiles.filterTags.join(`
|
||||
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=a.getValue().split(`
|
||||
`).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 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
|
||||
${ee(m)}
|
||||
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.
|
||||
`+ee(m),O),null}else c=`---
|
||||
var ne=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Se=(c,d)=>{for(var e in d)ne(c,e,{get:d[e],enumerable:!0})},Fe=(c,d,e,n)=>{if(d&&typeof d=="object"||typeof d=="function")for(let a of be(d))!De.call(c,a)&&a!==e&&ne(c,a,{get:()=>d[a],enumerable:!(n=ke(d,a))||n.enumerable});return c};var xe=c=>Fe(ne({},"__esModule",{value:!0}),c);var Ae={};Se(Ae,{default:()=>ee});module.exports=xe(Ae);var y=require("obsidian");var G={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file",indicatorColor:"#64748b"},M={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,show:"all",omittedPaths:[],omittedTags:[],types:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var f=require("obsidian");var me="{title}";function V(c){let d=c.indexOf(me);return d<0?{before:c,after:"",hasTitle:!1}:{before:c.slice(0,d),after:c.slice(d+me.length),hasTitle:!0}}function ae(c,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return c.startsWith(e)}function ie(c,d,e,n){return n?!d||c.length<d.length+e.length?!1:c.startsWith(d)&&c.endsWith(e):c===d+e}function ue(c,d,e){let n=c.startsWith(d)?d.length:0,a=e&&c.endsWith(e)?c.length-e.length:c.length;return a<=n?c:c.slice(n,a).trim()||c}var Te=/[\\/:*?"<>|#^[\]]/g;function ge(c){return c.replace(Te,"-").replace(/\s+/g," ").trim()}function W(c){let{before:d}=V(c),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var h=require("obsidian");var B=require("obsidian");function ye(c,d,e){let n=(0,B.moment)({year:c,month:d,day:1}),a=(0,B.moment)(n).endOf("month"),t=(0,B.moment)(n).subtract((n.day()-e+7)%7,"days"),i=(0,B.moment)().startOf("day"),r=[],s=(0,B.moment)(t);for(;s.isBefore(a)||s.month()===d;){let o=[];for(let l=0;l<7;l++)o.push({date:(0,B.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(i,"day"),isCurrentMonth:s.month()===d,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(r.push({weekNumber:o[0].isoWeekNumber,days:o}),r.length>=6)break}return r}function Ee(c,d){return d==="opened"?c.openedAt:d==="changed"||c.openedAt===void 0?c.changedAt:c.changedAt===void 0?c.openedAt:Math.max(c.openedAt,c.changedAt)}function R(c,d){let e=[];for(let n of c){let a=Ee(n,d);a!==void 0&&e.push({entry:n,key:a})}return e.sort((n,a)=>a.key-n.key),e.map(n=>n.entry)}function j(c,d){let e=new Set([...R(c,"opened").slice(0,d),...R(c,"changed").slice(0,d)]);return R(c,"all").filter(n=>e.has(n))}var E="waypoint-view";function Me(c){return c.dragManager}var O=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");let n=this.contentEl.createDiv({cls:"waypoint-lists"});this.renderFavorites(n),this.renderRecentFiles(n),this.renderCalendar()};this.currentDisplayMonth=(0,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.selectedDate=null;this.plugin=n}getViewType(){return E}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}showDate(e){this.currentDisplayMonth=e.month(),this.currentDisplayYear=e.year(),this.selectedDate=e.clone(),this.redraw()}renderCalendar(){var le;let n=this.contentEl.createDiv({cls:"waypoint-section waypoint-calendar-section"}).createDiv({cls:"waypoint-calendar"}),a=(0,h.moment)(),t=(0,h.moment)({year:this.currentDisplayYear,month:this.cuLine truncated
|
||||
\\.png$`),t.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=t.getValue().split(`
|
||||
`).filter(i=>i.trim()),this.saveAndRefresh()}});let a=new DocumentFragment;a.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new f.Setting(e).setName("Omitted tags").setDesc(a).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`ignore
|
||||
archive`),t.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=t.getValue().split(`
|
||||
`).filter(i=>i.trim()),this.saveAndRefresh()}}),this.renderRecentTypes(e)}renderRecentTypes(e){let n=this.settings.recentFiles.types;new f.Setting(e).setHeading().setName("File types").setDesc("Frontmatter `type` values. A type's icon shows beside matching recent files."),n.forEach((a,t)=>{new f.Setting(e).addText(i=>{i.setPlaceholder("meeting"),i.setValue(a.type),i.inputEl.onblur=()=>{let r=i.getValue().trim();r!==a.type&&(a.type=r,this.saveAndRefresh())}}).addExtraButton(i=>{i.setIcon(a.icon||"image-off").setTooltip(a.icon?`Icon: ${a.icon}`:"Choose icon").onClick(()=>{new H(this.app,a.icon,r=>{a.icon=r,this.saveAndRefresh(),this.display()}).open()})}).addExtraButton(i=>{i.setIcon("trash").setTooltip("Remove this type").onClick(()=>{n.splice(t,1),this.saveAndRefresh(),this.display()})})}),new f.Setting(e).addButton(a=>{a.setButtonText("Add type").onClick(()=>{n.push({type:"",icon:""}),this.display()})})}renderDisplayTab(e){new f.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 f.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new f.Setting(e).addButton(n=>n.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...M.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,n,a,t,i,r,s,o,l){let p=new f.Setting(e).setName(n).setDesc(`${a} (${t[i]}${l})`);p.addSlider(u=>{u.setLimits(r,s,o).setValue(t[i]).setDynamicTooltip().onChange(D=>{t[i]=D,p.setDesc(`${a} (${D}${l})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let n=this.plugin.manifest.version,a=e.createDiv();a.style.display="flex",a.style.alignItems="center",a.style.gap="12px",a.style.marginBottom="16px";let t=a.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,f.setIcon)(t,"compass");let i=a.createDiv(),r=i.createEl("h2",{text:"Waypoint Sidebar"});r.style.margin="0",r.style.lineHeight="1.2";let s=i.createDiv({text:`v${n}`});s.style.color="var(--text-muted)",s.style.fontSize="var(--font-ui-small)";let o=e.createDiv();o.style.marginBottom="20px",o.style.lineHeight="1.6",o.style.color="var(--text-normal)",o.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 and changed files with type icons, 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 J=require("obsidian"),Z=class extends J.Modal{constructor(e,n,a){super(e);this.initialDate=n;this.onSubmit=a}onOpen(){this.titleEl.setText("Open date");let e=this.contentEl.createEl("input",{type:"date",value:this.initialDate.format("YYYY-MM-DD")});e.style.width="100%",e.style.marginBottom="12px",e.focus();let n=()=>{let t=(0,J.moment)(e.value,"YYYY-MM-DD",!0);t.isValid()&&(this.close(),this.onSubmit(t))};e.addEventListener("keydown",t=>{t.key==="Enter"&&n()});let a=this.contentEl.createDiv({cls:"modal-button-container"});a.createEl("button",{text:"Cancel"}).addEventListener("click",()=>this.close()),a.createEl("button",{text:"Open",cls:"mod-cta"}).addEventListener("click",n)}onClose(){this.contentEl.empty()}};function se(c,d,e){return!c||!d?null:c===d?e:c.startsWith(d+"/")?e+c.slice(d.length):null}var ee=class extends y.Plugin{constructor(){super(...arguments);this.recentFiles=[];this.savePromise=Promise.resolve();this.markdownBasenames=new Set;this.dateSystemIndicators=null;this.dateSystemIndicatorKey="";this.indicatorModeMigrated=!1;this.previouslyActive=null;this.activePath=null}async onload(){console.debug("Waypoint: loading plugin v"+this.manifest.version);let e=await this.loadData(),n=this.applySettings(e);this.applyWaypointData(e),n&&this.persistAll(),this.registerView(E,s=>new O(s,this)),this.addSettingTab(new U(this.app,this,this.settings,()=>{this.enforceRecentFilesLimit(),this.invalidateDateSystemIndicators(),this.redrawAll()})),this.addCommand({id:"waypoint-open-view",name:"Open Waypoint sidebar",callback:async()=>{let s=this.app.workspace.getLeavesOfType(E);if(s.length>0)await this.app.workspace.revealLeaf(s[0]);else{let o=this.app.workspace.getLeftLeaf(!1);o&&(await o.setViewState({type:E}),await this.app.workspace.revealLeaf(o))}}}),this.addCommand({id:"waypoint-add-bookmark",name:"Add current file as Waypoint bookmark",callback:async()=>{let s=this.app.workspace.getActiveFile();if(!s){new y.Notice("No active file");return}this.addBookmark(s.path,s.basename,"file"),new y.Notice(`Bookmarked: ${s.basename}`)}}),this.addCommand({id:"waypoint-go-to-daily",name:"Go to daily note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"d"}],callback:async()=>{await this.openPeriodNote("day",(0,y.moment)())}}),this.addCommand({id:"waypoint-go-to-weekly",name:"Go to weekly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"w"}],callback:async()=>{await this.openPeriodNote("week",(0,y.moment)())}}),this.addCommand({id:"waypoint-go-to-monthly",name:"Go to monthly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"m"}],callback:async()=>{await this.openPeriodNote("month",(0,y.moment)())}}),this.addCommand({id:"waypoint-go-to-quarterly",name:"Go to quarterly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"q"}],callback:async()=>{await this.openPeriodNote("quarter",(0,y.moment)())}}),this.addCommand({id:"waypoint-go-to-yearly",name:"Go to yearly note",hotkeys:[{modifiers:["Mod","Shift","Alt"],key:"y"}],callback:async()=>{await this.openPeriodNote("year",(0,y.moment)())}}),this.addCommand({id:"waypoint-open-date",name:"Open daily note for a date\u2026",callback:()=>{new Z(this.app,(0,y.moment)(),s=>{this.showDateInViews(s),this.openPeriodNote("day",s)}).open()}});let a=["next","prev"],t=["daily","weekly","monthly","quarterly","yearly"],i={next:"Next",prev:"Previous"};for(let s of t)for(let o of a){let l=`waypoint-go-to-${o}-${s}`,p=`${i[o]} ${s} note`;this.addCommand({id:l,name:p,callback:async()=>{await this.navigatePeriodNote(o)}})}this.registerEvent(this.app.workspace.on("file-open",s=>{s&&this.onFileOpen(s)})),this.registerEvent(this.app.vault.on("create",s=>this.onVaultCreate(s))),this.registerEvent(this.app.vault.on("delete",s=>this.onVaultDelete(s))),this.registerEvent(this.app.vault.on("rename",(s,o)=>this.onRename(s,o))),this.registerEvent(this.app.vault.on("modify",s=>this.onFileChange(s))),this.app.workspace.onLayoutReady(()=>{if(this.buildMarkdownIndex(),this.app.workspace.getLeavesOfType(E).length===0){let o=this.app.workspace.getLeftLeaf(!1);o&&o.setViewState({type:E})}else this.broadcastRedraw()});let r=new Date().toDateString();this.registerInterval(window.setInterval(()=>{let s=new Date().toDateString();s!==r&&(r=s,this.redrawAll())},6e5))}async onunload(){this.app.workspace.detachLeavesOfType(E)}applySettings(e){var r,s;let n=(e==null?void 0:e.settings)||{};this.settings=Object.assign({},M,n),this.settings.recentFiles=Object.assign({},M.recentFiles,n.recentFiles||{});let a=this.settings.recentFiles;this.settings.recentFiles.types=Array.isArray((r=n.recentFiles)==null?void 0:r.types)?n.recentFiles.types.map(o=>({...o})):[],delete a.filterTags,delete a.showTypeFilter,delete a.updateOn,this.settings.calendar=Object.assign({},M.calendar,n.calendar||{}),this.settings.display=Object.assign({},M.display,n.display||{});for(let o of Ce)this.settings[o]=Object.assign({},M[o],n[o]||{});this.settings.dateSystems=Array.isArray(n.dateSystems)?n.dateSystems.map(o=>{let l=M.dateSystems.find(p=
Line truncated
|
||||
${oe(u)}
|
||||
Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,q),null}let s=n.templateFile,o=this.resolveTemplateFile(s),l;if(o)try{l=await this.app.vault.read(o)}catch(u){return new y.Notice(`Waypoint: could not read the template "${o.path}" for the ${t} note.
|
||||
`+oe(u),q),null}else l=`---
|
||||
type: ${n.typeProperty}
|
||||
date: ${i.format("YYYY-MM-DD")}
|
||||
date: ${a.format("YYYY-MM-DD")}
|
||||
---
|
||||
|
||||
`;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}".
|
||||
${ee(m)}`,O),null}return s&&!r?new f.Notice(`Created ${t} note: ${l.basename}
|
||||
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}.`,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):""}
|
||||
`;let p;try{p=await this.app.vault.create(e,l)}catch(u){return new y.Notice(`Waypoint: could not create the ${t} note at "${e}".
|
||||
${oe(u)}`,q),null}return s&&!o?new y.Notice(`Created ${t} note: ${p.basename}
|
||||
Template "${s}" was not found, so a basic note was created instead.`,q):new y.Notice(`Created ${t} note: ${p.basename}`),p}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof y.TFolder)return;let n="";for(let a of e.split("/"))if(a&&(n=n?`${n}/${a}`:a,!(this.app.vault.getAbstractFileByPath(n)instanceof y.TFolder)))try{await this.app.vault.createFolder(n)}catch(t){if(!(this.app.vault.getAbstractFileByPath(n)instanceof y.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 fe){let a=this.settings[X[n].key].nameFormat;if(!a)continue;let t=(0,y.moment)(e,a,!0);if(t.isValid())return{period:n,date:t}}return null}async navigatePeriodNote(e){let n=this.app.workspace.getActiveFile();if(!n){new y.Notice("No active file");return}let a=this.detectPeriodType(n.basename);if(!a){let o=fe.map(l=>`${X[l].label.toLowerCase()} "${this.settings[X[l].key].nameFormat}"`).join(", ");new y.Notice(`Waypoint: "${n.basename}" does not match any configured periodic note format.
|
||||
Expected one of: ${o}.`,q);return}let{period:t,date:i}=a,r=e==="next"?1:-1,s=t==="quarter"?i.clone().add(r*3,"months"):i.clone().add(r,`${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 O&&n.view.redraw()}showDateInViews(e){for(let n of this.app.workspace.getLeavesOfType(E))n.view instanceof O&&n.view.showDate(e)}},Ce=["daily","weekly","monthly","quarterly","yearly"],X={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"}},fe=["day","week","month","quarter","year"];function ve(c){return c.slice(c.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var q=1e4,Le=5e3;function oe(c){return c instanceof Error?c.message:String(c)}function $(c,d){return d?c.format(d):""}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "waypoint-sidebar",
|
||||
"name": "Waypoint Sidebar",
|
||||
"version": "1.8.0",
|
||||
"version": "1.10.0",
|
||||
"minAppVersion": "1.4.10",
|
||||
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
||||
"author": "Olivier",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "waypoint",
|
||||
"version": "1.8.0",
|
||||
"version": "1.10.0",
|
||||
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+102
-27
@@ -13,8 +13,10 @@ import {
|
||||
import { WaypointSettings, DEFAULT_SETTINGS, DateSystemSettings, DEFAULT_DATE_SYSTEM } from 'src/settings';
|
||||
import { WaypointSettingTab } from 'src/settings-tab';
|
||||
import { WaypointView, WAYPOINT_VIEW_TYPE } from 'src/views/waypoint-view';
|
||||
import { BookmarkItem, WaypointData } from 'src/models/bookmark';
|
||||
import { BookmarkItem, RecentFileEntry, WaypointData } from 'src/models/bookmark';
|
||||
import { DatePickerModal } from 'src/modals/date-picker-modal';
|
||||
import { remapRenamedPath } from 'src/utils/path-utils';
|
||||
import { recentFilesFor, trimRecentFiles } from 'src/utils/recent-files';
|
||||
import {
|
||||
splitNameFormat,
|
||||
isInFolder,
|
||||
@@ -52,7 +54,7 @@ export interface DateSystemIndicator {
|
||||
export default class WaypointPlugin extends Plugin {
|
||||
public settings: WaypointSettings;
|
||||
public waypointData: WaypointData;
|
||||
public recentFiles: { path: string; basename: string }[] = [];
|
||||
public recentFiles: RecentFileEntry[] = [];
|
||||
private recentFilesSaveTimer: number | undefined;
|
||||
/** Serializes writes to data.json so overlapping saves cannot lose updates. */
|
||||
private savePromise: Promise<void> = Promise.resolve();
|
||||
@@ -67,6 +69,13 @@ export default class WaypointPlugin extends Plugin {
|
||||
* even if this session never triggers another settings write.
|
||||
*/
|
||||
private indicatorModeMigrated = false;
|
||||
/**
|
||||
* The file that was active just before the current one. Its editor may
|
||||
* still flush a pending save after the switch, which is the user's own
|
||||
* edit and must not be flagged as a background change.
|
||||
*/
|
||||
private previouslyActive: { path: string; until: number } | null = null;
|
||||
private activePath: string | null = null;
|
||||
|
||||
async onload(): Promise<void> {
|
||||
console.debug('Waypoint: loading plugin v' + this.manifest.version);
|
||||
@@ -178,6 +187,17 @@ export default class WaypointPlugin extends Plugin {
|
||||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: 'waypoint-open-date',
|
||||
name: 'Open daily note for a date…',
|
||||
callback: () => {
|
||||
new DatePickerModal(this.app, moment(), (date) => {
|
||||
this.showDateInViews(date);
|
||||
void this.openPeriodNote('day', date);
|
||||
}).open();
|
||||
},
|
||||
});
|
||||
|
||||
// ── Period navigation commands (no hotkeys) ──
|
||||
|
||||
const directions = ['next', 'prev'] as const;
|
||||
@@ -216,7 +236,7 @@ export default class WaypointPlugin extends Plugin {
|
||||
this.app.vault.on('rename', (file, oldPath) => this.onRename(file, oldPath)),
|
||||
);
|
||||
this.registerEvent(
|
||||
this.app.vault.on('modify', (file: TAbstractFile) => this.onFileModify(file)),
|
||||
this.app.vault.on('modify', (file: TAbstractFile) => this.onFileChange(file)),
|
||||
);
|
||||
|
||||
// Auto-open view on first load
|
||||
@@ -265,6 +285,16 @@ export default class WaypointPlugin extends Plugin {
|
||||
const s = (saved?.settings || {}) as Partial<WaypointSettings>;
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, s);
|
||||
this.settings.recentFiles = Object.assign({}, DEFAULT_SETTINGS.recentFiles, s.recentFiles || {});
|
||||
// Drop keys of removed features: the old type filter (`filterTags`,
|
||||
// then `showTypeFilter`) and the single `updateOn` mode, now the header
|
||||
// filter `show`.
|
||||
const legacyRecent = this.settings.recentFiles as Partial<{ filterTags: string[]; showTypeFilter: boolean; updateOn: string }>;
|
||||
this.settings.recentFiles.types = Array.isArray(s.recentFiles?.types)
|
||||
? s.recentFiles.types.map(t => ({ ...t }))
|
||||
: [];
|
||||
delete legacyRecent.filterTags;
|
||||
delete legacyRecent.showTypeFilter;
|
||||
delete legacyRecent.updateOn;
|
||||
this.settings.calendar = Object.assign({}, DEFAULT_SETTINGS.calendar, s.calendar || {});
|
||||
this.settings.display = Object.assign({}, DEFAULT_SETTINGS.display, s.display || {});
|
||||
for (const key of PERIOD_SETTING_KEYS) {
|
||||
@@ -306,14 +336,20 @@ export default class WaypointPlugin extends Plugin {
|
||||
recentFiles: Array.isArray(d.recentFiles) ? d.recentFiles : [],
|
||||
};
|
||||
|
||||
// Load persisted recent files
|
||||
this.recentFiles = this.waypointData.recentFiles;
|
||||
|
||||
// Apply current limit (in case maxItems was reduced since last save)
|
||||
if (this.recentFiles.length > this.settings.recentFiles.maxItems) {
|
||||
this.recentFiles = this.recentFiles.slice(0, this.settings.recentFiles.maxItems);
|
||||
this.waypointData.recentFiles = this.recentFiles;
|
||||
}
|
||||
// Entries saved before per-kind timestamps carry only their order and
|
||||
// the old single tracking mode. Small descending stamps keep that order
|
||||
// and sort them after anything recorded from now on.
|
||||
const legacy = (saved?.settings as { recentFiles?: { updateOn?: string } } | undefined)?.recentFiles?.updateOn;
|
||||
const legacyKind = legacy === 'file-edit' ? 'changedAt' : 'openedAt';
|
||||
const count = this.waypointData.recentFiles.length;
|
||||
this.recentFiles = trimRecentFiles(
|
||||
this.waypointData.recentFiles.map((entry, i) =>
|
||||
entry.openedAt === undefined && entry.changedAt === undefined
|
||||
? { ...entry, [legacyKind]: count - i }
|
||||
: entry),
|
||||
this.settings.recentFiles.maxItems,
|
||||
);
|
||||
this.waypointData.recentFiles = this.recentFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,8 +389,9 @@ export default class WaypointPlugin extends Plugin {
|
||||
* Called when the maxItems setting changes.
|
||||
*/
|
||||
enforceRecentFilesLimit(): void {
|
||||
if (this.recentFiles.length > this.settings.recentFiles.maxItems) {
|
||||
this.recentFiles = this.recentFiles.slice(0, this.settings.recentFiles.maxItems);
|
||||
const trimmed = trimRecentFiles(this.recentFiles, this.settings.recentFiles.maxItems);
|
||||
if (trimmed.length !== this.recentFiles.length) {
|
||||
this.recentFiles = trimmed;
|
||||
this.persistRecentFiles();
|
||||
}
|
||||
}
|
||||
@@ -373,31 +410,55 @@ export default class WaypointPlugin extends Plugin {
|
||||
// ── Recent Files ──
|
||||
|
||||
private onFileOpen(file: TFile): void {
|
||||
if (this.settings.recentFiles.updateOn !== 'file-open') return;
|
||||
this.addToRecentFiles(file);
|
||||
if (this.activePath && this.activePath !== file.path) {
|
||||
this.previouslyActive = { path: this.activePath, until: Date.now() + PENDING_SAVE_GRACE_MS };
|
||||
}
|
||||
this.activePath = file.path;
|
||||
this.recordRecentFile(file, 'opened');
|
||||
}
|
||||
|
||||
private onFileModify(file: TAbstractFile): void {
|
||||
if (this.settings.recentFiles.updateOn !== 'file-edit') return;
|
||||
/** Vault `modify`, and `create` once the layout is ready (sync, other plugins). */
|
||||
private onFileChange(file: TAbstractFile): void {
|
||||
if (!(file instanceof TFile)) return;
|
||||
// Already the most recent entry: nothing to reorder or redraw.
|
||||
if (this.recentFiles.length > 0 && this.recentFiles[0].path === file.path) return;
|
||||
this.addToRecentFiles(file);
|
||||
this.recordRecentFile(file, 'changed', this.isBackgroundChange(file));
|
||||
}
|
||||
|
||||
addToRecentFiles(file: TFile): void {
|
||||
/** A change the user did not make in the editor: the file is neither active nor just left. */
|
||||
private isBackgroundChange(file: TFile): boolean {
|
||||
if (this.app.workspace.getActiveFile()?.path === file.path) return false;
|
||||
const prev = this.previouslyActive;
|
||||
return !(prev && prev.path === file.path && Date.now() < prev.until);
|
||||
}
|
||||
|
||||
/** Stamp `file` as just opened or just changed. Opening clears the background dot. */
|
||||
private recordRecentFile(file: TFile, kind: 'opened' | 'changed', background = false): void {
|
||||
if (this.isOmittedFromRecentFiles(file)) return;
|
||||
|
||||
this.recentFiles = this.recentFiles.filter(f => f.path !== file.path);
|
||||
this.recentFiles.unshift({ path: file.path, basename: file.basename });
|
||||
let entry = this.recentFiles.find(f => f.path === file.path);
|
||||
// The editor saves every couple of seconds while you type. When this
|
||||
// file already leads both orderings and the dot is unchanged, only the
|
||||
// timestamp moves, so the sidebar does not need a rebuild.
|
||||
const quiet = kind === 'changed'
|
||||
&& entry !== undefined
|
||||
&& this.recentFiles[0] === entry
|
||||
&& recentFilesFor(this.recentFiles, 'changed')[0] === entry
|
||||
&& !(background && !entry.changedInBackground);
|
||||
|
||||
// Apply max items limit
|
||||
if (this.recentFiles.length > this.settings.recentFiles.maxItems) {
|
||||
this.recentFiles = this.recentFiles.slice(0, this.settings.recentFiles.maxItems);
|
||||
if (!entry) {
|
||||
entry = { path: file.path, basename: file.basename };
|
||||
this.recentFiles.push(entry);
|
||||
}
|
||||
if (kind === 'opened') {
|
||||
entry.openedAt = Date.now();
|
||||
delete entry.changedInBackground;
|
||||
} else {
|
||||
entry.changedAt = Date.now();
|
||||
if (background) entry.changedInBackground = true;
|
||||
}
|
||||
|
||||
this.recentFiles = trimRecentFiles(this.recentFiles, this.settings.recentFiles.maxItems);
|
||||
this.persistRecentFiles();
|
||||
this.broadcastRedraw();
|
||||
if (!quiet) this.broadcastRedraw();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,6 +537,8 @@ export default class WaypointPlugin extends Plugin {
|
||||
this.markdownBasenames.add(file.basename);
|
||||
this.invalidateDateSystemIndicators();
|
||||
}
|
||||
// The initial vault scan fires `create` for every file before layout-ready.
|
||||
if (this.app.workspace.layoutReady) this.onFileChange(file);
|
||||
this.broadcastRedraw();
|
||||
}
|
||||
|
||||
@@ -972,6 +1035,15 @@ export default class WaypointPlugin extends Plugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Point every Waypoint calendar at `date`'s month and mark that day. */
|
||||
showDateInViews(date: moment.Moment): void {
|
||||
for (const leaf of this.app.workspace.getLeavesOfType(WAYPOINT_VIEW_TYPE)) {
|
||||
if (leaf.view instanceof WaypointView) {
|
||||
leaf.view.showDate(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Module helpers ──
|
||||
@@ -999,6 +1071,9 @@ function basenameFromPath(path: string): string {
|
||||
/** Notices that carry a diagnosis need longer on screen than the default. */
|
||||
const DIAGNOSTIC_NOTICE_MS = 10000;
|
||||
|
||||
/** How long after leaving a file its editor's last save still counts as the user's edit. */
|
||||
const PENDING_SAVE_GRACE_MS = 5000;
|
||||
|
||||
function describeError(err: unknown): string {
|
||||
return err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// ── Date picker modal ──
|
||||
|
||||
import { App, Modal, moment } from 'obsidian';
|
||||
|
||||
/** Native date input (the OS picker on mobile), confirmed with Enter or Open. */
|
||||
export class DatePickerModal extends Modal {
|
||||
constructor(
|
||||
app: App,
|
||||
private initialDate: moment.Moment,
|
||||
private onSubmit: (date: moment.Moment) => void,
|
||||
) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
onOpen(): void {
|
||||
this.titleEl.setText('Open date');
|
||||
|
||||
const input = this.contentEl.createEl('input', {
|
||||
type: 'date',
|
||||
value: this.initialDate.format('YYYY-MM-DD'),
|
||||
});
|
||||
input.style.width = '100%';
|
||||
input.style.marginBottom = '12px';
|
||||
input.focus();
|
||||
|
||||
const submit = (): void => {
|
||||
// A date input's value is always ISO (YYYY-MM-DD), or empty when incomplete.
|
||||
const date = moment(input.value, 'YYYY-MM-DD', true);
|
||||
if (!date.isValid()) return;
|
||||
this.close();
|
||||
this.onSubmit(date);
|
||||
};
|
||||
|
||||
input.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') submit();
|
||||
});
|
||||
|
||||
const btnContainer = this.contentEl.createDiv({ cls: 'modal-button-container' });
|
||||
btnContainer.createEl('button', { text: 'Cancel' })
|
||||
.addEventListener('click', () => this.close());
|
||||
btnContainer.createEl('button', { text: 'Open', cls: 'mod-cta' })
|
||||
.addEventListener('click', submit);
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
this.contentEl.empty();
|
||||
}
|
||||
}
|
||||
+12
-1
@@ -11,7 +11,18 @@ export interface BookmarkItem {
|
||||
indent: number;
|
||||
}
|
||||
|
||||
export interface RecentFileEntry {
|
||||
path: string;
|
||||
basename: string;
|
||||
/** Epoch ms of the last open; absent if never opened while tracked. */
|
||||
openedAt?: number;
|
||||
/** Epoch ms of the last change (yours or not); absent if never changed while tracked. */
|
||||
changedAt?: number;
|
||||
/** Changed while not the active file (sync, another plugin…); cleared once opened. */
|
||||
changedInBackground?: boolean;
|
||||
}
|
||||
|
||||
export interface WaypointData {
|
||||
bookmarks: BookmarkItem[];
|
||||
recentFiles: { path: string; basename: string }[];
|
||||
recentFiles: RecentFileEntry[];
|
||||
}
|
||||
+58
-28
@@ -2,6 +2,7 @@ import { Setting, PluginSettingTab, App, setIcon, AbstractInputSuggest, TFile }
|
||||
import type WaypointPlugin from 'src/main';
|
||||
import { WaypointSettings, DEFAULT_SETTINGS, DEFAULT_DATE_SYSTEM, PeriodNoteSettings } from 'src/settings';
|
||||
import { formatHasDateToken } from 'src/utils/date-systems';
|
||||
import { IconSuggestModal } from 'src/views/waypoint-view';
|
||||
|
||||
/**
|
||||
* Vault-wide Markdown-file suggester for template-path fields, matching
|
||||
@@ -381,7 +382,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
||||
private renderRecentTab(container: HTMLElement): void {
|
||||
new Setting(container)
|
||||
.setName('Max items')
|
||||
.setDesc('Maximum number of recent files to track.')
|
||||
.setDesc('How many recently opened files, and separately how many recently changed files, to keep. A burst of synced changes cannot push out the files you opened.')
|
||||
.addText((text) => {
|
||||
text.inputEl.setAttr('type', 'number');
|
||||
text.inputEl.setAttr('placeholder', '50');
|
||||
@@ -395,20 +396,6 @@ export class WaypointSettingTab extends PluginSettingTab {
|
||||
};
|
||||
});
|
||||
|
||||
new Setting(container)
|
||||
.setName('Update on')
|
||||
.setDesc('When to add a file to the recent list.')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown
|
||||
.addOption('file-open', 'File opened')
|
||||
.addOption('file-edit', 'File changed')
|
||||
.setValue(this.settings.recentFiles.updateOn)
|
||||
.onChange((value: 'file-open' | 'file-edit') => {
|
||||
this.settings.recentFiles.updateOn = value;
|
||||
this.saveAndRefresh();
|
||||
});
|
||||
});
|
||||
|
||||
const pathDesc = new DocumentFragment();
|
||||
pathDesc.appendText('Regex patterns for paths to exclude. One per line.');
|
||||
new Setting(container)
|
||||
@@ -439,19 +426,62 @@ export class WaypointSettingTab extends PluginSettingTab {
|
||||
};
|
||||
});
|
||||
|
||||
const filterDesc = new DocumentFragment();
|
||||
filterDesc.appendText('Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property.');
|
||||
this.renderRecentTypes(container);
|
||||
}
|
||||
|
||||
/** Frontmatter types with an icon each. */
|
||||
private renderRecentTypes(container: HTMLElement): void {
|
||||
const types = this.settings.recentFiles.types;
|
||||
|
||||
new Setting(container)
|
||||
.setName('Filter tags')
|
||||
.setDesc(filterDesc)
|
||||
.addTextArea((text) => {
|
||||
text.inputEl.setAttr('rows', 4);
|
||||
text.setPlaceholder('meeting\nperson\nproject');
|
||||
text.setValue(this.settings.recentFiles.filterTags.join('\n'));
|
||||
text.inputEl.onblur = () => {
|
||||
this.settings.recentFiles.filterTags = text.getValue().split('\n').filter(t => t.trim());
|
||||
this.saveAndRefresh();
|
||||
};
|
||||
.setHeading()
|
||||
.setName('File types')
|
||||
.setDesc('Frontmatter `type` values. A type\'s icon shows beside matching recent files.');
|
||||
|
||||
types.forEach((entry, i) => {
|
||||
new Setting(container)
|
||||
.addText((text) => {
|
||||
text.setPlaceholder('meeting');
|
||||
text.setValue(entry.type);
|
||||
text.inputEl.onblur = () => {
|
||||
const value = text.getValue().trim();
|
||||
if (value === entry.type) return;
|
||||
entry.type = value;
|
||||
this.saveAndRefresh();
|
||||
};
|
||||
})
|
||||
.addExtraButton((btn) => {
|
||||
btn
|
||||
.setIcon(entry.icon || 'image-off')
|
||||
.setTooltip(entry.icon ? `Icon: ${entry.icon}` : 'Choose icon')
|
||||
.onClick(() => {
|
||||
new IconSuggestModal(this.app, entry.icon, (icon) => {
|
||||
entry.icon = icon;
|
||||
this.saveAndRefresh();
|
||||
this.display();
|
||||
}).open();
|
||||
});
|
||||
})
|
||||
.addExtraButton((btn) => {
|
||||
btn
|
||||
.setIcon('trash')
|
||||
.setTooltip('Remove this type')
|
||||
.onClick(() => {
|
||||
types.splice(i, 1);
|
||||
this.saveAndRefresh();
|
||||
this.display();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(container)
|
||||
.addButton((btn) => {
|
||||
btn
|
||||
.setButtonText('Add type')
|
||||
.onClick(() => {
|
||||
types.push({ type: '', icon: '' });
|
||||
this.display();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -576,7 +606,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
||||
`<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> — 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> — a list of recently opened files with type filtering, drag-and-drop, and right-click actions.</li>`,
|
||||
`<li><strong>Recent Files</strong> — a list of recently opened and changed files with type icons, drag-and-drop, and right-click actions.</li>`,
|
||||
`<li><strong>Bookmarks</strong> — 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>`,
|
||||
|
||||
+16
-4
@@ -1,3 +1,5 @@
|
||||
import type { RecentFilesShow } from 'src/utils/recent-files';
|
||||
|
||||
// ── Waypoint Settings ──
|
||||
|
||||
export interface PeriodNoteSettings {
|
||||
@@ -51,12 +53,22 @@ export interface CalendarSettings {
|
||||
dailyIndicatorColor: string;
|
||||
}
|
||||
|
||||
/** A frontmatter `type` value and its icon in Recent Files. */
|
||||
export interface RecentFileType {
|
||||
type: string;
|
||||
/** Lucide icon name; empty for none. */
|
||||
icon: string;
|
||||
}
|
||||
|
||||
export interface RecentFilesSettings {
|
||||
/** Kept per kind: the N most recently opened plus the N most recently changed. */
|
||||
maxItems: number;
|
||||
updateOn: 'file-open' | 'file-edit';
|
||||
/** Header filter: opened files, changed files, or both. */
|
||||
show: RecentFilesShow;
|
||||
omittedPaths: string[];
|
||||
omittedTags: string[];
|
||||
filterTags: string[]; // tags to show as filter pills (empty = auto-detect from frontmatter)
|
||||
/** Frontmatter types with an icon each. */
|
||||
types: RecentFileType[];
|
||||
}
|
||||
|
||||
export interface DisplaySettings {
|
||||
@@ -145,10 +157,10 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
|
||||
],
|
||||
recentFiles: {
|
||||
maxItems: 50,
|
||||
updateOn: 'file-open',
|
||||
show: 'all',
|
||||
omittedPaths: [],
|
||||
omittedTags: [],
|
||||
filterTags: [],
|
||||
types: [],
|
||||
},
|
||||
display: {
|
||||
rowSize: 26,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// ── Recent files ordering ──
|
||||
//
|
||||
// Pure helpers (no 'obsidian' import) shared by the plugin, which trims the
|
||||
// stored list, and the view, which filters it for display.
|
||||
|
||||
import type { RecentFileEntry } from 'src/models/bookmark';
|
||||
|
||||
/** Which recent files the sidebar lists. */
|
||||
export type RecentFilesShow = 'all' | 'opened' | 'changed';
|
||||
|
||||
/** The timestamp `show` sorts by, or undefined when the entry is not listed. */
|
||||
function sortKey(entry: RecentFileEntry, show: RecentFilesShow): number | undefined {
|
||||
if (show === 'opened') return entry.openedAt;
|
||||
if (show === 'changed') return entry.changedAt;
|
||||
if (entry.openedAt === undefined) return entry.changedAt;
|
||||
if (entry.changedAt === undefined) return entry.openedAt;
|
||||
return Math.max(entry.openedAt, entry.changedAt);
|
||||
}
|
||||
|
||||
/** Entries listed under `show`, most recent first. */
|
||||
export function recentFilesFor(entries: RecentFileEntry[], show: RecentFilesShow): RecentFileEntry[] {
|
||||
const keyed: { entry: RecentFileEntry; key: number }[] = [];
|
||||
for (const entry of entries) {
|
||||
const key = sortKey(entry, show);
|
||||
if (key !== undefined) keyed.push({ entry, key });
|
||||
}
|
||||
keyed.sort((a, b) => b.key - a.key);
|
||||
return keyed.map(k => k.entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep an entry while it is among the `max` most recently opened OR the `max`
|
||||
* most recently changed files, so a burst of synced changes cannot push out
|
||||
* the files you opened. Returns the kept entries most recent first.
|
||||
*/
|
||||
export function trimRecentFiles(entries: RecentFileEntry[], max: number): RecentFileEntry[] {
|
||||
const kept = new Set<RecentFileEntry>([
|
||||
...recentFilesFor(entries, 'opened').slice(0, max),
|
||||
...recentFilesFor(entries, 'changed').slice(0, max),
|
||||
]);
|
||||
return recentFilesFor(entries, 'all').filter(entry => kept.has(entry));
|
||||
}
|
||||
+99
-82
@@ -18,6 +18,7 @@ import type WaypointPlugin from 'src/main';
|
||||
import type { DateSystemNotes } from 'src/main';
|
||||
import { getMonthGrid } from 'src/utils/date-utils';
|
||||
import { BookmarkItem } from 'src/models/bookmark';
|
||||
import { recentFilesFor, type RecentFilesShow } from 'src/utils/recent-files';
|
||||
|
||||
export const WAYPOINT_VIEW_TYPE = 'waypoint-view';
|
||||
|
||||
@@ -74,8 +75,10 @@ export class WaypointView extends ItemView {
|
||||
this.contentEl.style.setProperty('--wp-icon-size', d.iconSize + 'px');
|
||||
this.contentEl.style.setProperty('--wp-cal-cell-size', d.calendarCellSize + 'px');
|
||||
|
||||
this.renderFavorites();
|
||||
this.renderRecentFiles();
|
||||
// The lists scroll on their own on mobile so the calendar stays on screen.
|
||||
const lists = this.contentEl.createDiv({ cls: 'waypoint-lists' });
|
||||
this.renderFavorites(lists);
|
||||
this.renderRecentFiles(lists);
|
||||
this.renderCalendar();
|
||||
};
|
||||
|
||||
@@ -87,10 +90,19 @@ export class WaypointView extends ItemView {
|
||||
private currentDisplayYear: number = moment().year();
|
||||
private dragId: string | null = null;
|
||||
private dropZones = new WeakMap<HTMLElement, { above: boolean; into: boolean }>();
|
||||
private recentFilesFilter: string | null = null; // null = show all, else filter by type
|
||||
/** Day picked with the date picker or the "Open date" command; cleared by month navigation. */
|
||||
private selectedDate: moment.Moment | null = null;
|
||||
|
||||
/** Show `date`'s month and mark the day, without opening any note. */
|
||||
showDate(date: moment.Moment): void {
|
||||
this.currentDisplayMonth = date.month();
|
||||
this.currentDisplayYear = date.year();
|
||||
this.selectedDate = date.clone();
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
private renderCalendar(): void {
|
||||
const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
|
||||
const section = this.contentEl.createDiv({ cls: 'waypoint-section waypoint-calendar-section' });
|
||||
|
||||
const cal = section.createDiv({ cls: 'waypoint-calendar' });
|
||||
|
||||
@@ -100,7 +112,7 @@ export class WaypointView extends ItemView {
|
||||
// ── Top row: breadcrumb + today nav ──
|
||||
const topRow = cal.createDiv({ cls: 'waypoint-calendar-top' });
|
||||
|
||||
// Left: Q2 · June · 2026
|
||||
// Left: Q2 · Jun · 2026
|
||||
const breadcrumb = topRow.createDiv({ cls: 'waypoint-calendar-breadcrumb' });
|
||||
|
||||
const qLabel = displayDate.format('[Q]Q');
|
||||
@@ -115,7 +127,7 @@ export class WaypointView extends ItemView {
|
||||
}
|
||||
});
|
||||
|
||||
const mLabel = displayDate.format('MMMM');
|
||||
const mLabel = displayDate.clone().locale('en').format('MMM');
|
||||
const mEl = breadcrumb.createSpan({ cls: 'waypoint-clickable', text: mLabel });
|
||||
mEl.addEventListener('click', () => {
|
||||
this.plugin.openPeriodNote('month', displayDate);
|
||||
@@ -150,6 +162,7 @@ export class WaypointView extends ItemView {
|
||||
todayBtn.addEventListener('click', () => {
|
||||
this.currentDisplayMonth = moment().month();
|
||||
this.currentDisplayYear = moment().year();
|
||||
this.selectedDate = null;
|
||||
this.redraw();
|
||||
});
|
||||
|
||||
@@ -157,6 +170,27 @@ export class WaypointView extends ItemView {
|
||||
setIcon(nextBtn, 'chevron-right');
|
||||
nextBtn.addEventListener('click', () => this.navigateMonth(1));
|
||||
|
||||
// Invisible native date input beside the button: the OS picker (native
|
||||
// sheet on mobile) beats anything drawn here.
|
||||
const pickBtn = todayGroup.createEl('button', { cls: 'waypoint-calendar-nav-btn waypoint-calendar-pick-btn' });
|
||||
setIcon(pickBtn, 'calendar-search');
|
||||
setTooltip(pickBtn, 'Go to date');
|
||||
const pickInput = todayGroup.createEl('input', { type: 'date', cls: 'waypoint-calendar-pick-input' });
|
||||
pickInput.tabIndex = -1;
|
||||
pickInput.value = (this.selectedDate ?? now).format('YYYY-MM-DD');
|
||||
pickInput.addEventListener('change', () => {
|
||||
const picked = moment(pickInput.value, 'YYYY-MM-DD', true);
|
||||
if (picked.isValid()) this.showDate(picked);
|
||||
});
|
||||
pickBtn.addEventListener('click', () => {
|
||||
try {
|
||||
pickInput.showPicker();
|
||||
} catch {
|
||||
// Older webviews without showPicker still open the picker on click.
|
||||
pickInput.click();
|
||||
}
|
||||
});
|
||||
|
||||
// ── Calendar grid ──
|
||||
const table = cal.createEl('table');
|
||||
const thead = table.createEl('thead');
|
||||
@@ -165,7 +199,7 @@ export class WaypointView extends ItemView {
|
||||
// Week number column header (blank)
|
||||
headerRow.createEl('th', { text: '' });
|
||||
|
||||
const dayNames = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
|
||||
const dayNames = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
|
||||
const firstDay = this.plugin.settings.calendar.firstDayOfWeek;
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const idx = (firstDay + i) % 7;
|
||||
@@ -216,6 +250,10 @@ export class WaypointView extends ItemView {
|
||||
cell.addClass('today');
|
||||
}
|
||||
|
||||
if (this.selectedDate && day.date.isSame(this.selectedDate, 'day')) {
|
||||
cell.addClass('is-selected');
|
||||
}
|
||||
|
||||
if (this.plugin.settings.calendar.showNoteIndicators) {
|
||||
const dateStr = day.date.format('YYYY-MM-DD');
|
||||
if (this.plugin.settings.calendar.indicatorMode === 'any') {
|
||||
@@ -258,6 +296,7 @@ export class WaypointView extends ItemView {
|
||||
const d = moment({ year: this.currentDisplayYear, month: this.currentDisplayMonth }).add(delta, 'month');
|
||||
this.currentDisplayMonth = d.month();
|
||||
this.currentDisplayYear = d.year();
|
||||
this.selectedDate = null;
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
@@ -338,94 +377,72 @@ export class WaypointView extends ItemView {
|
||||
// Recent Files panel
|
||||
// ════════════════════════════════════════
|
||||
|
||||
private renderRecentFiles(): void {
|
||||
const section = this.contentEl.createDiv({ cls: 'waypoint-section waypoint-recent-files' });
|
||||
section.createDiv({ cls: 'waypoint-section-header', text: 'Recent Files' });
|
||||
private renderRecentFiles(parent: HTMLElement): void {
|
||||
const settings = this.plugin.settings.recentFiles;
|
||||
const section = parent.createDiv({ cls: 'waypoint-section waypoint-recent-files' });
|
||||
const header = section.createDiv({ cls: 'waypoint-section-header' });
|
||||
header.createSpan({ text: 'Recent Files' });
|
||||
|
||||
if (this.plugin.recentFiles.length === 0) {
|
||||
// ── Opened / changed switch ──
|
||||
const showBar = header.createDiv({ cls: 'waypoint-recent-show' });
|
||||
const showOptions: { value: RecentFilesShow; label: string; tooltip: string }[] = [
|
||||
{ value: 'all', label: 'all', tooltip: 'Opened or changed' },
|
||||
{ value: 'opened', label: 'opened', tooltip: 'Files you opened' },
|
||||
{ value: 'changed', label: 'changed', tooltip: 'Files that changed, by you or in the background' },
|
||||
];
|
||||
for (const option of showOptions) {
|
||||
const el = showBar.createSpan({
|
||||
cls: `waypoint-recent-show-option${settings.show === option.value ? ' is-active' : ''}`,
|
||||
text: option.label,
|
||||
});
|
||||
setTooltip(el, option.tooltip);
|
||||
el.addEventListener('click', () => {
|
||||
if (settings.show === option.value) return;
|
||||
settings.show = option.value;
|
||||
void this.plugin.saveSettings();
|
||||
this.redraw();
|
||||
});
|
||||
}
|
||||
|
||||
const shownFiles = recentFilesFor(this.plugin.recentFiles, settings.show);
|
||||
if (shownFiles.length === 0) {
|
||||
section.createDiv({ cls: 'nav-file', text: 'No recent files' });
|
||||
return;
|
||||
}
|
||||
|
||||
// ── Type filter bar ──
|
||||
const configuredTags = this.plugin.settings.recentFiles.filterTags || [];
|
||||
let typeCounts: Record<string, number> = {};
|
||||
const typeOf = (path: string): string | null => {
|
||||
const tfile = this.app.vault.getFileByPath(path);
|
||||
const type = tfile ? this.app.metadataCache.getFileCache(tfile)?.frontmatter?.type : null;
|
||||
return typeof type === 'string' ? type : null;
|
||||
};
|
||||
|
||||
if (configuredTags.length > 0) {
|
||||
// Use configured tags — count occurrences in recent files
|
||||
for (const tag of configuredTags) {
|
||||
typeCounts[tag] = 0;
|
||||
}
|
||||
for (const file of this.plugin.recentFiles) {
|
||||
const tfile = this.app.vault.getAbstractFileByPath(file.path);
|
||||
if (tfile instanceof TFile) {
|
||||
const cache = this.app.metadataCache.getFileCache(tfile);
|
||||
const type = cache?.frontmatter?.type;
|
||||
if (type && typeof type === 'string' && typeCounts.hasOwnProperty(type)) {
|
||||
typeCounts[type]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Auto-detect from frontmatter `type` property
|
||||
for (const file of this.plugin.recentFiles) {
|
||||
const tfile = this.app.vault.getAbstractFileByPath(file.path);
|
||||
if (tfile instanceof TFile) {
|
||||
const cache = this.app.metadataCache.getFileCache(tfile);
|
||||
const type = cache?.frontmatter?.type;
|
||||
if (type && typeof type === 'string') {
|
||||
typeCounts[type] = (typeCounts[type] || 0) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Rows still being typed in settings have no name yet.
|
||||
const types = settings.types.filter(t => t.type);
|
||||
|
||||
if (Object.keys(typeCounts).length > 0) {
|
||||
const filterBar = section.createDiv({ cls: 'waypoint-recent-filter' });
|
||||
// "All" pill
|
||||
const allPill = filterBar.createSpan({ cls: `waypoint-recent-pill${!this.recentFilesFilter ? ' is-active' : ''}`, text: 'all' });
|
||||
allPill.addEventListener('click', () => {
|
||||
this.recentFilesFilter = null;
|
||||
this.redraw();
|
||||
});
|
||||
// Type pills
|
||||
const sortedTypes = configuredTags.length > 0
|
||||
? Object.entries(typeCounts) // preserve configured order
|
||||
: Object.entries(typeCounts).sort((a, b) => b[1] - a[1]); // sort by count
|
||||
for (const [type, count] of sortedTypes) {
|
||||
const pill = filterBar.createSpan({ cls: `waypoint-recent-pill${this.recentFilesFilter === type ? ' is-active' : ''}` });
|
||||
pill.setText(`${type} ${count}`);
|
||||
pill.addEventListener('click', () => {
|
||||
this.recentFilesFilter = this.recentFilesFilter === type ? null : type;
|
||||
this.redraw();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ── Filter the file list ──
|
||||
let filteredFiles = this.plugin.recentFiles;
|
||||
if (this.recentFilesFilter) {
|
||||
filteredFiles = this.plugin.recentFiles.filter(file => {
|
||||
const tfile = this.app.vault.getAbstractFileByPath(file.path);
|
||||
if (tfile instanceof TFile) {
|
||||
const cache = this.app.metadataCache.getFileCache(tfile);
|
||||
const type = cache?.frontmatter?.type;
|
||||
return type === this.recentFilesFilter;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
// Type icons. Every row reserves the icon slot once any type has an
|
||||
// icon, so names stay aligned.
|
||||
const typeIcons = new Map(types.filter(t => t.icon).map(t => [t.type, t.icon]));
|
||||
const reserveIcon = typeIcons.size > 0;
|
||||
|
||||
const openFile = this.app.workspace.getActiveFile();
|
||||
const rootEl = section.createDiv({ cls: 'nav-folder mod-root' });
|
||||
const childrenEl = rootEl.createDiv({ cls: 'nav-folder-children' });
|
||||
|
||||
for (const file of filteredFiles) {
|
||||
for (const file of shownFiles) {
|
||||
const navFile = childrenEl.createDiv({ cls: 'tree-item nav-file' });
|
||||
const navFileTitle = navFile.createDiv({ cls: 'tree-item-self is-clickable nav-file-title' });
|
||||
if (reserveIcon) {
|
||||
const iconEl = navFileTitle.createDiv({ cls: 'waypoint-recent-icon' });
|
||||
const icon = typeIcons.get(typeOf(file.path) ?? '');
|
||||
if (icon) setIcon(iconEl, icon);
|
||||
}
|
||||
const navFileTitleContent = navFileTitle.createDiv({ cls: 'tree-item-inner nav-file-title-content' });
|
||||
navFileTitleContent.setText(file.basename);
|
||||
const spacer = navFileTitle.createDiv({ cls: 'tree-item-spacer' });
|
||||
navFileTitle.createDiv({ cls: 'tree-item-spacer' });
|
||||
if (file.changedInBackground) {
|
||||
const changedEl = navFileTitle.createDiv({ cls: 'waypoint-recent-changed' });
|
||||
setTooltip(changedEl, 'Changed in the background');
|
||||
}
|
||||
|
||||
// Remove button
|
||||
const removeBtn = navFileTitle.createDiv({ cls: 'waypoint-recent-remove' });
|
||||
@@ -523,8 +540,8 @@ export class WaypointView extends ItemView {
|
||||
// Favorites panel
|
||||
// ════════════════════════════════════════
|
||||
|
||||
private renderFavorites(): void {
|
||||
const section = this.contentEl.createDiv({ cls: 'waypoint-section waypoint-favorites' });
|
||||
private renderFavorites(parent: HTMLElement): void {
|
||||
const section = parent.createDiv({ cls: 'waypoint-section waypoint-favorites' });
|
||||
const headerEl = section.createDiv({ cls: 'waypoint-section-header' });
|
||||
headerEl.setText('Waypoint Bookmarks');
|
||||
|
||||
@@ -1261,7 +1278,7 @@ function loadIconCatalog(): Promise<Record<string, string[]>> {
|
||||
return iconCatalog;
|
||||
}
|
||||
|
||||
class IconSuggestModal extends Modal {
|
||||
export class IconSuggestModal extends Modal {
|
||||
private onSubmit: (icon: string) => void;
|
||||
private selected: string;
|
||||
private allIcons: string[] = [];
|
||||
|
||||
+120
-29
@@ -13,7 +13,7 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.waypoint-view .waypoint-section:last-child {
|
||||
.waypoint-view .waypoint-calendar-section {
|
||||
margin-top: auto;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
@@ -102,6 +102,20 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Anchors the native picker under the date button without taking space. */
|
||||
.waypoint-calendar-today-group .waypoint-calendar-pick-input {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.waypoint-calendar-today-group button {
|
||||
@@ -194,6 +208,40 @@
|
||||
background-color: var(--background-modifier-active-hover);
|
||||
}
|
||||
|
||||
/* Day jumped to with the date picker or the "Open date" command. */
|
||||
.waypoint-calendar .waypoint-day.is-selected {
|
||||
color: var(--text-on-accent);
|
||||
background-color: var(--interactive-accent);
|
||||
}
|
||||
|
||||
.waypoint-calendar .waypoint-day.is-selected:hover {
|
||||
background-color: var(--interactive-accent-hover);
|
||||
}
|
||||
|
||||
/* Lists wrap only so mobile can scroll them apart from the calendar. */
|
||||
.waypoint-lists {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
/* Mobile drawer: the whole calendar stays on screen; the lists scroll above it. */
|
||||
.is-mobile .waypoint-view {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.is-mobile .waypoint-view .waypoint-lists {
|
||||
display: block;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* Mobile's wide default buttons push the date button out of the calendar. */
|
||||
.is-mobile .waypoint-calendar-today-group button {
|
||||
width: auto;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
/* Single-dot mode preserves the pre-date-systems indicator. */
|
||||
.waypoint-calendar .waypoint-day.has-note::after {
|
||||
content: '';
|
||||
@@ -232,34 +280,6 @@
|
||||
|
||||
/* ── Recent Files ── */
|
||||
|
||||
.waypoint-recent-filter {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.waypoint-recent-pill {
|
||||
font-size: var(--font-ui-smaller);
|
||||
color: var(--text-muted);
|
||||
background: var(--background-modifier-hover);
|
||||
padding: 1px 6px;
|
||||
border-radius: 10px;
|
||||
cursor: var(--cursor-link, pointer);
|
||||
transition: color 80ms, background 80ms;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.waypoint-recent-pill:hover {
|
||||
color: var(--text-normal);
|
||||
background: var(--background-modifier-active-hover);
|
||||
}
|
||||
|
||||
.waypoint-recent-pill.is-active {
|
||||
color: var(--text-on-accent);
|
||||
background: var(--interactive-accent);
|
||||
}
|
||||
|
||||
.waypoint-recent-files .nav-file {
|
||||
padding: 2px 0;
|
||||
}
|
||||
@@ -268,6 +288,8 @@
|
||||
padding: 2px 28px 2px 4px;
|
||||
font-size: var(--font-ui-small);
|
||||
position: relative;
|
||||
/* Obsidian's baseline alignment puts the type icon above the text's centre. */
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.waypoint-recent-files .waypoint-recent-remove {
|
||||
@@ -294,6 +316,64 @@
|
||||
color: var(--text-accent);
|
||||
}
|
||||
|
||||
/* Header switch: all / opened / changed. */
|
||||
.waypoint-recent-show {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
font-weight: var(--font-normal);
|
||||
}
|
||||
|
||||
.waypoint-recent-show-option {
|
||||
font-size: var(--font-ui-smaller);
|
||||
color: var(--text-faint);
|
||||
padding: 0 6px;
|
||||
border-radius: 10px;
|
||||
cursor: var(--cursor-link, pointer);
|
||||
user-select: none;
|
||||
transition: color 80ms, background 80ms;
|
||||
}
|
||||
|
||||
.waypoint-recent-show-option:hover {
|
||||
color: var(--text-normal);
|
||||
background: var(--background-modifier-hover);
|
||||
}
|
||||
|
||||
.waypoint-recent-show-option.is-active {
|
||||
color: var(--text-normal);
|
||||
background: var(--background-modifier-active-hover);
|
||||
}
|
||||
|
||||
/* Icon of the file's configured frontmatter type; empty slots keep names aligned. */
|
||||
.waypoint-recent-files .waypoint-recent-icon {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 16px;
|
||||
/* Same box with or without an icon, and shorter than a text line, so rows keep one height. */
|
||||
height: 14px;
|
||||
margin-right: 6px;
|
||||
color: var(--text-muted);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.waypoint-recent-files .waypoint-recent-icon svg {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
/* Changed in the background (sync, another plugin) since last opened. */
|
||||
.waypoint-recent-files .waypoint-recent-changed {
|
||||
flex-shrink: 0;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
margin-left: 6px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--interactive-accent);
|
||||
}
|
||||
|
||||
/* ── Favorites ── */
|
||||
|
||||
.waypoint-favorites .waypoint-bookmark-item {
|
||||
@@ -423,6 +503,7 @@ button.waypoint-calendar-today-btn {
|
||||
|
||||
.waypoint-settings-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid var(--background-modifier-border);
|
||||
@@ -453,6 +534,16 @@ button.waypoint-calendar-today-btn {
|
||||
margin-bottom: -9px;
|
||||
}
|
||||
|
||||
/* Wrapped rows cannot sit on the bar's bottom border, so mobile tabs are pills. */
|
||||
.is-mobile .waypoint-settings-tab {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.is-mobile .waypoint-settings-tab.is-active {
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* ── Icon picker ── */
|
||||
|
||||
/* Sits left of Cancel/Save so clearing reads as a separate, secondary action. */
|
||||
|
||||
Reference in new issue
Block a user