fix: calendar disappeared for existing users
Shallow Object.assign on settings meant filterTags (new in 1.5.0) was undefined for anyone with prior saved settings. Accessing .length on undefined threw, killing the entire redraw before calendar could render. - Defensive fallback: filterTags || [] - Deep merge on loadSettings for recentFiles, calendar, display
This commit is contained in:
1 parent
abf4d6ccf7
commit
3c7b6741f5
5 files changed
+11
-7
No files matched your search
@@ -2,7 +2,7 @@
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
*/
|
||||
|
||||
var z=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var U=(D,u)=>{for(var t in u)z(D,t,{get:u[t],enumerable:!0})},X=(D,u,t,a)=>{if(u&&typeof u=="object"||typeof u=="function")for(let n of H(u))!Q.call(D,n)&&n!==t&&z(D,n,{get:()=>u[n],enumerable:!(a=j(u,n))||a.enumerable});return D};var K=D=>X(z({},"__esModule",{value:!0}),D);var ee={};U(ee,{default:()=>$});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:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var v=require("obsidian");var O=class extends v.PluginSettingTab{constructor(t,a,n,i){super(t,a);this.activeTab="calendar";this.plugin=a,this.settings=n,this.onSettingsChange=i}display(){let{containerEl:t}=this;t.empty();let a=t.createDiv({cls:"waypoint-settings-tabs"}),n=[{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 n)a.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===e.key?" is-active":""}`,text:e.label}).addEventListener("click",()=>{this.activeTab=e.key,this.display()});let i=t.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(i);break;case"periodic":this.renderPeriodicTab(i);break;case"recent":this.renderRecentTab(i);break;case"display":this.renderDisplayTab(i);break;case"about":this.renderAboutTab(i);break}}renderCalendarTab(t){new v.Setting(t).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(a=>{a.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(n=>{this.settings.calendar.firstDayOfWeek=parseInt(n,10),this.saveAndRefresh()})}),new v.Setting(t).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(a=>{a.setValue(this.settings.calendar.showNoteIndicators).onChange(n=>{this.settings.calendar.showNoteIndicators=n,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,a,n){new v.Setting(t).setHeading().setName(a),new v.Setting(t).setName("Folder").setDesc(`Folder path for ${a.toLowerCase()} notes.`).addText(i=>{i.setPlaceholder("periodic/daily"),i.setValue(n.folder),i.onChange(e=>{n.folder=e,this.saveAndRefresh()})}),new v.Setting(t).setName("Name format").setDesc(`Date format for ${a.toLowerCase()} note filenames (moment.js format).`).addText(i=>{i.setPlaceholder("yyyy-MM-dd"),i.setValue(n.nameFormat),i.onChange(e=>{n.nameFormat=e,this.saveAndRefresh()})}),new v.Setting(t).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(i=>{i.setPlaceholder("Templates/Daily note"),i.setValue(n.templateFile),i.onChange(e=>{n.templateFile=e,this.saveAndRefresh()})}),new v.Setting(t).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(i=>{i.setPlaceholder("daily-note"),i.setValue(n.typeProperty),i.onChange(e=>{n.typeProperty=e,this.saveAndRefresh()})})}renderRecentTab(t){new v.Setting(t).setName("Max items").setDesc("Maximum number of recent files to track.").addText(e=>{e.inputEl.setAttr("type","number"),e.inputEl.setAttr("placeholder","50"),e.setValue(String(this.settings.recentFiles.maxItems)),e.inputEl.onblur=()=>{let s=parseInt(e.getValue(),10);!isNaN(s)&&s>0&&(this.settings.recentFiles.maxItems=s,this.saveAndRefresh())}}),new v.Setting(t).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(e=>{e.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(s=>{this.settings.recentFiles.updateOn=s,this.saveAndRefresh()})});let a=new DocumentFragment;a.appendText("Regex patterns for paths to exclude. One per line."),new v.Setting(t).setName("Omitted pathsLine truncated
|
||||
var z=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var U=(D,u)=>{for(var t in u)z(D,t,{get:u[t],enumerable:!0})},X=(D,u,t,a)=>{if(u&&typeof u=="object"||typeof u=="function")for(let n of H(u))!Q.call(D,n)&&n!==t&&z(D,n,{get:()=>u[n],enumerable:!(a=_(u,n))||a.enumerable});return D};var K=D=>X(z({},"__esModule",{value:!0}),D);var ee={};U(ee,{default:()=>$});module.exports=K(ee);var f=require("obsidian");var M={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var v=require("obsidian");var O=class extends v.PluginSettingTab{constructor(t,a,n,i){super(t,a);this.activeTab="calendar";this.plugin=a,this.settings=n,this.onSettingsChange=i}display(){let{containerEl:t}=this;t.empty();let a=t.createDiv({cls:"waypoint-settings-tabs"}),n=[{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 n)a.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===e.key?" is-active":""}`,text:e.label}).addEventListener("click",()=>{this.activeTab=e.key,this.display()});let i=t.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(i);break;case"periodic":this.renderPeriodicTab(i);break;case"recent":this.renderRecentTab(i);break;case"display":this.renderDisplayTab(i);break;case"about":this.renderAboutTab(i);break}}renderCalendarTab(t){new v.Setting(t).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(a=>{a.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(n=>{this.settings.calendar.firstDayOfWeek=parseInt(n,10),this.saveAndRefresh()})}),new v.Setting(t).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(a=>{a.setValue(this.settings.calendar.showNoteIndicators).onChange(n=>{this.settings.calendar.showNoteIndicators=n,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,a,n){new v.Setting(t).setHeading().setName(a),new v.Setting(t).setName("Folder").setDesc(`Folder path for ${a.toLowerCase()} notes.`).addText(i=>{i.setPlaceholder("periodic/daily"),i.setValue(n.folder),i.onChange(e=>{n.folder=e,this.saveAndRefresh()})}),new v.Setting(t).setName("Name format").setDesc(`Date format for ${a.toLowerCase()} note filenames (moment.js format).`).addText(i=>{i.setPlaceholder("yyyy-MM-dd"),i.setValue(n.nameFormat),i.onChange(e=>{n.nameFormat=e,this.saveAndRefresh()})}),new v.Setting(t).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(i=>{i.setPlaceholder("Templates/Daily note"),i.setValue(n.templateFile),i.onChange(e=>{n.templateFile=e,this.saveAndRefresh()})}),new v.Setting(t).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(i=>{i.setPlaceholder("daily-note"),i.setValue(n.typeProperty),i.onChange(e=>{n.typeProperty=e,this.saveAndRefresh()})})}renderRecentTab(t){new v.Setting(t).setName("Max items").setDesc("Maximum number of recent files to track.").addText(e=>{e.inputEl.setAttr("type","number"),e.inputEl.setAttr("placeholder","50"),e.setValue(String(this.settings.recentFiles.maxItems)),e.inputEl.onblur=()=>{let s=parseInt(e.getValue(),10);!isNaN(s)&&s>0&&(this.settings.recentFiles.maxItems=s,this.saveAndRefresh())}}),new v.Setting(t).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(e=>{e.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(s=>{this.settings.recentFiles.updateOn=s,this.saveAndRefresh()})});let a=new DocumentFragment;a.appendText("Regex patterns for paths to exclude. One per line."),new v.Setting(t).setName("Omitted pathsLine truncated
|
||||
\\.png$`),e.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||
`)),e.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=e.getValue().split(`
|
||||
`).filter(s=>s.trim()),this.saveAndRefresh()}});let n=new DocumentFragment;n.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new v.Setting(t).setName("Omitted tags").setDesc(n).addTextArea(e=>{e.inputEl.setAttr("rows",4),e.setPlaceholder(`ignore
|
||||
@@ -12,8 +12,8 @@ archive`),e.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||
person
|
||||
project`),e.setValue(this.settings.recentFiles.filterTags.join(`
|
||||
`)),e.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=e.getValue().split(`
|
||||
`).filter(s=>s.trim()),this.saveAndRefresh()}})}renderDisplayTab(t){new v.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 v.Setting(t).setHeading().setName("Calendar"),this.addSliderSetting(t,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new v.Setting(t).addButton(a=>a.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...W.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(t,a,n,i,e,s,o,d,r){let l=new v.Setting(t).setName(a).setDesc(`${n} (${i[e]}${r})`);l.addSlider(c=>{c.setLimits(s,o,d).setValue(i[e]).setDynamicTooltip().onChange(p=>{i[e]=p,l.setDesc(`${n} (${p}${r})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(t){let a=this.plugin.manifest.version,n=t.createDiv();n.style.display="flex",n.style.alignItems="center",n.style.gap="12px",n.style.marginBottom="16px";let i=n.createDiv();i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.width="48px",i.style.height="48px",i.style.borderRadius="12px",i.style.background="var(--interactive-accent)",i.style.color="var(--text-on-accent)",i.style.fontSize="24px",(0,v.setIcon)(i,"compass");let e=n.createDiv(),s=e.createEl("h2",{text:"Waypoint Sidebar"});s.style.margin="0",s.style.lineHeight="1.2";let o=e.createDiv({text:`v${a}`});o.style.color="var(--text-muted)",o.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 h=require("obsidian");var M=require("obsidian");function _(D,u,t){let a=(0,M.moment)({year:D,month:u,day:1}),n=(0,M.moment)(a).endOf("month"),i=(0,M.moment)(a).subtract((a.day()-t+7)%7,"days"),e=(0,M.moment)().startOf("day"),s=[],o=(0,M.moment)(i);for(;o.isBefore(n)||o.month()===u;){let d=[];for(let r=0;r<7;r++)d.push({date:(0,M.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(e,"day"),isCurrentMonth:o.month()===u,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(s.push({weekNumber:d[0].isoWeekNumber,days:d}),s.length>=6)break}return s}var C="waypoint-view",N=class extends h.ItemView{constructor(t,a){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,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.recentFilesFilter=null;this.plugin=a}getViewType(){return C}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 a=t.createDiv({cls:"waypoint-calendar"}),n=(0,h.moment)(),i=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=a.createDiv({cls:"waypoint-calendar-top"}),s=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=i.format("[Q]Q"),d=s.createSpan({cls:"waypoint-clickable",text:o});d.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",i)}),d.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",i,this.app.workspace.getLeaf("tab")))});let r=i.format("MMMM"),l=s.createSpan({cls:"waypoint-clickable",text:r});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",i)}),l.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",i,this.app.workspace.getLeaf("tab")))});let c=i.format("YYYY"),p=s.createSpan({cls:"waypoint-clickable",text:c});p.addEventListener("click",()=>{this.plugin.openPeriodNote("year",i)}),p.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",i,this.app.workspace.getLeaf("tab")))});let m=e.createDiv({cls:"waypoint-calendar-today-group"}),b=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(b,"chevron-left"),b.addEventListener("click",()=>this.navigateMonth(-1)),m.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 y=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(y,"chevron-right"),y.addEventListener("click",()=>this.navigateMonth(1));let w=a.createEl("table"),I=w.createEl("thead").createEl("tr");I.createEl("th",{text:""});let k=["sun","mon","tue","wed","thu","fri","sat"],R=this.plugin.settings.calendar.firstDayOfWeek;for(let g=0;g<7;g++){let B=(R+g)%7;I.createEl("th",{text:k[B]})}let F=w.createEl("tbody"),P=_(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let g of P){let B=F.createEl("tr"),Y=B.createEl("td",{cls:"waypoint-weeknum"});Y.setText(String(g.weekNumber)),Y.addEventListener("click",()=>{let E=g.days[0].date;this.plugin.openPeriodNote("week",E)}),Y.addEventListener("mousedown",E=>{if(E.button===1){E.preventDefault();let T=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("week",monday,T)}});for(let E of g.days){let T=B.createEl("td",{cls:"waypoint-day"});if(T.setText(String(E.dayOfMonth)),E.isCurrentMonth||T.addClass("other-month"),E.isToday&&T.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let A=E.date.format("YYYY-MM-DD");this.plugin.app.vault.getFiles().some(G=>G.extension==="md"&&G.basename===A)&&T.addClass("has-note")}T.addEventListener("click",()=>{this.plugin.openPeriodNote("day",E.date)}),T.addEventListener("mousedown",A=>{if(A.button===1){A.preventDefault();let S=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("day",E.date,S)}})}}}navigateMonth(t){let a=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(t,"month");this.currentDisplayMonth=a.month(),this.currentDisplayYear=a.year(),this.redraw()}renderRecentFiles(){var d,r;let t=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(t.createDiv({cls
Line truncated
|
||||
`).filter(s=>s.trim()),this.saveAndRefresh()}})}renderDisplayTab(t){new v.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 v.Setting(t).setHeading().setName("Calendar"),this.addSliderSetting(t,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new v.Setting(t).addButton(a=>a.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...M.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(t,a,n,i,e,s,o,d,r){let l=new v.Setting(t).setName(a).setDesc(`${n} (${i[e]}${r})`);l.addSlider(c=>{c.setLimits(s,o,d).setValue(i[e]).setDynamicTooltip().onChange(p=>{i[e]=p,l.setDesc(`${n} (${p}${r})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(t){let a=this.plugin.manifest.version,n=t.createDiv();n.style.display="flex",n.style.alignItems="center",n.style.gap="12px",n.style.marginBottom="16px";let i=n.createDiv();i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.width="48px",i.style.height="48px",i.style.borderRadius="12px",i.style.background="var(--interactive-accent)",i.style.color="var(--text-on-accent)",i.style.fontSize="24px",(0,v.setIcon)(i,"compass");let e=n.createDiv(),s=e.createEl("h2",{text:"Waypoint Sidebar"});s.style.margin="0",s.style.lineHeight="1.2";let o=e.createDiv({text:`v${a}`});o.style.color="var(--text-muted)",o.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 h=require("obsidian");var B=require("obsidian");function j(D,u,t){let a=(0,B.moment)({year:D,month:u,day:1}),n=(0,B.moment)(a).endOf("month"),i=(0,B.moment)(a).subtract((a.day()-t+7)%7,"days"),e=(0,B.moment)().startOf("day"),s=[],o=(0,B.moment)(i);for(;o.isBefore(n)||o.month()===u;){let d=[];for(let r=0;r<7;r++)d.push({date:(0,B.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(e,"day"),isCurrentMonth:o.month()===u,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(s.push({weekNumber:d[0].isoWeekNumber,days:d}),s.length>=6)break}return s}var C="waypoint-view",R=class extends h.ItemView{constructor(t,a){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,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.recentFilesFilter=null;this.plugin=a}getViewType(){return C}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 a=t.createDiv({cls:"waypoint-calendar"}),n=(0,h.moment)(),i=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=a.createDiv({cls:"waypoint-calendar-top"}),s=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=i.format("[Q]Q"),d=s.createSpan({cls:"waypoint-clickable",text:o});d.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",i)}),d.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",i,this.app.workspace.getLeaf("tab")))});let r=i.format("MMMM"),l=s.createSpan({cls:"waypoint-clickable",text:r});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",i)}),l.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",i,this.app.workspace.getLeaf("tab")))});let c=i.format("YYYY"),p=s.createSpan({cls:"waypoint-clickable",text:c});p.addEventListener("click",()=>{this.plugin.openPeriodNote("year",i)}),p.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",i,this.app.workspace.getLeaf("tab")))});let m=e.createDiv({cls:"waypoint-calendar-today-group"}),b=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(b,"chevron-left"),b.addEventListener("click",()=>this.navigateMonth(-1)),m.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 y=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(y,"chevron-right"),y.addEventListener("click",()=>this.navigateMonth(1));let w=a.createEl("table"),I=w.createEl("thead").createEl("tr");I.createEl("th",{text:""});let k=["sun","mon","tue","wed","thu","fri","sat"],W=this.plugin.settings.calendar.firstDayOfWeek;for(let g=0;g<7;g++){let A=(W+g)%7;I.createEl("th",{text:k[A]})}let x=w.createEl("tbody"),P=j(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let g of P){let A=x.createEl("tr"),N=A.createEl("td",{cls:"waypoint-weeknum"});N.setText(String(g.weekNumber)),N.addEventListener("click",()=>{let E=g.days[0].date;this.plugin.openPeriodNote("week",E)}),N.addEventListener("mousedown",E=>{if(E.button===1){E.preventDefault();let T=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("week",monday,T)}});for(let E of g.days){let T=A.createEl("td",{cls:"waypoint-day"});if(T.setText(String(E.dayOfMonth)),E.isCurrentMonth||T.addClass("other-month"),E.isToday&&T.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let Y=E.date.format("YYYY-MM-DD");this.plugin.app.vault.getFiles().some(G=>G.extension==="md"&&G.basename===Y)&&T.addClass("has-note")}T.addEventListener("click",()=>{this.plugin.openPeriodNote("day",E.date)}),T.addEventListener("mousedown",Y=>{if(Y.button===1){Y.preventDefault();let S=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("day",E.date,S)}})}}}navigateMonth(t){let a=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(t,"month");this.currentDisplayMonth=a.month(),this.currentDisplayYear=a.year(),this.redraw()}renderRecentFiles(){var d,r;let t=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(t.createDiv({cls
Line truncated
|
||||
type: ${e.typeProperty}
|
||||
date: ${a.format("YYYY-MM-DD")}
|
||||
---
|
||||
@@ -23,4 +23,4 @@ type: ${s.typeProperty}
|
||||
date: ${a.format("YYYY-MM-DD")}
|
||||
---
|
||||
|
||||
`;r=await this.app.vault.create(d,p)}}catch(l){new f.Notice(`Failed to create ${e.label.toLowerCase()} note: ${l.message}`);return}r&&await n.openFile(r)}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 a=this.app.workspace.getActiveFile();if(!a){new f.Notice("No active file");return}let n=this.detectPeriodType(a.basename);if(!n){new f.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:i,date:e}=n;if(!e.isValid()){new f.Notice(`Could not parse date from filename: ${a.basename}`);return}let s=t==="next"?1:-1,o=i==="quarter"?e.clone().add(s*3,"months"):e.clone().add(s,`${i}s`);await this.openPeriodNote(i,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(C);for(let a of t)a.view instanceof N&&a.view.redraw()}async getNotesForDate(t){return this.app.vault.getFiles().filter(a=>a.extension==="md"&&a.basename===t)}async hasNoteForDate(t){return this.app.vault.getFiles().some(a=>a.extension==="md"&&a.basename===t)}};
|
||||
`;r=await this.app.vault.create(d,p)}}catch(l){new f.Notice(`Failed to create ${e.label.toLowerCase()} note: ${l.message}`);return}r&&await n.openFile(r)}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 a=this.app.workspace.getActiveFile();if(!a){new f.Notice("No active file");return}let n=this.detectPeriodType(a.basename);if(!n){new f.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:i,date:e}=n;if(!e.isValid()){new f.Notice(`Could not parse date from filename: ${a.basename}`);return}let s=t==="next"?1:-1,o=i==="quarter"?e.clone().add(s*3,"months"):e.clone().add(s,`${i}s`);await this.openPeriodNote(i,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(C);for(let a of t)a.view instanceof R&&a.view.redraw()}async getNotesForDate(t){return this.app.vault.getFiles().filter(a=>a.extension==="md"&&a.basename===t)}async hasNoteForDate(t){return this.app.vault.getFiles().some(a=>a.extension==="md"&&a.basename===t)}};
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "waypoint-sidebar",
|
||||
"name": "Waypoint Sidebar",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"minAppVersion": "0.16.3",
|
||||
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
||||
"author": "Olivier",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "waypoint",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"description": "Calendar, recent files, and custom bookmarks sidebar.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -199,6 +199,10 @@ export default class WaypointPlugin extends Plugin {
|
||||
const saved = await this.loadData() as Record<string, unknown> | null;
|
||||
const s = (saved?.settings || {}) as Partial<WaypointSettings>;
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, s);
|
||||
// Deep merge nested objects that might be missing new fields
|
||||
this.settings.recentFiles = Object.assign({}, DEFAULT_SETTINGS.recentFiles, s.recentFiles || {});
|
||||
this.settings.calendar = Object.assign({}, DEFAULT_SETTINGS.calendar, s.calendar || {});
|
||||
this.settings.display = Object.assign({}, DEFAULT_SETTINGS.display, s.display || {});
|
||||
}
|
||||
|
||||
async saveSettings(): Promise<void> {
|
||||
|
||||
@@ -241,7 +241,7 @@ export class WaypointView extends ItemView {
|
||||
}
|
||||
|
||||
// ── Type filter bar ──
|
||||
const configuredTags = this.plugin.settings.recentFiles.filterTags;
|
||||
const configuredTags = this.plugin.settings.recentFiles.filterTags || [];
|
||||
let typeCounts: Record<string, number> = {};
|
||||
|
||||
if (configuredTags.length > 0) {
|
||||
|
||||
Reference in new issue
Block a user