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:
@@ -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) ──
|
||||
|
||||
Reference in New Issue
Block a user