feat: add bookmark from recent files + calendar middle-click
- Recent files right-click now has 'Add to bookmarks' option - Calendar: middle-click on day/week/quarter/month/year opens in new tab - Added openPeriodNoteInLeaf() method for opening period notes in a specific leaf
This commit is contained in:
@@ -84,18 +84,36 @@ export class WaypointView extends ItemView {
|
||||
qEl.addEventListener('click', () => {
|
||||
this.plugin.openPeriodNote('quarter', displayDate);
|
||||
});
|
||||
qEl.addEventListener('mousedown', (event: MouseEvent) => {
|
||||
if (event.button === 1) {
|
||||
event.preventDefault();
|
||||
this.plugin.openPeriodNoteInLeaf('quarter', displayDate, this.app.workspace.getLeaf('tab'));
|
||||
}
|
||||
});
|
||||
|
||||
const mLabel = displayDate.format('MMMM');
|
||||
const mEl = breadcrumb.createSpan({ cls: 'waypoint-clickable', text: mLabel });
|
||||
mEl.addEventListener('click', () => {
|
||||
this.plugin.openPeriodNote('month', displayDate);
|
||||
});
|
||||
mEl.addEventListener('mousedown', (event: MouseEvent) => {
|
||||
if (event.button === 1) {
|
||||
event.preventDefault();
|
||||
this.plugin.openPeriodNoteInLeaf('month', displayDate, this.app.workspace.getLeaf('tab'));
|
||||
}
|
||||
});
|
||||
|
||||
const yLabel = displayDate.format('YYYY');
|
||||
const yEl = breadcrumb.createSpan({ cls: 'waypoint-clickable', text: yLabel });
|
||||
yEl.addEventListener('click', () => {
|
||||
this.plugin.openPeriodNote('year', displayDate);
|
||||
});
|
||||
yEl.addEventListener('mousedown', (event: MouseEvent) => {
|
||||
if (event.button === 1) {
|
||||
event.preventDefault();
|
||||
this.plugin.openPeriodNoteInLeaf('year', displayDate, this.app.workspace.getLeaf('tab'));
|
||||
}
|
||||
});
|
||||
|
||||
// Right: ◀ Today ▶
|
||||
const todayGroup = topRow.createDiv({ cls: 'waypoint-calendar-today-group' });
|
||||
@@ -148,6 +166,13 @@ export class WaypointView extends ItemView {
|
||||
const monday = week.days[0].date;
|
||||
this.plugin.openPeriodNote('week', monday);
|
||||
});
|
||||
wnCell.addEventListener('mousedown', (event: MouseEvent) => {
|
||||
if (event.button === 1) {
|
||||
event.preventDefault();
|
||||
const file = this.app.workspace.getLeaf('tab');
|
||||
this.plugin.openPeriodNoteInLeaf('week', monday, file);
|
||||
}
|
||||
});
|
||||
|
||||
for (const day of week.days) {
|
||||
const cell = row.createEl('td', { cls: 'waypoint-day' });
|
||||
@@ -173,6 +198,13 @@ export class WaypointView extends ItemView {
|
||||
cell.addEventListener('click', () => {
|
||||
this.plugin.openPeriodNote('day', day.date);
|
||||
});
|
||||
cell.addEventListener('mousedown', (event: MouseEvent) => {
|
||||
if (event.button === 1) {
|
||||
event.preventDefault();
|
||||
const file = this.app.workspace.getLeaf('tab');
|
||||
this.plugin.openPeriodNoteInLeaf('day', day.date, file);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,14 +290,23 @@ export class WaypointView extends ItemView {
|
||||
.setIcon('file-plus')
|
||||
.onClick(() => this.focusFile(file, 'tab')),
|
||||
);
|
||||
menu.addItem((item) =>
|
||||
item
|
||||
.setSection('action')
|
||||
.setTitle('Add to bookmarks')
|
||||
.setIcon('bookmark')
|
||||
.onClick(() => {
|
||||
this.plugin.addBookmark(file.path, file.basename, 'file');
|
||||
new Notice(`Bookmarked: ${file.basename}`);
|
||||
}),
|
||||
);
|
||||
const tfile = this.app.vault.getAbstractFileByPath(file.path);
|
||||
if (tfile) {
|
||||
this.app.workspace.trigger('file-menu', menu, tfile, 'link-context-menu');
|
||||
}
|
||||
menu.showAtPosition({ x: event.clientX, y: event.clientY });
|
||||
});
|
||||
|
||||
// Left click
|
||||
// Left click
|
||||
navFileTitle.addEventListener('click', (event: MouseEvent) => {
|
||||
const newLeaf = Keymap.isModEvent(event);
|
||||
this.focusFile(file, newLeaf);
|
||||
|
||||
Reference in New Issue
Block a user