import { AbstractInputSuggest, App, TFolder } from 'obsidian'; export default class PathSuggest extends AbstractInputSuggest { private textInputEl: HTMLInputElement | HTMLDivElement; constructor(app: App, textInputEl: HTMLInputElement | HTMLDivElement) { super(app, textInputEl); this.textInputEl = textInputEl; } async getSuggestions(query: string): Promise { query ||= '/'; const folder = this.app.vault.getFolderByPath(query); if (!folder) return []; return folder.children .filter((c) => c instanceof TFolder) .map((f) => f.path); } renderSuggestion(item: string, el: HTMLElement): void { el.setText(item); } selectSuggestion(item: string, _: MouseEvent | KeyboardEvent): void { this.setValue(item); this.textInputEl.dispatchEvent(new Event('input')); } }