feat: drag onto file bookmark creates parent note + fix calendar layout
Drag-and-drop: - Dropping a bookmark onto a file bookmark (middle zone) creates a new parent note group containing both items - Dropping onto a group still moves into the group as before - All file/group bookmarks now accept drops (3-zone behavior) Calendar: - Fixed broken table layout caused by display:flex on td elements - Uses vertical-align:middle instead for cell content centering - Calendar cells still have configurable height via CSS variable
This commit is contained in:
1 parent
765c6f3b47
commit
7a5be506e0
3 files changed
+69
-9
No files matched your search
@@ -2,20 +2,20 @@
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
*/
|
||||
|
||||
var z=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var U=(k,u)=>{for(var t in u)z(k,t,{get:u[t],enumerable:!0})},X=(k,u,t,i)=>{if(u&&typeof u=="object"||typeof u=="function")for(let o of j(u))!H.call(k,o)&&o!==t&&z(k,o,{get:()=>u[o],enumerable:!(i=Q(u,o))||i.enumerable});return k};var K=k=>X(z({},"__esModule",{value:!0}),k);var ee={};U(ee,{default:()=>O});module.exports=K(ee);var f=require("obsidian");var W={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var w=require("obsidian");var $=class extends w.PluginSettingTab{constructor(t,i,o,a){super(t,i);this.activeTab="calendar";this.plugin=i,this.settings=o,this.onSettingsChange=a}display(){let{containerEl:t}=this;t.empty();let i=t.createDiv({cls:"waypoint-settings-tabs"}),o=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"}];for(let e of o)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===e.key?" is-active":""}`,text:e.label}).addEventListener("click",()=>{this.activeTab=e.key,this.display()});let a=t.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(a);break;case"periodic":this.renderPeriodicTab(a);break;case"recent":this.renderRecentTab(a);break;case"display":this.renderDisplayTab(a);break}}renderCalendarTab(t){new w.Setting(t).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(i=>{i.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(o=>{this.settings.calendar.firstDayOfWeek=parseInt(o,10),this.saveAndRefresh()})}),new w.Setting(t).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(i=>{i.setValue(this.settings.calendar.showNoteIndicators).onChange(o=>{this.settings.calendar.showNoteIndicators=o,this.saveAndRefresh()})})}renderPeriodicTab(t){this.addPeriodNoteSettings(t,"Daily",this.settings.daily),this.addPeriodNoteSettings(t,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(t,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(t,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(t,"Yearly",this.settings.yearly)}addPeriodNoteSettings(t,i,o){new w.Setting(t).setHeading().setName(i),new w.Setting(t).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(o.folder),a.onChange(e=>{o.folder=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Name format").setDesc(`Date format for ${i.toLowerCase()} note filenames (moment.js format).`).addText(a=>{a.setPlaceholder("yyyy-MM-dd"),a.setValue(o.nameFormat),a.onChange(e=>{o.nameFormat=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(a=>{a.setPlaceholder("Templates/Daily note"),a.setValue(o.templateFile),a.onChange(e=>{o.templateFile=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(o.typeProperty),a.onChange(e=>{o.typeProperty=e,this.saveAndRefresh()})})}renderRecentTab(t){new w.Setting(t).setName("Max items").setDesc("Maximum number of recent files to track.").addText(a=>{a.inputEl.setAttr("type","number"),a.inputEl.setAttr("placeholder","50"),a.setValue(String(this.settings.recentFiles.maxItems)),a.inputEl.onblur=()=>{let e=parseInt(a.getValue(),10);!isNaN(e)&&e>0&&(this.settings.recentFiles.maxItems=e,this.saveAndRefresh())}}),new w.Setting(t).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(a=>{a.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(e=>{this.settings.recentFiles.updateOn=e,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(t).setName("Omitted paths").setDesc(i).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`^archiv
Line truncated
|
||||
var z=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var U=(b,u)=>{for(var t in u)z(b,t,{get:u[t],enumerable:!0})},X=(b,u,t,i)=>{if(u&&typeof u=="object"||typeof u=="function")for(let o of j(u))!H.call(b,o)&&o!==t&&z(b,o,{get:()=>u[o],enumerable:!(i=Q(u,o))||i.enumerable});return b};var K=b=>X(z({},"__esModule",{value:!0}),b);var ee={};U(ee,{default:()=>O});module.exports=K(ee);var y=require("obsidian");var W={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[]},display:{rowSize:26,rowSpacing:2,indentSize:16,fontSize:13,iconSize:16,calendarCellSize:32}};var w=require("obsidian");var $=class extends w.PluginSettingTab{constructor(t,i,o,a){super(t,i);this.activeTab="calendar";this.plugin=i,this.settings=o,this.onSettingsChange=a}display(){let{containerEl:t}=this;t.empty();let i=t.createDiv({cls:"waypoint-settings-tabs"}),o=[{key:"calendar",label:"Calendar"},{key:"periodic",label:"Periodic Notes"},{key:"recent",label:"Recent Files"},{key:"display",label:"Display"}];for(let e of o)i.createEl("button",{cls:`waypoint-settings-tab${this.activeTab===e.key?" is-active":""}`,text:e.label}).addEventListener("click",()=>{this.activeTab=e.key,this.display()});let a=t.createDiv({cls:"waypoint-settings-content"});switch(this.activeTab){case"calendar":this.renderCalendarTab(a);break;case"periodic":this.renderPeriodicTab(a);break;case"recent":this.renderRecentTab(a);break;case"display":this.renderDisplayTab(a);break}}renderCalendarTab(t){new w.Setting(t).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(i=>{i.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(o=>{this.settings.calendar.firstDayOfWeek=parseInt(o,10),this.saveAndRefresh()})}),new w.Setting(t).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(i=>{i.setValue(this.settings.calendar.showNoteIndicators).onChange(o=>{this.settings.calendar.showNoteIndicators=o,this.saveAndRefresh()})})}renderPeriodicTab(t){this.addPeriodNoteSettings(t,"Daily",this.settings.daily),this.addPeriodNoteSettings(t,"Weekly",this.settings.weekly),this.addPeriodNoteSettings(t,"Monthly",this.settings.monthly),this.addPeriodNoteSettings(t,"Quarterly",this.settings.quarterly),this.addPeriodNoteSettings(t,"Yearly",this.settings.yearly)}addPeriodNoteSettings(t,i,o){new w.Setting(t).setHeading().setName(i),new w.Setting(t).setName("Folder").setDesc(`Folder path for ${i.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(o.folder),a.onChange(e=>{o.folder=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Name format").setDesc(`Date format for ${i.toLowerCase()} note filenames (moment.js format).`).addText(a=>{a.setPlaceholder("yyyy-MM-dd"),a.setValue(o.nameFormat),a.onChange(e=>{o.nameFormat=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(a=>{a.setPlaceholder("Templates/Daily note"),a.setValue(o.templateFile),a.onChange(e=>{o.templateFile=e,this.saveAndRefresh()})}),new w.Setting(t).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(o.typeProperty),a.onChange(e=>{o.typeProperty=e,this.saveAndRefresh()})})}renderRecentTab(t){new w.Setting(t).setName("Max items").setDesc("Maximum number of recent files to track.").addText(a=>{a.inputEl.setAttr("type","number"),a.inputEl.setAttr("placeholder","50"),a.setValue(String(this.settings.recentFiles.maxItems)),a.inputEl.onblur=()=>{let e=parseInt(a.getValue(),10);!isNaN(e)&&e>0&&(this.settings.recentFiles.maxItems=e,this.saveAndRefresh())}}),new w.Setting(t).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(a=>{a.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(e=>{this.settings.recentFiles.updateOn=e,this.saveAndRefresh()})});let i=new DocumentFragment;i.appendText("Regex patterns for paths to exclude. One per line."),new w.Setting(t).setName("Omitted paths").setDesc(i).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`^archiv
Line truncated
|
||||
\\.png$`),a.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=a.getValue().split(`
|
||||
`).filter(e=>e.trim()),this.saveAndRefresh()}});let o=new DocumentFragment;o.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new w.Setting(t).setName("Omitted tags").setDesc(o).addTextArea(a=>{a.inputEl.setAttr("rows",4),a.setPlaceholder(`ignore
|
||||
archive`),a.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||
`)),a.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=a.getValue().split(`
|
||||
`).filter(e=>e.trim()),this.saveAndRefresh()}})}renderDisplayTab(t){new w.Setting(t).setHeading().setName("Bookmarks"),this.addSliderSetting(t,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(t,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(t,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(t,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(t,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new w.Setting(t).setHeading().setName("Calendar"),this.addSliderSetting(t,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(t).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...W.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(t,i,o,a,e,r,s,d,n){let l=new w.Setting(t).setName(i).setDesc(`${o} (${a[e]}${n})`);l.addSlider(c=>{c.setLimits(r,s,d).setValue(a[e]).setDynamicTooltip().onChange(h=>{a[e]=h,l.setDesc(`${o} (${h}${n})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveData(this.settings),this.onSettingsChange()}};var p=require("obsidian");var L=require("obsidian");function _(k,u,t){let i=(0,L.moment)({year:k,month:u,day:1}),o=(0,L.moment)(i).endOf("month"),a=(0,L.moment)(i).subtract((i.day()-t+7)%7,"days"),e=(0,L.moment)().startOf("day"),r=[],s=(0,L.moment)(a);for(;s.isBefore(o)||s.month()===u;){let d=[];for(let n=0;n<7;n++)d.push({date:(0,L.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(e,"day"),isCurrentMonth:s.month()===u,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(r.push({weekNumber:d[0].isoWeekNumber,days:d}),r.length>=6)break}return r}var C="waypoint-view",A=class extends p.ItemView{constructor(t,i){super(t);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let t=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",t.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",t.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",t.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",t.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",t.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",t.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,p.moment)().month();this.currentDisplayYear=(0,p.moment)().year();this.dragId=null;this.recentFilesFilter=null;this.plugin=i}getViewType(){return C}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let t=this.contentEl.createDiv({cls:"waypoint-section"});t.createDiv({cls:"waypoint-section-header",text:"Calendar"});let i=t.createDiv({cls:"waypoint-calendar"}),o=(0,p.moment)(),a=(0,p.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=i.createDiv({cls:"waypoint-calendar-top"}),r=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=a.format("[Q]Q"),d=r.createSpan({cls:"waypoint-clickable",text:s});d.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",a)}),d.addEventListener("mousedown",y=>{y.button===1&&(y.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",a,this.app.workspace.getLeaf("tab")))});let n=a.format("MMMM"),l=r.createSpan({cls:"waypoint-clickable",text:n});l.addEventListener("click",()=>{this.plugin.openPeriodNote("month",a)}),l.addEventListener("mousedown",y=>{y.button===1&&(y.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",a,this.app.workspace.getLeaf("tab")))});let c=a.format("YYYY"),h=r.createSpan({cls:"waypoint-clickable",text:c});h.addEventListener("click",()=>{this.plugin.openPeriodNote("year",a)}),h.addEventListener("mousedown",y=>{y.button===1&&(y.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",a,this.app.workspace.getLeaf("tab")))});let m=e.createDiv({cls:"waypoint-calendar-today-group"}),g=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(g,"chevron-left"),g.addEventListener("click",()=>this.navigateMonth(-1)),m.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,p.moment)().month(),this.currentDisplayYear=(0,p.moment)().year(),this.redraw()});let F=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(F,"chevron-right"),F.addEventListener("click",()=>this.navigateMonth(1));let x=i.createEl("table"),S=x.createEl("thead").createEl("tr");S.createEl("th",{text:""});let b=["sun","mon","tue","wed","thu","fri","sat"],R=this.plugin.settings.calendar.firstDayOfWeek;for(let y=0;y<7;y++){let M=(R+y)%7;S.createEl("th",{text:b[M]})}let D=x.createEl("tbody"),P=_(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.s
Line truncated
|
||||
`).filter(e=>e.trim()),this.saveAndRefresh()}})}renderDisplayTab(t){new w.Setting(t).setHeading().setName("Bookmarks"),this.addSliderSetting(t,"Row size","Height of bookmark items.",this.settings.display,"rowSize",18,40,1,"px"),this.addSliderSetting(t,"Row spacing","Gap between bookmark items.",this.settings.display,"rowSpacing",0,12,1,"px"),this.addSliderSetting(t,"Indent size","Indent per nesting depth.",this.settings.display,"indentSize",8,32,2,"px"),this.addSliderSetting(t,"Font size","Label font size.",this.settings.display,"fontSize",10,18,1,"px"),this.addSliderSetting(t,"Icon size","Bookmark icon size.",this.settings.display,"iconSize",12,24,1,"px"),new w.Setting(t).setHeading().setName("Calendar"),this.addSliderSetting(t,"Cell size","Height of calendar day cells.",this.settings.display,"calendarCellSize",20,48,2,"px"),new w.Setting(t).addButton(i=>i.setButtonText("Reset to defaults").onClick(()=>{this.settings.display={...W.display},this.saveAndRefresh(),this.display()}))}addSliderSetting(t,i,o,a,e,l,s,d,n){let r=new w.Setting(t).setName(i).setDesc(`${o} (${a[e]}${n})`);r.addSlider(c=>{c.setLimits(l,s,d).setValue(a[e]).setDynamicTooltip().onChange(h=>{a[e]=h,r.setDesc(`${o} (${h}${n})`),this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveData(this.settings),this.onSettingsChange()}};var p=require("obsidian");var L=require("obsidian");function _(b,u,t){let i=(0,L.moment)({year:b,month:u,day:1}),o=(0,L.moment)(i).endOf("month"),a=(0,L.moment)(i).subtract((i.day()-t+7)%7,"days"),e=(0,L.moment)().startOf("day"),l=[],s=(0,L.moment)(a);for(;s.isBefore(o)||s.month()===u;){let d=[];for(let n=0;n<7;n++)d.push({date:(0,L.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(e,"day"),isCurrentMonth:s.month()===u,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(l.push({weekNumber:d[0].isoWeekNumber,days:d}),l.length>=6)break}return l}var C="waypoint-view",A=class extends p.ItemView{constructor(t,i){super(t);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view");let t=this.plugin.settings.display;this.contentEl.style.setProperty("--wp-row-size",t.rowSize+"px"),this.contentEl.style.setProperty("--wp-row-spacing",t.rowSpacing+"px"),this.contentEl.style.setProperty("--wp-indent-size",t.indentSize+"px"),this.contentEl.style.setProperty("--wp-font-size",t.fontSize+"px"),this.contentEl.style.setProperty("--wp-icon-size",t.iconSize+"px"),this.contentEl.style.setProperty("--wp-cal-cell-size",t.calendarCellSize+"px"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,p.moment)().month();this.currentDisplayYear=(0,p.moment)().year();this.dragId=null;this.recentFilesFilter=null;this.plugin=i}getViewType(){return C}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let t=this.contentEl.createDiv({cls:"waypoint-section"});t.createDiv({cls:"waypoint-section-header",text:"Calendar"});let i=t.createDiv({cls:"waypoint-calendar"}),o=(0,p.moment)(),a=(0,p.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=i.createDiv({cls:"waypoint-calendar-top"}),l=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=a.format("[Q]Q"),d=l.createSpan({cls:"waypoint-clickable",text:s});d.addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",a)}),d.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("quarter",a,this.app.workspace.getLeaf("tab")))});let n=a.format("MMMM"),r=l.createSpan({cls:"waypoint-clickable",text:n});r.addEventListener("click",()=>{this.plugin.openPeriodNote("month",a)}),r.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("month",a,this.app.workspace.getLeaf("tab")))});let c=a.format("YYYY"),h=l.createSpan({cls:"waypoint-clickable",text:c});h.addEventListener("click",()=>{this.plugin.openPeriodNote("year",a)}),h.addEventListener("mousedown",f=>{f.button===1&&(f.preventDefault(),this.plugin.openPeriodNoteInLeaf("year",a,this.app.workspace.getLeaf("tab")))});let m=e.createDiv({cls:"waypoint-calendar-today-group"}),g=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(g,"chevron-left"),g.addEventListener("click",()=>this.navigateMonth(-1)),m.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,p.moment)().month(),this.currentDisplayYear=(0,p.moment)().year(),this.redraw()});let F=m.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,p.setIcon)(F,"chevron-right"),F.addEventListener("click",()=>this.navigateMonth(1));let E=i.createEl("table"),S=E.createEl("thead").createEl("tr");S.createEl("th",{text:""});let k=["sun","mon","tue","wed","thu","fri","sat"],R=this.plugin.settings.calendar.firstDayOfWeek;for(let f=0;f<7;f++){let M=(R+f)%7;S.createEl("th",{text:k[M]})}let D=E.createEl("tbody"),I=_(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.s
Line truncated
|
||||
type: ${e.typeProperty}
|
||||
date: ${i.format("YYYY-MM-DD")}
|
||||
---
|
||||
|
||||
`;d=await this.app.vault.create(s,c)}}catch(n){new f.Notice(`Failed to create ${a.label.toLowerCase()} note: ${n.message}`);return}new f.Notice(`Created ${a.label.toLowerCase()} note: ${r}`)}d&&await this.app.workspace.getLeaf(!1).openFile(d)}async openPeriodNoteInLeaf(t,i,o){let e={day:{settings:this.settings.daily,label:"Daily"},week:{settings:this.settings.weekly,label:"Weekly"},month:{settings:this.settings.monthly,label:"Monthly"},quarter:{settings:this.settings.quarterly,label:"Quarterly"},year:{settings:this.settings.yearly,label:"Yearly"}}[t];if(!e)return;let{settings:r}=e,s=i.format(r.nameFormat)+".md",d=r.folder?`${r.folder}/${s}`:s,n=this.app.vault.getFileByPath(d);if(!n)try{let l=r.templateFile+".md",c=this.app.vault.getFileByPath(l);if(c){let h=await this.app.vault.read(c);n=await this.app.vault.create(d,h)}else{let h=`---
|
||||
type: ${r.typeProperty}
|
||||
`;d=await this.app.vault.create(s,c)}}catch(n){new y.Notice(`Failed to create ${a.label.toLowerCase()} note: ${n.message}`);return}new y.Notice(`Created ${a.label.toLowerCase()} note: ${l}`)}d&&await this.app.workspace.getLeaf(!1).openFile(d)}async openPeriodNoteInLeaf(t,i,o){let e={day:{settings:this.settings.daily,label:"Daily"},week:{settings:this.settings.weekly,label:"Weekly"},month:{settings:this.settings.monthly,label:"Monthly"},quarter:{settings:this.settings.quarterly,label:"Quarterly"},year:{settings:this.settings.yearly,label:"Yearly"}}[t];if(!e)return;let{settings:l}=e,s=i.format(l.nameFormat)+".md",d=l.folder?`${l.folder}/${s}`:s,n=this.app.vault.getFileByPath(d);if(!n)try{let r=l.templateFile+".md",c=this.app.vault.getFileByPath(r);if(c){let h=await this.app.vault.read(c);n=await this.app.vault.create(d,h)}else{let h=`---
|
||||
type: ${l.typeProperty}
|
||||
date: ${i.format("YYYY-MM-DD")}
|
||||
---
|
||||
|
||||
`;n=await this.app.vault.create(d,h)}}catch(l){new f.Notice(`Failed to create ${e.label.toLowerCase()} note: ${l.message}`);return}n&&await o.openFile(n)}detectPeriodType(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?{period:"day",date:(0,f.moment)(t,"YYYY-MM-DD")}:/^\d{4}-W\d{2}$/.test(t)?{period:"week",date:(0,f.moment)(t,"GGGG-[W]WW")}:/^\d{4}-\d{2}$/.test(t)?{period:"month",date:(0,f.moment)(t,"YYYY-MM")}:/^\d{4}-Q[1-4]$/.test(t)?{period:"quarter",date:(0,f.moment)(t,"YYYY-[Q]Q")}:/^\d{4}$/.test(t)?{period:"year",date:(0,f.moment)(t,"YYYY")}:null}async navigatePeriodNote(t){let i=this.app.workspace.getActiveFile();if(!i){new f.Notice("No active file");return}let o=this.detectPeriodType(i.basename);if(!o){new f.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:a,date:e}=o;if(!e.isValid()){new f.Notice(`Could not parse date from filename: ${i.basename}`);return}let r=t==="next"?1:-1,s=a==="quarter"?e.clone().add(r*3,"months"):e.clone().add(r,`${a}s`);await this.openPeriodNote(a,s)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(C);for(let i of t)i.view instanceof A&&i.view.redraw()}async getNotesForDate(t){return this.app.vault.getFiles().filter(i=>i.extension==="md"&&i.basename===t)}async hasNoteForDate(t){return this.app.vault.getFiles().some(i=>i.extension==="md"&&i.basename===t)}};
|
||||
`;n=await this.app.vault.create(d,h)}}catch(r){new y.Notice(`Failed to create ${e.label.toLowerCase()} note: ${r.message}`);return}n&&await o.openFile(n)}detectPeriodType(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?{period:"day",date:(0,y.moment)(t,"YYYY-MM-DD")}:/^\d{4}-W\d{2}$/.test(t)?{period:"week",date:(0,y.moment)(t,"GGGG-[W]WW")}:/^\d{4}-\d{2}$/.test(t)?{period:"month",date:(0,y.moment)(t,"YYYY-MM")}:/^\d{4}-Q[1-4]$/.test(t)?{period:"quarter",date:(0,y.moment)(t,"YYYY-[Q]Q")}:/^\d{4}$/.test(t)?{period:"year",date:(0,y.moment)(t,"YYYY")}:null}async navigatePeriodNote(t){let i=this.app.workspace.getActiveFile();if(!i){new y.Notice("No active file");return}let o=this.detectPeriodType(i.basename);if(!o){new y.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:a,date:e}=o;if(!e.isValid()){new y.Notice(`Could not parse date from filename: ${i.basename}`);return}let l=t==="next"?1:-1,s=a==="quarter"?e.clone().add(l*3,"months"):e.clone().add(l,`${a}s`);await this.openPeriodNote(a,s)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(C);for(let i of t)i.view instanceof A&&i.view.redraw()}async getNotesForDate(t){return this.app.vault.getFiles().filter(i=>i.extension==="md"&&i.basename===t)}async hasNoteForDate(t){return this.app.vault.getFiles().some(i=>i.extension==="md"&&i.basename===t)}};
|
||||
@@ -604,7 +604,7 @@ export class WaypointView extends ItemView {
|
||||
rowEl.addClass('waypoint-bm-dragging');
|
||||
});
|
||||
|
||||
const canAcceptChildren = isGroup || (item.children && item.children.length > 0);
|
||||
const canAcceptChildren = true; // all file/group bookmarks can accept drops
|
||||
|
||||
rowEl.addEventListener('dragend', () => {
|
||||
this.dragId = null;
|
||||
@@ -646,7 +646,11 @@ export class WaypointView extends ItemView {
|
||||
|
||||
const dropInto = (rowEl as any).__dropInto;
|
||||
if (dropInto && canAcceptChildren) {
|
||||
if (isGroup) {
|
||||
this.moveBookmarkToGroup(draggedId, item.id);
|
||||
} else {
|
||||
this.createParentNoteAndMove(draggedId, item.id);
|
||||
}
|
||||
} else {
|
||||
const dropAbove = (rowEl as any).__dropAbove;
|
||||
this.moveBookmarkToPosition(draggedId, item.id, dropAbove);
|
||||
@@ -1001,6 +1005,64 @@ export class WaypointView extends ItemView {
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new parent note group at the target's position,
|
||||
* containing both the target and the dragged item.
|
||||
*/
|
||||
private createParentNoteAndMove(draggedId: string, targetId: string): void {
|
||||
const removeById = (items: BookmarkItem[]): BookmarkItem | null => {
|
||||
const idx = items.findIndex(i => i.id === draggedId);
|
||||
if (idx >= 0) {
|
||||
const [removed] = items.splice(idx, 1);
|
||||
return removed;
|
||||
}
|
||||
for (const child of items) {
|
||||
if (child.children) {
|
||||
const found = removeById(child.children);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const dragged = removeById(this.plugin.waypointData.bookmarks);
|
||||
if (!dragged) return;
|
||||
|
||||
// Find the target in its parent array
|
||||
const findTarget = (items: BookmarkItem[]): { parent: BookmarkItem[]; idx: number } | null => {
|
||||
const idx = items.findIndex(i => i.id === targetId);
|
||||
if (idx >= 0) return { parent: items, idx };
|
||||
for (const child of items) {
|
||||
if (child.children) {
|
||||
const result = findTarget(child.children);
|
||||
if (result) return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const targetInfo = findTarget(this.plugin.waypointData.bookmarks);
|
||||
if (!targetInfo) return;
|
||||
|
||||
const target = targetInfo.parent[targetInfo.idx];
|
||||
const newGroup: BookmarkItem = {
|
||||
id: `bm-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
||||
type: 'group',
|
||||
label: target.label,
|
||||
filePath: target.filePath || '',
|
||||
icon: '',
|
||||
children: [{ ...target, indent: 1 }, { ...dragged, indent: 1 }],
|
||||
collapsed: false,
|
||||
indent: target.indent,
|
||||
};
|
||||
|
||||
// Replace target with the new group
|
||||
targetInfo.parent.splice(targetInfo.idx, 1, newGroup);
|
||||
|
||||
this.plugin.saveWaypointData();
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
private moveBookmarkToPosition(draggedId: string, targetId: string, before: boolean): void {
|
||||
// Find and remove the dragged item from wherever it is
|
||||
const removeById = (items: BookmarkItem[]): { item: BookmarkItem | null; parent: BookmarkItem[] } => {
|
||||
|
||||
+1
-3
@@ -159,9 +159,7 @@
|
||||
border-radius: 6px;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.waypoint-calendar .waypoint-day:hover {
|
||||
|
||||
Reference in new issue
Block a user