mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix #182
This commit is contained in:
parent
ba4069fe7d
commit
69a1318442
2 changed files with 19 additions and 4 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { TFile, TFolder } from "obsidian";
|
||||
import { FileExplorerWorkspaceLeaf } from "src/globals";
|
||||
import FolderNotesPlugin from "src/main";
|
||||
import { FileExplorerLeaf } from "obsidian-typings";
|
||||
|
||||
export function getFileNameFromPathString(path: string): string {
|
||||
return path.substring(path.lastIndexOf('/') >= 0 ? path.lastIndexOf('/') + 1 : 0);
|
||||
|
|
@ -39,6 +41,12 @@ export function getFileExplorer(plugin: FolderNotesPlugin) {
|
|||
return plugin.app.workspace.getLeavesOfType('file-explorer')[0] as any as FileExplorerWorkspaceLeaf;
|
||||
}
|
||||
|
||||
export function getFileExplorerView() {
|
||||
return this.getFileExplorer().view;
|
||||
export function getFileExplorerView(plugin: FolderNotesPlugin) {
|
||||
return getFileExplorer(plugin).view;
|
||||
}
|
||||
|
||||
export function getFocusedItem(plugin: FolderNotesPlugin) {
|
||||
const fileExplorer = getFileExplorer(plugin) as any as FileExplorerLeaf;
|
||||
const focusedItem = fileExplorer.view.tree.focusedItem
|
||||
return focusedItem;
|
||||
}
|
||||
11
src/main.ts
11
src/main.ts
|
|
@ -5,7 +5,7 @@ import { FileExplorerWorkspaceLeaf } from './globals';
|
|||
import { handleFolderClick } from './events/handleClick';
|
||||
import { addObserver } from './events/MutationObserver';
|
||||
import { handleRename } from './events/handleRename';
|
||||
import { getFolderNote, getFolder } from './functions/folderNoteFunctions';
|
||||
import { getFolderNote, getFolder, openFolderNote } from './functions/folderNoteFunctions';
|
||||
import { handleCreate } from './events/handleCreate';
|
||||
import { FrontMatterTitlePluginHandler } from './events/FrontMatterTitle';
|
||||
import { FolderOverviewSettings } from './folderOverview/ModalSettings';
|
||||
|
|
@ -15,7 +15,8 @@ import './functions/ListComponent';
|
|||
import { handleDelete } from './events/handleDelete';
|
||||
import { addCSSClassToTitleEL, getEl, loadFileClasses } from './functions/styleFunctions';
|
||||
import { getExcludedFolder } from './ExcludeFolders/functions/folderFunctions';
|
||||
import { ClipBoardManager, FileExplorerView, InternalPlugin, InternalPlugins } from 'obsidian-typings'
|
||||
import { ClipBoardManager, FileExplorerView, InternalPlugin } from 'obsidian-typings'
|
||||
import { getFocusedItem } from './functions/utils';
|
||||
export default class FolderNotesPlugin extends Plugin {
|
||||
observer: MutationObserver;
|
||||
settings: FolderNotesSettings;
|
||||
|
|
@ -68,6 +69,12 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
});
|
||||
|
||||
this.registerDomEvent(window, 'keydown', (event: KeyboardEvent) => {
|
||||
if (event.key == 'Enter') {
|
||||
const folderNote = getFolderNote(this, getFocusedItem(this)?.file?.path || '');
|
||||
if (!folderNote) return;
|
||||
openFolderNote(this, folderNote);
|
||||
}
|
||||
|
||||
const hoveredElement = this.hoveredElement;
|
||||
if (this.hoverLinkTriggered) return;
|
||||
if (!hoveredElement) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue