Finished addressing review.

This commit is contained in:
Caleb Campbell
2025-10-09 12:32:46 +11:00
parent 9911e0ce8a
commit 6c83e97297
4 changed files with 80 additions and 29 deletions

30
src/version-suggest.ts Normal file
View File

@@ -0,0 +1,30 @@
import { AbstractInputSuggest, App, TFolder } from "obsidian";
import { LocalBibleRefSettings } from "./settings";
export class VersionSuggest extends AbstractInputSuggest<string> {
private settings: LocalBibleRefSettings;
private textInputEl: HTMLInputElement | HTMLDivElement;
constructor(app: App, textInputEl: HTMLInputElement | HTMLDivElement, settings: LocalBibleRefSettings) {
super(app, textInputEl);
this.textInputEl = textInputEl;
this.settings = settings;
}
async getSuggestions(): Promise<string[]> {
const folder = this.app.vault.getFolderByPath(this.settings.biblesPath);
if (!folder) return [];
return folder.children
.filter(c => c instanceof TFolder)
.map(f => f.name);
}
renderSuggestion(item: string, el: HTMLElement): void {
el.setText(item);
}
selectSuggestion(item: string, _: MouseEvent | KeyboardEvent): void {
this.setValue(item);
this.textInputEl.dispatchEvent(new Event('input'));
}
}