feat: middle-click + mod-click on bookmarks opens in new tab

- File bookmarks: middle-click opens in new tab, mod+click opens in new leaf
- Group bookmarks: middle-click opens group's linked file in new tab,
  mod+click opens group's linked file (click still toggles collapse)
This commit is contained in:
2026-06-10 20:16:17 -04:00
parent 99a3ea80ae
commit 4278507ae2
2 changed files with 36 additions and 8 deletions
+4 -4
View File
File diff suppressed because one or more lines are too long
+32 -4
View File
@@ -540,10 +540,27 @@ export class WaypointView extends ItemView {
const labelEl = rowEl.createDiv({ cls: 'waypoint-bm-label', text: item.label });
rowEl.addEventListener('click', () => {
rowEl.addEventListener('click', (event: MouseEvent) => {
// Mod+click opens group's linked file
if (item.filePath && Keymap.isModEvent(event)) {
const tfile = this.app.vault.getFileByPath(item.filePath);
if (tfile) this.app.workspace.getLeaf(false).openFile(tfile);
return;
}
this.plugin.updateBookmark(item.id, { collapsed: !item.collapsed });
});
// Middle click on group header → open group's linked file in new tab
rowEl.addEventListener('mousedown', (event: MouseEvent) => {
if (event.button === 1 && item.filePath) {
event.preventDefault();
const tfile = this.app.vault.getFileByPath(item.filePath);
if (tfile) {
this.app.workspace.getLeaf('tab').openFile(tfile);
}
}
});
const childrenContainer = container.createDiv({
cls: `waypoint-bookmark-children${item.collapsed ? ' collapsed' : ''}`,
});
@@ -559,18 +576,29 @@ export class WaypointView extends ItemView {
const labelEl = rowEl.createDiv({ cls: 'waypoint-bm-label', text: item.label });
setTooltip(rowEl, item.filePath);
rowEl.addEventListener('click', () => {
rowEl.addEventListener('click', (event: MouseEvent) => {
if (item.filePath) {
const tfile = this.app.vault.getFileByPath(item.filePath);
if (tfile) {
const leaf = this.app.workspace.getLeaf(false);
leaf.openFile(tfile);
const newLeaf = Keymap.isModEvent(event);
this.app.workspace.getLeaf(newLeaf as any).openFile(tfile);
} else {
new Notice('File not found');
this.plugin.removeBookmark(item.id);
}
}
});
// Middle click → open in new tab
rowEl.addEventListener('mousedown', (event: MouseEvent) => {
if (event.button === 1 && item.filePath) {
event.preventDefault();
const tfile = this.app.vault.getFileByPath(item.filePath);
if (tfile) {
this.app.workspace.getLeaf('tab').openFile(tfile);
}
}
});
}
// ── Right-click context menu (both types) ──