From 7d36fa7cb841533f82ba19db9e3715611ba1485c Mon Sep 17 00:00:00 2001 From: TfT Hacker Date: Sun, 22 May 2022 14:10:28 +0200 Subject: [PATCH] Hoverlink support for sidepane --- src/sidepane.ts | 16 +++++++++++++--- todo.txt | 1 - 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/sidepane.ts b/src/sidepane.ts index d2fc0fc..d57934d 100644 --- a/src/sidepane.ts +++ b/src/sidepane.ts @@ -125,7 +125,6 @@ export class SidePaneView extends ItemView { document.querySelectorAll('.snw-sidepane-link').forEach(el => { el.addEventListener('click', (e: PointerEvent) => { e.preventDefault(); - console.log("click",e) const target = e.target as HTMLElement; const filePath = target.getAttribute("data-href"); const LineNu = Number(target.getAttribute("data-line-number")); @@ -141,9 +140,20 @@ export class SidePaneView extends ItemView { this.thePlugin.app.workspace.activeLeaf.view.setEphemeralState({line: LineNu }) }, 500); } - }) + }); + el.addEventListener('mouseover', (e: PointerEvent) => { + const target = e.target as HTMLElement; + const filePath = target.getAttribute("data-href"); + app.workspace.trigger("hover-link", { + event: e, + source: 'source', + hoverParent: document.querySelector(".markdown-preview-view"), + targetEl: null, + linktext: filePath, + }); + }); }); - }, 200); + }, 500); } diff --git a/todo.txt b/todo.txt index 8e5c7a2..5ba52cc 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,5 @@ Enable hover view on links -Shift+click will open link in new pane file rename causes error \ No newline at end of file