-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Update folder suggester to use new Obsidian API
- Loading branch information
Showing
5 changed files
with
29 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { AbstractInputSuggest, TAbstractFile, TFolder } from "obsidian"; | ||
|
||
export class FolderSuggest extends AbstractInputSuggest<TFolder> { | ||
protected getSuggestions(query: string): TFolder[] | Promise<TFolder[]> { | ||
const abstractFiles = this.app.vault.getAllLoadedFiles(); | ||
const folders: TFolder[] = []; | ||
const lowerCaseInputStr = query.toLowerCase(); | ||
|
||
abstractFiles.forEach((folder: TAbstractFile) => { | ||
if ( | ||
folder instanceof TFolder && | ||
folder.path.toLowerCase().contains(lowerCaseInputStr) | ||
) { | ||
folders.push(folder); | ||
} | ||
}); | ||
|
||
return folders; | ||
} | ||
renderSuggestion(value: TFolder, el: HTMLElement): void { | ||
el.setText(value.path); | ||
} | ||
selectSuggestion(value: TFolder, evt: MouseEvent | KeyboardEvent): void { | ||
this.setValue(value.path); | ||
this.close(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.