feat: add FormPickerModal for quick form selection
FuzzySuggestModal that lets users pick a form by name with fuzzy search. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f3207a8b64
commit
092c960a9c
1 changed files with 33 additions and 0 deletions
33
src/ui/form-picker-modal.ts
Normal file
33
src/ui/form-picker-modal.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { App, FuzzySuggestModal } from 'obsidian';
|
||||
import { FormDefinition } from '../types';
|
||||
|
||||
/**
|
||||
* A fuzzy search modal for selecting a form from the available definitions.
|
||||
*/
|
||||
export class FormPickerModal extends FuzzySuggestModal<FormDefinition> {
|
||||
private forms: FormDefinition[];
|
||||
private onChoose: (form: FormDefinition) => void;
|
||||
|
||||
constructor(
|
||||
app: App,
|
||||
forms: FormDefinition[],
|
||||
onChoose: (form: FormDefinition) => void,
|
||||
) {
|
||||
super(app);
|
||||
this.forms = forms;
|
||||
this.onChoose = onChoose;
|
||||
this.setPlaceholder('Pick a form...');
|
||||
}
|
||||
|
||||
getItems(): FormDefinition[] {
|
||||
return this.forms;
|
||||
}
|
||||
|
||||
getItemText(item: FormDefinition): string {
|
||||
return item.name;
|
||||
}
|
||||
|
||||
onChooseItem(item: FormDefinition): void {
|
||||
this.onChoose(item);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue