1- import { TFile , TFolder , Plugin , Menu , WorkspaceLeaf , MarkdownView } from 'obsidian' ;
1+ import { TFile , TFolder , Plugin , Menu } from 'obsidian' ;
22import { ExplorerLeaf , ElementsObj , Pairs } from '../types/obsidian' ;
33
44export function newNavTreeStart ( plugin : Plugin ) {
@@ -46,17 +46,13 @@ export function oldNavTreeChange(plugin: Plugin, pairs: Pairs) {
4646 if ( file instanceof TFile ) {
4747 // Create a new Menu object
4848 const menu = new Menu ( ) ;
49- const leaf = getLeafForFile ( plugin , file )
50- // Trigger the 'file-menu' event
51- if ( leaf ) {
5249
53- //@ts -ignore
54- plugin . app . workspace . trigger ( "file-menu" , menu , file , "file-explorer" , leaf ) ;
50+ // Trigger the 'file-menu' event
51+ //@ts -ignore
52+ plugin . app . workspace . trigger ( "file-menu" , menu , file , "file-explorer" ) ;
5553
56- // Show the menu at the mouse position
57- menu . showAtMouseEvent ( e ) ;
58- return
59- }
54+ // Show the menu at the mouse position
55+ menu . showAtMouseEvent ( e ) ;
6056 }
6157 } ) ;
6258 targetInnerEl . style . display = "none"
@@ -123,18 +119,4 @@ export function getElementsObj(plugin: Plugin): ElementsObj | undefined {
123119 } ) ;
124120
125121 return elementsObj . folders . length > 0 ? elementsObj : undefined ;
126- }
127-
128- function getLeafForFile ( plugin : Plugin , file : TFile ) : WorkspaceLeaf | null {
129- const leaves = plugin . app . workspace . getLeavesOfType ( "markdown" ) ;
130-
131- for ( const leaf of leaves ) {
132- const view = leaf . view ;
133-
134- if ( view instanceof MarkdownView && view . file ?. path === file . path ) {
135- return leaf ; // Found the leaf for this file
136- }
137- }
138-
139- return null ; // No matching leaf found
140122}
0 commit comments