FileInputSuggest
Suggests the vault’s files in an <input>, matching the typed text fuzzily against the file path.
Each suggestion shows the file name as its title and the full path below it, with the matched characters highlighted in both. Picking one puts its path into the input and dispatches an input event, so a wrapping text component’s onChange fires.
Import:
import { FileInputSuggest } from '@mnaoumov/obsidian-lib/file-input-suggest';Signature:
export class FileInputSuggest extends AbstractInputSuggest<TFile>Extends: AbstractInputSuggest<TFile>
Constructor
new FileInputSuggest(app: App, inputEl: HTMLInputElement, options?: FileInputSuggestConstructorOptions)Creates a new file suggest.
Properties
| Property | Type | Description |
|---|---|---|
| inputEl | HTMLInputElement | The input the suggest completes. |
| shouldIncludeFile | (file: TFile) => boolean | Decides whether a file is offered. |
Methods
| Method | Returns | Description |
|---|---|---|
| getSuggestions(query) | TFile[] | Gets the files matching the typed text. |
| renderSuggestion(file, el) | void | Renders a file: its name as the title and its path as the note, the matched characters highlighted. |
| selectSuggestion(file, $event) | void | Puts the file path into the input, dispatches an input event, then calls the onSelect callback. |
Links to this page: