feat: recent files type filter + calendar middle-click + calendar spacing
Recent files: - Type filter bar with pill tags above the list - Scans frontmatter 'type' property of each recent file - Click a pill to filter, click again or 'all' to clear - Active pill shows accent color Calendar: - Middle-click on day/week/quarter/month/year opens in new tab - openPeriodNoteInLeaf() method for leaf-targeted opening - More spacing: taller day cells, more padding, wider margins Bookmarks: - Right-click on recent file → 'Add to bookmarks' option
This commit is contained in:
1 parent
7bf1223673
commit
e92903a7aa
3 files changed
+86
-13
No files matched your search
@@ -2,20 +2,20 @@
|
|||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var U=(k,p)=>{for(var t in p)$(k,t,{get:p[t],enumerable:!0})},X=(k,p,t,a)=>{if(p&&typeof p=="object"||typeof p=="function")for(let n of z(p))!H.call(k,n)&&n!==t&&$(k,n,{get:()=>p[n],enumerable:!(a=j(p,n))||a.enumerable});return k};var K=k=>X($({},"__esModule",{value:!0}),k);var ee={};U(ee,{default:()=>O});module.exports=K(ee);var f=require("obsidian");var _={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:[]}};var y=require("obsidian"),R=class extends y.PluginSettingTab{constructor(p,t,a,n){super(p,t),this.plugin=t,this.settings=a,this.onSettingsChange=n}display(){let{containerEl:p}=this;p.empty(),new y.Setting(p).setHeading().setName("Calendar"),new y.Setting(p).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(o=>{this.settings.calendar.firstDayOfWeek=parseInt(o,10),this.saveAndRefresh()})}),new y.Setting(p).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(n=>{n.setValue(this.settings.calendar.showNoteIndicators).onChange(o=>{this.settings.calendar.showNoteIndicators=o,this.saveAndRefresh()})}),new y.Setting(p).setHeading().setName("Periodic Note Paths"),this.addPeriodNoteSettings("Daily",this.settings.daily),this.addPeriodNoteSettings("Weekly",this.settings.weekly),this.addPeriodNoteSettings("Monthly",this.settings.monthly),this.addPeriodNoteSettings("Quarterly",this.settings.quarterly),this.addPeriodNoteSettings("Yearly",this.settings.yearly),new y.Setting(p).setHeading().setName("Recent Files"),new y.Setting(p).setName("Max items").setDesc("Maximum number of recent files to track.").addText(n=>{n.inputEl.setAttr("type","number"),n.inputEl.setAttr("placeholder","50"),n.setValue(String(this.settings.recentFiles.maxItems)),n.inputEl.onblur=()=>{let o=parseInt(n.getValue(),10);!isNaN(o)&&o>0&&(this.settings.recentFiles.maxItems=o,this.saveAndRefresh())}}),new y.Setting(p).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(n=>{n.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(o=>{this.settings.recentFiles.updateOn=o,this.saveAndRefresh()})});let t=new DocumentFragment;t.appendText("Regex patterns for paths to exclude. One per line."),new y.Setting(p).setName("Omitted paths").setDesc(t).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`^archives/
|
var $=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var U=(b,h)=>{for(var t in h)$(b,t,{get:h[t],enumerable:!0})},X=(b,h,t,a)=>{if(h&&typeof h=="object"||typeof h=="function")for(let n of z(h))!H.call(b,n)&&n!==t&&$(b,n,{get:()=>h[n],enumerable:!(a=Q(h,n))||a.enumerable});return b};var K=b=>X($({},"__esModule",{value:!0}),b);var ee={};U(ee,{default:()=>O});module.exports=K(ee);var y=require("obsidian");var _={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:[]}};var w=require("obsidian"),R=class extends w.PluginSettingTab{constructor(h,t,a,n){super(h,t),this.plugin=t,this.settings=a,this.onSettingsChange=n}display(){let{containerEl:h}=this;h.empty(),new w.Setting(h).setHeading().setName("Calendar"),new w.Setting(h).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 w.Setting(h).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 w.Setting(h).setHeading().setName("Periodic Note Paths"),this.addPeriodNoteSettings("Daily",this.settings.daily),this.addPeriodNoteSettings("Weekly",this.settings.weekly),this.addPeriodNoteSettings("Monthly",this.settings.monthly),this.addPeriodNoteSettings("Quarterly",this.settings.quarterly),this.addPeriodNoteSettings("Yearly",this.settings.yearly),new w.Setting(h).setHeading().setName("Recent Files"),new w.Setting(h).setName("Max items").setDesc("Maximum number of recent files to track.").addText(n=>{n.inputEl.setAttr("type","number"),n.inputEl.setAttr("placeholder","50"),n.setValue(String(this.settings.recentFiles.maxItems)),n.inputEl.onblur=()=>{let i=parseInt(n.getValue(),10);!isNaN(i)&&i>0&&(this.settings.recentFiles.maxItems=i,this.saveAndRefresh())}}),new w.Setting(h).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(n=>{n.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(i=>{this.settings.recentFiles.updateOn=i,this.saveAndRefresh()})});let t=new DocumentFragment;t.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(h).setName("Omitted paths").setDesc(t).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`^archives/
|
||||||
\\.png$`),n.setValue(this.settings.recentFiles.omittedPaths.join(`
|
\\.png$`),n.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||||
`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=n.getValue().split(`
|
`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=n.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 y.Setting(p).setName("Omitted tags").setDesc(a).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`ignore
|
`).filter(i=>i.trim()),this.saveAndRefresh()}});let a=new DocumentFragment;a.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(h).setName("Omitted tags").setDesc(a).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`ignore
|
||||||
archive`),n.setValue(this.settings.recentFiles.omittedTags.join(`
|
archive`),n.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||||
`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=n.getValue().split(`
|
`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=n.getValue().split(`
|
||||||
`).filter(o=>o.trim()),this.saveAndRefresh()}})}addPeriodNoteSettings(p,t){new y.Setting(this.containerEl).setHeading().setName(p),new y.Setting(this.containerEl).setName("Folder").setDesc(`Folder path for ${p.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(t.folder),a.onChange(n=>{t.folder=n,this.saveAndRefresh()})}),new y.Setting(this.containerEl).setName("Name format").setDesc(`Date format for ${p.toLowerCase()} note filenames (moment.js format).`).addText(a=>{a.setPlaceholder("yyyy-MM-dd"),a.setValue(t.nameFormat),a.onChange(n=>{t.nameFormat=n,this.saveAndRefresh()})}),new y.Setting(this.containerEl).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(a=>{a.setPlaceholder("Templates/Daily note"),a.setValue(t.templateFile),a.onChange(n=>{t.templateFile=n,this.saveAndRefresh()})}),new y.Setting(this.containerEl).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(t.typeProperty),a.onChange(n=>{t.typeProperty=n,this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveData(this.settings),this.onSettingsChange()}};var h=require("obsidian");var T=require("obsidian");function Q(k,p,t){let a=(0,T.moment)({year:k,month:p,day:1}),n=(0,T.moment)(a).endOf("month"),o=(0,T.moment)(a).subtract((a.day()-t+7)%7,"days"),e=(0,T.moment)().startOf("day"),r=[],i=(0,T.moment)(o);for(;i.isBefore(n)||i.month()===p;){let c=[];for(let s=0;s<7;s++)c.push({date:(0,T.moment)(i),dayOfMonth:i.date(),isToday:i.isSame(e,"day"),isCurrentMonth:i.month()===p,isoWeekNumber:i.isoWeek()}),i.add(1,"day");if(r.push({weekNumber:c[0].isoWeekNumber,days:c}),r.length>=6)break}return r}var I="waypoint-view",N=class extends h.ItemView{constructor(t,a){super(t);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.plugin=a}getViewType(){return I}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)(),o=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=a.createDiv({cls:"waypoint-calendar-top"}),r=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),i=o.format("[Q]Q"),c=r.createSpan({cls:"waypoint-clickable",text:i});c.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",o)}),c.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",o,this.app.workspace.getLeaf("tab")))});let s=o.format("MMMM"),l=r.createSpan({cls:"waypoint-clickable",text:s});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",o)}),l.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",o,this.app.workspace.getLeaf("tab")))});let d=o.format("YYYY"),m=r.createSpan({cls:"waypoint-clickable",text:d});m.addEventListener("click",()=>{this.plugin.openPeriodNote("year",o)}),m.addEventListener("mousedown",g=>{g.button===1&&(g.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",o,this.app.workspace.getLeaf("tab")))});let u=e.createDiv({cls:"waypoint-calendar-today-group"}),w=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(w,"chevron-left"),w.addEventListener("click",()=>this.navigateMonth(-1)),u.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 M=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(M,"chevron-right"),M.addEventListener("click",()=>this.navigateMonth(1));let L=a.createEl("table"),C=L.createEl("thead").createEl("tr");C.createEl("th",{text:""});let v=["sun","mon","tue","wed","thu","fri","sat"],W=this.plugin.settings.calendar.firstDayOfWeek;for(let g=0;g<7;g++){let S=(W+g)%7;C.createEl("th",{text:v[S]})}let b=L.createEl("tbody"),E=Q(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let g of E){let S=b.createEl("tr"),A=S.createEl("td",{cls:"waypoint-weeknum"});A.setText(String(g.weekNumber)),A.addEventListener("click",()=>{let D=g.days[0].date;this.plugin.openPeriodNote("week",D)}),A.addEventListener("mousedown",D=>{if(D.button===1){D.preventDefault();let x=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("week",monday,x)}});for(let D of g.days){let x=S.createEl("td",{cls:"waypoint-day"});if(x.setText(String(D.dayOfMonth)),D.isCurrentMonth||x.addClass("other-month"),D.isToday&&x.addClass("today"),this.plugin.settings.calendar.show
Line truncated
|
`).filter(i=>i.trim()),this.saveAndRefresh()}})}addPeriodNoteSettings(h,t){new w.Setting(this.containerEl).setHeading().setName(h),new w.Setting(this.containerEl).setName("Folder").setDesc(`Folder path for ${h.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(t.folder),a.onChange(n=>{t.folder=n,this.saveAndRefresh()})}),new w.Setting(this.containerEl).setName("Name format").setDesc(`Date format for ${h.toLowerCase()} note filenames (moment.js format).`).addText(a=>{a.setPlaceholder("yyyy-MM-dd"),a.setValue(t.nameFormat),a.onChange(n=>{t.nameFormat=n,this.saveAndRefresh()})}),new w.Setting(this.containerEl).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(a=>{a.setPlaceholder("Templates/Daily note"),a.setValue(t.templateFile),a.onChange(n=>{t.templateFile=n,this.saveAndRefresh()})}),new w.Setting(this.containerEl).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(t.typeProperty),a.onChange(n=>{t.typeProperty=n,this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveData(this.settings),this.onSettingsChange()}};var p=require("obsidian");var M=require("obsidian");function j(b,h,t){let a=(0,M.moment)({year:b,month:h,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"),l=[],s=(0,M.moment)(i);for(;s.isBefore(n)||s.month()===h;){let d=[];for(let o=0;o<7;o++)d.push({date:(0,M.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(e,"day"),isCurrentMonth:s.month()===h,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(l.push({weekNumber:d[0].isoWeekNumber,days:d}),l.length>=6)break}return l}var F="waypoint-view",B=class extends p.ItemView{constructor(t,a){super(t);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view"),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=a}getViewType(){return F}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,p.moment)(),i=(0,p.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=a.createDiv({cls:"waypoint-calendar-top"}),l=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=i.format("[Q]Q"),d=l.createSpan({cls:"waypoint-clickable",text:s});d.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",i)}),d.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",i,this.app.workspace.getLeaf("tab")))});let o=i.format("MMMM"),r=l.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("month",i)}),r.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",i,this.app.workspace.getLeaf("tab")))});let c=i.format("YYYY"),m=l.createSpan({cls:"waypoint-clickable",text:c});m.addEventListener("click",()=>{this.plugin.openPeriodNote("year",i)}),m.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",i,this.app.workspace.getLeaf("tab")))});let u=e.createDiv({cls:"waypoint-calendar-today-group"}),g=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(g,"chevron-left"),g.addEventListener("click",()=>this.navigateMonth(-1)),u.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=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(C,"chevron-right"),C.addEventListener("click",()=>this.navigateMonth(1));let x=a.createEl("table"),L=x.createEl("thead").createEl("tr");L.createEl("th",{text:""});let k=["sun","mon","tue","wed","thu","fri","sat"],W=this.plugin.settings.calendar.firstDayOfWeek;for(let f=0;f<7;f++){let S=(W+f)%7;L.createEl("th",{text:k[S]})}let D=x.createEl("tbody"),I=j(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let f of I){let S=D.createEl("tr"),A=S.createEl("td",{cls:"waypoint-weeknum"});A.setText(String(f.weekNumber)),A.addEventListener("click",()=>{let E=f.days[0].date;this.plugin.openPeriodNote("week",E)}),A.addEventListener("mousedown",E=>{if(E.button===1){E.preventDefault();let P=this.app.workspace.getLeaf("tab");this.plugin.openPeriodNoteInLeaf("week",monday,P)}});for(let E of f.days){let P=S.createEl("td",{cls:"waypoint-day"});if(P.setText(String(E.dayOfMonth)),E.isCurrentMonth||P.addClass("other-month"),E.isToday&&P.addClass("today"),this.p
Line truncated
|
||||||
type: ${e.typeProperty}
|
type: ${e.typeProperty}
|
||||||
date: ${a.format("YYYY-MM-DD")}
|
date: ${a.format("YYYY-MM-DD")}
|
||||||
---
|
---
|
||||||
|
|
||||||
`;c=await this.app.vault.create(i,d)}}catch(s){new f.Notice(`Failed to create ${o.label.toLowerCase()} note: ${s.message}`);return}new f.Notice(`Created ${o.label.toLowerCase()} note: ${r}`)}c&&await this.app.workspace.getLeaf(!1).openFile(c)}async openPeriodNoteInLeaf(t,a,n){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,i=a.format(r.nameFormat)+".md",c=r.folder?`${r.folder}/${i}`:i,s=this.app.vault.getFileByPath(c);if(!s)try{let l=r.templateFile+".md",d=this.app.vault.getFileByPath(l);if(d){let m=await this.app.vault.read(d);s=await this.app.vault.create(c,m)}else{let m=`---
|
`;d=await this.app.vault.create(s,c)}}catch(o){new y.Notice(`Failed to create ${i.label.toLowerCase()} note: ${o.message}`);return}new y.Notice(`Created ${i.label.toLowerCase()} note: ${l}`)}d&&await this.app.workspace.getLeaf(!1).openFile(d)}async openPeriodNoteInLeaf(t,a,n){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:l}=e,s=a.format(l.nameFormat)+".md",d=l.folder?`${l.folder}/${s}`:s,o=this.app.vault.getFileByPath(d);if(!o)try{let r=l.templateFile+".md",c=this.app.vault.getFileByPath(r);if(c){let m=await this.app.vault.read(c);o=await this.app.vault.create(d,m)}else{let m=`---
|
||||||
type: ${r.typeProperty}
|
type: ${l.typeProperty}
|
||||||
date: ${a.format("YYYY-MM-DD")}
|
date: ${a.format("YYYY-MM-DD")}
|
||||||
---
|
---
|
||||||
|
|
||||||
`;s=await this.app.vault.create(c,m)}}catch(l){new f.Notice(`Failed to create ${e.label.toLowerCase()} note: ${l.message}`);return}s&&await n.openFile(s)}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:o,date:e}=n;if(!e.isValid()){new f.Notice(`Could not parse date from filename: ${a.basename}`);return}let r=t==="next"?1:-1,i=o==="quarter"?e.clone().add(r*3,"months"):e.clone().add(r,`${o}s`);await this.openPeriodNote(o,i)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(I);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)}};
|
`;o=await this.app.vault.create(d,m)}}catch(r){new y.Notice(`Failed to create ${e.label.toLowerCase()} note: ${r.message}`);return}o&&await n.openFile(o)}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 a=this.app.workspace.getActiveFile();if(!a){new y.Notice("No active file");return}let n=this.detectPeriodType(a.basename);if(!n){new y.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:i,date:e}=n;if(!e.isValid()){new y.Notice(`Could not parse date from filename: ${a.basename}`);return}let l=t==="next"?1:-1,s=i==="quarter"?e.clone().add(l*3,"months"):e.clone().add(l,`${i}s`);await this.openPeriodNote(i,s)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(F);for(let a of t)a.view instanceof B&&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)}};
|
||||||
@@ -63,6 +63,7 @@ export class WaypointView extends ItemView {
|
|||||||
private currentDisplayMonth: number = moment().month(); // 0-indexed
|
private currentDisplayMonth: number = moment().month(); // 0-indexed
|
||||||
private currentDisplayYear: number = moment().year();
|
private currentDisplayYear: number = moment().year();
|
||||||
private dragId: string | null = null;
|
private dragId: string | null = null;
|
||||||
|
private recentFilesFilter: string | null = null; // null = show all, else filter by type
|
||||||
|
|
||||||
private renderCalendar(): void {
|
private renderCalendar(): void {
|
||||||
const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
|
const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
|
||||||
@@ -230,17 +231,62 @@ export class WaypointView extends ItemView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const openFile = this.app.workspace.getActiveFile();
|
// ── Type filter bar ──
|
||||||
|
const typeCounts: Record<string, number> = {};
|
||||||
|
for (const file of this.plugin.recentFiles) {
|
||||||
|
const tfile = this.app.vault.getAbstractFileByPath(file.path);
|
||||||
|
if (tfile instanceof TFile) {
|
||||||
|
const cache = this.app.metadataCache.getFileCache(tfile);
|
||||||
|
const type = cache?.frontmatter?.type;
|
||||||
|
if (type && typeof type === 'string') {
|
||||||
|
typeCounts[type] = (typeCounts[type] || 0) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(typeCounts).length > 0) {
|
||||||
|
const filterBar = section.createDiv({ cls: 'waypoint-recent-filter' });
|
||||||
|
// "All" pill
|
||||||
|
const allPill = filterBar.createSpan({ cls: `waypoint-recent-pill${!this.recentFilesFilter ? ' is-active' : ''}`, text: 'all' });
|
||||||
|
allPill.addEventListener('click', () => {
|
||||||
|
this.recentFilesFilter = null;
|
||||||
|
this.redraw();
|
||||||
|
});
|
||||||
|
// Type pills
|
||||||
|
const sortedTypes = Object.entries(typeCounts).sort(([,a], [,b]) => b - a);
|
||||||
|
for (const [type, count] of sortedTypes) {
|
||||||
|
const pill = filterBar.createSpan({ cls: `waypoint-recent-pill${this.recentFilesFilter === type ? ' is-active' : ''}` });
|
||||||
|
pill.setText(`${type} ${count}`);
|
||||||
|
pill.addEventListener('click', () => {
|
||||||
|
this.recentFilesFilter = this.recentFilesFilter === type ? null : type;
|
||||||
|
this.redraw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Filter the file list ──
|
||||||
|
let filteredFiles = this.plugin.recentFiles;
|
||||||
|
if (this.recentFilesFilter) {
|
||||||
|
filteredFiles = this.plugin.recentFiles.filter(file => {
|
||||||
|
const tfile = this.app.vault.getAbstractFileByPath(file.path);
|
||||||
|
if (tfile instanceof TFile) {
|
||||||
|
const cache = this.app.metadataCache.getFileCache(tfile);
|
||||||
|
const type = cache?.frontmatter?.type;
|
||||||
|
return type === this.recentFilesFilter;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const openFile = this.app.workspace.getActiveFile();
|
||||||
const rootEl = section.createDiv({ cls: 'nav-folder mod-root' });
|
const rootEl = section.createDiv({ cls: 'nav-folder mod-root' });
|
||||||
const childrenEl = rootEl.createDiv({ cls: 'nav-folder-children' });
|
const childrenEl = rootEl.createDiv({ cls: 'nav-folder-children' });
|
||||||
|
|
||||||
for (const file of this.plugin.recentFiles) {
|
for (const file of filteredFiles) {
|
||||||
const navFile = childrenEl.createDiv({ cls: 'tree-item nav-file' });
|
const navFile = childrenEl.createDiv({ cls: 'tree-item nav-file' });
|
||||||
const navFileTitle = navFile.createDiv({ cls: 'tree-item-self is-clickable nav-file-title' });
|
const navFileTitle = navFile.createDiv({ cls: 'tree-item-self is-clickable nav-file-title' });
|
||||||
const navFileTitleContent = navFileTitle.createDiv({ cls: 'tree-item-inner nav-file-title-content' });
|
const navFileTitleContent = navFileTitle.createDiv({ cls: 'tree-item-inner nav-file-title-content' });
|
||||||
navFileTitleContent.setText(file.basename);
|
navFileTitleContent.setText(file.basename);
|
||||||
|
|
||||||
const spacer = navFileTitle.createDiv({ cls: 'tree-item-spacer' });
|
const spacer = navFileTitle.createDiv({ cls: 'tree-item-spacer' });
|
||||||
|
|
||||||
// Remove button
|
// Remove button
|
||||||
@@ -252,9 +298,7 @@ export class WaypointView extends ItemView {
|
|||||||
this.plugin.saveSettings();
|
this.plugin.saveSettings();
|
||||||
this.redraw();
|
this.redraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
setTooltip(navFile, file.path);
|
setTooltip(navFile, file.path);
|
||||||
|
|
||||||
if (openFile && file.path === openFile.path) {
|
if (openFile && file.path === openFile.path) {
|
||||||
navFileTitle.addClass('is-active');
|
navFileTitle.addClass('is-active');
|
||||||
}
|
}
|
||||||
@@ -306,7 +350,8 @@ export class WaypointView extends ItemView {
|
|||||||
}
|
}
|
||||||
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
||||||
});
|
});
|
||||||
// Left click
|
|
||||||
|
// Left click
|
||||||
navFileTitle.addEventListener('click', (event: MouseEvent) => {
|
navFileTitle.addEventListener('click', (event: MouseEvent) => {
|
||||||
const newLeaf = Keymap.isModEvent(event);
|
const newLeaf = Keymap.isModEvent(event);
|
||||||
this.focusFile(file, newLeaf);
|
this.focusFile(file, newLeaf);
|
||||||
@@ -322,7 +367,7 @@ export class WaypointView extends ItemView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private focusFile(file: { path: string; basename: string }, newLeaf: boolean | string | 'split'): void {
|
private focusFile(file: { path: string; basename: string }, newLeaf: boolean | string | 'split'): void {
|
||||||
const targetFile = this.app.vault.getFiles().find(f => f.path === file.path);
|
const targetFile = this.app.vault.getFiles().find(f => f.path === file.path);
|
||||||
if (targetFile) {
|
if (targetFile) {
|
||||||
const leaf = this.app.workspace.getLeaf(newLeaf as any);
|
const leaf = this.app.workspace.getLeaf(newLeaf as any);
|
||||||
|
|||||||
+28
@@ -189,6 +189,34 @@
|
|||||||
}
|
}
|
||||||
/* ── Recent Files ── */
|
/* ── Recent Files ── */
|
||||||
|
|
||||||
|
.waypoint-recent-filter {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypoint-recent-pill {
|
||||||
|
font-size: var(--font-ui-smaller);
|
||||||
|
color: var(--text-muted);
|
||||||
|
background: var(--background-modifier-hover);
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: var(--cursor);
|
||||||
|
transition: color 80ms, background 80ms;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypoint-recent-pill:hover {
|
||||||
|
color: var(--text-normal);
|
||||||
|
background: var(--background-modifier-active-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypoint-recent-pill.is-active {
|
||||||
|
color: var(--text-on-accent);
|
||||||
|
background: var(--interactive-accent);
|
||||||
|
}
|
||||||
|
|
||||||
.waypoint-recent-files .nav-file {
|
.waypoint-recent-files .nav-file {
|
||||||
padding: 2px 0;
|
padding: 2px 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user