obsidian-media-db-sync/src/settings/suggesters/FileSuggest.ts
ltctceplrm f8b6ae8761 Fix checkbox state not updating + ran prettier
Forgot a comma and to load back the wikilink with new properties
2025-12-09 21:34:00 +01:00

17 lines
589 B
TypeScript

import { AbstractInputSuggest, TFile } from 'obsidian';
export class FileSuggest extends AbstractInputSuggest<TFile> {
protected getSuggestions(query: string): TFile[] | Promise<TFile[]> {
const lowerCaseInputStr = query.toLowerCase();
// we do two filters because otherwise TS type inference does convert the array to TFile[]
return this.app.vault
.getAllLoadedFiles()
.filter(file => file instanceof TFile)
.filter(file => file.path.toLowerCase().contains(lowerCaseInputStr));
}
renderSuggestion(value: TFile, el: HTMLElement): void {
el.setText(value.path);
}
}