feat: add bookmark from recent files + calendar middle-click

- Recent files right-click now has 'Add to bookmarks' option
- Calendar: middle-click on day/week/quarter/month/year opens in new tab
- Added openPeriodNoteInLeaf() method for opening period notes in a specific leaf
This commit is contained in:
2026-06-11 10:46:57 -04:00
parent eeb6059fe5
commit a36c8ab6f4
3 changed files with 89 additions and 6 deletions
+37
View File
@@ -376,6 +376,43 @@ export default class WaypointPlugin extends Plugin {
}
}
// ── Open period note in a specific leaf (for middle-click) ──
async openPeriodNoteInLeaf(period: 'day' | 'week' | 'month' | 'quarter' | 'year', date: moment.Moment, leaf: any): Promise<void> {
type PeriodConfig = { settings: PeriodNoteSettings; label: string };
const configs: Record<string, PeriodConfig> = {
day: { settings: this.settings.daily, label: 'Daily' },
week: { settings: this.settings.weekly, label: 'Weekly' },
month: { settings: this.settings.monthly, label: 'Monthly' },
quarter: { settings: this.settings.quarterly, label: 'Quarterly' },
year: { settings: this.settings.yearly, label: 'Yearly' },
};
const config = configs[period];
if (!config) return;
const { settings: periodSettings } = config;
const filename = date.format(periodSettings.nameFormat) + '.md';
const fullPath = periodSettings.folder ? `${periodSettings.folder}/${filename}` : filename;
let file = this.app.vault.getFileByPath(fullPath);
if (!file) {
try {
const templatePath = periodSettings.templateFile + '.md';
const templateFile = this.app.vault.getFileByPath(templatePath);
if (templateFile) {
const templateContent = await this.app.vault.read(templateFile);
file = await this.app.vault.create(fullPath, templateContent);
} else {
const content = `---\ntype: ${periodSettings.typeProperty}\ndate: ${date.format('YYYY-MM-DD')}\n---\n\n`;
file = await this.app.vault.create(fullPath, content);
}
} catch (err) {
new Notice(`Failed to create ${config.label.toLowerCase()} note: ${err.message}`);
return;
}
}
if (file) {
await leaf.openFile(file);
}
}
// ── Period note navigation (next/prev from current file) ──
/**