Skip to content

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

PropertyTypeDescription
inputElHTMLInputElementThe input the suggest completes.
shouldIncludeFile(file: TFile) => booleanDecides whether a file is offered.

Methods

MethodReturnsDescription
getSuggestions(query)TFile[]Gets the files matching the typed text.
renderSuggestion(file, el)voidRenders a file: its name as the title and its path as the note, the matched characters highlighted.
selectSuggestion(file, $event)voidPuts the file path into the input, dispatches an input event, then calls the onSelect callback.

Links to this page: