release v1.8.0: reuse open tabs for periodic notes
This commit is contained in:
1 parent
695141383f
commit
984a0ab44f
10 files changed
+75
-32
No files matched your search
+5
-4
@@ -53,6 +53,7 @@ Detaches all leaves of `WAYPOINT_VIEW_TYPE`.
|
|||||||
interface WaypointSettings {
|
interface WaypointSettings {
|
||||||
calendar: CalendarSettings; // week start, indicator visibility/style, daily indicator colour
|
calendar: CalendarSettings; // week start, indicator visibility/style, daily indicator colour
|
||||||
daily: PeriodNoteSettings;
|
daily: PeriodNoteSettings;
|
||||||
|
reusePeriodicNoteTabs: boolean; // defaults to false; all periodic-note openers reuse an open tab
|
||||||
weekly: PeriodNoteSettings;
|
weekly: PeriodNoteSettings;
|
||||||
monthly: PeriodNoteSettings;
|
monthly: PeriodNoteSettings;
|
||||||
quarterly: PeriodNoteSettings;
|
quarterly: PeriodNoteSettings;
|
||||||
@@ -132,7 +133,7 @@ The bookmark tree is stored under `waypointData.bookmarks` and rendered recursiv
|
|||||||
| `waypoint-go-to-quarterly` | Go to quarterly note | `Mod+Shift+Alt+Q` |
|
| `waypoint-go-to-quarterly` | Go to quarterly note | `Mod+Shift+Alt+Q` |
|
||||||
| `waypoint-go-to-yearly` | Go to yearly note | `Mod+Shift+Alt+Y` |
|
| `waypoint-go-to-yearly` | Go to yearly note | `Mod+Shift+Alt+Y` |
|
||||||
|
|
||||||
All call `openPeriodNote(period, moment())` — opens or creates the current period's note.
|
All five commands call `openPeriodNote(period, moment())` — opening or creating the current period's note. **Periodic Notes → Use existing tabs** defaults to off. When enabled, the shared opener focuses a Markdown tab for the exact configured file path, including in another pane or window, without reopening the file or resetting its editor position. This also applies to next/previous navigation and regular calendar clicks. With no matching tab, normal note creation/opening is unchanged. Explicit open-in-new-tab actions still win; existing duplicate tabs are not closed.
|
||||||
|
|
||||||
### Next/Previous period (no default hotkeys)
|
### Next/Previous period (no default hotkeys)
|
||||||
|
|
||||||
@@ -237,7 +238,7 @@ getDateSystemIndicators(dates: moment.Moment[]): Map<string, DateSystemIndicator
|
|||||||
openDateSystemNote(
|
openDateSystemNote(
|
||||||
system: DateSystemSettings,
|
system: DateSystemSettings,
|
||||||
date: moment.Moment,
|
date: moment.Moment,
|
||||||
opts?: { title?: string; leaf?: WorkspaceLeaf },
|
opts?: { title?: string; leaf?: WorkspaceLeaf; reuseExistingLeaf?: boolean },
|
||||||
): Promise<void>
|
): Promise<void>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -252,7 +253,7 @@ openDateSystemNote(
|
|||||||
1. **Filename** — `splitNameFormat(system.nameFormat)`, format `before` and `after` against `date`, and for a many-per-date system join `sanitizeTitle(opts.title)` between them. Append `.md`; prepend `system.folder` when it is set.
|
1. **Filename** — `splitNameFormat(system.nameFormat)`, format `before` and `after` against `date`, and for a many-per-date system join `sanitizeTitle(opts.title)` between them. Append `.md`; prepend `system.folder` when it is set.
|
||||||
2. **Existing note** — a `vault.getFileByPath()` hit is opened as-is, never overwritten. A date that already has notes can still gain another in a many-per-date system, because the title makes the filename unique.
|
2. **Existing note** — a `vault.getFileByPath()` hit is opened as-is, never overwritten. A date that already has notes can still gain another in a many-per-date system, because the title makes the filename unique.
|
||||||
3. **Missing note** — created via `createDatedNote`, then opened.
|
3. **Missing note** — created via `createDatedNote`, then opened.
|
||||||
4. **Leaf** — `opts.leaf` when supplied (middle-click and Ctrl/Cmd-click pass an explicit tab leaf), otherwise `workspace.getLeaf(false)`.
|
4. **Leaf** — an explicit `opts.leaf` always wins (middle-click and Ctrl/Cmd-click pass a tab leaf). Otherwise, when `opts.reuseExistingLeaf` is true, scan Markdown leaves by `getViewState().state.file` so deferred tabs also match; compare the complete file path, not the basename. Await `workspace.revealLeaf(existing)` to reveal/load the tab, then call `workspace.setActiveLeaf(existing, { focus: true })` to activate it and focus its editor. Return without calling `openFile`, preserving editor position. With no matching tab, or when reuse is disabled, open in `workspace.getLeaf(false)` as before.
|
||||||
|
|
||||||
### Note creation (`createDatedNote`)
|
### Note creation (`createDatedNote`)
|
||||||
|
|
||||||
@@ -273,7 +274,7 @@ openPeriodNote(
|
|||||||
): Promise<void>
|
): Promise<void>
|
||||||
```
|
```
|
||||||
|
|
||||||
Single unified opener — there is no separate `openPeriodNoteInLeaf`, and since the date-systems refactor there is no separate creation path either. `openPeriodNote` synthesizes the period's `PeriodNoteSettings` into a `DateSystemSettings` (`folder`, `nameFormat`, `templateFile` and `typeProperty` carry over verbatim; a period format never contains `{title}`, so a period maps to exactly one filename) and delegates to `openDateSystemNote(system, date, { leaf })`.
|
Single unified opener — there is no separate `openPeriodNoteInLeaf`, and since the date-systems refactor there is no separate creation path either. `openPeriodNote` synthesizes the period's `PeriodNoteSettings` into a `DateSystemSettings` (`folder`, `nameFormat`, `templateFile` and `typeProperty` carry over verbatim; a period format never contains `{title}`, so a period maps to exactly one filename) and delegates to `openDateSystemNote(system, date, { leaf, reuseExistingLeaf: settings.reusePeriodicNoteTabs })`. All five periodic-note types therefore share the same tab-reuse policy, with an explicit `leaf` taking precedence.
|
||||||
|
|
||||||
Filename building, the existence check, template-or-frontmatter creation and leaf selection are therefore documented once, under Date Systems above.
|
Filename building, the existence check, template-or-frontmatter creation and leaf selection are therefore documented once, under Date Systems above.
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,17 @@
|
|||||||
- [ ] Bookmarks persist across vault reload
|
- [ ] Bookmarks persist across vault reload
|
||||||
- [ ] Move a folder containing bookmarked files to a new location → those bookmarks survive and still open the moved files
|
- [ ] Move a folder containing bookmarked files to a new location → those bookmarks survive and still open the moved files
|
||||||
|
|
||||||
|
## Periodic Notes: Reuse Existing Tabs
|
||||||
|
|
||||||
|
- [ ] An existing configuration without `reusePeriodicNoteTabs` loads with the toggle off
|
||||||
|
- [ ] Enable **Periodic Notes → Use existing tabs**, reload the plugin, and verify it stays enabled
|
||||||
|
- [ ] For each of daily, weekly, monthly, quarterly, and yearly: open the current note in another pane, run its **Go to…** command repeatedly → that tab becomes active, its editor position is preserved, and no duplicate opens
|
||||||
|
- [ ] For each type, a note with the same basename in another folder is not reused; the configured path opens or is created normally
|
||||||
|
- [ ] Regular calendar clicks and next/previous navigation focus existing periodic-note tabs when enabled
|
||||||
|
- [ ] With the toggle off, all five commands retain their original active-leaf opening behaviour
|
||||||
|
- [ ] With the toggle on, an explicit open-in-new-tab action still creates a new tab
|
||||||
|
- [ ] A deferred periodic-note tab or a periodic-note tab in a pop-out window is revealed and focused instead of duplicated
|
||||||
|
|
||||||
## Calendar (Regression)
|
## Calendar (Regression)
|
||||||
|
|
||||||
- [ ] Calendar renders with correct month grid
|
- [ ] Calendar renders with correct month grid
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ Calendar, recent files, and custom bookmarks sidebar for Obsidian.
|
|||||||
| Go to yearly note | `Ctrl+Shift+Alt+Y` |
|
| Go to yearly note | `Ctrl+Shift+Alt+Y` |
|
||||||
| Next/Previous daily/weekly/monthly/quarterly/yearly note | — |
|
| Next/Previous daily/weekly/monthly/quarterly/yearly note | — |
|
||||||
|
|
||||||
|
Under **Settings → Waypoint Sidebar → Periodic Notes**, turn on **Use existing tabs** to switch to a daily, weekly, monthly, quarterly, or yearly note's tab if it is already open. This works with the five **Go to…** commands, next/previous navigation, and regular calendar clicks. If the note is not open, it opens or is created as usual. The setting is off by default. It keeps your place in the note and leaves existing duplicate tabs alone. Choosing to open a new tab still opens a new tab.
|
||||||
|
|
||||||
## Date systems
|
## Date systems
|
||||||
|
|
||||||
Right-click any calendar day to open its **date systems** menu. The daily note always appears first; left-click behaviour is unchanged. The included defaults match this vault's common layouts:
|
Right-click any calendar day to open its **date systems** menu. The daily note always appears first; left-click behaviour is unchanged. The included defaults match this vault's common layouts:
|
||||||
|
|||||||
@@ -2,26 +2,26 @@
|
|||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Q=Object.defineProperty;var 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 a of ue(d))!ge.call(p,a)&&a!==e&&Q(p,a,{get:()=>d[a],enumerable:!(n=he(d,a))||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"},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 v=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,a=e&&p.endsWith(e)?p.length-e.length:p.length;return a<=n?p:p.slice(n,a).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 v.AbstractInputSuggest{constructor(e,n){super(e,n);this.inputEl=n}getSuggestions(e){let n=e.toLowerCase();return this.app.vault.getMarkdownFiles().filter(a=>a.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 v.PluginSettingTab{constructor(e,n,a,t){super(e,n);this.activeTab="calendar";this.plugin=n,this.settings=a,this.onSettingsChange=t}display(){let{containerEl:e}=this;e.empty();let n=e.createDiv({cls:"waypoint-settings-tabs"}),a=[{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 i of a)n.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===i.key?" is-active":""}`,text:i.label}).addEventListener("click",()=>{this.activeTab=i.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 v.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(a=>{this.settings.calendar.firstDayOfWeek=parseInt(a,10),this.saveAndRefresh()})}),new v.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(a=>{this.settings.calendar.showNoteIndicators=a,this.saveAndRefresh()})}),new v.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(a=>{this.settings.calendar.indicatorMode=a,this.saveAndRefresh()})}),new v.Setting(e).setName("Daily indicator colour").setDesc("Colour for daily-note doLine truncated
|
var Q=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var fe=(p,d)=>{for(var e in d)Q(p,e,{get:d[e],enumerable:!0})},ye=(p,d,e,n)=>{if(d&&typeof d=="object"||typeof d=="function")for(let i of ue(d))!ge.call(p,i)&&i!==e&&Q(p,i,{get:()=>d[i],enumerable:!(n=he(d,i))||n.enumerable});return p};var ve=p=>ye(Q({},"__esModule",{value:!0}),p);var Fe={};fe(Fe,{default:()=>G});module.exports=ve(Fe);var f=require("obsidian");var $={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file",indicatorColor:"#64748b"},T={calendar:{firstDayOfWeek:1,showNoteIndicators:!0,indicatorMode:"systems",dailyIndicatorColor:"#3b82f6"},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},reusePeriodicNoteTabs:!1,weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},dateSystems:[{id:"journal",name:"Journal",folder:"periodic/journal",nameFormat:"YYYY-MM-DD - [Journal]",templateFile:"",typeProperty:"journal",icon:"book-open",indicatorColor:"#22c55e"},{id:"meetings",name:"Meeting",folder:"periodic/meetings",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"meeting",icon:"users",indicatorColor:"#a855f7"}],recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var y=require("obsidian");var oe="{title}";function R(p){let d=p.indexOf(oe);return d<0?{before:p,after:"",hasTitle:!1}:{before:p.slice(0,d),after:p.slice(d+oe.length),hasTitle:!0}}function U(p,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return p.startsWith(e)}function Z(p,d,e,n){return n?!d||p.length<d.length+e.length?!1:p.startsWith(d)&&p.endsWith(e):p===d+e}function re(p,d,e){let n=p.startsWith(d)?d.length:0,i=e&&p.endsWith(e)?p.length-e.length:p.length;return i<=n?p:p.slice(n,i).trim()||p}var ke=/[\\/:*?"<>|#^[\]]/g;function le(p){return p.replace(ke,"-").replace(/\s+/g," ").trim()}function A(p){let{before:d}=R(p),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var z=class extends y.AbstractInputSuggest{constructor(e,n){super(e,n);this.inputEl=n}getSuggestions(e){let n=e.toLowerCase();return this.app.vault.getMarkdownFiles().filter(i=>i.path.toLowerCase().includes(n)).slice(0,200)}renderSuggestion(e,n){n.setText(e.path.replace(/\.md$/,""))}selectSuggestion(e){this.setValue(e.path.replace(/\.md$/,"")),this.inputEl.trigger("input"),this.close()}},V=class extends y.PluginSettingTab{constructor(e,n,i,t){super(e,n);this.activeTab="calendar";this.plugin=n,this.settings=i,this.onSettingsChange=t}display(){let{containerEl:e}=this;e.empty();let n=e.createDiv({cls:"waypoint-settings-tabs"}),i=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"systems",label:"Date systems"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let a of i)n.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===a.key?" is-active":""}`,text:a.label}).addEventListener("click",()=>{this.activeTab=a.key,this.display()});let t=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(t);break;case"periodic":this.renderPeriodicTab(t);break;case"systems":this.renderSystemsTab(t);break;case"recent":this.renderRecentTab(t);break;case"display":this.renderDisplayTab(t);break;case"about":this.renderAboutTab(t);break}}renderCalendarTab(e){new y.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(n=>{n.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(i=>{this.settings.calendar.firstDayOfWeek=parseInt(i,10),this.saveAndRefresh()})}),new y.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(n=>{n.setValue(this.settings.calendar.showNoteIndicators).onChange(i=>{this.settings.calendar.showNoteIndicators=i,this.saveAndRefresh()})}),new y.Setting(e).setName("Indicator style").setDesc("Show one neutral dot for any dated note, or one coloured dot for each configured date system.").addDropdown(n=>{n.addOption("any","Single dot").addOption("systems","Colour by note system").setValue(this.settings.calendar.indicatorMode).onChange(i=>{this.settings.calendar.indicatorMode=i,this.saveAndRefresh()})}),new y.Setting(e).setName("Daily indicator colour").setDesc(Line truncated
|
||||||
\\.png$`),i.setValue(this.settings.recentFiles.omittedPaths.join(`
|
\\.png$`),a.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||||
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=i.getValue().split(`
|
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=a.getValue().split(`
|
||||||
`).filter(o=>o.trim()),this.saveAndRefresh()}});let a=new DocumentFragment;a.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new v.Setting(e).setName("Omitted tags").setDesc(a).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`ignore
|
`).filter(o=>o.trim()),this.saveAndRefresh()}});let i=new DocumentFragment;i.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new y.Setting(e).setName("Omitted tags").setDesc(i).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`ignore
|
||||||
archive`),i.setValue(this.settings.recentFiles.omittedTags.join(`
|
archive`),a.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||||
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=i.getValue().split(`
|
`)),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 v.Setting(e).setName("Filter tags").setDesc(t).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`meeting
|
`).filter(o=>o.trim()),this.saveAndRefresh()}});let t=new DocumentFragment;t.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new y.Setting(e).setName("Filter tags").setDesc(t).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`meeting
|
||||||
person
|
person
|
||||||
project`),i.setValue(this.settings.recentFiles.filterTags.join(`
|
project`),a.setValue(this.settings.recentFiles.filterTags.join(`
|
||||||
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=i.getValue().split(`
|
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=a.getValue().split(`
|
||||||
`).filter(o=>o.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new v.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 v.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new v.Setting(e).addButton(n=>n.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...T.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,n,a,t,i,o,s,r,c){let l=new v.Setting(e).setName(n).setDesc(`${a} (${t[i]}${c})`);l.addSlider(h=>{h.setLimits(o,s,r).setValue(t[i]).setDynamicTooltip().onChange(u=>{t[i]=u,l.setDesc(`${a} (${u}${c})`),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,v.setIcon)(t,"compass");let i=a.createDiv(),o=i.createEl("h2",{text:"Waypoint Sidebar"});o.style.margin="0",o.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 r=e.createDiv();r.style.marginBottom="20px",r.style.lineHeight="1.6",r.style.color="var(--text-normal)",r.innerHTML=["<p><strong>Waypoint</strong> is a sidebar plugin that brings three essential panels into one view:</p>",'<ul style="padding-left: 20px; margin: 8px 0;">',"<li><strong>Calendar</strong> \u2014 a monthly grid for your periodic notes (daily, weekly, monthly, quarterly, yearly). Click any day, week, or month to open or create the corresponding note.</li>","<li><strong>Recent Files</strong> \u2014 a list of recently opened files with type filtering, drag-and-drop, and right-click actions.</li>","<li><strong>Bookmarks</strong> \u2014 custom bookmarks with icons, groups, nesting, and drag-and-drop reordering. Separate from Obsidian's native bookmarks.</li>","</ul>",'<p style="color: var(--text-muted); font-size: var(--font-ui-small);">Made by Olivier. Licensed under MIT.</p>'].join(`
|
`).filter(o=>o.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new y.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new y.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new y.Setting(e).addButton(n=>n.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...T.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,n,i,t,a,o,s,r,c){let l=new y.Setting(e).setName(n).setDesc(`${i} (${t[a]}${c})`);l.addSlider(m=>{m.setLimits(o,s,r).setValue(t[a]).setDynamicTooltip().onChange(u=>{t[a]=u,l.setDesc(`${i} (${u}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let n=this.plugin.manifest.version,i=e.createDiv();i.style.display="flex",i.style.alignItems="center",i.style.gap="12px",i.style.marginBottom="16px";let t=i.createDiv();t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="48px",t.style.height="48px",t.style.borderRadius="12px",t.style.background="var(--interactive-accent)",t.style.color="var(--text-on-accent)",t.style.fontSize="24px",(0,y.setIcon)(t,"compass");let a=i.createDiv(),o=a.createEl("h2",{text:"Waypoint Sidebar"});o.style.margin="0",o.style.lineHeight="1.2";let s=a.createDiv({text:`v${n}`});s.style.color="var(--text-muted)",s.style.fontSize="var(--font-ui-small)";let r=e.createDiv();r.style.marginBottom="20px",r.style.lineHeight="1.6",r.style.color="var(--text-normal)",r.innerHTML=["<p><strong>Waypoint</strong> is a sidebar plugin that brings three essential panels into one view:</p>",'<ul style="padding-left: 20px; margin: 8px 0;">',"<li><strong>Calendar</strong> \u2014 a monthly grid for your periodic notes (daily, weekly, monthly, quarterly, yearly). Click any day, week, or month to open or create the corresponding note.</li>","<li><strong>Recent Files</strong> \u2014 a list of recently opened files with type filtering, drag-and-drop, and right-click actions.</li>","<li><strong>Bookmarks</strong> \u2014 custom bookmarks with icons, groups, nesting, and drag-and-drop reordering. Separate from Obsidian's native bookmarks.</li>","</ul>",'<p style="color: var(--text-muted); font-size: var(--font-ui-small);">Made by Olivier. Licensed under MIT.</p>'].join(`
|
||||||
`)}};var m=require("obsidian");var C=require("obsidian");function ce(p,d,e){let n=(0,C.moment)({year:p,month:d,day:1}),a=(0,C.moment)(n).endOf("month"),t=(0,C.moment)(n).subtract((n.day()-e+7)%7,"days"),i=(0,C.moment)().startOf("day"),o=[],s=(0,C.moment)(t);for(;s.isBefore(a)||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(i,"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 m.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,m.moment)().month();this.currentDisplayYear=(0,m.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"}),a=(0,m.moment)(),t=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),i=n.createDiv({cls:"waypoint-calendar-top"}),o=i.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 h=t.format("YYYY"),u=o.createSpan({cls:"waypoint-clickable",text:h});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=i.createDiv({cls:"waypoint-calendar-today-group"}),S=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.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,m.moment)().month(),this.currentDisplayYear=(0,m.moment)().year(),this.redraw()});let w=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(w,"chevron-right"),w.addEventListener("click",()=>this.navigateMonth(1));let b=n.createEl("table"),y=b.createEl("thead").createEl("tr");y.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;y.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,m.setTooltip)(se,ae.name)}}}}I.addEventListener("click",()=>{this.plugin.openPeriodNote("day",x.date)}),I.addEventListener("mousedown",M=>{M.
Line truncated
|
`)}};var h=require("obsidian");var C=require("obsidian");function ce(p,d,e){let n=(0,C.moment)({year:p,month:d,day:1}),i=(0,C.moment)(n).endOf("month"),t=(0,C.moment)(n).subtract((n.day()-e+7)%7,"days"),a=(0,C.moment)().startOf("day"),o=[],s=(0,C.moment)(t);for(;s.isBefore(i)||s.month()===d;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,C.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(a,"day"),isCurrentMonth:s.month()===d,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(o.push({weekNumber:r[0].isoWeekNumber,days:r}),o.length>=6)break}return o}var E="waypoint-view";function we(p){return p.dragManager}var W=class extends h.ItemView{constructor(e,n){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=n}getViewType(){return E}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let n=this.contentEl.createDiv({cls:"waypoint-section"}).createDiv({cls:"waypoint-calendar"}),i=(0,h.moment)(),t=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),a=n.createDiv({cls:"waypoint-calendar-top"}),o=a.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=t.format("[Q]Q"),r=o.createSpan({cls:"waypoint-clickable",text:s});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",t)}),r.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("quarter",t,this.app.workspace.getLeaf("tab")))});let c=t.format("MMMM"),l=o.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",t)}),l.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("month",t,this.app.workspace.getLeaf("tab")))});let m=t.format("YYYY"),u=o.createSpan({cls:"waypoint-clickable",text:m});u.addEventListener("click",()=>{this.plugin.openPeriodNote("year",t)}),u.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("year",t,this.app.workspace.getLeaf("tab")))});let g=a.createDiv({cls:"waypoint-calendar-today-group"}),S=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(S,"chevron-left"),S.addEventListener("click",()=>this.navigateMonth(-1)),g.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,h.moment)().month(),this.currentDisplayYear=(0,h.moment)().year(),this.redraw()});let w=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(w,"chevron-right"),w.addEventListener("click",()=>this.navigateMonth(1));let b=n.createEl("table"),v=b.createEl("thead").createEl("tr");v.createEl("th",{text:""});let L=["sun","mon","tue","wed","thu","fri","sat"],K=this.plugin.settings.calendar.firstDayOfWeek;for(let D=0;D<7;D++){let N=(K+D)%7;v.createEl("th",{text:L[N]})}let P=b.createEl("tbody"),te=ce(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek),_=this.plugin.settings.calendar.showNoteIndicators&&this.plugin.settings.calendar.indicatorMode==="systems"?this.plugin.getDateSystemIndicators(te.reduce((D,N)=>D.concat(N.days.map(Y=>Y.date)),[])):null;for(let D of te){let N=P.createEl("tr"),Y=N.createEl("td",{cls:"waypoint-weeknum"});Y.setText(String(D.weekNumber));let ie=D.days[0].date;Y.addEventListener("click",()=>{this.plugin.openPeriodNote("week",ie)}),Y.addEventListener("mousedown",x=>{x.button===1&&(x.preventDefault(),this.plugin.openPeriodNote("week",ie,this.app.workspace.getLeaf("tab")))});for(let x of D.days){let I=N.createEl("td",{cls:"waypoint-day"});if(I.setText(String(x.dayOfMonth)),x.isCurrentMonth||I.addClass("other-month"),x.isToday&&I.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let M=x.date.format("YYYY-MM-DD");if(this.plugin.settings.calendar.indicatorMode==="any")this.plugin.hasNoteForDate(M)&&I.addClass("has-note");else{let ne=(_==null?void 0:_.get(M))||[];if(ne.length>0){let me=I.createDiv({cls:"waypoint-day-indicators"});for(let ae of ne){let se=me.createSpan({cls:"waypoint-day-indicator"});se.style.setProperty("--waypoint-indicator-color",ae.color),(0,h.setTooltip)(se,ae.name)}}}}I.addEventListener("click",()=>{this.plugin.openPeriodNote("day",x.date)}),I.addEventListener("mousedown",M=>{M.
Line truncated
|
||||||
${ee(h)}
|
${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(h){return new f.Notice(`Waypoint: could not read the template "${r.path}" for the ${t} note.
|
Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,O),null}let s=n.templateFile,r=this.resolveTemplateFile(s),c;if(r)try{c=await this.app.vault.read(r)}catch(m){return new f.Notice(`Waypoint: could not read the template "${r.path}" for the ${t} note.
|
||||||
`+ee(h),O),null}else c=`---
|
`+ee(m),O),null}else c=`---
|
||||||
type: ${n.typeProperty}
|
type: ${n.typeProperty}
|
||||||
date: ${a.format("YYYY-MM-DD")}
|
date: ${i.format("YYYY-MM-DD")}
|
||||||
---
|
---
|
||||||
|
|
||||||
`;let l;try{l=await this.app.vault.create(e,c)}catch(h){return new f.Notice(`Waypoint: could not create the ${t} note at "${e}".
|
`;let l;try{l=await this.app.vault.create(e,c)}catch(m){return new f.Notice(`Waypoint: could not create the ${t} note at "${e}".
|
||||||
${ee(h)}`,O),null}return s&&!r?new f.Notice(`Created ${t} note: ${l.basename}
|
${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 a of e.split("/"))if(a&&(n=n?`${n}/${a}`:a,!(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 a=this.settings[j[n].key].nameFormat;if(!a)continue;let t=(0,f.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 f.Notice("No active file");return}let a=this.detectPeriodType(n.basename);if(!a){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.
|
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:i}=a,o=e==="next"?1:-1,s=t==="quarter"?i.clone().add(o*3,"months"):i.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):""}
|
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):""}
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "waypoint-sidebar",
|
"id": "waypoint-sidebar",
|
||||||
"name": "Waypoint Sidebar",
|
"name": "Waypoint Sidebar",
|
||||||
"version": "1.7.1",
|
"version": "1.8.0",
|
||||||
"minAppVersion": "1.4.10",
|
"minAppVersion": "1.4.10",
|
||||||
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
||||||
"author": "Olivier",
|
"author": "Olivier",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "waypoint",
|
"name": "waypoint",
|
||||||
"version": "1.5.1",
|
"version": "1.8.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "waypoint",
|
"name": "waypoint",
|
||||||
"version": "1.5.1",
|
"version": "1.8.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"builtin-modules": "4.0.0",
|
"builtin-modules": "4.0.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "waypoint",
|
"name": "waypoint",
|
||||||
"version": "1.7.1",
|
"version": "1.8.0",
|
||||||
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+20
-5
@@ -738,13 +738,14 @@ export default class WaypointPlugin extends Plugin {
|
|||||||
* Open (creating if needed) the note `system` holds for `date`.
|
* Open (creating if needed) the note `system` holds for `date`.
|
||||||
*
|
*
|
||||||
* `opts.title` fills the `{title}` token of a many-per-date system and is
|
* `opts.title` fills the `{title}` token of a many-per-date system and is
|
||||||
* ignored by systems without one. Opens in `opts.leaf` when given,
|
* ignored by systems without one. An explicit `opts.leaf` takes precedence;
|
||||||
* otherwise in the active leaf.
|
* otherwise `opts.reuseExistingLeaf` reveals an open Markdown tab for the
|
||||||
|
* exact file path, falling back to the active leaf when none is open.
|
||||||
*/
|
*/
|
||||||
async openDateSystemNote(
|
async openDateSystemNote(
|
||||||
system: DateSystemSettings,
|
system: DateSystemSettings,
|
||||||
date: moment.Moment,
|
date: moment.Moment,
|
||||||
opts?: { title?: string; leaf?: WorkspaceLeaf },
|
opts?: { title?: string; leaf?: WorkspaceLeaf; reuseExistingLeaf?: boolean },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
||||||
if (!formatHasDateToken(system.nameFormat)) {
|
if (!formatHasDateToken(system.nameFormat)) {
|
||||||
@@ -777,16 +778,30 @@ export default class WaypointPlugin extends Plugin {
|
|||||||
if (!file) return;
|
if (!file) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts?.reuseExistingLeaf && !opts.leaf) {
|
||||||
|
// View state also identifies deferred tabs whose view is not loaded yet.
|
||||||
|
const existing = this.app.workspace.getLeavesOfType('markdown')
|
||||||
|
.find(leaf => leaf.getViewState().state?.file === file.path);
|
||||||
|
if (existing) {
|
||||||
|
await this.app.workspace.revealLeaf(existing);
|
||||||
|
this.app.workspace.setActiveLeaf(existing, { focus: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const target = opts?.leaf || this.app.workspace.getLeaf(false);
|
const target = opts?.leaf || this.app.workspace.getLeaf(false);
|
||||||
await target.openFile(file);
|
await target.openFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open (creating if needed) the period note for `date`.
|
* Open (creating if needed) the period note for `date`.
|
||||||
* Opens in `leaf` when given, otherwise in the active leaf.
|
* An explicit `leaf` wins; otherwise reuse an open tab when enabled.
|
||||||
*/
|
*/
|
||||||
async openPeriodNote(period: PeriodKey, date: moment.Moment, leaf?: WorkspaceLeaf): Promise<void> {
|
async openPeriodNote(period: PeriodKey, date: moment.Moment, leaf?: WorkspaceLeaf): Promise<void> {
|
||||||
await this.openDateSystemNote(this.periodAsDateSystem(period), date, { leaf });
|
await this.openDateSystemNote(this.periodAsDateSystem(period), date, {
|
||||||
|
leaf,
|
||||||
|
reuseExistingLeaf: this.settings.reusePeriodicNoteTabs,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -157,6 +157,17 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
// ═══════════════════════════════
|
// ═══════════════════════════════
|
||||||
|
|
||||||
private renderPeriodicTab(container: HTMLElement): void {
|
private renderPeriodicTab(container: HTMLElement): void {
|
||||||
|
new Setting(container)
|
||||||
|
.setName('Use existing tabs')
|
||||||
|
.setDesc('If a periodic note is already open, switch to its tab instead of opening it again.')
|
||||||
|
.addToggle((toggle) => {
|
||||||
|
toggle
|
||||||
|
.setValue(this.settings.reusePeriodicNoteTabs)
|
||||||
|
.onChange((value) => {
|
||||||
|
this.settings.reusePeriodicNoteTabs = value;
|
||||||
|
this.saveAndRefresh();
|
||||||
|
});
|
||||||
|
});
|
||||||
this.addPeriodNoteSettings(container, 'Daily', this.settings.daily);
|
this.addPeriodNoteSettings(container, 'Daily', this.settings.daily);
|
||||||
this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly);
|
this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly);
|
||||||
this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly);
|
this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly);
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ export interface DisplaySettings {
|
|||||||
export interface WaypointSettings {
|
export interface WaypointSettings {
|
||||||
calendar: CalendarSettings;
|
calendar: CalendarSettings;
|
||||||
daily: PeriodNoteSettings;
|
daily: PeriodNoteSettings;
|
||||||
|
/** Focus an open tab when opening a periodic note without an explicit leaf. */
|
||||||
|
reusePeriodicNoteTabs: boolean;
|
||||||
weekly: PeriodNoteSettings;
|
weekly: PeriodNoteSettings;
|
||||||
monthly: PeriodNoteSettings;
|
monthly: PeriodNoteSettings;
|
||||||
quarterly: PeriodNoteSettings;
|
quarterly: PeriodNoteSettings;
|
||||||
@@ -94,6 +96,7 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
|
|||||||
nameFormat: 'YYYY-MM-DD',
|
nameFormat: 'YYYY-MM-DD',
|
||||||
typeProperty: 'daily-note',
|
typeProperty: 'daily-note',
|
||||||
},
|
},
|
||||||
|
reusePeriodicNoteTabs: false,
|
||||||
weekly: {
|
weekly: {
|
||||||
folder: 'periodic/weekly',
|
folder: 'periodic/weekly',
|
||||||
templateFile: 'Templates/Weekly note',
|
templateFile: 'Templates/Weekly note',
|
||||||
|
|||||||
Reference in new issue
Block a user