fix: default calendar to system indicators
Use coloured system markers by default, preserve configured colours through settings migration, expose all template fields through native vault-path autocomplete, and remove the redundant Calendar heading.
This commit is contained in:
1 parent
069456799e
commit
72a61e49ee
4 files changed
+54
-28
No files matched your search
@@ -2,26 +2,26 @@
|
|||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var _=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ge=(p,d)=>{for(var e in d)_(p,e,{get:d[e],enumerable:!0})},fe=(p,d,e,a)=>{if(d&&typeof d=="object"||typeof d=="function")for(let n of he(d))!ue.call(p,n)&&n!==e&&_(p,n,{get:()=>d[n],enumerable:!(a=me(d,n))||a.enumerable});return p};var ye=p=>fe(_({},"__esModule",{value:!0}),p);var Se={};ge(Se,{default:()=>q});module.exports=ye(Se);var f=require("obsidian");var $={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file",indicatorColor:"#64748b"},T={calendar:{firstDayOfWeek:1,showNoteIndicators:!0,indicatorMode:"any",dailyIndicatorColor:"#3b82f6"},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},dateSystems:[{id:"journal",name:"Journal",folder:"periodic/journal",nameFormat:"YYYY-MM-DD - [Journal]",templateFile:"",typeProperty:"journal",icon:"book-open",indicatorColor:"#22c55e"},{id:"meetings",name:"Meeting",folder:"periodic/meetings",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"meeting",icon:"users",indicatorColor:"#a855f7"}],recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var v=require("obsidian");var se="{title}";function R(p){let d=p.indexOf(se);return d<0?{before:p,after:"",hasTitle:!1}:{before:p.slice(0,d),after:p.slice(d+se.length),hasTitle:!0}}function Q(p,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return p.startsWith(e)}function U(p,d,e,a){return a?!d||p.length<d.length+e.length?!1:p.startsWith(d)&&p.endsWith(e):p===d+e}function oe(p,d,e){let a=p.startsWith(d)?d.length:0,n=e&&p.endsWith(e)?p.length-e.length:p.length;return n<=a?p:p.slice(a,n).trim()||p}var ve=/[\\/:*?"<>|#^[\]]/g;function re(p){return p.replace(ve,"-").replace(/\s+/g," ").trim()}function A(p){let{before:d}=R(p),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var z=class extends v.PluginSettingTab{constructor(e,a,n,t){super(e,a);this.activeTab="calendar";this.plugin=a,this.settings=n,this.onSettingsChange=t}display(){let{containerEl:e}=this;e.empty();let a=e.createDiv({cls:"waypoint-settings-tabs"}),n=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"systems",label:"Date systems"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let i of n)a.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===i.key?" is-active":""}`,text:i.label}).addEventListener("click",()=>{this.activeTab=i.key,this.display()});let t=e.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(t);break;case"periodic":this.renderPeriodicTab(t);break;case"systems":this.renderSystemsTab(t);break;case"recent":this.renderRecentTab(t);break;case"display":this.renderDisplayTab(t);break;case"about":this.renderAboutTab(t);break}}renderCalendarTab(e){new v.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(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(e).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()})}),new v.Setting(e).setName("Indicator style").setDesc("Show one neutral dot for any dated note, or one coloured dot for each configured date system.").addDropdown(a=>{a.addOption("any","Single dot").addOption("systems","Colour by note system").setValue(this.settings.calendar.indicatorMode).onChange(n=>{this.settings.calendar.indicatorMode=n,this.saveAndRefresh()})}),new v.Setting(e).setName("Daily indicator colour").setDesc("Colour for daily-note dots when using \u201CColour by note system\u201D.").addColorPicker(a=>{a.setValue(this.settings.calendar.dailyIndicatorColor).onChange(n=>{this.settings.calendar.dailyIndicatorColor=n,this.saveAndRefresh()})})}renderPeriodicTab(e){this.addPeriodNoteSettings(e,"Daily",this.settings.daily),this.addPeriodNoteSettings(e,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(e,"Monthly",thisLine truncated
|
var _=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ge=(p,d)=>{for(var e in d)_(p,e,{get:d[e],enumerable:!0})},fe=(p,d,e,n)=>{if(d&&typeof d=="object"||typeof d=="function")for(let i of he(d))!ue.call(p,i)&&i!==e&&_(p,i,{get:()=>d[i],enumerable:!(n=me(d,i))||n.enumerable});return p};var ye=p=>fe(_({},"__esModule",{value:!0}),p);var Se={};ge(Se,{default:()=>q});module.exports=ye(Se);var f=require("obsidian");var $={name:"",folder:"",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"",icon:"file",indicatorColor:"#64748b"},T={calendar:{firstDayOfWeek:1,showNoteIndicators:!0,indicatorMode:"systems",dailyIndicatorColor:"#3b82f6"},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},dateSystems:[{id:"journal",name:"Journal",folder:"periodic/journal",nameFormat:"YYYY-MM-DD - [Journal]",templateFile:"",typeProperty:"journal",icon:"book-open",indicatorColor:"#22c55e"},{id:"meetings",name:"Meeting",folder:"periodic/meetings",nameFormat:"YYYY-MM-DD - {title}",templateFile:"",typeProperty:"meeting",icon:"users",indicatorColor:"#a855f7"}],recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[],filterTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var v=require("obsidian");var se="{title}";function R(p){let d=p.indexOf(se);return d<0?{before:p,after:"",hasTitle:!1}:{before:p.slice(0,d),after:p.slice(d+se.length),hasTitle:!0}}function Q(p,d){if(!d)return!0;let e=d.endsWith("/")?d:`${d}/`;return p.startsWith(e)}function U(p,d,e,n){return n?!d||p.length<d.length+e.length?!1:p.startsWith(d)&&p.endsWith(e):p===d+e}function oe(p,d,e){let n=p.startsWith(d)?d.length:0,i=e&&p.endsWith(e)?p.length-e.length:p.length;return i<=n?p:p.slice(n,i).trim()||p}var ve=/[\\/:*?"<>|#^[\]]/g;function re(p){return p.replace(ve,"-").replace(/\s+/g," ").trim()}function A(p){let{before:d}=R(p),e=d.replace(/\[[^\]]*\]/g,"");return/[YMDQGWEwdgeo]/.test(e)}var z=class extends v.PluginSettingTab{constructor(e,n,i,a){super(e,n);this.activeTab="calendar";this.plugin=n,this.settings=i,this.onSettingsChange=a}display(){let{containerEl:e}=this;e.empty();let n=e.createDiv({cls:"waypoint-settings-tabs"}),i=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"systems",label:"Date systems"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"},{key:"about",label:"About"}];for(let t of i)n.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"systems":this.renderSystemsTab(a);break;case"recent":this.renderRecentTab(a);break;case"display":this.renderDisplayTab(a);break;case"about":this.renderAboutTab(a);break}}renderCalendarTab(e){new v.Setting(e).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(n=>{n.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(i=>{this.settings.calendar.firstDayOfWeek=parseInt(i,10),this.saveAndRefresh()})}),new v.Setting(e).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(n=>{n.setValue(this.settings.calendar.showNoteIndicators).onChange(i=>{this.settings.calendar.showNoteIndicators=i,this.saveAndRefresh()})}),new v.Setting(e).setName("Indicator style").setDesc("Show one neutral dot for any dated note, or one coloured dot for each configured date system.").addDropdown(n=>{n.addOption("any","Single dot").addOption("systems","Colour by note system").setValue(this.settings.calendar.indicatorMode).onChange(i=>{this.settings.calendar.indicatorMode=i,this.saveAndRefresh()})}),new v.Setting(e).setName("Daily indicator colour").setDesc("Colour for daily-note dots when using \u201CColour by note system\u201D.").addColorPicker(n=>{n.setValue(this.settings.calendar.dailyIndicatorColor).onChange(i=>{this.settings.calendar.dailyIndicatorColor=i,this.saveAndRefresh()})})}renderPeriodicTab(e){let n=this.createTemplateSuggestions(e);this.addPeriodNoteSettings(e,"Daily",this.settings.daily,n),this.addPeriodNoteSettings(e,"Weekly",this.settings.weeklLine truncated
|
||||||
\\.png$`),i.setValue(this.settings.recentFiles.omittedPaths.join(`
|
\\.png$`),t.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||||
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=i.getValue().split(`
|
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=t.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(e).setName("Omitted tags").setDesc(n).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`ignore
|
`).filter(s=>s.trim()),this.saveAndRefresh()}});let i=new DocumentFragment;i.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new v.Setting(e).setName("Omitted tags").setDesc(i).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`ignore
|
||||||
archive`),i.setValue(this.settings.recentFiles.omittedTags.join(`
|
archive`),t.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||||
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=i.getValue().split(`
|
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=t.getValue().split(`
|
||||||
`).filter(s=>s.trim()),this.saveAndRefresh()}});let t=new DocumentFragment;t.appendText("Tags to show as filter pills above the file list. One per line. Leave empty to auto-detect from frontmatter `type` property."),new v.Setting(e).setName("Filter tags").setDesc(t).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`meeting
|
`).filter(s=>s.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 v.Setting(e).setName("Filter tags").setDesc(a).addTextArea(t=>{t.inputEl.setAttr("rows",4),t.setPlaceholder(`meeting
|
||||||
person
|
person
|
||||||
project`),i.setValue(this.settings.recentFiles.filterTags.join(`
|
project`),t.setValue(this.settings.recentFiles.filterTags.join(`
|
||||||
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=i.getValue().split(`
|
`)),t.inputEl.onblur=()=>{this.settings.recentFiles.filterTags=t.getValue().split(`
|
||||||
`).filter(s=>s.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new v.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new v.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new v.Setting(e).addButton(a=>a.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...T.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,a,n,t,i,s,o,r,c){let l=new v.Setting(e).setName(a).setDesc(`${n} (${t[i]}${c})`);l.addSlider(h=>{h.setLimits(s,o,r).setValue(t[i]).setDynamicTooltip().onChange(u=>{t[i]=u,l.setDesc(`${n} (${u}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let a=this.plugin.manifest.version,n=e.createDiv();n.style.display="flex",n.style.alignItems="center",n.style.gap="12px",n.style.marginBottom="16px";let t=n.createDiv();t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.width="48px",t.style.height="48px",t.style.borderRadius="12px",t.style.background="var(--interactive-accent)",t.style.color="var(--text-on-accent)",t.style.fontSize="24px",(0,v.setIcon)(t,"compass");let i=n.createDiv(),s=i.createEl("h2",{text:"Waypoint Sidebar"});s.style.margin="0",s.style.lineHeight="1.2";let o=i.createDiv({text:`v${a}`});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(s=>s.trim()),this.saveAndRefresh()}})}renderDisplayTab(e){new v.Setting(e).setHeading().setName("Bookmarks"),this.addSliderSetting(e,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(e,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(e,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(e,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(e,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new v.Setting(e).setHeading().setName("Calendar"),this.addSliderSetting(e,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new v.Setting(e).addButton(n=>n.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...T.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(e,n,i,a,t,s,o,r,c){let l=new v.Setting(e).setName(n).setDesc(`${i} (${a[t]}${c})`);l.addSlider(h=>{h.setLimits(s,o,r).setValue(a[t]).setDynamicTooltip().onChange(u=>{a[t]=u,l.setDesc(`${i} (${u}${c})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveSettings(),this.onSettingsChange()}renderAboutTab(e){let n=this.plugin.manifest.version,i=e.createDiv();i.style.display="flex",i.style.alignItems="center",i.style.gap="12px",i.style.marginBottom="16px";let a=i.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,v.setIcon)(a,"compass");let t=i.createDiv(),s=t.createEl("h2",{text:"Waypoint Sidebar"});s.style.margin="0",s.style.lineHeight="1.2";let o=t.createDiv({text:`v${n}`});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 m=require("obsidian");var C=require("obsidian");function le(p,d,e){let a=(0,C.moment)({year:p,month:d,day:1}),n=(0,C.moment)(a).endOf("month"),t=(0,C.moment)(a).subtract((a.day()-e+7)%7,"days"),i=(0,C.moment)().startOf("day"),s=[],o=(0,C.moment)(t);for(;o.isBefore(n)||o.month()===d;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,C.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(i,"day"),isCurrentMonth:o.month()===d,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(s.push({weekNumber:r[0].isoWeekNumber,days:r}),s.length>=6)break}return s}var E="waypoint-view";function ke(p){return p.dragManager}var W=class extends m.ItemView{constructor(e,a){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,m.moment)().month();this.currentDisplayYear=(0,m.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=a}getViewType(){return E}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 a=e.createDiv({cls:"waypoint-calendar"}),n=(0,m.moment)(),t=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),i=a.createDiv({cls:"waypoint-calendar-top"}),s=i.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=t.format("[Q]Q"),r=s.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",t)}),r.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("quarter",t,this.app.workspace.getLeaf("tab")))});let c=t.format("MMMM"),l=s.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",t)}),l.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("month",t,this.app.workspace.getLeaf("tab")))});let h=t.format("YYYY"),u=s.createSpan({cls:"waypoint-clickable",text:h});u.addEventListener("click",()=>{this.plugin.openPeriodNote("year",t)}),u.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("year",t,this.app.workspace.getLeaf("tab")))});let g=i.createDiv({cls:"waypoint-calendar-today-group"}),S=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(S,"chevron-left"),S.addEventListener("click",()=>this.navigateMonth(-1)),g.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,m.moment)().month(),this.currentDisplayYear=(0,m.moment)().year(),this.redraw()});let w=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(w,"chevron-right"),w.addEventListener("click",()=>this.navigateMonth(1));let b=a.createEl("table"),y=b.createEl("thead").createEl("tr");y.createEl("th",{text:""});let L=["sun","mon","tue","wed","thu","fri","sat"],G=this.plugin.settings.calendar.firstDayOfWeek;for(let D=0;D<7;D++){let N=(G+D)%7;y.createEl("th",{text:L[N]})}let P=b.createEl("tbody"),ee=le(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek),K=this.plugin.settings.calendar.showNoteIndicators&&this.plugin.settings.calendar.indicatorMode==="systems"?this.plugin.getDateSystemIndicators(ee.reduce((D,N)=>D.concat(N.days.map(Y=>Y.date)),[])):null;for(let D of ee){let N=P.createEl("tr"),Y=N.createEl("td",{cls:"waypoint-weeknum"});Y.setText(String(D.weekNumber));let te=D.days[0].date;Y.addEventListener("click",()=>{this.plugin.openPeriodNote("week",te)}),Y.addEventListener("mousedown",x=>{x.button===1&&(x.preventDefault(),this.plugin.openPeriodNote("week",te,this.app.workspace.getLeaf("tab")))});for(let x of D.days){let M=N.createEl("td",{cls:"waypoint-day"});if(M.setText(String(x.dayOfMonth)),x.isCurrentMonth||M.addClass("other-month"),x.isToday&&M.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let I=x.date.format("YYYY-MM-DD");if(this.plugin.settings.calendar.indicatorMode==="any")this.plugin.hasNoteForDate(I)&&M.addClass("has-note");else{let ne=(K==null?void 0:K.get(I))||[];if(ne.length>0){let pe=M.createDiv({cls:"waypoint-day-indicators"});for(let ie of ne){let ae=pe.createSpan({cls:"waypoint-day-indicator"});ae.style.setProperty("--waypoint-indicator-color",ie.color),(0,m.setTooltip)(ae,ie.name)}}}}M.addEventListener("click",()=>{this.plugin
Line truncated
|
`)}};var m=require("obsidian");var C=require("obsidian");function le(p,d,e){let n=(0,C.moment)({year:p,month:d,day:1}),i=(0,C.moment)(n).endOf("month"),a=(0,C.moment)(n).subtract((n.day()-e+7)%7,"days"),t=(0,C.moment)().startOf("day"),s=[],o=(0,C.moment)(a);for(;o.isBefore(i)||o.month()===d;){let r=[];for(let c=0;c<7;c++)r.push({date:(0,C.moment)(o),dayOfMonth:o.date(),isToday:o.isSame(t,"day"),isCurrentMonth:o.month()===d,isoWeekNumber:o.isoWeek()}),o.add(1,"day");if(s.push({weekNumber:r[0].isoWeekNumber,days:r}),s.length>=6)break}return s}var E="waypoint-view";function ke(p){return p.dragManager}var W=class extends m.ItemView{constructor(e,n){super(e);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let e=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",e.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",e.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",e.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",e.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",e.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",e.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,m.moment)().month();this.currentDisplayYear=(0,m.moment)().year();this.dragId=null;this.dropZones=new WeakMap;this.recentFilesFilter=null;this.plugin=n}getViewType(){return E}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let n=this.contentEl.createDiv({cls:"waypoint-section"}).createDiv({cls:"waypoint-calendar"}),i=(0,m.moment)(),a=(0,m.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),t=n.createDiv({cls:"waypoint-calendar-top"}),s=t.createDiv({cls:"waypoint-calendar-breadcrumb"}),o=a.format("[Q]Q"),r=s.createSpan({cls:"waypoint-clickable",text:o});r.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",a)}),r.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("quarter",a,this.app.workspace.getLeaf("tab")))});let c=a.format("MMMM"),l=s.createSpan({cls:"waypoint-clickable",text:c});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",a)}),l.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("month",a,this.app.workspace.getLeaf("tab")))});let h=a.format("YYYY"),u=s.createSpan({cls:"waypoint-clickable",text:h});u.addEventListener("click",()=>{this.plugin.openPeriodNote("year",a)}),u.addEventListener("mousedown",D=>{D.button===1&&(D.preventDefault(),this.plugin.openPeriodNote("year",a,this.app.workspace.getLeaf("tab")))});let g=t.createDiv({cls:"waypoint-calendar-today-group"}),S=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(S,"chevron-left"),S.addEventListener("click",()=>this.navigateMonth(-1)),g.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,m.moment)().month(),this.currentDisplayYear=(0,m.moment)().year(),this.redraw()});let w=g.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,m.setIcon)(w,"chevron-right"),w.addEventListener("click",()=>this.navigateMonth(1));let b=n.createEl("table"),y=b.createEl("thead").createEl("tr");y.createEl("th",{text:""});let L=["sun","mon","tue","wed","thu","fri","sat"],G=this.plugin.settings.calendar.firstDayOfWeek;for(let D=0;D<7;D++){let N=(G+D)%7;y.createEl("th",{text:L[N]})}let P=b.createEl("tbody"),ee=le(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek),K=this.plugin.settings.calendar.showNoteIndicators&&this.plugin.settings.calendar.indicatorMode==="systems"?this.plugin.getDateSystemIndicators(ee.reduce((D,N)=>D.concat(N.days.map(Y=>Y.date)),[])):null;for(let D of ee){let N=P.createEl("tr"),Y=N.createEl("td",{cls:"waypoint-weeknum"});Y.setText(String(D.weekNumber));let te=D.days[0].date;Y.addEventListener("click",()=>{this.plugin.openPeriodNote("week",te)}),Y.addEventListener("mousedown",x=>{x.button===1&&(x.preventDefault(),this.plugin.openPeriodNote("week",te,this.app.workspace.getLeaf("tab")))});for(let x of D.days){let M=N.createEl("td",{cls:"waypoint-day"});if(M.setText(String(x.dayOfMonth)),x.isCurrentMonth||M.addClass("other-month"),x.isToday&&M.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let I=x.date.format("YYYY-MM-DD");if(this.plugin.settings.calendar.indicatorMode==="any")this.plugin.hasNoteForDate(I)&&M.addClass("has-note");else{let ne=(K==null?void 0:K.get(I))||[];if(ne.length>0){let pe=M.createDiv({cls:"waypoint-day-indicators"});for(let ie of ne){let ae=pe.createSpan({cls:"waypoint-day-indicator"});ae.style.setProperty("--waypoint-indicator-color",ie.color),(0,m.setTooltip)(ae,ie.name)}}}}M.addEventListener("click",()=>{this.plugin.openPeriodNote("day",x.date)}),M.addEventListener("mousedown",I=>{I.
Line truncated
|
||||||
${X(h)}
|
${X(h)}
|
||||||
Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,O),null}let o=a.templateFile,r=this.resolveTemplateFile(o),c;if(r)try{c=await this.app.vault.read(r)}catch(h){return new f.Notice(`Waypoint: could not read the template "${r.path}" for the ${t} note.
|
Check Settings \u2192 Waypoint Sidebar \u2192 Periodic Notes.`,O),null}let o=n.templateFile,r=this.resolveTemplateFile(o),c;if(r)try{c=await this.app.vault.read(r)}catch(h){return new f.Notice(`Waypoint: could not read the template "${r.path}" for the ${a} note.
|
||||||
`+X(h),O),null}else c=`---
|
`+X(h),O),null}else c=`---
|
||||||
type: ${a.typeProperty}
|
type: ${n.typeProperty}
|
||||||
date: ${n.format("YYYY-MM-DD")}
|
date: ${i.format("YYYY-MM-DD")}
|
||||||
---
|
---
|
||||||
|
|
||||||
`;let l;try{l=await this.app.vault.create(e,c)}catch(h){return new f.Notice(`Waypoint: could not create the ${t} note at "${e}".
|
`;let l;try{l=await this.app.vault.create(e,c)}catch(h){return new f.Notice(`Waypoint: could not create the ${a} note at "${e}".
|
||||||
${X(h)}`,O),null}return o&&!r?new f.Notice(`Created ${t} note: ${l.basename}
|
${X(h)}`,O),null}return o&&!r?new f.Notice(`Created ${a} note: ${l.basename}
|
||||||
Template "${o}" was not found, so a basic note was created instead.`,O):new f.Notice(`Created ${t} note: ${l.basename}`),l}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof f.TFolder)return;let a="";for(let n of e.split("/"))if(n&&(a=a?`${a}/${n}`:n,!(this.app.vault.getAbstractFileByPath(a)instanceof f.TFolder)))try{await this.app.vault.createFolder(a)}catch(t){if(!(this.app.vault.getAbstractFileByPath(a)instanceof f.TFolder))throw t}}resolveTemplateFile(e){if(!e)return null;let a=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(a)}detectPeriodType(e){for(let a of ce){let n=this.settings[j[a].key].nameFormat;if(!n)continue;let t=(0,f.moment)(e,n,!0);if(t.isValid())return{period:a,date:t}}return null}async navigatePeriodNote(e){let a=this.app.workspace.getActiveFile();if(!a){new f.Notice("No active file");return}let n=this.detectPeriodType(a.basename);if(!n){let r=ce.map(c=>`${j[c].label.toLowerCase()} "${this.settings[j[c].key].nameFormat}"`).join(", ");new f.Notice(`Waypoint: "${a.basename}" does not match any configured periodic note format.
|
Template "${o}" was not found, so a basic note was created instead.`,O):new f.Notice(`Created ${a} note: ${l.basename}`),l}async ensureFolderExists(e){if(!e||this.app.vault.getAbstractFileByPath(e)instanceof f.TFolder)return;let n="";for(let i of e.split("/"))if(i&&(n=n?`${n}/${i}`:i,!(this.app.vault.getAbstractFileByPath(n)instanceof f.TFolder)))try{await this.app.vault.createFolder(n)}catch(a){if(!(this.app.vault.getAbstractFileByPath(n)instanceof f.TFolder))throw a}}resolveTemplateFile(e){if(!e)return null;let n=e.toLowerCase().endsWith(".md")?e:`${e}.md`;return this.app.vault.getFileByPath(n)}detectPeriodType(e){for(let n of ce){let i=this.settings[j[n].key].nameFormat;if(!i)continue;let a=(0,f.moment)(e,i,!0);if(a.isValid())return{period:n,date:a}}return null}async navigatePeriodNote(e){let n=this.app.workspace.getActiveFile();if(!n){new f.Notice("No active file");return}let i=this.detectPeriodType(n.basename);if(!i){let r=ce.map(c=>`${j[c].label.toLowerCase()} "${this.settings[j[c].key].nameFormat}"`).join(", ");new f.Notice(`Waypoint: "${n.basename}" does not match any configured periodic note format.
|
||||||
Expected one of: ${r}.`,O);return}let{period:t,date:i}=n,s=e==="next"?1:-1,o=t==="quarter"?i.clone().add(s*3,"months"):i.clone().add(s,`${t}s`);await this.openPeriodNote(t,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(E);for(let a of e)a.view instanceof W&&a.view.redraw()}},De=["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"}},ce=["day","week","month","quarter","year"];function de(p){return p.slice(p.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var O=1e4;function X(p){return p instanceof Error?p.message:String(p)}function B(p,d){return d?p.format(d):""}
|
Expected one of: ${r}.`,O);return}let{period:a,date:t}=i,s=e==="next"?1:-1,o=a==="quarter"?t.clone().add(s*3,"months"):t.clone().add(s,`${a}s`);await this.openPeriodNote(a,o)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let e=this.app.workspace.getLeavesOfType(E);for(let n of e)n.view instanceof W&&n.view.redraw()}},De=["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"}},ce=["day","week","month","quarter","year"];function de(p){return p.slice(p.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"")}var O=1e4;function X(p){return p instanceof Error?p.message:String(p)}function B(p,d){return d?p.format(d):""}
|
||||||
+35
-8
@@ -129,14 +129,20 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
// ═══════════════════════════════
|
// ═══════════════════════════════
|
||||||
|
|
||||||
private renderPeriodicTab(container: HTMLElement): void {
|
private renderPeriodicTab(container: HTMLElement): void {
|
||||||
this.addPeriodNoteSettings(container, 'Daily', this.settings.daily);
|
const templateSuggestionsId = this.createTemplateSuggestions(container);
|
||||||
this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly);
|
this.addPeriodNoteSettings(container, 'Daily', this.settings.daily, templateSuggestionsId);
|
||||||
this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly);
|
this.addPeriodNoteSettings(container, 'Weekly', this.settings.weekly, templateSuggestionsId);
|
||||||
this.addPeriodNoteSettings(container, 'Quarterly', this.settings.quarterly);
|
this.addPeriodNoteSettings(container, 'Monthly', this.settings.monthly, templateSuggestionsId);
|
||||||
this.addPeriodNoteSettings(container, 'Yearly', this.settings.yearly);
|
this.addPeriodNoteSettings(container, 'Quarterly', this.settings.quarterly, templateSuggestionsId);
|
||||||
|
this.addPeriodNoteSettings(container, 'Yearly', this.settings.yearly, templateSuggestionsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private addPeriodNoteSettings(container: HTMLElement, label: string, period: PeriodNoteSettings): void {
|
private addPeriodNoteSettings(
|
||||||
|
container: HTMLElement,
|
||||||
|
label: string,
|
||||||
|
period: PeriodNoteSettings,
|
||||||
|
templateSuggestionsId: string,
|
||||||
|
): void {
|
||||||
new Setting(container).setHeading().setName(label);
|
new Setting(container).setHeading().setName(label);
|
||||||
|
|
||||||
new Setting(container)
|
new Setting(container)
|
||||||
@@ -165,10 +171,11 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
new Setting(container)
|
new Setting(container)
|
||||||
.setName('Template file')
|
.setName('Template file')
|
||||||
.setDesc(`Path to the template file (without .md extension).`)
|
.setDesc('Path to the template file. The .md extension is optional.')
|
||||||
.addText((text) => {
|
.addText((text) => {
|
||||||
text.setPlaceholder('Templates/Daily note');
|
text.setPlaceholder('Templates/Daily note');
|
||||||
text.setValue(period.templateFile);
|
text.setValue(period.templateFile);
|
||||||
|
text.inputEl.setAttr('list', templateSuggestionsId);
|
||||||
text.onChange((value) => {
|
text.onChange((value) => {
|
||||||
period.templateFile = value;
|
period.templateFile = value;
|
||||||
this.saveAndRefresh();
|
this.saveAndRefresh();
|
||||||
@@ -204,6 +211,8 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
.setName('Date systems')
|
.setName('Date systems')
|
||||||
.setDesc(intro);
|
.setDesc(intro);
|
||||||
|
|
||||||
|
const templateSuggestionsId = this.createTemplateSuggestions(container);
|
||||||
|
|
||||||
this.settings.dateSystems.forEach((system, i, arr) => {
|
this.settings.dateSystems.forEach((system, i, arr) => {
|
||||||
new Setting(container)
|
new Setting(container)
|
||||||
.setHeading()
|
.setHeading()
|
||||||
@@ -270,7 +279,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
this.addSystemTextSetting(container,
|
this.addSystemTextSetting(container,
|
||||||
'Template file', 'Path to the template file. The .md extension is optional.',
|
'Template file', 'Path to the template file. The .md extension is optional.',
|
||||||
system, 'templateFile', 'resources/template/journal',
|
system, 'templateFile', 'resources/template/journal', templateSuggestionsId,
|
||||||
);
|
);
|
||||||
this.addSystemTextSetting(container,
|
this.addSystemTextSetting(container,
|
||||||
'Type property', `Fallback value for the 'type' frontmatter property, used when no template is found.`,
|
'Type property', `Fallback value for the 'type' frontmatter property, used when no template is found.`,
|
||||||
@@ -318,6 +327,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
obj: Record<K, string>,
|
obj: Record<K, string>,
|
||||||
key: K,
|
key: K,
|
||||||
placeholder: string,
|
placeholder: string,
|
||||||
|
templateSuggestionsId?: string,
|
||||||
): Setting {
|
): Setting {
|
||||||
return new Setting(container)
|
return new Setting(container)
|
||||||
.setName(name)
|
.setName(name)
|
||||||
@@ -325,6 +335,7 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
.addText((text) => {
|
.addText((text) => {
|
||||||
text.setPlaceholder(placeholder);
|
text.setPlaceholder(placeholder);
|
||||||
text.setValue(obj[key]);
|
text.setValue(obj[key]);
|
||||||
|
if (templateSuggestionsId) text.inputEl.setAttr('list', templateSuggestionsId);
|
||||||
text.onChange((value) => {
|
text.onChange((value) => {
|
||||||
obj[key] = value;
|
obj[key] = value;
|
||||||
this.saveAndRefresh();
|
this.saveAndRefresh();
|
||||||
@@ -332,6 +343,22 @@ export class WaypointSettingTab extends PluginSettingTab {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Native datalist keeps template paths searchable without another custom
|
||||||
|
* modal, and accepts templates stored anywhere in the vault.
|
||||||
|
*/
|
||||||
|
private createTemplateSuggestions(container: HTMLElement): string {
|
||||||
|
const id = 'waypoint-template-suggestions';
|
||||||
|
const list = container.createEl('datalist', { attr: { id } });
|
||||||
|
const paths = this.app.vault.getMarkdownFiles()
|
||||||
|
.map(file => file.path.replace(/\.md$/, ''))
|
||||||
|
.sort((a, b) => a.localeCompare(b));
|
||||||
|
for (const path of paths) {
|
||||||
|
list.createEl('option', { value: path });
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
// ═══════════════════════════════
|
// ═══════════════════════════════
|
||||||
// Recent Files tab
|
// Recent Files tab
|
||||||
// ═══════════════════════════════
|
// ═══════════════════════════════
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ export const DEFAULT_SETTINGS: WaypointSettings = {
|
|||||||
calendar: {
|
calendar: {
|
||||||
firstDayOfWeek: 1, // Monday
|
firstDayOfWeek: 1, // Monday
|
||||||
showNoteIndicators: true,
|
showNoteIndicators: true,
|
||||||
indicatorMode: 'any',
|
indicatorMode: 'systems',
|
||||||
dailyIndicatorColor: '#3b82f6',
|
dailyIndicatorColor: '#3b82f6',
|
||||||
},
|
},
|
||||||
daily: {
|
daily: {
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ export class WaypointView extends ItemView {
|
|||||||
|
|
||||||
private renderCalendar(): void {
|
private renderCalendar(): void {
|
||||||
const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
|
const section = this.contentEl.createDiv({ cls: 'waypoint-section' });
|
||||||
section.createDiv({ cls: 'waypoint-section-header', text: 'Calendar' });
|
|
||||||
|
|
||||||
const cal = section.createDiv({ cls: 'waypoint-calendar' });
|
const cal = section.createDiv({ cls: 'waypoint-calendar' });
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user