feat: add About tab to settings with version and plugin description

This commit is contained in:
olivier committed 2026-06-22 10:07:22 -04:00
1 parent 6a89660cf4
commit 141121878f
2 files changed
+60 -7

No files matched your search

+6 -5
View File
@@ -2,20 +2,21 @@
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
*/
var z=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var U=(b,u)=>{for(var t in u)z(b,t,{get:u[t],enumerable:!0})},X=(b,u,t,i)=>{if(u&&typeof u=="object"||typeof u=="function")for(let s of j(u))!H.call(b,s)&&s!==t&&z(b,s,{get:()=>u[s],enumerable:!(i=Q(u,s))||i.enumerable});return b};var K=b=>X(z({},"__esModule",{value:!0}),b);var ee={};U(ee,{default:()=>O});module.exports=K(ee);var y=require("obsidian");var W={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var w=require("obsidian");var $=class extends w.PluginSettingTab{constructor(t,i,s,a){super(t,i);this.activeTab="calendar";this.plugin=i,this.settings=s,this.onSettingsChange=a}display(){let{containerEl:t}=this;t.empty();let i=t.createDiv({cls:"waypoint-settings-tabs"}),s=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"}];for(let e of s)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===e.key?" is-active":""}`,text:e.label}).addEventListener("click",()=>{this.activeTab=e.key,this.display()});let a=t.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(a);break;case"periodic":this.renderPeriodicTab(a);break;case"recent":this.renderRecentTab(a);break;case"display":this.renderDisplayTab(a);break}}renderCalendarTab(t){new w.Setting(t).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(i=>{i.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(s=>{this.settings.calendar.firstDayOfWeek=parseInt(s,10),this.saveAndRefresh()})}),new w.Setting(t).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(i=>{i.setValue(this.settings.calendar.showNoteIndicators).onChange(s=>{this.settings.calendar.showNoteIndicators=s,this.saveAndRefresh()})})}renderPeriodicTab(t){this.addPeriodNoteSettings(t,"Daily",this.settings.daily),this.addPeriodNoteSettings(t,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(t,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(t,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(t,"Yearly",this.settings.yearly)}addPeriodNoteSettings(t,i,s){new w.Setting(t).setHeading().setName(i),new w.Setting(t).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(s.folder),a.onChange(e=>{s.folder=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Name format").setDesc(`Date format for ${i.toLowerCase()} note filenames (moment.js format).`).addText(a=>{a.setPlaceholder("yyyy-MM-dd"),a.setValue(s.nameFormat),a.onChange(e=>{s.nameFormat=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(a=>{a.setPlaceholder("Templates/Daily note"),a.setValue(s.templateFile),a.onChange(e=>{s.templateFile=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(s.typeProperty),a.onChange(e=>{s.typeProperty=e,this.saveAndRefresh()})})}renderRecentTab(t){new w.Setting(t).setName("Max items").setDesc("Maximum number of recent files to track.").addText(a=>{a.inputEl.setAttr("type","number"),a.inputEl.setAttr("placeholder","50"),a.setValue(String(this.settings.recentFiles.maxItems)),a.inputEl.onblur=()=>{let e=parseInt(a.getValue(),10);!isNaN(e)&&e>0&&(this.settings.recentFiles.maxItems=e,this.saveAndRefresh())}}),new w.Setting(t).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(a=>{a.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(e=>{this.settings.recentFiles.updateOn=e,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(t).setName("Omitted paths").setDesc(i).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`^archiv Line truncated
var z=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var U=(b,u)=>{for(var t in u)z(b,t,{get:u[t],enumerable:!0})},X=(b,u,t,i)=>{if(u&&typeof u=="object"||typeof u=="function")for(let o of j(u))!Q.call(b,o)&&o!==t&&z(b,o,{get:()=>u[o],enumerable:!(i=H(u,o))||i.enumerable});return b};var K=b=>X(z({},"__esModule",{value:!0}),b);var ee={};U(ee,{default:()=>O});module.exports=K(ee);var f=require("obsidian");var W={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var w=require("obsidian");var $=class extends w.PluginSettingTab{constructor(t,i,o,a){super(t,i);this.activeTab="calendar";this.plugin=i,this.settings=o,this.onSettingsChange=a}display(){let{containerEl:t}=this;t.empty();let i=t.createDiv({cls:"waypoint-settings-tabs"}),o=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let e of o)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===e.key?" is-active":""}`,text:e.label}).addEventListener("click",()=>{this.activeTab=e.key,this.display()});let a=t.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(a);break;case"periodic":this.renderPeriodicTab(a);break;case"recent":this.renderRecentTab(a);break;case"display":this.renderDisplayTab(a);break;case"about":this.renderAboutTab(a);break}}renderCalendarTab(t){new w.Setting(t).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(i=>{i.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(o=>{this.settings.calendar.firstDayOfWeek=parseInt(o,10),this.saveAndRefresh()})}),new w.Setting(t).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(i=>{i.setValue(this.settings.calendar.showNoteIndicators).onChange(o=>{this.settings.calendar.showNoteIndicators=o,this.saveAndRefresh()})})}renderPeriodicTab(t){this.addPeriodNoteSettings(t,"Daily",this.settings.daily),this.addPeriodNoteSettings(t,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(t,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(t,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(t,"Yearly",this.settings.yearly)}addPeriodNoteSettings(t,i,o){new w.Setting(t).setHeading().setName(i),new w.Setting(t).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(o.folder),a.onChange(e=>{o.folder=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Name format").setDesc(`Date format for ${i.toLowerCase()} note filenames (moment.js format).`).addText(a=>{a.setPlaceholder("yyyy-MM-dd"),a.setValue(o.nameFormat),a.onChange(e=>{o.nameFormat=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(a=>{a.setPlaceholder("Templates/Daily note"),a.setValue(o.templateFile),a.onChange(e=>{o.templateFile=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(o.typeProperty),a.onChange(e=>{o.typeProperty=e,this.saveAndRefresh()})})}renderRecentTab(t){new w.Setting(t).setName("Max items").setDesc("Maximum number of recent files to track.").addText(a=>{a.inputEl.setAttr("type","number"),a.inputEl.setAttr("placeholder","50"),a.setValue(String(this.settings.recentFiles.maxItems)),a.inputEl.onblur=()=>{let e=parseInt(a.getValue(),10);!isNaN(e)&&e>0&&(this.settings.recentFiles.maxItems=e,this.saveAndRefresh())}}),new w.Setting(t).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(a=>{a.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(e=>{this.settings.recentFiles.updateOn=e,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(t).setName("Omitted paths").setDesc(i).Line truncated
\\.png$`),a.setValue(this.settings.recentFiles.omittedPaths.join(`
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=a.getValue().split(`
`).filter(e=>e.trim()),this.saveAndRefresh()}});let s=new DocumentFragment;s.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(t).setName("Omitted tags").setDesc(s).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`ignore
`).filter(e=>e.trim()),this.saveAndRefresh()}});let o=new DocumentFragment;o.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(t).setName("Omitted tags").setDesc(o).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(e=>e.trim()),this.saveAndRefresh()}})}renderDisplayTab(t){new w.Setting(t).setHeading().setName("Bookmarks"),this.addSliderSetting(t,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(t,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(t,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(t,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(t,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new w.Setting(t).setHeading().setName("Calendar"),this.addSliderSetting(t,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(t).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...W.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(t,i,s,a,e,r,o,d,n){let l=new w.Setting(t).setName(i).setDesc(`${s} (${a[e]}${n})`);l.addSlider(c=>{c.setLimits(r,o,d).setValue(a[e]).setDynamicTooltip().onChange(h=>{a[e]=h,l.setDesc(`${s} (${h}${n})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}};var p=require("obsidian");var L=require("obsidian");function _(b,u,t){let i=(0,L.moment)({year:b,month:u,day:1}),s=(0,L.moment)(i).endOf("month"),a=(0,L.moment)(i).subtract((i.day()-t+7)%7,"days"),e=(0,L.moment)().startOf("day"),r=[],o=(0,L.moment)(a);for(;o.isBefore(s)||o.month()===u;){let d=[];for(let n=0;n<7;n++)d.push({date:(0,L.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(e,"day"),isCurrentMonth:o.month()===u,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(r.push({weekNumber:d[0].isoWeekNumber,days:d}),r.length>=6)break}return r}var P="waypoint-view",A=class extends p.ItemView{constructor(t,i){super(t);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let t=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",t.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",t.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",t.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",t.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",t.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",t.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,p.moment)().month();this.currentDisplayYear=(0,p.moment)().year();this.dragId=null;this.recentFilesFilter=null;this.plugin=i}getViewType(){return P}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let t=this.contentEl.createDiv({cls:"waypoint-section"});t.createDiv({cls:"waypoint-section-header",text:"Calendar"});let i=t.createDiv({cls:"waypoint-calendar"}),s=(0,p.moment)(),a=(0,p.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=i.createDiv({cls:"waypoint-calendar-top"}),r=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=a.format("[Q]Q"),d=r.createSpan({cls:"waypoint-clickable",text:o});d.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",a)}),d.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",a,this.app.workspace.getLeaf("tab")))});let n=a.format("MMMM"),l=r.createSpan({cls:"waypoint-clickable",text:n});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",a)}),l.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",a,this.app.workspace.getLeaf("tab")))});let c=a.format("YYYY"),h=r.createSpan({cls:"waypoint-clickable",text:c});h.addEventListener("click",()=>{this.plugin.openPeriodNote("year",a)}),h.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",a,this.app.workspace.getLeaf("tab")))});let m=e.createDiv({cls:"waypoint-calendar-today-group"}),g=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(g,"chevron-left"),g.addEventListener("click",()=>this.navigateMonth(-1)),m.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,p.moment)().month(),this.currentDisplayYear=(0,p.moment)().year(),this.redraw()});let C=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(C,"chevron-right"),C.addEventListener("click",()=>this.navigateMonth(1));let x=i.createEl("table"),T=x.createEl("thead").createEl("tr");T.createEl("th",{text:""});let k=["sun","mon","tue","wed","thu","fri","sat"],R=this.plugin.settings.calendar.firstDayOfWeek;for(let f=0;f<7;f++){let M=(R+f)%7;T.createEl("th",{text:k[M]})}let D=x.createEl("tbody"),E=_(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.c Line truncated
`).filter(e=>e.trim()),this.saveAndRefresh()}})}renderDisplayTab(t){new w.Setting(t).setHeading().setName("Bookmarks"),this.addSliderSetting(t,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(t,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(t,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(t,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(t,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new w.Setting(t).setHeading().setName("Calendar"),this.addSliderSetting(t,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(t).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...W.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(t,i,o,a,e,r,s,d,n){let l=new w.Setting(t).setName(i).setDesc(`${o} (${a[e]}${n})`);l.addSlider(c=>{c.setLimits(r,s,d).setValue(a[e]).setDynamicTooltip().onChange(h=>{a[e]=h,l.setDesc(`${o} (${h}${n})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(t){let i=this.plugin.manifest.version,o=t.createDiv();o.style.display="flex",o.style.alignItems="center",o.style.gap="12px",o.style.marginBottom="16px";let a=o.createDiv();a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.width="48px",a.style.height="48px",a.style.borderRadius="12px",a.style.background="var(--interactive-accent)",a.style.color="var(--text-on-accent)",a.style.fontSize="24px",(0,w.setIcon)(a,"compass");let e=o.createDiv(),r=e.createEl("h2",{text:"Waypoint Sidebar"});r.style.margin="0",r.style.lineHeight="1.2";let s=e.createDiv({text:`v${i}`});s.style.color="var(--text-muted)",s.style.fontSize="var(--font-ui-small)";let d=t.createDiv();d.style.marginBottom="20px",d.style.lineHeight="1.6",d.style.color="var(--text-normal)",d.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 p=require("obsidian");var L=require("obsidian");function _(b,u,t){let i=(0,L.moment)({year:b,month:u,day:1}),o=(0,L.moment)(i).endOf("month"),a=(0,L.moment)(i).subtract((i.day()-t+7)%7,"days"),e=(0,L.moment)().startOf("day"),r=[],s=(0,L.moment)(a);for(;s.isBefore(o)||s.month()===u;){let d=[];for(let n=0;n<7;n++)d.push({date:(0,L.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(e,"day"),isCurrentMonth:s.month()===u,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(r.push({weekNumber:d[0].isoWeekNumber,days:d}),r.length>=6)break}return r}var P="waypoint-view",Y=class extends p.ItemView{constructor(t,i){super(t);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let t=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",t.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",t.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",t.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",t.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",t.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",t.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,p.moment)().month();this.currentDisplayYear=(0,p.moment)().year();this.dragId=null;this.recentFilesFilter=null;this.plugin=i}getViewType(){return P}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let t=this.contentEl.createDiv({cls:"waypoint-section"});t.createDiv({cls:"waypoint-section-header",text:"Calendar"});let i=t.createDiv({cls:"waypoint-calendar"}),o=(0,p.moment)(),a=(0,p.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=i.createDiv({cls:"waypoint-calendar-top"}),r=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=a.format("[Q]Q"),d=r.createSpan({cls:"waypoint-clickable",text:s});d.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",a)}),d.addEventListener("mousedown",y=>{y.button===1&&(y.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",a,this.app.workspace.getLeaf("tab")))});let n=a.format("MMMM"),l=r.createSpan({cls:"waypoint-clickable",text:n});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",a)}),l.addEventListener("mousedown",y=>{y.button===1&&(y.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",a,this.app.workspace.getLeaf("tab")))});let c=a.format("YYYY"),h=r.createSpan({cls:"waypoint-clickable",text:c});h.addEventListener("click",()=>{this.plugin.openPeriodNote("year",a)}),h.addEventListener("mousedown",y=>{y.button===1&&(y.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",a,this.app.workspace.getLeaf("tab")))});let m=e.createDiv({cls:"waypoint-calendar-today-group"}),g=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(g,"chevron-left"),g.addEventListener("click",()=>this.navigateMonth(-1)),m.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,p.moment)().month(),this.currentDisplayYear=(0,p.moment)().year(),this.redraw()});let C=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(C,"chevron-right"),C.addEventListener("click",()=>this.navigateMonth(1));let F=i.createEl("table"),T=F.createEl("thead").createEl("tr");T.createEl("th",{text:""});let k=["sun","mon","tue","wed","thu","fri","sat"],R=this.plugin.settings.calendar.firstDayOfWeek;for(let y=0;y<7;y++){let M=(R+y)%7;T.createEl("th",{text:k[M]})}let D=F.createEl("tbody"),E=_(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let y of E){let M=D.createEl("tr"),A=M.createEl("td",{cls:"waypoint-weeknum"});A.setText(String(y.weekNumber)),A.addEventListener("click",()=>{let x=y.days[0].date;this.plugin.openPeriodNote("week",x)}),A.addEventListener("mousedown",x=>{if(x.button===1){x.preventDefault();let I=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("week",monday,I)}});for(let x of y.days){let I=M.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 B=x.date.format("YYYY-MM-DD");this.plugin.app.vault.getFiles().some(G=>G.extension==="md"&&G.basename===B)&&I.addClass("has-note")}I.addEventListener("click",()=>{this.plugin.openPeriodNote("day",x.date)}),I.addEventListener("mousedown",B=>{if(B.button===1){B.preventDefault();let S=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("day",x.date,S)}})}}}navigateMonth(t){let i=(0,p.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(t,"month");this.currentDisplayMonth=i.month(),this.currentDisplayYear=i.year(),this.redraw()}renderRecentFiles(){var s;let t=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(t.createDiv({cls:" Line truncated
type: ${e.typeProperty}
date: ${i.format("YYYY-MM-DD")}
---
`;d=await this.app.vault.create(o,c)}}catch(n){new y.Notice(`Failed to create ${a.label.toLowerCase()} note: ${n.message}`);return}new y.Notice(`Created ${a.label.toLowerCase()} note: ${r}`)}d&&await this.app.workspace.getLeaf(!1).openFile(d)}async openPeriodNoteInLeaf(t,i,s){let e={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"}}[t];if(!e)return;let{settings:r}=e,o=i.format(r.nameFormat)+".md",d=r.folder?`${r.folder}/${o}`:o,n=this.app.vault.getFileByPath(d);if(!n)try{let l=r.templateFile+".md",c=this.app.vault.getFileByPath(l);if(c){let h=await this.app.vault.read(c);n=await this.app.vault.create(d,h)}else{let h=`---
`;d=await this.app.vault.create(s,c)}}catch(n){new f.Notice(`Failed to create ${a.label.toLowerCase()} note: ${n.message}`);return}new f.Notice(`Created ${a.label.toLowerCase()} note: ${r}`)}d&&await this.app.workspace.getLeaf(!1).openFile(d)}async openPeriodNoteInLeaf(t,i,o){let e={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"}}[t];if(!e)return;let{settings:r}=e,s=i.format(r.nameFormat)+".md",d=r.folder?`${r.folder}/${s}`:s,n=this.app.vault.getFileByPath(d);if(!n)try{let l=r.templateFile+".md",c=this.app.vault.getFileByPath(l);if(c){let h=await this.app.vault.read(c);n=await this.app.vault.create(d,h)}else{let h=`---
type: ${r.typeProperty}
date: ${i.format("YYYY-MM-DD")}
---
`;n=await this.app.vault.create(d,h)}}catch(l){new y.Notice(`Failed to create ${e.label.toLowerCase()} note: ${l.message}`);return}n&&await s.openFile(n)}detectPeriodType(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?{period:"day",date:(0,y.moment)(t,"YYYY-MM-DD")}:/^\d{4}-W\d{2}$/.test(t)?{period:"week",date:(0,y.moment)(t,"GGGG-[W]WW")}:/^\d{4}-\d{2}$/.test(t)?{period:"month",date:(0,y.moment)(t,"YYYY-MM")}:/^\d{4}-Q[1-4]$/.test(t)?{period:"quarter",date:(0,y.moment)(t,"YYYY-[Q]Q")}:/^\d{4}$/.test(t)?{period:"year",date:(0,y.moment)(t,"YYYY")}:null}async navigatePeriodNote(t){let i=this.app.workspace.getActiveFile();if(!i){new y.Notice("No active file");return}let s=this.detectPeriodType(i.basename);if(!s){new y.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:a,date:e}=s;if(!e.isValid()){new y.Notice(`Could not parse date from filename: ${i.basename}`);return}let r=t==="next"?1:-1,o=a==="quarter"?e.clone().add(r*3,"months"):e.clone().add(r,`${a}s`);await this.openPeriodNote(a,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(P);for(let i of t)i.view instanceof A&&i.view.redraw()}async getNotesForDate(t){return this.app.vault.getFiles().filter(i=>i.extension==="md"&&i.basename===t)}async hasNoteForDate(t){return this.app.vault.getFiles().some(i=>i.extension==="md"&&i.basename===t)}};
`;n=await this.app.vault.create(d,h)}}catch(l){new f.Notice(`Failed to create ${e.label.toLowerCase()} note: ${l.message}`);return}n&&await o.openFile(n)}detectPeriodType(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?{period:"day",date:(0,f.moment)(t,"YYYY-MM-DD")}:/^\d{4}-W\d{2}$/.test(t)?{period:"week",date:(0,f.moment)(t,"GGGG-[W]WW")}:/^\d{4}-\d{2}$/.test(t)?{period:"month",date:(0,f.moment)(t,"YYYY-MM")}:/^\d{4}-Q[1-4]$/.test(t)?{period:"quarter",date:(0,f.moment)(t,"YYYY-[Q]Q")}:/^\d{4}$/.test(t)?{period:"year",date:(0,f.moment)(t,"YYYY")}:null}async navigatePeriodNote(t){let i=this.app.workspace.getActiveFile();if(!i){new f.Notice("No active file");return}let o=this.detectPeriodType(i.basename);if(!o){new f.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:a,date:e}=o;if(!e.isValid()){new f.Notice(`Could not parse date from filename: ${i.basename}`);return}let r=t==="next"?1:-1,s=a==="quarter"?e.clone().add(r*3,"months"):e.clone().add(r,`${a}s`);await this.openPeriodNote(a,s)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(P);for(let i of t)i.view instanceof Y&&i.view.redraw()}async getNotesForDate(t){return this.app.vault.getFiles().filter(i=>i.extension==="md"&&i.basename===t)}async hasNoteForDate(t){return this.app.vault.getFiles().some(i=>i.extension==="md"&&i.basename===t)}};