refactor: simplify bookmark menus — visible ⋯ button, flat context menus
Header: - Replace hidden right-click with visible ⋯ button (more-horizontal icon) - Menu: Add current file / Add as parent note / New group / separator / Add spacer File bookmark right-click (5 items, flat): Open in new tab / Rename / Change icon / Remove Group/parent note right-click (7 items max, flat): Open in new tab (only if linked) / Rename / Change icon / Expand|Collapse / Add child bookmark / Add child note / New sub-group / Remove Separator/Spacer right-click (1 item): Remove Removed dead code: insertAdjacent, collectGroups, collectDescendantIds, moveBookmarkToGroup — all moving is now drag-and-drop only
This commit is contained in:
1 parent
a692dc9a34
commit
2e8ac7047f
4 files changed
+93
-151
No files matched your search
@@ -2,15 +2,15 @@
|
|||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var U=(v,p)=>{for(var a in p)$(v,a,{get:p[a],enumerable:!0})},K=(v,p,a,t)=>{if(p&&typeof p=="object"||typeof p=="function")for(let n of H(p))!_.call(v,n)&&n!==a&&$(v,n,{get:()=>p[n],enumerable:!(t=z(p,n))||t.enumerable});return v};var X=v=>K($({},"__esModule",{value:!0}),v);var ee={};U(ee,{default:()=>R});module.exports=X(ee);var u=require("obsidian");var j={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[]}};var g=require("obsidian"),W=class extends g.PluginSettingTab{constructor(p,a,t,n){super(p,a),this.plugin=a,this.settings=t,this.onSettingsChange=n}display(){let{containerEl:p}=this;p.empty(),new g.Setting(p).setHeading().setName("Calendar"),new g.Setting(p).setName("First day of week").setDesc("Which day the calendar week starts on.").addDropdown(n=>{n.addOption("0","Sunday").addOption("1","Monday").setValue(String(this.settings.calendar.firstDayOfWeek)).onChange(s=>{this.settings.calendar.firstDayOfWeek=parseInt(s,10),this.saveAndRefresh()})}),new g.Setting(p).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(n=>{n.setValue(this.settings.calendar.showNoteIndicators).onChange(s=>{this.settings.calendar.showNoteIndicators=s,this.saveAndRefresh()})}),new g.Setting(p).setHeading().setName("Periodic Note Paths"),this.addPeriodNoteSettings("Daily",this.settings.daily),this.addPeriodNoteSettings("Weekly",this.settings.weekly),this.addPeriodNoteSettings("Monthly",this.settings.monthly),this.addPeriodNoteSettings("Quarterly",this.settings.quarterly),this.addPeriodNoteSettings("Yearly",this.settings.yearly),new g.Setting(p).setHeading().setName("Recent Files"),new g.Setting(p).setName("Max items").setDesc("Maximum number of recent files to track.").addText(n=>{n.inputEl.setAttr("type","number"),n.inputEl.setAttr("placeholder","50"),n.setValue(String(this.settings.recentFiles.maxItems)),n.inputEl.onblur=()=>{let s=parseInt(n.getValue(),10);!isNaN(s)&&s>0&&(this.settings.recentFiles.maxItems=s,this.saveAndRefresh())}}),new g.Setting(p).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(n=>{n.addOption("file-open","File opened").addOption("file-edit","File changed").setValue(this.settings.recentFiles.updateOn).onChange(s=>{this.settings.recentFiles.updateOn=s,this.saveAndRefresh()})});let a=new DocumentFragment;a.appendText("Regex patterns for paths to exclude. One per line."),new g.Setting(p).setName("Omitted paths").setDesc(a).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`^archives/
|
var $=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var U=(v,p)=>{for(var t in p)$(v,t,{get:p[t],enumerable:!0})},X=(v,p,t,a)=>{if(p&&typeof p=="object"||typeof p=="function")for(let i of H(p))!_.call(v,i)&&i!==t&&$(v,i,{get:()=>p[i],enumerable:!(a=z(p,i))||a.enumerable});return v};var K=v=>X($({},"__esModule",{value:!0}),v);var ee={};U(ee,{default:()=>R});module.exports=K(ee);var u=require("obsidian");var Q={calendar:{firstDayOfWeek:1,showNoteIndicators:!0},daily:{folder:"periodic/daily",templateFile:"Templates/Daily note",nameFormat:"YYYY-MM-DD",typeProperty:"daily-note"},weekly:{folder:"periodic/weekly",templateFile:"Templates/Weekly note",nameFormat:"GGGG-[W]WW",typeProperty:"weekly-note"},monthly:{folder:"periodic/monthly",templateFile:"Templates/Monthly note",nameFormat:"YYYY-MM",typeProperty:"monthly-note"},quarterly:{folder:"periodic/quarterly",templateFile:"Templates/Quarterly note",nameFormat:"YYYY-[Q]Q",typeProperty:"quarterly-note"},yearly:{folder:"periodic/yearly",templateFile:"Templates/Yearly note",nameFormat:"YYYY",typeProperty:"yearly-note"},recentFiles:{maxItems:50,updateOn:"file-open",omittedPaths:[],omittedTags:[]}};var g=require("obsidian"),W=class extends g.PluginSettingTab{constructor(p,t,a,i){super(p,t),this.plugin=t,this.settings=a,this.onSettingsChange=i}display(){let{containerEl:p}=this;p.empty(),new g.Setting(p).setHeading().setName("Calendar"),new g.Setting(p).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(n=>{this.settings.calendar.firstDayOfWeek=parseInt(n,10),this.saveAndRefresh()})}),new g.Setting(p).setName("Show note indicators").setDesc("Show a dot on days that have existing notes.").addToggle(i=>{i.setValue(this.settings.calendar.showNoteIndicators).onChange(n=>{this.settings.calendar.showNoteIndicators=n,this.saveAndRefresh()})}),new g.Setting(p).setHeading().setName("Periodic Note Paths"),this.addPeriodNoteSettings("Daily",this.settings.daily),this.addPeriodNoteSettings("Weekly",this.settings.weekly),this.addPeriodNoteSettings("Monthly",this.settings.monthly),this.addPeriodNoteSettings("Quarterly",this.settings.quarterly),this.addPeriodNoteSettings("Yearly",this.settings.yearly),new g.Setting(p).setHeading().setName("Recent Files"),new g.Setting(p).setName("Max items").setDesc("Maximum number of recent files to track.").addText(i=>{i.inputEl.setAttr("type","number"),i.inputEl.setAttr("placeholder","50"),i.setValue(String(this.settings.recentFiles.maxItems)),i.inputEl.onblur=()=>{let n=parseInt(i.getValue(),10);!isNaN(n)&&n>0&&(this.settings.recentFiles.maxItems=n,this.saveAndRefresh())}}),new g.Setting(p).setName("Update on").setDesc("When to add a file to the recent list.").addDropdown(i=>{i.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 t=new DocumentFragment;t.appendText("Regex patterns for paths to exclude. One per line."),new g.Setting(p).setName("Omitted paths").setDesc(t).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`^archives/
|
||||||
\\.png$`),n.setValue(this.settings.recentFiles.omittedPaths.join(`
|
\\.png$`),i.setValue(this.settings.recentFiles.omittedPaths.join(`
|
||||||
`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=n.getValue().split(`
|
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedPaths=i.getValue().split(`
|
||||||
`).filter(s=>s.trim()),this.saveAndRefresh()}});let t=new DocumentFragment;t.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new g.Setting(p).setName("Omitted tags").setDesc(t).addTextArea(n=>{n.inputEl.setAttr("rows",4),n.setPlaceholder(`ignore
|
`).filter(n=>n.trim()),this.saveAndRefresh()}});let a=new DocumentFragment;a.appendText("Regex patterns for frontmatter tags to exclude. One per line."),new g.Setting(p).setName("Omitted tags").setDesc(a).addTextArea(i=>{i.inputEl.setAttr("rows",4),i.setPlaceholder(`ignore
|
||||||
archive`),n.setValue(this.settings.recentFiles.omittedTags.join(`
|
archive`),i.setValue(this.settings.recentFiles.omittedTags.join(`
|
||||||
`)),n.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=n.getValue().split(`
|
`)),i.inputEl.onblur=()=>{this.settings.recentFiles.omittedTags=i.getValue().split(`
|
||||||
`).filter(s=>s.trim()),this.saveAndRefresh()}})}addPeriodNoteSettings(p,a){new g.Setting(this.containerEl).setHeading().setName(p),new g.Setting(this.containerEl).setName("Folder").setDesc(`Folder path for ${p.toLowerCase()} notes.`).addText(t=>{t.setPlaceholder("periodic/daily"),t.setValue(a.folder),t.onChange(n=>{a.folder=n,this.saveAndRefresh()})}),new g.Setting(this.containerEl).setName("Name format").setDesc(`Date format for ${p.toLowerCase()} note filenames (moment.js format).`).addText(t=>{t.setPlaceholder("yyyy-MM-dd"),t.setValue(a.nameFormat),t.onChange(n=>{a.nameFormat=n,this.saveAndRefresh()})}),new g.Setting(this.containerEl).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(t=>{t.setPlaceholder("Templates/Daily note"),t.setValue(a.templateFile),t.onChange(n=>{a.templateFile=n,this.saveAndRefresh()})}),new g.Setting(this.containerEl).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(t=>{t.setPlaceholder("daily-note"),t.setValue(a.typeProperty),t.onChange(n=>{a.typeProperty=n,this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveData(this.settings),this.onSettingsChange()}};var h=require("obsidian");var T=require("obsidian");function Q(v,p,a){let t=(0,T.moment)({year:v,month:p,day:1}),n=(0,T.moment)(t).endOf("month"),s=(0,T.moment)(t).subtract((t.day()-a+7)%7,"days"),e=(0,T.moment)().startOf("day"),r=[],i=(0,T.moment)(s);for(;i.isBefore(n)||i.month()===p;){let o=[];for(let l=0;l<7;l++)o.push({date:(0,T.moment)(i),dayOfMonth:i.date(),isToday:i.isSame(e,"day"),isCurrentMonth:i.month()===p,isoWeekNumber:i.isoWeek()}),i.add(1,"day");if(r.push({weekNumber:o[0].isoWeekNumber,days:o}),r.length>=6)break}return r}var I="waypoint-view",Y=class extends h.ItemView{constructor(a,t){super(a);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.plugin=t}getViewType(){return I}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let a=this.contentEl.createDiv({cls:"waypoint-section"});a.createDiv({cls:"waypoint-section-header",text:"Calendar"});let t=a.createDiv({cls:"waypoint-calendar"}),n=(0,h.moment)(),s=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=t.createDiv({cls:"waypoint-calendar-top"}),r=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),i=s.format("[Q]Q");r.createSpan({cls:"waypoint-clickable",text:i}).addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",s)});let l=s.format("MMMM");r.createSpan({cls:"waypoint-clickable",text:l}).addEventListener("click",()=>{this.plugin.openPeriodNote("month",s)});let d=s.format("YYYY");r.createSpan({cls:"waypoint-clickable",text:d}).addEventListener("click",()=>{this.plugin.openPeriodNote("year",s)});let k=e.createDiv({cls:"waypoint-calendar-today-group"}),x=k.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(x,"chevron-left"),x.addEventListener("click",()=>this.navigateMonth(-1)),k.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,h.moment)().month(),this.currentDisplayYear=(0,h.moment)().year(),this.redraw()});let M=k.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(M,"chevron-right"),M.addEventListener("click",()=>this.navigateMonth(1));let P=t.createEl("table"),E=P.createEl("thead").createEl("tr");E.createEl("th",{text:""});let f=["sun","mon","tue","wed","thu","fri","sat"],B=this.plugin.settings.calendar.firstDayOfWeek;for(let y=0;y<7;y++){let L=(B+y)%7;E.createEl("th",{text:f[L]})}let w=P.createEl("tbody"),b=Q(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let y of b){let L=w.createEl("tr"),N=L.createEl("td",{cls:"waypoint-weeknum"});N.setText(String(y.weekNumber)),N.addEventListener("click",()=>{let D=y.days[0].date;this.plugin.openPeriodNote("week",D)});for(let D of y.days){let C=L.createEl("td",{cls:"waypoint-day"});if(C.setText(String(D.dayOfMonth)),D.isCurrentMonth||C.addClass("other-month"),D.isToday&&C.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let O=D.date.format("YYYY-MM-DD");this.plugin.app.vault.getFiles().some(V=>V.extension==="md"&&V.basename===O)&&C.addClass("has-note")}C.addEventListener("click",()=>{this.plugin.openPeriodNote("day",D.date)})}}}navigateMonth(a){let t=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(a,"month");this.currentDisplayMonth=t.month(),this.currentDisplayYear=t.year(),this.redraw()}renderRecentFiles(){let a=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(a.createDiv({cls:"waypoint-section-header",text:"Recent Files"}),this.plugin.recentFiles.length===0){
Line truncated
|
`).filter(n=>n.trim()),this.saveAndRefresh()}})}addPeriodNoteSettings(p,t){new g.Setting(this.containerEl).setHeading().setName(p),new g.Setting(this.containerEl).setName("Folder").setDesc(`Folder path for ${p.toLowerCase()} notes.`).addText(a=>{a.setPlaceholder("periodic/daily"),a.setValue(t.folder),a.onChange(i=>{t.folder=i,this.saveAndRefresh()})}),new g.Setting(this.containerEl).setName("Name format").setDesc(`Date format for ${p.toLowerCase()} note filenames (moment.js format).`).addText(a=>{a.setPlaceholder("yyyy-MM-dd"),a.setValue(t.nameFormat),a.onChange(i=>{t.nameFormat=i,this.saveAndRefresh()})}),new g.Setting(this.containerEl).setName("Template file").setDesc("Path to the template file (without .md extension).").addText(a=>{a.setPlaceholder("Templates/Daily note"),a.setValue(t.templateFile),a.onChange(i=>{t.templateFile=i,this.saveAndRefresh()})}),new g.Setting(this.containerEl).setName("Type property").setDesc("Value for the 'type' frontmatter property.").addText(a=>{a.setPlaceholder("daily-note"),a.setValue(t.typeProperty),a.onChange(i=>{t.typeProperty=i,this.saveAndRefresh()})})}async saveAndRefresh(){await this.plugin.saveData(this.settings),this.onSettingsChange()}};var h=require("obsidian");var F=require("obsidian");function j(v,p,t){let a=(0,F.moment)({year:v,month:p,day:1}),i=(0,F.moment)(a).endOf("month"),n=(0,F.moment)(a).subtract((a.day()-t+7)%7,"days"),e=(0,F.moment)().startOf("day"),r=[],s=(0,F.moment)(n);for(;s.isBefore(i)||s.month()===p;){let o=[];for(let l=0;l<7;l++)o.push({date:(0,F.moment)(s),dayOfMonth:s.date(),isToday:s.isSame(e,"day"),isCurrentMonth:s.month()===p,isoWeekNumber:s.isoWeek()}),s.add(1,"day");if(r.push({weekNumber:o[0].isoWeekNumber,days:o}),r.length>=6)break}return r}var E="waypoint-view",Y=class extends h.ItemView{constructor(t,a){super(t);this.redraw=()=>{this.contentEl.empty(),this.contentEl.addClass("waypoint-view"),this.renderFavorites(),this.renderRecentFiles(),this.renderCalendar()};this.currentDisplayMonth=(0,h.moment)().month();this.currentDisplayYear=(0,h.moment)().year();this.dragId=null;this.plugin=a}getViewType(){return E}getDisplayText(){return"Waypoint"}getIcon(){return"compass"}async onOpen(){this.redraw()}async onClose(){}renderCalendar(){let t=this.contentEl.createDiv({cls:"waypoint-section"});t.createDiv({cls:"waypoint-section-header",text:"Calendar"});let a=t.createDiv({cls:"waypoint-calendar"}),i=(0,h.moment)(),n=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth,day:1}),e=a.createDiv({cls:"waypoint-calendar-top"}),r=e.createDiv({cls:"waypoint-calendar-breadcrumb"}),s=n.format("[Q]Q");r.createSpan({cls:"waypoint-clickable",text:s}).addEventListener("click",()=>{this.plugin.openPeriodNote("quarter",n)});let l=n.format("MMMM");r.createSpan({cls:"waypoint-clickable",text:l}).addEventListener("click",()=>{this.plugin.openPeriodNote("month",n)});let d=n.format("YYYY");r.createSpan({cls:"waypoint-clickable",text:d}).addEventListener("click",()=>{this.plugin.openPeriodNote("year",n)});let w=e.createDiv({cls:"waypoint-calendar-today-group"}),x=w.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(x,"chevron-left"),x.addEventListener("click",()=>this.navigateMonth(-1)),w.createEl("button",{cls:"waypoint-calendar-today-btn",text:"Today"}).addEventListener("click",()=>{this.currentDisplayMonth=(0,h.moment)().month(),this.currentDisplayYear=(0,h.moment)().year(),this.redraw()});let L=w.createEl("button",{cls:"waypoint-calendar-nav-btn"});(0,h.setIcon)(L,"chevron-right"),L.addEventListener("click",()=>this.navigateMonth(1));let P=a.createEl("table"),I=P.createEl("thead").createEl("tr");I.createEl("th",{text:""});let f=["sun","mon","tue","wed","thu","fri","sat"],N=this.plugin.settings.calendar.firstDayOfWeek;for(let y=0;y<7;y++){let M=(N+y)%7;I.createEl("th",{text:f[M]})}let k=P.createEl("tbody"),b=j(this.currentDisplayYear,this.currentDisplayMonth,this.plugin.settings.calendar.firstDayOfWeek);for(let y of b){let M=k.createEl("tr"),B=M.createEl("td",{cls:"waypoint-weeknum"});B.setText(String(y.weekNumber)),B.addEventListener("click",()=>{let D=y.days[0].date;this.plugin.openPeriodNote("week",D)});for(let D of y.days){let C=M.createEl("td",{cls:"waypoint-day"});if(C.setText(String(D.dayOfMonth)),D.isCurrentMonth||C.addClass("other-month"),D.isToday&&C.addClass("today"),this.plugin.settings.calendar.showNoteIndicators){let O=D.date.format("YYYY-MM-DD");this.plugin.app.vault.getFiles().some(G=>G.extension==="md"&&G.basename===O)&&C.addClass("has-note")}C.addEventListener("click",()=>{this.plugin.openPeriodNote("day",D.date)})}}}navigateMonth(t){let a=(0,h.moment)({year:this.currentDisplayYear,month:this.currentDisplayMonth}).add(t,"month");this.currentDisplayMonth=a.month(),this.currentDisplayYear=a.year(),this.redraw()}renderRecentFiles(){let t=this.contentEl.createDiv({cls:"waypoint-section waypoint-recent-files"});if(t.createDiv({cls:"waypoint-section-header",text:"Recent Files"}),this.plugin.recentFiles.length===0){
Line truncated
|
||||||
type: ${e.typeProperty}
|
type: ${e.typeProperty}
|
||||||
date: ${t.format("YYYY-MM-DD")}
|
date: ${a.format("YYYY-MM-DD")}
|
||||||
---
|
---
|
||||||
|
|
||||||
`;o=await this.app.vault.create(i,d)}}catch(l){new u.Notice(`Failed to create ${s.label.toLowerCase()} note: ${l.message}`);return}new u.Notice(`Created ${s.label.toLowerCase()} note: ${r}`)}o&&await this.app.workspace.getLeaf(!1).openFile(o)}detectPeriodType(a){return/^\d{4}-\d{2}-\d{2}$/.test(a)?{period:"day",date:(0,u.moment)(a,"YYYY-MM-DD")}:/^\d{4}-W\d{2}$/.test(a)?{period:"week",date:(0,u.moment)(a,"GGGG-[W]WW")}:/^\d{4}-\d{2}$/.test(a)?{period:"month",date:(0,u.moment)(a,"YYYY-MM")}:/^\d{4}-Q[1-4]$/.test(a)?{period:"quarter",date:(0,u.moment)(a,"YYYY-[Q]Q")}:/^\d{4}$/.test(a)?{period:"year",date:(0,u.moment)(a,"YYYY")}:null}async navigatePeriodNote(a){let t=this.app.workspace.getActiveFile();if(!t){new u.Notice("No active file");return}let n=this.detectPeriodType(t.basename);if(!n){new u.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:s,date:e}=n;if(!e.isValid()){new u.Notice(`Could not parse date from filename: ${t.basename}`);return}let r=a==="next"?1:-1,i=s==="quarter"?e.clone().add(r*3,"months"):e.clone().add(r,`${s}s`);await this.openPeriodNote(s,i)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let a=this.app.workspace.getLeavesOfType(I);for(let t of a)t.view instanceof Y&&t.view.redraw()}async getNotesForDate(a){return this.app.vault.getFiles().filter(t=>t.extension==="md"&&t.basename===a)}async hasNoteForDate(a){return this.app.vault.getFiles().some(t=>t.extension==="md"&&t.basename===a)}};
|
`;o=await this.app.vault.create(s,d)}}catch(l){new u.Notice(`Failed to create ${n.label.toLowerCase()} note: ${l.message}`);return}new u.Notice(`Created ${n.label.toLowerCase()} note: ${r}`)}o&&await this.app.workspace.getLeaf(!1).openFile(o)}detectPeriodType(t){return/^\d{4}-\d{2}-\d{2}$/.test(t)?{period:"day",date:(0,u.moment)(t,"YYYY-MM-DD")}:/^\d{4}-W\d{2}$/.test(t)?{period:"week",date:(0,u.moment)(t,"GGGG-[W]WW")}:/^\d{4}-\d{2}$/.test(t)?{period:"month",date:(0,u.moment)(t,"YYYY-MM")}:/^\d{4}-Q[1-4]$/.test(t)?{period:"quarter",date:(0,u.moment)(t,"YYYY-[Q]Q")}:/^\d{4}$/.test(t)?{period:"year",date:(0,u.moment)(t,"YYYY")}:null}async navigatePeriodNote(t){let a=this.app.workspace.getActiveFile();if(!a){new u.Notice("No active file");return}let i=this.detectPeriodType(a.basename);if(!i){new u.Notice("Current file is not a periodic note (daily/weekly/monthly/quarterly/yearly)");return}let{period:n,date:e}=i;if(!e.isValid()){new u.Notice(`Could not parse date from filename: ${a.basename}`);return}let r=t==="next"?1:-1,s=n==="quarter"?e.clone().add(r*3,"months"):e.clone().add(r,`${n}s`);await this.openPeriodNote(n,s)}redrawAll(){this.broadcastRedraw()}broadcastRedraw(){let t=this.app.workspace.getLeavesOfType(E);for(let a of t)a.view instanceof Y&&a.view.redraw()}async getNotesForDate(t){return this.app.vault.getFiles().filter(a=>a.extension==="md"&&a.basename===t)}async hasNoteForDate(t){return this.app.vault.getFiles().some(a=>a.extension==="md"&&a.basename===t)}};
|
||||||
+60
-142
@@ -303,8 +303,11 @@ export class WaypointView extends ItemView {
|
|||||||
const headerEl = section.createDiv({ cls: 'waypoint-section-header' });
|
const headerEl = section.createDiv({ cls: 'waypoint-section-header' });
|
||||||
headerEl.setText('Waypoint Bookmarks');
|
headerEl.setText('Waypoint Bookmarks');
|
||||||
|
|
||||||
// Right-click on header area → add bookmark / group
|
// ⋯ button — visible add menu
|
||||||
headerEl.addEventListener('contextmenu', (event: MouseEvent) => {
|
const moreBtn = headerEl.createEl('button', { cls: 'waypoint-header-more' });
|
||||||
|
setIcon(moreBtn, 'more-horizontal');
|
||||||
|
setTooltip(moreBtn, 'Add bookmark');
|
||||||
|
moreBtn.addEventListener('click', (event: MouseEvent) => {
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
menu.addItem((item) => {
|
menu.addItem((item) => {
|
||||||
item
|
item
|
||||||
@@ -337,6 +340,7 @@ export class WaypointView extends ItemView {
|
|||||||
this.plugin.addBookmark('', 'New Group', 'group', '');
|
this.plugin.addBookmark('', 'New Group', 'group', '');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
menu.addSeparator();
|
||||||
menu.addItem((item) => {
|
menu.addItem((item) => {
|
||||||
item
|
item
|
||||||
.setTitle('Add separator')
|
.setTitle('Add separator')
|
||||||
@@ -353,7 +357,6 @@ export class WaypointView extends ItemView {
|
|||||||
this.plugin.addBookmark('', '', 'spacer');
|
this.plugin.addBookmark('', '', 'spacer');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -655,6 +658,17 @@ export class WaypointView extends ItemView {
|
|||||||
private showBookmarkContextMenu(event: MouseEvent, item: BookmarkItem): void {
|
private showBookmarkContextMenu(event: MouseEvent, item: BookmarkItem): void {
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
|
|
||||||
|
if (item.type === 'separator' || item.type === 'spacer') {
|
||||||
|
menu.addItem((i) =>
|
||||||
|
i
|
||||||
|
.setTitle('Remove')
|
||||||
|
.setIcon('trash')
|
||||||
|
.onClick(() => this.plugin.removeBookmark(item.id)),
|
||||||
|
);
|
||||||
|
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.type === 'file') {
|
if (item.type === 'file') {
|
||||||
menu.addItem((i) =>
|
menu.addItem((i) =>
|
||||||
i
|
i
|
||||||
@@ -662,80 +676,69 @@ export class WaypointView extends ItemView {
|
|||||||
.setIcon('file-plus')
|
.setIcon('file-plus')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
const tfile = this.app.vault.getFileByPath(item.filePath);
|
const tfile = this.app.vault.getFileByPath(item.filePath);
|
||||||
if (tfile) {
|
if (tfile) this.app.workspace.getLeaf('tab').openFile(tfile);
|
||||||
this.app.workspace.getLeaf('tab').openFile(tfile);
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
}
|
|
||||||
|
|
||||||
if (item.type !== 'separator' && item.type !== 'spacer') {
|
|
||||||
menu.addItem((i) =>
|
menu.addItem((i) =>
|
||||||
i
|
i
|
||||||
.setTitle('Rename')
|
.setTitle('Rename')
|
||||||
.setIcon('pencil')
|
.setIcon('pencil')
|
||||||
.onClick(() => this.promptRename(item)),
|
.onClick(() => this.promptRename(item)),
|
||||||
);
|
);
|
||||||
|
|
||||||
menu.addItem((i) =>
|
menu.addItem((i) =>
|
||||||
i
|
i
|
||||||
.setTitle('Change icon')
|
.setTitle('Change icon')
|
||||||
.setIcon('image')
|
.setIcon('image')
|
||||||
.onClick(() => this.promptIcon(item)),
|
.onClick(() => this.promptIcon(item)),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// ── Move to group options ──
|
|
||||||
const allGroups = this.collectGroups(this.plugin.waypointData.bookmarks);
|
|
||||||
const ownIds = this.collectDescendantIds(item);
|
|
||||||
const availableGroups = allGroups.filter(g => !ownIds.includes(g.id) && g.id !== item.id);
|
|
||||||
|
|
||||||
if ((availableGroups.length > 0 || item.type === 'file' || item.type === 'group') && item.type !== 'separator' && item.type !== 'spacer') {
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
if (availableGroups.length > 0) {
|
menu.addItem((i) =>
|
||||||
for (const group of availableGroups) {
|
i
|
||||||
menu.addItem((mi) =>
|
.setTitle('Remove')
|
||||||
mi
|
.setIcon('trash')
|
||||||
.setTitle(` ${group.label}`)
|
.onClick(() => this.plugin.removeBookmark(item.id)),
|
||||||
.setIcon(group.icon || 'folder')
|
|
||||||
.onClick(() => {
|
|
||||||
this.moveBookmarkToGroup(item.id, group.id);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Add "Root" option for ungrouping
|
|
||||||
menu.addItem((mi) =>
|
|
||||||
mi
|
|
||||||
.setTitle(' (Root)')
|
|
||||||
.setIcon('layout')
|
|
||||||
.onClick(() => {
|
|
||||||
this.moveBookmarkToGroup(item.id, null);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
} else if (item.type === 'group') {
|
||||||
|
if (item.filePath) {
|
||||||
|
menu.addItem((i) =>
|
||||||
|
i
|
||||||
|
.setTitle('Open in new tab')
|
||||||
|
.setIcon('file-plus')
|
||||||
|
.onClick(() => {
|
||||||
|
const tfile = this.app.vault.getFileByPath(item.filePath);
|
||||||
|
if (tfile) this.app.workspace.getLeaf('tab').openFile(tfile);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
menu.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
if (item.type === 'group') {
|
menu.addItem((i) =>
|
||||||
|
i
|
||||||
|
.setTitle('Rename')
|
||||||
|
.setIcon('pencil')
|
||||||
|
.onClick(() => this.promptRename(item)),
|
||||||
|
);
|
||||||
|
menu.addItem((i) =>
|
||||||
|
i
|
||||||
|
.setTitle('Change icon')
|
||||||
|
.setIcon('image')
|
||||||
|
.onClick(() => this.promptIcon(item)),
|
||||||
|
);
|
||||||
menu.addItem((i) =>
|
menu.addItem((i) =>
|
||||||
i
|
i
|
||||||
.setTitle(item.collapsed ? 'Expand' : 'Collapse')
|
.setTitle(item.collapsed ? 'Expand' : 'Collapse')
|
||||||
.setIcon(item.collapsed ? 'chevron-down' : 'chevron-up')
|
.setIcon(item.collapsed ? 'chevron-down' : 'chevron-up')
|
||||||
.onClick(() => {
|
.onClick(() => this.plugin.updateBookmark(item.id, { collapsed: !item.collapsed })),
|
||||||
this.plugin.updateBookmark(item.id, { collapsed: !item.collapsed });
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addItem((i) =>
|
menu.addItem((i) =>
|
||||||
i
|
i
|
||||||
.setTitle('Add bookmark here')
|
.setTitle('Add child bookmark')
|
||||||
.setIcon('file-plus')
|
.setIcon('file-plus')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
const file = this.app.workspace.getActiveFile();
|
const file = this.app.workspace.getActiveFile();
|
||||||
if (!file) {
|
if (!file) { new Notice('No active file'); return; }
|
||||||
new Notice('No active file');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const child: BookmarkItem = {
|
const child: BookmarkItem = {
|
||||||
id: `bm-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
id: `bm-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
||||||
type: 'file',
|
type: 'file',
|
||||||
@@ -754,13 +757,10 @@ export class WaypointView extends ItemView {
|
|||||||
menu.addItem((i) =>
|
menu.addItem((i) =>
|
||||||
i
|
i
|
||||||
.setTitle('Add child note')
|
.setTitle('Add child note')
|
||||||
.setIcon('file-plus')
|
.setIcon('folder-plus')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
const file = this.app.workspace.getActiveFile();
|
const file = this.app.workspace.getActiveFile();
|
||||||
if (!file) {
|
if (!file) { new Notice('No active file'); return; }
|
||||||
new Notice('No active file');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const child: BookmarkItem = {
|
const child: BookmarkItem = {
|
||||||
id: `bm-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
id: `bm-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
||||||
type: 'group',
|
type: 'group',
|
||||||
@@ -796,100 +796,18 @@ export class WaypointView extends ItemView {
|
|||||||
this.redraw();
|
this.redraw();
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
menu.addSeparator();
|
||||||
|
menu.addItem((i) =>
|
||||||
|
i
|
||||||
|
.setTitle('Remove')
|
||||||
|
.setIcon('trash')
|
||||||
|
.onClick(() => this.plugin.removeBookmark(item.id)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.addSeparator();
|
|
||||||
|
|
||||||
// ── Insert separator / spacer ──
|
|
||||||
menu.addItem((i) =>
|
|
||||||
i
|
|
||||||
.setTitle('Insert separator above')
|
|
||||||
.setIcon('separator-vertical')
|
|
||||||
.onClick(() => this.insertAdjacent(item.id, 'separator', 'above')),
|
|
||||||
);
|
|
||||||
menu.addItem((i) =>
|
|
||||||
i
|
|
||||||
.setTitle('Insert separator below')
|
|
||||||
.setIcon('separator-vertical')
|
|
||||||
.onClick(() => this.insertAdjacent(item.id, 'separator', 'below')),
|
|
||||||
);
|
|
||||||
menu.addItem((i) =>
|
|
||||||
i
|
|
||||||
.setTitle('Insert spacer above')
|
|
||||||
.setIcon('space')
|
|
||||||
.onClick(() => this.insertAdjacent(item.id, 'spacer', 'above')),
|
|
||||||
);
|
|
||||||
menu.addItem((i) =>
|
|
||||||
i
|
|
||||||
.setTitle('Insert spacer below')
|
|
||||||
.setIcon('space')
|
|
||||||
.onClick(() => this.insertAdjacent(item.id, 'spacer', 'below')),
|
|
||||||
);
|
|
||||||
|
|
||||||
menu.addSeparator();
|
|
||||||
|
|
||||||
menu.addItem((i) =>
|
|
||||||
i
|
|
||||||
.setTitle('Remove')
|
|
||||||
.setIcon('trash')
|
|
||||||
.onClick(() => {
|
|
||||||
this.plugin.removeBookmark(item.id);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
||||||
}
|
}
|
||||||
|
|
||||||
private insertAdjacent(targetId: string, type: 'separator' | 'spacer', position: 'above' | 'below'): void {
|
|
||||||
const newItem: BookmarkItem = {
|
|
||||||
id: `bm-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
||||||
type,
|
|
||||||
label: '',
|
|
||||||
filePath: '',
|
|
||||||
icon: '',
|
|
||||||
children: [],
|
|
||||||
collapsed: false,
|
|
||||||
indent: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
const insert = (items: BookmarkItem[]): boolean => {
|
|
||||||
const idx = items.findIndex(i => i.id === targetId);
|
|
||||||
if (idx >= 0) {
|
|
||||||
const insertIdx = position === 'above' ? idx : idx + 1;
|
|
||||||
items.splice(insertIdx, 0, newItem);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (const item of items) {
|
|
||||||
if (item.children && insert(item.children)) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
insert(this.plugin.waypointData.bookmarks);
|
|
||||||
this.plugin.saveWaypointData();
|
|
||||||
this.redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private collectGroups(items: BookmarkItem[]): BookmarkItem[] {
|
|
||||||
const groups: BookmarkItem[] = [];
|
|
||||||
for (const item of items) {
|
|
||||||
if (item.type === 'group') {
|
|
||||||
groups.push(item);
|
|
||||||
groups.push(...this.collectGroups(item.children));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
private collectDescendantIds(item: BookmarkItem): string[] {
|
|
||||||
const ids: string[] = [];
|
|
||||||
for (const child of item.children) {
|
|
||||||
ids.push(child.id);
|
|
||||||
ids.push(...this.collectDescendantIds(child));
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
private showDropIndicator(el: HTMLElement, e: MouseEvent): void {
|
private showDropIndicator(el: HTMLElement, e: MouseEvent): void {
|
||||||
// Clear indicator from all siblings first
|
// Clear indicator from all siblings first
|
||||||
const parent = el.parentElement;
|
const parent = el.parentElement;
|
||||||
|
|||||||
+22
@@ -27,6 +27,28 @@
|
|||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px;
|
||||||
border-bottom: 1px solid var(--background-modifier-border);
|
border-bottom: 1px solid var(--background-modifier-border);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypoint-header-more {
|
||||||
|
margin-left: auto;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: var(--cursor);
|
||||||
|
color: var(--text-faint);
|
||||||
|
padding: 2px 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: color 80ms, background 80ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
.waypoint-header-more:hover {
|
||||||
|
color: var(--text-accent);
|
||||||
|
background-color: var(--background-modifier-active-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Calendar ── */
|
/* ── Calendar ── */
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
- [ ] in the bookmarks, i want to have notes that are parents to other notes
|
- [ ] in the bookmarks, i want to have notes that are parents to other notes
|
||||||
- [ ] by default, the bookmark should have no icon
|
- [ ] by default, the bookmark should have no icon
|
||||||
- [ ] the way to search for icons should be improved. on the lucide icon website, the search works by more than only the icon’s title. i want to be able to load all the icon (not by default though)
|
- [ ] the way to search for icons should be improved. on the lucide icon website, the search works by more than only the icon’s title. i want to be able to load all the icon (not by default though)
|
||||||
|
- [ ] add a right click menu on the recent files to make them bookmarks
|
||||||
|
- [ ] improve the drag and drop to have identations and groups
|
||||||
- [ ] calendar
|
- [ ] calendar
|
||||||
- [ ] middle click on a date/week/etc. should open it in a new tab
|
- [ ] middle click on a date/week/etc. should open it in a new tab
|
||||||
- [ ] i want to improve the look of the calendar. more space, a bit more height
|
- [ ] i want to improve the look of the calendar. more space, a bit more height
|
||||||
|
|||||||
Reference in new issue
Block a user