mirror of
https://github.com/rasmusachr/PDF2Images.git
synced 2026-07-22 11:10:24 +00:00
26 lines
No EOL
798 B
TypeScript
26 lines
No EOL
798 B
TypeScript
import { App, AbstractInputSuggest, TFolder } from 'obsidian';
|
|
|
|
export class FolderSuggest extends AbstractInputSuggest<TFolder> {
|
|
private inputEl: HTMLInputElement;
|
|
|
|
constructor(app: App, inputEl: HTMLInputElement) {
|
|
super(app, inputEl);
|
|
this.inputEl = inputEl;
|
|
}
|
|
|
|
getSuggestions(query: string): TFolder[] {
|
|
const folders = this.app.vault.getAllFolders();
|
|
const lower = query.toLowerCase();
|
|
return folders.filter(f => f.path.toLowerCase().includes(lower));
|
|
}
|
|
|
|
renderSuggestion(folder: TFolder, el: HTMLElement): void {
|
|
el.setText(folder.path);
|
|
}
|
|
|
|
selectSuggestion(folder: TFolder): void {
|
|
this.inputEl.value = folder.path;
|
|
this.inputEl.trigger('input'); // fires onChange
|
|
this.close();
|
|
}
|
|
} |