chore: rebuild bundle
This commit is contained in:
1 parent
ece066caf8
commit
0eb529e604
1 file changed
+12
-6
@@ -2,20 +2,26 @@
|
|||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var z=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var X=(f,m)=>{for(var e in m)z(f,e,{get:m[e],enumerable:!0})},J=(f,m,e,i)=>{if(m&&typeof m=="object"||typeof m=="function")for(let s of Z(m))!U.call(f,s)&&s!==e&&z(f,s,{get:()=>m[s],enumerable:!(i=_(m,s))||i.enumerable});return f};var ee=f=>J(z({},"__esModule",{value:!0}),f);var oe={};X(oe,{default:()=>Y});module.exports=ee(oe);var v=require("obsidian");var P={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 w=require("obsidian");var N=class extends w.PluginSettingTab{constructor(e,i,s,a){super(e,i);this.activeTab="calendar";this.plugin=i,this.settings=s,this.onSettingsChange=a}display(){let{containerEl:e}=this;e.empty();let i=e.createDiv({cls:"waypoint-settings-tabs"}),s=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let t of s)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===t.key?" is-active":""}`,text:t.label}).addEventListener("click",()=>{this.activeTab=t.key,this.display()});let a=e.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(e){new w.Setting(e).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(e).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(e){this.addPeriodNoteSettings(e,"Daily",this.settings.daily),this.addPeriodNoteSettings(e,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(e,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(e,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(e,"Yearly",this.settings.yearly)}addPeriodNoteSettings(e,i,s){new w.Setting(e).setHeading().setName(i),new w.Setting(e).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(s.folder),a.onChange(t=>{s.folder=t,this.saveAndRefresh()})}),new w.Setting(e).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(t=>{s.nameFormat=t,this.saveAndRefresh()})}),new w.Setting(e).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(t=>{s.templateFile=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(s.typeProperty),a.onChange(t=>{s.typeProperty=t,this.saveAndRefresh()})})}renderRecentTab(e){new w.Setting(e).setName("Max items").setDesc("Maximum number of recent files to track.").addText(t=>{t.inputEl.setAttr("type","number"),t.inputEl.setAttr("placeholder","50"),t.setValue(String(this.settings.recentFiles.maxItems)),t.inputEl.onblur=()=>{let n=parseInt(t.getValue(),10);!isNaN(n)&&n>0&&(this.settings.recentFiles.maxItems=n,this.saveAndRefresh())}}),new w.Setting(e).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(t=>{t.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(n=>{this.settings.recentFiles.updateOn=n,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(e).setName("Omitted patLine truncated
|
var q=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(g,m)=>{for(var e in m)q(g,e,{get:m[e],enumerable:!0})},ie=(g,m,e,i)=>{if(m&&typeof m=="object"||typeof m=="function")for(let s of J(m))!ee.call(g,s)&&s!==e&&q(g,s,{get:()=>m[s],enumerable:!(i=X(m,s))||i.enumerable});return g};var ne=g=>ie(q({},"__esModule",{value:!0}),g);var le={};te(le,{default:()=>O});module.exports=ne(le);var y=require("obsidian");var P={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 w=require("obsidian");var R=class extends w.PluginSettingTab{constructor(e,i,s,n){super(e,i);this.activeTab="calendar";this.plugin=i,this.settings=s,this.onSettingsChange=n}display(){let{containerEl:e}=this;e.empty();let i=e.createDiv({cls:"waypoint-settings-tabs"}),s=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let t of s)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===t.key?" is-active":""}`,text:t.label}).addEventListener("click",()=>{this.activeTab=t.key,this.display()});let n=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(n);break;case"periodic":this.renderPeriodicTab(n);break;case"recent":this.renderRecentTab(n);break;case"display":this.renderDisplayTab(n);break;case"about":this.renderAboutTab(n);break}}renderCalendarTab(e){new w.Setting(e).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(e).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(e){this.addPeriodNoteSettings(e,"Daily",this.settings.daily),this.addPeriodNoteSettings(e,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(e,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(e,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(e,"Yearly",this.settings.yearly)}addPeriodNoteSettings(e,i,s){new w.Setting(e).setHeading().setName(i),new w.Setting(e).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(n=>{n.setPlaceholder("periodic/daily"),n.setValue(s.folder),n.onChange(t=>{s.folder=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Name format").setDesc(`Date format for ${i.toLowerCase()} note filenames (moment.js format).`).addText(n=>{n.setPlaceholder("yyyy-MM-dd"),n.setValue(s.nameFormat),n.onChange(t=>{s.nameFormat=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(n=>{n.setPlaceholder("Templates/Daily note"),n.setValue(s.templateFile),n.onChange(t=>{s.templateFile=t,this.saveAndRefresh()})}),new w.Setting(e).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(n=>{n.setPlaceholder("daily-note"),n.setValue(s.typeProperty),n.onChange(t=>{s.typeProperty=t,this.saveAndRefresh()})})}renderRecentTab(e){new w.Setting(e).setName("Max items").setDesc("Maximum number of recent files to track.").addText(t=>{t.inputEl.setAttr("type","number"),t.inputEl.setAttr("placeholder","50"),t.setValue(String(this.settings.recentFiles.maxItems)),t.inputEl.onblur=()=>{let a=parseInt(t.getValue(),10);!isNaN(a)&&a>0&&(this.settings.recentFiles.maxItems=a,this.saveAndRefresh())}}),new w.Setting(e).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(t=>{t.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(a=>{this.settings.recentFiles.updateOn=a,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(e).setName("OmittLine truncated
|
||||||
\\.png$`),t.setValue(this.settings.recentFiles.omittedPaths.join(`
|
\\.png$`),t.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||||
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=t.getValue().split(`
|
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=t.getValue().split(`
|
||||||
`).filter(n=>n.trim()),this.saveAndRefresh()}});let s=new DocumentFragment;s.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(e).setName("Omitted tags").setDesc(s).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`ignore
|
`).filter(a=>a.trim()),this.saveAndRefresh()}});let s=new DocumentFragment;s.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(e).setName("Omitted tags").setDesc(s).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`ignore
|
||||||
archive`),t.setValue(this.settings.recentFiles.omittedTags.join(`
|
archive`),t.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||||
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=t.getValue().split(`
|
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=t.getValue().split(`
|
||||||
`).filter(n=>n.trim()),this.saveAndRefresh()}});let a=new DocumentFragment;a.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new w.Setting(e).setName("Filter tags").setDesc(a).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`meeting
|
`).filter(a=>a.trim()),this.saveAndRefresh()}});let n=new DocumentFragment;n.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new w.Setting(e).setName("Filter tags").setDesc(n).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`meeting
|
||||||
person
|
person
|
||||||
project`),t.setValue(this.settings.recentFiles.filterTags.join(`
|
project`),t.setValue(this.settings.recentFiles.filterTags.join(`
|
||||||
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=t.getValue().split(`
|
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=t.getValue().split(`
|
||||||
`).filter(n=>n.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new w.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 w.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(e).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...P.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,i,s,a,t,n,o,r,c){let l=new w.Setting(e).setName(i).setDesc(`${s} (${a[t]}${c})`);l.addSlider(h=>{h.setLimits(n,o,r).setValue(a[t]).setDynamicTooltip().onChange(p=>{a[t]=p,l.setDesc(`${s} (${p}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let i=this.plugin.manifest.version,s=e.createDiv();s.style.display="flex",s.style.alignItems="center",s.style.gap="12px",s.style.marginBottom="16px";let a=s.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 t=s.createDiv(),n=t.createEl("h2",{text:"Waypoint Sidebar"});n.style.margin="0",n.style.lineHeight="1.2";let o=t.createDiv({text:`v${i}`});o.style.color="var(--text-muted)",o.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(a=>a.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new w.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 w.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(e).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...P.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,i,s,n,t,a,o,r,c){let l=new w.Setting(e).setName(i).setDesc(`${s} (${n[t]}${c})`);l.addSlider(h=>{h.setLimits(a,o,r).setValue(n[t]).setDynamicTooltip().onChange(p=>{n[t]=p,l.setDesc(`${s} (${p}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let i=this.plugin.manifest.version,s=e.createDiv();s.style.display="flex",s.style.alignItems="center",s.style.gap="12px",s.style.marginBottom="16px";let n=s.createDiv();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.width="48px",n.style.height="48px",n.style.borderRadius="12px",n.style.background="var(--interactive-accent)",n.style.color="var(--text-on-accent)",n.style.fontSize="24px",(0,w.setIcon)(n,"compass");let t=s.createDiv(),a=t.createEl("h2",{text:"Waypoint Sidebar"});a.style.margin="0",a.style.lineHeight="1.2";let o=t.createDiv({text:`v${i}`});o.style.color="var(--text-muted)",o.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 d=require("obsidian");var I=require("obsidian");function G(f,m,e){let i=(0,I.moment)({year:f,month:m,day:1}),s=(0,I.moment)(i).endOf("month"),a=(0,I.moment)(i).subtract((i.day()-e+7)%7,"days"),t=(0,I.moment)().startOf("day"),n=[],o=(0,I.moment)(a);for(;o.isBefore(s)||o.month()===m;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,I.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(t,"day"),isCurrentMonth:o.month()===m,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(n.push({weekNumber:r[0].isoWeekNumber,days:r}),n.length>=6)break}return n}var T="waypoint-view";function te(f){return f.dragManager}var L=class extends d.ItemView{constructor(e,i){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,d.moment)().month();this.currentDisplayYear=(0,d.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=i}getViewType(){return T}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let e=this.contentEl.createDiv({cls:"waypoint-section"});e.createDiv({cls:"waypoint-section-header",text:"Calendar"});let i=e.createDiv({cls:"waypoint-calendar"}),s=(0,d.moment)(),a=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),t=i.createDiv({cls:"waypoint-calendar-top"}),n=t.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=a.format("[Q]Q"),r=n.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",a)}),r.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("quarter",a,this.app.workspace.getLeaf("tab")))});let c=a.format("MMMM"),l=n.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",a)}),l.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("month",a,this.app.workspace.getLeaf("tab")))});let h=a.format("YYYY"),p=n.createSpan({cls:"waypoint-clickable",text:h});p.addEventListener("click",()=>{this.plugin.openPeriodNote("year",a)}),p.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("year",a,this.app.workspace.getLeaf("tab")))});let u=t.createDiv({cls:"waypoint-calendar-today-group"}),D=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(D,"chevron-left"),D.addEventListener("click",()=>this.navigateMonth(-1)),u.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,d.moment)().month(),this.currentDisplayYear=(0,d.moment)().year(),this.redraw()});let k=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(k,"chevron-right"),k.addEventListener("click",()=>this.navigateMonth(1));let b=i.createEl("table"),g=b.createEl("thead").createEl("tr");g.createEl("th",{text:""});let C=["sun","mon","tue","wed","thu","fri","sat"],W=this.plugin.settings.calendar.firstDayOfWeek;for(let F=0;F<7;F++){let B=(W+F)%7;g.createEl("th",{text:C[B]})}let S=b.createEl("tbody"),Q=G(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let F of Q){let B=S.createEl("tr"),O=B.createEl("td",{cls:"waypoint-weeknum"});O.setText(String(F.weekNumber));let H=F.days[0].date;O.addEventListener("click",()=>{this.plugin.openPeriodNote("week",H)}),O.addEventListener("mousedown",E=>{E.button===1&&(E.preventDefault(),this.plugin.openPeriodNote("week",H,this.app.workspace.getLeaf("tab")))});for(let E of F.days){let M=B.createEl("td",{cls:"waypoint-day"});if(M.setText(String(E.dayOfMonth)),E.isCurrentMonth||M.addClass("other-month"),E.isToday&&M.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let A=E.date.format("YYYY-MM-DD");this.plugin.hasNoteForDate(A)&&M.addClass("has-note")}M.addEventListener("click",()=>{this.plugin.openPeriodNote("day",E.date)}),M.addEventListener("mousedown",A=>{A.button===1&&(A.preventDefault(),this.plugin.openPeriodNote("day",E.date,this.app.workspace.getLeaf("tab")))})}}}navigateMonth(e){let i=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(e,"month");this.currentDisplayMonth=i.month(),this.currentDisplayYear=i.year(),this.redraw()}renderRecentFiles(){var r,c;let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(e.createDiv({cls:"waypoint-section-header",text:"Re
Line truncated
|
`)}};var d=require("obsidian");var I=require("obsidian");function Q(g,m,e){let i=(0,I.moment)({year:g,month:m,day:1}),s=(0,I.moment)(i).endOf("month"),n=(0,I.moment)(i).subtract((i.day()-e+7)%7,"days"),t=(0,I.moment)().startOf("day"),a=[],o=(0,I.moment)(n);for(;o.isBefore(s)||o.month()===m;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,I.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(t,"day"),isCurrentMonth:o.month()===m,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(a.push({weekNumber:r[0].isoWeekNumber,days:r}),a.length>=6)break}return a}var T="waypoint-view";function ae(g){return g.dragManager}var L=class extends d.ItemView{constructor(e,i){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,d.moment)().month();this.currentDisplayYear=(0,d.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=i}getViewType(){return T}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let e=this.contentEl.createDiv({cls:"waypoint-section"});e.createDiv({cls:"waypoint-section-header",text:"Calendar"});let i=e.createDiv({cls:"waypoint-calendar"}),s=(0,d.moment)(),n=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),t=i.createDiv({cls:"waypoint-calendar-top"}),a=t.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=n.format("[Q]Q"),r=a.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",n)}),r.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("quarter",n,this.app.workspace.getLeaf("tab")))});let c=n.format("MMMM"),l=a.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",n)}),l.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("month",n,this.app.workspace.getLeaf("tab")))});let h=n.format("YYYY"),p=a.createSpan({cls:"waypoint-clickable",text:h});p.addEventListener("click",()=>{this.plugin.openPeriodNote("year",n)}),p.addEventListener("mousedown",F=>{F.button===1&&(F.preventDefault(),this.plugin.openPeriodNote("year",n,this.app.workspace.getLeaf("tab")))});let u=t.createDiv({cls:"waypoint-calendar-today-group"}),D=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(D,"chevron-left"),D.addEventListener("click",()=>this.navigateMonth(-1)),u.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,d.moment)().month(),this.currentDisplayYear=(0,d.moment)().year(),this.redraw()});let k=u.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,d.setIcon)(k,"chevron-right"),k.addEventListener("click",()=>this.navigateMonth(1));let b=i.createEl("table"),f=b.createEl("thead").createEl("tr");f.createEl("th",{text:""});let C=["sun","mon","tue","wed","thu","fri","sat"],$=this.plugin.settings.calendar.firstDayOfWeek;for(let F=0;F<7;F++){let A=($+F)%7;f.createEl("th",{text:C[A]})}let S=b.createEl("tbody"),U=Q(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let F of U){let A=S.createEl("tr"),z=A.createEl("td",{cls:"waypoint-weeknum"});z.setText(String(F.weekNumber));let K=F.days[0].date;z.addEventListener("click",()=>{this.plugin.openPeriodNote("week",K)}),z.addEventListener("mousedown",E=>{E.button===1&&(E.preventDefault(),this.plugin.openPeriodNote("week",K,this.app.workspace.getLeaf("tab")))});for(let E of F.days){let M=A.createEl("td",{cls:"waypoint-day"});if(M.setText(String(E.dayOfMonth)),E.isCurrentMonth||M.addClass("other-month"),E.isToday&&M.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let N=E.date.format("YYYY-MM-DD");this.plugin.hasNoteForDate(N)&&M.addClass("has-note")}M.addEventListener("click",()=>{this.plugin.openPeriodNote("day",E.date)}),M.addEventListener("mousedown",N=>{N.button===1&&(N.preventDefault(),this.plugin.openPeriodNote("day",E.date,this.app.workspace.getLeaf("tab")))})}}}navigateMonth(e){let i=(0,d.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(e,"month");this.currentDisplayMonth=i.month(),this.currentDisplayYear=i.year(),this.redraw()}renderRecentFiles(){var r,c;let e=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(e.createDiv({cls:"waypoint-section-header",text:"Re
Line truncated
|
||||||
|
${j(p)}
|
||||||
|
Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,B),null}let r=i.templateFile,c=this.resolveTemplateFile(r),l;if(c)try{l=await this.app.vault.read(c)}catch(p){return new y.Notice(`Waypoint: could not read the template "${c.path}" for the ${t} note.
|
||||||
|
`+j(p),B),null}else l=`---
|
||||||
type: ${i.typeProperty}
|
type: ${i.typeProperty}
|
||||||
date: ${s.format("YYYY-MM-DD")}
|
date: ${s.format("YYYY-MM-DD")}
|
||||||
---
|
---
|
||||||
|
|
||||||
`;return await this.app.vault.create(e,n)}catch(t){let n=t instanceof Error?t.message:String(t);return new v.Notice(`Failed to create ${a.toLowerCase()} note: ${n}`),null}}resolveTemplateFile(e){if(!e)return null;let i=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(i)}detectPeriodType(e){for(let i of se){let s=this.settings[j[i].key].nameFormat;if(!s)continue;let a=(0,v.moment)(e,s,!0);if(a.isValid())return{period:i,date:a}}return null}async navigatePeriodNote(e){let i=this.app.workspace.getActiveFile();if(!i){new v.Notice("No active file");return}let s=this.detectPeriodType(i.basename);if(!s){new v.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:a,date:t}=s;if(!t.isValid()){new v.Notice(`Could not parse date from filename: ${i.basename}`);return}let n=e==="next"?1:-1,o=a==="quarter"?t.clone().add(n*3,"months"):t.clone().add(n,`${a}s`);await this.openPeriodNote(a,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(T);for(let i of e)i.view instanceof L&&i.view.redraw()}},ne=["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"}},se=["day","week","month","quarter","year"];function K(f){return f.slice(f.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}
|
`;let h;try{h=await this.app.vault.create(e,l)}catch(p){return new y.Notice(`Waypoint: could not create the ${t} note at "${e}".
|
||||||
|
${j(p)}`,B),null}return r&&!c?new y.Notice(`Created ${t} note: ${h.basename}
|
||||||
|
Template "${r}" was not found, so a basic note was created instead.`,B):new y.Notice(`Created ${t} note: ${h.basename}`),h}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof y.TFolder)return;let i="";for(let s of e.split("/"))if(s&&(i=i?`${i}/${s}`:s,!(this.app.vault.getAbstractFileByPath(i)instanceof y.TFolder)))try{await this.app.vault.createFolder(i)}catch(n){if(!(this.app.vault.getAbstractFileByPath(i)instanceof y.TFolder))throw n}}resolveTemplateFile(e){if(!e)return null;let i=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(i)}detectPeriodType(e){for(let i of _){let s=this.settings[Y[i].key].nameFormat;if(!s)continue;let n=(0,y.moment)(e,s,!0);if(n.isValid())return{period:i,date:n}}return null}async navigatePeriodNote(e){let i=this.app.workspace.getActiveFile();if(!i){new y.Notice("No active file");return}let s=this.detectPeriodType(i.basename);if(!s){let r=_.map(c=>`${Y[c].label.toLowerCase()} "${this.settings[Y[c].key].nameFormat}"`).join(", ");new y.Notice(`Waypoint: "${i.basename}" does not match any configured periodic note format.
|
||||||
|
Expected one of: ${r}.`,B);return}let{period:n,date:t}=s,a=e==="next"?1:-1,o=n==="quarter"?t.clone().add(a*3,"months"):t.clone().add(a,`${n}s`);await this.openPeriodNote(n,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(T);for(let i of e)i.view instanceof L&&i.view.redraw()}},re=["daily","weekly","monthly","quarterly","yearly"],Y={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"}},_=["day","week","month","quarter","year"];function Z(g){return g.slice(g.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var B=1e4;function j(g){return g instanceof Error?g.message:String(g)}
|
||||||
Reference in new issue
Block a user