Support for middle mouse click to open in a new tab

This commit is contained in:
Lost Paul 2024-01-06 18:08:35 +01:00
parent ee1b2c699d
commit cb29a307f0
3 changed files with 6 additions and 2 deletions

View file

@ -1,7 +1,7 @@
{
"id": "folder-notes",
"name": "Folder notes",
"version": "1.7.1",
"version": "1.7.2",
"minAppVersion": "0.15.0",
"description": "Create notes within folders that can be accessed without collapsing the folder, similar to the functionality offered in Notion.",
"author": "Lost Paul",

View file

@ -154,7 +154,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile,
export async function openFolderNote(plugin: FolderNotesPlugin, file: TAbstractFile, evt?: MouseEvent) {
const path = file.path;
if (plugin.app.workspace.getActiveFile()?.path === path) { return; }
if (plugin.app.workspace.getActiveFile()?.path === path && !(Keymap.isModEvent(evt) == 'tab')) { return; }
const leaf = plugin.app.workspace.getLeaf(Keymap.isModEvent(evt) || plugin.settings.openInNewTab);
if (file instanceof TFile) {
await leaf.openFile(file);

View file

@ -53,6 +53,10 @@ export default class FolderNotesPlugin extends Plugin {
.forEach((element: HTMLElement) => {
if (element.onclick) return;
if (Platform.isMobile && this.settings.disableOpenFolderNoteOnClick) return;
// handle middle click
element.addEventListener('auxclick', (event: MouseEvent) => {
handleFolderClick(event, this)
}, { capture: true });
element.onclick = (event: MouseEvent) => handleFolderClick(event, this);
this.registerDomEvent(element, 'pointerover', (event: MouseEvent) => {
this.hoveredElement = element;