Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
turulix committed Apr 30, 2023
1 parent 3676e17 commit a027fde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
npm node_modules
build
src/types
src/types/DataEngine.ts
32 changes: 18 additions & 14 deletions src/modules/FolderNoteModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,38 @@ export class FolderNoteModule {
// FolderNoteModule.showAllIndexFiles()
}

private async onClick(event: MouseEvent) {
private getTargetFromEvent(event: MouseEvent): HTMLElement | null {
if (!(event.target instanceof HTMLElement)) {
return
}
let target = event.target as HTMLElement
const target = event.target
// @ts-ignore - This is a hack to get the active plugins.
const activePlugins: Set = this.app.plugins.enabledPlugins

// Compatibility with https://github.com/ozntel/file-tree-alternative
if (activePlugins.has("file-tree-alternative")) {
if (!target.matches(".oz-folder-name, .oz-folder-block"))
return
if (target.classList.contains("oz-folder-name")) {
target = target.parentElement
return target.parentElement.parentElement.parentElement
}
if (target.classList.contains("oz-folder-block")) {
target = target.parentElement.parentElement
}
} else {
// We only want to handle clicks on the folders in the file explorer
if (!target.matches(".nav-folder-title, .nav-folder-title-content"))
return
// If the user clicked on the content of the folder, we need to get the parent element
if (target.classList.contains("nav-folder-title-content")) {
target = event.target.parentElement
return target.parentElement.parentElement
}
}

// We only want to handle clicks on the folders in the file explorer
if (target.classList.contains("nav-folder-title"))
return target
// If the user clicked on the content of the folder, we need to get the parent element
if (target.classList.contains("nav-folder-title-content")) {
return target.parentElement
}
return null
}

private async onClick(event: MouseEvent) {
const target = this.getTargetFromEvent(event)
if (target == null)
return

// Get the path of the clicked folder
const dataPathAttribute = target.attributes.getNamedItem("data-path")
Expand Down
1 change: 0 additions & 1 deletion src/types/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function isIndexFile(path: string) {
}

export function isExcludedPath(path: string) {
debugger
const pathParts = path.split(/\//)
for (const excludedFolder of FolderIndexPlugin.PLUGIN.settings.excludeFolders) {
if (excludedFolder == "")
Expand Down

0 comments on commit a027fde

Please sign in to comment.